diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2020-05-04 23:31:17 +0200 |
---|---|---|
committer | ReinUsesLisp <reinuseslisp@airmail.cc> | 2020-05-04 23:31:17 +0200 |
commit | 2dbf5290f28efa47b2484537e9316909831fee05 (patch) | |
tree | 8532b1b39dc83cb9d6e6460a21b6fbebd3084b65 /src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp | |
parent | gl_rasterizer: Implement viewport swizzles with NV_viewport_swizzle (diff) | |
download | yuzu-2dbf5290f28efa47b2484537e9316909831fee05.tar yuzu-2dbf5290f28efa47b2484537e9316909831fee05.tar.gz yuzu-2dbf5290f28efa47b2484537e9316909831fee05.tar.bz2 yuzu-2dbf5290f28efa47b2484537e9316909831fee05.tar.lz yuzu-2dbf5290f28efa47b2484537e9316909831fee05.tar.xz yuzu-2dbf5290f28efa47b2484537e9316909831fee05.tar.zst yuzu-2dbf5290f28efa47b2484537e9316909831fee05.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index 1ac981974..5beea6a03 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <algorithm> #include <array> #include <cstring> #include <vector> @@ -50,6 +51,23 @@ bool SupportsPrimitiveRestart(VkPrimitiveTopology topology) { topology) == std::end(unsupported_topologies); } +VkViewportSwizzleNV UnpackViewportSwizzle(u16 swizzle) { + union { + u32 raw; + BitField<0, 3, Maxwell::ViewportSwizzle> x; + BitField<4, 3, Maxwell::ViewportSwizzle> y; + BitField<8, 3, Maxwell::ViewportSwizzle> z; + BitField<12, 3, Maxwell::ViewportSwizzle> w; + } const unpacked{swizzle}; + + VkViewportSwizzleNV result; + result.x = MaxwellToVK::ViewportSwizzle(unpacked.x); + result.y = MaxwellToVK::ViewportSwizzle(unpacked.y); + result.z = MaxwellToVK::ViewportSwizzle(unpacked.z); + result.w = MaxwellToVK::ViewportSwizzle(unpacked.w); + return result; +} + } // Anonymous namespace VKGraphicsPipeline::VKGraphicsPipeline(const VKDevice& device, VKScheduler& scheduler, @@ -162,6 +180,7 @@ vk::Pipeline VKGraphicsPipeline::CreatePipeline(const RenderPassParams& renderpa const auto& ds = fixed_state.depth_stencil; const auto& cd = fixed_state.color_blending; const auto& rs = fixed_state.rasterizer; + const auto& viewport_swizzles = fixed_state.viewport_swizzles.swizzles; std::vector<VkVertexInputBindingDescription> vertex_bindings; std::vector<VkVertexInputBindingDivisorDescriptionEXT> vertex_binding_divisors; @@ -244,6 +263,19 @@ vk::Pipeline VKGraphicsPipeline::CreatePipeline(const RenderPassParams& renderpa viewport_ci.scissorCount = Maxwell::NumViewports; viewport_ci.pScissors = nullptr; + std::array<VkViewportSwizzleNV, Maxwell::NumViewports> swizzles; + std::transform(viewport_swizzles.begin(), viewport_swizzles.end(), swizzles.begin(), + UnpackViewportSwizzle); + VkPipelineViewportSwizzleStateCreateInfoNV swizzle_ci; + swizzle_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV; + swizzle_ci.pNext = nullptr; + swizzle_ci.flags = 0; + swizzle_ci.viewportCount = Maxwell::NumViewports; + swizzle_ci.pViewportSwizzles = swizzles.data(); + if (device.IsNvViewportSwizzleSupported()) { + viewport_ci.pNext = &swizzle_ci; + } + VkPipelineRasterizationStateCreateInfo rasterization_ci; rasterization_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; rasterization_ci.pNext = nullptr; |