diff options
| author | 2022-12-14 15:33:10 -0500 | |
|---|---|---|
| committer | 2022-12-14 15:33:10 -0500 | |
| commit | a222f02c7aa88bfbae10075e6a19ce1fbe672815 (patch) | |
| tree | 67f7d5d94bfc66d71df7e60826a6c17ed54f9ef1 | |
| parent | Merge pull request #9425 from german77/german_unlimited (diff) | |
| parent | Fix validation errors on less compatible Intel GPU (diff) | |
| download | yuzu-a222f02c7aa88bfbae10075e6a19ce1fbe672815.tar.gz yuzu-a222f02c7aa88bfbae10075e6a19ce1fbe672815.tar.xz yuzu-a222f02c7aa88bfbae10075e6a19ce1fbe672815.zip | |
Merge pull request #6688 from yzct12345/valid-intel-max
render_vulkan: Fix validation errors on less compatible Intel GPUs
5 files changed, 34 insertions, 2 deletions
diff --git a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp index 558b8db56..84d36fea6 100644 --- a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp | |||
| @@ -285,6 +285,9 @@ void BufferCacheRuntime::BindQuadArrayIndexBuffer(u32 first, u32 count) { | |||
| 285 | 285 | ||
| 286 | void BufferCacheRuntime::BindVertexBuffer(u32 index, VkBuffer buffer, u32 offset, u32 size, | 286 | void BufferCacheRuntime::BindVertexBuffer(u32 index, VkBuffer buffer, u32 offset, u32 size, |
| 287 | u32 stride) { | 287 | u32 stride) { |
| 288 | if (index >= device.GetMaxVertexInputBindings()) { | ||
| 289 | return; | ||
| 290 | } | ||
| 288 | if (device.IsExtExtendedDynamicStateSupported()) { | 291 | if (device.IsExtExtendedDynamicStateSupported()) { |
| 289 | scheduler.Record([index, buffer, offset, size, stride](vk::CommandBuffer cmdbuf) { | 292 | scheduler.Record([index, buffer, offset, size, stride](vk::CommandBuffer cmdbuf) { |
| 290 | const VkDeviceSize vk_offset = buffer != VK_NULL_HANDLE ? offset : 0; | 293 | const VkDeviceSize vk_offset = buffer != VK_NULL_HANDLE ? offset : 0; |
diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index 006128638..4b10fe7bc 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp | |||
| @@ -529,7 +529,9 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) { | |||
| 529 | static_vector<VkVertexInputBindingDivisorDescriptionEXT, 32> vertex_binding_divisors; | 529 | static_vector<VkVertexInputBindingDivisorDescriptionEXT, 32> vertex_binding_divisors; |
| 530 | static_vector<VkVertexInputAttributeDescription, 32> vertex_attributes; | 530 | static_vector<VkVertexInputAttributeDescription, 32> vertex_attributes; |
| 531 | if (key.state.dynamic_vertex_input) { | 531 | if (key.state.dynamic_vertex_input) { |
| 532 | for (size_t index = 0; index < key.state.attributes.size(); ++index) { | 532 | const size_t num_vertex_arrays = std::min( |
| 533 | key.state.attributes.size(), static_cast<size_t>(device.GetMaxVertexInputBindings())); | ||
| 534 | for (size_t index = 0; index < num_vertex_arrays; ++index) { | ||
| 533 | const u32 type = key.state.DynamicAttributeType(index); | 535 | const u32 type = key.state.DynamicAttributeType(index); |
| 534 | if (!stage_infos[0].loads.Generic(index) || type == 0) { | 536 | if (!stage_infos[0].loads.Generic(index) || type == 0) { |
| 535 | continue; | 537 | continue; |
| @@ -551,7 +553,9 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) { | |||
| 551 | }); | 553 | }); |
| 552 | } | 554 | } |
| 553 | } else { | 555 | } else { |
| 554 | for (size_t index = 0; index < Maxwell::NumVertexArrays; ++index) { | 556 | const size_t num_vertex_arrays = std::min( |
| 557 | Maxwell::NumVertexArrays, static_cast<size_t>(device.GetMaxVertexInputBindings())); | ||
| 558 | for (size_t index = 0; index < num_vertex_arrays; ++index) { | ||
| 555 | const bool instanced = key.state.binding_divisors[index] != 0; | 559 | const bool instanced = key.state.binding_divisors[index] != 0; |
| 556 | const auto rate = | 560 | const auto rate = |
| 557 | instanced ? VK_VERTEX_INPUT_RATE_INSTANCE : VK_VERTEX_INPUT_RATE_VERTEX; | 561 | instanced ? VK_VERTEX_INPUT_RATE_INSTANCE : VK_VERTEX_INPUT_RATE_VERTEX; |
| @@ -580,6 +584,8 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) { | |||
| 580 | }); | 584 | }); |
| 581 | } | 585 | } |
| 582 | } | 586 | } |
| 587 | ASSERT(vertex_attributes.size() <= device.GetMaxVertexInputAttributes()); | ||
| 588 | |||
| 583 | VkPipelineVertexInputStateCreateInfo vertex_input_ci{ | 589 | VkPipelineVertexInputStateCreateInfo vertex_input_ci{ |
| 584 | .sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, | 590 | .sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, |
| 585 | .pNext = nullptr, | 591 | .pNext = nullptr, |
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index 81f5f3e11..86fdde014 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | |||
| @@ -341,6 +341,15 @@ PipelineCache::PipelineCache(RasterizerVulkan& rasterizer_, const Device& device | |||
| 341 | .support_snorm_render_buffer = true, | 341 | .support_snorm_render_buffer = true, |
| 342 | .support_viewport_index_layer = device.IsExtShaderViewportIndexLayerSupported(), | 342 | .support_viewport_index_layer = device.IsExtShaderViewportIndexLayerSupported(), |
| 343 | }; | 343 | }; |
| 344 | |||
| 345 | if (device.GetMaxVertexInputAttributes() < Maxwell::NumVertexAttributes) { | ||
| 346 | LOG_WARNING(Render_Vulkan, "maxVertexInputAttributes is too low: {} < {}", | ||
| 347 | device.GetMaxVertexInputAttributes(), Maxwell::NumVertexAttributes); | ||
| 348 | } | ||
| 349 | if (device.GetMaxVertexInputBindings() < Maxwell::NumVertexArrays) { | ||
| 350 | LOG_WARNING(Render_Vulkan, "maxVertexInputBindings is too low: {} < {}", | ||
| 351 | device.GetMaxVertexInputBindings(), Maxwell::NumVertexArrays); | ||
| 352 | } | ||
| 344 | } | 353 | } |
| 345 | 354 | ||
| 346 | PipelineCache::~PipelineCache() = default; | 355 | PipelineCache::~PipelineCache() = default; |
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index 6a2ad4b1d..67540cb80 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp | |||
| @@ -1380,6 +1380,10 @@ void Device::SetupFeatures() { | |||
| 1380 | is_shader_storage_image_multisample = features.shaderStorageImageMultisample; | 1380 | is_shader_storage_image_multisample = features.shaderStorageImageMultisample; |
| 1381 | is_blit_depth_stencil_supported = TestDepthStencilBlits(); | 1381 | is_blit_depth_stencil_supported = TestDepthStencilBlits(); |
| 1382 | is_optimal_astc_supported = IsOptimalAstcSupported(features); | 1382 | is_optimal_astc_supported = IsOptimalAstcSupported(features); |
| 1383 | |||
| 1384 | const VkPhysicalDeviceLimits& limits{properties.limits}; | ||
| 1385 | max_vertex_input_attributes = limits.maxVertexInputAttributes; | ||
| 1386 | max_vertex_input_bindings = limits.maxVertexInputBindings; | ||
| 1383 | } | 1387 | } |
| 1384 | 1388 | ||
| 1385 | void Device::SetupProperties() { | 1389 | void Device::SetupProperties() { |
diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h index db802437c..391b7604c 100644 --- a/src/video_core/vulkan_common/vulkan_device.h +++ b/src/video_core/vulkan_common/vulkan_device.h | |||
| @@ -368,6 +368,14 @@ public: | |||
| 368 | return must_emulate_bgr565; | 368 | return must_emulate_bgr565; |
| 369 | } | 369 | } |
| 370 | 370 | ||
| 371 | u32 GetMaxVertexInputAttributes() const { | ||
| 372 | return max_vertex_input_attributes; | ||
| 373 | } | ||
| 374 | |||
| 375 | u32 GetMaxVertexInputBindings() const { | ||
| 376 | return max_vertex_input_bindings; | ||
| 377 | } | ||
| 378 | |||
| 371 | private: | 379 | private: |
| 372 | /// Checks if the physical device is suitable. | 380 | /// Checks if the physical device is suitable. |
| 373 | void CheckSuitability(bool requires_swapchain) const; | 381 | void CheckSuitability(bool requires_swapchain) const; |
| @@ -467,6 +475,8 @@ private: | |||
| 467 | bool supports_d24_depth{}; ///< Supports D24 depth buffers. | 475 | bool supports_d24_depth{}; ///< Supports D24 depth buffers. |
| 468 | bool cant_blit_msaa{}; ///< Does not support MSAA<->MSAA blitting. | 476 | bool cant_blit_msaa{}; ///< Does not support MSAA<->MSAA blitting. |
| 469 | bool must_emulate_bgr565{}; ///< Emulates BGR565 by swizzling RGB565 format. | 477 | bool must_emulate_bgr565{}; ///< Emulates BGR565 by swizzling RGB565 format. |
| 478 | u32 max_vertex_input_attributes{}; ///< Max vertex input attributes in pipeline | ||
| 479 | u32 max_vertex_input_bindings{}; ///< Max vertex input buffers in pipeline | ||
| 470 | 480 | ||
| 471 | // Telemetry parameters | 481 | // Telemetry parameters |
| 472 | std::string vendor_name; ///< Device's driver name. | 482 | std::string vendor_name; ///< Device's driver name. |