[D3D12] Free two alphatest-related system constant dwords

This commit is contained in:
Triang3l
2019-01-15 12:58:36 +03:00
parent 7d7a539aee
commit 17dfd84f71
23 changed files with 2164 additions and 2156 deletions

View File

@@ -1907,7 +1907,7 @@ void D3D12CommandProcessor::UpdateSystemConstantValues(
uint32_t sq_context_misc = regs[XE_GPU_REG_SQ_CONTEXT_MISC].u32;
uint32_t rb_surface_info = regs[XE_GPU_REG_RB_SURFACE_INFO].u32;
uint32_t rb_colorcontrol = regs[XE_GPU_REG_RB_COLORCONTROL].u32;
uint32_t rb_alpha_ref = regs[XE_GPU_REG_RB_ALPHA_REF].u32;
float rb_alpha_ref = regs[XE_GPU_REG_RB_ALPHA_REF].f32;
uint32_t pa_su_sc_mode_cntl = regs[XE_GPU_REG_PA_SU_SC_MODE_CNTL].u32;
// Get the color info register values for each render target, and also put
@@ -2011,6 +2011,15 @@ void D3D12CommandProcessor::UpdateSystemConstantValues(
if (viewport_scale_z < 0.0f) {
flags |= DxbcShaderTranslator::kSysFlag_ReverseZ;
}
// Alpha test.
if (rb_colorcontrol & 0x8) {
flags |= (rb_colorcontrol & 0x7)
<< DxbcShaderTranslator::kSysFlag_AlphaPassIfLess_Shift;
} else {
flags |= DxbcShaderTranslator::kSysFlag_AlphaPassIfLess |
DxbcShaderTranslator::kSysFlag_AlphaPassIfEqual |
DxbcShaderTranslator::kSysFlag_AlphaPassIfGreater;
}
// Gamma writing.
if (((regs[XE_GPU_REG_RB_COLOR_INFO].u32 >> 16) & 0xF) ==
uint32_t(ColorRenderTargetFormat::k_8_8_8_8_GAMMA)) {
@@ -2198,37 +2207,8 @@ void D3D12CommandProcessor::UpdateSystemConstantValues(
system_constants_.sample_count_log2[1] = sample_count_log2_y;
// Alpha test.
int32_t alpha_test;
uint32_t alpha_test_function = rb_colorcontrol & 0x7;
if ((rb_colorcontrol & 0x8) && alpha_test_function != 0x7) {
// 0: Never - fail in [-inf, +inf].
// 1: Less - fail in [ref, +inf].
// 2: Equal - pass in [ref, ref].
// 3: Less or equal - pass in [-inf, ref].
// 4: Greater - fail in [-inf, ref].
// 5: Not equal - fail in [ref, ref].
// 6: Greater or equal - pass in [ref, +inf].
// 7: Always - pass in [-inf, +inf].
alpha_test = (alpha_test_function & 0x2) ? 1 : -1;
uint32_t alpha_test_range_start =
(alpha_test_function == 1 || alpha_test_function == 2 ||
alpha_test_function == 5 || alpha_test_function == 6)
? rb_alpha_ref
: 0xFF800000u;
uint32_t alpha_test_range_end =
(alpha_test_function == 2 || alpha_test_function == 3 ||
alpha_test_function == 4 || alpha_test_function == 5)
? rb_alpha_ref
: 0x7F800000u;
dirty |= system_constants_.alpha_test_range[0] != alpha_test_range_start;
dirty |= system_constants_.alpha_test_range[1] != alpha_test_range_end;
system_constants_.alpha_test_range[0] = alpha_test_range_start;
system_constants_.alpha_test_range[1] = alpha_test_range_end;
} else {
alpha_test = 0;
}
dirty |= system_constants_.alpha_test != alpha_test;
system_constants_.alpha_test = alpha_test;
dirty |= system_constants_.alpha_test_reference != rb_alpha_ref;
system_constants_.alpha_test_reference = rb_alpha_ref;
// EDRAM pitch for ROV writing.
if (IsROVUsedForEDRAM()) {