mirror of
https://github.com/citra-emu/citra-canary.git
synced 2024-12-24 19:45:27 +00:00
gl_rasterizer: Move logic for creating ShaderCacheKey to a static function.
This commit is contained in:
parent
b02a533d94
commit
3c057bd3d8
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue