summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/backend
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-05-21 00:21:38 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:32 +0200
commit79929be8331fabdb83b5595704241f863a0ae33a (patch)
tree88f532c0759862485592069180b064e22c9b87fe /src/shader_recompiler/backend
parentglasm: Properly declare attributes on geometry programs (diff)
downloadyuzu-79929be8331fabdb83b5595704241f863a0ae33a.tar
yuzu-79929be8331fabdb83b5595704241f863a0ae33a.tar.gz
yuzu-79929be8331fabdb83b5595704241f863a0ae33a.tar.bz2
yuzu-79929be8331fabdb83b5595704241f863a0ae33a.tar.lz
yuzu-79929be8331fabdb83b5595704241f863a0ae33a.tar.xz
yuzu-79929be8331fabdb83b5595704241f863a0ae33a.tar.zst
yuzu-79929be8331fabdb83b5595704241f863a0ae33a.zip
Diffstat (limited to 'src/shader_recompiler/backend')
-rw-r--r--src/shader_recompiler/backend/glasm/emit_context.cpp3
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp19
2 files changed, 18 insertions, 4 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_context.cpp b/src/shader_recompiler/backend/glasm/emit_context.cpp
index a9bbb680f..d8451b41f 100644
--- a/src/shader_recompiler/backend/glasm/emit_context.cpp
+++ b/src/shader_recompiler/backend/glasm/emit_context.cpp
@@ -74,6 +74,9 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile
InterpDecorator(generic.interpolation), index, attr_stage, index, index);
}
}
+ if (stage == Stage::Geometry && info.loads_position) {
+ Add("ATTRIB vertex_position=vertex.position;");
+ }
for (size_t index = 0; index < program.info.stores_frag_color.size(); ++index) {
if (!program.info.stores_frag_color[index]) {
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 a81bd209b..d736775c8 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
@@ -19,6 +19,14 @@ void GetCbuf(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, ScalarU
const Register ret{ctx.reg_alloc.Define(inst)};
ctx.Add("LDC.{} {},c{}[{}];", size, ret, binding.U32(), offset);
}
+
+std::string VertexIndex(EmitContext& ctx, ScalarU32 vertex) {
+ if (ctx.stage == Stage::Geometry) {
+ return fmt::format("[{}]", vertex);
+ } else {
+ return "";
+ }
+}
} // Anonymous namespace
void EmitGetCbufU8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, ScalarU32 offset) {
@@ -50,13 +58,12 @@ void EmitGetCbufU32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding
GetCbuf(ctx, inst, binding, offset, "U32X2");
}
-void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr,
- [[maybe_unused]] ScalarU32 vertex) {
+void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, ScalarU32 vertex) {
const u32 element{static_cast<u32>(attr) % 4};
const char swizzle{"xyzw"[element]};
if (IR::IsGeneric(attr)) {
const u32 index{IR::GenericAttributeIndex(attr)};
- ctx.Add("MOV.F {}.x,in_attr{}[0].{};", inst, index, swizzle);
+ ctx.Add("MOV.F {}.x,in_attr{}{}[0].{};", inst, index, VertexIndex(ctx, vertex), swizzle);
return;
}
switch (attr) {
@@ -64,7 +71,11 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr,
case IR::Attribute::PositionY:
case IR::Attribute::PositionZ:
case IR::Attribute::PositionW:
- ctx.Add("MOV.F {}.x,{}.position.{};", inst, ctx.attrib_name, swizzle);
+ if (ctx.stage == Stage::Geometry) {
+ ctx.Add("MOV.F {}.x,vertex_position{}.{};", inst, VertexIndex(ctx, vertex), swizzle);
+ } else {
+ ctx.Add("MOV.F {}.x,{}.position.{};", inst, ctx.attrib_name, swizzle);
+ }
break;
case IR::Attribute::PointSpriteS:
case IR::Attribute::PointSpriteT: