diff options
| author | 2016-04-23 15:19:41 +0200 | |
|---|---|---|
| committer | 2016-05-03 14:10:11 +0200 | |
| commit | f3f7018c9e4c398d50902eb1011ad9a731bdbc3b (patch) | |
| tree | 4a8ab3120b376fbffef15d74f66031145676e3c5 /src | |
| parent | Merge pull request #1754 from JayFoxRox/fix-const_color-revert (diff) | |
| download | yuzu-f3f7018c9e4c398d50902eb1011ad9a731bdbc3b.tar.gz yuzu-f3f7018c9e4c398d50902eb1011ad9a731bdbc3b.tar.xz yuzu-f3f7018c9e4c398d50902eb1011ad9a731bdbc3b.zip | |
Pica: Make PicaShaderConfig trivially_copyable and clear it before use
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index 82fa61742..47fd40f97 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h | |||
| @@ -41,9 +41,12 @@ struct ScreenInfo; | |||
| 41 | * two separate shaders sharing the same key. | 41 | * two separate shaders sharing the same key. |
| 42 | */ | 42 | */ |
| 43 | struct PicaShaderConfig { | 43 | struct PicaShaderConfig { |
| 44 | |||
| 44 | /// Construct a PicaShaderConfig with the current Pica register configuration. | 45 | /// Construct a PicaShaderConfig with the current Pica register configuration. |
| 45 | static PicaShaderConfig CurrentConfig() { | 46 | static PicaShaderConfig CurrentConfig() { |
| 46 | PicaShaderConfig res; | 47 | PicaShaderConfig res; |
| 48 | std::memset(&res, 0, sizeof(PicaShaderConfig)); | ||
| 49 | |||
| 47 | const auto& regs = Pica::g_state.regs; | 50 | const auto& regs = Pica::g_state.regs; |
| 48 | 51 | ||
| 49 | res.alpha_test_func = regs.output_merger.alpha_test.enable ? | 52 | res.alpha_test_func = regs.output_merger.alpha_test.enable ? |
| @@ -134,38 +137,42 @@ struct PicaShaderConfig { | |||
| 134 | return std::memcmp(this, &o, sizeof(PicaShaderConfig)) == 0; | 137 | return std::memcmp(this, &o, sizeof(PicaShaderConfig)) == 0; |
| 135 | }; | 138 | }; |
| 136 | 139 | ||
| 137 | Pica::Regs::CompareFunc alpha_test_func = Pica::Regs::CompareFunc::Never; | 140 | Pica::Regs::CompareFunc alpha_test_func; |
| 138 | std::array<Pica::Regs::TevStageConfig, 6> tev_stages = {}; | 141 | std::array<Pica::Regs::TevStageConfig, 6> tev_stages; |
| 139 | u8 combiner_buffer_input = 0; | 142 | u8 combiner_buffer_input; |
| 140 | 143 | ||
| 141 | struct { | 144 | struct { |
| 142 | struct { | 145 | struct { |
| 143 | unsigned num = 0; | 146 | unsigned num; |
| 144 | bool directional = false; | 147 | bool directional; |
| 145 | bool two_sided_diffuse = false; | 148 | bool two_sided_diffuse; |
| 146 | bool dist_atten_enable = false; | 149 | bool dist_atten_enable; |
| 147 | GLfloat dist_atten_scale = 0.0f; | 150 | GLfloat dist_atten_scale; |
| 148 | GLfloat dist_atten_bias = 0.0f; | 151 | GLfloat dist_atten_bias; |
| 149 | } light[8]; | 152 | } light[8]; |
| 150 | 153 | ||
| 151 | bool enable = false; | 154 | bool enable; |
| 152 | unsigned src_num = 0; | 155 | unsigned src_num; |
| 153 | Pica::Regs::LightingBumpMode bump_mode = Pica::Regs::LightingBumpMode::None; | 156 | Pica::Regs::LightingBumpMode bump_mode; |
| 154 | unsigned bump_selector = 0; | 157 | unsigned bump_selector; |
| 155 | bool bump_renorm = false; | 158 | bool bump_renorm; |
| 156 | bool clamp_highlights = false; | 159 | bool clamp_highlights; |
| 157 | 160 | ||
| 158 | Pica::Regs::LightingConfig config = Pica::Regs::LightingConfig::Config0; | 161 | Pica::Regs::LightingConfig config; |
| 159 | Pica::Regs::LightingFresnelSelector fresnel_selector = Pica::Regs::LightingFresnelSelector::None; | 162 | Pica::Regs::LightingFresnelSelector fresnel_selector; |
| 160 | 163 | ||
| 161 | struct { | 164 | struct { |
| 162 | bool enable = false; | 165 | bool enable; |
| 163 | bool abs_input = false; | 166 | bool abs_input; |
| 164 | Pica::Regs::LightingLutInput type = Pica::Regs::LightingLutInput::NH; | 167 | Pica::Regs::LightingLutInput type; |
| 165 | float scale = 1.0f; | 168 | float scale; |
| 166 | } lut_d0, lut_d1, lut_fr, lut_rr, lut_rg, lut_rb; | 169 | } lut_d0, lut_d1, lut_fr, lut_rr, lut_rg, lut_rb; |
| 167 | } lighting; | 170 | } lighting; |
| 171 | |||
| 168 | }; | 172 | }; |
| 173 | #if (__GNUC__ >= 5) || defined(__clang__) || defined(_MSC_VER) | ||
| 174 | static_assert(std::is_trivially_copyable<PicaShaderConfig>::value, "PicaShaderConfig must be trivially copyable"); | ||
| 175 | #endif | ||
| 169 | 176 | ||
| 170 | namespace std { | 177 | namespace std { |
| 171 | 178 | ||