diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index de9e4d22e..484579d82 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h | |||
| @@ -17,6 +17,14 @@ | |||
| 17 | #include "video_core/renderer_opengl/gl_state.h" | 17 | #include "video_core/renderer_opengl/gl_state.h" |
| 18 | #include "video_core/shader/shader_interpreter.h" | 18 | #include "video_core/shader/shader_interpreter.h" |
| 19 | 19 | ||
| 20 | /** | ||
| 21 | * This struct contains all state used to generate the GLSL shader program that emulates the current | ||
| 22 | * Pica register configuration. This struct is used as a cache key for generated GLSL shader | ||
| 23 | * programs. The functions in gl_shader_gen.cpp should retrieve state from this struct only, not by | ||
| 24 | * directly accessing Pica registers. This should reduce the risk of bugs in shader generation where | ||
| 25 | * Pica state is not being captured in the shader cache key, thereby resulting in (what should be) | ||
| 26 | * two separate shaders sharing the same key. | ||
| 27 | */ | ||
| 20 | struct ShaderCacheKey { | 28 | struct ShaderCacheKey { |
| 21 | using Regs = Pica::Regs; | 29 | using Regs = Pica::Regs; |
| 22 | 30 | ||
| @@ -36,6 +44,11 @@ struct ShaderCacheKey { | |||
| 36 | return (stage_index < 4) && ((combiner_buffer_input >> 4) & (1 << stage_index)); | 44 | return (stage_index < 4) && ((combiner_buffer_input >> 4) & (1 << stage_index)); |
| 37 | } | 45 | } |
| 38 | 46 | ||
| 47 | /** | ||
| 48 | * This function is used to construct a ShaderCacheKey with the current Pica register | ||
| 49 | * configuration. Don't construct a ShaderCacheKey manually, instead call this function (and | ||
| 50 | * extend it as additional state needs to be captured to generate shaders). | ||
| 51 | */ | ||
| 39 | static ShaderCacheKey CurrentConfig() { | 52 | static ShaderCacheKey CurrentConfig() { |
| 40 | const auto& regs = Pica::g_state.regs; | 53 | const auto& regs = Pica::g_state.regs; |
| 41 | ShaderCacheKey config; | 54 | ShaderCacheKey config; |
| @@ -43,6 +56,9 @@ struct ShaderCacheKey { | |||
| 43 | config.alpha_test_func = regs.output_merger.alpha_test.enable ? | 56 | config.alpha_test_func = regs.output_merger.alpha_test.enable ? |
| 44 | regs.output_merger.alpha_test.func.Value() : Pica::Regs::CompareFunc::Always; | 57 | regs.output_merger.alpha_test.func.Value() : Pica::Regs::CompareFunc::Always; |
| 45 | 58 | ||
| 59 | // Copy relevant TevStageConfig fields only. We're doing this manually (instead of calling | ||
| 60 | // the GetTevStages() function) because BitField explicitly disables copies. | ||
| 61 | |||
| 46 | config.tev_stages[0].source_raw = regs.tev_stage0.source_raw; | 62 | config.tev_stages[0].source_raw = regs.tev_stage0.source_raw; |
| 47 | config.tev_stages[1].source_raw = regs.tev_stage1.source_raw; | 63 | config.tev_stages[1].source_raw = regs.tev_stage1.source_raw; |
| 48 | config.tev_stages[2].source_raw = regs.tev_stage2.source_raw; | 64 | config.tev_stages[2].source_raw = regs.tev_stage2.source_raw; |