diff options
| -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 24a658dce..99dbc473d 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; |
| @@ -282,9 +283,11 @@ public: | |||
| 282 | AddExtension("SPV_KHR_storage_buffer_storage_class"); | 283 | AddExtension("SPV_KHR_storage_buffer_storage_class"); |
| 283 | AddExtension("SPV_KHR_variable_pointers"); | 284 | AddExtension("SPV_KHR_variable_pointers"); |
| 284 | 285 | ||
| 285 | if (ir.UsesViewportIndex()) { | 286 | if (ir.UsesLayer() || ir.UsesViewportIndex()) { |
| 286 | AddCapability(spv::Capability::MultiViewport); | 287 | if (ir.UsesViewportIndex()) { |
| 287 | if (device.IsExtShaderViewportIndexLayerSupported()) { | 288 | AddCapability(spv::Capability::MultiViewport); |
| 289 | } | ||
| 290 | if (stage != ShaderType::Geometry && device.IsExtShaderViewportIndexLayerSupported()) { | ||
| 288 | AddExtension("SPV_EXT_shader_viewport_index_layer"); | 291 | AddExtension("SPV_EXT_shader_viewport_index_layer"); |
| 289 | AddCapability(spv::Capability::ShaderViewportIndexLayerEXT); | 292 | AddCapability(spv::Capability::ShaderViewportIndexLayerEXT); |
| 290 | } | 293 | } |
| @@ -920,13 +923,22 @@ private: | |||
| 920 | VertexIndices indices; | 923 | VertexIndices indices; |
| 921 | indices.position = AddBuiltIn(t_float4, spv::BuiltIn::Position, "position"); | 924 | indices.position = AddBuiltIn(t_float4, spv::BuiltIn::Position, "position"); |
| 922 | 925 | ||
| 926 | if (ir.UsesLayer()) { | ||
| 927 | if (stage != ShaderType::Vertex || device.IsExtShaderViewportIndexLayerSupported()) { | ||
| 928 | indices.layer = AddBuiltIn(t_int, spv::BuiltIn::Layer, "layer"); | ||
| 929 | } else { | ||
| 930 | LOG_ERROR( | ||
| 931 | Render_Vulkan, | ||
| 932 | "Shader requires Layer but it's not supported on this stage with this device."); | ||
| 933 | } | ||
| 934 | } | ||
| 935 | |||
| 923 | if (ir.UsesViewportIndex()) { | 936 | if (ir.UsesViewportIndex()) { |
| 924 | if (stage != ShaderType::Vertex || device.IsExtShaderViewportIndexLayerSupported()) { | 937 | if (stage != ShaderType::Vertex || device.IsExtShaderViewportIndexLayerSupported()) { |
| 925 | indices.viewport = AddBuiltIn(t_int, spv::BuiltIn::ViewportIndex, "viewport_index"); | 938 | indices.viewport = AddBuiltIn(t_int, spv::BuiltIn::ViewportIndex, "viewport_index"); |
| 926 | } else { | 939 | } else { |
| 927 | LOG_ERROR(Render_Vulkan, | 940 | LOG_ERROR(Render_Vulkan, "Shader requires ViewportIndex but it's not supported on " |
| 928 | "Shader requires ViewportIndex but it's not supported on this " | 941 | "this stage with this device."); |
| 929 | "stage with this device."); | ||
| 930 | } | 942 | } |
| 931 | } | 943 | } |
| 932 | 944 | ||
| @@ -1285,6 +1297,13 @@ private: | |||
| 1285 | } | 1297 | } |
| 1286 | case Attribute::Index::LayerViewportPointSize: | 1298 | case Attribute::Index::LayerViewportPointSize: |
| 1287 | switch (element) { | 1299 | switch (element) { |
| 1300 | case 1: { | ||
| 1301 | if (!out_indices.layer) { | ||
| 1302 | return {}; | ||
| 1303 | } | ||
| 1304 | const u32 index = out_indices.layer.value(); | ||
| 1305 | return {AccessElement(t_out_int, out_vertex, index), Type::Int}; | ||
| 1306 | } | ||
| 1288 | case 2: { | 1307 | case 2: { |
| 1289 | if (!out_indices.viewport) { | 1308 | if (!out_indices.viewport) { |
| 1290 | return {}; | 1309 | return {}; |
| @@ -1355,6 +1374,11 @@ private: | |||
| 1355 | UNIMPLEMENTED(); | 1374 | UNIMPLEMENTED(); |
| 1356 | } | 1375 | } |
| 1357 | 1376 | ||
| 1377 | if (!target.id) { | ||
| 1378 | // On failure we return a nullptr target.id, skip these stores. | ||
| 1379 | return {}; | ||
| 1380 | } | ||
| 1381 | |||
| 1358 | OpStore(target.id, As(Visit(src), target.type)); | 1382 | OpStore(target.id, As(Visit(src), target.type)); |
| 1359 | return {}; | 1383 | return {}; |
| 1360 | } | 1384 | } |