diff options
| author | 2022-12-08 12:41:39 +0100 | |
|---|---|---|
| committer | 2022-12-08 12:41:39 +0100 | |
| commit | 41461514d6f3ba59dc027dbc4a88c0ffb570ea49 (patch) | |
| tree | c3cffc17ce63e66f5fa2921e4804c396140a9791 /src/video_core/renderer_vulkan | |
| parent | Merge pull request #9365 from liamwhite/val (diff) | |
| parent | video_core: Implement maxwell3d draw manager and split draw logic (diff) | |
| download | yuzu-41461514d6f3ba59dc027dbc4a88c0ffb570ea49.tar.gz yuzu-41461514d6f3ba59dc027dbc4a88c0ffb570ea49.tar.xz yuzu-41461514d6f3ba59dc027dbc4a88c0ffb570ea49.zip | |
Merge pull request #9401 from vonchenplus/draw_manager
video_core: Implement maxwell3d draw manager and split draw logic
Diffstat (limited to 'src/video_core/renderer_vulkan')
| -rw-r--r-- | src/video_core/renderer_vulkan/fixed_pipeline_state.cpp | 6 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | 3 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.cpp | 18 |
3 files changed, 16 insertions, 11 deletions
diff --git a/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp b/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp index 5864e772b..e62b36822 100644 --- a/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp +++ b/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include "common/cityhash.h" | 8 | #include "common/cityhash.h" |
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "common/polyfill_ranges.h" | 10 | #include "common/polyfill_ranges.h" |
| 11 | #include "video_core/engines/draw_manager.h" | ||
| 11 | #include "video_core/renderer_vulkan/fixed_pipeline_state.h" | 12 | #include "video_core/renderer_vulkan/fixed_pipeline_state.h" |
| 12 | #include "video_core/renderer_vulkan/vk_state_tracker.h" | 13 | #include "video_core/renderer_vulkan/vk_state_tracker.h" |
| 13 | 14 | ||
| @@ -50,12 +51,13 @@ void RefreshXfbState(VideoCommon::TransformFeedbackState& state, const Maxwell& | |||
| 50 | void FixedPipelineState::Refresh(Tegra::Engines::Maxwell3D& maxwell3d, | 51 | void FixedPipelineState::Refresh(Tegra::Engines::Maxwell3D& maxwell3d, |
| 51 | bool has_extended_dynamic_state, bool has_dynamic_vertex_input) { | 52 | bool has_extended_dynamic_state, bool has_dynamic_vertex_input) { |
| 52 | const Maxwell& regs = maxwell3d.regs; | 53 | const Maxwell& regs = maxwell3d.regs; |
| 54 | const auto topology_ = maxwell3d.draw_manager->GetDrawState().topology; | ||
| 53 | const std::array enabled_lut{ | 55 | const std::array enabled_lut{ |
| 54 | regs.polygon_offset_point_enable, | 56 | regs.polygon_offset_point_enable, |
| 55 | regs.polygon_offset_line_enable, | 57 | regs.polygon_offset_line_enable, |
| 56 | regs.polygon_offset_fill_enable, | 58 | regs.polygon_offset_fill_enable, |
| 57 | }; | 59 | }; |
| 58 | const u32 topology_index = static_cast<u32>(regs.draw.topology.Value()); | 60 | const u32 topology_index = static_cast<u32>(topology_); |
| 59 | 61 | ||
| 60 | raw1 = 0; | 62 | raw1 = 0; |
| 61 | extended_dynamic_state.Assign(has_extended_dynamic_state ? 1 : 0); | 63 | extended_dynamic_state.Assign(has_extended_dynamic_state ? 1 : 0); |
| @@ -78,7 +80,7 @@ void FixedPipelineState::Refresh(Tegra::Engines::Maxwell3D& maxwell3d, | |||
| 78 | Maxwell::Tessellation::OutputPrimitives::Triangles_CW); | 80 | Maxwell::Tessellation::OutputPrimitives::Triangles_CW); |
| 79 | logic_op_enable.Assign(regs.logic_op.enable != 0 ? 1 : 0); | 81 | logic_op_enable.Assign(regs.logic_op.enable != 0 ? 1 : 0); |
| 80 | logic_op.Assign(PackLogicOp(regs.logic_op.op)); | 82 | logic_op.Assign(PackLogicOp(regs.logic_op.op)); |
| 81 | topology.Assign(regs.draw.topology); | 83 | topology.Assign(topology_); |
| 82 | msaa_mode.Assign(regs.anti_alias_samples_mode); | 84 | msaa_mode.Assign(regs.anti_alias_samples_mode); |
| 83 | 85 | ||
| 84 | raw2 = 0; | 86 | raw2 = 0; |
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index 38a6b7488..81f5f3e11 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | |||
| @@ -507,7 +507,8 @@ GraphicsPipeline* PipelineCache::BuiltPipeline(GraphicsPipeline* pipeline) const | |||
| 507 | // If games are using a small index count, we can assume these are full screen quads. | 507 | // If games are using a small index count, we can assume these are full screen quads. |
| 508 | // Usually these shaders are only used once for building textures so we can assume they | 508 | // Usually these shaders are only used once for building textures so we can assume they |
| 509 | // can't be built async | 509 | // can't be built async |
| 510 | if (maxwell3d->regs.index_buffer.count <= 6 || maxwell3d->regs.vertex_buffer.count <= 6) { | 510 | const auto& draw_state = maxwell3d->draw_manager->GetDrawState(); |
| 511 | if (draw_state.index_buffer.count <= 6 || draw_state.vertex_buffer.count <= 6) { | ||
| 511 | return pipeline; | 512 | return pipeline; |
| 512 | } | 513 | } |
| 513 | return nullptr; | 514 | return nullptr; |
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index d8ad8815c..8d7a5e400 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | #include "common/scope_exit.h" | 12 | #include "common/scope_exit.h" |
| 13 | #include "common/settings.h" | 13 | #include "common/settings.h" |
| 14 | #include "video_core/control/channel_state.h" | 14 | #include "video_core/control/channel_state.h" |
| 15 | #include "video_core/engines/draw_manager.h" | ||
| 15 | #include "video_core/engines/kepler_compute.h" | 16 | #include "video_core/engines/kepler_compute.h" |
| 16 | #include "video_core/engines/maxwell_3d.h" | 17 | #include "video_core/engines/maxwell_3d.h" |
| 17 | #include "video_core/renderer_vulkan/blit_image.h" | 18 | #include "video_core/renderer_vulkan/blit_image.h" |
| @@ -36,6 +37,7 @@ | |||
| 36 | namespace Vulkan { | 37 | namespace Vulkan { |
| 37 | 38 | ||
| 38 | using Maxwell = Tegra::Engines::Maxwell3D::Regs; | 39 | using Maxwell = Tegra::Engines::Maxwell3D::Regs; |
| 40 | using MaxwellDrawState = Tegra::Engines::DrawManager::State; | ||
| 39 | using VideoCommon::ImageViewId; | 41 | using VideoCommon::ImageViewId; |
| 40 | using VideoCommon::ImageViewType; | 42 | using VideoCommon::ImageViewType; |
| 41 | 43 | ||
| @@ -127,16 +129,16 @@ VkRect2D GetScissorState(const Maxwell& regs, size_t index, u32 up_scale = 1, u3 | |||
| 127 | return scissor; | 129 | return scissor; |
| 128 | } | 130 | } |
| 129 | 131 | ||
| 130 | DrawParams MakeDrawParams(const Maxwell& regs, u32 num_instances, bool is_indexed) { | 132 | DrawParams MakeDrawParams(const MaxwellDrawState& draw_state, u32 num_instances, bool is_indexed) { |
| 131 | DrawParams params{ | 133 | DrawParams params{ |
| 132 | .base_instance = regs.global_base_instance_index, | 134 | .base_instance = draw_state.base_instance, |
| 133 | .num_instances = num_instances, | 135 | .num_instances = num_instances, |
| 134 | .base_vertex = is_indexed ? regs.global_base_vertex_index : regs.vertex_buffer.first, | 136 | .base_vertex = is_indexed ? draw_state.base_index : draw_state.vertex_buffer.first, |
| 135 | .num_vertices = is_indexed ? regs.index_buffer.count : regs.vertex_buffer.count, | 137 | .num_vertices = is_indexed ? draw_state.index_buffer.count : draw_state.vertex_buffer.count, |
| 136 | .first_index = is_indexed ? regs.index_buffer.first : 0, | 138 | .first_index = is_indexed ? draw_state.index_buffer.first : 0, |
| 137 | .is_indexed = is_indexed, | 139 | .is_indexed = is_indexed, |
| 138 | }; | 140 | }; |
| 139 | if (regs.draw.topology == Maxwell::PrimitiveTopology::Quads) { | 141 | if (draw_state.topology == Maxwell::PrimitiveTopology::Quads) { |
| 140 | // 6 triangle vertices per quad, base vertex is part of the index | 142 | // 6 triangle vertices per quad, base vertex is part of the index |
| 141 | // See BindQuadArrayIndexBuffer for more details | 143 | // See BindQuadArrayIndexBuffer for more details |
| 142 | params.num_vertices = (params.num_vertices / 4) * 6; | 144 | params.num_vertices = (params.num_vertices / 4) * 6; |
| @@ -195,9 +197,9 @@ void RasterizerVulkan::Draw(bool is_indexed, u32 instance_count) { | |||
| 195 | 197 | ||
| 196 | UpdateDynamicStates(); | 198 | UpdateDynamicStates(); |
| 197 | 199 | ||
| 198 | const auto& regs{maxwell3d->regs}; | 200 | const auto& draw_state = maxwell3d->draw_manager->GetDrawState(); |
| 199 | const u32 num_instances{instance_count}; | 201 | const u32 num_instances{instance_count}; |
| 200 | const DrawParams draw_params{MakeDrawParams(regs, num_instances, is_indexed)}; | 202 | const DrawParams draw_params{MakeDrawParams(draw_state, num_instances, is_indexed)}; |
| 201 | scheduler.Record([draw_params](vk::CommandBuffer cmdbuf) { | 203 | scheduler.Record([draw_params](vk::CommandBuffer cmdbuf) { |
| 202 | if (draw_params.is_indexed) { | 204 | if (draw_params.is_indexed) { |
| 203 | cmdbuf.DrawIndexed(draw_params.num_vertices, draw_params.num_instances, | 205 | cmdbuf.DrawIndexed(draw_params.num_vertices, draw_params.num_instances, |