diff options
| author | 2018-11-28 02:44:15 -0300 | |
|---|---|---|
| committer | 2018-11-28 23:46:14 -0300 | |
| commit | f4abebd731b2b03c47db7db3dd629de2f01a8a3a (patch) | |
| tree | 7ec30f8c45df2b8388a5bf406990928be29b2f66 /src | |
| parent | gl_shader_decompiler: Move texture code generation into lambdas (diff) | |
| download | yuzu-f4abebd731b2b03c47db7db3dd629de2f01a8a3a.tar.gz yuzu-f4abebd731b2b03c47db7db3dd629de2f01a8a3a.tar.xz yuzu-f4abebd731b2b03c47db7db3dd629de2f01a8a3a.zip | |
gl_shader_decompiler: Use GLSL scope on instructions unrelated to textures
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 45 |
1 files changed, 10 insertions, 35 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 7831067d4..0bba8fa5a 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |||
| @@ -854,14 +854,12 @@ private: | |||
| 854 | } | 854 | } |
| 855 | 855 | ||
| 856 | if (precise && stage != Maxwell3D::Regs::ShaderStage::Fragment) { | 856 | if (precise && stage != Maxwell3D::Regs::ShaderStage::Fragment) { |
| 857 | shader.AddLine('{'); | 857 | const auto scope = shader.Scope(); |
| 858 | ++shader.scope; | 858 | |
| 859 | // This avoids optimizations of constant propagation and keeps the code as the original | 859 | // This avoids optimizations of constant propagation and keeps the code as the original |
| 860 | // Sadly using the precise keyword causes "linking" errors on fragment shaders. | 860 | // Sadly using the precise keyword causes "linking" errors on fragment shaders. |
| 861 | shader.AddLine("precise float tmp = " + src + ';'); | 861 | shader.AddLine("precise float tmp = " + src + ';'); |
| 862 | shader.AddLine(dest + " = tmp;"); | 862 | shader.AddLine(dest + " = tmp;"); |
| 863 | --shader.scope; | ||
| 864 | shader.AddLine('}'); | ||
| 865 | } else { | 863 | } else { |
| 866 | shader.AddLine(dest + " = " + src + ';'); | 864 | shader.AddLine(dest + " = " + src + ';'); |
| 867 | } | 865 | } |
| @@ -1382,12 +1380,10 @@ private: | |||
| 1382 | * top. | 1380 | * top. |
| 1383 | */ | 1381 | */ |
| 1384 | void EmitPushToFlowStack(u32 target) { | 1382 | void EmitPushToFlowStack(u32 target) { |
| 1385 | shader.AddLine('{'); | 1383 | const auto scope = shader.Scope(); |
| 1386 | ++shader.scope; | 1384 | |
| 1387 | shader.AddLine("flow_stack[flow_stack_top] = " + std::to_string(target) + "u;"); | 1385 | shader.AddLine("flow_stack[flow_stack_top] = " + std::to_string(target) + "u;"); |
| 1388 | shader.AddLine("flow_stack_top++;"); | 1386 | shader.AddLine("flow_stack_top++;"); |
| 1389 | --shader.scope; | ||
| 1390 | shader.AddLine('}'); | ||
| 1391 | } | 1387 | } |
| 1392 | 1388 | ||
| 1393 | /* | 1389 | /* |
| @@ -1395,13 +1391,11 @@ private: | |||
| 1395 | * popped address and decrementing the stack top. | 1391 | * popped address and decrementing the stack top. |
| 1396 | */ | 1392 | */ |
| 1397 | void EmitPopFromFlowStack() { | 1393 | void EmitPopFromFlowStack() { |
| 1398 | shader.AddLine('{'); | 1394 | const auto scope = shader.Scope(); |
| 1399 | ++shader.scope; | 1395 | |
| 1400 | shader.AddLine("flow_stack_top--;"); | 1396 | shader.AddLine("flow_stack_top--;"); |
| 1401 | shader.AddLine("jmp_to = flow_stack[flow_stack_top];"); | 1397 | shader.AddLine("jmp_to = flow_stack[flow_stack_top];"); |
| 1402 | shader.AddLine("break;"); | 1398 | shader.AddLine("break;"); |
| 1403 | --shader.scope; | ||
| 1404 | shader.AddLine('}'); | ||
| 1405 | } | 1399 | } |
| 1406 | 1400 | ||
| 1407 | /// Writes the output values from a fragment shader to the corresponding GLSL output variables. | 1401 | /// Writes the output values from a fragment shader to the corresponding GLSL output variables. |
| @@ -2313,8 +2307,7 @@ private: | |||
| 2313 | UNIMPLEMENTED_IF(instr.conversion.selector); | 2307 | UNIMPLEMENTED_IF(instr.conversion.selector); |
| 2314 | UNIMPLEMENTED_IF_MSG(instr.generates_cc, | 2308 | UNIMPLEMENTED_IF_MSG(instr.generates_cc, |
| 2315 | "Condition codes generation in I2F is not implemented"); | 2309 | "Condition codes generation in I2F is not implemented"); |
| 2316 | 2310 | std::string op_a; | |
| 2317 | std::string op_a{}; | ||
| 2318 | 2311 | ||
| 2319 | if (instr.is_b_gpr) { | 2312 | if (instr.is_b_gpr) { |
| 2320 | op_a = | 2313 | op_a = |
| @@ -2470,10 +2463,7 @@ private: | |||
| 2470 | case OpCode::Id::LD_C: { | 2463 | case OpCode::Id::LD_C: { |
| 2471 | UNIMPLEMENTED_IF(instr.ld_c.unknown != 0); | 2464 | UNIMPLEMENTED_IF(instr.ld_c.unknown != 0); |
| 2472 | 2465 | ||
| 2473 | // Add an extra scope and declare the index register inside to prevent | 2466 | const auto scope = shader.Scope(); |
| 2474 | // overwriting it in case it is used as an output of the LD instruction. | ||
| 2475 | shader.AddLine("{"); | ||
| 2476 | ++shader.scope; | ||
| 2477 | 2467 | ||
| 2478 | shader.AddLine("uint index = (" + regs.GetRegisterAsInteger(instr.gpr8, 0, false) + | 2468 | shader.AddLine("uint index = (" + regs.GetRegisterAsInteger(instr.gpr8, 0, false) + |
| 2479 | " / 4) & (MAX_CONSTBUFFER_ELEMENTS - 1);"); | 2469 | " / 4) & (MAX_CONSTBUFFER_ELEMENTS - 1);"); |
| @@ -2499,19 +2489,13 @@ private: | |||
| 2499 | UNIMPLEMENTED_MSG("Unhandled type: {}", | 2489 | UNIMPLEMENTED_MSG("Unhandled type: {}", |
| 2500 | static_cast<unsigned>(instr.ld_c.type.Value())); | 2490 | static_cast<unsigned>(instr.ld_c.type.Value())); |
| 2501 | } | 2491 | } |
| 2502 | |||
| 2503 | --shader.scope; | ||
| 2504 | shader.AddLine("}"); | ||
| 2505 | break; | 2492 | break; |
| 2506 | } | 2493 | } |
| 2507 | case OpCode::Id::LD_L: { | 2494 | case OpCode::Id::LD_L: { |
| 2508 | UNIMPLEMENTED_IF_MSG(instr.ld_l.unknown == 1, "LD_L Unhandled mode: {}", | 2495 | UNIMPLEMENTED_IF_MSG(instr.ld_l.unknown == 1, "LD_L Unhandled mode: {}", |
| 2509 | static_cast<unsigned>(instr.ld_l.unknown.Value())); | 2496 | static_cast<unsigned>(instr.ld_l.unknown.Value())); |
| 2510 | 2497 | ||
| 2511 | // Add an extra scope and declare the index register inside to prevent | 2498 | const auto scope = shader.Scope(); |
| 2512 | // overwriting it in case it is used as an output of the LD instruction. | ||
| 2513 | shader.AddLine('{'); | ||
| 2514 | ++shader.scope; | ||
| 2515 | 2499 | ||
| 2516 | std::string op = '(' + regs.GetRegisterAsInteger(instr.gpr8, 0, false) + " + " + | 2500 | std::string op = '(' + regs.GetRegisterAsInteger(instr.gpr8, 0, false) + " + " + |
| 2517 | std::to_string(instr.smem_imm.Value()) + ')'; | 2501 | std::to_string(instr.smem_imm.Value()) + ')'; |
| @@ -2528,9 +2512,6 @@ private: | |||
| 2528 | UNIMPLEMENTED_MSG("LD_L Unhandled type: {}", | 2512 | UNIMPLEMENTED_MSG("LD_L Unhandled type: {}", |
| 2529 | static_cast<unsigned>(instr.ldst_sl.type.Value())); | 2513 | static_cast<unsigned>(instr.ldst_sl.type.Value())); |
| 2530 | } | 2514 | } |
| 2531 | |||
| 2532 | --shader.scope; | ||
| 2533 | shader.AddLine('}'); | ||
| 2534 | break; | 2515 | break; |
| 2535 | } | 2516 | } |
| 2536 | case OpCode::Id::ST_A: { | 2517 | case OpCode::Id::ST_A: { |
| @@ -2565,10 +2546,7 @@ private: | |||
| 2565 | UNIMPLEMENTED_IF_MSG(instr.st_l.unknown == 0, "ST_L Unhandled mode: {}", | 2546 | UNIMPLEMENTED_IF_MSG(instr.st_l.unknown == 0, "ST_L Unhandled mode: {}", |
| 2566 | static_cast<unsigned>(instr.st_l.unknown.Value())); | 2547 | static_cast<unsigned>(instr.st_l.unknown.Value())); |
| 2567 | 2548 | ||
| 2568 | // Add an extra scope and declare the index register inside to prevent | 2549 | const auto scope = shader.Scope(); |
| 2569 | // overwriting it in case it is used as an output of the LD instruction. | ||
| 2570 | shader.AddLine('{'); | ||
| 2571 | ++shader.scope; | ||
| 2572 | 2550 | ||
| 2573 | std::string op = '(' + regs.GetRegisterAsInteger(instr.gpr8, 0, false) + " + " + | 2551 | std::string op = '(' + regs.GetRegisterAsInteger(instr.gpr8, 0, false) + " + " + |
| 2574 | std::to_string(instr.smem_imm.Value()) + ')'; | 2552 | std::to_string(instr.smem_imm.Value()) + ')'; |
| @@ -2583,9 +2561,6 @@ private: | |||
| 2583 | UNIMPLEMENTED_MSG("ST_L Unhandled type: {}", | 2561 | UNIMPLEMENTED_MSG("ST_L Unhandled type: {}", |
| 2584 | static_cast<unsigned>(instr.ldst_sl.type.Value())); | 2562 | static_cast<unsigned>(instr.ldst_sl.type.Value())); |
| 2585 | } | 2563 | } |
| 2586 | |||
| 2587 | --shader.scope; | ||
| 2588 | shader.AddLine('}'); | ||
| 2589 | break; | 2564 | break; |
| 2590 | } | 2565 | } |
| 2591 | case OpCode::Id::TEX: { | 2566 | case OpCode::Id::TEX: { |