[GPU] Eliminate unused shader I/O, UCP culling, centroid on Vulkan

For more optimal usage of exports and the parameter cache on the host regardless of how effective the optimizations in the host GPU driver are. Also reserve space for Vulkan/Metal/D3D11-specific HostVertexShaderTypes to use one more bit for the host vertex shader type in the shader modification bits, so that won't have to be done in the future as that would require invalidating shader storages (which are invalidated by this commit) again.
This commit is contained in:
Triang3l
2022-07-21 12:32:28 +03:00
parent 0a94b86cb8
commit 1a95bef8b3
22 changed files with 3366 additions and 3235 deletions

View File

@@ -173,7 +173,7 @@ void DxbcShaderTranslator::StartPixelShader_LoadROVParameters() {
// system_temp_rov_params_.y = Y host pixel position as uint
in_position_used_ |= 0b0011;
a_.OpFToU(dxbc::Dest::R(system_temp_rov_params_, 0b0011),
dxbc::Src::V1D(uint32_t(InOutRegister::kPSInPosition)));
dxbc::Src::V1D(in_reg_ps_position_));
// Convert the position from pixels to samples.
// system_temp_rov_params_.x = X sample 0 position
// system_temp_rov_params_.y = Y sample 0 position
@@ -537,8 +537,8 @@ void DxbcShaderTranslator::ROV_DepthStencilTest() {
ROV_DepthTo24Bit(system_temp_depth_stencil_, 0, system_temp_depth_stencil_,
0, temp, 0);
} else {
dxbc::Src in_position_z(dxbc::Src::V1D(
uint32_t(InOutRegister::kPSInPosition), dxbc::Src::kZZZZ));
dxbc::Src in_position_z(
dxbc::Src::V1D(in_reg_ps_position_, dxbc::Src::kZZZZ));
// Get the derivatives of the screen-space (but not clamped to the viewport
// depth bounds yet - this happens after the pixel shader in Direct3D 11+;
// also linear within the triangle - thus constant derivatives along the
@@ -577,9 +577,8 @@ void DxbcShaderTranslator::ROV_DepthStencilTest() {
a_.OpMax(temp_z_dest, z_ddx_src.Abs(), z_ddy_src.Abs());
// Calculate the depth bias for the needed faceness.
in_front_face_used_ = true;
a_.OpIf(true, dxbc::Src::V1D(
uint32_t(InOutRegister::kPSInFrontFaceAndSampleIndex),
dxbc::Src::kXXXX));
a_.OpIf(true, dxbc::Src::V1D(in_reg_ps_front_face_sample_index_,
dxbc::Src::kXXXX));
// temp.x if early = ddx(z)
// temp.y if early = ddy(z)
// temp.z = front face polygon offset
@@ -881,9 +880,8 @@ void DxbcShaderTranslator::ROV_DepthStencilTest() {
{
// Check the current face to get the reference and apply the read mask.
in_front_face_used_ = true;
a_.OpIf(true, dxbc::Src::V1D(
uint32_t(InOutRegister::kPSInFrontFaceAndSampleIndex),
dxbc::Src::kXXXX));
a_.OpIf(true, dxbc::Src::V1D(in_reg_ps_front_face_sample_index_,
dxbc::Src::kXXXX));
for (uint32_t j = 0; j < 2; ++j) {
if (j) {
// Go to the back face.
@@ -944,8 +942,7 @@ void DxbcShaderTranslator::ROV_DepthStencilTest() {
in_front_face_used_ = true;
a_.OpMovC(
sample_temp_z_dest,
dxbc::Src::V1D(uint32_t(InOutRegister::kPSInFrontFaceAndSampleIndex),
dxbc::Src::kXXXX),
dxbc::Src::V1D(in_reg_ps_front_face_sample_index_, dxbc::Src::kXXXX),
LoadSystemConstant(
SystemConstants::Index::kEdramStencil,
offsetof(SystemConstants, edram_stencil_front_func_ops),
@@ -1023,9 +1020,8 @@ void DxbcShaderTranslator::ROV_DepthStencilTest() {
a_.OpCase(dxbc::Src::LU(uint32_t(xenos::StencilOp::kReplace)));
in_front_face_used_ = true;
a_.OpMovC(sample_temp_y_dest,
dxbc::Src::V1D(
uint32_t(InOutRegister::kPSInFrontFaceAndSampleIndex),
dxbc::Src::kXXXX),
dxbc::Src::V1D(in_reg_ps_front_face_sample_index_,
dxbc::Src::kXXXX),
LoadSystemConstant(
SystemConstants::Index::kEdramStencil,
offsetof(SystemConstants, edram_stencil_front_reference),
@@ -1087,8 +1083,7 @@ void DxbcShaderTranslator::ROV_DepthStencilTest() {
in_front_face_used_ = true;
a_.OpMovC(
sample_temp_z_dest,
dxbc::Src::V1D(uint32_t(InOutRegister::kPSInFrontFaceAndSampleIndex),
dxbc::Src::kXXXX),
dxbc::Src::V1D(in_reg_ps_front_face_sample_index_, dxbc::Src::kXXXX),
LoadSystemConstant(
SystemConstants::Index::kEdramStencil,
offsetof(SystemConstants, edram_stencil_front_write_mask),
@@ -1863,8 +1858,7 @@ void DxbcShaderTranslator::CompletePixelShader_DSV_DepthTo24Bit() {
temp = PushSystemTemp();
in_position_used_ |= 0b0100;
a_.OpMul(dxbc::Dest::R(temp, 0b0001),
dxbc::Src::V1D(uint32_t(InOutRegister::kPSInPosition),
dxbc::Src::kZZZZ),
dxbc::Src::V1D(in_reg_ps_position_, dxbc::Src::kZZZZ),
dxbc::Src::LF(2.0f), true);
}
@@ -2006,8 +2000,7 @@ void DxbcShaderTranslator::CompletePixelShader_AlphaToMask() {
// preserve the idea of dithering.
// temp.x = alpha to coverage offset as float 0.0...3.0.
in_position_used_ |= 0b0011;
a_.OpFToU(dxbc::Dest::R(temp, 0b0011),
dxbc::Src::V1D(uint32_t(InOutRegister::kPSInPosition)));
a_.OpFToU(dxbc::Dest::R(temp, 0b0011), dxbc::Src::V1D(in_reg_ps_position_));
a_.OpAnd(dxbc::Dest::R(temp, 0b0010), dxbc::Src::R(temp, dxbc::Src::kYYYY),
dxbc::Src::LU(1));
a_.OpBFI(temp_x_dest, dxbc::Src::LU(1), dxbc::Src::LU(1), temp_x_src,