diff options
| author | 2021-01-08 12:24:46 -0800 | |
|---|---|---|
| committer | 2021-01-08 12:24:46 -0800 | |
| commit | 8eea7c1176e587d4cfede258164998d9af3419e9 (patch) | |
| tree | d21b318c0451fe16ace40a8b02518de7465c0e5d | |
| parent | Merge pull request #5300 from JeremyStarTM/patch-1 (diff) | |
| parent | renderer_vulkan/fixed_pipeline_state: Move enabled bindings to static state (diff) | |
| download | yuzu-8eea7c1176e587d4cfede258164998d9af3419e9.tar.gz yuzu-8eea7c1176e587d4cfede258164998d9af3419e9.tar.xz yuzu-8eea7c1176e587d4cfede258164998d9af3419e9.zip | |
Merge pull request #5231 from ReinUsesLisp/dyn-bindings
renderer_vulkan/fixed_pipeline_state: Move enabled bindings to static state
Diffstat (limited to '')
3 files changed, 12 insertions, 26 deletions
diff --git a/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp b/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp index 67dd10500..5be6dabd9 100644 --- a/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp +++ b/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp | |||
| @@ -76,7 +76,7 @@ void FixedPipelineState::Fill(const Maxwell& regs, bool has_extended_dynamic_sta | |||
| 76 | regs.instanced_arrays.IsInstancingEnabled(index) ? regs.vertex_array[index].divisor : 0; | 76 | regs.instanced_arrays.IsInstancingEnabled(index) ? regs.vertex_array[index].divisor : 0; |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | for (std::size_t index = 0; index < Maxwell::NumVertexAttributes; ++index) { | 79 | for (size_t index = 0; index < Maxwell::NumVertexAttributes; ++index) { |
| 80 | const auto& input = regs.vertex_attrib_format[index]; | 80 | const auto& input = regs.vertex_attrib_format[index]; |
| 81 | auto& attribute = attributes[index]; | 81 | auto& attribute = attributes[index]; |
| 82 | attribute.raw = 0; | 82 | attribute.raw = 0; |
| @@ -85,6 +85,7 @@ void FixedPipelineState::Fill(const Maxwell& regs, bool has_extended_dynamic_sta | |||
| 85 | attribute.offset.Assign(input.offset); | 85 | attribute.offset.Assign(input.offset); |
| 86 | attribute.type.Assign(static_cast<u32>(input.type.Value())); | 86 | attribute.type.Assign(static_cast<u32>(input.type.Value())); |
| 87 | attribute.size.Assign(static_cast<u32>(input.size.Value())); | 87 | attribute.size.Assign(static_cast<u32>(input.size.Value())); |
| 88 | attribute.binding_index_enabled.Assign(regs.vertex_array[index].IsEnabled() ? 1 : 0); | ||
| 88 | } | 89 | } |
| 89 | 90 | ||
| 90 | for (std::size_t index = 0; index < std::size(attachments); ++index) { | 91 | for (std::size_t index = 0; index < std::size(attachments); ++index) { |
| @@ -172,14 +173,9 @@ void FixedPipelineState::DynamicState::Fill(const Maxwell& regs) { | |||
| 172 | depth_test_func.Assign(PackComparisonOp(regs.depth_test_func)); | 173 | depth_test_func.Assign(PackComparisonOp(regs.depth_test_func)); |
| 173 | cull_face.Assign(PackCullFace(regs.cull_face)); | 174 | cull_face.Assign(PackCullFace(regs.cull_face)); |
| 174 | cull_enable.Assign(regs.cull_test_enabled != 0 ? 1 : 0); | 175 | cull_enable.Assign(regs.cull_test_enabled != 0 ? 1 : 0); |
| 175 | 176 | std::ranges::transform(regs.vertex_array, vertex_strides.begin(), [](const auto& array) { | |
| 176 | for (std::size_t index = 0; index < Maxwell::NumVertexArrays; ++index) { | 177 | return static_cast<u16>(array.stride.Value()); |
| 177 | const auto& input = regs.vertex_array[index]; | 178 | }); |
| 178 | VertexBinding& binding = vertex_bindings[index]; | ||
| 179 | binding.raw = 0; | ||
| 180 | binding.enabled.Assign(input.IsEnabled() ? 1 : 0); | ||
| 181 | binding.stride.Assign(static_cast<u16>(input.stride.Value())); | ||
| 182 | } | ||
| 183 | } | 179 | } |
| 184 | 180 | ||
| 185 | std::size_t FixedPipelineState::Hash() const noexcept { | 181 | std::size_t FixedPipelineState::Hash() const noexcept { |
diff --git a/src/video_core/renderer_vulkan/fixed_pipeline_state.h b/src/video_core/renderer_vulkan/fixed_pipeline_state.h index 7e95e6fce..465a55fdb 100644 --- a/src/video_core/renderer_vulkan/fixed_pipeline_state.h +++ b/src/video_core/renderer_vulkan/fixed_pipeline_state.h | |||
| @@ -96,6 +96,8 @@ struct FixedPipelineState { | |||
| 96 | BitField<6, 14, u32> offset; | 96 | BitField<6, 14, u32> offset; |
| 97 | BitField<20, 3, u32> type; | 97 | BitField<20, 3, u32> type; |
| 98 | BitField<23, 6, u32> size; | 98 | BitField<23, 6, u32> size; |
| 99 | // Not really an element of a vertex attribute, but it can be packed here | ||
| 100 | BitField<29, 1, u32> binding_index_enabled; | ||
| 99 | 101 | ||
| 100 | constexpr Maxwell::VertexAttribute::Type Type() const noexcept { | 102 | constexpr Maxwell::VertexAttribute::Type Type() const noexcept { |
| 101 | return static_cast<Maxwell::VertexAttribute::Type>(type.Value()); | 103 | return static_cast<Maxwell::VertexAttribute::Type>(type.Value()); |
| @@ -130,12 +132,6 @@ struct FixedPipelineState { | |||
| 130 | } | 132 | } |
| 131 | }; | 133 | }; |
| 132 | 134 | ||
| 133 | union VertexBinding { | ||
| 134 | u16 raw; | ||
| 135 | BitField<0, 12, u16> stride; | ||
| 136 | BitField<12, 1, u16> enabled; | ||
| 137 | }; | ||
| 138 | |||
| 139 | struct DynamicState { | 135 | struct DynamicState { |
| 140 | union { | 136 | union { |
| 141 | u32 raw1; | 137 | u32 raw1; |
| @@ -153,7 +149,8 @@ struct FixedPipelineState { | |||
| 153 | BitField<0, 2, u32> cull_face; | 149 | BitField<0, 2, u32> cull_face; |
| 154 | BitField<2, 1, u32> cull_enable; | 150 | BitField<2, 1, u32> cull_enable; |
| 155 | }; | 151 | }; |
| 156 | std::array<VertexBinding, Maxwell::NumVertexArrays> vertex_bindings; | 152 | // Vertex stride is a 12 bits value, we have 4 bits to spare per element |
| 153 | std::array<u16, Maxwell::NumVertexArrays> vertex_strides; | ||
| 157 | 154 | ||
| 158 | void Fill(const Maxwell& regs); | 155 | void Fill(const Maxwell& regs); |
| 159 | 156 | ||
diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index 8a94464f6..a5214d0bc 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp | |||
| @@ -212,11 +212,7 @@ vk::Pipeline VKGraphicsPipeline::CreatePipeline(const SPIRVProgram& program, | |||
| 212 | // state is ignored | 212 | // state is ignored |
| 213 | dynamic.raw1 = 0; | 213 | dynamic.raw1 = 0; |
| 214 | dynamic.raw2 = 0; | 214 | dynamic.raw2 = 0; |
| 215 | for (FixedPipelineState::VertexBinding& binding : dynamic.vertex_bindings) { | 215 | dynamic.vertex_strides.fill(0); |
| 216 | // Enable all vertex bindings | ||
| 217 | binding.raw = 0; | ||
| 218 | binding.enabled.Assign(1); | ||
| 219 | } | ||
| 220 | } else { | 216 | } else { |
| 221 | dynamic = state.dynamic_state; | 217 | dynamic = state.dynamic_state; |
| 222 | } | 218 | } |
| @@ -224,19 +220,16 @@ vk::Pipeline VKGraphicsPipeline::CreatePipeline(const SPIRVProgram& program, | |||
| 224 | std::vector<VkVertexInputBindingDescription> vertex_bindings; | 220 | std::vector<VkVertexInputBindingDescription> vertex_bindings; |
| 225 | std::vector<VkVertexInputBindingDivisorDescriptionEXT> vertex_binding_divisors; | 221 | std::vector<VkVertexInputBindingDivisorDescriptionEXT> vertex_binding_divisors; |
| 226 | for (std::size_t index = 0; index < Maxwell::NumVertexArrays; ++index) { | 222 | for (std::size_t index = 0; index < Maxwell::NumVertexArrays; ++index) { |
| 227 | const auto& binding = dynamic.vertex_bindings[index]; | 223 | if (state.attributes[index].binding_index_enabled == 0) { |
| 228 | if (!binding.enabled) { | ||
| 229 | continue; | 224 | continue; |
| 230 | } | 225 | } |
| 231 | const bool instanced = state.binding_divisors[index] != 0; | 226 | const bool instanced = state.binding_divisors[index] != 0; |
| 232 | const auto rate = instanced ? VK_VERTEX_INPUT_RATE_INSTANCE : VK_VERTEX_INPUT_RATE_VERTEX; | 227 | const auto rate = instanced ? VK_VERTEX_INPUT_RATE_INSTANCE : VK_VERTEX_INPUT_RATE_VERTEX; |
| 233 | |||
| 234 | vertex_bindings.push_back({ | 228 | vertex_bindings.push_back({ |
| 235 | .binding = static_cast<u32>(index), | 229 | .binding = static_cast<u32>(index), |
| 236 | .stride = binding.stride, | 230 | .stride = dynamic.vertex_strides[index], |
| 237 | .inputRate = rate, | 231 | .inputRate = rate, |
| 238 | }); | 232 | }); |
| 239 | |||
| 240 | if (instanced) { | 233 | if (instanced) { |
| 241 | vertex_binding_divisors.push_back({ | 234 | vertex_binding_divisors.push_back({ |
| 242 | .binding = static_cast<u32>(index), | 235 | .binding = static_cast<u32>(index), |