summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFernandoS27 <fsahmkow27@gmail.com>2021-03-30 21:52:06 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:25 +0200
commit0c4cf3b9eb7de6624a844ae9ac9d2ba6b2ef3ac2 (patch)
tree2ee6b4fb859d23e304b80d91a3472d8a504d01e3 /src
parentshader: Fix TXD (diff)
downloadyuzu-0c4cf3b9eb7de6624a844ae9ac9d2ba6b2ef3ac2.tar
yuzu-0c4cf3b9eb7de6624a844ae9ac9d2ba6b2ef3ac2.tar.gz
yuzu-0c4cf3b9eb7de6624a844ae9ac9d2ba6b2ef3ac2.tar.bz2
yuzu-0c4cf3b9eb7de6624a844ae9ac9d2ba6b2ef3ac2.tar.lz
yuzu-0c4cf3b9eb7de6624a844ae9ac9d2ba6b2ef3ac2.tar.xz
yuzu-0c4cf3b9eb7de6624a844ae9ac9d2ba6b2ef3ac2.tar.zst
yuzu-0c4cf3b9eb7de6624a844ae9ac9d2ba6b2ef3ac2.zip
Diffstat (limited to 'src')
-rw-r--r--src/shader_recompiler/backend/spirv/emit_context.cpp9
-rw-r--r--src/shader_recompiler/backend/spirv/emit_context.h3
-rw-r--r--src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp13
-rw-r--r--src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp10
-rw-r--r--src/shader_recompiler/shader_info.h1
5 files changed, 36 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_context.cpp b/src/shader_recompiler/backend/spirv/emit_context.cpp
index c8ce58254..2e3e3346d 100644
--- a/src/shader_recompiler/backend/spirv/emit_context.cpp
+++ b/src/shader_recompiler/backend/spirv/emit_context.cpp
@@ -176,6 +176,9 @@ void EmitContext::DefineCommonTypes(const Info& info) {
AddCapability(spv::Capability::Float64);
F64.Define(*this, TypeFloat(64), "f64");
}
+ if (info.stores_clip_distance) {
+ Array8F32 = Name(TypeArray(F32[1], Constant(U32[1], 8)), "array_8_f32");
+ }
}
void EmitContext::DefineCommonConstants() {
@@ -502,6 +505,12 @@ void EmitContext::DefineOutputs(const Info& info) {
}
output_point_size = DefineOutput(*this, F32[1], spv::BuiltIn::PointSize);
}
+ if (info.stores_clip_distance) {
+ if (stage == Stage::Fragment) {
+ throw NotImplementedException("Storing PointSize in Fragment stage");
+ }
+ clip_distances = DefineOutput(*this, Array8F32, spv::BuiltIn::ClipDistance);
+ }
for (size_t i = 0; i < info.stores_generics.size(); ++i) {
if (info.stores_generics[i]) {
output_generics[i] = DefineOutput(*this, F32[4]);
diff --git a/src/shader_recompiler/backend/spirv/emit_context.h b/src/shader_recompiler/backend/spirv/emit_context.h
index 3965869f0..bffe1558c 100644
--- a/src/shader_recompiler/backend/spirv/emit_context.h
+++ b/src/shader_recompiler/backend/spirv/emit_context.h
@@ -67,6 +67,8 @@ public:
VectorTypes F16;
VectorTypes F64;
+ Id Array8F32{};
+
Id true_value{};
Id false_value{};
Id u32_zero_value{};
@@ -105,6 +107,7 @@ public:
Id base_vertex{};
Id front_face{};
Id point_coord{};
+ Id clip_distances{};
Id fswzadd_lut_a{};
Id fswzadd_lut_b{};
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 d02761f32..2eaeb29de 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
@@ -44,6 +44,19 @@ Id OutputAttrPointer(EmitContext& ctx, IR::Attribute attr) {
case IR::Attribute::PositionZ:
case IR::Attribute::PositionW:
return ctx.OpAccessChain(ctx.output_f32, ctx.output_position, element_id());
+ case IR::Attribute::ClipDistance0:
+ case IR::Attribute::ClipDistance1:
+ case IR::Attribute::ClipDistance2:
+ case IR::Attribute::ClipDistance3:
+ case IR::Attribute::ClipDistance4:
+ case IR::Attribute::ClipDistance5:
+ case IR::Attribute::ClipDistance6:
+ case IR::Attribute::ClipDistance7: {
+ const u32 base{static_cast<u32>(IR::Attribute::ClipDistance0)};
+ const u32 index{static_cast<u32>(attr) - base};
+ const Id clip_num{ctx.Constant(ctx.U32[1], index)};
+ return ctx.OpAccessChain(ctx.output_f32, ctx.clip_distances, clip_num);
+ }
default:
throw NotImplementedException("Read attribute {}", attr);
}
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 730d3e91e..50ffc4c19 100644
--- a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp
+++ b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp
@@ -71,6 +71,16 @@ void SetAttribute(Info& info, IR::Attribute attribute) {
case IR::Attribute::PositionW:
info.stores_position = true;
break;
+ case IR::Attribute::ClipDistance0:
+ case IR::Attribute::ClipDistance1:
+ case IR::Attribute::ClipDistance2:
+ case IR::Attribute::ClipDistance3:
+ case IR::Attribute::ClipDistance4:
+ case IR::Attribute::ClipDistance5:
+ case IR::Attribute::ClipDistance6:
+ case IR::Attribute::ClipDistance7:
+ info.stores_clip_distance = true;
+ break;
default:
throw NotImplementedException("Set attribute {}", attribute);
}
diff --git a/src/shader_recompiler/shader_info.h b/src/shader_recompiler/shader_info.h
index c9f6d9ef7..a62ad1e79 100644
--- a/src/shader_recompiler/shader_info.h
+++ b/src/shader_recompiler/shader_info.h
@@ -81,6 +81,7 @@ struct Info {
std::array<bool, 32> stores_generics{};
bool stores_position{};
bool stores_point_size{};
+ bool stores_clip_distance{};
bool uses_fp16{};
bool uses_fp64{};