summaryrefslogtreecommitdiff
path: root/src/shader_recompiler
diff options
context:
space:
mode:
authorGravatar FernandoS272021-03-29 20:05:38 +0200
committerGravatar ameerj2021-07-22 21:51:25 -0400
commit9d7422d967a97fea7888449652ad93da88e92b54 (patch)
tree609f0dd7d03d26cea693807b524f59e9d6092885 /src/shader_recompiler
parentshader: Add PointSize attribute (diff)
downloadyuzu-9d7422d967a97fea7888449652ad93da88e92b54.tar.gz
yuzu-9d7422d967a97fea7888449652ad93da88e92b54.tar.xz
yuzu-9d7422d967a97fea7888449652ad93da88e92b54.zip
shader: Add PointCoord attribute
Diffstat (limited to 'src/shader_recompiler')
-rw-r--r--src/shader_recompiler/backend/spirv/emit_context.cpp3
-rw-r--r--src/shader_recompiler/backend/spirv/emit_context.h2
-rw-r--r--src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp6
-rw-r--r--src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp4
-rw-r--r--src/shader_recompiler/shader_info.h1
5 files changed, 16 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_context.cpp b/src/shader_recompiler/backend/spirv/emit_context.cpp
index ecee1220e..2c93bada5 100644
--- a/src/shader_recompiler/backend/spirv/emit_context.cpp
+++ b/src/shader_recompiler/backend/spirv/emit_context.cpp
@@ -425,6 +425,9 @@ void EmitContext::DefineInputs(const Info& info) {
425 if (info.loads_front_face) { 425 if (info.loads_front_face) {
426 front_face = DefineInput(*this, U1, spv::BuiltIn::FrontFacing); 426 front_face = DefineInput(*this, U1, spv::BuiltIn::FrontFacing);
427 } 427 }
428 if (info.loads_point_coord) {
429 point_coord = DefineInput(*this, F32[2], spv::BuiltIn::PointCoord);
430 }
428 for (size_t index = 0; index < info.input_generics.size(); ++index) { 431 for (size_t index = 0; index < info.input_generics.size(); ++index) {
429 const InputVarying generic{info.input_generics[index]}; 432 const InputVarying generic{info.input_generics[index]};
430 if (!generic.used) { 433 if (!generic.used) {
diff --git a/src/shader_recompiler/backend/spirv/emit_context.h b/src/shader_recompiler/backend/spirv/emit_context.h
index 97e055db4..071e66c2a 100644
--- a/src/shader_recompiler/backend/spirv/emit_context.h
+++ b/src/shader_recompiler/backend/spirv/emit_context.h
@@ -103,6 +103,8 @@ public:
103 Id vertex_index{}; 103 Id vertex_index{};
104 Id base_vertex{}; 104 Id base_vertex{};
105 Id front_face{}; 105 Id front_face{};
106 Id point_coord{};
107
106 Id fswzadd_lut_a{}; 108 Id fswzadd_lut_a{};
107 Id fswzadd_lut_b{}; 109 Id fswzadd_lut_b{};
108 110
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp
index c870fac47..d02761f32 100644
--- a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp
+++ b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp
@@ -179,6 +179,12 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr) {
179 return ctx.OpSelect(ctx.U32[1], ctx.OpLoad(ctx.U1, ctx.front_face), 179 return ctx.OpSelect(ctx.U32[1], ctx.OpLoad(ctx.U1, ctx.front_face),
180 ctx.Constant(ctx.U32[1], std::numeric_limits<u32>::max()), 180 ctx.Constant(ctx.U32[1], std::numeric_limits<u32>::max()),
181 ctx.u32_zero_value); 181 ctx.u32_zero_value);
182 case IR::Attribute::PointSpriteS:
183 return ctx.OpLoad(ctx.F32[1], ctx.OpAccessChain(ctx.input_f32, ctx.point_coord,
184 ctx.Constant(ctx.U32[1], 0U)));
185 case IR::Attribute::PointSpriteT:
186 return ctx.OpLoad(ctx.F32[1], ctx.OpAccessChain(ctx.input_f32, ctx.point_coord,
187 ctx.Constant(ctx.U32[1], 1U)));
182 default: 188 default:
183 throw NotImplementedException("Read attribute {}", attr); 189 throw NotImplementedException("Read attribute {}", attr);
184 } 190 }
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 a47d54b9c..eb3d1343f 100644
--- a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp
+++ b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp
@@ -47,6 +47,10 @@ void GetAttribute(Info& info, IR::Attribute attribute) {
47 case IR::Attribute::FrontFace: 47 case IR::Attribute::FrontFace:
48 info.loads_front_face = true; 48 info.loads_front_face = true;
49 break; 49 break;
50 case IR::Attribute::PointSpriteS:
51 case IR::Attribute::PointSpriteT:
52 info.loads_point_coord = true;
53 break;
50 default: 54 default:
51 throw NotImplementedException("Get attribute {}", attribute); 55 throw NotImplementedException("Get attribute {}", attribute);
52 } 56 }
diff --git a/src/shader_recompiler/shader_info.h b/src/shader_recompiler/shader_info.h
index 3d8e08909..c9f6d9ef7 100644
--- a/src/shader_recompiler/shader_info.h
+++ b/src/shader_recompiler/shader_info.h
@@ -74,6 +74,7 @@ struct Info {
74 bool loads_instance_id{}; 74 bool loads_instance_id{};
75 bool loads_vertex_id{}; 75 bool loads_vertex_id{};
76 bool loads_front_face{}; 76 bool loads_front_face{};
77 bool loads_point_coord{};
77 78
78 std::array<bool, 8> stores_frag_color{}; 79 std::array<bool, 8> stores_frag_color{};
79 bool stores_frag_depth{}; 80 bool stores_frag_depth{};