[DXBC] Cleanup StartPixelShader, always_reads_mask, and ps_param_gen overall
This commit is contained in:
@@ -32,7 +32,8 @@ DEFINE_bool(d3d12_edram_rov, true,
|
||||
// may be blurry or have texture sampling artifacts, in this case the user may
|
||||
// disable half-pixel offset by setting this to false.
|
||||
DEFINE_bool(d3d12_half_pixel_offset, true,
|
||||
"Enable half-pixel vertex and VPOS offset.", "D3D12");
|
||||
"Enable half-pixel vertex offset (D3D9 PA_SU_VTX_CNTL PIX_CENTER).",
|
||||
"D3D12");
|
||||
DEFINE_bool(d3d12_readback_memexport, false,
|
||||
"Read data written by memory export in shaders on the CPU. This "
|
||||
"may be needed in some games (but many only access exported data "
|
||||
@@ -2427,6 +2428,10 @@ void D3D12CommandProcessor::UpdateSystemConstantValues(
|
||||
if (viewport_scale_z < 0.0f) {
|
||||
flags |= DxbcShaderTranslator::kSysFlag_ReverseZ;
|
||||
}
|
||||
// Whether SV_IsFrontFace matters.
|
||||
if (primitive_two_faced) {
|
||||
flags |= DxbcShaderTranslator::kSysFlag_PrimitiveTwoFaced;
|
||||
}
|
||||
// Primitive killing condition.
|
||||
if (pa_cl_clip_cntl.vtx_kill_or) {
|
||||
flags |= DxbcShaderTranslator::kSysFlag_KillIfAnyVertexKilled;
|
||||
@@ -2521,18 +2526,6 @@ void D3D12CommandProcessor::UpdateSystemConstantValues(
|
||||
}
|
||||
}
|
||||
|
||||
// Half pixel offset.
|
||||
bool half_pixel_offset =
|
||||
cvars::d3d12_half_pixel_offset && !pa_su_vtx_cntl.pix_center;
|
||||
// Like in OpenGL - VPOS giving pixel centers, or like in Direct3D 9 - VPOS
|
||||
// giving the top-left corner.
|
||||
// TODO(Triang3l): Check if ps_param_gen should give center positions in
|
||||
// OpenGL mode on the Xbox 360.
|
||||
float param_gen_half_pixel_offset = half_pixel_offset ? 0.0f : 0.5f;
|
||||
dirty |=
|
||||
system_constants_.pixel_half_pixel_offset != param_gen_half_pixel_offset;
|
||||
system_constants_.pixel_half_pixel_offset = param_gen_half_pixel_offset;
|
||||
|
||||
// Conversion to Direct3D 12 normalized device coordinates.
|
||||
// See viewport configuration in UpdateFixedFunctionState for explanations.
|
||||
// X and Y scale/offset is to convert unnormalized coordinates generated by
|
||||
@@ -2540,8 +2533,6 @@ void D3D12CommandProcessor::UpdateSystemConstantValues(
|
||||
// viewport that is used to emulate unnormalized coordinates.
|
||||
// Z scale/offset is to convert from OpenGL NDC to Direct3D NDC if needed.
|
||||
// Also apply half-pixel offset to reproduce Direct3D 9 rasterization rules.
|
||||
// TODO(Triang3l): Check if pixel coordinates need to be offset depending on a
|
||||
// different register (and if there's such register at all).
|
||||
float viewport_scale_x = regs[XE_GPU_REG_PA_CL_VPORT_XSCALE].f32;
|
||||
float viewport_scale_y = regs[XE_GPU_REG_PA_CL_VPORT_YSCALE].f32;
|
||||
// Kill all primitives if multipass or both faces are culled, but still need
|
||||
@@ -2579,7 +2570,7 @@ void D3D12CommandProcessor::UpdateSystemConstantValues(
|
||||
float ndc_offset_x = pa_cl_vte_cntl.vport_x_offset_ena ? 0.0f : -1.0f;
|
||||
float ndc_offset_y = pa_cl_vte_cntl.vport_y_offset_ena ? 0.0f : 1.0f;
|
||||
float ndc_offset_z = gl_clip_space_def ? 0.5f : 0.0f;
|
||||
if (half_pixel_offset) {
|
||||
if (cvars::d3d12_half_pixel_offset && !pa_su_vtx_cntl.pix_center) {
|
||||
// Signs are hopefully correct here, tested in GTA IV on both clearing
|
||||
// (without a viewport) and drawing things near the edges of the screen.
|
||||
if (pa_cl_vte_cntl.vport_x_scale_ena) {
|
||||
@@ -2642,11 +2633,11 @@ void D3D12CommandProcessor::UpdateSystemConstantValues(
|
||||
system_constants_.point_screen_to_ndc[0] = point_screen_to_ndc_x;
|
||||
system_constants_.point_screen_to_ndc[1] = point_screen_to_ndc_y;
|
||||
|
||||
// Pixel position register.
|
||||
uint32_t pixel_pos_reg =
|
||||
// Pixel parameter register.
|
||||
uint32_t ps_param_gen =
|
||||
sq_program_cntl.param_gen ? sq_context_misc.param_gen_pos : UINT_MAX;
|
||||
dirty |= system_constants_.pixel_pos_reg != pixel_pos_reg;
|
||||
system_constants_.pixel_pos_reg = pixel_pos_reg;
|
||||
dirty |= system_constants_.ps_param_gen != ps_param_gen;
|
||||
system_constants_.ps_param_gen = ps_param_gen;
|
||||
|
||||
// Log2 of sample count, for scaling VPOS with SSAA (without ROV) and for
|
||||
// EDRAM address calculation with MSAA (with ROV).
|
||||
|
||||
Reference in New Issue
Block a user