summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-05-31 10:34:53 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:34 +0200
commit5539b13c5a696de553be86bb7c4ae61a0cdcc754 (patch)
treef5ebdb9fb9459ade45e598122430cfe951c9463c
parentglasm: Implement legacy varyings (diff)
downloadyuzu-5539b13c5a696de553be86bb7c4ae61a0cdcc754.tar
yuzu-5539b13c5a696de553be86bb7c4ae61a0cdcc754.tar.gz
yuzu-5539b13c5a696de553be86bb7c4ae61a0cdcc754.tar.bz2
yuzu-5539b13c5a696de553be86bb7c4ae61a0cdcc754.tar.lz
yuzu-5539b13c5a696de553be86bb7c4ae61a0cdcc754.tar.xz
yuzu-5539b13c5a696de553be86bb7c4ae61a0cdcc754.tar.zst
yuzu-5539b13c5a696de553be86bb7c4ae61a0cdcc754.zip
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp12
-rw-r--r--src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp70
-rw-r--r--src/shader_recompiler/shader_info.h1
3 files changed, 29 insertions, 54 deletions
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 3236def25..3b73e8757 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
@@ -37,6 +37,10 @@ bool IsInputArray(Stage stage) {
std::string VertexIndex(EmitContext& ctx, ScalarU32 vertex) {
return IsInputArray(ctx.stage) ? fmt::format("[{}]", vertex) : "";
}
+
+u32 TexCoordIndex(IR::Attribute attr) {
+ return (static_cast<u32>(attr) - static_cast<u32>(IR::Attribute::FixedFncTexture0S)) / 4;
+}
} // Anonymous namespace
void EmitGetCbufU8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, ScalarU32 offset) {
@@ -76,6 +80,11 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, Scal
ctx.Add("MOV.F {}.x,in_attr{}{}[0].{};", inst, index, VertexIndex(ctx, vertex), swizzle);
return;
}
+ if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9Q) {
+ const u32 index{TexCoordIndex(attr)};
+ ctx.Add("MOV.F {}.x,{}.texcoord[{}].{};", inst, ctx.attrib_name, index, swizzle);
+ return;
+ }
switch (attr) {
case IR::Attribute::PrimitiveId:
ctx.Add("MOV.S {}.x,primitive.id;", inst);
@@ -128,8 +137,7 @@ void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, ScalarF32 value,
return;
}
if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9R) {
- const u32 index{
- (static_cast<u32>(attr) - static_cast<u32>(IR::Attribute::FixedFncTexture0S)) / 4};
+ const u32 index{TexCoordIndex(attr)};
ctx.Add("MOV.F result.texcoord[{}].{},{};", index, swizzle, value);
return;
}
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 b343f0429..6a5243c9f 100644
--- a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp
+++ b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp
@@ -28,12 +28,16 @@ void AddConstantBufferDescriptor(Info& info, u32 index, u32 count) {
});
}
-void GetAttribute(Info& info, IR::Attribute attribute) {
- if (IR::IsGeneric(attribute)) {
- info.input_generics.at(IR::GenericAttributeIndex(attribute)).used = true;
+void GetAttribute(Info& info, IR::Attribute attr) {
+ if (IR::IsGeneric(attr)) {
+ info.input_generics.at(IR::GenericAttributeIndex(attr)).used = true;
return;
}
- switch (attribute) {
+ if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9Q) {
+ info.loads_fixed_fnc_textures = true;
+ return;
+ }
+ switch (attr) {
case IR::Attribute::PrimitiveId:
info.loads_primitive_id = true;
break;
@@ -67,16 +71,20 @@ void GetAttribute(Info& info, IR::Attribute attribute) {
info.loads_front_face = true;
break;
default:
- throw NotImplementedException("Get attribute {}", attribute);
+ throw NotImplementedException("Get attribute {}", attr);
}
}
-void SetAttribute(Info& info, IR::Attribute attribute) {
- if (IR::IsGeneric(attribute)) {
- info.stores_generics.at(IR::GenericAttributeIndex(attribute)) = true;
+void SetAttribute(Info& info, IR::Attribute attr) {
+ if (IR::IsGeneric(attr)) {
+ info.stores_generics.at(IR::GenericAttributeIndex(attr)) = true;
return;
}
- switch (attribute) {
+ if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9Q) {
+ info.stores_fixed_fnc_textures = true;
+ return;
+ }
+ switch (attr) {
case IR::Attribute::Layer:
info.stores_layer = true;
break;
@@ -116,48 +124,6 @@ void SetAttribute(Info& info, IR::Attribute attribute) {
case IR::Attribute::ColorBackSpecularA:
info.stores_color_front_specular = true;
break;
- case IR::Attribute::FixedFncTexture0S:
- case IR::Attribute::FixedFncTexture0T:
- case IR::Attribute::FixedFncTexture0R:
- case IR::Attribute::FixedFncTexture0Q:
- case IR::Attribute::FixedFncTexture1S:
- case IR::Attribute::FixedFncTexture1T:
- case IR::Attribute::FixedFncTexture1R:
- case IR::Attribute::FixedFncTexture1Q:
- case IR::Attribute::FixedFncTexture2S:
- case IR::Attribute::FixedFncTexture2T:
- case IR::Attribute::FixedFncTexture2R:
- case IR::Attribute::FixedFncTexture2Q:
- case IR::Attribute::FixedFncTexture3S:
- case IR::Attribute::FixedFncTexture3T:
- case IR::Attribute::FixedFncTexture3R:
- case IR::Attribute::FixedFncTexture3Q:
- case IR::Attribute::FixedFncTexture4S:
- case IR::Attribute::FixedFncTexture4T:
- case IR::Attribute::FixedFncTexture4R:
- case IR::Attribute::FixedFncTexture4Q:
- case IR::Attribute::FixedFncTexture5S:
- case IR::Attribute::FixedFncTexture5T:
- case IR::Attribute::FixedFncTexture5R:
- case IR::Attribute::FixedFncTexture5Q:
- case IR::Attribute::FixedFncTexture6S:
- case IR::Attribute::FixedFncTexture6T:
- case IR::Attribute::FixedFncTexture6R:
- case IR::Attribute::FixedFncTexture6Q:
- case IR::Attribute::FixedFncTexture7S:
- case IR::Attribute::FixedFncTexture7T:
- case IR::Attribute::FixedFncTexture7R:
- case IR::Attribute::FixedFncTexture7Q:
- case IR::Attribute::FixedFncTexture8S:
- case IR::Attribute::FixedFncTexture8T:
- case IR::Attribute::FixedFncTexture8R:
- case IR::Attribute::FixedFncTexture8Q:
- case IR::Attribute::FixedFncTexture9S:
- case IR::Attribute::FixedFncTexture9T:
- case IR::Attribute::FixedFncTexture9R:
- case IR::Attribute::FixedFncTexture9Q:
- info.stores_fixed_fnc_textures = true;
- break;
case IR::Attribute::ClipDistance0:
case IR::Attribute::ClipDistance1:
case IR::Attribute::ClipDistance2:
@@ -175,7 +141,7 @@ void SetAttribute(Info& info, IR::Attribute attribute) {
info.stores_viewport_mask = true;
break;
default:
- throw NotImplementedException("Set attribute {}", attribute);
+ throw NotImplementedException("Set attribute {}", attr);
}
}
diff --git a/src/shader_recompiler/shader_info.h b/src/shader_recompiler/shader_info.h
index b60ba0457..d5b2ca7bc 100644
--- a/src/shader_recompiler/shader_info.h
+++ b/src/shader_recompiler/shader_info.h
@@ -123,6 +123,7 @@ struct Info {
bool loads_primitive_id{};
bool loads_position{};
bool loads_color_front_diffuse{};
+ bool loads_fixed_fnc_textures{};
bool loads_point_coord{};
bool loads_instance_id{};
bool loads_vertex_id{};