summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/glasm
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2021-06-24 02:41:09 -0300
committerGravatar ameerj2021-07-22 21:51:39 -0400
commit7dafa96ab59892b7f1fbffdb61e4326e6443955f (patch)
tree5ab58d56860db635542ea1ec24be258bd86b40b9 /src/shader_recompiler/backend/glasm
parentvk_graphics_pipeline: Implement conservative rendering (diff)
downloadyuzu-7dafa96ab59892b7f1fbffdb61e4326e6443955f.tar.gz
yuzu-7dafa96ab59892b7f1fbffdb61e4326e6443955f.tar.xz
yuzu-7dafa96ab59892b7f1fbffdb61e4326e6443955f.zip
shader: Rework varyings and implement passthrough geometry shaders
Put all varyings into a single std::bitset with helpers to access it. Implement passthrough geometry shaders using host's.
Diffstat (limited to 'src/shader_recompiler/backend/glasm')
-rw-r--r--src/shader_recompiler/backend/glasm/emit_context.cpp15
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm.cpp6
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp6
3 files changed, 14 insertions, 13 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_context.cpp b/src/shader_recompiler/backend/glasm/emit_context.cpp
index 21e14867c..80dad9ff3 100644
--- a/src/shader_recompiler/backend/glasm/emit_context.cpp
+++ b/src/shader_recompiler/backend/glasm/emit_context.cpp
@@ -83,14 +83,13 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile
83 break; 83 break;
84 } 84 }
85 const std::string_view attr_stage{stage == Stage::Fragment ? "fragment" : "vertex"}; 85 const std::string_view attr_stage{stage == Stage::Fragment ? "fragment" : "vertex"};
86 for (size_t index = 0; index < info.input_generics.size(); ++index) { 86 for (size_t index = 0; index < IR::NUM_GENERICS; ++index) {
87 const auto& generic{info.input_generics[index]}; 87 if (info.loads.Generic(index)) {
88 if (generic.used) {
89 Add("{}ATTRIB in_attr{}[]={{{}.attrib[{}..{}]}};", 88 Add("{}ATTRIB in_attr{}[]={{{}.attrib[{}..{}]}};",
90 InterpDecorator(generic.interpolation), index, attr_stage, index, index); 89 InterpDecorator(info.interpolation[index]), index, attr_stage, index, index);
91 } 90 }
92 } 91 }
93 if (IsInputArray(stage) && info.loads_position) { 92 if (IsInputArray(stage) && info.loads.AnyComponent(IR::Attribute::PositionX)) {
94 Add("ATTRIB vertex_position=vertex.position;"); 93 Add("ATTRIB vertex_position=vertex.position;");
95 } 94 }
96 if (info.uses_invocation_id) { 95 if (info.uses_invocation_id) {
@@ -102,7 +101,7 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile
102 if (info.stores_tess_level_inner) { 101 if (info.stores_tess_level_inner) {
103 Add("OUTPUT result_patch_tessinner[]={{result.patch.tessinner[0..1]}};"); 102 Add("OUTPUT result_patch_tessinner[]={{result.patch.tessinner[0..1]}};");
104 } 103 }
105 if (info.stores_clip_distance) { 104 if (info.stores.ClipDistances()) {
106 Add("OUTPUT result_clip[]={{result.clip[0..7]}};"); 105 Add("OUTPUT result_clip[]={{result.clip[0..7]}};");
107 } 106 }
108 for (size_t index = 0; index < info.uses_patches.size(); ++index) { 107 for (size_t index = 0; index < info.uses_patches.size(); ++index) {
@@ -124,8 +123,8 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile
124 Add("OUTPUT frag_color{}=result.color[{}];", index, index); 123 Add("OUTPUT frag_color{}=result.color[{}];", index, index);
125 } 124 }
126 } 125 }
127 for (size_t index = 0; index < info.stores_generics.size(); ++index) { 126 for (size_t index = 0; index < IR::NUM_GENERICS; ++index) {
128 if (info.stores_generics[index]) { 127 if (info.stores.Generic(index)) {
129 Add("OUTPUT out_attr{}[]={{result.attrib[{}..{}]}};", index, index, index); 128 Add("OUTPUT out_attr{}[]={{result.attrib[{}..{}]}};", index, index, index);
130 } 129 }
131 } 130 }
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm.cpp b/src/shader_recompiler/backend/glasm/emit_glasm.cpp
index 79314f130..2b96977b3 100644
--- a/src/shader_recompiler/backend/glasm/emit_glasm.cpp
+++ b/src/shader_recompiler/backend/glasm/emit_glasm.cpp
@@ -296,8 +296,10 @@ void SetupOptions(const IR::Program& program, const Profile& profile,
296 if (info.uses_sparse_residency) { 296 if (info.uses_sparse_residency) {
297 header += "OPTION EXT_sparse_texture2;"; 297 header += "OPTION EXT_sparse_texture2;";
298 } 298 }
299 if (((info.stores_viewport_index || info.stores_layer) && stage != Stage::Geometry) || 299 const bool stores_viewport_layer{info.stores[IR::Attribute::ViewportIndex] ||
300 info.stores_viewport_mask) { 300 info.stores[IR::Attribute::Layer]};
301 if ((stage != Stage::Geometry && stores_viewport_layer) ||
302 info.stores[IR::Attribute::ViewportMask]) {
301 if (profile.support_viewport_index_layer_non_geometry) { 303 if (profile.support_viewport_index_layer_non_geometry) {
302 header += "OPTION NV_viewport_array2;"; 304 header += "OPTION NV_viewport_array2;";
303 } 305 }
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 bc195d248..02c9dc6d7 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
@@ -261,7 +261,7 @@ void EmitGetAttributeIndexed(EmitContext& ctx, IR::Inst& inst, ScalarS32 offset,
261 fmt::format("{}.z", value), fmt::format("{}.w", value)}; 261 fmt::format("{}.z", value), fmt::format("{}.w", value)};
262 read(compare_index, values); 262 read(compare_index, values);
263 }}; 263 }};
264 if (ctx.info.loads_position) { 264 if (ctx.info.loads.AnyComponent(IR::Attribute::PositionX)) {
265 const u32 index{static_cast<u32>(IR::Attribute::PositionX)}; 265 const u32 index{static_cast<u32>(IR::Attribute::PositionX)};
266 if (IsInputArray(ctx.stage)) { 266 if (IsInputArray(ctx.stage)) {
267 read_swizzled(index, fmt::format("vertex_position{}", VertexIndex(ctx, vertex))); 267 read_swizzled(index, fmt::format("vertex_position{}", VertexIndex(ctx, vertex)));
@@ -269,8 +269,8 @@ void EmitGetAttributeIndexed(EmitContext& ctx, IR::Inst& inst, ScalarS32 offset,
269 read_swizzled(index, fmt::format("{}.position", ctx.attrib_name)); 269 read_swizzled(index, fmt::format("{}.position", ctx.attrib_name));
270 } 270 }
271 } 271 }
272 for (u32 index = 0; index < ctx.info.input_generics.size(); ++index) { 272 for (u32 index = 0; index < static_cast<u32>(IR::NUM_GENERICS); ++index) {
273 if (!ctx.info.input_generics[index].used) { 273 if (!ctx.info.loads.Generic(index)) {
274 continue; 274 continue;
275 } 275 }
276 read_swizzled(index, fmt::format("in_attr{}{}[0]", index, VertexIndex(ctx, vertex))); 276 read_swizzled(index, fmt::format("in_attr{}{}[0]", index, VertexIndex(ctx, vertex)));