[GPU] Gather used memexport constants in shader translator
This commit is contained in:
parent
dc0b468ea8
commit
adc0eb87f6
|
@ -31,8 +31,8 @@ enum class InstructionStorageTarget {
|
||||||
kPosition,
|
kPosition,
|
||||||
// Result is stored to the point size export (gl_PointSize).
|
// Result is stored to the point size export (gl_PointSize).
|
||||||
kPointSize,
|
kPointSize,
|
||||||
// Result is stored as memexport destination address.
|
// Result is stored as memexport destination address
|
||||||
// [physical >> 2, ??, ??, ??]
|
// (see xenos::xe_gpu_memexport_stream_t).
|
||||||
kExportAddress,
|
kExportAddress,
|
||||||
// Result is stored to memexport destination data.
|
// Result is stored to memexport destination data.
|
||||||
kExportData,
|
kExportData,
|
||||||
|
@ -583,6 +583,11 @@ class Shader {
|
||||||
return constant_register_map_;
|
return constant_register_map_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// All c# registers used as the addend in MAD operations to eA.
|
||||||
|
const std::vector<uint32_t>& memexport_stream_constants() const {
|
||||||
|
return memexport_stream_constants_;
|
||||||
|
}
|
||||||
|
|
||||||
// Returns true if the given color target index [0-3].
|
// Returns true if the given color target index [0-3].
|
||||||
bool writes_color_target(int i) const { return writes_color_targets_[i]; }
|
bool writes_color_target(int i) const { return writes_color_targets_[i]; }
|
||||||
|
|
||||||
|
@ -634,6 +639,7 @@ class Shader {
|
||||||
std::vector<TextureBinding> texture_bindings_;
|
std::vector<TextureBinding> texture_bindings_;
|
||||||
ConstantRegisterMap constant_register_map_ = {0};
|
ConstantRegisterMap constant_register_map_ = {0};
|
||||||
bool writes_color_targets_[4] = {false, false, false, false};
|
bool writes_color_targets_[4] = {false, false, false, false};
|
||||||
|
std::vector<uint32_t> memexport_stream_constants_;
|
||||||
|
|
||||||
bool is_valid_ = false;
|
bool is_valid_ = false;
|
||||||
bool is_translated_ = false;
|
bool is_translated_ = false;
|
||||||
|
|
|
@ -63,6 +63,7 @@ void ShaderTranslator::Reset() {
|
||||||
writes_color_targets_[i] = false;
|
writes_color_targets_[i] = false;
|
||||||
}
|
}
|
||||||
writes_depth_ = false;
|
writes_depth_ = false;
|
||||||
|
memexport_stream_constants_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShaderTranslator::GatherAllBindingInformation(Shader* shader) {
|
bool ShaderTranslator::GatherAllBindingInformation(Shader* shader) {
|
||||||
|
@ -174,6 +175,10 @@ bool ShaderTranslator::TranslateInternal(Shader* shader) {
|
||||||
for (size_t i = 0; i < xe::countof(writes_color_targets_); ++i) {
|
for (size_t i = 0; i < xe::countof(writes_color_targets_); ++i) {
|
||||||
shader->writes_color_targets_[i] = writes_color_targets_[i];
|
shader->writes_color_targets_[i] = writes_color_targets_[i];
|
||||||
}
|
}
|
||||||
|
shader->memexport_stream_constants_.clear();
|
||||||
|
for (uint32_t memexport_stream_constant : memexport_stream_constants_) {
|
||||||
|
shader->memexport_stream_constants_.push_back(memexport_stream_constant);
|
||||||
|
}
|
||||||
|
|
||||||
shader->is_valid_ = true;
|
shader->is_valid_ = true;
|
||||||
shader->is_translated_ = true;
|
shader->is_translated_ = true;
|
||||||
|
@ -282,6 +287,18 @@ void ShaderTranslator::GatherInstructionInformation(
|
||||||
writes_depth_ = true;
|
writes_depth_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Store used memexport constants because CPU code needs addresses
|
||||||
|
// and sizes. eA is (hopefully) always written to using:
|
||||||
|
// mad eA, r#, const0100, c#
|
||||||
|
// (though there are some exceptions, shaders in Halo 3 for some
|
||||||
|
// reason set eA to zeros, but the swizzle of the constant is not
|
||||||
|
// .xyzw in this case, and they don't write to eM#).
|
||||||
|
if (op.vector_dest() == 32 &&
|
||||||
|
op.vector_opcode() == AluVectorOpcode::kMad &&
|
||||||
|
op.vector_write_mask() == 0b1111 && !op.src_is_temp(3) &&
|
||||||
|
op.src_swizzle(3) == 0) {
|
||||||
|
memexport_stream_constants_.insert(op.src_reg(3));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (op.is_vector_dest_relative()) {
|
if (op.is_vector_dest_relative()) {
|
||||||
uses_register_dynamic_addressing_ = true;
|
uses_register_dynamic_addressing_ = true;
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#define XENIA_GPU_SHADER_TRANSLATOR_H_
|
#define XENIA_GPU_SHADER_TRANSLATOR_H_
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -65,6 +66,11 @@ class ShaderTranslator {
|
||||||
const std::vector<Shader::TextureBinding>& texture_bindings() const {
|
const std::vector<Shader::TextureBinding>& texture_bindings() const {
|
||||||
return texture_bindings_;
|
return texture_bindings_;
|
||||||
}
|
}
|
||||||
|
// All c# registers used as the addend in MAD operations to eA, populated
|
||||||
|
// before translation occurs.
|
||||||
|
const std::set<uint32_t>& memexport_stream_constants() const {
|
||||||
|
return memexport_stream_constants_;
|
||||||
|
}
|
||||||
|
|
||||||
// Current line number in the ucode disassembly.
|
// Current line number in the ucode disassembly.
|
||||||
size_t ucode_disasm_line_number() const { return ucode_disasm_line_number_; }
|
size_t ucode_disasm_line_number() const { return ucode_disasm_line_number_; }
|
||||||
|
@ -230,6 +236,7 @@ class ShaderTranslator {
|
||||||
bool uses_register_dynamic_addressing_ = false;
|
bool uses_register_dynamic_addressing_ = false;
|
||||||
bool writes_color_targets_[4] = {false, false, false, false};
|
bool writes_color_targets_[4] = {false, false, false, false};
|
||||||
bool writes_depth_ = false;
|
bool writes_depth_ = false;
|
||||||
|
std::set<uint32_t> memexport_stream_constants_;
|
||||||
|
|
||||||
static const AluOpcodeInfo alu_vector_opcode_infos_[0x20];
|
static const AluOpcodeInfo alu_vector_opcode_infos_[0x20];
|
||||||
static const AluOpcodeInfo alu_scalar_opcode_infos_[0x40];
|
static const AluOpcodeInfo alu_scalar_opcode_infos_[0x40];
|
||||||
|
|
Loading…
Reference in New Issue