diff options
| author | 2021-06-16 04:59:30 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:38 -0400 | |
| commit | 374eeda1a35f6a1dc81cf22122c701be68e89c0f (patch) | |
| tree | 1155e56fffab693fe2c66ca38e6a435562c21b6d /src/video_core/renderer_vulkan | |
| parent | glsl: Only declare fragment outputs on fragment shaders (diff) | |
| download | yuzu-374eeda1a35f6a1dc81cf22122c701be68e89c0f.tar.gz yuzu-374eeda1a35f6a1dc81cf22122c701be68e89c0f.tar.xz yuzu-374eeda1a35f6a1dc81cf22122c701be68e89c0f.zip | |
shader: Properly manage attributes not written from previous stages
Diffstat (limited to 'src/video_core/renderer_vulkan')
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index 72e6f4207..dc028306a 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | |||
| @@ -90,7 +90,7 @@ Shader::CompareFunction MaxwellToCompareFunction(Maxwell::ComparisonOp compariso | |||
| 90 | return {}; | 90 | return {}; |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | static Shader::AttributeType CastAttributeType(const FixedPipelineState::VertexAttribute& attr) { | 93 | Shader::AttributeType CastAttributeType(const FixedPipelineState::VertexAttribute& attr) { |
| 94 | if (attr.enabled == 0) { | 94 | if (attr.enabled == 0) { |
| 95 | return Shader::AttributeType::Disabled; | 95 | return Shader::AttributeType::Disabled; |
| 96 | } | 96 | } |
| @@ -124,9 +124,15 @@ Shader::AttributeType AttributeType(const FixedPipelineState& state, size_t inde | |||
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | Shader::RuntimeInfo MakeRuntimeInfo(const GraphicsPipelineCacheKey& key, | 126 | Shader::RuntimeInfo MakeRuntimeInfo(const GraphicsPipelineCacheKey& key, |
| 127 | const Shader::IR::Program& program) { | 127 | const Shader::IR::Program& program, |
| 128 | const Shader::IR::Program* previous_program) { | ||
| 128 | Shader::RuntimeInfo info; | 129 | Shader::RuntimeInfo info; |
| 129 | 130 | if (previous_program) { | |
| 131 | info.previous_stage_stores_generic = previous_program->info.stores_generics; | ||
| 132 | } else { | ||
| 133 | // Mark all stores as available | ||
| 134 | info.previous_stage_stores_generic.flip(); | ||
| 135 | } | ||
| 130 | const Shader::Stage stage{program.stage}; | 136 | const Shader::Stage stage{program.stage}; |
| 131 | const bool has_geometry{key.unique_hashes[4] != 0}; | 137 | const bool has_geometry{key.unique_hashes[4] != 0}; |
| 132 | const bool gl_ndc{key.state.ndc_minus_one_to_one != 0}; | 138 | const bool gl_ndc{key.state.ndc_minus_one_to_one != 0}; |
| @@ -499,6 +505,7 @@ std::unique_ptr<GraphicsPipeline> PipelineCache::CreateGraphicsPipeline( | |||
| 499 | std::array<const Shader::Info*, Maxwell::MaxShaderStage> infos{}; | 505 | std::array<const Shader::Info*, Maxwell::MaxShaderStage> infos{}; |
| 500 | std::array<vk::ShaderModule, Maxwell::MaxShaderStage> modules; | 506 | std::array<vk::ShaderModule, Maxwell::MaxShaderStage> modules; |
| 501 | 507 | ||
| 508 | const Shader::IR::Program* previous_stage{}; | ||
| 502 | Shader::Backend::Bindings binding; | 509 | Shader::Backend::Bindings binding; |
| 503 | for (size_t index = uses_vertex_a && uses_vertex_b ? 1 : 0; index < Maxwell::MaxShaderProgram; | 510 | for (size_t index = uses_vertex_a && uses_vertex_b ? 1 : 0; index < Maxwell::MaxShaderProgram; |
| 504 | ++index) { | 511 | ++index) { |
| @@ -511,7 +518,7 @@ std::unique_ptr<GraphicsPipeline> PipelineCache::CreateGraphicsPipeline( | |||
| 511 | const size_t stage_index{index - 1}; | 518 | const size_t stage_index{index - 1}; |
| 512 | infos[stage_index] = &program.info; | 519 | infos[stage_index] = &program.info; |
| 513 | 520 | ||
| 514 | const Shader::RuntimeInfo runtime_info{MakeRuntimeInfo(key, program)}; | 521 | const Shader::RuntimeInfo runtime_info{MakeRuntimeInfo(key, program, previous_stage)}; |
| 515 | const std::vector<u32> code{EmitSPIRV(profile, runtime_info, program, binding)}; | 522 | const std::vector<u32> code{EmitSPIRV(profile, runtime_info, program, binding)}; |
| 516 | device.SaveShader(code); | 523 | device.SaveShader(code); |
| 517 | modules[stage_index] = BuildShader(device, code); | 524 | modules[stage_index] = BuildShader(device, code); |
| @@ -519,6 +526,7 @@ std::unique_ptr<GraphicsPipeline> PipelineCache::CreateGraphicsPipeline( | |||
| 519 | const std::string name{fmt::format("Shader {:016x}", key.unique_hashes[index])}; | 526 | const std::string name{fmt::format("Shader {:016x}", key.unique_hashes[index])}; |
| 520 | modules[stage_index].SetObjectNameEXT(name.c_str()); | 527 | modules[stage_index].SetObjectNameEXT(name.c_str()); |
| 521 | } | 528 | } |
| 529 | previous_stage = &program; | ||
| 522 | } | 530 | } |
| 523 | Common::ThreadWorker* const thread_worker{build_in_parallel ? &workers : nullptr}; | 531 | Common::ThreadWorker* const thread_worker{build_in_parallel ? &workers : nullptr}; |
| 524 | VideoCore::ShaderNotify* const notify{build_in_parallel ? &shader_notify : nullptr}; | 532 | VideoCore::ShaderNotify* const notify{build_in_parallel ? &shader_notify : nullptr}; |