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 c27f2e3..5eaba89 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 @@ -428,6 +428,10 @@ void EmitSR_WScaleFactorXY(EmitContext& ctx, IR::Inst& inst) { LOG_WARNING(Shader, "(STUBBED) called"); } +void EmitSR_WScaleFactorZ(EmitContext& ctx, IR::Inst& inst) { + LOG_WARNING(Shader, "(STUBBED) called"); +} + void EmitYDirection(EmitContext& ctx, IR::Inst& inst) { ctx.uses_y_direction = true; ctx.Add("MOV.F {}.x,y_direction[0].w;", inst); diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h b/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h index 42ae9b4..22542f2 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h +++ b/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h @@ -73,6 +73,7 @@ void EmitInvocationInfo(EmitContext& ctx, IR::Inst& inst); void EmitSampleId(EmitContext& ctx, IR::Inst& inst); void EmitIsHelperInvocation(EmitContext& ctx, IR::Inst& inst); void EmitSR_WScaleFactorXY(EmitContext& ctx, IR::Inst& inst); +void EmitSR_WScaleFactorZ(EmitContext& ctx, IR::Inst& inst); void EmitYDirection(EmitContext& ctx, IR::Inst& inst); void EmitResolutionDownFactor(EmitContext& ctx, IR::Inst& inst); void EmitRenderArea(EmitContext& ctx, IR::Inst& inst); 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 31a7ea1..b940a9d 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 @@ -428,7 +428,7 @@ void EmitInvocationInfo(EmitContext& ctx, IR::Inst& inst) { break; case Stage::Geometry: ctx.AddU32("{}=uint({}<<16);", inst, - InputTopologyVertices::vertices(ctx.runtime_info.input_topology)); + InputTopologyVertices::vertices(ctx.runtime_info.input_topology)); break; default: LOG_WARNING(Shader, "(STUBBED) called"); @@ -448,6 +448,10 @@ void EmitSR_WScaleFactorXY(EmitContext& ctx, IR::Inst& inst) { LOG_WARNING(Shader, "(STUBBED) called"); } +void EmitSR_WScaleFactorZ(EmitContext& ctx, IR::Inst& inst) { + LOG_WARNING(Shader, "(STUBBED) called"); +} + void EmitYDirection(EmitContext& ctx, IR::Inst& inst) { ctx.uses_y_direction = true; ctx.AddF32("{}=gl_FrontMaterial.ambient.a;", inst); diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h b/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h index 8e135c2..8638ad9 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h +++ b/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h @@ -87,6 +87,7 @@ void EmitInvocationInfo(EmitContext& ctx, IR::Inst& inst); void EmitSampleId(EmitContext& ctx, IR::Inst& inst); void EmitIsHelperInvocation(EmitContext& ctx, IR::Inst& inst); void EmitSR_WScaleFactorXY(EmitContext& ctx, IR::Inst& inst); +void EmitSR_WScaleFactorZ(EmitContext& ctx, IR::Inst& inst); void EmitYDirection(EmitContext& ctx, IR::Inst& inst); void EmitResolutionDownFactor(EmitContext& ctx, IR::Inst& inst); void EmitRenderArea(EmitContext& ctx, IR::Inst& inst); 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 39cc401..a7ad318 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 @@ -570,6 +570,11 @@ Id EmitSR_WScaleFactorXY(EmitContext& ctx) { return ctx.Const(0x00ff0000u); } +Id EmitSR_WScaleFactorZ(EmitContext& ctx) { + LOG_WARNING(Shader, "(STUBBED) called"); + return ctx.Const(0x00ff0000u); +} + Id EmitYDirection(EmitContext& ctx) { return ctx.Const(ctx.runtime_info.y_negate ? -1.0f : 1.0f); } diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h index 05cda37..57202f3 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h +++ b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h @@ -76,6 +76,7 @@ Id EmitInvocationInfo(EmitContext& ctx); Id EmitSampleId(EmitContext& ctx); Id EmitIsHelperInvocation(EmitContext& ctx); Id EmitSR_WScaleFactorXY(EmitContext& ctx); +Id EmitSR_WScaleFactorZ(EmitContext& ctx); Id EmitYDirection(EmitContext& ctx); Id EmitResolutionDownFactor(EmitContext& ctx); Id EmitRenderArea(EmitContext& ctx); diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.cpp b/src/shader_recompiler/frontend/ir/ir_emitter.cpp index ba81c6b..667d992 100644 --- a/src/shader_recompiler/frontend/ir/ir_emitter.cpp +++ b/src/shader_recompiler/frontend/ir/ir_emitter.cpp @@ -386,6 +386,10 @@ U32 IREmitter::SR_WScaleFactorXY() { return Inst(Opcode::SR_WScaleFactorXY); } +U32 IREmitter::SR_WScaleFactorZ() { + return Inst(Opcode::SR_WScaleFactorZ); +} + F32 IREmitter::YDirection() { return Inst(Opcode::YDirection); } diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.h b/src/shader_recompiler/frontend/ir/ir_emitter.h index 736bea8..d701c9f 100644 --- a/src/shader_recompiler/frontend/ir/ir_emitter.h +++ b/src/shader_recompiler/frontend/ir/ir_emitter.h @@ -103,6 +103,7 @@ public: [[nodiscard]] U32 SampleId(); [[nodiscard]] U1 IsHelperInvocation(); [[nodiscard]] U32 SR_WScaleFactorXY(); + [[nodiscard]] U32 SR_WScaleFactorZ(); [[nodiscard]] F32 YDirection(); [[nodiscard]] F32 ResolutionDownFactor(); diff --git a/src/shader_recompiler/frontend/ir/opcodes.inc b/src/shader_recompiler/frontend/ir/opcodes.inc index 1b368dc..a62c299 100644 --- a/src/shader_recompiler/frontend/ir/opcodes.inc +++ b/src/shader_recompiler/frontend/ir/opcodes.inc @@ -63,6 +63,7 @@ OPCODE(InvocationInfo, U32, OPCODE(SampleId, U32, ) OPCODE(IsHelperInvocation, U1, ) OPCODE(SR_WScaleFactorXY, U32, ) +OPCODE(SR_WScaleFactorZ, U32, ) OPCODE(YDirection, F32, ) OPCODE(ResolutionDownFactor, F32, ) OPCODE(RenderArea, F32x4, ) diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/move_special_register.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/move_special_register.cpp index c48ac77..05cc24a 100644 --- a/src/shader_recompiler/frontend/maxwell/translate/impl/move_special_register.cpp +++ b/src/shader_recompiler/frontend/maxwell/translate/impl/move_special_register.cpp @@ -142,7 +142,7 @@ enum class SpecialRegister : u64 { return ir.SR_WScaleFactorXY(); case SpecialRegister::SR_WSCALEFACTOR_Z: LOG_WARNING(Shader, "(STUBBED) SR_WSCALEFACTOR_Z"); - return ir.Imm32(Common::BitCast(1.0f)); + return ir.SR_WScaleFactorZ(); case SpecialRegister::SR_LANEID: return ir.LaneId(); case SpecialRegister::SR_EQMASK: