feat(shader-recompiler): add stubs for SR_WScaleFactorXY and SR_WScaleFactorZ

- Implemented stubs for `SR_WScaleFactorXY` and `SR_WScaleFactorZ` to handle scaling factors for X, Y, and Z dimensions in the shader recompiler.
- Placeholder logic for scaling factor fetching, allowing future extension for proper uniform or buffer access.
- Ensures compatibility with the GLSL backend by providing stubbed implementations for scaling factors.
This commit is contained in:
Phoenix 2024-09-08 13:28:45 +10:00
parent 86ea71d565
commit 1dd89a04ee
10 changed files with 52 additions and 2 deletions

View File

@ -429,6 +429,16 @@ void EmitIsHelperInvocation(EmitContext& ctx, IR::Inst& inst) {
ctx.Add("MOV.S {}.x,fragment.helperthread.x;", inst);
}
// Emit scaling factor for XY dimensions (stubbed)
void EmitSR_WScaleFactorXY(EmitContext& ctx, IR::Inst& inst) {
LOG_WARNING(Shader, "(STUBBED) called");
}
// Emit scaling factor for Z dimension (stubbed)
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);

View File

@ -71,6 +71,8 @@ void EmitLocalInvocationId(EmitContext& ctx, IR::Inst& inst);
void EmitInvocationId(EmitContext& ctx, IR::Inst& inst);
void EmitInvocationInfo(EmitContext& ctx, IR::Inst& inst);
void EmitSampleId(EmitContext& ctx, IR::Inst& inst);
void EmitSR_WScaleFactorXY(EmitContext& ctx, IR::Inst& inst);
void EmitSR_WScaleFactorZ(EmitContext& ctx, IR::Inst& inst);
void EmitIsHelperInvocation(EmitContext& ctx, IR::Inst& inst);
void EmitYDirection(EmitContext& ctx, IR::Inst& inst);
void EmitResolutionDownFactor(EmitContext& ctx, IR::Inst& inst);

View File

@ -450,6 +450,14 @@ void EmitIsHelperInvocation(EmitContext& ctx, IR::Inst& inst) {
ctx.AddU1("{}=gl_HelperInvocation;", inst);
}
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);

View File

@ -85,6 +85,8 @@ void EmitLocalInvocationId(EmitContext& ctx, IR::Inst& inst);
void EmitInvocationId(EmitContext& ctx, IR::Inst& inst);
void EmitInvocationInfo(EmitContext& ctx, IR::Inst& inst);
void EmitSampleId(EmitContext& ctx, IR::Inst& inst);
void EmitSR_WScaleFactorXY(EmitContext& ctx, IR::Inst& inst);
void EmitSR_WScaleFactorZ(EmitContext& ctx, IR::Inst& inst);
void EmitIsHelperInvocation(EmitContext& ctx, IR::Inst& inst);
void EmitYDirection(EmitContext& ctx, IR::Inst& inst);
void EmitResolutionDownFactor(EmitContext& ctx, IR::Inst& inst);

View File

@ -569,6 +569,20 @@ Id EmitIsHelperInvocation(EmitContext& ctx) {
return ctx.OpLoad(ctx.U1, ctx.is_helper_invocation);
}
Id EmitSR_WScaleFactorXY(EmitContext& ctx) {
// Stubbed function for fetching W scale factors (XY).
// Replace with actual implementation based on your system's logic.
LOG_WARNING(Shader, "EmitSR_WScaleFactorXY is stubbed");
return ctx.Const(1.0f); // Returns a default scale factor of 1.0 for stubbing purposes
}
Id EmitSR_WScaleFactorZ(EmitContext& ctx) {
// Stubbed function for fetching W scale factor (Z).
// Replace with actual implementation based on your system's logic.
LOG_WARNING(Shader, "EmitSR_WScaleFactorZ is stubbed");
return ctx.Const(1.0f); // Returns a default scale factor of 1.0 for stubbing purposes
}
Id EmitYDirection(EmitContext& ctx) {
return ctx.Const(ctx.runtime_info.y_negate ? -1.0f : 1.0f);
}

View File

@ -75,6 +75,8 @@ Id EmitInvocationId(EmitContext& ctx);
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);

View File

@ -382,6 +382,14 @@ U1 IREmitter::IsHelperInvocation() {
return Inst<U1>(Opcode::IsHelperInvocation);
}
U32 IREmitter::SR_WScaleFactorXY() {
return Inst<U32>(Opcode::SR_WScaleFactorXY);
}
U32 IREmitter::SR_WScaleFactorZ() {
return Inst<U32>(Opcode::SR_WScaleFactorZ);
}
F32 IREmitter::YDirection() {
return Inst<F32>(Opcode::YDirection);
}

View File

@ -102,6 +102,8 @@ public:
[[nodiscard]] U32 InvocationInfo();
[[nodiscard]] U32 SampleId();
[[nodiscard]] U1 IsHelperInvocation();
[[nodiscard]] U32 SR_WScaleFactorXY();
[[nodiscard]] U32 SR_WScaleFactorZ();
[[nodiscard]] F32 YDirection();
[[nodiscard]] F32 ResolutionDownFactor();

View File

@ -62,6 +62,8 @@ OPCODE(InvocationId, U32,
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, )

View File

@ -139,10 +139,10 @@ enum class SpecialRegister : u64 {
return ir.WorkgroupIdZ();
case SpecialRegister::SR_WSCALEFACTOR_XY:
LOG_WARNING(Shader, "(STUBBED) SR_WSCALEFACTOR_XY");
return ir.Imm32(Common::BitCast<u32>(1.0f));
return ir.SR_WScaleFactorXY();
case SpecialRegister::SR_WSCALEFACTOR_Z:
LOG_WARNING(Shader, "(STUBBED) SR_WSCALEFACTOR_Z");
return ir.Imm32(Common::BitCast<u32>(1.0f));
return ir.SR_WScaleFactorZ();
case SpecialRegister::SR_LANEID:
return ir.LaneId();
case SpecialRegister::SR_EQMASK: