Implementing one case of conditional shader execution blocks.

This commit is contained in:
Ben Vanik 2015-03-14 23:55:33 -07:00
parent ff4e9c32b6
commit 613fdac71d
3 changed files with 16 additions and 12 deletions

View File

@ -2264,6 +2264,7 @@ CommandProcessor::UpdateStatus CommandProcessor::PopulateVertexBuffers() {
fetch = &group->vertex_fetch_2; fetch = &group->vertex_fetch_2;
break; break;
} }
assert_true(fetch->endian == 2);
// Constrain the vertex upload to just what we are interested in. // Constrain the vertex upload to just what we are interested in.
const size_t kRangeKludge = 5; // could pick index count based on prim. const size_t kRangeKludge = 5; // could pick index count based on prim.

View File

@ -244,17 +244,16 @@ bool GL4Shader::PreparePixelShader(
} }
has_prepared_ = true; has_prepared_ = true;
std::string source = std::string source = GetHeader() +
GetHeader() + "layout(origin_upper_left) in vec4 gl_FragCoord;\n"
"layout(origin_upper_left) in vec4 gl_FragCoord;\n" "layout(location = 0) flat in uint draw_id;\n"
"layout(location = 0) flat in uint draw_id;\n" "layout(location = 1) in VertexData vtx;\n"
"layout(location = 1) in VertexData vtx;\n" "layout(location = 0) out vec4 oC[4];\n"
"layout(location = 0) out vec4 oC[4];\n" "void processFragment(const in StateData state);\n"
"void processFragment(const in StateData state);\n" "void main() {\n" +
"void main() {\n" + " const StateData state = states[draw_id];\n"
" const StateData state = states[draw_id];\n" " processFragment(state);\n"
" processFragment(state);\n" "}\n";
"}\n";
std::string translated_source = std::string translated_source =
shader_translator_.TranslatePixelShader(this, program_cntl); shader_translator_.TranslatePixelShader(this, program_cntl);

View File

@ -1325,7 +1325,7 @@ bool GL4ShaderTranslator::TranslateExec(const instr_cf_exec_t& cf) {
if (vc) { if (vc) {
Append(" VC(0x%x)", vc); Append(" VC(0x%x)", vc);
} }
if (cf.bool_addr) { if (cf.is_cond_exec()) {
Append(" BOOL_ADDR(0x%x)", cf.bool_addr); Append(" BOOL_ADDR(0x%x)", cf.bool_addr);
} }
if (cf.address_mode == ABSOLUTE_ADDR) { if (cf.address_mode == ABSOLUTE_ADDR) {
@ -1337,6 +1337,10 @@ bool GL4ShaderTranslator::TranslateExec(const instr_cf_exec_t& cf) {
Append("\n"); Append("\n");
if (cf.is_cond_exec()) { 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 ? ' ' : '!'); Append(" if(%cp) {\n", cf.pred_condition ? ' ' : '!');
} }