[DXBC] Skip backface check in point PsParamGen

This commit is contained in:
Triang3l 2022-07-25 21:48:25 +03:00
parent 77e85ecaa4
commit f248e23079
1 changed files with 23 additions and 24 deletions

View File

@ -734,16 +734,24 @@ void DxbcShaderTranslator::StartPixelShader() {
dxbc::Src::LF(1.0f / draw_resolution_scale_x_, dxbc::Src::LF(1.0f / draw_resolution_scale_x_,
1.0f / draw_resolution_scale_y_, 1.0f, 1.0f)); 1.0f / draw_resolution_scale_y_, 1.0f, 1.0f));
} }
// Take the absolute value of the position and apply the point flag.
if (shader_modification.pixel.param_gen_point) { if (shader_modification.pixel.param_gen_point) {
// A point - always front-facing (the upper bit of X is 0), not a line
// (the upper bit of Z is 0).
// Take the absolute value of the position and apply the point flag.
a_.OpMov(dxbc::Dest::R(param_gen_temp, 0b0001), a_.OpMov(dxbc::Dest::R(param_gen_temp, 0b0001),
dxbc::Src::R(param_gen_temp, dxbc::Src::kXXXX).Abs()); dxbc::Src::R(param_gen_temp, dxbc::Src::kXXXX).Abs());
a_.OpMov(dxbc::Dest::R(param_gen_temp, 0b0010), a_.OpMov(dxbc::Dest::R(param_gen_temp, 0b0010),
-(dxbc::Src::R(param_gen_temp, dxbc::Src::kYYYY).Abs())); -(dxbc::Src::R(param_gen_temp, dxbc::Src::kYYYY).Abs()));
// ZW - point sprite coordinates.
// Saturate to avoid negative point coordinates if the center of the pixel
// is not covered, and extrapolation is done.
assert_true(in_reg_ps_point_coordinates_ != UINT32_MAX);
a_.OpMov(dxbc::Dest::R(param_gen_temp, 0b1100),
dxbc::Src::V1D(in_reg_ps_point_coordinates_, 0b0100 << 4), true);
} else { } else {
// Take the absolute value of the position and apply the point flag.
a_.OpMov(dxbc::Dest::R(param_gen_temp, 0b0011), a_.OpMov(dxbc::Dest::R(param_gen_temp, 0b0011),
dxbc::Src::R(param_gen_temp).Abs()); dxbc::Src::R(param_gen_temp).Abs());
}
// Faceness. // Faceness.
// Check if faceness applies to the current primitive type. // Check if faceness applies to the current primitive type.
// Using Z as a temporary (not written yet). // Using Z as a temporary (not written yet).
@ -754,22 +762,13 @@ void DxbcShaderTranslator::StartPixelShader() {
// Negate modifier flips the sign bit even for 0 - set it to minus for // Negate modifier flips the sign bit even for 0 - set it to minus for
// backfaces. // backfaces.
in_front_face_used_ = true; in_front_face_used_ = true;
a_.OpMovC( a_.OpMovC(dxbc::Dest::R(param_gen_temp, 0b0001),
dxbc::Dest::R(param_gen_temp, 0b0001), dxbc::Src::V1D(in_reg_ps_front_face_sample_index_,
dxbc::Src::V1D(in_reg_ps_front_face_sample_index_, dxbc::Src::kXXXX), dxbc::Src::kXXXX),
dxbc::Src::R(param_gen_temp, dxbc::Src::kXXXX), dxbc::Src::R(param_gen_temp, dxbc::Src::kXXXX),
-dxbc::Src::R(param_gen_temp, dxbc::Src::kXXXX)); -dxbc::Src::R(param_gen_temp, dxbc::Src::kXXXX));
} }
a_.OpEndIf(); a_.OpEndIf();
if (shader_modification.pixel.param_gen_point) {
// A point - not a line (the upper bit of Z is 0).
// ZW - point sprite coordinates.
// Saturate to avoid negative point coordinates if the center of the pixel
// is not covered, and extrapolation is done.
assert_true(in_reg_ps_point_coordinates_ != UINT32_MAX);
a_.OpMov(dxbc::Dest::R(param_gen_temp, 0b1100),
dxbc::Src::V1D(in_reg_ps_point_coordinates_, 0b0100 << 4), true);
} else {
// No point coordinates. // No point coordinates.
// Z - is line in the sign bit. // Z - is line in the sign bit.
// W - nothing. // W - nothing.