summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader_recompiler/backend')
-rw-r--r--src/shader_recompiler/backend/glasm/emit_context.cpp18
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp37
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm_instructions.h2
3 files changed, 51 insertions, 6 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_context.cpp b/src/shader_recompiler/backend/glasm/emit_context.cpp
index 7b25fa042..bb68b3d19 100644
--- a/src/shader_recompiler/backend/glasm/emit_context.cpp
+++ b/src/shader_recompiler/backend/glasm/emit_context.cpp
@@ -80,6 +80,24 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile
80 if (info.uses_invocation_id) { 80 if (info.uses_invocation_id) {
81 Add("ATTRIB primitive_invocation=primitive.invocation;"); 81 Add("ATTRIB primitive_invocation=primitive.invocation;");
82 } 82 }
83 if (info.stores_tess_level_outer) {
84 Add("OUTPUT result_patch_tessouter[]={{result.patch.tessouter[0..3]}};");
85 }
86 if (info.stores_tess_level_inner) {
87 Add("OUTPUT result_patch_tessinner[]={{result.patch.tessinner[0..1]}};");
88 }
89 for (size_t index = 0; index < info.uses_patches.size(); ++index) {
90 if (!info.uses_patches[index]) {
91 continue;
92 }
93 if (stage == Stage::TessellationEval) {
94 Add("OUTPUT result_patch_attrib{}[]={{result.patch.attrib[{}..{}]}};", index, index,
95 index);
96 } else {
97 Add("ATTRIB primitive_patch_attrib{}[]={{primitive.patch.attrib[{}..{}]}};", index,
98 index, index);
99 }
100 }
83 for (size_t index = 0; index < program.info.stores_frag_color.size(); ++index) { 101 for (size_t index = 0; index < program.info.stores_frag_color.size(); ++index) {
84 if (!program.info.stores_frag_color[index]) { 102 if (!program.info.stores_frag_color[index]) {
85 continue; 103 continue;
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp
index d736775c8..c3a2c6b70 100644
--- a/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp
+++ b/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp
@@ -136,13 +136,40 @@ void EmitSetAttributeIndexed([[maybe_unused]] EmitContext& ctx, [[maybe_unused]]
136 throw NotImplementedException("GLASM instruction"); 136 throw NotImplementedException("GLASM instruction");
137} 137}
138 138
139void EmitGetPatch([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Patch patch) { 139void EmitGetPatch(EmitContext& ctx, IR::Inst& inst, IR::Patch patch) {
140 throw NotImplementedException("GLASM instruction"); 140 if (!IR::IsGeneric(patch)) {
141 throw NotImplementedException("Non-generic patch load");
142 }
143 const u32 index{IR::GenericPatchIndex(patch)};
144 const u32 element{IR::GenericPatchElement(patch)};
145 ctx.Add("MOV.F {},result.patch.attrib[{}].{}", inst, index, "xyzw"[element]);
141} 146}
142 147
143void EmitSetPatch([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Patch patch, 148void EmitSetPatch(EmitContext& ctx, IR::Patch patch, ScalarF32 value) {
144 [[maybe_unused]] ScalarF32 value) { 149 if (IR::IsGeneric(patch)) {
145 throw NotImplementedException("GLASM instruction"); 150 const u32 index{IR::GenericPatchIndex(patch)};
151 const u32 element{IR::GenericPatchElement(patch)};
152 ctx.Add("MOV.F result.patch.attrib[{}].{},{}", index, "xyzw"[element], value);
153 return;
154 }
155 switch (patch) {
156 case IR::Patch::TessellationLodLeft:
157 case IR::Patch::TessellationLodRight:
158 case IR::Patch::TessellationLodTop:
159 case IR::Patch::TessellationLodBottom: {
160 const u32 index{static_cast<u32>(patch) - u32(IR::Patch::TessellationLodLeft)};
161 ctx.Add("MOV.F result.patch.tessouter[{}].x,{};", index, value);
162 break;
163 }
164 case IR::Patch::TessellationLodInteriorU:
165 ctx.Add("MOV.F result.patch.tessinner[0].x,{};", value);
166 break;
167 case IR::Patch::TessellationLodInteriorV:
168 ctx.Add("MOV.F result.patch.tessinner[1].x,{};", value);
169 break;
170 default:
171 throw NotImplementedException("Patch {}", patch);
172 }
146} 173}
147 174
148void EmitSetFragColor(EmitContext& ctx, u32 index, u32 component, ScalarF32 value) { 175void EmitSetFragColor(EmitContext& ctx, u32 index, u32 component, ScalarF32 value) {
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h b/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h
index b0af02235..2eb1eb123 100644
--- a/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h
+++ b/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h
@@ -53,7 +53,7 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, Scal
53void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, ScalarF32 value, ScalarU32 vertex); 53void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, ScalarF32 value, ScalarU32 vertex);
54void EmitGetAttributeIndexed(EmitContext& ctx, ScalarU32 offset, ScalarU32 vertex); 54void EmitGetAttributeIndexed(EmitContext& ctx, ScalarU32 offset, ScalarU32 vertex);
55void EmitSetAttributeIndexed(EmitContext& ctx, ScalarU32 offset, ScalarF32 value, ScalarU32 vertex); 55void EmitSetAttributeIndexed(EmitContext& ctx, ScalarU32 offset, ScalarF32 value, ScalarU32 vertex);
56void EmitGetPatch(EmitContext& ctx, IR::Patch patch); 56void EmitGetPatch(EmitContext& ctx, IR::Inst& inst, IR::Patch patch);
57void EmitSetPatch(EmitContext& ctx, IR::Patch patch, ScalarF32 value); 57void EmitSetPatch(EmitContext& ctx, IR::Patch patch, ScalarF32 value);
58void EmitSetFragColor(EmitContext& ctx, u32 index, u32 component, ScalarF32 value); 58void EmitSetFragColor(EmitContext& ctx, u32 index, u32 component, ScalarF32 value);
59void EmitSetSampleMask(EmitContext& ctx, ScalarS32 value); 59void EmitSetSampleMask(EmitContext& ctx, ScalarS32 value);