summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2015-10-06 02:52:04 +0200
committerbunnei <bunneidev@gmail.com>2015-10-22 03:53:05 +0200
commit3c057bd3d80b049720b11d0b44391c18870c28e8 (patch)
treea5c141dc0b3ff15d30e3bbd962d08826bbd26b42 /src
parentgl_shader_util: Use vec3 constants for AppendColorCombiner. (diff)
downloadyuzu-3c057bd3d80b049720b11d0b44391c18870c28e8.tar
yuzu-3c057bd3d80b049720b11d0b44391c18870c28e8.tar.gz
yuzu-3c057bd3d80b049720b11d0b44391c18870c28e8.tar.bz2
yuzu-3c057bd3d80b049720b11d0b44391c18870c28e8.tar.lz
yuzu-3c057bd3d80b049720b11d0b44391c18870c28e8.tar.xz
yuzu-3c057bd3d80b049720b11d0b44391c18870c28e8.tar.zst
yuzu-3c057bd3d80b049720b11d0b44391c18870c28e8.zip
Diffstat (limited to 'src')
-rw-r--r--src/video_core/pica.h8
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp19
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h45
3 files changed, 50 insertions, 22 deletions
diff --git a/src/video_core/pica.h b/src/video_core/pica.h
index 18fdc8c85..2f1b2dec4 100644
--- a/src/video_core/pica.h
+++ b/src/video_core/pica.h
@@ -317,7 +317,7 @@ struct Regs {
};
union {
- u32 source_raw;
+ u32 sources_raw;
BitField< 0, 4, Source> color_source1;
BitField< 4, 4, Source> color_source2;
BitField< 8, 4, Source> color_source3;
@@ -327,7 +327,7 @@ struct Regs {
};
union {
- u32 modifier_raw;
+ u32 modifiers_raw;
BitField< 0, 4, ColorModifier> color_modifier1;
BitField< 4, 4, ColorModifier> color_modifier2;
BitField< 8, 4, ColorModifier> color_modifier3;
@@ -337,7 +337,7 @@ struct Regs {
};
union {
- u32 op_raw;
+ u32 ops_raw;
BitField< 0, 4, Operation> color_op;
BitField<16, 4, Operation> alpha_op;
};
@@ -351,7 +351,7 @@ struct Regs {
};
union {
- u32 scale_raw;
+ u32 scales_raw;
BitField< 0, 2, u32> color_scale;
BitField<16, 2, u32> alpha_scale;
};
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index a69e09188..01b9c91c6 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -145,21 +145,7 @@ extern std::string GenerateFragmentShader(const ShaderCacheKey& config);
}
void RasterizerOpenGL::RegenerateShaders() {
- const auto& regs = Pica::g_state.regs;
-
- ShaderCacheKey config;
- config.alpha_test_func = regs.output_merger.alpha_test.enable ?
- regs.output_merger.alpha_test.func.Value() : Pica::Regs::CompareFunc::Always;
- config.tev_stages = regs.GetTevStages();
- for (auto& tev : config.tev_stages) {
- tev.const_r = 0;
- tev.const_g = 0;
- tev.const_b = 0;
- tev.const_a = 0;
- }
- config.combiner_buffer_input =
- regs.tev_combiner_buffer_input.update_mask_rgb.Value() |
- regs.tev_combiner_buffer_input.update_mask_a.Value() << 4;
+ ShaderCacheKey config = ShaderCacheKey::CurrentShaderConfig();
auto cached_shader = shader_cache.find(config);
if (cached_shader != shader_cache.end()) {
@@ -192,10 +178,9 @@ void RasterizerOpenGL::RegenerateShaders() {
}
}
-
// Sync alpha reference
if (current_shader->uniform_alphatest_ref != -1)
- glUniform1i(current_shader->uniform_alphatest_ref, regs.output_merger.alpha_test.ref);
+ glUniform1i(current_shader->uniform_alphatest_ref, Pica::g_state.regs.output_merger.alpha_test.ref);
// Sync combiner buffer color
if (current_shader->uniform_tev_combiner_buffer_color != -1) {
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index 19e8db69a..5bc4a319f 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -9,6 +9,7 @@
#include "common/common_types.h"
+#include "video_core/pica.h"
#include "video_core/hwrasterizer_base.h"
#include "video_core/renderer_opengl/gl_rasterizer_cache.h"
#include "video_core/renderer_opengl/gl_state.h"
@@ -37,7 +38,7 @@ struct ShaderCacheKey {
};
Regs::CompareFunc alpha_test_func;
- std::array<Regs::TevStageConfig, 6> tev_stages;
+ std::array<Regs::TevStageConfig, 6> tev_stages = {};
u8 combiner_buffer_input;
bool TevStageUpdatesCombinerBufferColor(unsigned stage_index) const {
@@ -47,6 +48,48 @@ struct ShaderCacheKey {
bool TevStageUpdatesCombinerBufferAlpha(unsigned stage_index) const {
return (stage_index < 4) && ((combiner_buffer_input >> 4) & (1 << stage_index));
}
+
+ static ShaderCacheKey CurrentShaderConfig() {
+ const auto& regs = Pica::g_state.regs;
+ ShaderCacheKey config;
+
+ config.alpha_test_func = regs.output_merger.alpha_test.enable ?
+ regs.output_merger.alpha_test.func.Value() : Pica::Regs::CompareFunc::Always;
+
+ config.tev_stages[0].source_raw = regs.tev_stage0.source_raw;
+ config.tev_stages[1].source_raw = regs.tev_stage1.source_raw;
+ config.tev_stages[2].source_raw = regs.tev_stage2.source_raw;
+ config.tev_stages[3].source_raw = regs.tev_stage3.source_raw;
+ config.tev_stages[4].source_raw = regs.tev_stage4.source_raw;
+ config.tev_stages[5].source_raw = regs.tev_stage5.source_raw;
+
+ config.tev_stages[0].modifier_raw = regs.tev_stage0.modifier_raw;
+ config.tev_stages[1].modifier_raw = regs.tev_stage1.modifier_raw;
+ config.tev_stages[2].modifier_raw = regs.tev_stage2.modifier_raw;
+ config.tev_stages[3].modifier_raw = regs.tev_stage3.modifier_raw;
+ config.tev_stages[4].modifier_raw = regs.tev_stage4.modifier_raw;
+ config.tev_stages[5].modifier_raw = regs.tev_stage5.modifier_raw;
+
+ config.tev_stages[0].op_raw = regs.tev_stage0.op_raw;
+ config.tev_stages[1].op_raw = regs.tev_stage1.op_raw;
+ config.tev_stages[2].op_raw = regs.tev_stage2.op_raw;
+ config.tev_stages[3].op_raw = regs.tev_stage3.op_raw;
+ config.tev_stages[4].op_raw = regs.tev_stage4.op_raw;
+ config.tev_stages[5].op_raw = regs.tev_stage5.op_raw;
+
+ config.tev_stages[0].scale_raw = regs.tev_stage0.scale_raw;
+ config.tev_stages[1].scale_raw = regs.tev_stage1.scale_raw;
+ config.tev_stages[2].scale_raw = regs.tev_stage2.scale_raw;
+ config.tev_stages[3].scale_raw = regs.tev_stage3.scale_raw;
+ config.tev_stages[4].scale_raw = regs.tev_stage4.scale_raw;
+ config.tev_stages[5].scale_raw = regs.tev_stage5.scale_raw;
+
+ config.combiner_buffer_input =
+ regs.tev_combiner_buffer_input.update_mask_rgb.Value() |
+ regs.tev_combiner_buffer_input.update_mask_a.Value() << 4;
+
+ return config;
+ }
};
namespace std {