summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/backend/spirv
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-04-17 08:07:31 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:28 +0200
commit7cfa403683f46cfca71ef2caf4ff53355eac47b2 (patch)
tree29c3357670adce555fc1c6d710a7b2f2d7b78519 /src/shader_recompiler/backend/spirv
parentspirv: Use ConstOffset instead of Offset when possible (diff)
downloadyuzu-7cfa403683f46cfca71ef2caf4ff53355eac47b2.tar
yuzu-7cfa403683f46cfca71ef2caf4ff53355eac47b2.tar.gz
yuzu-7cfa403683f46cfca71ef2caf4ff53355eac47b2.tar.bz2
yuzu-7cfa403683f46cfca71ef2caf4ff53355eac47b2.tar.lz
yuzu-7cfa403683f46cfca71ef2caf4ff53355eac47b2.tar.xz
yuzu-7cfa403683f46cfca71ef2caf4ff53355eac47b2.tar.zst
yuzu-7cfa403683f46cfca71ef2caf4ff53355eac47b2.zip
Diffstat (limited to 'src/shader_recompiler/backend/spirv')
-rw-r--r--src/shader_recompiler/backend/spirv/emit_spirv_image.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp
index 021933a8c..fea3bc112 100644
--- a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp
+++ b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp
@@ -310,11 +310,22 @@ Id EmitBoundImageWrite(EmitContext&) {
Id EmitImageSampleImplicitLod(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords,
Id bias_lc, const IR::Value& offset) {
const auto info{inst->Flags<IR::TextureInstInfo>()};
- const ImageOperands operands(ctx, info.has_bias != 0, false, info.has_lod_clamp != 0, bias_lc,
- offset);
- return Emit(&EmitContext::OpImageSparseSampleImplicitLod,
- &EmitContext::OpImageSampleImplicitLod, ctx, inst, ctx.F32[4], Texture(ctx, index),
- coords, operands.Mask(), operands.Span());
+ if (ctx.stage == Stage::Fragment) {
+ const ImageOperands operands(ctx, info.has_bias != 0, false, info.has_lod_clamp != 0,
+ bias_lc, offset);
+ return Emit(&EmitContext::OpImageSparseSampleImplicitLod,
+ &EmitContext::OpImageSampleImplicitLod, ctx, inst, ctx.F32[4],
+ Texture(ctx, index), coords, operands.Mask(), operands.Span());
+ } else {
+ // We can't use implicit lods on non-fragment stages on SPIR-V. Maxwell hardware behaves as
+ // if the lod was explicitly zero. This may change on Turing with implicit compute
+ // derivatives
+ const Id lod{ctx.Const(0)};
+ const ImageOperands operands(ctx, false, true, info.has_lod_clamp != 0, lod, offset);
+ return Emit(&EmitContext::OpImageSparseSampleExplicitLod,
+ &EmitContext::OpImageSampleExplicitLod, ctx, inst, ctx.F32[4],
+ Texture(ctx, index), coords, operands.Mask(), operands.Span());
+ }
}
Id EmitImageSampleExplicitLod(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords,