[D3D12] DXBC RDEF, operand swizzle and cubemap orientation fix
This commit is contained in:
parent
4651a0b5ed
commit
9f7496ac23
|
@ -1309,13 +1309,12 @@ void DxbcShaderTranslator::UseDxbcSourceOperand(
|
||||||
if (select_component <= 3) {
|
if (select_component <= 3) {
|
||||||
component_bits |= ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE(
|
component_bits |= ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE(
|
||||||
D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_MODE) |
|
D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_MODE) |
|
||||||
(((operand.swizzle >> (select_component * 2)) & 0x3)
|
(((swizzle >> (select_component * 2)) & 0x3)
|
||||||
<< D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_SHIFT);
|
<< D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_SHIFT);
|
||||||
} else {
|
} else {
|
||||||
component_bits |=
|
component_bits |= ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE(
|
||||||
ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE(
|
|
||||||
D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_MODE) |
|
D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_MODE) |
|
||||||
(operand.swizzle << D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_SHIFT);
|
(swizzle << D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_SHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply both the operand negation and the usage negation (for subtraction)
|
// Apply both the operand negation and the usage negation (for subtraction)
|
||||||
|
@ -2950,7 +2949,7 @@ uint32_t DxbcShaderTranslator::FindOrAddSamplerBinding(
|
||||||
return sampler_register;
|
return sampler_register;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DxbcShaderTranslator::ArrayToCubeDirection(uint32_t reg) {
|
void DxbcShaderTranslator::ArrayCoordToCubeDirection(uint32_t reg) {
|
||||||
// This does the reverse of what the cube vector ALU instruction does, but
|
// This does the reverse of what the cube vector ALU instruction does, but
|
||||||
// assuming S and T are normalized.
|
// assuming S and T are normalized.
|
||||||
//
|
//
|
||||||
|
@ -3794,7 +3793,7 @@ void DxbcShaderTranslator::ProcessTextureFetchInstruction(
|
||||||
// at the edges, especially in pixel shader helper invocations, the
|
// at the edges, especially in pixel shader helper invocations, the
|
||||||
// major axis changes, causing S/T to jump between 0 and 1, breaking
|
// major axis changes, causing S/T to jump between 0 and 1, breaking
|
||||||
// gradient calculation and causing the 1x1 mipmap to be sampled.
|
// gradient calculation and causing the 1x1 mipmap to be sampled.
|
||||||
ArrayToCubeDirection(system_temp_pv_);
|
ArrayCoordToCubeDirection(system_temp_pv_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// tfetch1D/2D/Cube just fetch directly. tfetch3D needs to fetch either
|
// tfetch1D/2D/Cube just fetch directly. tfetch3D needs to fetch either
|
||||||
|
@ -4545,14 +4544,14 @@ void DxbcShaderTranslator::ProcessVectorAluInstruction(
|
||||||
++stat_.uint_instruction_count;
|
++stat_.uint_instruction_count;
|
||||||
|
|
||||||
// Flip T or S.
|
// Flip T or S.
|
||||||
// movc pv.xy__, mask.xy__, -pv.xy__, pv.xy__
|
// movc pv.xy__, mask.yx__, -pv.xy__, pv.xy__
|
||||||
shader_code_.push_back(ENCODE_D3D10_SB_OPCODE_TYPE(D3D10_SB_OPCODE_MOVC) |
|
shader_code_.push_back(ENCODE_D3D10_SB_OPCODE_TYPE(D3D10_SB_OPCODE_MOVC) |
|
||||||
ENCODE_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH(10));
|
ENCODE_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH(10));
|
||||||
shader_code_.push_back(
|
shader_code_.push_back(
|
||||||
EncodeVectorMaskedOperand(D3D10_SB_OPERAND_TYPE_TEMP, 0b0011, 1));
|
EncodeVectorMaskedOperand(D3D10_SB_OPERAND_TYPE_TEMP, 0b0011, 1));
|
||||||
shader_code_.push_back(system_temp_pv_);
|
shader_code_.push_back(system_temp_pv_);
|
||||||
shader_code_.push_back(EncodeVectorSwizzledOperand(
|
shader_code_.push_back(EncodeVectorSwizzledOperand(
|
||||||
D3D10_SB_OPERAND_TYPE_TEMP, kSwizzleXYZW, 1));
|
D3D10_SB_OPERAND_TYPE_TEMP, 0b11100001, 1));
|
||||||
shader_code_.push_back(cube_mask_temp);
|
shader_code_.push_back(cube_mask_temp);
|
||||||
shader_code_.push_back(EncodeVectorSwizzledOperand(
|
shader_code_.push_back(EncodeVectorSwizzledOperand(
|
||||||
D3D10_SB_OPERAND_TYPE_TEMP, kSwizzleXYZW, 1) |
|
D3D10_SB_OPERAND_TYPE_TEMP, kSwizzleXYZW, 1) |
|
||||||
|
@ -5941,11 +5940,6 @@ void DxbcShaderTranslator::WriteResourceDefinitions() {
|
||||||
uint32_t chunk_position_dwords = uint32_t(shader_object_.size());
|
uint32_t chunk_position_dwords = uint32_t(shader_object_.size());
|
||||||
uint32_t new_offset;
|
uint32_t new_offset;
|
||||||
|
|
||||||
// + 1 for shared memory (vfetches can probably appear in pixel shaders too,
|
|
||||||
// they are handled safely there anyway).
|
|
||||||
// TODO(Triang3l): Textures, samplers.
|
|
||||||
uint32_t binding_count = uint32_t(RdefConstantBufferIndex::kCount) + 1;
|
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
// Header
|
// Header
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
@ -5954,8 +5948,12 @@ void DxbcShaderTranslator::WriteResourceDefinitions() {
|
||||||
shader_object_.push_back(uint32_t(RdefConstantBufferIndex::kCount));
|
shader_object_.push_back(uint32_t(RdefConstantBufferIndex::kCount));
|
||||||
// Constant buffer offset (set later).
|
// Constant buffer offset (set later).
|
||||||
shader_object_.push_back(0);
|
shader_object_.push_back(0);
|
||||||
// Bound resource count (CBV, SRV, UAV, samplers).
|
// Bound resource count (samplers, SRV, UAV, CBV).
|
||||||
shader_object_.push_back(binding_count);
|
// + 1 for shared memory (vfetches can probably appear in pixel shaders too,
|
||||||
|
// they are handled safely there anyway).
|
||||||
|
shader_object_.push_back(uint32_t(sampler_bindings_.size()) + 1 +
|
||||||
|
uint32_t(texture_srvs_.size()) +
|
||||||
|
uint32_t(RdefConstantBufferIndex::kCount));
|
||||||
// Bound resource buffer offset (set later).
|
// Bound resource buffer offset (set later).
|
||||||
shader_object_.push_back(0);
|
shader_object_.push_back(0);
|
||||||
if (is_vertex_shader()) {
|
if (is_vertex_shader()) {
|
||||||
|
|
|
@ -365,7 +365,7 @@ class DxbcShaderTranslator : public ShaderTranslator {
|
||||||
AnisoFilter aniso_filter);
|
AnisoFilter aniso_filter);
|
||||||
// Converts (S, T, face index) in the specified temporary register to a 3D
|
// Converts (S, T, face index) in the specified temporary register to a 3D
|
||||||
// cubemap coordinate.
|
// cubemap coordinate.
|
||||||
void ArrayToCubeDirection(uint32_t reg);
|
void ArrayCoordToCubeDirection(uint32_t reg);
|
||||||
|
|
||||||
void ProcessVectorAluInstruction(const ParsedAluInstruction& instr);
|
void ProcessVectorAluInstruction(const ParsedAluInstruction& instr);
|
||||||
void ProcessScalarAluInstruction(const ParsedAluInstruction& instr);
|
void ProcessScalarAluInstruction(const ParsedAluInstruction& instr);
|
||||||
|
|
Loading…
Reference in New Issue