summaryrefslogtreecommitdiff
path: root/src/video_core
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/clipper.cpp3
-rw-r--r--src/video_core/command_processor.cpp3
-rw-r--r--src/video_core/debug_utils/debug_utils.cpp37
-rw-r--r--src/video_core/debug_utils/debug_utils.h6
-rw-r--r--src/video_core/gpu_debugger.h3
-rw-r--r--src/video_core/pica.h25
-rw-r--r--src/video_core/primitive_assembly.cpp3
-rw-r--r--src/video_core/rasterizer.cpp42
-rw-r--r--src/video_core/rasterizer_interface.h3
-rw-r--r--src/video_core/renderer_base.h3
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp10
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h9
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp4
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.h4
-rw-r--r--src/video_core/renderer_opengl/gl_shader_gen.cpp4
-rw-r--r--src/video_core/renderer_opengl/pica_to_gl.h16
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp32
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.h7
-rw-r--r--src/video_core/shader/shader.cpp4
-rw-r--r--src/video_core/shader/shader.h3
-rw-r--r--src/video_core/shader/shader_interpreter.cpp5
-rw-r--r--src/video_core/shader/shader_jit_x64.cpp3
-rw-r--r--src/video_core/swrasterizer.h15
23 files changed, 119 insertions, 125 deletions
diff --git a/src/video_core/clipper.cpp b/src/video_core/clipper.cpp
index 747285866..82178d249 100644
--- a/src/video_core/clipper.cpp
+++ b/src/video_core/clipper.cpp
@@ -30,8 +30,7 @@ public:
30 ClippingEdge(Math::Vec4<float24> coeffs, Math::Vec4<float24> bias = Math::Vec4<float24>( 30 ClippingEdge(Math::Vec4<float24> coeffs, Math::Vec4<float24> bias = Math::Vec4<float24>(
31 float24::FromFloat32(0), float24::FromFloat32(0), 31 float24::FromFloat32(0), float24::FromFloat32(0),
32 float24::FromFloat32(0), float24::FromFloat32(0))) 32 float24::FromFloat32(0), float24::FromFloat32(0)))
33 : coeffs(coeffs), bias(bias) { 33 : coeffs(coeffs), bias(bias) {}
34 }
35 34
36 bool IsInside(const OutputVertex& vertex) const { 35 bool IsInside(const OutputVertex& vertex) const {
37 return Math::Dot(vertex.pos + bias, coeffs) <= float24::FromFloat32(0); 36 return Math::Dot(vertex.pos + bias, coeffs) <= float24::FromFloat32(0);
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp
index 415b5f74c..04a4ee3a2 100644
--- a/src/video_core/command_processor.cpp
+++ b/src/video_core/command_processor.cpp
@@ -44,7 +44,8 @@ static u32 default_attr_write_buffer[3];
44// Expand a 4-bit mask to 4-byte mask, e.g. 0b0101 -> 0x00FF00FF 44// Expand a 4-bit mask to 4-byte mask, e.g. 0b0101 -> 0x00FF00FF
45static const u32 expand_bits_to_bytes[] = { 45static const u32 expand_bits_to_bytes[] = {
46 0x00000000, 0x000000ff, 0x0000ff00, 0x0000ffff, 0x00ff0000, 0x00ff00ff, 0x00ffff00, 0x00ffffff, 46 0x00000000, 0x000000ff, 0x0000ff00, 0x0000ffff, 0x00ff0000, 0x00ff00ff, 0x00ffff00, 0x00ffffff,
47 0xff000000, 0xff0000ff, 0xff00ff00, 0xff00ffff, 0xffff0000, 0xffff00ff, 0xffffff00, 0xffffffff}; 47 0xff000000, 0xff0000ff, 0xff00ff00, 0xff00ffff, 0xffff0000, 0xffff00ff, 0xffffff00, 0xffffffff,
48};
48 49
49MICROPROFILE_DEFINE(GPU_Drawing, "GPU", "Drawing", MP_RGB(50, 50, 240)); 50MICROPROFILE_DEFINE(GPU_Drawing, "GPU", "Drawing", MP_RGB(50, 50, 240));
50 51
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp
index 1cb868ead..194e5833c 100644
--- a/src/video_core/debug_utils/debug_utils.cpp
+++ b/src/video_core/debug_utils/debug_utils.cpp
@@ -155,7 +155,8 @@ void DumpShader(const std::string& filename, const Regs::ShaderConfig& config,
155 {OutputAttributes::TEXCOORD2_V, {OutputRegisterInfo::TEXCOORD2, 2}}, 155 {OutputAttributes::TEXCOORD2_V, {OutputRegisterInfo::TEXCOORD2, 2}},
156 {OutputAttributes::VIEW_X, {OutputRegisterInfo::VIEW, 1}}, 156 {OutputAttributes::VIEW_X, {OutputRegisterInfo::VIEW, 1}},
157 {OutputAttributes::VIEW_Y, {OutputRegisterInfo::VIEW, 2}}, 157 {OutputAttributes::VIEW_Y, {OutputRegisterInfo::VIEW, 2}},
158 {OutputAttributes::VIEW_Z, {OutputRegisterInfo::VIEW, 4}}}; 158 {OutputAttributes::VIEW_Z, {OutputRegisterInfo::VIEW, 4}},
159 };
159 160
160 for (const auto& semantic : std::vector<OutputAttributes::Semantic>{ 161 for (const auto& semantic : std::vector<OutputAttributes::Semantic>{
161 output_attributes[i].map_x, output_attributes[i].map_y, output_attributes[i].map_z, 162 output_attributes[i].map_x, output_attributes[i].map_y, output_attributes[i].map_z,
@@ -529,14 +530,16 @@ const Math::Vec4<u8> LookupTexture(const u8* source, int x, int y, const Texture
529 unsigned table_index = 530 unsigned table_index =
530 static_cast<int>((x < 2) ? table_index_1.Value() : table_index_2.Value()); 531 static_cast<int>((x < 2) ? table_index_1.Value() : table_index_2.Value());
531 532
532 static const std::array<std::array<u8, 2>, 8> etc1_modifier_table = {{{{2, 8}}, 533 static const std::array<std::array<u8, 2>, 8> etc1_modifier_table = {{
533 {{5, 17}}, 534 {{2, 8}},
534 {{9, 29}}, 535 {{5, 17}},
535 {{13, 42}}, 536 {{9, 29}},
536 {{18, 60}}, 537 {{13, 42}},
537 {{24, 80}}, 538 {{18, 60}},
538 {{33, 106}}, 539 {{24, 80}},
539 {{47, 183}}}}; 540 {{33, 106}},
541 {{47, 183}},
542 }};
540 543
541 int modifier = etc1_modifier_table.at(table_index).at(GetTableSubIndex(texel)); 544 int modifier = etc1_modifier_table.at(table_index).at(GetTableSubIndex(texel));
542 if (GetNegationFlag(texel)) 545 if (GetNegationFlag(texel))
@@ -713,9 +716,9 @@ static std::string GetTevStageConfigSourceString(const Pica::Regs::TevStageConfi
713 return src_it->second; 716 return src_it->second;
714} 717}
715 718
716static std::string 719static std::string GetTevStageConfigColorSourceString(
717GetTevStageConfigColorSourceString(const Pica::Regs::TevStageConfig::Source& source, 720 const Pica::Regs::TevStageConfig::Source& source,
718 const Pica::Regs::TevStageConfig::ColorModifier modifier) { 721 const Pica::Regs::TevStageConfig::ColorModifier modifier) {
719 using ColorModifier = Pica::Regs::TevStageConfig::ColorModifier; 722 using ColorModifier = Pica::Regs::TevStageConfig::ColorModifier;
720 static const std::map<ColorModifier, std::string> color_modifier_map = { 723 static const std::map<ColorModifier, std::string> color_modifier_map = {
721 {ColorModifier::SourceColor, "%source.rgb"}, 724 {ColorModifier::SourceColor, "%source.rgb"},
@@ -739,9 +742,9 @@ GetTevStageConfigColorSourceString(const Pica::Regs::TevStageConfig::Source& sou
739 return ReplacePattern(modifier_str, "%source", src_str); 742 return ReplacePattern(modifier_str, "%source", src_str);
740} 743}
741 744
742static std::string 745static std::string GetTevStageConfigAlphaSourceString(
743GetTevStageConfigAlphaSourceString(const Pica::Regs::TevStageConfig::Source& source, 746 const Pica::Regs::TevStageConfig::Source& source,
744 const Pica::Regs::TevStageConfig::AlphaModifier modifier) { 747 const Pica::Regs::TevStageConfig::AlphaModifier modifier) {
745 using AlphaModifier = Pica::Regs::TevStageConfig::AlphaModifier; 748 using AlphaModifier = Pica::Regs::TevStageConfig::AlphaModifier;
746 static const std::map<AlphaModifier, std::string> alpha_modifier_map = { 749 static const std::map<AlphaModifier, std::string> alpha_modifier_map = {
747 {AlphaModifier::SourceAlpha, "%source.a"}, 750 {AlphaModifier::SourceAlpha, "%source.a"},
@@ -763,8 +766,8 @@ GetTevStageConfigAlphaSourceString(const Pica::Regs::TevStageConfig::Source& sou
763 return ReplacePattern(modifier_str, "%source", src_str); 766 return ReplacePattern(modifier_str, "%source", src_str);
764} 767}
765 768
766static std::string 769static std::string GetTevStageConfigOperationString(
767GetTevStageConfigOperationString(const Pica::Regs::TevStageConfig::Operation& operation) { 770 const Pica::Regs::TevStageConfig::Operation& operation) {
768 using Operation = Pica::Regs::TevStageConfig::Operation; 771 using Operation = Pica::Regs::TevStageConfig::Operation;
769 static const std::map<Operation, std::string> combiner_map = { 772 static const std::map<Operation, std::string> combiner_map = {
770 {Operation::Replace, "%source1"}, 773 {Operation::Replace, "%source1"},
diff --git a/src/video_core/debug_utils/debug_utils.h b/src/video_core/debug_utils/debug_utils.h
index 1a58f40ff..fe3ed247d 100644
--- a/src/video_core/debug_utils/debug_utils.h
+++ b/src/video_core/debug_utils/debug_utils.h
@@ -87,15 +87,13 @@ public:
87 * @param data Optional data pointer (if unused, this is a nullptr) 87 * @param data Optional data pointer (if unused, this is a nullptr)
88 * @note This function will perform nothing unless it is overridden in the child class. 88 * @note This function will perform nothing unless it is overridden in the child class.
89 */ 89 */
90 virtual void OnPicaBreakPointHit(Event, void*) { 90 virtual void OnPicaBreakPointHit(Event, void*) {}
91 }
92 91
93 /** 92 /**
94 * Action to perform when emulation is resumed from a breakpoint. 93 * Action to perform when emulation is resumed from a breakpoint.
95 * @note This function will perform nothing unless it is overridden in the child class. 94 * @note This function will perform nothing unless it is overridden in the child class.
96 */ 95 */
97 virtual void OnPicaResume() { 96 virtual void OnPicaResume() {}
98 }
99 97
100 protected: 98 protected:
101 /** 99 /**
diff --git a/src/video_core/gpu_debugger.h b/src/video_core/gpu_debugger.h
index e3ba80d8f..aea391619 100644
--- a/src/video_core/gpu_debugger.h
+++ b/src/video_core/gpu_debugger.h
@@ -15,8 +15,7 @@ public:
15 // Base class for all objects which need to be notified about GPU events 15 // Base class for all objects which need to be notified about GPU events
16 class DebuggerObserver { 16 class DebuggerObserver {
17 public: 17 public:
18 DebuggerObserver() : observed(nullptr) { 18 DebuggerObserver() : observed(nullptr) {}
19 }
20 19
21 virtual ~DebuggerObserver() { 20 virtual ~DebuggerObserver() {
22 if (observed) 21 if (observed)
diff --git a/src/video_core/pica.h b/src/video_core/pica.h
index 1d1a686e0..b2db609ec 100644
--- a/src/video_core/pica.h
+++ b/src/video_core/pica.h
@@ -176,7 +176,10 @@ struct Regs {
176 MirroredRepeat = 3, 176 MirroredRepeat = 3,
177 }; 177 };
178 178
179 enum TextureFilter : u32 { Nearest = 0, Linear = 1 }; 179 enum TextureFilter : u32 {
180 Nearest = 0,
181 Linear = 1,
182 };
180 183
181 union { 184 union {
182 u32 raw; 185 u32 raw;
@@ -300,9 +303,11 @@ struct Regs {
300 const TextureFormat format; 303 const TextureFormat format;
301 }; 304 };
302 const std::array<FullTextureConfig, 3> GetTextures() const { 305 const std::array<FullTextureConfig, 3> GetTextures() const {
303 return {{{texture0_enable.ToBool(), texture0, texture0_format}, 306 return {{
304 {texture1_enable.ToBool(), texture1, texture1_format}, 307 {texture0_enable.ToBool(), texture0, texture0_format},
305 {texture2_enable.ToBool(), texture2, texture2_format}}}; 308 {texture1_enable.ToBool(), texture1, texture1_format},
309 {texture2_enable.ToBool(), texture2, texture2_format},
310 }};
306 } 311 }
307 312
308 // 0xc0-0xff: Texture Combiner (akin to glTexEnv) 313 // 0xc0-0xff: Texture Combiner (akin to glTexEnv)
@@ -523,7 +528,7 @@ struct Regs {
523 Decrement = 4, 528 Decrement = 4,
524 Invert = 5, 529 Invert = 5,
525 IncrementWrap = 6, 530 IncrementWrap = 6,
526 DecrementWrap = 7 531 DecrementWrap = 7,
527 }; 532 };
528 533
529 struct { 534 struct {
@@ -1173,7 +1178,10 @@ struct Regs {
1173 1178
1174 INSERT_PADDING_WORDS(0x07); 1179 INSERT_PADDING_WORDS(0x07);
1175 1180
1176 enum class GPUMode : u32 { Drawing = 0, Configuring = 1 }; 1181 enum class GPUMode : u32 {
1182 Drawing = 0,
1183 Configuring = 1,
1184 };
1177 1185
1178 GPUMode gpu_mode; 1186 GPUMode gpu_mode;
1179 1187
@@ -1249,7 +1257,10 @@ struct Regs {
1249 INSERT_PADDING_WORDS(0x2); 1257 INSERT_PADDING_WORDS(0x2);
1250 1258
1251 struct { 1259 struct {
1252 enum Format : u32 { FLOAT24 = 0, FLOAT32 = 1 }; 1260 enum Format : u32 {
1261 FLOAT24 = 0,
1262 FLOAT32 = 1,
1263 };
1253 1264
1254 bool IsFloat32() const { 1265 bool IsFloat32() const {
1255 return format == FLOAT32; 1266 return format == FLOAT32;
diff --git a/src/video_core/primitive_assembly.cpp b/src/video_core/primitive_assembly.cpp
index 343edb191..901cca26b 100644
--- a/src/video_core/primitive_assembly.cpp
+++ b/src/video_core/primitive_assembly.cpp
@@ -12,8 +12,7 @@ namespace Pica {
12 12
13template <typename VertexType> 13template <typename VertexType>
14PrimitiveAssembler<VertexType>::PrimitiveAssembler(Regs::TriangleTopology topology) 14PrimitiveAssembler<VertexType>::PrimitiveAssembler(Regs::TriangleTopology topology)
15 : topology(topology), buffer_index(0) { 15 : topology(topology), buffer_index(0) {}
16}
17 16
18template <typename VertexType> 17template <typename VertexType>
19void PrimitiveAssembler<VertexType>::SubmitVertex(VertexType& vtx, 18void PrimitiveAssembler<VertexType>::SubmitVertex(VertexType& vtx,
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp
index dbdc37ce6..f815d6cf0 100644
--- a/src/video_core/rasterizer.cpp
+++ b/src/video_core/rasterizer.cpp
@@ -268,10 +268,8 @@ static u8 PerformStencilAction(Regs::StencilAction action, u8 old_stencil, u8 re
268 268
269// NOTE: Assuming that rasterizer coordinates are 12.4 fixed-point values 269// NOTE: Assuming that rasterizer coordinates are 12.4 fixed-point values
270struct Fix12P4 { 270struct Fix12P4 {
271 Fix12P4() { 271 Fix12P4() {}
272 } 272 Fix12P4(u16 val) : val(val) {}
273 Fix12P4(u16 val) : val(val) {
274 }
275 273
276 static u16 FracMask() { 274 static u16 FracMask() {
277 return 0xF; 275 return 0xF;
@@ -491,7 +489,8 @@ static void ProcessTriangleInternal(const Shader::OutputVertex& v0, const Shader
491 255), 489 255),
492 (u8)( 490 (u8)(
493 GetInterpolatedAttribute(v0.color.a(), v1.color.a(), v2.color.a()).ToFloat32() * 491 GetInterpolatedAttribute(v0.color.a(), v1.color.a(), v2.color.a()).ToFloat32() *
494 255)}; 492 255),
493 };
495 494
496 Math::Vec2<float24> uv[3]; 495 Math::Vec2<float24> uv[3];
497 uv[0].u() = GetInterpolatedAttribute(v0.tc0.u(), v1.tc0.u(), v2.tc0.u()); 496 uv[0].u() = GetInterpolatedAttribute(v0.tc0.u(), v1.tc0.u(), v2.tc0.u());
@@ -604,7 +603,8 @@ static void ProcessTriangleInternal(const Shader::OutputVertex& v0, const Shader
604 Math::Vec4<u8> combiner_buffer = {0, 0, 0, 0}; 603 Math::Vec4<u8> combiner_buffer = {0, 0, 0, 0};
605 Math::Vec4<u8> next_combiner_buffer = { 604 Math::Vec4<u8> next_combiner_buffer = {
606 regs.tev_combiner_buffer_color.r, regs.tev_combiner_buffer_color.g, 605 regs.tev_combiner_buffer_color.r, regs.tev_combiner_buffer_color.g,
607 regs.tev_combiner_buffer_color.b, regs.tev_combiner_buffer_color.a}; 606 regs.tev_combiner_buffer_color.b, regs.tev_combiner_buffer_color.a,
607 };
608 608
609 for (unsigned tev_stage_index = 0; tev_stage_index < tev_stages.size(); 609 for (unsigned tev_stage_index = 0; tev_stage_index < tev_stages.size();
610 ++tev_stage_index) { 610 ++tev_stage_index) {
@@ -841,18 +841,16 @@ static void ProcessTriangleInternal(const Shader::OutputVertex& v0, const Shader
841 Math::Vec3<u8> color_result[3] = { 841 Math::Vec3<u8> color_result[3] = {
842 GetColorModifier(tev_stage.color_modifier1, GetSource(tev_stage.color_source1)), 842 GetColorModifier(tev_stage.color_modifier1, GetSource(tev_stage.color_source1)),
843 GetColorModifier(tev_stage.color_modifier2, GetSource(tev_stage.color_source2)), 843 GetColorModifier(tev_stage.color_modifier2, GetSource(tev_stage.color_source2)),
844 GetColorModifier(tev_stage.color_modifier3, 844 GetColorModifier(tev_stage.color_modifier3, GetSource(tev_stage.color_source3)),
845 GetSource(tev_stage.color_source3))}; 845 };
846 auto color_output = ColorCombine(tev_stage.color_op, color_result); 846 auto color_output = ColorCombine(tev_stage.color_op, color_result);
847 847
848 // alpha combiner 848 // alpha combiner
849 std::array<u8, 3> alpha_result = { 849 std::array<u8, 3> alpha_result = {{
850 {GetAlphaModifier(tev_stage.alpha_modifier1, 850 GetAlphaModifier(tev_stage.alpha_modifier1, GetSource(tev_stage.alpha_source1)),
851 GetSource(tev_stage.alpha_source1)), 851 GetAlphaModifier(tev_stage.alpha_modifier2, GetSource(tev_stage.alpha_source2)),
852 GetAlphaModifier(tev_stage.alpha_modifier2, 852 GetAlphaModifier(tev_stage.alpha_modifier3, GetSource(tev_stage.alpha_source3)),
853 GetSource(tev_stage.alpha_source2)), 853 }};
854 GetAlphaModifier(tev_stage.alpha_modifier3,
855 GetSource(tev_stage.alpha_source3))}};
856 auto alpha_output = AlphaCombine(tev_stage.alpha_op, alpha_result); 854 auto alpha_output = AlphaCombine(tev_stage.alpha_op, alpha_result);
857 855
858 combiner_output[0] = 856 combiner_output[0] =
@@ -1083,7 +1081,8 @@ static void ProcessTriangleInternal(const Shader::OutputVertex& v0, const Shader
1083 static_cast<u8>(output_merger.blend_const.r), 1081 static_cast<u8>(output_merger.blend_const.r),
1084 static_cast<u8>(output_merger.blend_const.g), 1082 static_cast<u8>(output_merger.blend_const.g),
1085 static_cast<u8>(output_merger.blend_const.b), 1083 static_cast<u8>(output_merger.blend_const.b),
1086 static_cast<u8>(output_merger.blend_const.a)}; 1084 static_cast<u8>(output_merger.blend_const.a),
1085 };
1087 1086
1088 switch (factor) { 1087 switch (factor) {
1089 case Regs::BlendFactor::Zero: 1088 case Regs::BlendFactor::Zero:
@@ -1267,11 +1266,12 @@ static void ProcessTriangleInternal(const Shader::OutputVertex& v0, const Shader
1267 LogicOp(combiner_output.a(), dest.a(), output_merger.logic_op)); 1266 LogicOp(combiner_output.a(), dest.a(), output_merger.logic_op));
1268 } 1267 }
1269 1268
1270 const Math::Vec4<u8> result = {output_merger.red_enable ? blend_output.r() : dest.r(), 1269 const Math::Vec4<u8> result = {
1271 output_merger.green_enable ? blend_output.g() : dest.g(), 1270 output_merger.red_enable ? blend_output.r() : dest.r(),
1272 output_merger.blue_enable ? blend_output.b() : dest.b(), 1271 output_merger.green_enable ? blend_output.g() : dest.g(),
1273 output_merger.alpha_enable ? blend_output.a() 1272 output_merger.blue_enable ? blend_output.b() : dest.b(),
1274 : dest.a()}; 1273 output_merger.alpha_enable ? blend_output.a() : dest.a(),
1274 };
1275 1275
1276 if (regs.framebuffer.allow_color_write != 0) 1276 if (regs.framebuffer.allow_color_write != 0)
1277 DrawPixel(x >> 4, y >> 4, result); 1277 DrawPixel(x >> 4, y >> 4, result);
diff --git a/src/video_core/rasterizer_interface.h b/src/video_core/rasterizer_interface.h
index ce834bd30..c7bd29f12 100644
--- a/src/video_core/rasterizer_interface.h
+++ b/src/video_core/rasterizer_interface.h
@@ -20,8 +20,7 @@ namespace VideoCore {
20 20
21class RasterizerInterface { 21class RasterizerInterface {
22public: 22public:
23 virtual ~RasterizerInterface() { 23 virtual ~RasterizerInterface() {}
24 }
25 24
26 /// Queues the primitive formed by the given vertices for rendering 25 /// Queues the primitive formed by the given vertices for rendering
27 virtual void AddTriangle(const Pica::Shader::OutputVertex& v0, 26 virtual void AddTriangle(const Pica::Shader::OutputVertex& v0,
diff --git a/src/video_core/renderer_base.h b/src/video_core/renderer_base.h
index 22e2f9815..daacdb167 100644
--- a/src/video_core/renderer_base.h
+++ b/src/video_core/renderer_base.h
@@ -17,8 +17,7 @@ public:
17 /// Used to reference a framebuffer 17 /// Used to reference a framebuffer
18 enum kFramebuffer { kFramebuffer_VirtualXFB = 0, kFramebuffer_EFB, kFramebuffer_Texture }; 18 enum kFramebuffer { kFramebuffer_VirtualXFB = 0, kFramebuffer_EFB, kFramebuffer_Texture };
19 19
20 virtual ~RendererBase() { 20 virtual ~RendererBase() {}
21 }
22 21
23 /// Swap buffers (render frame) 22 /// Swap buffers (render frame)
24 virtual void SwapBuffers() = 0; 23 virtual void SwapBuffers() = 0;
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 5021f48bc..37977464d 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -136,8 +136,7 @@ RasterizerOpenGL::RasterizerOpenGL() : shader_dirty(true) {
136 SyncDepthWriteMask(); 136 SyncDepthWriteMask();
137} 137}
138 138
139RasterizerOpenGL::~RasterizerOpenGL() { 139RasterizerOpenGL::~RasterizerOpenGL() {}
140}
141 140
142/** 141/**
143 * This is a helper function to resolve an issue with opposite quaternions being interpolated by 142 * This is a helper function to resolve an issue with opposite quaternions being interpolated by
@@ -1156,9 +1155,10 @@ void RasterizerOpenGL::SyncBlendColor() {
1156 1155
1157void RasterizerOpenGL::SyncFogColor() { 1156void RasterizerOpenGL::SyncFogColor() {
1158 const auto& regs = Pica::g_state.regs; 1157 const auto& regs = Pica::g_state.regs;
1159 uniform_block_data.data.fog_color = {regs.fog_color.r.Value() / 255.0f, 1158 uniform_block_data.data.fog_color = {
1160 regs.fog_color.g.Value() / 255.0f, 1159 regs.fog_color.r.Value() / 255.0f, regs.fog_color.g.Value() / 255.0f,
1161 regs.fog_color.b.Value() / 255.0f}; 1160 regs.fog_color.b.Value() / 255.0f,
1161 };
1162 uniform_block_data.dirty = true; 1162 uniform_block_data.dirty = true;
1163} 1163}
1164 1164
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index 70e9e64ef..60d70539c 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -41,12 +41,9 @@ struct ScreenInfo;
41 * two separate shaders sharing the same key. 41 * two separate shaders sharing the same key.
42 * 42 *
43 * We use a union because "implicitly-defined copy/move constructor for a union X copies the object 43 * We use a union because "implicitly-defined copy/move constructor for a union X copies the object
44 * representation of X." 44 * representation of X." and "implicitly-defined copy assignment operator for a union X copies the
45 * and "implicitly-defined copy assignment operator for a union X copies the object representation 45 * object representation (3.9) of X." = Bytewise copy instead of memberwise copy. This is important
46 * (3.9) of X." 46 * because the padding bytes are included in the hash and comparison between objects.
47 * = Bytewise copy instead of memberwise copy.
48 * This is important because the padding bytes are included in the hash and comparison between
49 * objects.
50 */ 47 */
51union PicaShaderConfig { 48union PicaShaderConfig {
52 49
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index 8f1477bcd..ec3300ca6 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -522,8 +522,8 @@ CachedSurface* RasterizerCacheOpenGL::GetSurfaceRect(const CachedSurface& params
522 return GetSurface(params, match_res_scale, load_if_create); 522 return GetSurface(params, match_res_scale, load_if_create);
523} 523}
524 524
525CachedSurface* 525CachedSurface* RasterizerCacheOpenGL::GetTextureSurface(
526RasterizerCacheOpenGL::GetTextureSurface(const Pica::Regs::FullTextureConfig& config) { 526 const Pica::Regs::FullTextureConfig& config) {
527 Pica::DebugUtils::TextureInfo info = 527 Pica::DebugUtils::TextureInfo info =
528 Pica::DebugUtils::TextureInfo::FromPicaRegister(config.config, config.format); 528 Pica::DebugUtils::TextureInfo::FromPicaRegister(config.config, config.format);
529 529
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
index db5b649da..b2272bda8 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
@@ -212,8 +212,8 @@ public:
212 212
213 /// Gets the color and depth surfaces and rect (resolution scaled) based on the framebuffer 213 /// Gets the color and depth surfaces and rect (resolution scaled) based on the framebuffer
214 /// configuration 214 /// configuration
215 std::tuple<CachedSurface*, CachedSurface*, MathUtil::Rectangle<int>> 215 std::tuple<CachedSurface*, CachedSurface*, MathUtil::Rectangle<int>> GetFramebufferSurfaces(
216 GetFramebufferSurfaces(const Pica::Regs::FramebufferConfig& config); 216 const Pica::Regs::FramebufferConfig& config);
217 217
218 /// Attempt to get a surface that exactly matches the fill region and format 218 /// Attempt to get a surface that exactly matches the fill region and format
219 CachedSurface* TryGetFillSurface(const GPU::Regs::MemoryFillConfig& config); 219 CachedSurface* TryGetFillSurface(const GPU::Regs::MemoryFillConfig& config);
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp
index f86cffee5..9392c67b8 100644
--- a/src/video_core/renderer_opengl/gl_shader_gen.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp
@@ -293,9 +293,7 @@ static void AppendAlphaTestCondition(std::string& out, Regs::CompareFunc func) {
293 case CompareFunc::LessThanOrEqual: 293 case CompareFunc::LessThanOrEqual:
294 case CompareFunc::GreaterThan: 294 case CompareFunc::GreaterThan:
295 case CompareFunc::GreaterThanOrEqual: { 295 case CompareFunc::GreaterThanOrEqual: {
296 static const char* op[] = { 296 static const char* op[] = {"!=", "==", ">=", ">", "<=", "<"};
297 "!=", "==", ">=", ">", "<=", "<",
298 };
299 unsigned index = (unsigned)func - (unsigned)CompareFunc::Equal; 297 unsigned index = (unsigned)func - (unsigned)CompareFunc::Equal;
300 out += "int(last_tex_env_out.a * 255.0f) " + std::string(op[index]) + " alphatest_ref"; 298 out += "int(last_tex_env_out.a * 255.0f) " + std::string(op[index]) + " alphatest_ref";
301 break; 299 break;
diff --git a/src/video_core/renderer_opengl/pica_to_gl.h b/src/video_core/renderer_opengl/pica_to_gl.h
index a604e94d4..415358b6c 100644
--- a/src/video_core/renderer_opengl/pica_to_gl.h
+++ b/src/video_core/renderer_opengl/pica_to_gl.h
@@ -26,7 +26,7 @@ namespace PicaToGL {
26inline GLenum TextureFilterMode(Pica::Regs::TextureConfig::TextureFilter mode) { 26inline GLenum TextureFilterMode(Pica::Regs::TextureConfig::TextureFilter mode) {
27 static const GLenum filter_mode_table[] = { 27 static const GLenum filter_mode_table[] = {
28 GL_NEAREST, // TextureFilter::Nearest 28 GL_NEAREST, // TextureFilter::Nearest
29 GL_LINEAR // TextureFilter::Linear 29 GL_LINEAR, // TextureFilter::Linear
30 }; 30 };
31 31
32 // Range check table for input 32 // Range check table for input
@@ -55,7 +55,7 @@ inline GLenum WrapMode(Pica::Regs::TextureConfig::WrapMode mode) {
55 GL_CLAMP_TO_EDGE, // WrapMode::ClampToEdge 55 GL_CLAMP_TO_EDGE, // WrapMode::ClampToEdge
56 GL_CLAMP_TO_BORDER, // WrapMode::ClampToBorder 56 GL_CLAMP_TO_BORDER, // WrapMode::ClampToBorder
57 GL_REPEAT, // WrapMode::Repeat 57 GL_REPEAT, // WrapMode::Repeat
58 GL_MIRRORED_REPEAT // WrapMode::MirroredRepeat 58 GL_MIRRORED_REPEAT, // WrapMode::MirroredRepeat
59 }; 59 };
60 60
61 // Range check table for input 61 // Range check table for input
@@ -192,7 +192,7 @@ inline GLenum StencilOp(Pica::Regs::StencilAction action) {
192 GL_DECR, // StencilAction::Decrement 192 GL_DECR, // StencilAction::Decrement
193 GL_INVERT, // StencilAction::Invert 193 GL_INVERT, // StencilAction::Invert
194 GL_INCR_WRAP, // StencilAction::IncrementWrap 194 GL_INCR_WRAP, // StencilAction::IncrementWrap
195 GL_DECR_WRAP // StencilAction::DecrementWrap 195 GL_DECR_WRAP, // StencilAction::DecrementWrap
196 }; 196 };
197 197
198 // Range check table for input 198 // Range check table for input
@@ -207,12 +207,16 @@ inline GLenum StencilOp(Pica::Regs::StencilAction action) {
207} 207}
208 208
209inline GLvec4 ColorRGBA8(const u32 color) { 209inline GLvec4 ColorRGBA8(const u32 color) {
210 return {{(color >> 0 & 0xFF) / 255.0f, (color >> 8 & 0xFF) / 255.0f, 210 return {{
211 (color >> 16 & 0xFF) / 255.0f, (color >> 24 & 0xFF) / 255.0f}}; 211 (color >> 0 & 0xFF) / 255.0f, (color >> 8 & 0xFF) / 255.0f, (color >> 16 & 0xFF) / 255.0f,
212 (color >> 24 & 0xFF) / 255.0f,
213 }};
212} 214}
213 215
214inline std::array<GLfloat, 3> LightColor(const Pica::Regs::LightColor& color) { 216inline std::array<GLfloat, 3> LightColor(const Pica::Regs::LightColor& color) {
215 return {{color.r / 255.0f, color.g / 255.0f, color.b / 255.0f}}; 217 return {{
218 color.r / 255.0f, color.g / 255.0f, color.b / 255.0f,
219 }};
216} 220}
217 221
218} // namespace 222} // namespace
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index 3cabda8f9..a1d08e04d 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -87,15 +87,13 @@ struct ScreenRectVertex {
87 * by a 3x2 matrix. 87 * by a 3x2 matrix.
88 */ 88 */
89static std::array<GLfloat, 3 * 2> MakeOrthographicMatrix(const float width, const float height) { 89static std::array<GLfloat, 3 * 2> MakeOrthographicMatrix(const float width, const float height) {
90 std::array<GLfloat, 3 * 2> matrix; 90 std::array<GLfloat, 3 * 2> matrix; // Laid out in column-major order
91 91
92 matrix[0] = 2.f / width; 92 // clang-format off
93 matrix[2] = 0.f; 93 matrix[0] = 2.f / width; matrix[2] = 0.f; matrix[4] = -1.f;
94 matrix[4] = -1.f; 94 matrix[1] = 0.f; matrix[3] = -2.f / height; matrix[5] = 1.f;
95 matrix[1] = 0.f;
96 matrix[3] = -2.f / height;
97 matrix[5] = 1.f;
98 // Last matrix row is implicitly assumed to be [0, 0, 1]. 95 // Last matrix row is implicitly assumed to be [0, 0, 1].
96 // clang-format on
99 97
100 return matrix; 98 return matrix;
101} 99}
@@ -107,8 +105,7 @@ RendererOpenGL::RendererOpenGL() {
107} 105}
108 106
109/// RendererOpenGL destructor 107/// RendererOpenGL destructor
110RendererOpenGL::~RendererOpenGL() { 108RendererOpenGL::~RendererOpenGL() {}
111}
112 109
113/// Swap buffers (render frame) 110/// Swap buffers (render frame)
114void RendererOpenGL::SwapBuffers() { 111void RendererOpenGL::SwapBuffers() {
@@ -215,8 +212,7 @@ void RendererOpenGL::LoadFBToScreenInfo(const GPU::Regs::FramebufferConfig& fram
215 212
216 // Update existing texture 213 // Update existing texture
217 // TODO: Test what happens on hardware when you change the framebuffer dimensions so that 214 // TODO: Test what happens on hardware when you change the framebuffer dimensions so that
218 // they 215 // they differ from the LCD resolution.
219 // differ from the LCD resolution.
220 // TODO: Applications could theoretically crash Citra here by specifying too large 216 // TODO: Applications could theoretically crash Citra here by specifying too large
221 // framebuffer sizes. We should make sure that this cannot happen. 217 // framebuffer sizes. We should make sure that this cannot happen.
222 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, framebuffer.width, framebuffer.height, 218 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, framebuffer.width, framebuffer.height,
@@ -231,10 +227,8 @@ void RendererOpenGL::LoadFBToScreenInfo(const GPU::Regs::FramebufferConfig& fram
231} 227}
232 228
233/** 229/**
234 * Fills active OpenGL texture with the given RGB color. 230 * Fills active OpenGL texture with the given RGB color. Since the color is solid, the texture can
235 * Since the color is solid, the texture can be 1x1 but will stretch across whatever it's rendered 231 * be 1x1 but will stretch across whatever it's rendered on.
236 * on.
237 * This has the added benefit of being *really fast*.
238 */ 232 */
239void RendererOpenGL::LoadColorToActiveGLTexture(u8 color_r, u8 color_g, u8 color_b, 233void RendererOpenGL::LoadColorToActiveGLTexture(u8 color_r, u8 color_g, u8 color_b,
240 const TextureInfo& texture) { 234 const TextureInfo& texture) {
@@ -424,8 +418,7 @@ void RendererOpenGL::DrawScreens() {
424} 418}
425 419
426/// Updates the framerate 420/// Updates the framerate
427void RendererOpenGL::UpdateFramerate() { 421void RendererOpenGL::UpdateFramerate() {}
428}
429 422
430/** 423/**
431 * Set the emulator window to use for renderer 424 * Set the emulator window to use for renderer
@@ -513,5 +506,4 @@ bool RendererOpenGL::Init() {
513} 506}
514 507
515/// Shutdown the renderer 508/// Shutdown the renderer
516void RendererOpenGL::ShutDown() { 509void RendererOpenGL::ShutDown() {}
517}
diff --git a/src/video_core/renderer_opengl/renderer_opengl.h b/src/video_core/renderer_opengl/renderer_opengl.h
index faeb519ec..762b790c1 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.h
+++ b/src/video_core/renderer_opengl/renderer_opengl.h
@@ -81,11 +81,14 @@ private:
81 OGLVertexArray vertex_array; 81 OGLVertexArray vertex_array;
82 OGLBuffer vertex_buffer; 82 OGLBuffer vertex_buffer;
83 OGLShader shader; 83 OGLShader shader;
84 std::array<ScreenInfo, 2> 84
85 screen_infos; ///< Display information for top and bottom screens respectively 85 /// Display information for top and bottom screens respectively
86 std::array<ScreenInfo, 2> screen_infos;
87
86 // Shader uniform location indices 88 // Shader uniform location indices
87 GLuint uniform_modelview_matrix; 89 GLuint uniform_modelview_matrix;
88 GLuint uniform_color_texture; 90 GLuint uniform_color_texture;
91
89 // Shader attribute input indices 92 // Shader attribute input indices
90 GLuint attrib_position; 93 GLuint attrib_position;
91 GLuint attrib_tex_coord; 94 GLuint attrib_tex_coord;
diff --git a/src/video_core/shader/shader.cpp b/src/video_core/shader/shader.cpp
index 852c5a9a0..c38bdcc3c 100644
--- a/src/video_core/shader/shader.cpp
+++ b/src/video_core/shader/shader.cpp
@@ -96,8 +96,8 @@ void ShaderSetup::Setup() {
96#ifdef ARCHITECTURE_x86_64 96#ifdef ARCHITECTURE_x86_64
97 if (VideoCore::g_shader_jit_enabled) { 97 if (VideoCore::g_shader_jit_enabled) {
98 u64 cache_key = 98 u64 cache_key =
99 (Common::ComputeHash64(&g_state.vs.program_code, sizeof(g_state.vs.program_code)) ^ 99 Common::ComputeHash64(&g_state.vs.program_code, sizeof(g_state.vs.program_code)) ^
100 Common::ComputeHash64(&g_state.vs.swizzle_data, sizeof(g_state.vs.swizzle_data))); 100 Common::ComputeHash64(&g_state.vs.swizzle_data, sizeof(g_state.vs.swizzle_data));
101 101
102 auto iter = shader_map.find(cache_key); 102 auto iter = shader_map.find(cache_key);
103 if (iter != shader_map.end()) { 103 if (iter != shader_map.end()) {
diff --git a/src/video_core/shader/shader.h b/src/video_core/shader/shader.h
index 830d933a8..79c716b6e 100644
--- a/src/video_core/shader/shader.h
+++ b/src/video_core/shader/shader.h
@@ -358,8 +358,7 @@ struct ShaderSetup {
358 358
359 /** 359 /**
360 * Performs any shader unit setup that only needs to happen once per shader (as opposed to once 360 * Performs any shader unit setup that only needs to happen once per shader (as opposed to once
361 * per 361 * per vertex, which would happen within the `Run` function).
362 * vertex, which would happen within the `Run` function).
363 */ 362 */
364 void Setup(); 363 void Setup();
365 364
diff --git a/src/video_core/shader/shader_interpreter.cpp b/src/video_core/shader/shader_interpreter.cpp
index 681ff9728..41df8a2fd 100644
--- a/src/video_core/shader/shader_interpreter.cpp
+++ b/src/video_core/shader/shader_interpreter.cpp
@@ -80,9 +80,8 @@ void RunInterpreter(const ShaderSetup& setup, UnitState<Debug>& state, unsigned
80 auto call = [&program_counter, &call_stack](UnitState<Debug>& state, u32 offset, 80 auto call = [&program_counter, &call_stack](UnitState<Debug>& state, u32 offset,
81 u32 num_instructions, u32 return_offset, 81 u32 num_instructions, u32 return_offset,
82 u8 repeat_count, u8 loop_increment) { 82 u8 repeat_count, u8 loop_increment) {
83 program_counter = 83 // -1 to make sure when incrementing the PC we end up at the correct offset
84 offset - 84 program_counter = offset - 1;
85 1; // -1 to make sure when incrementing the PC we end up at the correct offset
86 ASSERT(call_stack.size() < call_stack.capacity()); 85 ASSERT(call_stack.size() < call_stack.capacity());
87 call_stack.push_back( 86 call_stack.push_back(
88 {offset + num_instructions, return_offset, repeat_count, loop_increment, offset}); 87 {offset + num_instructions, return_offset, repeat_count, loop_increment, offset});
diff --git a/src/video_core/shader/shader_jit_x64.cpp b/src/video_core/shader/shader_jit_x64.cpp
index 04e04ba1a..d1b2ce8d5 100644
--- a/src/video_core/shader/shader_jit_x64.cpp
+++ b/src/video_core/shader/shader_jit_x64.cpp
@@ -590,8 +590,7 @@ void JitShader::Compile_RSQ(Instruction instr) {
590 Compile_DestEnable(instr, SRC1); 590 Compile_DestEnable(instr, SRC1);
591} 591}
592 592
593void JitShader::Compile_NOP(Instruction instr) { 593void JitShader::Compile_NOP(Instruction instr) {}
594}
595 594
596void JitShader::Compile_END(Instruction instr) { 595void JitShader::Compile_END(Instruction instr) {
597 ABI_PopRegistersAndAdjustStack(ABI_ALL_CALLEE_SAVED, 8); 596 ABI_PopRegistersAndAdjustStack(ABI_ALL_CALLEE_SAVED, 8);
diff --git a/src/video_core/swrasterizer.h b/src/video_core/swrasterizer.h
index bca9780e5..12dc56bef 100644
--- a/src/video_core/swrasterizer.h
+++ b/src/video_core/swrasterizer.h
@@ -19,15 +19,10 @@ namespace VideoCore {
19class SWRasterizer : public RasterizerInterface { 19class SWRasterizer : public RasterizerInterface {
20 void AddTriangle(const Pica::Shader::OutputVertex& v0, const Pica::Shader::OutputVertex& v1, 20 void AddTriangle(const Pica::Shader::OutputVertex& v0, const Pica::Shader::OutputVertex& v1,
21 const Pica::Shader::OutputVertex& v2) override; 21 const Pica::Shader::OutputVertex& v2) override;
22 void DrawTriangles() override { 22 void DrawTriangles() override {}
23 } 23 void NotifyPicaRegisterChanged(u32 id) override {}
24 void NotifyPicaRegisterChanged(u32 id) override { 24 void FlushAll() override {}
25 } 25 void FlushRegion(PAddr addr, u32 size) override {}
26 void FlushAll() override { 26 void FlushAndInvalidateRegion(PAddr addr, u32 size) override {}
27 }
28 void FlushRegion(PAddr addr, u32 size) override {
29 }
30 void FlushAndInvalidateRegion(PAddr addr, u32 size) override {
31 }
32}; 27};
33} 28}