diff options
| author | 2020-07-16 18:49:42 -0400 | |
|---|---|---|
| committer | 2020-07-16 18:49:42 -0400 | |
| commit | 01f297f2e01873a36769de728c3cac32c667e3e1 (patch) | |
| tree | 6d5197d2aeaaf8a534f2f37c1294cff9f76ef6db /src | |
| parent | vk_query_cache: Make use of designated initializers where applicable (diff) | |
| download | yuzu-01f297f2e01873a36769de728c3cac32c667e3e1.tar.gz yuzu-01f297f2e01873a36769de728c3cac32c667e3e1.tar.xz yuzu-01f297f2e01873a36769de728c3cac32c667e3e1.zip | |
vk_rasterizer: Make use of designated initializers where applicable
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.cpp | 88 |
1 files changed, 47 insertions, 41 deletions
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 7625871c2..31e44aa2b 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp | |||
| @@ -64,20 +64,22 @@ VkViewport GetViewportState(const VKDevice& device, const Maxwell& regs, std::si | |||
| 64 | const auto& src = regs.viewport_transform[index]; | 64 | const auto& src = regs.viewport_transform[index]; |
| 65 | const float width = src.scale_x * 2.0f; | 65 | const float width = src.scale_x * 2.0f; |
| 66 | const float height = src.scale_y * 2.0f; | 66 | const float height = src.scale_y * 2.0f; |
| 67 | const float reduce_z = regs.depth_mode == Maxwell::DepthMode::MinusOneToOne ? 1.0f : 0.0f; | ||
| 67 | 68 | ||
| 68 | VkViewport viewport; | 69 | VkViewport viewport{ |
| 69 | viewport.x = src.translate_x - src.scale_x; | 70 | .x = src.translate_x - src.scale_x, |
| 70 | viewport.y = src.translate_y - src.scale_y; | 71 | .y = src.translate_y - src.scale_y, |
| 71 | viewport.width = width != 0.0f ? width : 1.0f; | 72 | .width = width != 0.0f ? width : 1.0f, |
| 72 | viewport.height = height != 0.0f ? height : 1.0f; | 73 | .height = height != 0.0f ? height : 1.0f, |
| 74 | .minDepth = src.translate_z - src.scale_z * reduce_z, | ||
| 75 | .maxDepth = src.translate_z + src.scale_z, | ||
| 76 | }; | ||
| 73 | 77 | ||
| 74 | const float reduce_z = regs.depth_mode == Maxwell::DepthMode::MinusOneToOne ? 1.0f : 0.0f; | ||
| 75 | viewport.minDepth = src.translate_z - src.scale_z * reduce_z; | ||
| 76 | viewport.maxDepth = src.translate_z + src.scale_z; | ||
| 77 | if (!device.IsExtDepthRangeUnrestrictedSupported()) { | 78 | if (!device.IsExtDepthRangeUnrestrictedSupported()) { |
| 78 | viewport.minDepth = std::clamp(viewport.minDepth, 0.0f, 1.0f); | 79 | viewport.minDepth = std::clamp(viewport.minDepth, 0.0f, 1.0f); |
| 79 | viewport.maxDepth = std::clamp(viewport.maxDepth, 0.0f, 1.0f); | 80 | viewport.maxDepth = std::clamp(viewport.maxDepth, 0.0f, 1.0f); |
| 80 | } | 81 | } |
| 82 | |||
| 81 | return viewport; | 83 | return viewport; |
| 82 | } | 84 | } |
| 83 | 85 | ||
| @@ -508,10 +510,11 @@ void RasterizerVulkan::Clear() { | |||
| 508 | 510 | ||
| 509 | const u32 color_attachment = regs.clear_buffers.RT; | 511 | const u32 color_attachment = regs.clear_buffers.RT; |
| 510 | scheduler.Record([color_attachment, clear_value, clear_rect](vk::CommandBuffer cmdbuf) { | 512 | scheduler.Record([color_attachment, clear_value, clear_rect](vk::CommandBuffer cmdbuf) { |
| 511 | VkClearAttachment attachment; | 513 | const VkClearAttachment attachment{ |
| 512 | attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | 514 | .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, |
| 513 | attachment.colorAttachment = color_attachment; | 515 | .colorAttachment = color_attachment, |
| 514 | attachment.clearValue = clear_value; | 516 | .clearValue = clear_value, |
| 517 | }; | ||
| 515 | cmdbuf.ClearAttachments(attachment, clear_rect); | 518 | cmdbuf.ClearAttachments(attachment, clear_rect); |
| 516 | }); | 519 | }); |
| 517 | } | 520 | } |
| @@ -551,13 +554,16 @@ void RasterizerVulkan::DispatchCompute(GPUVAddr code_addr) { | |||
| 551 | query_cache.UpdateCounters(); | 554 | query_cache.UpdateCounters(); |
| 552 | 555 | ||
| 553 | const auto& launch_desc = system.GPU().KeplerCompute().launch_description; | 556 | const auto& launch_desc = system.GPU().KeplerCompute().launch_description; |
| 554 | ComputePipelineCacheKey key; | 557 | auto& pipeline = pipeline_cache.GetComputePipeline({ |
| 555 | key.shader = code_addr; | 558 | .shader = code_addr, |
| 556 | key.shared_memory_size = launch_desc.shared_alloc; | 559 | .shared_memory_size = launch_desc.shared_alloc, |
| 557 | key.workgroup_size = {launch_desc.block_dim_x, launch_desc.block_dim_y, | 560 | .workgroup_size = |
| 558 | launch_desc.block_dim_z}; | 561 | { |
| 559 | 562 | launch_desc.block_dim_x, | |
| 560 | auto& pipeline = pipeline_cache.GetComputePipeline(key); | 563 | launch_desc.block_dim_y, |
| 564 | launch_desc.block_dim_z, | ||
| 565 | }, | ||
| 566 | }); | ||
| 561 | 567 | ||
| 562 | // Compute dispatches can't be executed inside a renderpass | 568 | // Compute dispatches can't be executed inside a renderpass |
| 563 | scheduler.RequestOutsideRenderPassOperationContext(); | 569 | scheduler.RequestOutsideRenderPassOperationContext(); |
| @@ -841,17 +847,17 @@ std::tuple<VkFramebuffer, VkExtent2D> RasterizerVulkan::ConfigureFramebuffers( | |||
| 841 | const auto [fbentry, is_cache_miss] = framebuffer_cache.try_emplace(key); | 847 | const auto [fbentry, is_cache_miss] = framebuffer_cache.try_emplace(key); |
| 842 | auto& framebuffer = fbentry->second; | 848 | auto& framebuffer = fbentry->second; |
| 843 | if (is_cache_miss) { | 849 | if (is_cache_miss) { |
| 844 | VkFramebufferCreateInfo framebuffer_ci; | 850 | framebuffer = device.GetLogical().CreateFramebuffer({ |
| 845 | framebuffer_ci.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; | 851 | .sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, |
| 846 | framebuffer_ci.pNext = nullptr; | 852 | .pNext = nullptr, |
| 847 | framebuffer_ci.flags = 0; | 853 | .flags = 0, |
| 848 | framebuffer_ci.renderPass = key.renderpass; | 854 | .renderPass = key.renderpass, |
| 849 | framebuffer_ci.attachmentCount = static_cast<u32>(key.views.size()); | 855 | .attachmentCount = static_cast<u32>(key.views.size()), |
| 850 | framebuffer_ci.pAttachments = key.views.data(); | 856 | .pAttachments = key.views.data(), |
| 851 | framebuffer_ci.width = key.width; | 857 | .width = key.width, |
| 852 | framebuffer_ci.height = key.height; | 858 | .height = key.height, |
| 853 | framebuffer_ci.layers = key.layers; | 859 | .layers = key.layers, |
| 854 | framebuffer = device.GetLogical().CreateFramebuffer(framebuffer_ci); | 860 | }); |
| 855 | } | 861 | } |
| 856 | 862 | ||
| 857 | return {*framebuffer, VkExtent2D{key.width, key.height}}; | 863 | return {*framebuffer, VkExtent2D{key.width, key.height}}; |
| @@ -1553,17 +1559,17 @@ VkBuffer RasterizerVulkan::DefaultBuffer() { | |||
| 1553 | return *default_buffer; | 1559 | return *default_buffer; |
| 1554 | } | 1560 | } |
| 1555 | 1561 | ||
| 1556 | VkBufferCreateInfo ci; | 1562 | default_buffer = device.GetLogical().CreateBuffer({ |
| 1557 | ci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | 1563 | .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, |
| 1558 | ci.pNext = nullptr; | 1564 | .pNext = nullptr, |
| 1559 | ci.flags = 0; | 1565 | .flags = 0, |
| 1560 | ci.size = DEFAULT_BUFFER_SIZE; | 1566 | .size = DEFAULT_BUFFER_SIZE, |
| 1561 | ci.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | | 1567 | .usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | |
| 1562 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | 1568 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, |
| 1563 | ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | 1569 | .sharingMode = VK_SHARING_MODE_EXCLUSIVE, |
| 1564 | ci.queueFamilyIndexCount = 0; | 1570 | .queueFamilyIndexCount = 0, |
| 1565 | ci.pQueueFamilyIndices = nullptr; | 1571 | .pQueueFamilyIndices = nullptr, |
| 1566 | default_buffer = device.GetLogical().CreateBuffer(ci); | 1572 | }); |
| 1567 | default_buffer_commit = memory_manager.Commit(default_buffer, false); | 1573 | default_buffer_commit = memory_manager.Commit(default_buffer, false); |
| 1568 | 1574 | ||
| 1569 | scheduler.RequestOutsideRenderPassOperationContext(); | 1575 | scheduler.RequestOutsideRenderPassOperationContext(); |