diff options
Diffstat (limited to 'src/shader_recompiler/backend')
5 files changed, 32 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp index f0bd84ab2..c7d7d5fef 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp | |||
| @@ -137,6 +137,15 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, Scal | |||
| 137 | case IR::Attribute::VertexId: | 137 | case IR::Attribute::VertexId: |
| 138 | ctx.Add("MOV.F {}.x,{}.id;", inst, ctx.attrib_name); | 138 | ctx.Add("MOV.F {}.x,{}.id;", inst, ctx.attrib_name); |
| 139 | break; | 139 | break; |
| 140 | case IR::Attribute::BaseInstance: | ||
| 141 | ctx.Add("MOV.F {}.x,{}.baseInstance;", inst, ctx.attrib_name); | ||
| 142 | break; | ||
| 143 | case IR::Attribute::BaseVertex: | ||
| 144 | ctx.Add("MOV.F {}.x,{}.baseVertex;", inst, ctx.attrib_name); | ||
| 145 | break; | ||
| 146 | case IR::Attribute::DrawID: | ||
| 147 | ctx.Add("MOV.F {}.x,{}.draw.id;", inst, ctx.attrib_name); | ||
| 148 | break; | ||
| 140 | case IR::Attribute::FrontFace: | 149 | case IR::Attribute::FrontFace: |
| 141 | ctx.Add("CMP.F {}.x,{}.facing.x,0,-1;", inst, ctx.attrib_name); | 150 | ctx.Add("CMP.F {}.x,{}.facing.x,0,-1;", inst, ctx.attrib_name); |
| 142 | break; | 151 | break; |
| @@ -156,6 +165,15 @@ void EmitGetAttributeU32(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, S | |||
| 156 | case IR::Attribute::VertexId: | 165 | case IR::Attribute::VertexId: |
| 157 | ctx.Add("MOV.S {}.x,{}.id;", inst, ctx.attrib_name); | 166 | ctx.Add("MOV.S {}.x,{}.id;", inst, ctx.attrib_name); |
| 158 | break; | 167 | break; |
| 168 | case IR::Attribute::BaseInstance: | ||
| 169 | ctx.Add("MOV.S {}.x,{}.baseInstance;", inst, ctx.attrib_name); | ||
| 170 | break; | ||
| 171 | case IR::Attribute::BaseVertex: | ||
| 172 | ctx.Add("MOV.S {}.x,{}.baseVertex;", inst, ctx.attrib_name); | ||
| 173 | break; | ||
| 174 | case IR::Attribute::DrawID: | ||
| 175 | ctx.Add("MOV.S {}.x,{}.draw.id;", inst, ctx.attrib_name); | ||
| 176 | break; | ||
| 159 | default: | 177 | default: |
| 160 | throw NotImplementedException("Get U32 attribute {}", attr); | 178 | throw NotImplementedException("Get U32 attribute {}", attr); |
| 161 | } | 179 | } |
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp index 25106da67..2e369ed72 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp | |||
| @@ -240,6 +240,9 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, | |||
| 240 | case IR::Attribute::BaseVertex: | 240 | case IR::Attribute::BaseVertex: |
| 241 | ctx.AddF32("{}=itof(gl_BaseVertex);", inst); | 241 | ctx.AddF32("{}=itof(gl_BaseVertex);", inst); |
| 242 | break; | 242 | break; |
| 243 | case IR::Attribute::DrawID: | ||
| 244 | ctx.AddF32("{}=itof(gl_DrawID);", inst); | ||
| 245 | break; | ||
| 243 | default: | 246 | default: |
| 244 | throw NotImplementedException("Get attribute {}", attr); | 247 | throw NotImplementedException("Get attribute {}", attr); |
| 245 | } | 248 | } |
| @@ -262,6 +265,9 @@ void EmitGetAttributeU32(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, s | |||
| 262 | case IR::Attribute::BaseVertex: | 265 | case IR::Attribute::BaseVertex: |
| 263 | ctx.AddU32("{}=uint(gl_BaseVertex);", inst); | 266 | ctx.AddU32("{}=uint(gl_BaseVertex);", inst); |
| 264 | break; | 267 | break; |
| 268 | case IR::Attribute::DrawID: | ||
| 269 | ctx.AddU32("{}=uint(gl_DrawID);", inst); | ||
| 270 | break; | ||
| 265 | default: | 271 | default: |
| 266 | throw NotImplementedException("Get U32 attribute {}", attr); | 272 | throw NotImplementedException("Get U32 attribute {}", attr); |
| 267 | } | 273 | } |
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 e4802bf9e..db9c94ce8 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 | |||
| @@ -343,6 +343,8 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, Id vertex) { | |||
| 343 | return ctx.OpBitcast(ctx.F32[1], ctx.OpLoad(ctx.U32[1], ctx.base_instance)); | 343 | return ctx.OpBitcast(ctx.F32[1], ctx.OpLoad(ctx.U32[1], ctx.base_instance)); |
| 344 | case IR::Attribute::BaseVertex: | 344 | case IR::Attribute::BaseVertex: |
| 345 | return ctx.OpBitcast(ctx.F32[1], ctx.OpLoad(ctx.U32[1], ctx.base_vertex)); | 345 | return ctx.OpBitcast(ctx.F32[1], ctx.OpLoad(ctx.U32[1], ctx.base_vertex)); |
| 346 | case IR::Attribute::DrawID: | ||
| 347 | return ctx.OpBitcast(ctx.F32[1], ctx.OpLoad(ctx.U32[1], ctx.draw_index)); | ||
| 346 | case IR::Attribute::FrontFace: | 348 | case IR::Attribute::FrontFace: |
| 347 | return ctx.OpSelect(ctx.F32[1], ctx.OpLoad(ctx.U1, ctx.front_face), | 349 | return ctx.OpSelect(ctx.F32[1], ctx.OpLoad(ctx.U1, ctx.front_face), |
| 348 | ctx.OpBitcast(ctx.F32[1], ctx.Const(std::numeric_limits<u32>::max())), | 350 | ctx.OpBitcast(ctx.F32[1], ctx.Const(std::numeric_limits<u32>::max())), |
| @@ -388,6 +390,8 @@ Id EmitGetAttributeU32(EmitContext& ctx, IR::Attribute attr, Id) { | |||
| 388 | return ctx.OpLoad(ctx.U32[1], ctx.base_instance); | 390 | return ctx.OpLoad(ctx.U32[1], ctx.base_instance); |
| 389 | case IR::Attribute::BaseVertex: | 391 | case IR::Attribute::BaseVertex: |
| 390 | return ctx.OpLoad(ctx.U32[1], ctx.base_vertex); | 392 | return ctx.OpLoad(ctx.U32[1], ctx.base_vertex); |
| 393 | case IR::Attribute::DrawID: | ||
| 394 | return ctx.OpLoad(ctx.U32[1], ctx.draw_index); | ||
| 391 | default: | 395 | default: |
| 392 | throw NotImplementedException("Read U32 attribute {}", attr); | 396 | throw NotImplementedException("Read U32 attribute {}", attr); |
| 393 | } | 397 | } |
diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp index 563a5fc49..ecb2db494 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp | |||
| @@ -1402,6 +1402,9 @@ void EmitContext::DefineInputs(const IR::Program& program) { | |||
| 1402 | } else if (loads[IR::Attribute::BaseVertex]) { | 1402 | } else if (loads[IR::Attribute::BaseVertex]) { |
| 1403 | base_vertex = DefineInput(*this, U32[1], true, spv::BuiltIn::BaseVertex); | 1403 | base_vertex = DefineInput(*this, U32[1], true, spv::BuiltIn::BaseVertex); |
| 1404 | } | 1404 | } |
| 1405 | if (loads[IR::Attribute::DrawID]) { | ||
| 1406 | draw_index = DefineInput(*this, U32[1], true, spv::BuiltIn::DrawIndex); | ||
| 1407 | } | ||
| 1405 | if (loads[IR::Attribute::FrontFace]) { | 1408 | if (loads[IR::Attribute::FrontFace]) { |
| 1406 | front_face = DefineInput(*this, U1, true, spv::BuiltIn::FrontFacing); | 1409 | front_face = DefineInput(*this, U1, true, spv::BuiltIn::FrontFacing); |
| 1407 | } | 1410 | } |
diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.h b/src/shader_recompiler/backend/spirv/spirv_emit_context.h index dde45b4bc..4414a5169 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.h +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.h | |||
| @@ -218,6 +218,7 @@ public: | |||
| 218 | Id base_instance{}; | 218 | Id base_instance{}; |
| 219 | Id vertex_id{}; | 219 | Id vertex_id{}; |
| 220 | Id vertex_index{}; | 220 | Id vertex_index{}; |
| 221 | Id draw_index{}; | ||
| 221 | Id base_vertex{}; | 222 | Id base_vertex{}; |
| 222 | Id front_face{}; | 223 | Id front_face{}; |
| 223 | Id point_coord{}; | 224 | Id point_coord{}; |