diff options
| author | 2021-04-18 20:47:31 -0400 | |
|---|---|---|
| committer | 2021-07-22 21:51:28 -0400 | |
| commit | 5b8afed87115c82cb48913fd47dfbfa347e4faa5 (patch) | |
| tree | 84eff714b71e1f3e5f1b9436e877327480144b0b /src/shader_recompiler/backend/spirv/emit_spirv_image.cpp | |
| parent | shader: Address feedback (diff) | |
| download | yuzu-5b8afed87115c82cb48913fd47dfbfa347e4faa5.tar.gz yuzu-5b8afed87115c82cb48913fd47dfbfa347e4faa5.tar.xz yuzu-5b8afed87115c82cb48913fd47dfbfa347e4faa5.zip | |
spirv: Replace Constant/ConstantComposite with Const helper
Diffstat (limited to 'src/shader_recompiler/backend/spirv/emit_spirv_image.cpp')
| -rw-r--r-- | src/shader_recompiler/backend/spirv/emit_spirv_image.cpp | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp index 7a4388e7e..90817f161 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp | |||
| @@ -45,16 +45,12 @@ public: | |||
| 45 | if (opcode != values[1]->GetOpcode() || opcode != IR::Opcode::CompositeConstructU32x4) { | 45 | if (opcode != values[1]->GetOpcode() || opcode != IR::Opcode::CompositeConstructU32x4) { |
| 46 | throw LogicError("Invalid PTP arguments"); | 46 | throw LogicError("Invalid PTP arguments"); |
| 47 | } | 47 | } |
| 48 | auto read{[&](unsigned int a, unsigned int b) { | 48 | auto read{[&](unsigned int a, unsigned int b) { return values[a]->Arg(b).U32(); }}; |
| 49 | return ctx.Constant(ctx.U32[1], values[a]->Arg(b).U32()); | 49 | |
| 50 | }}; | 50 | const Id offsets{ctx.ConstantComposite( |
| 51 | 51 | ctx.TypeArray(ctx.U32[2], ctx.Const(4U)), ctx.Const(read(0, 0), read(0, 1)), | |
| 52 | const Id offsets{ | 52 | ctx.Const(read(0, 2), read(0, 3)), ctx.Const(read(1, 0), read(1, 1)), |
| 53 | ctx.ConstantComposite(ctx.TypeArray(ctx.U32[2], ctx.Constant(ctx.U32[1], 4)), | 53 | ctx.Const(read(1, 2), read(1, 3)))}; |
| 54 | ctx.ConstantComposite(ctx.U32[2], read(0, 0), read(0, 1)), | ||
| 55 | ctx.ConstantComposite(ctx.U32[2], read(0, 2), read(0, 3)), | ||
| 56 | ctx.ConstantComposite(ctx.U32[2], read(1, 0), read(1, 1)), | ||
| 57 | ctx.ConstantComposite(ctx.U32[2], read(1, 2), read(1, 3)))}; | ||
| 58 | Add(spv::ImageOperandsMask::ConstOffsets, offsets); | 54 | Add(spv::ImageOperandsMask::ConstOffsets, offsets); |
| 59 | } | 55 | } |
| 60 | 56 | ||
| @@ -108,7 +104,7 @@ private: | |||
| 108 | return; | 104 | return; |
| 109 | } | 105 | } |
| 110 | if (offset.IsImmediate()) { | 106 | if (offset.IsImmediate()) { |
| 111 | Add(spv::ImageOperandsMask::ConstOffset, ctx.Constant(ctx.U32[1], offset.U32())); | 107 | Add(spv::ImageOperandsMask::ConstOffset, ctx.Const(offset.U32())); |
| 112 | return; | 108 | return; |
| 113 | } | 109 | } |
| 114 | IR::Inst* const inst{offset.InstRecursive()}; | 110 | IR::Inst* const inst{offset.InstRecursive()}; |
| @@ -361,9 +357,8 @@ Id EmitImageGather(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id | |||
| 361 | const auto info{inst->Flags<IR::TextureInstInfo>()}; | 357 | const auto info{inst->Flags<IR::TextureInstInfo>()}; |
| 362 | const ImageOperands operands(ctx, offset, offset2); | 358 | const ImageOperands operands(ctx, offset, offset2); |
| 363 | return Emit(&EmitContext::OpImageSparseGather, &EmitContext::OpImageGather, ctx, inst, | 359 | return Emit(&EmitContext::OpImageSparseGather, &EmitContext::OpImageGather, ctx, inst, |
| 364 | ctx.F32[4], Texture(ctx, index), coords, | 360 | ctx.F32[4], Texture(ctx, index), coords, ctx.Const(info.gather_component), |
| 365 | ctx.Constant(ctx.U32[1], info.gather_component.Value()), operands.Mask(), | 361 | operands.Mask(), operands.Span()); |
| 366 | operands.Span()); | ||
| 367 | } | 362 | } |
| 368 | 363 | ||
| 369 | Id EmitImageGatherDref(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, | 364 | Id EmitImageGatherDref(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, |