diff options
| author | 2019-07-07 20:36:42 -0300 | |
|---|---|---|
| committer | 2019-07-07 20:42:55 -0300 | |
| commit | c9d886c84e4102f7b9c464c704eecb61d37b3df4 (patch) | |
| tree | c26dadd5ead8fb3d9b8241cc8b9d6f97dd9d98f4 /src/video_core/renderer_vulkan | |
| parent | Merge pull request #2694 from FearlessTobi/patch-1 (diff) | |
| download | yuzu-c9d886c84e4102f7b9c464c704eecb61d37b3df4.tar.gz yuzu-c9d886c84e4102f7b9c464c704eecb61d37b3df4.tar.xz yuzu-c9d886c84e4102f7b9c464c704eecb61d37b3df4.zip | |
gl_shader_decompiler: Implement gl_ViewportIndex and gl_Layer in vertex shaders
This commit implements gl_ViewportIndex and gl_Layer in vertex and
geometry shaders. In the case it's used in a vertex shader, it requires
ARB_shader_viewport_layer_array. This extension is available on AMD and
Nvidia devices (mesa and proprietary drivers), but not available on
Intel on any platform. At the moment of writing this description I don't
know if this is a hardware limitation or a driver limitation.
In the case that ARB_shader_viewport_layer_array is not available,
writes to these registers on a vertex shader are ignored, with the
appropriate logging.
Diffstat (limited to 'src/video_core/renderer_vulkan')
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_shader_decompiler.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp index 97ce214b1..6071c6d99 100644 --- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp +++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp | |||
| @@ -430,20 +430,17 @@ private: | |||
| 430 | instance_index = DeclareBuiltIn(spv::BuiltIn::InstanceIndex, spv::StorageClass::Input, | 430 | instance_index = DeclareBuiltIn(spv::BuiltIn::InstanceIndex, spv::StorageClass::Input, |
| 431 | t_in_uint, "instance_index"); | 431 | t_in_uint, "instance_index"); |
| 432 | 432 | ||
| 433 | bool is_point_size_declared = false; | ||
| 434 | bool is_clip_distances_declared = false; | 433 | bool is_clip_distances_declared = false; |
| 435 | for (const auto index : ir.GetOutputAttributes()) { | 434 | for (const auto index : ir.GetOutputAttributes()) { |
| 436 | if (index == Attribute::Index::PointSize) { | 435 | if (index == Attribute::Index::ClipDistances0123 || |
| 437 | is_point_size_declared = true; | 436 | index == Attribute::Index::ClipDistances4567) { |
| 438 | } else if (index == Attribute::Index::ClipDistances0123 || | ||
| 439 | index == Attribute::Index::ClipDistances4567) { | ||
| 440 | is_clip_distances_declared = true; | 437 | is_clip_distances_declared = true; |
| 441 | } | 438 | } |
| 442 | } | 439 | } |
| 443 | 440 | ||
| 444 | std::vector<Id> members; | 441 | std::vector<Id> members; |
| 445 | members.push_back(t_float4); | 442 | members.push_back(t_float4); |
| 446 | if (is_point_size_declared) { | 443 | if (ir.UsesPointSize()) { |
| 447 | members.push_back(t_float); | 444 | members.push_back(t_float); |
| 448 | } | 445 | } |
| 449 | if (is_clip_distances_declared) { | 446 | if (is_clip_distances_declared) { |
| @@ -466,7 +463,7 @@ private: | |||
| 466 | 463 | ||
| 467 | position_index = MemberDecorateBuiltIn(spv::BuiltIn::Position, "position", true); | 464 | position_index = MemberDecorateBuiltIn(spv::BuiltIn::Position, "position", true); |
| 468 | point_size_index = | 465 | point_size_index = |
| 469 | MemberDecorateBuiltIn(spv::BuiltIn::PointSize, "point_size", is_point_size_declared); | 466 | MemberDecorateBuiltIn(spv::BuiltIn::PointSize, "point_size", ir.UsesPointSize()); |
| 470 | clip_distances_index = MemberDecorateBuiltIn(spv::BuiltIn::ClipDistance, "clip_distances", | 467 | clip_distances_index = MemberDecorateBuiltIn(spv::BuiltIn::ClipDistance, "clip_distances", |
| 471 | is_clip_distances_declared); | 468 | is_clip_distances_declared); |
| 472 | 469 | ||
| @@ -712,7 +709,8 @@ private: | |||
| 712 | case Attribute::Index::Position: | 709 | case Attribute::Index::Position: |
| 713 | return AccessElement(t_out_float, per_vertex, position_index, | 710 | return AccessElement(t_out_float, per_vertex, position_index, |
| 714 | abuf->GetElement()); | 711 | abuf->GetElement()); |
| 715 | case Attribute::Index::PointSize: | 712 | case Attribute::Index::LayerViewportPointSize: |
| 713 | UNIMPLEMENTED_IF(abuf->GetElement() != 3); | ||
| 716 | return AccessElement(t_out_float, per_vertex, point_size_index); | 714 | return AccessElement(t_out_float, per_vertex, point_size_index); |
| 717 | case Attribute::Index::ClipDistances0123: | 715 | case Attribute::Index::ClipDistances0123: |
| 718 | return AccessElement(t_out_float, per_vertex, clip_distances_index, | 716 | return AccessElement(t_out_float, per_vertex, clip_distances_index, |