diff options
| author | 2021-03-24 01:33:45 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:24 -0400 | |
| commit | 68a9505d8a1d00c6ba2739bc0af3069cf87b9b84 (patch) | |
| tree | b9a78497cd8af1d73a7eda34cd0df08b3dc324e6 /src/video_core/renderer_vulkan | |
| parent | shader: Fix use-after-free bug in object_pool (diff) | |
| download | yuzu-68a9505d8a1d00c6ba2739bc0af3069cf87b9b84.tar.gz yuzu-68a9505d8a1d00c6ba2739bc0af3069cf87b9b84.tar.xz yuzu-68a9505d8a1d00c6ba2739bc0af3069cf87b9b84.zip | |
shader: Implement NDC [-1, 1], attribute types and default varying initialization
Diffstat (limited to 'src/video_core/renderer_vulkan')
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp | 3 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | 33 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_pipeline_cache.h | 4 |
3 files changed, 37 insertions, 3 deletions
diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index a2ec418b1..a87ed1976 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp | |||
| @@ -181,6 +181,9 @@ void GraphicsPipeline::Configure(bool is_indexed) { | |||
| 181 | PushImageDescriptors(stage_infos[stage], samplers.data(), image_view_ids.data(), | 181 | PushImageDescriptors(stage_infos[stage], samplers.data(), image_view_ids.data(), |
| 182 | *texture_cache, *update_descriptor_queue, index); | 182 | *texture_cache, *update_descriptor_queue, index); |
| 183 | } | 183 | } |
| 184 | if (!descriptor_set_layout) { | ||
| 185 | return; | ||
| 186 | } | ||
| 184 | const VkDescriptorSet descriptor_set{descriptor_allocator.Commit()}; | 187 | const VkDescriptorSet descriptor_set{descriptor_allocator.Commit()}; |
| 185 | update_descriptor_queue->Send(*descriptor_update_template, descriptor_set); | 188 | update_descriptor_queue->Send(*descriptor_update_template, descriptor_set); |
| 186 | 189 | ||
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index bdbc8dd1e..504b8c9d6 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | |||
| @@ -437,7 +437,7 @@ PipelineCache::PipelineCache(RasterizerVulkan& rasterizer_, Tegra::GPU& gpu_, | |||
| 437 | buffer_cache{buffer_cache_}, texture_cache{texture_cache_} { | 437 | buffer_cache{buffer_cache_}, texture_cache{texture_cache_} { |
| 438 | const auto& float_control{device.FloatControlProperties()}; | 438 | const auto& float_control{device.FloatControlProperties()}; |
| 439 | const VkDriverIdKHR driver_id{device.GetDriverID()}; | 439 | const VkDriverIdKHR driver_id{device.GetDriverID()}; |
| 440 | profile = Shader::Profile{ | 440 | base_profile = Shader::Profile{ |
| 441 | .unified_descriptor_binding = true, | 441 | .unified_descriptor_binding = true, |
| 442 | .support_vertex_instance_id = false, | 442 | .support_vertex_instance_id = false, |
| 443 | .support_float_controls = true, | 443 | .support_float_controls = true, |
| @@ -458,6 +458,7 @@ PipelineCache::PipelineCache(RasterizerVulkan& rasterizer_, Tegra::GPU& gpu_, | |||
| 458 | .support_vote = true, | 458 | .support_vote = true, |
| 459 | .warp_size_potentially_larger_than_guest = device.IsWarpSizePotentiallyBiggerThanGuest(), | 459 | .warp_size_potentially_larger_than_guest = device.IsWarpSizePotentiallyBiggerThanGuest(), |
| 460 | .has_broken_spirv_clamp = driver_id == VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS_KHR, | 460 | .has_broken_spirv_clamp = driver_id == VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS_KHR, |
| 461 | .generic_input_types{}, | ||
| 461 | }; | 462 | }; |
| 462 | } | 463 | } |
| 463 | 464 | ||
| @@ -589,6 +590,7 @@ GraphicsPipeline PipelineCache::CreateGraphicsPipeline(ShaderPools& pools, | |||
| 589 | Shader::Environment& env{*envs[env_index]}; | 590 | Shader::Environment& env{*envs[env_index]}; |
| 590 | ++env_index; | 591 | ++env_index; |
| 591 | 592 | ||
| 593 | const Shader::Profile profile{MakeProfile(key, env.ShaderStage())}; | ||
| 592 | const std::vector<u32> code{EmitSPIRV(profile, env, program, binding)}; | 594 | const std::vector<u32> code{EmitSPIRV(profile, env, program, binding)}; |
| 593 | modules[stage_index] = BuildShader(device, code); | 595 | modules[stage_index] = BuildShader(device, code); |
| 594 | } | 596 | } |
| @@ -645,9 +647,36 @@ ComputePipeline PipelineCache::CreateComputePipeline(ShaderPools& pools, | |||
| 645 | Shader::Maxwell::Flow::CFG cfg{env, pools.flow_block, env.StartAddress()}; | 647 | Shader::Maxwell::Flow::CFG cfg{env, pools.flow_block, env.StartAddress()}; |
| 646 | Shader::IR::Program program{TranslateProgram(pools.inst, pools.block, env, cfg)}; | 648 | Shader::IR::Program program{TranslateProgram(pools.inst, pools.block, env, cfg)}; |
| 647 | u32 binding{0}; | 649 | u32 binding{0}; |
| 648 | std::vector<u32> code{EmitSPIRV(profile, env, program, binding)}; | 650 | std::vector<u32> code{EmitSPIRV(base_profile, env, program, binding)}; |
| 649 | return ComputePipeline{device, descriptor_pool, update_descriptor_queue, program.info, | 651 | return ComputePipeline{device, descriptor_pool, update_descriptor_queue, program.info, |
| 650 | BuildShader(device, code)}; | 652 | BuildShader(device, code)}; |
| 651 | } | 653 | } |
| 652 | 654 | ||
| 655 | static Shader::AttributeType CastAttributeType(const FixedPipelineState::VertexAttribute& attr) { | ||
| 656 | switch (attr.Type()) { | ||
| 657 | case Maxwell::VertexAttribute::Type::SignedNorm: | ||
| 658 | case Maxwell::VertexAttribute::Type::UnsignedNorm: | ||
| 659 | case Maxwell::VertexAttribute::Type::UnsignedScaled: | ||
| 660 | case Maxwell::VertexAttribute::Type::SignedScaled: | ||
| 661 | case Maxwell::VertexAttribute::Type::Float: | ||
| 662 | return Shader::AttributeType::Float; | ||
| 663 | case Maxwell::VertexAttribute::Type::SignedInt: | ||
| 664 | return Shader::AttributeType::SignedInt; | ||
| 665 | case Maxwell::VertexAttribute::Type::UnsignedInt: | ||
| 666 | return Shader::AttributeType::UnsignedInt; | ||
| 667 | } | ||
| 668 | return Shader::AttributeType::Float; | ||
| 669 | } | ||
| 670 | |||
| 671 | Shader::Profile PipelineCache::MakeProfile(const GraphicsPipelineCacheKey& key, | ||
| 672 | Shader::Stage stage) { | ||
| 673 | Shader::Profile profile{base_profile}; | ||
| 674 | if (stage == Shader::Stage::VertexB) { | ||
| 675 | profile.convert_depth_mode = key.state.ndc_minus_one_to_one != 0; | ||
| 676 | std::ranges::transform(key.state.attributes, profile.generic_input_types.begin(), | ||
| 677 | &CastAttributeType); | ||
| 678 | } | ||
| 679 | return profile; | ||
| 680 | } | ||
| 681 | |||
| 653 | } // namespace Vulkan | 682 | } // namespace Vulkan |
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.h b/src/video_core/renderer_vulkan/vk_pipeline_cache.h index d481f56f9..e09d78063 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.h +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.h | |||
| @@ -156,6 +156,8 @@ private: | |||
| 156 | ComputePipeline CreateComputePipeline(ShaderPools& pools, const ComputePipelineCacheKey& key, | 156 | ComputePipeline CreateComputePipeline(ShaderPools& pools, const ComputePipelineCacheKey& key, |
| 157 | Shader::Environment& env) const; | 157 | Shader::Environment& env) const; |
| 158 | 158 | ||
| 159 | Shader::Profile MakeProfile(const GraphicsPipelineCacheKey& key, Shader::Stage stage); | ||
| 160 | |||
| 159 | Tegra::GPU& gpu; | 161 | Tegra::GPU& gpu; |
| 160 | Tegra::Engines::Maxwell3D& maxwell3d; | 162 | Tegra::Engines::Maxwell3D& maxwell3d; |
| 161 | Tegra::Engines::KeplerCompute& kepler_compute; | 163 | Tegra::Engines::KeplerCompute& kepler_compute; |
| @@ -176,7 +178,7 @@ private: | |||
| 176 | 178 | ||
| 177 | ShaderPools main_pools; | 179 | ShaderPools main_pools; |
| 178 | 180 | ||
| 179 | Shader::Profile profile; | 181 | Shader::Profile base_profile; |
| 180 | std::string pipeline_cache_filename; | 182 | std::string pipeline_cache_filename; |
| 181 | }; | 183 | }; |
| 182 | 184 | ||