diff options
| author | 2021-05-21 02:12:32 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:33 -0400 | |
| commit | 9e7b6622c25aa858b96bf0f1c7f94223a2f449a2 (patch) | |
| tree | 48c62889aeb79d6f0f01a467ba0d1ac01dec512b /src/video_core/renderer_vulkan | |
| parent | emit_glasm_context_get_and_set.cpp: Add missing semicolons (diff) | |
| download | yuzu-9e7b6622c25aa858b96bf0f1c7f94223a2f449a2.tar.gz yuzu-9e7b6622c25aa858b96bf0f1c7f94223a2f449a2.tar.xz yuzu-9e7b6622c25aa858b96bf0f1c7f94223a2f449a2.zip | |
shader: Split profile and runtime information in separate structs
Diffstat (limited to 'src/video_core/renderer_vulkan')
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | 418 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_pipeline_cache.h | 5 |
2 files changed, 208 insertions, 215 deletions
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index 7830c0194..88db10b75 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | |||
| @@ -89,6 +89,208 @@ Shader::CompareFunction MaxwellToCompareFunction(Maxwell::ComparisonOp compariso | |||
| 89 | UNIMPLEMENTED_MSG("Unimplemented comparison op={}", comparison); | 89 | UNIMPLEMENTED_MSG("Unimplemented comparison op={}", comparison); |
| 90 | return {}; | 90 | return {}; |
| 91 | } | 91 | } |
| 92 | |||
| 93 | static Shader::AttributeType CastAttributeType(const FixedPipelineState::VertexAttribute& attr) { | ||
| 94 | if (attr.enabled == 0) { | ||
| 95 | return Shader::AttributeType::Disabled; | ||
| 96 | } | ||
| 97 | switch (attr.Type()) { | ||
| 98 | case Maxwell::VertexAttribute::Type::SignedNorm: | ||
| 99 | case Maxwell::VertexAttribute::Type::UnsignedNorm: | ||
| 100 | case Maxwell::VertexAttribute::Type::UnsignedScaled: | ||
| 101 | case Maxwell::VertexAttribute::Type::SignedScaled: | ||
| 102 | case Maxwell::VertexAttribute::Type::Float: | ||
| 103 | return Shader::AttributeType::Float; | ||
| 104 | case Maxwell::VertexAttribute::Type::SignedInt: | ||
| 105 | return Shader::AttributeType::SignedInt; | ||
| 106 | case Maxwell::VertexAttribute::Type::UnsignedInt: | ||
| 107 | return Shader::AttributeType::UnsignedInt; | ||
| 108 | } | ||
| 109 | return Shader::AttributeType::Float; | ||
| 110 | } | ||
| 111 | |||
| 112 | std::vector<Shader::TransformFeedbackVarying> MakeTransformFeedbackVaryings( | ||
| 113 | const GraphicsPipelineCacheKey& key) { | ||
| 114 | static constexpr std::array VECTORS{ | ||
| 115 | 28, // gl_Position | ||
| 116 | 32, // Generic 0 | ||
| 117 | 36, // Generic 1 | ||
| 118 | 40, // Generic 2 | ||
| 119 | 44, // Generic 3 | ||
| 120 | 48, // Generic 4 | ||
| 121 | 52, // Generic 5 | ||
| 122 | 56, // Generic 6 | ||
| 123 | 60, // Generic 7 | ||
| 124 | 64, // Generic 8 | ||
| 125 | 68, // Generic 9 | ||
| 126 | 72, // Generic 10 | ||
| 127 | 76, // Generic 11 | ||
| 128 | 80, // Generic 12 | ||
| 129 | 84, // Generic 13 | ||
| 130 | 88, // Generic 14 | ||
| 131 | 92, // Generic 15 | ||
| 132 | 96, // Generic 16 | ||
| 133 | 100, // Generic 17 | ||
| 134 | 104, // Generic 18 | ||
| 135 | 108, // Generic 19 | ||
| 136 | 112, // Generic 20 | ||
| 137 | 116, // Generic 21 | ||
| 138 | 120, // Generic 22 | ||
| 139 | 124, // Generic 23 | ||
| 140 | 128, // Generic 24 | ||
| 141 | 132, // Generic 25 | ||
| 142 | 136, // Generic 26 | ||
| 143 | 140, // Generic 27 | ||
| 144 | 144, // Generic 28 | ||
| 145 | 148, // Generic 29 | ||
| 146 | 152, // Generic 30 | ||
| 147 | 156, // Generic 31 | ||
| 148 | 160, // gl_FrontColor | ||
| 149 | 164, // gl_FrontSecondaryColor | ||
| 150 | 160, // gl_BackColor | ||
| 151 | 164, // gl_BackSecondaryColor | ||
| 152 | 192, // gl_TexCoord[0] | ||
| 153 | 196, // gl_TexCoord[1] | ||
| 154 | 200, // gl_TexCoord[2] | ||
| 155 | 204, // gl_TexCoord[3] | ||
| 156 | 208, // gl_TexCoord[4] | ||
| 157 | 212, // gl_TexCoord[5] | ||
| 158 | 216, // gl_TexCoord[6] | ||
| 159 | 220, // gl_TexCoord[7] | ||
| 160 | }; | ||
| 161 | std::vector<Shader::TransformFeedbackVarying> xfb(256); | ||
| 162 | for (size_t buffer = 0; buffer < Maxwell::NumTransformFeedbackBuffers; ++buffer) { | ||
| 163 | const auto& locations = key.state.xfb_state.varyings[buffer]; | ||
| 164 | const auto& layout = key.state.xfb_state.layouts[buffer]; | ||
| 165 | const u32 varying_count = layout.varying_count; | ||
| 166 | u32 highest = 0; | ||
| 167 | for (u32 offset = 0; offset < varying_count; ++offset) { | ||
| 168 | const u32 base_offset = offset; | ||
| 169 | const u8 location = locations[offset]; | ||
| 170 | |||
| 171 | Shader::TransformFeedbackVarying varying; | ||
| 172 | varying.buffer = layout.stream; | ||
| 173 | varying.stride = layout.stride; | ||
| 174 | varying.offset = offset * 4; | ||
| 175 | varying.components = 1; | ||
| 176 | |||
| 177 | if (std::ranges::find(VECTORS, Common::AlignDown(location, 4)) != VECTORS.end()) { | ||
| 178 | UNIMPLEMENTED_IF_MSG(location % 4 != 0, "Unaligned TFB"); | ||
| 179 | |||
| 180 | const u8 base_index = location / 4; | ||
| 181 | while (offset + 1 < varying_count && base_index == locations[offset + 1] / 4) { | ||
| 182 | ++offset; | ||
| 183 | ++varying.components; | ||
| 184 | } | ||
| 185 | } | ||
| 186 | xfb[location] = varying; | ||
| 187 | highest = std::max(highest, (base_offset + varying.components) * 4); | ||
| 188 | } | ||
| 189 | UNIMPLEMENTED_IF(highest != layout.stride); | ||
| 190 | } | ||
| 191 | return xfb; | ||
| 192 | } | ||
| 193 | |||
| 194 | Shader::RuntimeInfo MakeRuntimeInfo(const GraphicsPipelineCacheKey& key, | ||
| 195 | const Shader::IR::Program& program) { | ||
| 196 | Shader::RuntimeInfo info; | ||
| 197 | |||
| 198 | const Shader::Stage stage{program.stage}; | ||
| 199 | const bool has_geometry{key.unique_hashes[4] != 0}; | ||
| 200 | const bool gl_ndc{key.state.ndc_minus_one_to_one != 0}; | ||
| 201 | const float point_size{Common::BitCast<float>(key.state.point_size)}; | ||
| 202 | switch (stage) { | ||
| 203 | case Shader::Stage::VertexB: | ||
| 204 | if (!has_geometry) { | ||
| 205 | if (key.state.topology == Maxwell::PrimitiveTopology::Points) { | ||
| 206 | info.fixed_state_point_size = point_size; | ||
| 207 | } | ||
| 208 | if (key.state.xfb_enabled != 0) { | ||
| 209 | info.xfb_varyings = MakeTransformFeedbackVaryings(key); | ||
| 210 | } | ||
| 211 | info.convert_depth_mode = gl_ndc; | ||
| 212 | } | ||
| 213 | std::ranges::transform(key.state.attributes, info.generic_input_types.begin(), | ||
| 214 | &CastAttributeType); | ||
| 215 | break; | ||
| 216 | case Shader::Stage::TessellationEval: | ||
| 217 | // We have to flip tessellation clockwise for some reason... | ||
| 218 | info.tess_clockwise = key.state.tessellation_clockwise == 0; | ||
| 219 | info.tess_primitive = [&key] { | ||
| 220 | const u32 raw{key.state.tessellation_primitive.Value()}; | ||
| 221 | switch (static_cast<Maxwell::TessellationPrimitive>(raw)) { | ||
| 222 | case Maxwell::TessellationPrimitive::Isolines: | ||
| 223 | return Shader::TessPrimitive::Isolines; | ||
| 224 | case Maxwell::TessellationPrimitive::Triangles: | ||
| 225 | return Shader::TessPrimitive::Triangles; | ||
| 226 | case Maxwell::TessellationPrimitive::Quads: | ||
| 227 | return Shader::TessPrimitive::Quads; | ||
| 228 | } | ||
| 229 | UNREACHABLE(); | ||
| 230 | return Shader::TessPrimitive::Triangles; | ||
| 231 | }(); | ||
| 232 | info.tess_spacing = [&] { | ||
| 233 | const u32 raw{key.state.tessellation_spacing}; | ||
| 234 | switch (static_cast<Maxwell::TessellationSpacing>(raw)) { | ||
| 235 | case Maxwell::TessellationSpacing::Equal: | ||
| 236 | return Shader::TessSpacing::Equal; | ||
| 237 | case Maxwell::TessellationSpacing::FractionalOdd: | ||
| 238 | return Shader::TessSpacing::FractionalOdd; | ||
| 239 | case Maxwell::TessellationSpacing::FractionalEven: | ||
| 240 | return Shader::TessSpacing::FractionalEven; | ||
| 241 | } | ||
| 242 | UNREACHABLE(); | ||
| 243 | return Shader::TessSpacing::Equal; | ||
| 244 | }(); | ||
| 245 | break; | ||
| 246 | case Shader::Stage::Geometry: | ||
| 247 | if (program.output_topology == Shader::OutputTopology::PointList) { | ||
| 248 | info.fixed_state_point_size = point_size; | ||
| 249 | } | ||
| 250 | if (key.state.xfb_enabled != 0) { | ||
| 251 | info.xfb_varyings = MakeTransformFeedbackVaryings(key); | ||
| 252 | } | ||
| 253 | info.convert_depth_mode = gl_ndc; | ||
| 254 | break; | ||
| 255 | case Shader::Stage::Fragment: | ||
| 256 | info.alpha_test_func = MaxwellToCompareFunction( | ||
| 257 | key.state.UnpackComparisonOp(key.state.alpha_test_func.Value())); | ||
| 258 | info.alpha_test_reference = Common::BitCast<float>(key.state.alpha_test_ref); | ||
| 259 | break; | ||
| 260 | default: | ||
| 261 | break; | ||
| 262 | } | ||
| 263 | switch (key.state.topology) { | ||
| 264 | case Maxwell::PrimitiveTopology::Points: | ||
| 265 | info.input_topology = Shader::InputTopology::Points; | ||
| 266 | break; | ||
| 267 | case Maxwell::PrimitiveTopology::Lines: | ||
| 268 | case Maxwell::PrimitiveTopology::LineLoop: | ||
| 269 | case Maxwell::PrimitiveTopology::LineStrip: | ||
| 270 | info.input_topology = Shader::InputTopology::Lines; | ||
| 271 | break; | ||
| 272 | case Maxwell::PrimitiveTopology::Triangles: | ||
| 273 | case Maxwell::PrimitiveTopology::TriangleStrip: | ||
| 274 | case Maxwell::PrimitiveTopology::TriangleFan: | ||
| 275 | case Maxwell::PrimitiveTopology::Quads: | ||
| 276 | case Maxwell::PrimitiveTopology::QuadStrip: | ||
| 277 | case Maxwell::PrimitiveTopology::Polygon: | ||
| 278 | case Maxwell::PrimitiveTopology::Patches: | ||
| 279 | info.input_topology = Shader::InputTopology::Triangles; | ||
| 280 | break; | ||
| 281 | case Maxwell::PrimitiveTopology::LinesAdjacency: | ||
| 282 | case Maxwell::PrimitiveTopology::LineStripAdjacency: | ||
| 283 | info.input_topology = Shader::InputTopology::LinesAdjacency; | ||
| 284 | break; | ||
| 285 | case Maxwell::PrimitiveTopology::TrianglesAdjacency: | ||
| 286 | case Maxwell::PrimitiveTopology::TriangleStripAdjacency: | ||
| 287 | info.input_topology = Shader::InputTopology::TrianglesAdjacency; | ||
| 288 | break; | ||
| 289 | } | ||
| 290 | info.force_early_z = key.state.early_z != 0; | ||
| 291 | info.y_negate = key.state.y_negate != 0; | ||
| 292 | return info; | ||
| 293 | } | ||
| 92 | } // Anonymous namespace | 294 | } // Anonymous namespace |
| 93 | 295 | ||
| 94 | size_t ComputePipelineCacheKey::Hash() const noexcept { | 296 | size_t ComputePipelineCacheKey::Hash() const noexcept { |
| @@ -124,7 +326,7 @@ PipelineCache::PipelineCache(RasterizerVulkan& rasterizer_, Tegra::Engines::Maxw | |||
| 124 | serialization_thread(1, "yuzu:PipelineSerialization") { | 326 | serialization_thread(1, "yuzu:PipelineSerialization") { |
| 125 | const auto& float_control{device.FloatControlProperties()}; | 327 | const auto& float_control{device.FloatControlProperties()}; |
| 126 | const VkDriverIdKHR driver_id{device.GetDriverID()}; | 328 | const VkDriverIdKHR driver_id{device.GetDriverID()}; |
| 127 | base_profile = Shader::Profile{ | 329 | profile = Shader::Profile{ |
| 128 | .supported_spirv = device.IsKhrSpirv1_4Supported() ? 0x00010400U : 0x00010000U, | 330 | .supported_spirv = device.IsKhrSpirv1_4Supported() ? 0x00010400U : 0x00010000U, |
| 129 | .unified_descriptor_binding = true, | 331 | .unified_descriptor_binding = true, |
| 130 | .support_descriptor_aliasing = true, | 332 | .support_descriptor_aliasing = true, |
| @@ -153,14 +355,10 @@ PipelineCache::PipelineCache(RasterizerVulkan& rasterizer_, Tegra::Engines::Maxw | |||
| 153 | .support_viewport_mask = device.IsNvViewportArray2Supported(), | 355 | .support_viewport_mask = device.IsNvViewportArray2Supported(), |
| 154 | .support_typeless_image_loads = device.IsFormatlessImageLoadSupported(), | 356 | .support_typeless_image_loads = device.IsFormatlessImageLoadSupported(), |
| 155 | .support_demote_to_helper_invocation = true, | 357 | .support_demote_to_helper_invocation = true, |
| 156 | .warp_size_potentially_larger_than_guest = device.IsWarpSizePotentiallyBiggerThanGuest(), | ||
| 157 | .support_int64_atomics = device.IsExtShaderAtomicInt64Supported(), | 358 | .support_int64_atomics = device.IsExtShaderAtomicInt64Supported(), |
| 359 | .warp_size_potentially_larger_than_guest = device.IsWarpSizePotentiallyBiggerThanGuest(), | ||
| 158 | .has_broken_spirv_clamp = driver_id == VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS_KHR, | 360 | .has_broken_spirv_clamp = driver_id == VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS_KHR, |
| 159 | .has_broken_unsigned_image_offsets = false, | 361 | .has_broken_unsigned_image_offsets = false, |
| 160 | .generic_input_types{}, | ||
| 161 | .fixed_state_point_size{}, | ||
| 162 | .alpha_test_func{}, | ||
| 163 | .xfb_varyings{}, | ||
| 164 | }; | 362 | }; |
| 165 | } | 363 | } |
| 166 | 364 | ||
| @@ -329,8 +527,8 @@ std::unique_ptr<GraphicsPipeline> PipelineCache::CreateGraphicsPipeline( | |||
| 329 | const size_t stage_index{index - 1}; | 527 | const size_t stage_index{index - 1}; |
| 330 | infos[stage_index] = &program.info; | 528 | infos[stage_index] = &program.info; |
| 331 | 529 | ||
| 332 | const Shader::Profile profile{MakeProfile(key, program)}; | 530 | const Shader::RuntimeInfo runtime_info{MakeRuntimeInfo(key, program)}; |
| 333 | const std::vector<u32> code{EmitSPIRV(profile, program, binding)}; | 531 | const std::vector<u32> code{EmitSPIRV(profile, runtime_info, program, binding)}; |
| 334 | device.SaveShader(code); | 532 | device.SaveShader(code); |
| 335 | modules[stage_index] = BuildShader(device, code); | 533 | modules[stage_index] = BuildShader(device, code); |
| 336 | if (device.HasDebuggingToolAttached()) { | 534 | if (device.HasDebuggingToolAttached()) { |
| @@ -391,7 +589,7 @@ std::unique_ptr<ComputePipeline> PipelineCache::CreateComputePipeline( | |||
| 391 | 589 | ||
| 392 | Shader::Maxwell::Flow::CFG cfg{env, pools.flow_block, env.StartAddress()}; | 590 | Shader::Maxwell::Flow::CFG cfg{env, pools.flow_block, env.StartAddress()}; |
| 393 | Shader::IR::Program program{TranslateProgram(pools.inst, pools.block, env, cfg)}; | 591 | Shader::IR::Program program{TranslateProgram(pools.inst, pools.block, env, cfg)}; |
| 394 | const std::vector<u32> code{EmitSPIRV(base_profile, program)}; | 592 | const std::vector<u32> code{EmitSPIRV(profile, program)}; |
| 395 | device.SaveShader(code); | 593 | device.SaveShader(code); |
| 396 | vk::ShaderModule spv_module{BuildShader(device, code)}; | 594 | vk::ShaderModule spv_module{BuildShader(device, code)}; |
| 397 | if (device.HasDebuggingToolAttached()) { | 595 | if (device.HasDebuggingToolAttached()) { |
| @@ -403,206 +601,4 @@ std::unique_ptr<ComputePipeline> PipelineCache::CreateComputePipeline( | |||
| 403 | thread_worker, program.info, std::move(spv_module)); | 601 | thread_worker, program.info, std::move(spv_module)); |
| 404 | } | 602 | } |
| 405 | 603 | ||
| 406 | static Shader::AttributeType CastAttributeType(const FixedPipelineState::VertexAttribute& attr) { | ||
| 407 | if (attr.enabled == 0) { | ||
| 408 | return Shader::AttributeType::Disabled; | ||
| 409 | } | ||
| 410 | switch (attr.Type()) { | ||
| 411 | case Maxwell::VertexAttribute::Type::SignedNorm: | ||
| 412 | case Maxwell::VertexAttribute::Type::UnsignedNorm: | ||
| 413 | case Maxwell::VertexAttribute::Type::UnsignedScaled: | ||
| 414 | case Maxwell::VertexAttribute::Type::SignedScaled: | ||
| 415 | case Maxwell::VertexAttribute::Type::Float: | ||
| 416 | return Shader::AttributeType::Float; | ||
| 417 | case Maxwell::VertexAttribute::Type::SignedInt: | ||
| 418 | return Shader::AttributeType::SignedInt; | ||
| 419 | case Maxwell::VertexAttribute::Type::UnsignedInt: | ||
| 420 | return Shader::AttributeType::UnsignedInt; | ||
| 421 | } | ||
| 422 | return Shader::AttributeType::Float; | ||
| 423 | } | ||
| 424 | |||
| 425 | static std::vector<Shader::TransformFeedbackVarying> MakeTransformFeedbackVaryings( | ||
| 426 | const GraphicsPipelineCacheKey& key) { | ||
| 427 | static constexpr std::array VECTORS{ | ||
| 428 | 28, // gl_Position | ||
| 429 | 32, // Generic 0 | ||
| 430 | 36, // Generic 1 | ||
| 431 | 40, // Generic 2 | ||
| 432 | 44, // Generic 3 | ||
| 433 | 48, // Generic 4 | ||
| 434 | 52, // Generic 5 | ||
| 435 | 56, // Generic 6 | ||
| 436 | 60, // Generic 7 | ||
| 437 | 64, // Generic 8 | ||
| 438 | 68, // Generic 9 | ||
| 439 | 72, // Generic 10 | ||
| 440 | 76, // Generic 11 | ||
| 441 | 80, // Generic 12 | ||
| 442 | 84, // Generic 13 | ||
| 443 | 88, // Generic 14 | ||
| 444 | 92, // Generic 15 | ||
| 445 | 96, // Generic 16 | ||
| 446 | 100, // Generic 17 | ||
| 447 | 104, // Generic 18 | ||
| 448 | 108, // Generic 19 | ||
| 449 | 112, // Generic 20 | ||
| 450 | 116, // Generic 21 | ||
| 451 | 120, // Generic 22 | ||
| 452 | 124, // Generic 23 | ||
| 453 | 128, // Generic 24 | ||
| 454 | 132, // Generic 25 | ||
| 455 | 136, // Generic 26 | ||
| 456 | 140, // Generic 27 | ||
| 457 | 144, // Generic 28 | ||
| 458 | 148, // Generic 29 | ||
| 459 | 152, // Generic 30 | ||
| 460 | 156, // Generic 31 | ||
| 461 | 160, // gl_FrontColor | ||
| 462 | 164, // gl_FrontSecondaryColor | ||
| 463 | 160, // gl_BackColor | ||
| 464 | 164, // gl_BackSecondaryColor | ||
| 465 | 192, // gl_TexCoord[0] | ||
| 466 | 196, // gl_TexCoord[1] | ||
| 467 | 200, // gl_TexCoord[2] | ||
| 468 | 204, // gl_TexCoord[3] | ||
| 469 | 208, // gl_TexCoord[4] | ||
| 470 | 212, // gl_TexCoord[5] | ||
| 471 | 216, // gl_TexCoord[6] | ||
| 472 | 220, // gl_TexCoord[7] | ||
| 473 | }; | ||
| 474 | std::vector<Shader::TransformFeedbackVarying> xfb(256); | ||
| 475 | for (size_t buffer = 0; buffer < Maxwell::NumTransformFeedbackBuffers; ++buffer) { | ||
| 476 | const auto& locations = key.state.xfb_state.varyings[buffer]; | ||
| 477 | const auto& layout = key.state.xfb_state.layouts[buffer]; | ||
| 478 | const u32 varying_count = layout.varying_count; | ||
| 479 | u32 highest = 0; | ||
| 480 | for (u32 offset = 0; offset < varying_count; ++offset) { | ||
| 481 | const u32 base_offset = offset; | ||
| 482 | const u8 location = locations[offset]; | ||
| 483 | |||
| 484 | Shader::TransformFeedbackVarying varying; | ||
| 485 | varying.buffer = layout.stream; | ||
| 486 | varying.stride = layout.stride; | ||
| 487 | varying.offset = offset * 4; | ||
| 488 | varying.components = 1; | ||
| 489 | |||
| 490 | if (std::ranges::find(VECTORS, Common::AlignDown(location, 4)) != VECTORS.end()) { | ||
| 491 | UNIMPLEMENTED_IF_MSG(location % 4 != 0, "Unaligned TFB"); | ||
| 492 | |||
| 493 | const u8 base_index = location / 4; | ||
| 494 | while (offset + 1 < varying_count && base_index == locations[offset + 1] / 4) { | ||
| 495 | ++offset; | ||
| 496 | ++varying.components; | ||
| 497 | } | ||
| 498 | } | ||
| 499 | xfb[location] = varying; | ||
| 500 | highest = std::max(highest, (base_offset + varying.components) * 4); | ||
| 501 | } | ||
| 502 | UNIMPLEMENTED_IF(highest != layout.stride); | ||
| 503 | } | ||
| 504 | return xfb; | ||
| 505 | } | ||
| 506 | |||
| 507 | Shader::Profile PipelineCache::MakeProfile(const GraphicsPipelineCacheKey& key, | ||
| 508 | const Shader::IR::Program& program) { | ||
| 509 | Shader::Profile profile{base_profile}; | ||
| 510 | |||
| 511 | const Shader::Stage stage{program.stage}; | ||
| 512 | const bool has_geometry{key.unique_hashes[4] != 0}; | ||
| 513 | const bool gl_ndc{key.state.ndc_minus_one_to_one != 0}; | ||
| 514 | const float point_size{Common::BitCast<float>(key.state.point_size)}; | ||
| 515 | switch (stage) { | ||
| 516 | case Shader::Stage::VertexB: | ||
| 517 | if (!has_geometry) { | ||
| 518 | if (key.state.topology == Maxwell::PrimitiveTopology::Points) { | ||
| 519 | profile.fixed_state_point_size = point_size; | ||
| 520 | } | ||
| 521 | if (key.state.xfb_enabled != 0) { | ||
| 522 | profile.xfb_varyings = MakeTransformFeedbackVaryings(key); | ||
| 523 | } | ||
| 524 | profile.convert_depth_mode = gl_ndc; | ||
| 525 | } | ||
| 526 | std::ranges::transform(key.state.attributes, profile.generic_input_types.begin(), | ||
| 527 | &CastAttributeType); | ||
| 528 | break; | ||
| 529 | case Shader::Stage::TessellationEval: | ||
| 530 | // We have to flip tessellation clockwise for some reason... | ||
| 531 | profile.tess_clockwise = key.state.tessellation_clockwise == 0; | ||
| 532 | profile.tess_primitive = [&key] { | ||
| 533 | const u32 raw{key.state.tessellation_primitive.Value()}; | ||
| 534 | switch (static_cast<Maxwell::TessellationPrimitive>(raw)) { | ||
| 535 | case Maxwell::TessellationPrimitive::Isolines: | ||
| 536 | return Shader::TessPrimitive::Isolines; | ||
| 537 | case Maxwell::TessellationPrimitive::Triangles: | ||
| 538 | return Shader::TessPrimitive::Triangles; | ||
| 539 | case Maxwell::TessellationPrimitive::Quads: | ||
| 540 | return Shader::TessPrimitive::Quads; | ||
| 541 | } | ||
| 542 | UNREACHABLE(); | ||
| 543 | return Shader::TessPrimitive::Triangles; | ||
| 544 | }(); | ||
| 545 | profile.tess_spacing = [&] { | ||
| 546 | const u32 raw{key.state.tessellation_spacing}; | ||
| 547 | switch (static_cast<Maxwell::TessellationSpacing>(raw)) { | ||
| 548 | case Maxwell::TessellationSpacing::Equal: | ||
| 549 | return Shader::TessSpacing::Equal; | ||
| 550 | case Maxwell::TessellationSpacing::FractionalOdd: | ||
| 551 | return Shader::TessSpacing::FractionalOdd; | ||
| 552 | case Maxwell::TessellationSpacing::FractionalEven: | ||
| 553 | return Shader::TessSpacing::FractionalEven; | ||
| 554 | } | ||
| 555 | UNREACHABLE(); | ||
| 556 | return Shader::TessSpacing::Equal; | ||
| 557 | }(); | ||
| 558 | break; | ||
| 559 | case Shader::Stage::Geometry: | ||
| 560 | if (program.output_topology == Shader::OutputTopology::PointList) { | ||
| 561 | profile.fixed_state_point_size = point_size; | ||
| 562 | } | ||
| 563 | if (key.state.xfb_enabled != 0) { | ||
| 564 | profile.xfb_varyings = MakeTransformFeedbackVaryings(key); | ||
| 565 | } | ||
| 566 | profile.convert_depth_mode = gl_ndc; | ||
| 567 | break; | ||
| 568 | case Shader::Stage::Fragment: | ||
| 569 | profile.alpha_test_func = MaxwellToCompareFunction( | ||
| 570 | key.state.UnpackComparisonOp(key.state.alpha_test_func.Value())); | ||
| 571 | profile.alpha_test_reference = Common::BitCast<float>(key.state.alpha_test_ref); | ||
| 572 | break; | ||
| 573 | default: | ||
| 574 | break; | ||
| 575 | } | ||
| 576 | switch (key.state.topology) { | ||
| 577 | case Maxwell::PrimitiveTopology::Points: | ||
| 578 | profile.input_topology = Shader::InputTopology::Points; | ||
| 579 | break; | ||
| 580 | case Maxwell::PrimitiveTopology::Lines: | ||
| 581 | case Maxwell::PrimitiveTopology::LineLoop: | ||
| 582 | case Maxwell::PrimitiveTopology::LineStrip: | ||
| 583 | profile.input_topology = Shader::InputTopology::Lines; | ||
| 584 | break; | ||
| 585 | case Maxwell::PrimitiveTopology::Triangles: | ||
| 586 | case Maxwell::PrimitiveTopology::TriangleStrip: | ||
| 587 | case Maxwell::PrimitiveTopology::TriangleFan: | ||
| 588 | case Maxwell::PrimitiveTopology::Quads: | ||
| 589 | case Maxwell::PrimitiveTopology::QuadStrip: | ||
| 590 | case Maxwell::PrimitiveTopology::Polygon: | ||
| 591 | case Maxwell::PrimitiveTopology::Patches: | ||
| 592 | profile.input_topology = Shader::InputTopology::Triangles; | ||
| 593 | break; | ||
| 594 | case Maxwell::PrimitiveTopology::LinesAdjacency: | ||
| 595 | case Maxwell::PrimitiveTopology::LineStripAdjacency: | ||
| 596 | profile.input_topology = Shader::InputTopology::LinesAdjacency; | ||
| 597 | break; | ||
| 598 | case Maxwell::PrimitiveTopology::TrianglesAdjacency: | ||
| 599 | case Maxwell::PrimitiveTopology::TriangleStripAdjacency: | ||
| 600 | profile.input_topology = Shader::InputTopology::TrianglesAdjacency; | ||
| 601 | break; | ||
| 602 | } | ||
| 603 | profile.force_early_z = key.state.early_z != 0; | ||
| 604 | profile.y_negate = key.state.y_negate != 0; | ||
| 605 | return profile; | ||
| 606 | } | ||
| 607 | |||
| 608 | } // namespace Vulkan | 604 | } // 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 4e48b4956..4116cc73f 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.h +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.h | |||
| @@ -129,9 +129,6 @@ private: | |||
| 129 | Shader::Environment& env, | 129 | Shader::Environment& env, |
| 130 | bool build_in_parallel); | 130 | bool build_in_parallel); |
| 131 | 131 | ||
| 132 | Shader::Profile MakeProfile(const GraphicsPipelineCacheKey& key, | ||
| 133 | const Shader::IR::Program& program); | ||
| 134 | |||
| 135 | const Device& device; | 132 | const Device& device; |
| 136 | VKScheduler& scheduler; | 133 | VKScheduler& scheduler; |
| 137 | DescriptorPool& descriptor_pool; | 134 | DescriptorPool& descriptor_pool; |
| @@ -148,7 +145,7 @@ private: | |||
| 148 | 145 | ||
| 149 | ShaderPools main_pools; | 146 | ShaderPools main_pools; |
| 150 | 147 | ||
| 151 | Shader::Profile base_profile; | 148 | Shader::Profile profile; |
| 152 | std::filesystem::path pipeline_cache_filename; | 149 | std::filesystem::path pipeline_cache_filename; |
| 153 | 150 | ||
| 154 | Common::ThreadWorker workers; | 151 | Common::ThreadWorker workers; |