diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_shader_decompiler.cpp | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp index 6d0bf6aa1..2da622d15 100644 --- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp +++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp | |||
| @@ -86,6 +86,7 @@ struct AttributeType { | |||
| 86 | 86 | ||
| 87 | struct VertexIndices { | 87 | struct VertexIndices { |
| 88 | std::optional<u32> position; | 88 | std::optional<u32> position; |
| 89 | std::optional<u32> layer; | ||
| 89 | std::optional<u32> viewport; | 90 | std::optional<u32> viewport; |
| 90 | std::optional<u32> point_size; | 91 | std::optional<u32> point_size; |
| 91 | std::optional<u32> clip_distances; | 92 | std::optional<u32> clip_distances; |
| @@ -284,9 +285,11 @@ public: | |||
| 284 | AddExtension("SPV_KHR_variable_pointers"); | 285 | AddExtension("SPV_KHR_variable_pointers"); |
| 285 | AddExtension("SPV_KHR_shader_draw_parameters"); | 286 | AddExtension("SPV_KHR_shader_draw_parameters"); |
| 286 | 287 | ||
| 287 | if (ir.UsesViewportIndex()) { | 288 | if (ir.UsesLayer() || ir.UsesViewportIndex()) { |
| 288 | AddCapability(spv::Capability::MultiViewport); | 289 | if (ir.UsesViewportIndex()) { |
| 289 | if (device.IsExtShaderViewportIndexLayerSupported()) { | 290 | AddCapability(spv::Capability::MultiViewport); |
| 291 | } | ||
| 292 | if (stage != ShaderType::Geometry && device.IsExtShaderViewportIndexLayerSupported()) { | ||
| 290 | AddExtension("SPV_EXT_shader_viewport_index_layer"); | 293 | AddExtension("SPV_EXT_shader_viewport_index_layer"); |
| 291 | AddCapability(spv::Capability::ShaderViewportIndexLayerEXT); | 294 | AddCapability(spv::Capability::ShaderViewportIndexLayerEXT); |
| 292 | } | 295 | } |
| @@ -928,13 +931,22 @@ private: | |||
| 928 | VertexIndices indices; | 931 | VertexIndices indices; |
| 929 | indices.position = AddBuiltIn(t_float4, spv::BuiltIn::Position, "position"); | 932 | indices.position = AddBuiltIn(t_float4, spv::BuiltIn::Position, "position"); |
| 930 | 933 | ||
| 934 | if (ir.UsesLayer()) { | ||
| 935 | if (stage != ShaderType::Vertex || device.IsExtShaderViewportIndexLayerSupported()) { | ||
| 936 | indices.layer = AddBuiltIn(t_int, spv::BuiltIn::Layer, "layer"); | ||
| 937 | } else { | ||
| 938 | LOG_ERROR( | ||
| 939 | Render_Vulkan, | ||
| 940 | "Shader requires Layer but it's not supported on this stage with this device."); | ||
| 941 | } | ||
| 942 | } | ||
| 943 | |||
| 931 | if (ir.UsesViewportIndex()) { | 944 | if (ir.UsesViewportIndex()) { |
| 932 | if (stage != ShaderType::Vertex || device.IsExtShaderViewportIndexLayerSupported()) { | 945 | if (stage != ShaderType::Vertex || device.IsExtShaderViewportIndexLayerSupported()) { |
| 933 | indices.viewport = AddBuiltIn(t_int, spv::BuiltIn::ViewportIndex, "viewport_index"); | 946 | indices.viewport = AddBuiltIn(t_int, spv::BuiltIn::ViewportIndex, "viewport_index"); |
| 934 | } else { | 947 | } else { |
| 935 | LOG_ERROR(Render_Vulkan, | 948 | LOG_ERROR(Render_Vulkan, "Shader requires ViewportIndex but it's not supported on " |
| 936 | "Shader requires ViewportIndex but it's not supported on this " | 949 | "this stage with this device."); |
| 937 | "stage with this device."); | ||
| 938 | } | 950 | } |
| 939 | } | 951 | } |
| 940 | 952 | ||
| @@ -1296,6 +1308,13 @@ private: | |||
| 1296 | } | 1308 | } |
| 1297 | case Attribute::Index::LayerViewportPointSize: | 1309 | case Attribute::Index::LayerViewportPointSize: |
| 1298 | switch (element) { | 1310 | switch (element) { |
| 1311 | case 1: { | ||
| 1312 | if (!out_indices.layer) { | ||
| 1313 | return {}; | ||
| 1314 | } | ||
| 1315 | const u32 index = out_indices.layer.value(); | ||
| 1316 | return {AccessElement(t_out_int, out_vertex, index), Type::Int}; | ||
| 1317 | } | ||
| 1299 | case 2: { | 1318 | case 2: { |
| 1300 | if (!out_indices.viewport) { | 1319 | if (!out_indices.viewport) { |
| 1301 | return {}; | 1320 | return {}; |
| @@ -1366,6 +1385,11 @@ private: | |||
| 1366 | UNIMPLEMENTED(); | 1385 | UNIMPLEMENTED(); |
| 1367 | } | 1386 | } |
| 1368 | 1387 | ||
| 1388 | if (!target.id) { | ||
| 1389 | // On failure we return a nullptr target.id, skip these stores. | ||
| 1390 | return {}; | ||
| 1391 | } | ||
| 1392 | |||
| 1369 | OpStore(target.id, As(Visit(src), target.type)); | 1393 | OpStore(target.id, As(Visit(src), target.type)); |
| 1370 | return {}; | 1394 | return {}; |
| 1371 | } | 1395 | } |