diff options
21 files changed, 177 insertions, 61 deletions
diff --git a/src/citra_qt/debugger/graphics_cmdlists.cpp b/src/citra_qt/debugger/graphics_cmdlists.cpp index ab97c8d2d..5186d2b44 100644 --- a/src/citra_qt/debugger/graphics_cmdlists.cpp +++ b/src/citra_qt/debugger/graphics_cmdlists.cpp | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | #include "common/vector_math.h" | 21 | #include "common/vector_math.h" |
| 22 | 22 | ||
| 23 | #include "video_core/pica.h" | 23 | #include "video_core/pica.h" |
| 24 | #include "video_core/pica_state.h" | ||
| 24 | #include "video_core/debug_utils/debug_utils.h" | 25 | #include "video_core/debug_utils/debug_utils.h" |
| 25 | 26 | ||
| 26 | QImage LoadTexture(u8* src, const Pica::DebugUtils::TextureInfo& info) { | 27 | QImage LoadTexture(u8* src, const Pica::DebugUtils::TextureInfo& info) { |
diff --git a/src/citra_qt/debugger/graphics_framebuffer.cpp b/src/citra_qt/debugger/graphics_framebuffer.cpp index 80b32eaff..c30e75933 100644 --- a/src/citra_qt/debugger/graphics_framebuffer.cpp +++ b/src/citra_qt/debugger/graphics_framebuffer.cpp | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | #include "core/hw/gpu.h" | 18 | #include "core/hw/gpu.h" |
| 19 | 19 | ||
| 20 | #include "video_core/pica.h" | 20 | #include "video_core/pica.h" |
| 21 | #include "video_core/pica_state.h" | ||
| 21 | #include "video_core/utils.h" | 22 | #include "video_core/utils.h" |
| 22 | 23 | ||
| 23 | GraphicsFramebufferWidget::GraphicsFramebufferWidget(std::shared_ptr<Pica::DebugContext> debug_context, | 24 | GraphicsFramebufferWidget::GraphicsFramebufferWidget(std::shared_ptr<Pica::DebugContext> debug_context, |
diff --git a/src/citra_qt/debugger/graphics_tracing.cpp b/src/citra_qt/debugger/graphics_tracing.cpp index b0bc782df..e06498744 100644 --- a/src/citra_qt/debugger/graphics_tracing.cpp +++ b/src/citra_qt/debugger/graphics_tracing.cpp | |||
| @@ -22,7 +22,7 @@ | |||
| 22 | #include "nihstro/float24.h" | 22 | #include "nihstro/float24.h" |
| 23 | 23 | ||
| 24 | #include "video_core/pica.h" | 24 | #include "video_core/pica.h" |
| 25 | 25 | #include "video_core/pica_state.h" | |
| 26 | 26 | ||
| 27 | GraphicsTracingWidget::GraphicsTracingWidget(std::shared_ptr<Pica::DebugContext> debug_context, | 27 | GraphicsTracingWidget::GraphicsTracingWidget(std::shared_ptr<Pica::DebugContext> debug_context, |
| 28 | QWidget* parent) | 28 | QWidget* parent) |
diff --git a/src/citra_qt/debugger/graphics_vertex_shader.cpp b/src/citra_qt/debugger/graphics_vertex_shader.cpp index a5a5fe6b0..a11c61667 100644 --- a/src/citra_qt/debugger/graphics_vertex_shader.cpp +++ b/src/citra_qt/debugger/graphics_vertex_shader.cpp | |||
| @@ -19,6 +19,8 @@ | |||
| 19 | #include "citra_qt/debugger/graphics_vertex_shader.h" | 19 | #include "citra_qt/debugger/graphics_vertex_shader.h" |
| 20 | #include "citra_qt/util/util.h" | 20 | #include "citra_qt/util/util.h" |
| 21 | 21 | ||
| 22 | #include "video_core/pica.h" | ||
| 23 | #include "video_core/pica_state.h" | ||
| 22 | #include "video_core/shader/shader.h" | 24 | #include "video_core/shader/shader.h" |
| 23 | 25 | ||
| 24 | using nihstro::OpCode; | 26 | using nihstro::OpCode; |
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index 4b5d298f3..76cfd4f7d 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt | |||
| @@ -33,6 +33,7 @@ set(HEADERS | |||
| 33 | command_processor.h | 33 | command_processor.h |
| 34 | gpu_debugger.h | 34 | gpu_debugger.h |
| 35 | pica.h | 35 | pica.h |
| 36 | pica_state.h | ||
| 36 | pica_types.h | 37 | pica_types.h |
| 37 | primitive_assembly.h | 38 | primitive_assembly.h |
| 38 | rasterizer.h | 39 | rasterizer.h |
diff --git a/src/video_core/clipper.cpp b/src/video_core/clipper.cpp index a385589d2..3d503486e 100644 --- a/src/video_core/clipper.cpp +++ b/src/video_core/clipper.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include "video_core/clipper.h" | 7 | #include "video_core/clipper.h" |
| 8 | #include "video_core/pica.h" | 8 | #include "video_core/pica.h" |
| 9 | #include "video_core/pica_state.h" | ||
| 9 | #include "video_core/rasterizer.h" | 10 | #include "video_core/rasterizer.h" |
| 10 | #include "video_core/shader/shader_interpreter.h" | 11 | #include "video_core/shader/shader_interpreter.h" |
| 11 | 12 | ||
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index 73fdfbe9c..2f92be661 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #include "video_core/clipper.h" | 15 | #include "video_core/clipper.h" |
| 16 | #include "video_core/command_processor.h" | 16 | #include "video_core/command_processor.h" |
| 17 | #include "video_core/pica.h" | 17 | #include "video_core/pica.h" |
| 18 | #include "video_core/pica_state.h" | ||
| 18 | #include "video_core/primitive_assembly.h" | 19 | #include "video_core/primitive_assembly.h" |
| 19 | #include "video_core/renderer_base.h" | 20 | #include "video_core/renderer_base.h" |
| 20 | #include "video_core/video_core.h" | 21 | #include "video_core/video_core.h" |
| @@ -73,6 +74,14 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 73 | GSP_GPU::SignalInterrupt(GSP_GPU::InterruptId::P3D); | 74 | GSP_GPU::SignalInterrupt(GSP_GPU::InterruptId::P3D); |
| 74 | break; | 75 | break; |
| 75 | 76 | ||
| 77 | case PICA_REG_INDEX_WORKAROUND(vs_default_attributes_setup.index, 0x232): | ||
| 78 | if (regs.vs_default_attributes_setup.index == 15) { | ||
| 79 | // Reset immediate primitive state | ||
| 80 | g_state.immediate.primitive_assembler.Reconfigure(regs.triangle_topology); | ||
| 81 | g_state.immediate.attribute_id = 0; | ||
| 82 | } | ||
| 83 | break; | ||
| 84 | |||
| 76 | // Load default vertex input attributes | 85 | // Load default vertex input attributes |
| 77 | case PICA_REG_INDEX_WORKAROUND(vs_default_attributes_setup.set_value[0], 0x233): | 86 | case PICA_REG_INDEX_WORKAROUND(vs_default_attributes_setup.set_value[0], 0x233): |
| 78 | case PICA_REG_INDEX_WORKAROUND(vs_default_attributes_setup.set_value[1], 0x234): | 87 | case PICA_REG_INDEX_WORKAROUND(vs_default_attributes_setup.set_value[1], 0x234): |
| @@ -108,11 +117,48 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 108 | attribute.w.ToFloat32()); | 117 | attribute.w.ToFloat32()); |
| 109 | 118 | ||
| 110 | // TODO: Verify that this actually modifies the register! | 119 | // TODO: Verify that this actually modifies the register! |
| 111 | setup.index = setup.index + 1; | 120 | if (setup.index < 15) { |
| 121 | setup.index++; | ||
| 122 | } else { | ||
| 123 | // Put each attribute into an immediate input buffer. | ||
| 124 | // When all specified immediate attributes are present, the Vertex Shader is invoked and everything is | ||
| 125 | // sent to the primitive assembler. | ||
| 126 | |||
| 127 | auto& immediate_input = g_state.immediate.input; | ||
| 128 | auto& immediate_attribute_id = g_state.immediate.attribute_id; | ||
| 129 | const auto& attribute_config = regs.vertex_attributes; | ||
| 130 | |||
| 131 | immediate_input.attr[immediate_attribute_id++] = attribute; | ||
| 132 | |||
| 133 | if (immediate_attribute_id >= attribute_config.GetNumTotalAttributes()) { | ||
| 134 | immediate_attribute_id = 0; | ||
| 135 | |||
| 136 | Shader::UnitState<false> shader_unit; | ||
| 137 | Shader::Setup(shader_unit); | ||
| 138 | |||
| 139 | // Send to vertex shader | ||
| 140 | Shader::OutputVertex output = Shader::Run(shader_unit, immediate_input, attribute_config.GetNumTotalAttributes()); | ||
| 141 | |||
| 142 | // Send to renderer | ||
| 143 | using Pica::Shader::OutputVertex; | ||
| 144 | auto AddTriangle = [](const OutputVertex& v0, const OutputVertex& v1, const OutputVertex& v2) { | ||
| 145 | VideoCore::g_renderer->rasterizer->AddTriangle(v0, v1, v2); | ||
| 146 | }; | ||
| 147 | |||
| 148 | g_state.immediate.primitive_assembler.SubmitVertex(output, AddTriangle); | ||
| 149 | } | ||
| 150 | } | ||
| 112 | } | 151 | } |
| 113 | break; | 152 | break; |
| 114 | } | 153 | } |
| 115 | 154 | ||
| 155 | case PICA_REG_INDEX(gpu_mode): | ||
| 156 | if (regs.gpu_mode == Regs::GPUMode::Configuring && regs.vs_default_attributes_setup.index == 15) { | ||
| 157 | // Draw immediate mode triangles when GPU Mode is set to GPUMode::Configuring | ||
| 158 | VideoCore::g_renderer->rasterizer->DrawTriangles(); | ||
| 159 | } | ||
| 160 | break; | ||
| 161 | |||
| 116 | case PICA_REG_INDEX_WORKAROUND(command_buffer.trigger[0], 0x23c): | 162 | case PICA_REG_INDEX_WORKAROUND(command_buffer.trigger[0], 0x23c): |
| 117 | case PICA_REG_INDEX_WORKAROUND(command_buffer.trigger[1], 0x23d): | 163 | case PICA_REG_INDEX_WORKAROUND(command_buffer.trigger[1], 0x23d): |
| 118 | { | 164 | { |
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp index 6e6fd7335..6e21caa78 100644 --- a/src/video_core/debug_utils/debug_utils.cpp +++ b/src/video_core/debug_utils/debug_utils.cpp | |||
| @@ -28,6 +28,7 @@ | |||
| 28 | #include "core/settings.h" | 28 | #include "core/settings.h" |
| 29 | 29 | ||
| 30 | #include "video_core/pica.h" | 30 | #include "video_core/pica.h" |
| 31 | #include "video_core/pica_state.h" | ||
| 31 | #include "video_core/renderer_base.h" | 32 | #include "video_core/renderer_base.h" |
| 32 | #include "video_core/utils.h" | 33 | #include "video_core/utils.h" |
| 33 | #include "video_core/video_core.h" | 34 | #include "video_core/video_core.h" |
| @@ -113,7 +114,7 @@ void GeometryDumper::Dump() { | |||
| 113 | } | 114 | } |
| 114 | 115 | ||
| 115 | 116 | ||
| 116 | void DumpShader(const std::string& filename, const Regs::ShaderConfig& config, const State::ShaderSetup& setup, const Regs::VSOutputAttributes* output_attributes) | 117 | void DumpShader(const std::string& filename, const Regs::ShaderConfig& config, const Shader::ShaderSetup& setup, const Regs::VSOutputAttributes* output_attributes) |
| 117 | { | 118 | { |
| 118 | struct StuffToWrite { | 119 | struct StuffToWrite { |
| 119 | u8* pointer; | 120 | u8* pointer; |
diff --git a/src/video_core/debug_utils/debug_utils.h b/src/video_core/debug_utils/debug_utils.h index 85762f5b4..795160a32 100644 --- a/src/video_core/debug_utils/debug_utils.h +++ b/src/video_core/debug_utils/debug_utils.h | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include "core/tracer/recorder.h" | 17 | #include "core/tracer/recorder.h" |
| 18 | 18 | ||
| 19 | #include "video_core/pica.h" | 19 | #include "video_core/pica.h" |
| 20 | #include "video_core/shader/shader.h" | ||
| 20 | 21 | ||
| 21 | namespace Pica { | 22 | namespace Pica { |
| 22 | 23 | ||
| @@ -182,7 +183,7 @@ private: | |||
| 182 | }; | 183 | }; |
| 183 | 184 | ||
| 184 | void DumpShader(const std::string& filename, const Regs::ShaderConfig& config, | 185 | void DumpShader(const std::string& filename, const Regs::ShaderConfig& config, |
| 185 | const State::ShaderSetup& setup, const Regs::VSOutputAttributes* output_attributes); | 186 | const Shader::ShaderSetup& setup, const Regs::VSOutputAttributes* output_attributes); |
| 186 | 187 | ||
| 187 | 188 | ||
| 188 | // Utility class to log Pica commands. | 189 | // Utility class to log Pica commands. |
diff --git a/src/video_core/pica.cpp b/src/video_core/pica.cpp index d7b31384a..32ad72674 100644 --- a/src/video_core/pica.cpp +++ b/src/video_core/pica.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include <unordered_map> | 6 | #include <unordered_map> |
| 7 | 7 | ||
| 8 | #include "video_core/pica.h" | 8 | #include "video_core/pica.h" |
| 9 | #include "video_core/pica_state.h" | ||
| 9 | #include "video_core/shader/shader.h" | 10 | #include "video_core/shader/shader.h" |
| 10 | 11 | ||
| 11 | namespace Pica { | 12 | namespace Pica { |
diff --git a/src/video_core/pica.h b/src/video_core/pica.h index 9077b1725..2e0c33201 100644 --- a/src/video_core/pica.h +++ b/src/video_core/pica.h | |||
| @@ -1089,7 +1089,16 @@ struct Regs { | |||
| 1089 | } | 1089 | } |
| 1090 | } command_buffer; | 1090 | } command_buffer; |
| 1091 | 1091 | ||
| 1092 | INSERT_PADDING_WORDS(0x20); | 1092 | INSERT_PADDING_WORDS(0x07); |
| 1093 | |||
| 1094 | enum class GPUMode : u32 { | ||
| 1095 | Drawing = 0, | ||
| 1096 | Configuring = 1 | ||
| 1097 | }; | ||
| 1098 | |||
| 1099 | GPUMode gpu_mode; | ||
| 1100 | |||
| 1101 | INSERT_PADDING_WORDS(0x18); | ||
| 1093 | 1102 | ||
| 1094 | enum class TriangleTopology : u32 { | 1103 | enum class TriangleTopology : u32 { |
| 1095 | List = 0, | 1104 | List = 0, |
| @@ -1278,6 +1287,7 @@ ASSERT_REG_POSITION(trigger_draw, 0x22e); | |||
| 1278 | ASSERT_REG_POSITION(trigger_draw_indexed, 0x22f); | 1287 | ASSERT_REG_POSITION(trigger_draw_indexed, 0x22f); |
| 1279 | ASSERT_REG_POSITION(vs_default_attributes_setup, 0x232); | 1288 | ASSERT_REG_POSITION(vs_default_attributes_setup, 0x232); |
| 1280 | ASSERT_REG_POSITION(command_buffer, 0x238); | 1289 | ASSERT_REG_POSITION(command_buffer, 0x238); |
| 1290 | ASSERT_REG_POSITION(gpu_mode, 0x245); | ||
| 1281 | ASSERT_REG_POSITION(triangle_topology, 0x25e); | 1291 | ASSERT_REG_POSITION(triangle_topology, 0x25e); |
| 1282 | ASSERT_REG_POSITION(restart_primitive, 0x25f); | 1292 | ASSERT_REG_POSITION(restart_primitive, 0x25f); |
| 1283 | ASSERT_REG_POSITION(gs, 0x280); | 1293 | ASSERT_REG_POSITION(gs, 0x280); |
| @@ -1292,64 +1302,10 @@ static_assert(sizeof(Regs::ShaderConfig) == 0x30 * sizeof(u32), "ShaderConfig st | |||
| 1292 | static_assert(sizeof(Regs) <= 0x300 * sizeof(u32), "Register set structure larger than it should be"); | 1302 | static_assert(sizeof(Regs) <= 0x300 * sizeof(u32), "Register set structure larger than it should be"); |
| 1293 | static_assert(sizeof(Regs) >= 0x300 * sizeof(u32), "Register set structure smaller than it should be"); | 1303 | static_assert(sizeof(Regs) >= 0x300 * sizeof(u32), "Register set structure smaller than it should be"); |
| 1294 | 1304 | ||
| 1295 | /// Struct used to describe current Pica state | ||
| 1296 | struct State { | ||
| 1297 | /// Pica registers | ||
| 1298 | Regs regs; | ||
| 1299 | |||
| 1300 | /// Vertex shader memory | ||
| 1301 | struct ShaderSetup { | ||
| 1302 | struct { | ||
| 1303 | // The float uniforms are accessed by the shader JIT using SSE instructions, and are | ||
| 1304 | // therefore required to be 16-byte aligned. | ||
| 1305 | Math::Vec4<float24> MEMORY_ALIGNED16(f[96]); | ||
| 1306 | |||
| 1307 | std::array<bool, 16> b; | ||
| 1308 | std::array<Math::Vec4<u8>, 4> i; | ||
| 1309 | } uniforms; | ||
| 1310 | |||
| 1311 | Math::Vec4<float24> default_attributes[16]; | ||
| 1312 | |||
| 1313 | std::array<u32, 1024> program_code; | ||
| 1314 | std::array<u32, 1024> swizzle_data; | ||
| 1315 | }; | ||
| 1316 | |||
| 1317 | ShaderSetup vs; | ||
| 1318 | ShaderSetup gs; | ||
| 1319 | |||
| 1320 | struct { | ||
| 1321 | union LutEntry { | ||
| 1322 | // Used for raw access | ||
| 1323 | u32 raw; | ||
| 1324 | |||
| 1325 | // LUT value, encoded as 12-bit fixed point, with 12 fraction bits | ||
| 1326 | BitField< 0, 12, u32> value; | ||
| 1327 | |||
| 1328 | // Used by HW for efficient interpolation, Citra does not use these | ||
| 1329 | BitField<12, 12, u32> difference; | ||
| 1330 | |||
| 1331 | float ToFloat() { | ||
| 1332 | return static_cast<float>(value) / 4095.f; | ||
| 1333 | } | ||
| 1334 | }; | ||
| 1335 | |||
| 1336 | std::array<std::array<LutEntry, 256>, 24> luts; | ||
| 1337 | } lighting; | ||
| 1338 | |||
| 1339 | /// Current Pica command list | ||
| 1340 | struct { | ||
| 1341 | const u32* head_ptr; | ||
| 1342 | const u32* current_ptr; | ||
| 1343 | u32 length; | ||
| 1344 | } cmd_list; | ||
| 1345 | }; | ||
| 1346 | |||
| 1347 | /// Initialize Pica state | 1305 | /// Initialize Pica state |
| 1348 | void Init(); | 1306 | void Init(); |
| 1349 | 1307 | ||
| 1350 | /// Shutdown Pica state | 1308 | /// Shutdown Pica state |
| 1351 | void Shutdown(); | 1309 | void Shutdown(); |
| 1352 | 1310 | ||
| 1353 | extern State g_state; ///< Current Pica state | ||
| 1354 | |||
| 1355 | } // namespace | 1311 | } // namespace |
diff --git a/src/video_core/pica_state.h b/src/video_core/pica_state.h new file mode 100644 index 000000000..c7616bc55 --- /dev/null +++ b/src/video_core/pica_state.h | |||
| @@ -0,0 +1,60 @@ | |||
| 1 | // Copyright 2016 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "video_core/pica.h" | ||
| 8 | #include "video_core/primitive_assembly.h" | ||
| 9 | #include "video_core/shader/shader.h" | ||
| 10 | |||
| 11 | namespace Pica { | ||
| 12 | |||
| 13 | /// Struct used to describe current Pica state | ||
| 14 | struct State { | ||
| 15 | /// Pica registers | ||
| 16 | Regs regs; | ||
| 17 | |||
| 18 | Shader::ShaderSetup vs; | ||
| 19 | Shader::ShaderSetup gs; | ||
| 20 | |||
| 21 | struct { | ||
| 22 | union LutEntry { | ||
| 23 | // Used for raw access | ||
| 24 | u32 raw; | ||
| 25 | |||
| 26 | // LUT value, encoded as 12-bit fixed point, with 12 fraction bits | ||
| 27 | BitField< 0, 12, u32> value; | ||
| 28 | |||
| 29 | // Used by HW for efficient interpolation, Citra does not use these | ||
| 30 | BitField<12, 12, u32> difference; | ||
| 31 | |||
| 32 | float ToFloat() { | ||
| 33 | return static_cast<float>(value) / 4095.f; | ||
| 34 | } | ||
| 35 | }; | ||
| 36 | |||
| 37 | std::array<std::array<LutEntry, 256>, 24> luts; | ||
| 38 | } lighting; | ||
| 39 | |||
| 40 | /// Current Pica command list | ||
| 41 | struct { | ||
| 42 | const u32* head_ptr; | ||
| 43 | const u32* current_ptr; | ||
| 44 | u32 length; | ||
| 45 | } cmd_list; | ||
| 46 | |||
| 47 | /// Struct used to describe immediate mode rendering state | ||
| 48 | struct ImmediateModeState { | ||
| 49 | Shader::InputVertex input; | ||
| 50 | // This is constructed with a dummy triangle topology | ||
| 51 | PrimitiveAssembler<Shader::OutputVertex> primitive_assembler; | ||
| 52 | int attribute_id = 0; | ||
| 53 | |||
| 54 | ImmediateModeState() : primitive_assembler(Regs::TriangleTopology::List) {} | ||
| 55 | } immediate; | ||
| 56 | }; | ||
| 57 | |||
| 58 | extern State g_state; ///< Current Pica state | ||
| 59 | |||
| 60 | } // namespace | ||
diff --git a/src/video_core/primitive_assembly.cpp b/src/video_core/primitive_assembly.cpp index d5a0a96a4..0061690f1 100644 --- a/src/video_core/primitive_assembly.cpp +++ b/src/video_core/primitive_assembly.cpp | |||
| @@ -53,6 +53,18 @@ void PrimitiveAssembler<VertexType>::SubmitVertex(VertexType& vtx, TriangleHandl | |||
| 53 | } | 53 | } |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | template<typename VertexType> | ||
| 57 | void PrimitiveAssembler<VertexType>::Reset() { | ||
| 58 | buffer_index = 0; | ||
| 59 | strip_ready = false; | ||
| 60 | } | ||
| 61 | |||
| 62 | template<typename VertexType> | ||
| 63 | void PrimitiveAssembler<VertexType>::Reconfigure(Regs::TriangleTopology topology) { | ||
| 64 | Reset(); | ||
| 65 | this->topology = topology; | ||
| 66 | } | ||
| 67 | |||
| 56 | // explicitly instantiate use cases | 68 | // explicitly instantiate use cases |
| 57 | template | 69 | template |
| 58 | struct PrimitiveAssembler<Shader::OutputVertex>; | 70 | struct PrimitiveAssembler<Shader::OutputVertex>; |
diff --git a/src/video_core/primitive_assembly.h b/src/video_core/primitive_assembly.h index 52d0ec8ff..cc6e5fde5 100644 --- a/src/video_core/primitive_assembly.h +++ b/src/video_core/primitive_assembly.h | |||
| @@ -30,6 +30,16 @@ struct PrimitiveAssembler { | |||
| 30 | */ | 30 | */ |
| 31 | void SubmitVertex(VertexType& vtx, TriangleHandler triangle_handler); | 31 | void SubmitVertex(VertexType& vtx, TriangleHandler triangle_handler); |
| 32 | 32 | ||
| 33 | /** | ||
| 34 | * Resets the internal state of the PrimitiveAssembler. | ||
| 35 | */ | ||
| 36 | void Reset(); | ||
| 37 | |||
| 38 | /** | ||
| 39 | * Reconfigures the PrimitiveAssembler to use a different triangle topology. | ||
| 40 | */ | ||
| 41 | void Reconfigure(Regs::TriangleTopology topology); | ||
| 42 | |||
| 33 | private: | 43 | private: |
| 34 | Regs::TriangleTopology topology; | 44 | Regs::TriangleTopology topology; |
| 35 | 45 | ||
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp index ecfdbc9e8..dd1604a38 100644 --- a/src/video_core/rasterizer.cpp +++ b/src/video_core/rasterizer.cpp | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #include "core/hw/gpu.h" | 15 | #include "core/hw/gpu.h" |
| 16 | 16 | ||
| 17 | #include "video_core/pica.h" | 17 | #include "video_core/pica.h" |
| 18 | #include "video_core/pica_state.h" | ||
| 18 | #include "video_core/rasterizer.h" | 19 | #include "video_core/rasterizer.h" |
| 19 | #include "video_core/utils.h" | 20 | #include "video_core/utils.h" |
| 20 | #include "video_core/debug_utils/debug_utils.h" | 21 | #include "video_core/debug_utils/debug_utils.h" |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index b7d19bf94..0f864b617 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include "core/hw/gpu.h" | 19 | #include "core/hw/gpu.h" |
| 20 | 20 | ||
| 21 | #include "video_core/pica.h" | 21 | #include "video_core/pica.h" |
| 22 | #include "video_core/pica_state.h" | ||
| 22 | #include "video_core/utils.h" | 23 | #include "video_core/utils.h" |
| 23 | #include "video_core/renderer_opengl/gl_rasterizer.h" | 24 | #include "video_core/renderer_opengl/gl_rasterizer.h" |
| 24 | #include "video_core/renderer_opengl/gl_shader_gen.h" | 25 | #include "video_core/renderer_opengl/gl_shader_gen.h" |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index fef5f5331..fc85aa3ff 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include "common/hash.h" | 14 | #include "common/hash.h" |
| 15 | 15 | ||
| 16 | #include "video_core/pica.h" | 16 | #include "video_core/pica.h" |
| 17 | #include "video_core/pica_state.h" | ||
| 17 | #include "video_core/rasterizer_interface.h" | 18 | #include "video_core/rasterizer_interface.h" |
| 18 | #include "video_core/renderer_opengl/gl_rasterizer_cache.h" | 19 | #include "video_core/renderer_opengl/gl_rasterizer_cache.h" |
| 19 | #include "video_core/renderer_opengl/gl_state.h" | 20 | #include "video_core/renderer_opengl/gl_state.h" |
diff --git a/src/video_core/shader/shader.cpp b/src/video_core/shader/shader.cpp index 44c234ed8..5e8930476 100644 --- a/src/video_core/shader/shader.cpp +++ b/src/video_core/shader/shader.cpp | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | 14 | ||
| 15 | #include "video_core/debug_utils/debug_utils.h" | 15 | #include "video_core/debug_utils/debug_utils.h" |
| 16 | #include "video_core/pica.h" | 16 | #include "video_core/pica.h" |
| 17 | #include "video_core/pica_state.h" | ||
| 17 | #include "video_core/video_core.h" | 18 | #include "video_core/video_core.h" |
| 18 | 19 | ||
| 19 | #include "shader.h" | 20 | #include "shader.h" |
| @@ -145,7 +146,7 @@ OutputVertex Run(UnitState<false>& state, const InputVertex& input, int num_attr | |||
| 145 | return ret; | 146 | return ret; |
| 146 | } | 147 | } |
| 147 | 148 | ||
| 148 | DebugData<true> ProduceDebugInfo(const InputVertex& input, int num_attributes, const Regs::ShaderConfig& config, const State::ShaderSetup& setup) { | 149 | DebugData<true> ProduceDebugInfo(const InputVertex& input, int num_attributes, const Regs::ShaderConfig& config, const ShaderSetup& setup) { |
| 149 | UnitState<true> state; | 150 | UnitState<true> state; |
| 150 | 151 | ||
| 151 | state.program_counter = config.main_offset; | 152 | state.program_counter = config.main_offset; |
diff --git a/src/video_core/shader/shader.h b/src/video_core/shader/shader.h index f068cd93f..1be4e3734 100644 --- a/src/video_core/shader/shader.h +++ b/src/video_core/shader/shader.h | |||
| @@ -77,6 +77,22 @@ struct OutputVertex { | |||
| 77 | static_assert(std::is_pod<OutputVertex>::value, "Structure is not POD"); | 77 | static_assert(std::is_pod<OutputVertex>::value, "Structure is not POD"); |
| 78 | static_assert(sizeof(OutputVertex) == 32 * sizeof(float), "OutputVertex has invalid size"); | 78 | static_assert(sizeof(OutputVertex) == 32 * sizeof(float), "OutputVertex has invalid size"); |
| 79 | 79 | ||
| 80 | /// Vertex shader memory | ||
| 81 | struct ShaderSetup { | ||
| 82 | struct { | ||
| 83 | // The float uniforms are accessed by the shader JIT using SSE instructions, and are | ||
| 84 | // therefore required to be 16-byte aligned. | ||
| 85 | Math::Vec4<float24> MEMORY_ALIGNED16(f[96]); | ||
| 86 | |||
| 87 | std::array<bool, 16> b; | ||
| 88 | std::array<Math::Vec4<u8>, 4> i; | ||
| 89 | } uniforms; | ||
| 90 | |||
| 91 | Math::Vec4<float24> default_attributes[16]; | ||
| 92 | |||
| 93 | std::array<u32, 1024> program_code; | ||
| 94 | std::array<u32, 1024> swizzle_data; | ||
| 95 | }; | ||
| 80 | 96 | ||
| 81 | // Helper structure used to keep track of data useful for inspection of shader emulation | 97 | // Helper structure used to keep track of data useful for inspection of shader emulation |
| 82 | template<bool full_debugging> | 98 | template<bool full_debugging> |
| @@ -347,7 +363,7 @@ OutputVertex Run(UnitState<false>& state, const InputVertex& input, int num_attr | |||
| 347 | * @param setup Setup object for the shader pipeline | 363 | * @param setup Setup object for the shader pipeline |
| 348 | * @return Debug information for this shader with regards to the given vertex | 364 | * @return Debug information for this shader with regards to the given vertex |
| 349 | */ | 365 | */ |
| 350 | DebugData<true> ProduceDebugInfo(const InputVertex& input, int num_attributes, const Regs::ShaderConfig& config, const State::ShaderSetup& setup); | 366 | DebugData<true> ProduceDebugInfo(const InputVertex& input, int num_attributes, const Regs::ShaderConfig& config, const ShaderSetup& setup); |
| 351 | 367 | ||
| 352 | } // namespace Shader | 368 | } // namespace Shader |
| 353 | 369 | ||
diff --git a/src/video_core/shader/shader_interpreter.cpp b/src/video_core/shader/shader_interpreter.cpp index aeced71b0..79fcc56b9 100644 --- a/src/video_core/shader/shader_interpreter.cpp +++ b/src/video_core/shader/shader_interpreter.cpp | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include <nihstro/shader_bytecode.h> | 7 | #include <nihstro/shader_bytecode.h> |
| 8 | 8 | ||
| 9 | #include "video_core/pica.h" | 9 | #include "video_core/pica.h" |
| 10 | #include "video_core/pica_state.h" | ||
| 10 | #include "video_core/shader/shader.h" | 11 | #include "video_core/shader/shader.h" |
| 11 | #include "video_core/shader/shader_interpreter.h" | 12 | #include "video_core/shader/shader_interpreter.h" |
| 12 | 13 | ||
diff --git a/src/video_core/shader/shader_jit_x64.cpp b/src/video_core/shader/shader_jit_x64.cpp index 4249675a5..5083d7e54 100644 --- a/src/video_core/shader/shader_jit_x64.cpp +++ b/src/video_core/shader/shader_jit_x64.cpp | |||
| @@ -11,6 +11,8 @@ | |||
| 11 | #include "shader.h" | 11 | #include "shader.h" |
| 12 | #include "shader_jit_x64.h" | 12 | #include "shader_jit_x64.h" |
| 13 | 13 | ||
| 14 | #include "video_core/pica_state.h" | ||
| 15 | |||
| 14 | namespace Pica { | 16 | namespace Pica { |
| 15 | 17 | ||
| 16 | namespace Shader { | 18 | namespace Shader { |