diff options
| author | 2021-04-15 22:46:11 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:27 -0400 | |
| commit | 183855e396cc6918d36fbf3e38ea426e934b4e3e (patch) | |
| tree | a665794753520c09a1d34d8a086352894ec1cb72 /src/video_core | |
| parent | shader: Mark atomic instructions as writes (diff) | |
| download | yuzu-183855e396cc6918d36fbf3e38ea426e934b4e3e.tar.gz yuzu-183855e396cc6918d36fbf3e38ea426e934b4e3e.tar.xz yuzu-183855e396cc6918d36fbf3e38ea426e934b4e3e.zip | |
shader: Implement tessellation shaders, polygon mode and invocation id
Diffstat (limited to 'src/video_core')
6 files changed, 50 insertions, 3 deletions
diff --git a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp index dc4ff0da2..8f0b0b8ec 100644 --- a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp +++ b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp | |||
| @@ -685,6 +685,19 @@ VkCullModeFlagBits CullFace(Maxwell::CullFace cull_face) { | |||
| 685 | return {}; | 685 | return {}; |
| 686 | } | 686 | } |
| 687 | 687 | ||
| 688 | VkPolygonMode PolygonMode(Maxwell::PolygonMode polygon_mode) { | ||
| 689 | switch (polygon_mode) { | ||
| 690 | case Maxwell::PolygonMode::Point: | ||
| 691 | return VK_POLYGON_MODE_POINT; | ||
| 692 | case Maxwell::PolygonMode::Line: | ||
| 693 | return VK_POLYGON_MODE_LINE; | ||
| 694 | case Maxwell::PolygonMode::Fill: | ||
| 695 | return VK_POLYGON_MODE_FILL; | ||
| 696 | } | ||
| 697 | UNIMPLEMENTED_MSG("Unimplemented polygon mode={}", polygon_mode); | ||
| 698 | return {}; | ||
| 699 | } | ||
| 700 | |||
| 688 | VkComponentSwizzle SwizzleSource(Tegra::Texture::SwizzleSource swizzle) { | 701 | VkComponentSwizzle SwizzleSource(Tegra::Texture::SwizzleSource swizzle) { |
| 689 | switch (swizzle) { | 702 | switch (swizzle) { |
| 690 | case Tegra::Texture::SwizzleSource::Zero: | 703 | case Tegra::Texture::SwizzleSource::Zero: |
diff --git a/src/video_core/renderer_vulkan/maxwell_to_vk.h b/src/video_core/renderer_vulkan/maxwell_to_vk.h index 9f78e15b6..50a599c11 100644 --- a/src/video_core/renderer_vulkan/maxwell_to_vk.h +++ b/src/video_core/renderer_vulkan/maxwell_to_vk.h | |||
| @@ -65,6 +65,8 @@ VkFrontFace FrontFace(Maxwell::FrontFace front_face); | |||
| 65 | 65 | ||
| 66 | VkCullModeFlagBits CullFace(Maxwell::CullFace cull_face); | 66 | VkCullModeFlagBits CullFace(Maxwell::CullFace cull_face); |
| 67 | 67 | ||
| 68 | VkPolygonMode PolygonMode(Maxwell::PolygonMode polygon_mode); | ||
| 69 | |||
| 68 | VkComponentSwizzle SwizzleSource(Tegra::Texture::SwizzleSource swizzle); | 70 | VkComponentSwizzle SwizzleSource(Tegra::Texture::SwizzleSource swizzle); |
| 69 | 71 | ||
| 70 | VkViewportCoordinateSwizzleNV ViewportSwizzle(Maxwell::ViewportSwizzle swizzle); | 72 | VkViewportCoordinateSwizzleNV ViewportSwizzle(Maxwell::ViewportSwizzle swizzle); |
diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index 84720a6f9..d5e9dae0f 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp | |||
| @@ -355,7 +355,8 @@ void GraphicsPipeline::MakePipeline(const Device& device, VkRenderPass render_pa | |||
| 355 | static_cast<VkBool32>(state.depth_clamp_disabled == 0 ? VK_TRUE : VK_FALSE), | 355 | static_cast<VkBool32>(state.depth_clamp_disabled == 0 ? VK_TRUE : VK_FALSE), |
| 356 | .rasterizerDiscardEnable = | 356 | .rasterizerDiscardEnable = |
| 357 | static_cast<VkBool32>(state.rasterize_enable == 0 ? VK_TRUE : VK_FALSE), | 357 | static_cast<VkBool32>(state.rasterize_enable == 0 ? VK_TRUE : VK_FALSE), |
| 358 | .polygonMode = VK_POLYGON_MODE_FILL, | 358 | .polygonMode = |
| 359 | MaxwellToVK::PolygonMode(FixedPipelineState::UnpackPolygonMode(state.polygon_mode)), | ||
| 359 | .cullMode = static_cast<VkCullModeFlags>( | 360 | .cullMode = static_cast<VkCullModeFlags>( |
| 360 | dynamic.cull_enable ? MaxwellToVK::CullFace(dynamic.CullFace()) : VK_CULL_MODE_NONE), | 361 | dynamic.cull_enable ? MaxwellToVK::CullFace(dynamic.CullFace()) : VK_CULL_MODE_NONE), |
| 361 | .frontFace = MaxwellToVK::FrontFace(dynamic.FrontFace()), | 362 | .frontFace = MaxwellToVK::FrontFace(dynamic.FrontFace()), |
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index ee22255bf..0bccc640a 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | |||
| @@ -1040,6 +1040,36 @@ Shader::Profile PipelineCache::MakeProfile(const GraphicsPipelineCacheKey& key, | |||
| 1040 | std::ranges::transform(key.state.attributes, profile.generic_input_types.begin(), | 1040 | std::ranges::transform(key.state.attributes, profile.generic_input_types.begin(), |
| 1041 | &CastAttributeType); | 1041 | &CastAttributeType); |
| 1042 | break; | 1042 | break; |
| 1043 | case Shader::Stage::TessellationEval: | ||
| 1044 | // We have to flip tessellation clockwise for some reason... | ||
| 1045 | profile.tess_clockwise = key.state.tessellation_clockwise == 0; | ||
| 1046 | profile.tess_primitive = [&key] { | ||
| 1047 | const u32 raw{key.state.tessellation_primitive.Value()}; | ||
| 1048 | switch (static_cast<Maxwell::TessellationPrimitive>(raw)) { | ||
| 1049 | case Maxwell::TessellationPrimitive::Isolines: | ||
| 1050 | return Shader::TessPrimitive::Isolines; | ||
| 1051 | case Maxwell::TessellationPrimitive::Triangles: | ||
| 1052 | return Shader::TessPrimitive::Triangles; | ||
| 1053 | case Maxwell::TessellationPrimitive::Quads: | ||
| 1054 | return Shader::TessPrimitive::Quads; | ||
| 1055 | } | ||
| 1056 | UNREACHABLE(); | ||
| 1057 | return Shader::TessPrimitive::Triangles; | ||
| 1058 | }(); | ||
| 1059 | profile.tess_spacing = [&] { | ||
| 1060 | const u32 raw{key.state.tessellation_spacing}; | ||
| 1061 | switch (static_cast<Maxwell::TessellationSpacing>(raw)) { | ||
| 1062 | case Maxwell::TessellationSpacing::Equal: | ||
| 1063 | return Shader::TessSpacing::Equal; | ||
| 1064 | case Maxwell::TessellationSpacing::FractionalOdd: | ||
| 1065 | return Shader::TessSpacing::FractionalOdd; | ||
| 1066 | case Maxwell::TessellationSpacing::FractionalEven: | ||
| 1067 | return Shader::TessSpacing::FractionalEven; | ||
| 1068 | } | ||
| 1069 | UNREACHABLE(); | ||
| 1070 | return Shader::TessSpacing::Equal; | ||
| 1071 | }(); | ||
| 1072 | break; | ||
| 1043 | case Shader::Stage::Geometry: | 1073 | case Shader::Stage::Geometry: |
| 1044 | if (program.output_topology == Shader::OutputTopology::PointList) { | 1074 | if (program.output_topology == Shader::OutputTopology::PointList) { |
| 1045 | profile.fixed_state_point_size = point_size; | 1075 | profile.fixed_state_point_size = point_size; |
diff --git a/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp b/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp index 0412b5234..555b12ed7 100644 --- a/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp +++ b/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp | |||
| @@ -91,7 +91,7 @@ StagingBufferPool::StagingBufferPool(const Device& device_, MemoryAllocator& mem | |||
| 91 | .flags = 0, | 91 | .flags = 0, |
| 92 | .size = STREAM_BUFFER_SIZE, | 92 | .size = STREAM_BUFFER_SIZE, |
| 93 | .usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | | 93 | .usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | |
| 94 | VK_BUFFER_USAGE_INDEX_BUFFER_BIT, | 94 | VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, |
| 95 | .sharingMode = VK_SHARING_MODE_EXCLUSIVE, | 95 | .sharingMode = VK_SHARING_MODE_EXCLUSIVE, |
| 96 | .queueFamilyIndexCount = 0, | 96 | .queueFamilyIndexCount = 0, |
| 97 | .pQueueFamilyIndices = nullptr, | 97 | .pQueueFamilyIndices = nullptr, |
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index 87cfe6312..f0de19ba1 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp | |||
| @@ -225,7 +225,7 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR | |||
| 225 | .drawIndirectFirstInstance = false, | 225 | .drawIndirectFirstInstance = false, |
| 226 | .depthClamp = true, | 226 | .depthClamp = true, |
| 227 | .depthBiasClamp = true, | 227 | .depthBiasClamp = true, |
| 228 | .fillModeNonSolid = false, | 228 | .fillModeNonSolid = true, |
| 229 | .depthBounds = false, | 229 | .depthBounds = false, |
| 230 | .wideLines = false, | 230 | .wideLines = false, |
| 231 | .largePoints = true, | 231 | .largePoints = true, |
| @@ -670,6 +670,7 @@ void Device::CheckSuitability(bool requires_swapchain) const { | |||
| 670 | std::make_pair(features.largePoints, "largePoints"), | 670 | std::make_pair(features.largePoints, "largePoints"), |
| 671 | std::make_pair(features.multiViewport, "multiViewport"), | 671 | std::make_pair(features.multiViewport, "multiViewport"), |
| 672 | std::make_pair(features.depthBiasClamp, "depthBiasClamp"), | 672 | std::make_pair(features.depthBiasClamp, "depthBiasClamp"), |
| 673 | std::make_pair(features.fillModeNonSolid, "fillModeNonSolid"), | ||
| 673 | std::make_pair(features.geometryShader, "geometryShader"), | 674 | std::make_pair(features.geometryShader, "geometryShader"), |
| 674 | std::make_pair(features.tessellationShader, "tessellationShader"), | 675 | std::make_pair(features.tessellationShader, "tessellationShader"), |
| 675 | std::make_pair(features.occlusionQueryPrecise, "occlusionQueryPrecise"), | 676 | std::make_pair(features.occlusionQueryPrecise, "occlusionQueryPrecise"), |