summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/backend
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2022-11-09 17:58:10 +0100
committerFernando Sahmkow <fsahmkow27@gmail.com>2023-01-01 22:43:57 +0100
commitaad0cbf024fb8077a9b375a093c60a7e2ab1db3d (patch)
tree8c6a86c92ed8cedbafb5f34dd9f72283eaaf4342 /src/shader_recompiler/backend
parentMacroHLE: Add Index Buffer size estimation. (diff)
downloadyuzu-aad0cbf024fb8077a9b375a093c60a7e2ab1db3d.tar
yuzu-aad0cbf024fb8077a9b375a093c60a7e2ab1db3d.tar.gz
yuzu-aad0cbf024fb8077a9b375a093c60a7e2ab1db3d.tar.bz2
yuzu-aad0cbf024fb8077a9b375a093c60a7e2ab1db3d.tar.lz
yuzu-aad0cbf024fb8077a9b375a093c60a7e2ab1db3d.tar.xz
yuzu-aad0cbf024fb8077a9b375a093c60a7e2ab1db3d.tar.zst
yuzu-aad0cbf024fb8077a9b375a093c60a7e2ab1db3d.zip
Diffstat (limited to 'src/shader_recompiler/backend')
-rw-r--r--src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp8
-rw-r--r--src/shader_recompiler/backend/spirv/spirv_emit_context.cpp10
2 files changed, 18 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp
index 73b67f0af..e4802bf9e 100644
--- a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp
+++ b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp
@@ -339,6 +339,10 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, Id vertex) {
const Id base{ctx.OpLoad(ctx.U32[1], ctx.base_vertex)};
return ctx.OpBitcast(ctx.F32[1], ctx.OpISub(ctx.U32[1], index, base));
}
+ case IR::Attribute::BaseInstance:
+ return ctx.OpBitcast(ctx.F32[1], ctx.OpLoad(ctx.U32[1], ctx.base_instance));
+ case IR::Attribute::BaseVertex:
+ return ctx.OpBitcast(ctx.F32[1], ctx.OpLoad(ctx.U32[1], ctx.base_vertex));
case IR::Attribute::FrontFace:
return ctx.OpSelect(ctx.F32[1], ctx.OpLoad(ctx.U1, ctx.front_face),
ctx.OpBitcast(ctx.F32[1], ctx.Const(std::numeric_limits<u32>::max())),
@@ -380,6 +384,10 @@ Id EmitGetAttributeU32(EmitContext& ctx, IR::Attribute attr, Id) {
const Id base{ctx.OpLoad(ctx.U32[1], ctx.base_vertex)};
return ctx.OpISub(ctx.U32[1], index, base);
}
+ case IR::Attribute::BaseInstance:
+ return ctx.OpLoad(ctx.U32[1], ctx.base_instance);
+ case IR::Attribute::BaseVertex:
+ return ctx.OpLoad(ctx.U32[1], ctx.base_vertex);
default:
throw NotImplementedException("Read U32 attribute {}", attr);
}
diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp
index 41dc6d031..563a5fc49 100644
--- a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp
+++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp
@@ -1379,18 +1379,28 @@ void EmitContext::DefineInputs(const IR::Program& program) {
if (loads[IR::Attribute::InstanceId]) {
if (profile.support_vertex_instance_id) {
instance_id = DefineInput(*this, U32[1], true, spv::BuiltIn::InstanceId);
+ if (loads[IR::Attribute::BaseInstance]) {
+ base_instance = DefineInput(*this, U32[1], true, spv::BuiltIn::BaseVertex);
+ }
} else {
instance_index = DefineInput(*this, U32[1], true, spv::BuiltIn::InstanceIndex);
base_instance = DefineInput(*this, U32[1], true, spv::BuiltIn::BaseInstance);
}
+ } else if (loads[IR::Attribute::BaseInstance]) {
+ base_instance = DefineInput(*this, U32[1], true, spv::BuiltIn::BaseInstance);
}
if (loads[IR::Attribute::VertexId]) {
if (profile.support_vertex_instance_id) {
vertex_id = DefineInput(*this, U32[1], true, spv::BuiltIn::VertexId);
+ if (loads[IR::Attribute::BaseVertex]) {
+ base_vertex = DefineInput(*this, U32[1], true, spv::BuiltIn::BaseVertex);
+ }
} else {
vertex_index = DefineInput(*this, U32[1], true, spv::BuiltIn::VertexIndex);
base_vertex = DefineInput(*this, U32[1], true, spv::BuiltIn::BaseVertex);
}
+ } else if (loads[IR::Attribute::BaseVertex]) {
+ base_vertex = DefineInput(*this, U32[1], true, spv::BuiltIn::BaseVertex);
}
if (loads[IR::Attribute::FrontFace]) {
front_face = DefineInput(*this, U1, true, spv::BuiltIn::FrontFacing);