Skip to content

Commit

Permalink
GPU: Rewrite/rephrase some confusing shader translator code
Browse files Browse the repository at this point in the history
  • Loading branch information
DrChat committed Aug 8, 2017
1 parent 6d9a56a commit cfc65a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/xenia/gpu/shader_translator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,12 @@ void ShaderTranslator::GatherBindingInformation(
// Gather up color targets written to.
auto& op = *reinterpret_cast<const AluInstruction*>(ucode_dwords_ +
instr_offset * 3);
if (op.has_vector_op() && op.is_export()) {
if (op.vector_dest() <= 3) {
if (op.is_export()) {
if (op.has_vector_op() && op.vector_dest() <= 3) {
writes_color_targets_[op.vector_dest()] = true;
}
}
if (op.has_scalar_op() && op.is_export()) {
if (op.vector_dest() <= 3) {
writes_color_targets_[op.vector_dest()] = true;
if (op.has_scalar_op() && op.scalar_dest() <= 3) {
writes_color_targets_[op.scalar_dest()] = true;
}
}
}
Expand Down Expand Up @@ -1321,8 +1319,9 @@ void ShaderTranslator::ParseAluScalarInstruction(
uint32_t src3_swizzle = op.src_swizzle(3);
uint32_t swiz_a = ((src3_swizzle >> 6) + 3) & 0x3;
uint32_t swiz_b = ((src3_swizzle >> 0) + 0) & 0x3;
uint32_t reg2 = (static_cast<int>(op.scalar_opcode()) & 1) |
(src3_swizzle & 0x3C) | (op.src_is_temp(3) << 1);
uint32_t reg2 = (src3_swizzle & 0x3C) | (op.src_is_temp(3) << 1) |
(static_cast<int>(op.scalar_opcode()) & 1);

int const_slot = (op.src_is_temp(1) || op.src_is_temp(2)) ? 1 : 0;

ParseAluInstructionOperandSpecial(
Expand Down
2 changes: 2 additions & 0 deletions src/xenia/gpu/spirv_shader_translator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ void SpirvShaderTranslator::StartTranslation() {
attrib_type = is_signed ? vec2_int_type_ : vec2_uint_type_;
break;
}
// Intentionally fall through to float type.
case VertexFormat::k_16_16_FLOAT:
case VertexFormat::k_32_32_FLOAT:
attrib_type = vec2_float_type_;
Expand All @@ -260,6 +261,7 @@ void SpirvShaderTranslator::StartTranslation() {
attrib_type = is_signed ? vec4_int_type_ : vec4_uint_type_;
break;
}
// Intentionally fall through to float type.
case VertexFormat::k_16_16_16_16_FLOAT:
case VertexFormat::k_32_32_32_32_FLOAT:
attrib_type = vec4_float_type_;
Expand Down

0 comments on commit cfc65a0

Please sign in to comment.