diff options
| author | 2018-08-11 19:21:31 -0500 | |
|---|---|---|
| committer | 2018-08-14 22:25:07 -0500 | |
| commit | c5284efd4f04bca05b1f5c61dce59090a7edf61e (patch) | |
| tree | a4bf294444c67058812f010d01a60e44aa1c80b6 /src/video_core/engines | |
| parent | Merge pull request #1069 from bunnei/vtx-sz (diff) | |
| download | yuzu-c5284efd4f04bca05b1f5c61dce59090a7edf61e.tar.gz yuzu-c5284efd4f04bca05b1f5c61dce59090a7edf61e.tar.xz yuzu-c5284efd4f04bca05b1f5c61dce59090a7edf61e.zip | |
Rasterizer: Implemented instanced rendering.
We keep track of the current instance and update an uniform in the shaders to let them know which instance they are.
Instanced vertex arrays are not yet implemented.
Diffstat (limited to 'src/video_core/engines')
| -rw-r--r-- | src/video_core/engines/maxwell_3d.cpp | 12 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_3d.h | 3 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index a46ed4bd7..68f91cc75 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp | |||
| @@ -222,6 +222,18 @@ void Maxwell3D::DrawArrays() { | |||
| 222 | debug_context->OnEvent(Tegra::DebugContext::Event::FinishedPrimitiveBatch, nullptr); | 222 | debug_context->OnEvent(Tegra::DebugContext::Event::FinishedPrimitiveBatch, nullptr); |
| 223 | } | 223 | } |
| 224 | 224 | ||
| 225 | // Both instance configuration registers can not be set at the same time. | ||
| 226 | ASSERT_MSG(!regs.draw.instance_next || !regs.draw.instance_cont, | ||
| 227 | "Illegal combination of instancing parameters"); | ||
| 228 | |||
| 229 | if (regs.draw.instance_next) { | ||
| 230 | // Increment the current instance *before* drawing. | ||
| 231 | state.current_instance += 1; | ||
| 232 | } else if (!regs.draw.instance_cont) { | ||
| 233 | // Reset the current instance to 0. | ||
| 234 | state.current_instance = 0; | ||
| 235 | } | ||
| 236 | |||
| 225 | const bool is_indexed{regs.index_array.count && !regs.vertex_buffer.count}; | 237 | const bool is_indexed{regs.index_array.count && !regs.vertex_buffer.count}; |
| 226 | rasterizer.AccelerateDrawBatch(is_indexed); | 238 | rasterizer.AccelerateDrawBatch(is_indexed); |
| 227 | 239 | ||
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index 1b30ce018..771eb5abc 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -638,6 +638,8 @@ public: | |||
| 638 | union { | 638 | union { |
| 639 | u32 vertex_begin_gl; | 639 | u32 vertex_begin_gl; |
| 640 | BitField<0, 16, PrimitiveTopology> topology; | 640 | BitField<0, 16, PrimitiveTopology> topology; |
| 641 | BitField<26, 1, u32> instance_next; | ||
| 642 | BitField<27, 1, u32> instance_cont; | ||
| 641 | }; | 643 | }; |
| 642 | } draw; | 644 | } draw; |
| 643 | 645 | ||
| @@ -830,6 +832,7 @@ public: | |||
| 830 | }; | 832 | }; |
| 831 | 833 | ||
| 832 | std::array<ShaderStageInfo, Regs::MaxShaderStage> shader_stages; | 834 | std::array<ShaderStageInfo, Regs::MaxShaderStage> shader_stages; |
| 835 | u32 current_instance = 0; ///< Current instance to be used to simulate instanced rendering. | ||
| 833 | }; | 836 | }; |
| 834 | 837 | ||
| 835 | State state{}; | 838 | State state{}; |