diff options
| author | 2021-06-24 02:41:09 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:39 -0400 | |
| commit | 7dafa96ab59892b7f1fbffdb61e4326e6443955f (patch) | |
| tree | 5ab58d56860db635542ea1ec24be258bd86b40b9 /src/video_core/renderer_vulkan | |
| parent | vk_graphics_pipeline: Implement conservative rendering (diff) | |
| download | yuzu-7dafa96ab59892b7f1fbffdb61e4326e6443955f.tar.gz yuzu-7dafa96ab59892b7f1fbffdb61e4326e6443955f.tar.xz yuzu-7dafa96ab59892b7f1fbffdb61e4326e6443955f.zip | |
shader: Rework varyings and implement passthrough geometry shaders
Put all varyings into a single std::bitset with helpers to access it.
Implement passthrough geometry shaders using host's.
Diffstat (limited to 'src/video_core/renderer_vulkan')
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp | 6 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | 16 |
2 files changed, 12 insertions, 10 deletions
diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index 70e183e65..6d664ed6b 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp | |||
| @@ -487,10 +487,9 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) { | |||
| 487 | static_vector<VkVertexInputBindingDivisorDescriptionEXT, 32> vertex_binding_divisors; | 487 | static_vector<VkVertexInputBindingDivisorDescriptionEXT, 32> vertex_binding_divisors; |
| 488 | static_vector<VkVertexInputAttributeDescription, 32> vertex_attributes; | 488 | static_vector<VkVertexInputAttributeDescription, 32> vertex_attributes; |
| 489 | if (key.state.dynamic_vertex_input) { | 489 | if (key.state.dynamic_vertex_input) { |
| 490 | const auto& input_attributes = stage_infos[0].input_generics; | ||
| 491 | for (size_t index = 0; index < key.state.attributes.size(); ++index) { | 490 | for (size_t index = 0; index < key.state.attributes.size(); ++index) { |
| 492 | const u32 type = key.state.DynamicAttributeType(index); | 491 | const u32 type = key.state.DynamicAttributeType(index); |
| 493 | if (!input_attributes[index].used || type == 0) { | 492 | if (!stage_infos[0].loads.Generic(index) || type == 0) { |
| 494 | continue; | 493 | continue; |
| 495 | } | 494 | } |
| 496 | vertex_attributes.push_back({ | 495 | vertex_attributes.push_back({ |
| @@ -526,10 +525,9 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) { | |||
| 526 | }); | 525 | }); |
| 527 | } | 526 | } |
| 528 | } | 527 | } |
| 529 | const auto& input_attributes = stage_infos[0].input_generics; | ||
| 530 | for (size_t index = 0; index < key.state.attributes.size(); ++index) { | 528 | for (size_t index = 0; index < key.state.attributes.size(); ++index) { |
| 531 | const auto& attribute = key.state.attributes[index]; | 529 | const auto& attribute = key.state.attributes[index]; |
| 532 | if (!attribute.enabled || !input_attributes[index].used) { | 530 | if (!attribute.enabled || !stage_infos[0].loads.Generic(index)) { |
| 533 | continue; | 531 | continue; |
| 534 | } | 532 | } |
| 535 | vertex_attributes.push_back({ | 533 | vertex_attributes.push_back({ |
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index ec06b124f..7aaa40ef2 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | |||
| @@ -123,18 +123,21 @@ Shader::AttributeType AttributeType(const FixedPipelineState& state, size_t inde | |||
| 123 | return Shader::AttributeType::Disabled; | 123 | return Shader::AttributeType::Disabled; |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | Shader::RuntimeInfo MakeRuntimeInfo(const GraphicsPipelineCacheKey& key, | 126 | Shader::RuntimeInfo MakeRuntimeInfo(std::span<const Shader::IR::Program> programs, |
| 127 | const GraphicsPipelineCacheKey& key, | ||
| 127 | const Shader::IR::Program& program, | 128 | const Shader::IR::Program& program, |
| 128 | const Shader::IR::Program* previous_program) { | 129 | const Shader::IR::Program* previous_program) { |
| 129 | Shader::RuntimeInfo info; | 130 | Shader::RuntimeInfo info; |
| 130 | if (previous_program) { | 131 | if (previous_program) { |
| 131 | info.previous_stage_stores_generic = previous_program->info.stores_generics; | 132 | info.previous_stage_stores = previous_program->info.stores; |
| 133 | if (previous_program->is_geometry_passthrough) { | ||
| 134 | info.previous_stage_stores.mask |= previous_program->info.passthrough.mask; | ||
| 135 | } | ||
| 132 | } else { | 136 | } else { |
| 133 | // Mark all stores as available | 137 | info.previous_stage_stores.mask.set(); |
| 134 | info.previous_stage_stores_generic.flip(); | ||
| 135 | } | 138 | } |
| 136 | const Shader::Stage stage{program.stage}; | 139 | const Shader::Stage stage{program.stage}; |
| 137 | const bool has_geometry{key.unique_hashes[4] != 0}; | 140 | const bool has_geometry{key.unique_hashes[4] != 0 && !programs[4].is_geometry_passthrough}; |
| 138 | const bool gl_ndc{key.state.ndc_minus_one_to_one != 0}; | 141 | const bool gl_ndc{key.state.ndc_minus_one_to_one != 0}; |
| 139 | const float point_size{Common::BitCast<float>(key.state.point_size)}; | 142 | const float point_size{Common::BitCast<float>(key.state.point_size)}; |
| 140 | switch (stage) { | 143 | switch (stage) { |
| @@ -302,6 +305,7 @@ PipelineCache::PipelineCache(RasterizerVulkan& rasterizer_, Tegra::Engines::Maxw | |||
| 302 | .support_demote_to_helper_invocation = true, | 305 | .support_demote_to_helper_invocation = true, |
| 303 | .support_int64_atomics = device.IsExtShaderAtomicInt64Supported(), | 306 | .support_int64_atomics = device.IsExtShaderAtomicInt64Supported(), |
| 304 | .support_derivative_control = true, | 307 | .support_derivative_control = true, |
| 308 | .support_geometry_shader_passthrough = device.IsNvGeometryShaderPassthroughSupported(), | ||
| 305 | 309 | ||
| 306 | .warp_size_potentially_larger_than_guest = device.IsWarpSizePotentiallyBiggerThanGuest(), | 310 | .warp_size_potentially_larger_than_guest = device.IsWarpSizePotentiallyBiggerThanGuest(), |
| 307 | 311 | ||
| @@ -518,7 +522,7 @@ std::unique_ptr<GraphicsPipeline> PipelineCache::CreateGraphicsPipeline( | |||
| 518 | const size_t stage_index{index - 1}; | 522 | const size_t stage_index{index - 1}; |
| 519 | infos[stage_index] = &program.info; | 523 | infos[stage_index] = &program.info; |
| 520 | 524 | ||
| 521 | const Shader::RuntimeInfo runtime_info{MakeRuntimeInfo(key, program, previous_stage)}; | 525 | const auto runtime_info{MakeRuntimeInfo(programs, key, program, previous_stage)}; |
| 522 | const std::vector<u32> code{EmitSPIRV(profile, runtime_info, program, binding)}; | 526 | const std::vector<u32> code{EmitSPIRV(profile, runtime_info, program, binding)}; |
| 523 | device.SaveShader(code); | 527 | device.SaveShader(code); |
| 524 | modules[stage_index] = BuildShader(device, code); | 528 | modules[stage_index] = BuildShader(device, code); |