mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-05-26 21:47:06 +02:00
hotfix-performance: lizzie/togleless-approach-tomo32 (#3975)
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3975
This commit is contained in:
parent
4234d0cefd
commit
7eb6c8306e
3 changed files with 22 additions and 44 deletions
|
|
@ -462,6 +462,13 @@ void SetupCapabilities(const Profile& profile, const Info& info, EmitContext& ct
|
||||||
ctx.AddCapability(spv::Capability::ImageGatherExtended);
|
ctx.AddCapability(spv::Capability::ImageGatherExtended);
|
||||||
ctx.AddCapability(spv::Capability::ImageQuery);
|
ctx.AddCapability(spv::Capability::ImageQuery);
|
||||||
ctx.AddCapability(spv::Capability::SampledBuffer);
|
ctx.AddCapability(spv::Capability::SampledBuffer);
|
||||||
|
// TODO: this usage needs to be tracked properly
|
||||||
|
if (ctx.profile.support_sampled_image_array_nonuniform_indexing) {
|
||||||
|
if (ctx.profile.supported_spirv < 0x00010400)
|
||||||
|
ctx.AddExtension("SPV_EXT_descriptor_indexing");
|
||||||
|
ctx.AddCapability(spv::Capability::ShaderNonUniform);
|
||||||
|
ctx.AddCapability(spv::Capability::SampledImageArrayNonUniformIndexing);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PatchPhiNodes(IR::Program& program, EmitContext& ctx) {
|
void PatchPhiNodes(IR::Program& program, EmitContext& ctx) {
|
||||||
|
|
|
||||||
|
|
@ -14,37 +14,10 @@
|
||||||
|
|
||||||
namespace Shader::Backend::SPIRV {
|
namespace Shader::Backend::SPIRV {
|
||||||
namespace {
|
namespace {
|
||||||
class DescriptorIndex {
|
|
||||||
public:
|
|
||||||
explicit DescriptorIndex(EmitContext& ctx, const IR::Value& index)
|
|
||||||
: id{index.IsImmediate() ? ctx.Const(index.U32()) : ctx.Def(index)},
|
|
||||||
is_non_uniform{ctx.profile.support_sampled_image_array_nonuniform_indexing &&
|
|
||||||
!index.IsImmediate()} {
|
|
||||||
if (!is_non_uniform) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (ctx.profile.supported_spirv < 0x00010400) {
|
|
||||||
ctx.AddExtension("SPV_EXT_descriptor_indexing");
|
|
||||||
}
|
|
||||||
ctx.AddCapability(spv::Capability::ShaderNonUniform);
|
|
||||||
ctx.AddCapability(spv::Capability::SampledImageArrayNonUniformIndexing);
|
|
||||||
Decorate(ctx, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
Id Value() const {
|
[[nodiscard]] bool IsNonUniformDescriptor(EmitContext& ctx, const IR::Value& index) noexcept {
|
||||||
return id;
|
return ctx.profile.support_sampled_image_array_nonuniform_indexing && !index.IsImmediate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Decorate(EmitContext& ctx, Id object) const {
|
|
||||||
if (is_non_uniform) {
|
|
||||||
ctx.Decorate(object, spv::Decoration::NonUniform);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Id id;
|
|
||||||
bool is_non_uniform;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ImageOperands {
|
class ImageOperands {
|
||||||
public:
|
public:
|
||||||
|
|
@ -221,11 +194,11 @@ private:
|
||||||
Id Texture(EmitContext& ctx, IR::TextureInstInfo info, [[maybe_unused]] const IR::Value& index) {
|
Id Texture(EmitContext& ctx, IR::TextureInstInfo info, [[maybe_unused]] const IR::Value& index) {
|
||||||
const TextureDefinition& def{ctx.textures.at(info.descriptor_index)};
|
const TextureDefinition& def{ctx.textures.at(info.descriptor_index)};
|
||||||
if (def.count > 1) {
|
if (def.count > 1) {
|
||||||
const DescriptorIndex idx{ctx, index};
|
auto const idx = index.IsImmediate() ? ctx.Const(index.U32()) : ctx.Def(index);
|
||||||
const Id pointer{ctx.OpAccessChain(def.pointer_type, def.id, idx.Value())};
|
const Id pointer{ctx.OpAccessChain(def.pointer_type, def.id, idx)};
|
||||||
idx.Decorate(ctx, pointer);
|
|
||||||
const Id object{ctx.OpLoad(def.sampled_type, pointer)};
|
const Id object{ctx.OpLoad(def.sampled_type, pointer)};
|
||||||
idx.Decorate(ctx, object);
|
if (IsNonUniformDescriptor(ctx, index))
|
||||||
|
ctx.Decorate(idx, spv::Decoration::NonUniform);
|
||||||
return object;
|
return object;
|
||||||
} else {
|
} else {
|
||||||
return ctx.OpLoad(def.sampled_type, def.id);
|
return ctx.OpLoad(def.sampled_type, def.id);
|
||||||
|
|
@ -244,13 +217,12 @@ Id TextureImage(EmitContext& ctx, IR::TextureInstInfo info, const IR::Value& ind
|
||||||
} else {
|
} else {
|
||||||
const TextureDefinition& def{ctx.textures.at(info.descriptor_index)};
|
const TextureDefinition& def{ctx.textures.at(info.descriptor_index)};
|
||||||
if (def.count > 1) {
|
if (def.count > 1) {
|
||||||
const DescriptorIndex idx{ctx, index};
|
auto const idx = index.IsImmediate() ? ctx.Const(index.U32()) : ctx.Def(index);
|
||||||
const Id ptr{ctx.OpAccessChain(def.pointer_type, def.id, idx.Value())};
|
const Id ptr = ctx.OpAccessChain(def.pointer_type, def.id, idx);
|
||||||
idx.Decorate(ctx, ptr);
|
const Id object = ctx.OpLoad(def.sampled_type, ptr);
|
||||||
const Id object{ctx.OpLoad(def.sampled_type, ptr)};
|
const Id image = ctx.OpImage(def.image_type, object);
|
||||||
idx.Decorate(ctx, object);
|
if (IsNonUniformDescriptor(ctx, index))
|
||||||
const Id image{ctx.OpImage(def.image_type, object)};
|
ctx.Decorate(idx, spv::Decoration::NonUniform);
|
||||||
idx.Decorate(ctx, image);
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
return ctx.OpImage(def.image_type, ctx.OpLoad(def.sampled_type, def.id));
|
return ctx.OpImage(def.image_type, ctx.OpLoad(def.sampled_type, def.id));
|
||||||
|
|
|
||||||
|
|
@ -733,9 +733,8 @@ void TexturePass(Environment& env, IR::Program& program, const HostTranslateInfo
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
u32 index;
|
u32 index;
|
||||||
const u32 size_shift{cbuf.count > 1 ? DynamicDescriptorSizeShift(cbuf.dynamic_offset)
|
u32 size_shift = cbuf.count > 1 ? DynamicDescriptorSizeShift(cbuf.dynamic_offset) : DESCRIPTOR_SIZE_SHIFT;
|
||||||
: DESCRIPTOR_SIZE_SHIFT};
|
u32 count = cbuf.count;
|
||||||
u32 count{cbuf.count};
|
|
||||||
switch (inst->GetOpcode()) {
|
switch (inst->GetOpcode()) {
|
||||||
case IR::Opcode::ImageRead:
|
case IR::Opcode::ImageRead:
|
||||||
case IR::Opcode::ImageAtomicIAdd32:
|
case IR::Opcode::ImageAtomicIAdd32:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue