Shaders: Track the register count from the program control register (if available)
This commit is contained in:
parent
1faf5a813a
commit
d94ff6eb25
|
@ -558,6 +558,9 @@ class Shader {
|
||||||
// True if the shader was translated and prepared without error.
|
// True if the shader was translated and prepared without error.
|
||||||
bool is_valid() const { return is_valid_; }
|
bool is_valid() const { return is_valid_; }
|
||||||
|
|
||||||
|
// True if the shader has already been translated.
|
||||||
|
bool is_translated() const { return is_translated_; }
|
||||||
|
|
||||||
// Errors that occurred during translation.
|
// Errors that occurred during translation.
|
||||||
const std::vector<Error>& errors() const { return errors_; }
|
const std::vector<Error>& errors() const { return errors_; }
|
||||||
|
|
||||||
|
@ -602,6 +605,7 @@ class Shader {
|
||||||
bool writes_color_targets_[4] = {false, false, false, false};
|
bool writes_color_targets_[4] = {false, false, false, false};
|
||||||
|
|
||||||
bool is_valid_ = false;
|
bool is_valid_ = false;
|
||||||
|
bool is_translated_ = false;
|
||||||
std::vector<Error> errors_;
|
std::vector<Error> errors_;
|
||||||
|
|
||||||
std::string ucode_disassembly_;
|
std::string ucode_disassembly_;
|
||||||
|
|
|
@ -51,6 +51,7 @@ void ShaderTranslator::Reset() {
|
||||||
ucode_disasm_buffer_.Reset();
|
ucode_disasm_buffer_.Reset();
|
||||||
ucode_disasm_line_number_ = 0;
|
ucode_disasm_line_number_ = 0;
|
||||||
previous_ucode_disasm_scan_offset_ = 0;
|
previous_ucode_disasm_scan_offset_ = 0;
|
||||||
|
register_count_ = 64;
|
||||||
total_attrib_count_ = 0;
|
total_attrib_count_ = 0;
|
||||||
vertex_bindings_.clear();
|
vertex_bindings_.clear();
|
||||||
texture_bindings_.clear();
|
texture_bindings_.clear();
|
||||||
|
@ -95,9 +96,21 @@ bool ShaderTranslator::GatherAllBindingInformation(Shader* shader) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ShaderTranslator::Translate(Shader* shader,
|
||||||
|
xenos::xe_gpu_program_cntl_t cntl) {
|
||||||
|
Reset();
|
||||||
|
register_count_ = shader->type() == ShaderType::kVertex ? cntl.vs_regs + 1
|
||||||
|
: cntl.ps_regs + 1;
|
||||||
|
|
||||||
|
return TranslateInternal(shader);
|
||||||
|
}
|
||||||
|
|
||||||
bool ShaderTranslator::Translate(Shader* shader) {
|
bool ShaderTranslator::Translate(Shader* shader) {
|
||||||
Reset();
|
Reset();
|
||||||
|
return TranslateInternal(shader);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ShaderTranslator::TranslateInternal(Shader* shader) {
|
||||||
shader_type_ = shader->type();
|
shader_type_ = shader->type();
|
||||||
ucode_dwords_ = shader->ucode_dwords();
|
ucode_dwords_ = shader->ucode_dwords();
|
||||||
ucode_dword_count_ = shader->ucode_dword_count();
|
ucode_dword_count_ = shader->ucode_dword_count();
|
||||||
|
@ -155,6 +168,7 @@ bool ShaderTranslator::Translate(Shader* shader) {
|
||||||
}
|
}
|
||||||
|
|
||||||
shader->is_valid_ = true;
|
shader->is_valid_ = true;
|
||||||
|
shader->is_translated_ = true;
|
||||||
for (const auto& error : shader->errors_) {
|
for (const auto& error : shader->errors_) {
|
||||||
if (error.is_fatal) {
|
if (error.is_fatal) {
|
||||||
shader->is_valid_ = false;
|
shader->is_valid_ = false;
|
||||||
|
|
|
@ -30,6 +30,7 @@ class ShaderTranslator {
|
||||||
// DEPRECATED(benvanik): remove this when shader cache is removed.
|
// DEPRECATED(benvanik): remove this when shader cache is removed.
|
||||||
bool GatherAllBindingInformation(Shader* shader);
|
bool GatherAllBindingInformation(Shader* shader);
|
||||||
|
|
||||||
|
bool Translate(Shader* shader, xenos::xe_gpu_program_cntl_t cntl);
|
||||||
bool Translate(Shader* shader);
|
bool Translate(Shader* shader);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -38,6 +39,8 @@ class ShaderTranslator {
|
||||||
// Resets translator state before beginning translation.
|
// Resets translator state before beginning translation.
|
||||||
virtual void Reset();
|
virtual void Reset();
|
||||||
|
|
||||||
|
// Register count.
|
||||||
|
uint32_t register_count() const { return register_count_; }
|
||||||
// True if the current shader is a vertex shader.
|
// True if the current shader is a vertex shader.
|
||||||
bool is_vertex_shader() const { return shader_type_ == ShaderType::kVertex; }
|
bool is_vertex_shader() const { return shader_type_ == ShaderType::kVertex; }
|
||||||
// True if the current shader is a pixel shader.
|
// True if the current shader is a pixel shader.
|
||||||
|
@ -132,6 +135,8 @@ class ShaderTranslator {
|
||||||
int src_swizzle_component_count;
|
int src_swizzle_component_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool TranslateInternal(Shader* shader);
|
||||||
|
|
||||||
void MarkUcodeInstruction(uint32_t dword_offset);
|
void MarkUcodeInstruction(uint32_t dword_offset);
|
||||||
void AppendUcodeDisasm(char c);
|
void AppendUcodeDisasm(char c);
|
||||||
void AppendUcodeDisasm(const char* value);
|
void AppendUcodeDisasm(const char* value);
|
||||||
|
@ -184,6 +189,8 @@ class ShaderTranslator {
|
||||||
ShaderType shader_type_;
|
ShaderType shader_type_;
|
||||||
const uint32_t* ucode_dwords_;
|
const uint32_t* ucode_dwords_;
|
||||||
size_t ucode_dword_count_;
|
size_t ucode_dword_count_;
|
||||||
|
xenos::xe_gpu_program_cntl_t program_cntl_;
|
||||||
|
uint32_t register_count_;
|
||||||
|
|
||||||
// Accumulated translation errors.
|
// Accumulated translation errors.
|
||||||
std::vector<Shader::Error> errors_;
|
std::vector<Shader::Error> errors_;
|
||||||
|
|
Loading…
Reference in New Issue