summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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) {
37std::string VertexIndex(EmitContext& ctx, ScalarU32 vertex) { 37std::string VertexIndex(EmitContext& ctx, ScalarU32 vertex) {
38 return IsInputArray(ctx.stage) ? fmt::format("[{}]", vertex) : ""; 38 return IsInputArray(ctx.stage) ? fmt::format("[{}]", vertex) : "";
39} 39}
40
41u32 TexCoordIndex(IR::Attribute attr) {
42 return (static_cast<u32>(attr) - static_cast<u32>(IR::Attribute::FixedFncTexture0S)) / 4;
43}
40} // Anonymous namespace 44} // Anonymous namespace
41 45
42void EmitGetCbufU8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, ScalarU32 offset) { 46void 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
76 ctx.Add("MOV.F {}.x,in_attr{}{}[0].{};", inst, index, VertexIndex(ctx, vertex), swizzle); 80 ctx.Add("MOV.F {}.x,in_attr{}{}[0].{};", inst, index, VertexIndex(ctx, vertex), swizzle);
77 return; 81 return;
78 } 82 }
83 if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9Q) {
84 const u32 index{TexCoordIndex(attr)};
85 ctx.Add("MOV.F {}.x,{}.texcoord[{}].{};", inst, ctx.attrib_name, index, swizzle);
86 return;
87 }
79 switch (attr) { 88 switch (attr) {
80 case IR::Attribute::PrimitiveId: 89 case IR::Attribute::PrimitiveId:
81 ctx.Add("MOV.S {}.x,primitive.id;", inst); 90 ctx.Add("MOV.S {}.x,primitive.id;", inst);
@@ -128,8 +137,7 @@ void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, ScalarF32 value,
128 return; 137 return;
129 } 138 }
130 if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9R) { 139 if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9R) {
131 const u32 index{ 140 const u32 index{TexCoordIndex(attr)};
132 (static_cast<u32>(attr) - static_cast<u32>(IR::Attribute::FixedFncTexture0S)) / 4};
133 ctx.Add("MOV.F result.texcoord[{}].{},{};", index, swizzle, value); 141 ctx.Add("MOV.F result.texcoord[{}].{},{};", index, swizzle, value);
134 return; 142 return;
135 } 143 }
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) {
28 }); 28 });
29} 29}
30 30
31void GetAttribute(Info& info, IR::Attribute attribute) { 31void GetAttribute(Info& info, IR::Attribute attr) {
32 if (IR::IsGeneric(attribute)) { 32 if (IR::IsGeneric(attr)) {
33 info.input_generics.at(IR::GenericAttributeIndex(attribute)).used = true; 33 info.input_generics.at(IR::GenericAttributeIndex(attr)).used = true;
34 return; 34 return;
35 } 35 }
36 switch (attribute) { 36 if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9Q) {
37 info.loads_fixed_fnc_textures = true;
38 return;
39 }
40 switch (attr) {
37 case IR::Attribute::PrimitiveId: 41 case IR::Attribute::PrimitiveId:
38 info.loads_primitive_id = true; 42 info.loads_primitive_id = true;
39 break; 43 break;
@@ -67,16 +71,20 @@ void GetAttribute(Info& info, IR::Attribute attribute) {
67 info.loads_front_face = true; 71 info.loads_front_face = true;
68 break; 72 break;
69 default: 73 default:
70 throw NotImplementedException("Get attribute {}", attribute); 74 throw NotImplementedException("Get attribute {}", attr);
71 } 75 }
72} 76}
73 77
74void SetAttribute(Info& info, IR::Attribute attribute) { 78void SetAttribute(Info& info, IR::Attribute attr) {
75 if (IR::IsGeneric(attribute)) { 79 if (IR::IsGeneric(attr)) {
76 info.stores_generics.at(IR::GenericAttributeIndex(attribute)) = true; 80 info.stores_generics.at(IR::GenericAttributeIndex(attr)) = true;
77 return; 81 return;
78 } 82 }
79 switch (attribute) { 83 if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9Q) {
84 info.stores_fixed_fnc_textures = true;
85 return;
86 }
87 switch (attr) {
80 case IR::Attribute::Layer: 88 case IR::Attribute::Layer:
81 info.stores_layer = true; 89 info.stores_layer = true;
82 break; 90 break;
@@ -116,48 +124,6 @@ void SetAttribute(Info& info, IR::Attribute attribute) {
116 case IR::Attribute::ColorBackSpecularA: 124 case IR::Attribute::ColorBackSpecularA:
117 info.stores_color_front_specular = true; 125 info.stores_color_front_specular = true;
118 break; 126 break;
119 case IR::Attribute::FixedFncTexture0S:
120 case IR::Attribute::FixedFncTexture0T:
121 case IR::Attribute::FixedFncTexture0R:
122 case IR::Attribute::FixedFncTexture0Q:
123 case IR::Attribute::FixedFncTexture1S:
124 case IR::Attribute::FixedFncTexture1T:
125 case IR::Attribute::FixedFncTexture1R:
126 case IR::Attribute::FixedFncTexture1Q:
127 case IR::Attribute::FixedFncTexture2S:
128 case IR::Attribute::FixedFncTexture2T:
129 case IR::Attribute::FixedFncTexture2R:
130 case IR::Attribute::FixedFncTexture2Q:
131 case IR::Attribute::FixedFncTexture3S:
132 case IR::Attribute::FixedFncTexture3T:
133 case IR::Attribute::FixedFncTexture3R:
134 case IR::Attribute::FixedFncTexture3Q:
135 case IR::Attribute::FixedFncTexture4S:
136 case IR::Attribute::FixedFncTexture4T:
137 case IR::Attribute::FixedFncTexture4R:
138 case IR::Attribute::FixedFncTexture4Q:
139 case IR::Attribute::FixedFncTexture5S:
140 case IR::Attribute::FixedFncTexture5T:
141 case IR::Attribute::FixedFncTexture5R:
142 case IR::Attribute::FixedFncTexture5Q:
143 case IR::Attribute::FixedFncTexture6S:
144 case IR::Attribute::FixedFncTexture6T:
145 case IR::Attribute::FixedFncTexture6R:
146 case IR::Attribute::FixedFncTexture6Q:
147 case IR::Attribute::FixedFncTexture7S:
148 case IR::Attribute::FixedFncTexture7T:
149 case IR::Attribute::FixedFncTexture7R:
150 case IR::Attribute::FixedFncTexture7Q:
151 case IR::Attribute::FixedFncTexture8S:
152 case IR::Attribute::FixedFncTexture8T:
153 case IR::Attribute::FixedFncTexture8R:
154 case IR::Attribute::FixedFncTexture8Q:
155 case IR::Attribute::FixedFncTexture9S:
156 case IR::Attribute::FixedFncTexture9T:
157 case IR::Attribute::FixedFncTexture9R:
158 case IR::Attribute::FixedFncTexture9Q:
159 info.stores_fixed_fnc_textures = true;
160 break;
161 case IR::Attribute::ClipDistance0: 127 case IR::Attribute::ClipDistance0:
162 case IR::Attribute::ClipDistance1: 128 case IR::Attribute::ClipDistance1:
163 case IR::Attribute::ClipDistance2: 129 case IR::Attribute::ClipDistance2:
@@ -175,7 +141,7 @@ void SetAttribute(Info& info, IR::Attribute attribute) {
175 info.stores_viewport_mask = true; 141 info.stores_viewport_mask = true;
176 break; 142 break;
177 default: 143 default:
178 throw NotImplementedException("Set attribute {}", attribute); 144 throw NotImplementedException("Set attribute {}", attr);
179 } 145 }
180} 146}
181 147
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 {
123 bool loads_primitive_id{}; 123 bool loads_primitive_id{};
124 bool loads_position{}; 124 bool loads_position{};
125 bool loads_color_front_diffuse{}; 125 bool loads_color_front_diffuse{};
126 bool loads_fixed_fnc_textures{};
126 bool loads_point_coord{}; 127 bool loads_point_coord{};
127 bool loads_instance_id{}; 128 bool loads_instance_id{};
128 bool loads_vertex_id{}; 129 bool loads_vertex_id{};