summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend
diff options
context:
space:
mode:
authorGravatar FernandoS272021-03-30 08:41:21 +0200
committerGravatar ameerj2021-07-22 21:51:25 -0400
commit4d0d29fc2092bf02e102b8bac9cfa1b509274901 (patch)
tree97fbee1b64a0e5d8189cac30e8dd0a1a72a8ec4a /src/shader_recompiler/backend
parentshader: Always pass a lod for TexelFetch (diff)
downloadyuzu-4d0d29fc2092bf02e102b8bac9cfa1b509274901.tar.gz
yuzu-4d0d29fc2092bf02e102b8bac9cfa1b509274901.tar.xz
yuzu-4d0d29fc2092bf02e102b8bac9cfa1b509274901.zip
shader: Address feedback
Diffstat (limited to 'src/shader_recompiler/backend')
-rw-r--r--src/shader_recompiler/backend/spirv/emit_spirv_image.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp
index 1eba9cc00..03d2ec73e 100644
--- a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp
+++ b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp
@@ -72,20 +72,19 @@ public:
72 explicit ImageOperands(EmitContext& ctx, bool has_lod_clamp, Id derivates, u32 num_derivates, 72 explicit ImageOperands(EmitContext& ctx, bool has_lod_clamp, Id derivates, u32 num_derivates,
73 Id offset, Id lod_clamp) { 73 Id offset, Id lod_clamp) {
74 if (Sirit::ValidId(derivates)) { 74 if (Sirit::ValidId(derivates)) {
75 boost::container::static_vector<Id, 3> deriv_x_accum;
76 boost::container::static_vector<Id, 3> deriv_y_accum;
77 for (size_t i = 0; i < num_derivates; i++) {
78 deriv_x_accum.push_back(ctx.OpCompositeExtract(ctx.F32[1], derivates, i * 2));
79 deriv_y_accum.push_back(ctx.OpCompositeExtract(ctx.F32[1], derivates, i * 2 + 1));
80 }
81 Id derivates_X = ctx.OpCompositeConstruct(
82 ctx.F32[num_derivates], std::span{deriv_x_accum.data(), deriv_x_accum.size()});
83 Id derivates_Y = ctx.OpCompositeConstruct(
84 ctx.F32[num_derivates], std::span{deriv_y_accum.data(), deriv_y_accum.size()});
85 Add(spv::ImageOperandsMask::Grad, derivates_X, derivates_Y);
86 } else {
87 throw LogicError("Derivates must be present"); 75 throw LogicError("Derivates must be present");
88 } 76 }
77 boost::container::static_vector<Id, 3> deriv_x_accum;
78 boost::container::static_vector<Id, 3> deriv_y_accum;
79 for (size_t i = 0; i < num_derivates; i++) {
80 deriv_x_accum.push_back(ctx.OpCompositeExtract(ctx.F32[1], derivates, i * 2));
81 deriv_y_accum.push_back(ctx.OpCompositeExtract(ctx.F32[1], derivates, i * 2 + 1));
82 }
83 const Id derivates_X{ctx.OpCompositeConstruct(
84 ctx.F32[num_derivates], std::span{deriv_x_accum.data(), deriv_x_accum.size()})};
85 const Id derivates_Y{ctx.OpCompositeConstruct(
86 ctx.F32[num_derivates], std::span{deriv_y_accum.data(), deriv_y_accum.size()})};
87 Add(spv::ImageOperandsMask::Grad, derivates_X, derivates_Y);
89 if (Sirit::ValidId(offset)) { 88 if (Sirit::ValidId(offset)) {
90 Add(spv::ImageOperandsMask::Offset, offset); 89 Add(spv::ImageOperandsMask::Offset, offset);
91 } 90 }
@@ -100,10 +99,10 @@ public:
100 operands.push_back(value); 99 operands.push_back(value);
101 } 100 }
102 101
103 void Add(spv::ImageOperandsMask new_mask, Id value, Id value_2) { 102 void Add(spv::ImageOperandsMask new_mask, Id value_1, Id value_2) {
104 mask = static_cast<spv::ImageOperandsMask>(static_cast<unsigned>(mask) | 103 mask = static_cast<spv::ImageOperandsMask>(static_cast<unsigned>(mask) |
105 static_cast<unsigned>(new_mask)); 104 static_cast<unsigned>(new_mask));
106 operands.push_back(value); 105 operands.push_back(value_1);
107 operands.push_back(value_2); 106 operands.push_back(value_2);
108 } 107 }
109 108
@@ -345,7 +344,8 @@ Id EmitImageQueryLod(EmitContext& ctx, IR::Inst*, const IR::Value& index, Id coo
345Id EmitImageGradient(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, 344Id EmitImageGradient(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords,
346 Id derivates, Id offset, Id lod_clamp) { 345 Id derivates, Id offset, Id lod_clamp) {
347 const auto info{inst->Flags<IR::TextureInstInfo>()}; 346 const auto info{inst->Flags<IR::TextureInstInfo>()};
348 const ImageOperands operands(ctx, info.has_lod_clamp != 0, derivates, info.num_derivates, offset, lod_clamp); 347 const ImageOperands operands(ctx, info.has_lod_clamp != 0, derivates, info.num_derivates,
348 offset, lod_clamp);
349 return Emit(&EmitContext::OpImageSparseSampleExplicitLod, 349 return Emit(&EmitContext::OpImageSparseSampleExplicitLod,
350 &EmitContext::OpImageSampleExplicitLod, ctx, inst, ctx.F32[4], Texture(ctx, index), 350 &EmitContext::OpImageSampleExplicitLod, ctx, inst, ctx.F32[4], Texture(ctx, index),
351 coords, operands.Mask(), operands.Span()); 351 coords, operands.Mask(), operands.Span());