mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-07-01 07:05:44 +02:00
[shader_recompiler] add 'legacy descriptor indices' toggle for tomodachi
Signed-off-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
parent
4d49341918
commit
a99cc426d6
3 changed files with 34 additions and 20 deletions
|
|
@ -591,6 +591,8 @@ struct Values {
|
||||||
SwitchableSetting<bool> gpu_unswizzle_enabled{linkage, false, "gpu_unswizzle_enabled",
|
SwitchableSetting<bool> gpu_unswizzle_enabled{linkage, false, "gpu_unswizzle_enabled",
|
||||||
Category::RendererHacks};
|
Category::RendererHacks};
|
||||||
|
|
||||||
|
SwitchableSetting<bool> legacy_descriptor_indices{linkage, true, "legacy_descriptor_indices", Category::RendererHacks};
|
||||||
|
|
||||||
SwitchableSetting<ExtendedDynamicState> dyna_state{linkage,
|
SwitchableSetting<ExtendedDynamicState> dyna_state{linkage,
|
||||||
#if defined(ANDROID)
|
#if defined(ANDROID)
|
||||||
ExtendedDynamicState::Disabled,
|
ExtendedDynamicState::Disabled,
|
||||||
|
|
|
||||||
|
|
@ -221,12 +221,17 @@ 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};
|
if (Settings::values.legacy_descriptor_indices.GetValue()) {
|
||||||
const Id pointer{ctx.OpAccessChain(def.pointer_type, def.id, idx.Value())};
|
const Id pointer{ctx.OpAccessChain(def.pointer_type, def.id, ctx.Def(index))};
|
||||||
idx.Decorate(ctx, pointer);
|
return ctx.OpLoad(def.sampled_type, pointer);
|
||||||
const Id object{ctx.OpLoad(def.sampled_type, pointer)};
|
} else {
|
||||||
idx.Decorate(ctx, object);
|
const DescriptorIndex idx{ctx, index};
|
||||||
return object;
|
const Id pointer{ctx.OpAccessChain(def.pointer_type, def.id, idx.Value())};
|
||||||
|
idx.Decorate(ctx, pointer);
|
||||||
|
const Id object{ctx.OpLoad(def.sampled_type, pointer)};
|
||||||
|
idx.Decorate(ctx, object);
|
||||||
|
return object;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return ctx.OpLoad(def.sampled_type, def.id);
|
return ctx.OpLoad(def.sampled_type, def.id);
|
||||||
}
|
}
|
||||||
|
|
@ -244,14 +249,20 @@ 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};
|
if (Settings::values.legacy_descriptor_indices.GetValue()) {
|
||||||
const Id ptr{ctx.OpAccessChain(def.pointer_type, def.id, idx.Value())};
|
const Id idx{index.IsImmediate() ? ctx.Const(index.U32()) : ctx.Def(index)};
|
||||||
idx.Decorate(ctx, ptr);
|
const Id ptr{ctx.OpAccessChain(def.pointer_type, def.id, idx)};
|
||||||
const Id object{ctx.OpLoad(def.sampled_type, ptr)};
|
return ctx.OpImage(def.image_type, ctx.OpLoad(def.sampled_type, ptr));
|
||||||
idx.Decorate(ctx, object);
|
} else {
|
||||||
const Id image{ctx.OpImage(def.image_type, object)};
|
const DescriptorIndex idx{ctx, index};
|
||||||
idx.Decorate(ctx, image);
|
const Id ptr{ctx.OpAccessChain(def.pointer_type, def.id, idx.Value())};
|
||||||
return image;
|
idx.Decorate(ctx, ptr);
|
||||||
|
const Id object{ctx.OpLoad(def.sampled_type, ptr)};
|
||||||
|
idx.Decorate(ctx, object);
|
||||||
|
const Id image{ctx.OpImage(def.image_type, object)};
|
||||||
|
idx.Decorate(ctx, 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));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <boost/container/small_vector.hpp>
|
#include <boost/container/small_vector.hpp>
|
||||||
|
|
||||||
|
#include "common/settings.h"
|
||||||
#include "shader_recompiler/environment.h"
|
#include "shader_recompiler/environment.h"
|
||||||
#include "shader_recompiler/frontend/ir/basic_block.h"
|
#include "shader_recompiler/frontend/ir/basic_block.h"
|
||||||
#include "shader_recompiler/frontend/ir/breadth_first_search.h"
|
#include "shader_recompiler/frontend/ir/breadth_first_search.h"
|
||||||
|
|
@ -461,7 +462,7 @@ std::optional<ConstBufferAddr> TryGetConstBuffer(const IR::Inst* inst, Environme
|
||||||
.secondary_offset = 0,
|
.secondary_offset = 0,
|
||||||
.secondary_shift_left = 0,
|
.secondary_shift_left = 0,
|
||||||
.dynamic_offset = dynamic_offset,
|
.dynamic_offset = dynamic_offset,
|
||||||
.count = DynamicDescriptorCount(base_offset, size_shift),
|
.count = Settings::values.legacy_descriptor_indices.GetValue() ? 8 : DynamicDescriptorCount(base_offset, size_shift),
|
||||||
.has_secondary = false,
|
.has_secondary = false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -733,9 +734,10 @@ 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};
|
if (Settings::values.legacy_descriptor_indices.GetValue())
|
||||||
u32 count{cbuf.count};
|
size_shift = DESCRIPTOR_SIZE_SHIFT;
|
||||||
|
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:
|
||||||
|
|
@ -821,8 +823,7 @@ void TexturePass(Environment& env, IR::Program& program, const HostTranslateInfo
|
||||||
const auto insert_point{IR::Block::InstructionList::s_iterator_to(*inst)};
|
const auto insert_point{IR::Block::InstructionList::s_iterator_to(*inst)};
|
||||||
IR::IREmitter ir{*texture_inst.block, insert_point};
|
IR::IREmitter ir{*texture_inst.block, insert_point};
|
||||||
const IR::U32 shift{ir.Imm32(size_shift)};
|
const IR::U32 shift{ir.Imm32(size_shift)};
|
||||||
inst->SetArg(0, ir.UMin(ir.ShiftRightLogical(cbuf.dynamic_offset, shift),
|
inst->SetArg(0, ir.UMin(ir.ShiftRightLogical(cbuf.dynamic_offset, shift), ir.Imm32(count - 1)));
|
||||||
ir.Imm32(count - 1)));
|
|
||||||
} else {
|
} else {
|
||||||
inst->SetArg(0, IR::Value{});
|
inst->SetArg(0, IR::Value{});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue