diff options
Diffstat (limited to 'src/shader_recompiler/backend')
5 files changed, 14 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm.cpp b/src/shader_recompiler/backend/glasm/emit_glasm.cpp index 3b0176bf6..0cb1e193e 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm.cpp | |||
| @@ -320,6 +320,7 @@ void SetupOptions(const IR::Program& program, const Profile& profile, | |||
| 320 | } | 320 | } |
| 321 | if (stage == Stage::Fragment) { | 321 | if (stage == Stage::Fragment) { |
| 322 | header += "OPTION ARB_draw_buffers;"; | 322 | header += "OPTION ARB_draw_buffers;"; |
| 323 | header += "OPTION ARB_fragment_layer_viewport;"; | ||
| 323 | } | 324 | } |
| 324 | } | 325 | } |
| 325 | 326 | ||
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 d6562c842..f0bd84ab2 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 | |||
| @@ -104,6 +104,9 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, Scal | |||
| 104 | case IR::Attribute::PrimitiveId: | 104 | case IR::Attribute::PrimitiveId: |
| 105 | ctx.Add("MOV.F {}.x,primitive.id;", inst); | 105 | ctx.Add("MOV.F {}.x,primitive.id;", inst); |
| 106 | break; | 106 | break; |
| 107 | case IR::Attribute::Layer: | ||
| 108 | ctx.Add("MOV.F {}.x,fragment.layer;", inst); | ||
| 109 | break; | ||
| 107 | case IR::Attribute::PositionX: | 110 | case IR::Attribute::PositionX: |
| 108 | case IR::Attribute::PositionY: | 111 | case IR::Attribute::PositionY: |
| 109 | case IR::Attribute::PositionZ: | 112 | case IR::Attribute::PositionZ: |
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 c1671c37b..39579cf5d 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 | |||
| @@ -205,6 +205,9 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, | |||
| 205 | case IR::Attribute::PrimitiveId: | 205 | case IR::Attribute::PrimitiveId: |
| 206 | ctx.AddF32("{}=itof(gl_PrimitiveID);", inst); | 206 | ctx.AddF32("{}=itof(gl_PrimitiveID);", inst); |
| 207 | break; | 207 | break; |
| 208 | case IR::Attribute::Layer: | ||
| 209 | ctx.AddF32("{}=itof(gl_Layer);", inst); | ||
| 210 | break; | ||
| 208 | case IR::Attribute::PositionX: | 211 | case IR::Attribute::PositionX: |
| 209 | case IR::Attribute::PositionY: | 212 | case IR::Attribute::PositionY: |
| 210 | case IR::Attribute::PositionZ: | 213 | case IR::Attribute::PositionZ: |
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 5b3b5d1f3..01f6ec9b5 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 | |||
| @@ -315,6 +315,8 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, Id vertex) { | |||
| 315 | switch (attr) { | 315 | switch (attr) { |
| 316 | case IR::Attribute::PrimitiveId: | 316 | case IR::Attribute::PrimitiveId: |
| 317 | return ctx.OpBitcast(ctx.F32[1], ctx.OpLoad(ctx.U32[1], ctx.primitive_id)); | 317 | return ctx.OpBitcast(ctx.F32[1], ctx.OpLoad(ctx.U32[1], ctx.primitive_id)); |
| 318 | case IR::Attribute::Layer: | ||
| 319 | return ctx.OpBitcast(ctx.F32[1], ctx.OpLoad(ctx.U32[1], ctx.layer)); | ||
| 318 | case IR::Attribute::PositionX: | 320 | case IR::Attribute::PositionX: |
| 319 | case IR::Attribute::PositionY: | 321 | case IR::Attribute::PositionY: |
| 320 | case IR::Attribute::PositionZ: | 322 | case IR::Attribute::PositionZ: |
diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp index 0bfc2dd89..8e3e40cd5 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp | |||
| @@ -1359,6 +1359,11 @@ void EmitContext::DefineInputs(const IR::Program& program) { | |||
| 1359 | if (loads[IR::Attribute::PrimitiveId]) { | 1359 | if (loads[IR::Attribute::PrimitiveId]) { |
| 1360 | primitive_id = DefineInput(*this, U32[1], false, spv::BuiltIn::PrimitiveId); | 1360 | primitive_id = DefineInput(*this, U32[1], false, spv::BuiltIn::PrimitiveId); |
| 1361 | } | 1361 | } |
| 1362 | if (loads[IR::Attribute::Layer]) { | ||
| 1363 | AddCapability(spv::Capability::Geometry); | ||
| 1364 | layer = DefineInput(*this, U32[1], false, spv::BuiltIn::Layer); | ||
| 1365 | Decorate(layer, spv::Decoration::Flat); | ||
| 1366 | } | ||
| 1362 | if (loads.AnyComponent(IR::Attribute::PositionX)) { | 1367 | if (loads.AnyComponent(IR::Attribute::PositionX)) { |
| 1363 | const bool is_fragment{stage != Stage::Fragment}; | 1368 | const bool is_fragment{stage != Stage::Fragment}; |
| 1364 | const spv::BuiltIn built_in{is_fragment ? spv::BuiltIn::Position : spv::BuiltIn::FragCoord}; | 1369 | const spv::BuiltIn built_in{is_fragment ? spv::BuiltIn::Position : spv::BuiltIn::FragCoord}; |