[D3D12] ROV: Blending fixes

This commit is contained in:
Triang3l 2018-10-13 17:23:50 +03:00
parent efc7f794ed
commit c8a48f9c1c
2 changed files with 17 additions and 10 deletions

View File

@ -1797,6 +1797,8 @@ void D3D12CommandProcessor::UpdateSystemConstantValues(
// Color exponent bias and output index mapping or ROV writing. // Color exponent bias and output index mapping or ROV writing.
uint32_t rb_color_mask = regs[XE_GPU_REG_RB_COLOR_MASK].u32; uint32_t rb_color_mask = regs[XE_GPU_REG_RB_COLOR_MASK].u32;
bool colorcontrol_blend_enable =
(regs[XE_GPU_REG_RB_COLORCONTROL].u32 & 0x20) == 0;
for (uint32_t i = 0; i < 4; ++i) { for (uint32_t i = 0; i < 4; ++i) {
uint32_t color_info, blend_control; uint32_t color_info, blend_control;
switch (i) { switch (i) {
@ -1899,7 +1901,8 @@ void D3D12CommandProcessor::UpdateSystemConstantValues(
rt_flags |= DxbcShaderTranslator::kRTFlag_Load; rt_flags |= DxbcShaderTranslator::kRTFlag_Load;
} }
uint32_t blend_x, blend_y; uint32_t blend_x, blend_y;
if (DxbcShaderTranslator::GetBlendConstants(blend_control, blend_x, if (colorcontrol_blend_enable &&
DxbcShaderTranslator::GetBlendConstants(blend_control, blend_x,
blend_y)) { blend_y)) {
rt_flags |= DxbcShaderTranslator::kRTFlag_Load | rt_flags |= DxbcShaderTranslator::kRTFlag_Load |
DxbcShaderTranslator::kRTFlag_Blend; DxbcShaderTranslator::kRTFlag_Blend;
@ -1912,7 +1915,7 @@ void D3D12CommandProcessor::UpdateSystemConstantValues(
} }
if (system_constants_ if (system_constants_
.edram_blend_rt01_rt23[rt_pair_index][rt_pair_comp + 1] != .edram_blend_rt01_rt23[rt_pair_index][rt_pair_comp + 1] !=
blend_x) { blend_y) {
dirty = true; dirty = true;
system_constants_ system_constants_
.edram_blend_rt01_rt23[rt_pair_index][rt_pair_comp + 1] = .edram_blend_rt01_rt23[rt_pair_index][rt_pair_comp + 1] =

View File

@ -90,6 +90,7 @@ bool DxbcShaderTranslator::GetBlendConstants(uint32_t blend_control,
0, 0,
kBlendX_Src_One, kBlendX_Src_One,
0, 0,
kBlendX_Src_One,
kBlendX_Src_One | kBlendX_Src_DestAlpha_Neg, kBlendX_Src_One | kBlendX_Src_DestAlpha_Neg,
}; };
static const uint32_t kBlendYSrcFactorMap[32] = { static const uint32_t kBlendYSrcFactorMap[32] = {
@ -128,6 +129,7 @@ bool DxbcShaderTranslator::GetBlendConstants(uint32_t blend_control,
kBlendX_SrcAlpha_One, kBlendX_SrcAlpha_One,
0, 0,
kBlendX_SrcAlpha_One, kBlendX_SrcAlpha_One,
kBlendX_SrcAlpha_One,
}; };
static const uint32_t kBlendYSrcAlphaFactorMap[32] = { static const uint32_t kBlendYSrcAlphaFactorMap[32] = {
0, 0,
@ -164,6 +166,7 @@ bool DxbcShaderTranslator::GetBlendConstants(uint32_t blend_control,
0, 0,
kBlendX_Dest_One, kBlendX_Dest_One,
0, 0,
kBlendX_Dest_One,
kBlendX_Dest_One | kBlendX_Src_DestAlpha_Neg, kBlendX_Dest_One | kBlendX_Src_DestAlpha_Neg,
}; };
static const uint32_t kBlendYDestFactorMap[32] = { static const uint32_t kBlendYDestFactorMap[32] = {
@ -202,6 +205,7 @@ bool DxbcShaderTranslator::GetBlendConstants(uint32_t blend_control,
kBlendX_DestAlpha_One, kBlendX_DestAlpha_One,
0, 0,
kBlendX_DestAlpha_One, kBlendX_DestAlpha_One,
kBlendX_DestAlpha_One,
}; };
static const uint32_t kBlendYDestAlphaFactorMap[32] = { static const uint32_t kBlendYDestAlphaFactorMap[32] = {
0, 0,
@ -270,8 +274,8 @@ bool DxbcShaderTranslator::GetBlendConstants(uint32_t blend_control,
uint32_t src_alpha_factor = (blend_control >> 16) & 0x1F; uint32_t src_alpha_factor = (blend_control >> 16) & 0x1F;
uint32_t dest_alpha_factor = (blend_control >> 24) & 0x1F; uint32_t dest_alpha_factor = (blend_control >> 24) & 0x1F;
blend_x |= kBlendXSrcAlphaFactorMap[src_alpha_factor] | blend_x |= kBlendXSrcAlphaFactorMap[src_alpha_factor] |
kBlendYDestAlphaFactorMap[dest_alpha_factor]; kBlendXDestAlphaFactorMap[dest_alpha_factor];
blend_y |= kBlendXSrcAlphaFactorMap[src_alpha_factor] | blend_y |= kBlendYSrcAlphaFactorMap[src_alpha_factor] |
kBlendYDestAlphaFactorMap[dest_alpha_factor]; kBlendYDestAlphaFactorMap[dest_alpha_factor];
switch (op_alpha) { switch (op_alpha) {
case BlendOp::kAdd: case BlendOp::kAdd:
@ -1376,8 +1380,8 @@ void DxbcShaderTranslator::CompletePixelShader_WriteToROV_ExtractBlendScales(
system_constants_used_ |= (1ull << kSysConst_EDRAMBlendRT01_Index) system_constants_used_ |= (1ull << kSysConst_EDRAMBlendRT01_Index)
<< rt_pair_index; << rt_pair_index;
shader_code_.push_back( shader_code_.push_back(
ENCODE_D3D10_SB_OPCODE_TYPE(is_signed ? D3D11_SB_OPCODE_UBFE ENCODE_D3D10_SB_OPCODE_TYPE(is_signed ? D3D11_SB_OPCODE_IBFE
: D3D11_SB_OPCODE_IBFE) | : D3D11_SB_OPCODE_UBFE) |
ENCODE_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH(17)); ENCODE_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH(17));
shader_code_.push_back( shader_code_.push_back(
EncodeVectorMaskedOperand(D3D10_SB_OPERAND_TYPE_TEMP, write_mask, 1)); EncodeVectorMaskedOperand(D3D10_SB_OPERAND_TYPE_TEMP, write_mask, 1));
@ -1409,8 +1413,8 @@ void DxbcShaderTranslator::CompletePixelShader_WriteToROV_ExtractBlendScales(
// Convert -1, 0 or 1 integer to float. // Convert -1, 0 or 1 integer to float.
shader_code_.push_back( shader_code_.push_back(
ENCODE_D3D10_SB_OPCODE_TYPE(is_signed ? D3D10_SB_OPCODE_UTOF ENCODE_D3D10_SB_OPCODE_TYPE(is_signed ? D3D10_SB_OPCODE_ITOF
: D3D10_SB_OPCODE_ITOF) | : D3D10_SB_OPCODE_UTOF) |
ENCODE_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH(5)); ENCODE_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH(5));
shader_code_.push_back( shader_code_.push_back(
EncodeVectorMaskedOperand(D3D10_SB_OPERAND_TYPE_TEMP, write_mask, 1)); EncodeVectorMaskedOperand(D3D10_SB_OPERAND_TYPE_TEMP, write_mask, 1));
@ -1448,8 +1452,8 @@ void DxbcShaderTranslator::CompletePixelShader_WriteToROV_Blend(
// This will initialize src_factor_temp and dest_factor_temp. // This will initialize src_factor_temp and dest_factor_temp.
CompletePixelShader_WriteToROV_ExtractBlendScales( CompletePixelShader_WriteToROV_ExtractBlendScales(
rt_index, 0b00000000, true, kBlendX_Src_SrcColor_Shift, rt_index, 0b00000000, true, kBlendX_Src_SrcColor_Shift,
kBlendX_SrcAlpha_SrcAlpha_Shift, kBlendX_Dest_DestColor_Shift, kBlendX_SrcAlpha_SrcAlpha_Shift, kBlendX_Dest_SrcColor_Shift,
kBlendX_DestAlpha_DestAlpha_Shift, scale_temp); kBlendX_DestAlpha_SrcAlpha_Shift, scale_temp);
for (uint32_t i = 0; i < 2; ++i) { for (uint32_t i = 0; i < 2; ++i) {
shader_code_.push_back(ENCODE_D3D10_SB_OPCODE_TYPE(D3D10_SB_OPCODE_MAD) | shader_code_.push_back(ENCODE_D3D10_SB_OPCODE_TYPE(D3D10_SB_OPCODE_MAD) |
ENCODE_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH(9)); ENCODE_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH(9));