From 613fdac71da2aff4f3f555d0dede07ddb586fbe1 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sat, 14 Mar 2015 23:55:33 -0700 Subject: [PATCH] Implementing one case of conditional shader execution blocks. --- src/xenia/gpu/gl4/command_processor.cc | 1 + src/xenia/gpu/gl4/gl4_shader.cc | 21 ++++++++++----------- src/xenia/gpu/gl4/gl4_shader_translator.cc | 6 +++++- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/xenia/gpu/gl4/command_processor.cc b/src/xenia/gpu/gl4/command_processor.cc index 65f0e8a74..7d98677a0 100644 --- a/src/xenia/gpu/gl4/command_processor.cc +++ b/src/xenia/gpu/gl4/command_processor.cc @@ -2264,6 +2264,7 @@ CommandProcessor::UpdateStatus CommandProcessor::PopulateVertexBuffers() { fetch = &group->vertex_fetch_2; break; } + assert_true(fetch->endian == 2); // Constrain the vertex upload to just what we are interested in. const size_t kRangeKludge = 5; // could pick index count based on prim. diff --git a/src/xenia/gpu/gl4/gl4_shader.cc b/src/xenia/gpu/gl4/gl4_shader.cc index 7f78dcab3..c6de3d1d1 100644 --- a/src/xenia/gpu/gl4/gl4_shader.cc +++ b/src/xenia/gpu/gl4/gl4_shader.cc @@ -244,17 +244,16 @@ bool GL4Shader::PreparePixelShader( } has_prepared_ = true; - std::string source = - GetHeader() + - "layout(origin_upper_left) in vec4 gl_FragCoord;\n" - "layout(location = 0) flat in uint draw_id;\n" - "layout(location = 1) in VertexData vtx;\n" - "layout(location = 0) out vec4 oC[4];\n" - "void processFragment(const in StateData state);\n" - "void main() {\n" + - " const StateData state = states[draw_id];\n" - " processFragment(state);\n" - "}\n"; + std::string source = GetHeader() + + "layout(origin_upper_left) in vec4 gl_FragCoord;\n" + "layout(location = 0) flat in uint draw_id;\n" + "layout(location = 1) in VertexData vtx;\n" + "layout(location = 0) out vec4 oC[4];\n" + "void processFragment(const in StateData state);\n" + "void main() {\n" + + " const StateData state = states[draw_id];\n" + " processFragment(state);\n" + "}\n"; std::string translated_source = shader_translator_.TranslatePixelShader(this, program_cntl); diff --git a/src/xenia/gpu/gl4/gl4_shader_translator.cc b/src/xenia/gpu/gl4/gl4_shader_translator.cc index ec76a629a..53100980c 100644 --- a/src/xenia/gpu/gl4/gl4_shader_translator.cc +++ b/src/xenia/gpu/gl4/gl4_shader_translator.cc @@ -1325,7 +1325,7 @@ bool GL4ShaderTranslator::TranslateExec(const instr_cf_exec_t& cf) { if (vc) { Append(" VC(0x%x)", vc); } - if (cf.bool_addr) { + if (cf.is_cond_exec()) { Append(" BOOL_ADDR(0x%x)", cf.bool_addr); } if (cf.address_mode == ABSOLUTE_ADDR) { @@ -1337,6 +1337,10 @@ bool GL4ShaderTranslator::TranslateExec(const instr_cf_exec_t& cf) { Append("\n"); if (cf.is_cond_exec()) { + if (cf.opc == COND_EXEC_PRED_CLEAN || cf.opc == COND_EXEC_PRED_CLEAN_END) { + Append(" p = (state.bool_consts[%d] & (1 << %d)) != 0;\n", + cf.bool_addr / 32, cf.bool_addr % 32); + } Append(" if(%cp) {\n", cf.pred_condition ? ' ' : '!'); }