diff options
| author | 2023-08-04 03:33:04 +0200 | |
|---|---|---|
| committer | 2023-09-23 23:05:29 +0200 | |
| commit | 57401589c2e94d49b03fd68ae0ad5b2e36aac795 (patch) | |
| tree | 5ce446785bbcc09bb956be65c066c8aa54342297 /src | |
| parent | Query Cachge: Fully rework Vulkan's query cache (diff) | |
| download | yuzu-57401589c2e94d49b03fd68ae0ad5b2e36aac795.tar.gz yuzu-57401589c2e94d49b03fd68ae0ad5b2e36aac795.tar.xz yuzu-57401589c2e94d49b03fd68ae0ad5b2e36aac795.zip | |
Macro HLE: Add DrawIndirectByteCount
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/engines/draw_manager.h | 1 | ||||
| -rw-r--r-- | src/video_core/macro/macro_hle.cpp | 35 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_wrapper.cpp | 1 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_wrapper.h | 8 |
4 files changed, 40 insertions, 5 deletions
diff --git a/src/video_core/engines/draw_manager.h b/src/video_core/engines/draw_manager.h index 7c22c49f1..18d959143 100644 --- a/src/video_core/engines/draw_manager.h +++ b/src/video_core/engines/draw_manager.h | |||
| @@ -46,6 +46,7 @@ public: | |||
| 46 | }; | 46 | }; |
| 47 | 47 | ||
| 48 | struct IndirectParams { | 48 | struct IndirectParams { |
| 49 | bool is_byte_count; | ||
| 49 | bool is_indexed; | 50 | bool is_indexed; |
| 50 | bool include_count; | 51 | bool include_count; |
| 51 | GPUVAddr count_start_address; | 52 | GPUVAddr count_start_address; |
diff --git a/src/video_core/macro/macro_hle.cpp b/src/video_core/macro/macro_hle.cpp index e980af171..046c8085e 100644 --- a/src/video_core/macro/macro_hle.cpp +++ b/src/video_core/macro/macro_hle.cpp | |||
| @@ -67,6 +67,7 @@ public: | |||
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | auto& params = maxwell3d.draw_manager->GetIndirectParams(); | 69 | auto& params = maxwell3d.draw_manager->GetIndirectParams(); |
| 70 | params.is_byte_count = false; | ||
| 70 | params.is_indexed = false; | 71 | params.is_indexed = false; |
| 71 | params.include_count = false; | 72 | params.include_count = false; |
| 72 | params.count_start_address = 0; | 73 | params.count_start_address = 0; |
| @@ -161,6 +162,7 @@ public: | |||
| 161 | 0, 0x644, Maxwell3D::HLEReplacementAttributeType::BaseInstance); | 162 | 0, 0x644, Maxwell3D::HLEReplacementAttributeType::BaseInstance); |
| 162 | } | 163 | } |
| 163 | auto& params = maxwell3d.draw_manager->GetIndirectParams(); | 164 | auto& params = maxwell3d.draw_manager->GetIndirectParams(); |
| 165 | params.is_byte_count = false; | ||
| 164 | params.is_indexed = true; | 166 | params.is_indexed = true; |
| 165 | params.include_count = false; | 167 | params.include_count = false; |
| 166 | params.count_start_address = 0; | 168 | params.count_start_address = 0; |
| @@ -256,6 +258,7 @@ public: | |||
| 256 | const u32 estimate = static_cast<u32>(maxwell3d.EstimateIndexBufferSize()); | 258 | const u32 estimate = static_cast<u32>(maxwell3d.EstimateIndexBufferSize()); |
| 257 | maxwell3d.dirty.flags[VideoCommon::Dirty::IndexBuffer] = true; | 259 | maxwell3d.dirty.flags[VideoCommon::Dirty::IndexBuffer] = true; |
| 258 | auto& params = maxwell3d.draw_manager->GetIndirectParams(); | 260 | auto& params = maxwell3d.draw_manager->GetIndirectParams(); |
| 261 | params.is_byte_count = false; | ||
| 259 | params.is_indexed = true; | 262 | params.is_indexed = true; |
| 260 | params.include_count = true; | 263 | params.include_count = true; |
| 261 | params.count_start_address = maxwell3d.GetMacroAddress(4); | 264 | params.count_start_address = maxwell3d.GetMacroAddress(4); |
| @@ -324,17 +327,39 @@ public: | |||
| 324 | explicit HLE_DrawIndirectByteCount(Maxwell3D& maxwell3d_) : HLEMacroImpl(maxwell3d_) {} | 327 | explicit HLE_DrawIndirectByteCount(Maxwell3D& maxwell3d_) : HLEMacroImpl(maxwell3d_) {} |
| 325 | 328 | ||
| 326 | void Execute(const std::vector<u32>& parameters, [[maybe_unused]] u32 method) override { | 329 | void Execute(const std::vector<u32>& parameters, [[maybe_unused]] u32 method) override { |
| 330 | auto topology = static_cast<Maxwell3D::Regs::PrimitiveTopology>(parameters[0] & 0xFFFFU); | ||
| 331 | if (!maxwell3d.AnyParametersDirty() || !IsTopologySafe(topology)) { | ||
| 332 | Fallback(parameters); | ||
| 333 | return; | ||
| 334 | } | ||
| 335 | |||
| 336 | auto& params = maxwell3d.draw_manager->GetIndirectParams(); | ||
| 337 | params.is_byte_count = true; | ||
| 338 | params.is_indexed = false; | ||
| 339 | params.include_count = false; | ||
| 340 | params.count_start_address = 0; | ||
| 341 | params.indirect_start_address = maxwell3d.GetMacroAddress(2); | ||
| 342 | params.buffer_size = 4; | ||
| 343 | params.max_draw_counts = 1; | ||
| 344 | params.stride = parameters[1]; | ||
| 345 | maxwell3d.regs.draw.begin = parameters[0]; | ||
| 346 | maxwell3d.regs.draw_auto_stride = parameters[1]; | ||
| 347 | maxwell3d.regs.draw_auto_byte_count = parameters[2]; | ||
| 348 | |||
| 349 | maxwell3d.draw_manager->DrawArrayIndirect(topology); | ||
| 350 | } | ||
| 351 | |||
| 352 | private: | ||
| 353 | void Fallback(const std::vector<u32>& parameters) { | ||
| 327 | maxwell3d.RefreshParameters(); | 354 | maxwell3d.RefreshParameters(); |
| 328 | 355 | ||
| 329 | maxwell3d.regs.draw.begin = parameters[0]; | 356 | maxwell3d.regs.draw.begin = parameters[0]; |
| 330 | maxwell3d.regs.draw_auto_stride = parameters[1]; | 357 | maxwell3d.regs.draw_auto_stride = parameters[1]; |
| 331 | maxwell3d.regs.draw_auto_byte_count = parameters[2]; | 358 | maxwell3d.regs.draw_auto_byte_count = parameters[2]; |
| 332 | 359 | ||
| 333 | if (maxwell3d.ShouldExecute()) { | 360 | maxwell3d.draw_manager->DrawArray( |
| 334 | maxwell3d.draw_manager->DrawArray( | 361 | maxwell3d.regs.draw.topology, 0, |
| 335 | maxwell3d.regs.draw.topology, 0, | 362 | maxwell3d.regs.draw_auto_byte_count / maxwell3d.regs.draw_auto_stride, 0, 1); |
| 336 | maxwell3d.regs.draw_auto_byte_count / maxwell3d.regs.draw_auto_stride, 0, 1); | ||
| 337 | } | ||
| 338 | } | 363 | } |
| 339 | }; | 364 | }; |
| 340 | 365 | ||
diff --git a/src/video_core/vulkan_common/vulkan_wrapper.cpp b/src/video_core/vulkan_common/vulkan_wrapper.cpp index 5a08a92e1..5afba365c 100644 --- a/src/video_core/vulkan_common/vulkan_wrapper.cpp +++ b/src/video_core/vulkan_common/vulkan_wrapper.cpp | |||
| @@ -101,6 +101,7 @@ void Load(VkDevice device, DeviceDispatch& dld) noexcept { | |||
| 101 | X(vkCmdDrawIndexedIndirect); | 101 | X(vkCmdDrawIndexedIndirect); |
| 102 | X(vkCmdDrawIndirectCount); | 102 | X(vkCmdDrawIndirectCount); |
| 103 | X(vkCmdDrawIndexedIndirectCount); | 103 | X(vkCmdDrawIndexedIndirectCount); |
| 104 | X(vkCmdDrawIndirectByteCountEXT); | ||
| 104 | X(vkCmdEndConditionalRenderingEXT); | 105 | X(vkCmdEndConditionalRenderingEXT); |
| 105 | X(vkCmdEndQuery); | 106 | X(vkCmdEndQuery); |
| 106 | X(vkCmdEndRenderPass); | 107 | X(vkCmdEndRenderPass); |
diff --git a/src/video_core/vulkan_common/vulkan_wrapper.h b/src/video_core/vulkan_common/vulkan_wrapper.h index 27d94a7d5..0d4bbe7f7 100644 --- a/src/video_core/vulkan_common/vulkan_wrapper.h +++ b/src/video_core/vulkan_common/vulkan_wrapper.h | |||
| @@ -212,6 +212,7 @@ struct DeviceDispatch : InstanceDispatch { | |||
| 212 | PFN_vkCmdDrawIndexedIndirect vkCmdDrawIndexedIndirect{}; | 212 | PFN_vkCmdDrawIndexedIndirect vkCmdDrawIndexedIndirect{}; |
| 213 | PFN_vkCmdDrawIndirectCount vkCmdDrawIndirectCount{}; | 213 | PFN_vkCmdDrawIndirectCount vkCmdDrawIndirectCount{}; |
| 214 | PFN_vkCmdDrawIndexedIndirectCount vkCmdDrawIndexedIndirectCount{}; | 214 | PFN_vkCmdDrawIndexedIndirectCount vkCmdDrawIndexedIndirectCount{}; |
| 215 | PFN_vkCmdDrawIndirectByteCountEXT vkCmdDrawIndirectByteCountEXT{}; | ||
| 215 | PFN_vkCmdEndConditionalRenderingEXT vkCmdEndConditionalRenderingEXT{}; | 216 | PFN_vkCmdEndConditionalRenderingEXT vkCmdEndConditionalRenderingEXT{}; |
| 216 | PFN_vkCmdEndDebugUtilsLabelEXT vkCmdEndDebugUtilsLabelEXT{}; | 217 | PFN_vkCmdEndDebugUtilsLabelEXT vkCmdEndDebugUtilsLabelEXT{}; |
| 217 | PFN_vkCmdEndQuery vkCmdEndQuery{}; | 218 | PFN_vkCmdEndQuery vkCmdEndQuery{}; |
| @@ -1185,6 +1186,13 @@ public: | |||
| 1185 | count_offset, draw_count, stride); | 1186 | count_offset, draw_count, stride); |
| 1186 | } | 1187 | } |
| 1187 | 1188 | ||
| 1189 | void DrawIndirectByteCountEXT(u32 instance_count, u32 first_instance, VkBuffer counter_buffer, | ||
| 1190 | VkDeviceSize counter_buffer_offset, u32 counter_offset, | ||
| 1191 | u32 stride) { | ||
| 1192 | dld->vkCmdDrawIndirectByteCountEXT(handle, instance_count, first_instance, counter_buffer, | ||
| 1193 | counter_buffer_offset, counter_offset, stride); | ||
| 1194 | } | ||
| 1195 | |||
| 1188 | void ClearAttachments(Span<VkClearAttachment> attachments, | 1196 | void ClearAttachments(Span<VkClearAttachment> attachments, |
| 1189 | Span<VkClearRect> rects) const noexcept { | 1197 | Span<VkClearRect> rects) const noexcept { |
| 1190 | dld->vkCmdClearAttachments(handle, attachments.size(), attachments.data(), rects.size(), | 1198 | dld->vkCmdClearAttachments(handle, attachments.size(), attachments.data(), rects.size(), |