summaryrefslogtreecommitdiff
path: root/src/video_core/shader
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2020-03-15 21:00:51 -0300
committerGravatar ReinUsesLisp2020-03-15 21:01:52 -0300
commit6442e02c5daf09b1087dffb26780c03ed5d2ffd5 (patch)
treecc12cb12ceca490957cdf05090224ac349744799 /src/video_core/shader
parentshader/shader_ir: Fix clip distance usage stores (diff)
downloadyuzu-6442e02c5daf09b1087dffb26780c03ed5d2ffd5.tar.gz
yuzu-6442e02c5daf09b1087dffb26780c03ed5d2ffd5.tar.xz
yuzu-6442e02c5daf09b1087dffb26780c03ed5d2ffd5.zip
shader/shader_ir: Track usage in input attribute and of legacy varyings
Diffstat (limited to 'src/video_core/shader')
-rw-r--r--src/video_core/shader/shader_ir.cpp84
-rw-r--r--src/video_core/shader/shader_ir.h8
2 files changed, 58 insertions, 34 deletions
diff --git a/src/video_core/shader/shader_ir.cpp b/src/video_core/shader/shader_ir.cpp
index 32bb28452..baf7188d2 100644
--- a/src/video_core/shader/shader_ir.cpp
+++ b/src/video_core/shader/shader_ir.cpp
@@ -96,6 +96,7 @@ Node ShaderIR::GetPredicate(bool immediate) {
96} 96}
97 97
98Node ShaderIR::GetInputAttribute(Attribute::Index index, u64 element, Node buffer) { 98Node ShaderIR::GetInputAttribute(Attribute::Index index, u64 element, Node buffer) {
99 MarkAttributeUsage(index, element);
99 used_input_attributes.emplace(index); 100 used_input_attributes.emplace(index);
100 return MakeNode<AbufNode>(index, static_cast<u32>(element), std::move(buffer)); 101 return MakeNode<AbufNode>(index, static_cast<u32>(element), std::move(buffer));
101} 102}
@@ -106,40 +107,7 @@ Node ShaderIR::GetPhysicalInputAttribute(Tegra::Shader::Register physical_addres
106} 107}
107 108
108Node ShaderIR::GetOutputAttribute(Attribute::Index index, u64 element, Node buffer) { 109Node ShaderIR::GetOutputAttribute(Attribute::Index index, u64 element, Node buffer) {
109 switch (index) { 110 MarkAttributeUsage(index, element);
110 case Attribute::Index::LayerViewportPointSize:
111 switch (element) {
112 case 0:
113 UNIMPLEMENTED();
114 break;
115 case 1:
116 uses_layer = true;
117 break;
118 case 2:
119 uses_viewport_index = true;
120 break;
121 case 3:
122 uses_point_size = true;
123 break;
124 }
125 break;
126 case Attribute::Index::TessCoordInstanceIDVertexID:
127 switch (element) {
128 case 2:
129 uses_instance_id = true;
130 break;
131 case 3:
132 uses_vertex_id = true;
133 break;
134 }
135 break;
136 case Attribute::Index::ClipDistances0123:
137 case Attribute::Index::ClipDistances4567: {
138 const u64 clip_index = (index == Attribute::Index::ClipDistances4567 ? 4 : 0) + element;
139 used_clip_distances.at(clip_index) = true;
140 break;
141 }
142 }
143 used_output_attributes.insert(index); 111 used_output_attributes.insert(index);
144 return MakeNode<AbufNode>(index, static_cast<u32>(element), std::move(buffer)); 112 return MakeNode<AbufNode>(index, static_cast<u32>(element), std::move(buffer));
145} 113}
@@ -451,6 +419,54 @@ Node ShaderIR::BitfieldInsert(Node base, Node insert, u32 offset, u32 bits) {
451 Immediate(bits)); 419 Immediate(bits));
452} 420}
453 421
422void ShaderIR::MarkAttributeUsage(Attribute::Index index, u64 element) {
423 switch (index) {
424 case Attribute::Index::LayerViewportPointSize:
425 switch (element) {
426 case 0:
427 UNIMPLEMENTED();
428 break;
429 case 1:
430 uses_layer = true;
431 break;
432 case 2:
433 uses_viewport_index = true;
434 break;
435 case 3:
436 uses_point_size = true;
437 break;
438 }
439 break;
440 case Attribute::Index::TessCoordInstanceIDVertexID:
441 switch (element) {
442 case 2:
443 uses_instance_id = true;
444 break;
445 case 3:
446 uses_vertex_id = true;
447 break;
448 }
449 break;
450 case Attribute::Index::ClipDistances0123:
451 case Attribute::Index::ClipDistances4567: {
452 const u64 clip_index = (index == Attribute::Index::ClipDistances4567 ? 4 : 0) + element;
453 used_clip_distances.at(clip_index) = true;
454 break;
455 }
456 case Attribute::Index::FrontColor:
457 case Attribute::Index::FrontSecondaryColor:
458 case Attribute::Index::BackColor:
459 case Attribute::Index::BackSecondaryColor:
460 uses_legacy_varyings = true;
461 break;
462 default:
463 if (index >= Attribute::Index::TexCoord_0 && index <= Attribute::Index::TexCoord_7) {
464 uses_legacy_varyings = true;
465 }
466 break;
467 }
468}
469
454std::size_t ShaderIR::DeclareAmend(Node new_amend) { 470std::size_t ShaderIR::DeclareAmend(Node new_amend) {
455 const std::size_t id = amend_code.size(); 471 const std::size_t id = amend_code.size();
456 amend_code.push_back(new_amend); 472 amend_code.push_back(new_amend);
diff --git a/src/video_core/shader/shader_ir.h b/src/video_core/shader/shader_ir.h
index dde036b40..80fc9b82c 100644
--- a/src/video_core/shader/shader_ir.h
+++ b/src/video_core/shader/shader_ir.h
@@ -137,6 +137,10 @@ public:
137 return uses_vertex_id; 137 return uses_vertex_id;
138 } 138 }
139 139
140 bool UsesLegacyVaryings() const {
141 return uses_legacy_varyings;
142 }
143
140 bool UsesWarps() const { 144 bool UsesWarps() const {
141 return uses_warps; 145 return uses_warps;
142 } 146 }
@@ -343,6 +347,9 @@ private:
343 /// Inserts a sequence of bits from a node 347 /// Inserts a sequence of bits from a node
344 Node BitfieldInsert(Node base, Node insert, u32 offset, u32 bits); 348 Node BitfieldInsert(Node base, Node insert, u32 offset, u32 bits);
345 349
350 /// Marks the usage of a input or output attribute.
351 void MarkAttributeUsage(Tegra::Shader::Attribute::Index index, u64 element);
352
346 void WriteTexInstructionFloat(NodeBlock& bb, Tegra::Shader::Instruction instr, 353 void WriteTexInstructionFloat(NodeBlock& bb, Tegra::Shader::Instruction instr,
347 const Node4& components); 354 const Node4& components);
348 355
@@ -443,6 +450,7 @@ private:
443 bool uses_physical_attributes{}; // Shader uses AL2P or physical attribute read/writes 450 bool uses_physical_attributes{}; // Shader uses AL2P or physical attribute read/writes
444 bool uses_instance_id{}; 451 bool uses_instance_id{};
445 bool uses_vertex_id{}; 452 bool uses_vertex_id{};
453 bool uses_legacy_varyings{};
446 bool uses_warps{}; 454 bool uses_warps{};
447 bool uses_indexed_samplers{}; 455 bool uses_indexed_samplers{};
448 456