VERY experimental Nintendo Switch 2 emulator
C++
GPU: Refactor "VertexShader" namespace to "Shader".
bunneif622a7854444
diff --git a/src/citra_qt/debugger/graphics_vertex_shader.cpp b/src/citra_qt/debugger/graphics_vertex_shader.cppindex f42a2f4ce6..566a986f5c 100644--- a/src/citra_qt/debugger/graphics_vertex_shader.cpp+++ b/src/citra_qt/debugger/graphics_vertex_shader.cpp@@ -8,7 +8,7 @@#include <QBoxLayout>#include <QTreeView>-#include "video_core/vertex_shader.h"+#include "video_core/shader_interpreter.h"#include "graphics_vertex_shader.h"diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txtindex 162108301a..e06d368e5e 100644--- a/src/video_core/CMakeLists.txt+++ b/src/video_core/CMakeLists.txt@@ -11,8 +11,8 @@ set(SRCSpica.cppprimitive_assembly.cpprasterizer.cpp+ shader_interpreter.cpputils.cpp- vertex_shader.cppvideo_core.cpp)@@ -35,8 +35,8 @@ set(HEADERSprimitive_assembly.hrasterizer.hrenderer_base.h+ shader_interpreter.hutils.h- vertex_shader.hvideo_core.h)diff --git a/src/video_core/clipper.cpp b/src/video_core/clipper.cppindex 558b49d60e..e397ca2e84 100644--- a/src/video_core/clipper.cpp+++ b/src/video_core/clipper.cpp@@ -7,7 +7,7 @@#include "clipper.h"#include "pica.h"#include "rasterizer.h"-#include "vertex_shader.h"+#include "shader_interpreter.h"namespace Pica {diff --git a/src/video_core/clipper.h b/src/video_core/clipper.hindex 19ce8e1403..6ed01e8772 100644--- a/src/video_core/clipper.h+++ b/src/video_core/clipper.h@@ -6,13 +6,13 @@namespace Pica {-namespace VertexShader {+namespace Shader {struct OutputVertex;}namespace Clipper {-using VertexShader::OutputVertex;+using Shader::OutputVertex;void ProcessTriangle(OutputVertex& v0, OutputVertex& v1, OutputVertex& v2);diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cppindex 243abe842c..e199424c38 100644--- a/src/video_core/command_processor.cpp+++ b/src/video_core/command_processor.cpp@@ -18,7 +18,7 @@#include "pica.h"#include "primitive_assembly.h"#include "renderer_base.h"-#include "vertex_shader.h"+#include "shader_interpreter.h"#include "video_core.h"namespace Pica {@@ -165,7 +165,7 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {DebugUtils::GeometryDumper geometry_dumper;PrimitiveAssembler<DebugUtils::GeometryDumper::Vertex> dumping_primitive_assembler(regs.triangle_topology.Value());#endif- PrimitiveAssembler<VertexShader::OutputVertex> primitive_assembler(regs.triangle_topology.Value());+ PrimitiveAssembler<Shader::OutputVertex> primitive_assembler(regs.triangle_topology.Value());if (g_debug_context) {for (int i = 0; i < 3; ++i) {@@ -210,7 +210,7 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {// The size has been tuned for optimal balance between hit-rate and the cost of lookupconst size_t VERTEX_CACHE_SIZE = 32;std::array<u16, VERTEX_CACHE_SIZE> vertex_cache_ids;- std::array<VertexShader::OutputVertex, VERTEX_CACHE_SIZE> vertex_cache;+ std::array<Shader::OutputVertex, VERTEX_CACHE_SIZE> vertex_cache;unsigned int vertex_cache_pos = 0;vertex_cache_ids.fill(-1);@@ -224,7 +224,7 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {ASSERT(vertex != -1);bool vertex_cache_hit = false;- VertexShader::OutputVertex output;+ Shader::OutputVertex output;if (is_indexed) {if (g_debug_context && Pica::g_debug_context->recorder) {@@ -243,7 +243,7 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {if (!vertex_cache_hit) {// Initialize data for the current vertex- VertexShader::InputVertex input;+ Shader::InputVertex input;for (int i = 0; i < attribute_config.GetNumTotalAttributes(); ++i) {if (vertex_attribute_elements[i] != 0) {@@ -306,9 +306,8 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {std::bind(&DebugUtils::GeometryDumper::AddTriangle,&geometry_dumper, _1, _2, _3));#endif-// Send to vertex shader- output = VertexShader::RunShader(input, attribute_config.GetNumTotalAttributes(), g_state.regs.vs, g_state.vs);+ output = Shader::RunShader(input, attribute_config.GetNumTotalAttributes(), g_state.regs.vs, g_state.vs);if (is_indexed) {vertex_cache[vertex_cache_pos] = output;@@ -319,9 +318,9 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {if (Settings::values.use_hw_renderer) {// Send to hardware renderer- static auto AddHWTriangle = [](const Pica::VertexShader::OutputVertex& v0,- const Pica::VertexShader::OutputVertex& v1,- const Pica::VertexShader::OutputVertex& v2) {+ static auto AddHWTriangle = [](const Pica::Shader::OutputVertex& v0,+ const Pica::Shader::OutputVertex& v1,+ const Pica::Shader::OutputVertex& v2) {VideoCore::g_renderer->hw_rasterizer->AddTriangle(v0, v1, v2);};diff --git a/src/video_core/hwrasterizer_base.h b/src/video_core/hwrasterizer_base.hindex c8746c608a..54b8892fb2 100644--- a/src/video_core/hwrasterizer_base.h+++ b/src/video_core/hwrasterizer_base.h@@ -7,7 +7,7 @@#include "common/common_types.h"namespace Pica {-namespace VertexShader {+namespace Shader {struct OutputVertex;}}@@ -24,9 +24,9 @@ public:virtual void Reset() = 0;/// Queues the primitive formed by the given vertices for rendering- virtual void AddTriangle(const Pica::VertexShader::OutputVertex& v0,- const Pica::VertexShader::OutputVertex& v1,- const Pica::VertexShader::OutputVertex& v2) = 0;+ virtual void AddTriangle(const Pica::Shader::OutputVertex& v0,+ const Pica::Shader::OutputVertex& v1,+ const Pica::Shader::OutputVertex& v2) = 0;/// Draw the current batch of trianglesvirtual void DrawTriangles() = 0;diff --git a/src/video_core/primitive_assembly.cpp b/src/video_core/primitive_assembly.cppindex 2f22bdccef..e15a1daba6 100644--- a/src/video_core/primitive_assembly.cpp+++ b/src/video_core/primitive_assembly.cpp@@ -4,7 +4,7 @@#include "pica.h"#include "primitive_assembly.h"-#include "vertex_shader.h"+#include "shader_interpreter.h"#include "common/logging/log.h"#include "video_core/debug_utils/debug_utils.h"@@ -56,7 +56,7 @@ void PrimitiveAssembler<VertexType>::SubmitVertex(VertexType& vtx, TriangleHandl// explicitly instantiate use casestemplate-struct PrimitiveAssembler<VertexShader::OutputVertex>;+struct PrimitiveAssembler<Shader::OutputVertex>;templatestruct PrimitiveAssembler<DebugUtils::GeometryDumper::Vertex>;diff --git a/src/video_core/primitive_assembly.h b/src/video_core/primitive_assembly.hindex 52ff4cd890..0de0b88102 100644--- a/src/video_core/primitive_assembly.h+++ b/src/video_core/primitive_assembly.h@@ -8,7 +8,7 @@#include "video_core/pica.h"-#include "video_core/vertex_shader.h"+#include "video_core/shader_interpreter.h"namespace Pica {diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cppindex 68b7cc05db..4f94313dfb 100644--- a/src/video_core/rasterizer.cpp+++ b/src/video_core/rasterizer.cpp@@ -16,7 +16,7 @@#include "math.h"#include "pica.h"#include "rasterizer.h"-#include "vertex_shader.h"+#include "shader_interpreter.h"#include "video_core/utils.h"namespace Pica {@@ -272,9 +272,9 @@ static Common::Profiling::TimingCategory rasterization_category("Rasterization")* Helper function for ProcessTriangle with the "reversed" flag to allow for implementing* culling via recursion.*/-static void ProcessTriangleInternal(const VertexShader::OutputVertex& v0,- const VertexShader::OutputVertex& v1,- const VertexShader::OutputVertex& v2,+static void ProcessTriangleInternal(const Shader::OutputVertex& v0,+ const Shader::OutputVertex& v1,+ const Shader::OutputVertex& v2,bool reversed = false){const auto& regs = g_state.regs;@@ -1107,9 +1107,9 @@ static void ProcessTriangleInternal(const VertexShader::OutputVertex& v0,}}-void ProcessTriangle(const VertexShader::OutputVertex& v0,- const VertexShader::OutputVertex& v1,- const VertexShader::OutputVertex& v2) {+void ProcessTriangle(const Shader::OutputVertex& v0,+ const Shader::OutputVertex& v1,+ const Shader::OutputVertex& v2) {ProcessTriangleInternal(v0, v1, v2);}diff --git a/src/video_core/rasterizer.h b/src/video_core/rasterizer.hindex 42148f8b13..a6a9634b45 100644--- a/src/video_core/rasterizer.h+++ b/src/video_core/rasterizer.h@@ -6,15 +6,15 @@namespace Pica {-namespace VertexShader {+namespace Shader {struct OutputVertex;}namespace Rasterizer {-void ProcessTriangle(const VertexShader::OutputVertex& v0,- const VertexShader::OutputVertex& v1,- const VertexShader::OutputVertex& v2);+void ProcessTriangle(const Shader::OutputVertex& v0,+ const Shader::OutputVertex& v1,+ const Shader::OutputVertex& v2);} // namespace Rasterizerdiff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cppindex e7c1cfeb75..9f1552adf9 100644--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp@@ -202,9 +202,9 @@ void RasterizerOpenGL::Reset() {res_cache.FullFlush();}-void RasterizerOpenGL::AddTriangle(const Pica::VertexShader::OutputVertex& v0,- const Pica::VertexShader::OutputVertex& v1,- const Pica::VertexShader::OutputVertex& v2) {+void RasterizerOpenGL::AddTriangle(const Pica::Shader::OutputVertex& v0,+ const Pica::Shader::OutputVertex& v1,+ const Pica::Shader::OutputVertex& v2) {vertex_batch.push_back(HardwareVertex(v0));vertex_batch.push_back(HardwareVertex(v1));vertex_batch.push_back(HardwareVertex(v2));diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.hindex ae7b26fc66..9018b5e886 100644--- a/src/video_core/renderer_opengl/gl_rasterizer.h+++ b/src/video_core/renderer_opengl/gl_rasterizer.h@@ -9,7 +9,7 @@#include "common/common_types.h"#include "video_core/hwrasterizer_base.h"-#include "video_core/vertex_shader.h"+#include "video_core/shader_interpreter.h"#include "gl_state.h"#include "gl_rasterizer_cache.h"@@ -27,9 +27,9 @@ public:void Reset() override;/// Queues the primitive formed by the given vertices for rendering- void AddTriangle(const Pica::VertexShader::OutputVertex& v0,- const Pica::VertexShader::OutputVertex& v1,- const Pica::VertexShader::OutputVertex& v2) override;+ void AddTriangle(const Pica::Shader::OutputVertex& v0,+ const Pica::Shader::OutputVertex& v1,+ const Pica::Shader::OutputVertex& v2) override;/// Draw the current batch of trianglesvoid DrawTriangles() override;@@ -82,7 +82,7 @@ private:/// Structure that the hardware rendered vertices are composed ofstruct HardwareVertex {- HardwareVertex(const Pica::VertexShader::OutputVertex& v) {+ HardwareVertex(const Pica::Shader::OutputVertex& v) {position[0] = v.pos.x.ToFloat32();position[1] = v.pos.y.ToFloat32();position[2] = v.pos.z.ToFloat32();diff --git a/src/video_core/vertex_shader.cpp b/src/video_core/shader_interpreter.cppsimilarity index 98%rename from src/video_core/vertex_shader.cpprename to src/video_core/shader_interpreter.cppindex 5f66f3455f..3cce26d364 100644--- a/src/video_core/vertex_shader.cpp+++ b/src/video_core/shader_interpreter.cpp@@ -12,7 +12,7 @@#include "common/profiler.h"#include "pica.h"-#include "vertex_shader.h"+#include "shader_interpreter.h"#include "debug_utils/debug_utils.h"using nihstro::OpCode;@@ -23,9 +23,9 @@ using nihstro::SwizzlePattern;namespace Pica {-namespace VertexShader {+namespace Shader {-struct VertexShaderState {+struct ShaderState {u32 program_counter;const float24* input_register_table[16];@@ -60,7 +60,7 @@ struct VertexShaderState {} debug;};-static void ProcessShaderCode(VertexShaderState& state) {+static void ProcessShaderCode(ShaderState& state) {const auto& uniforms = g_state.vs.uniforms;const auto& swizzle_data = g_state.vs.swizzle_data;const auto& program_code = g_state.vs.program_code;@@ -90,7 +90,7 @@ static void ProcessShaderCode(VertexShaderState& state) {const Instruction instr = { program_code[state.program_counter] };const SwizzlePattern swizzle = { swizzle_data[instr.common.operand_desc_id] };- static auto call = [](VertexShaderState& state, u32 offset, u32 num_instructions,+ static auto call = [](ShaderState& state, u32 offset, u32 num_instructions,u32 return_offset, u8 repeat_count, u8 loop_increment) {state.program_counter = offset - 1; // -1 to make sure when incrementing the PC we end up at the correct offsetASSERT(state.call_stack.size() < state.call_stack.capacity());@@ -413,7 +413,7 @@ static void ProcessShaderCode(VertexShaderState& state) {default:{- static auto evaluate_condition = [](const VertexShaderState& state, bool refx, bool refy, Instruction::FlowControlType flow_control) {+ static auto evaluate_condition = [](const ShaderState& state, bool refx, bool refy, Instruction::FlowControlType flow_control) {bool results[2] = { refx == state.conditional_code[0],refy == state.conditional_code[1] };@@ -547,7 +547,7 @@ static Common::Profiling::TimingCategory shader_category("Vertex Shader");OutputVertex RunShader(const InputVertex& input, int num_attributes, const Regs::ShaderConfig& config, const State::ShaderSetup& setup) {Common::Profiling::ScopeTimer timer(shader_category);- VertexShaderState state;+ ShaderState state;state.program_counter = config.main_offset;state.debug.max_offset = 0;diff --git a/src/video_core/vertex_shader.h b/src/video_core/shader_interpreter.hsimilarity index 98%rename from src/video_core/vertex_shader.hrename to src/video_core/shader_interpreter.hindex 97f9250ddf..942a308419 100644--- a/src/video_core/vertex_shader.h+++ b/src/video_core/shader_interpreter.h@@ -12,7 +12,7 @@namespace Pica {-namespace VertexShader {+namespace Shader {struct InputVertex {Math::Vec4<float24> attr[16];@@ -70,4 +70,3 @@ OutputVertex RunShader(const InputVertex& input, int num_attributes, const Regs:} // namespace} // namespace-