summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/ir_opt
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2021-04-15 22:46:11 -0300
committerGravatar ameerj2021-07-22 21:51:27 -0400
commit183855e396cc6918d36fbf3e38ea426e934b4e3e (patch)
treea665794753520c09a1d34d8a086352894ec1cb72 /src/shader_recompiler/ir_opt
parentshader: Mark atomic instructions as writes (diff)
downloadyuzu-183855e396cc6918d36fbf3e38ea426e934b4e3e.tar.gz
yuzu-183855e396cc6918d36fbf3e38ea426e934b4e3e.tar.xz
yuzu-183855e396cc6918d36fbf3e38ea426e934b4e3e.zip
shader: Implement tessellation shaders, polygon mode and invocation id
Diffstat (limited to 'src/shader_recompiler/ir_opt')
-rw-r--r--src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp
index 617ec05ce..aadcf7999 100644
--- a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp
+++ b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp
@@ -53,6 +53,10 @@ void GetAttribute(Info& info, IR::Attribute attribute) {
53 case IR::Attribute::PointSpriteT: 53 case IR::Attribute::PointSpriteT:
54 info.loads_point_coord = true; 54 info.loads_point_coord = true;
55 break; 55 break;
56 case IR::Attribute::TessellationEvaluationPointU:
57 case IR::Attribute::TessellationEvaluationPointV:
58 info.loads_tess_coord = true;
59 break;
56 default: 60 default:
57 throw NotImplementedException("Get attribute {}", attribute); 61 throw NotImplementedException("Get attribute {}", attribute);
58 } 62 }
@@ -94,6 +98,34 @@ void SetAttribute(Info& info, IR::Attribute attribute) {
94 } 98 }
95} 99}
96 100
101void GetPatch(Info& info, IR::Patch patch) {
102 if (!IR::IsGeneric(patch)) {
103 throw NotImplementedException("Reading non-generic patch {}", patch);
104 }
105 info.uses_patches.at(IR::GenericPatchIndex(patch)) = true;
106}
107
108void SetPatch(Info& info, IR::Patch patch) {
109 if (IR::IsGeneric(patch)) {
110 info.uses_patches.at(IR::GenericPatchIndex(patch)) = true;
111 return;
112 }
113 switch (patch) {
114 case IR::Patch::TessellationLodLeft:
115 case IR::Patch::TessellationLodTop:
116 case IR::Patch::TessellationLodRight:
117 case IR::Patch::TessellationLodBottom:
118 info.stores_tess_level_outer = true;
119 break;
120 case IR::Patch::TessellationLodInteriorU:
121 case IR::Patch::TessellationLodInteriorV:
122 info.stores_tess_level_inner = true;
123 break;
124 default:
125 throw NotImplementedException("Set patch {}", patch);
126 }
127}
128
97void VisitUsages(Info& info, IR::Inst& inst) { 129void VisitUsages(Info& info, IR::Inst& inst) {
98 switch (inst.GetOpcode()) { 130 switch (inst.GetOpcode()) {
99 case IR::Opcode::CompositeConstructF16x2: 131 case IR::Opcode::CompositeConstructF16x2:
@@ -350,6 +382,12 @@ void VisitUsages(Info& info, IR::Inst& inst) {
350 case IR::Opcode::SetAttribute: 382 case IR::Opcode::SetAttribute:
351 SetAttribute(info, inst.Arg(0).Attribute()); 383 SetAttribute(info, inst.Arg(0).Attribute());
352 break; 384 break;
385 case IR::Opcode::GetPatch:
386 GetPatch(info, inst.Arg(0).Patch());
387 break;
388 case IR::Opcode::SetPatch:
389 SetPatch(info, inst.Arg(0).Patch());
390 break;
353 case IR::Opcode::GetAttributeIndexed: 391 case IR::Opcode::GetAttributeIndexed:
354 info.loads_indexed_attributes = true; 392 info.loads_indexed_attributes = true;
355 break; 393 break;
@@ -368,6 +406,9 @@ void VisitUsages(Info& info, IR::Inst& inst) {
368 case IR::Opcode::LocalInvocationId: 406 case IR::Opcode::LocalInvocationId:
369 info.uses_local_invocation_id = true; 407 info.uses_local_invocation_id = true;
370 break; 408 break;
409 case IR::Opcode::InvocationId:
410 info.uses_invocation_id = true;
411 break;
371 case IR::Opcode::IsHelperInvocation: 412 case IR::Opcode::IsHelperInvocation:
372 info.uses_is_helper_invocation = true; 413 info.uses_is_helper_invocation = true;
373 break; 414 break;