diff options
| author | 2014-07-27 14:58:30 +0200 | |
|---|---|---|
| committer | 2014-08-12 13:48:56 +0200 | |
| commit | 9a76a2d0611fc0c35b665fb886d437e8f4d5b4df (patch) | |
| tree | 3dc2277e820070ef0d13769c10892f1fd2460d13 | |
| parent | Pica: Add vertex shader implementation. (diff) | |
| download | yuzu-9a76a2d0611fc0c35b665fb886d437e8f4d5b4df.tar.gz yuzu-9a76a2d0611fc0c35b665fb886d437e8f4d5b4df.tar.xz yuzu-9a76a2d0611fc0c35b665fb886d437e8f4d5b4df.zip | |
Pica: Add primitive assembly stage.
| -rw-r--r-- | src/video_core/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/video_core/command_processor.cpp | 3 | ||||
| -rw-r--r-- | src/video_core/pica.h | 15 | ||||
| -rw-r--r-- | src/video_core/primitive_assembly.cpp | 52 | ||||
| -rw-r--r-- | src/video_core/primitive_assembly.h | 21 | ||||
| -rw-r--r-- | src/video_core/video_core.vcxproj | 2 | ||||
| -rw-r--r-- | src/video_core/video_core.vcxproj.filters | 2 |
7 files changed, 95 insertions, 2 deletions
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index 74304ee49..b06f14db0 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | set(SRCS command_processor.cpp | 1 | set(SRCS command_processor.cpp |
| 2 | primitive_assembly.cpp | ||
| 2 | utils.cpp | 3 | utils.cpp |
| 3 | vertex_shader.cpp | 4 | vertex_shader.cpp |
| 4 | video_core.cpp | 5 | video_core.cpp |
| @@ -6,6 +7,7 @@ set(SRCS command_processor.cpp | |||
| 6 | 7 | ||
| 7 | set(HEADERS command_processor.h | 8 | set(HEADERS command_processor.h |
| 8 | math.h | 9 | math.h |
| 10 | primitive_assembly.h | ||
| 9 | utils.h | 11 | utils.h |
| 10 | video_core.h | 12 | video_core.h |
| 11 | renderer_base.h | 13 | renderer_base.h |
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index 339fa7726..020a4da3f 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include "command_processor.h" | 5 | #include "command_processor.h" |
| 6 | #include "math.h" | 6 | #include "math.h" |
| 7 | #include "pica.h" | 7 | #include "pica.h" |
| 8 | #include "primitive_assembly.h" | ||
| 8 | #include "vertex_shader.h" | 9 | #include "vertex_shader.h" |
| 9 | 10 | ||
| 10 | 11 | ||
| @@ -100,7 +101,7 @@ static inline void WritePicaReg(u32 id, u32 value) { | |||
| 100 | // TODO: Add processed vertex to vertex cache! | 101 | // TODO: Add processed vertex to vertex cache! |
| 101 | } | 102 | } |
| 102 | 103 | ||
| 103 | // TODO: Submit vertex to primitive assembly | 104 | PrimitiveAssembly::SubmitVertex(output); |
| 104 | } | 105 | } |
| 105 | break; | 106 | break; |
| 106 | } | 107 | } |
diff --git a/src/video_core/pica.h b/src/video_core/pica.h index 42303a585..6bbd3ce33 100644 --- a/src/video_core/pica.h +++ b/src/video_core/pica.h | |||
| @@ -221,7 +221,18 @@ struct Regs { | |||
| 221 | u32 trigger_draw; | 221 | u32 trigger_draw; |
| 222 | u32 trigger_draw_indexed; | 222 | u32 trigger_draw_indexed; |
| 223 | 223 | ||
| 224 | INSERT_PADDING_WORDS(0x8a); | 224 | INSERT_PADDING_WORDS(0x2e); |
| 225 | |||
| 226 | enum class TriangleTopology : u32 { | ||
| 227 | List = 0, | ||
| 228 | Strip = 1, | ||
| 229 | Fan = 2, | ||
| 230 | ListIndexed = 3, // TODO: No idea if this is correct | ||
| 231 | }; | ||
| 232 | |||
| 233 | BitField<8, 2, TriangleTopology> triangle_topology; | ||
| 234 | |||
| 235 | INSERT_PADDING_WORDS(0x5b); | ||
| 225 | 236 | ||
| 226 | // Offset to shader program entry point (in words) | 237 | // Offset to shader program entry point (in words) |
| 227 | BitField<0, 16, u32> vs_main_offset; | 238 | BitField<0, 16, u32> vs_main_offset; |
| @@ -334,6 +345,7 @@ struct Regs { | |||
| 334 | ADD_FIELD(num_vertices); | 345 | ADD_FIELD(num_vertices); |
| 335 | ADD_FIELD(trigger_draw); | 346 | ADD_FIELD(trigger_draw); |
| 336 | ADD_FIELD(trigger_draw_indexed); | 347 | ADD_FIELD(trigger_draw_indexed); |
| 348 | ADD_FIELD(triangle_topology); | ||
| 337 | ADD_FIELD(vs_main_offset); | 349 | ADD_FIELD(vs_main_offset); |
| 338 | ADD_FIELD(vs_input_register_map); | 350 | ADD_FIELD(vs_input_register_map); |
| 339 | ADD_FIELD(vs_uniform_setup); | 351 | ADD_FIELD(vs_uniform_setup); |
| @@ -386,6 +398,7 @@ ASSERT_REG_POSITION(index_array, 0x227); | |||
| 386 | ASSERT_REG_POSITION(num_vertices, 0x228); | 398 | ASSERT_REG_POSITION(num_vertices, 0x228); |
| 387 | ASSERT_REG_POSITION(trigger_draw, 0x22e); | 399 | ASSERT_REG_POSITION(trigger_draw, 0x22e); |
| 388 | ASSERT_REG_POSITION(trigger_draw_indexed, 0x22f); | 400 | ASSERT_REG_POSITION(trigger_draw_indexed, 0x22f); |
| 401 | ASSERT_REG_POSITION(triangle_topology, 0x25e); | ||
| 389 | ASSERT_REG_POSITION(vs_main_offset, 0x2ba); | 402 | ASSERT_REG_POSITION(vs_main_offset, 0x2ba); |
| 390 | ASSERT_REG_POSITION(vs_input_register_map, 0x2bb); | 403 | ASSERT_REG_POSITION(vs_input_register_map, 0x2bb); |
| 391 | ASSERT_REG_POSITION(vs_uniform_setup, 0x2c0); | 404 | ASSERT_REG_POSITION(vs_uniform_setup, 0x2c0); |
diff --git a/src/video_core/primitive_assembly.cpp b/src/video_core/primitive_assembly.cpp new file mode 100644 index 000000000..b2196d13c --- /dev/null +++ b/src/video_core/primitive_assembly.cpp | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "pica.h" | ||
| 6 | #include "primitive_assembly.h" | ||
| 7 | #include "vertex_shader.h" | ||
| 8 | |||
| 9 | namespace Pica { | ||
| 10 | |||
| 11 | namespace PrimitiveAssembly { | ||
| 12 | |||
| 13 | static OutputVertex buffer[2]; | ||
| 14 | static int buffer_index = 0; // TODO: reset this on emulation restart | ||
| 15 | |||
| 16 | void SubmitVertex(OutputVertex& vtx) | ||
| 17 | { | ||
| 18 | switch (registers.triangle_topology) { | ||
| 19 | case Regs::TriangleTopology::List: | ||
| 20 | case Regs::TriangleTopology::ListIndexed: | ||
| 21 | if (buffer_index < 2) { | ||
| 22 | buffer[buffer_index++] = vtx; | ||
| 23 | } else { | ||
| 24 | buffer_index = 0; | ||
| 25 | |||
| 26 | // TODO | ||
| 27 | // Clipper::ProcessTriangle(buffer[0], buffer[1], vtx); | ||
| 28 | } | ||
| 29 | break; | ||
| 30 | |||
| 31 | case Regs::TriangleTopology::Fan: | ||
| 32 | if (buffer_index == 2) { | ||
| 33 | buffer_index = 0; | ||
| 34 | |||
| 35 | // TODO | ||
| 36 | // Clipper::ProcessTriangle(buffer[0], buffer[1], vtx); | ||
| 37 | |||
| 38 | buffer[1] = vtx; | ||
| 39 | } else { | ||
| 40 | buffer[buffer_index++] = vtx; | ||
| 41 | } | ||
| 42 | break; | ||
| 43 | |||
| 44 | default: | ||
| 45 | ERROR_LOG(GPU, "Unknown triangle mode %x:", (int)registers.triangle_topology.Value()); | ||
| 46 | break; | ||
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 50 | } // namespace | ||
| 51 | |||
| 52 | } // namespace | ||
diff --git a/src/video_core/primitive_assembly.h b/src/video_core/primitive_assembly.h new file mode 100644 index 000000000..2a2b0c170 --- /dev/null +++ b/src/video_core/primitive_assembly.h | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | namespace Pica { | ||
| 8 | |||
| 9 | namespace VertexShader { | ||
| 10 | struct OutputVertex; | ||
| 11 | } | ||
| 12 | |||
| 13 | namespace PrimitiveAssembly { | ||
| 14 | |||
| 15 | using VertexShader::OutputVertex; | ||
| 16 | |||
| 17 | void SubmitVertex(OutputVertex& vtx); | ||
| 18 | |||
| 19 | } // namespace | ||
| 20 | |||
| 21 | } // namespace | ||
diff --git a/src/video_core/video_core.vcxproj b/src/video_core/video_core.vcxproj index 56729dc03..9cf3b0858 100644 --- a/src/video_core/video_core.vcxproj +++ b/src/video_core/video_core.vcxproj | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | <ItemGroup> | 21 | <ItemGroup> |
| 22 | <ClCompile Include="renderer_opengl\renderer_opengl.cpp" /> | 22 | <ClCompile Include="renderer_opengl\renderer_opengl.cpp" /> |
| 23 | <ClCompile Include="command_processor.cpp" /> | 23 | <ClCompile Include="command_processor.cpp" /> |
| 24 | <ClCompile Include="primitive_assembly.cpp" /> | ||
| 24 | <ClCompile Include="utils.cpp" /> | 25 | <ClCompile Include="utils.cpp" /> |
| 25 | <ClCompile Include="vertex_shader.cpp" /> | 26 | <ClCompile Include="vertex_shader.cpp" /> |
| 26 | <ClCompile Include="video_core.cpp" /> | 27 | <ClCompile Include="video_core.cpp" /> |
| @@ -30,6 +31,7 @@ | |||
| 30 | <ClInclude Include="gpu_debugger.h" /> | 31 | <ClInclude Include="gpu_debugger.h" /> |
| 31 | <ClInclude Include="math.h" /> | 32 | <ClInclude Include="math.h" /> |
| 32 | <ClInclude Include="pica.h" /> | 33 | <ClInclude Include="pica.h" /> |
| 34 | <ClInclude Include="primitive_assembly.h" /> | ||
| 33 | <ClInclude Include="renderer_base.h" /> | 35 | <ClInclude Include="renderer_base.h" /> |
| 34 | <ClInclude Include="utils.h" /> | 36 | <ClInclude Include="utils.h" /> |
| 35 | <ClInclude Include="vertex_shader.h" /> | 37 | <ClInclude Include="vertex_shader.h" /> |
diff --git a/src/video_core/video_core.vcxproj.filters b/src/video_core/video_core.vcxproj.filters index db0b37018..9da20b284 100644 --- a/src/video_core/video_core.vcxproj.filters +++ b/src/video_core/video_core.vcxproj.filters | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | <Filter>renderer_opengl</Filter> | 10 | <Filter>renderer_opengl</Filter> |
| 11 | </ClCompile> | 11 | </ClCompile> |
| 12 | <ClCompile Include="command_processor.cpp" /> | 12 | <ClCompile Include="command_processor.cpp" /> |
| 13 | <ClCompile Include="primitive_assembly.cpp" /> | ||
| 13 | <ClCompile Include="utils.cpp" /> | 14 | <ClCompile Include="utils.cpp" /> |
| 14 | <ClCompile Include="vertex_shader.cpp" /> | 15 | <ClCompile Include="vertex_shader.cpp" /> |
| 15 | <ClCompile Include="video_core.cpp" /> | 16 | <ClCompile Include="video_core.cpp" /> |
| @@ -22,6 +23,7 @@ | |||
| 22 | <ClInclude Include="gpu_debugger.h" /> | 23 | <ClInclude Include="gpu_debugger.h" /> |
| 23 | <ClInclude Include="math.h" /> | 24 | <ClInclude Include="math.h" /> |
| 24 | <ClInclude Include="pica.h" /> | 25 | <ClInclude Include="pica.h" /> |
| 26 | <ClInclude Include="primitive_assembly.h" /> | ||
| 25 | <ClInclude Include="renderer_base.h" /> | 27 | <ClInclude Include="renderer_base.h" /> |
| 26 | <ClInclude Include="utils.h" /> | 28 | <ClInclude Include="utils.h" /> |
| 27 | <ClInclude Include="vertex_shader.h" /> | 29 | <ClInclude Include="vertex_shader.h" /> |