diff options
| author | 2021-03-24 00:02:30 +0100 | |
|---|---|---|
| committer | 2021-07-22 21:51:24 -0400 | |
| commit | 8cb9443cb99c4510e6ef26a91d09a31a8fa6281f (patch) | |
| tree | 2337f294c7179e1e2e98cafedde5c2eb254965cb /src/shader_recompiler/backend/spirv | |
| parent | shader: Implement NDC [-1, 1], attribute types and default varying initializa... (diff) | |
| download | yuzu-8cb9443cb99c4510e6ef26a91d09a31a8fa6281f.tar.gz yuzu-8cb9443cb99c4510e6ef26a91d09a31a8fa6281f.tar.xz yuzu-8cb9443cb99c4510e6ef26a91d09a31a8fa6281f.zip | |
shader: Fix F2I
Diffstat (limited to 'src/shader_recompiler/backend/spirv')
| -rw-r--r-- | src/shader_recompiler/backend/spirv/emit_spirv.h | 3 | ||||
| -rw-r--r-- | src/shader_recompiler/backend/spirv/emit_spirv_floating_point.cpp | 20 |
2 files changed, 19 insertions, 4 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv.h b/src/shader_recompiler/backend/spirv/emit_spirv.h index 7fefcf2f2..6d4adafc7 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv.h +++ b/src/shader_recompiler/backend/spirv/emit_spirv.h | |||
| @@ -189,6 +189,9 @@ Id EmitFPSqrt(EmitContext& ctx, Id value); | |||
| 189 | Id EmitFPSaturate16(EmitContext& ctx, Id value); | 189 | Id EmitFPSaturate16(EmitContext& ctx, Id value); |
| 190 | Id EmitFPSaturate32(EmitContext& ctx, Id value); | 190 | Id EmitFPSaturate32(EmitContext& ctx, Id value); |
| 191 | Id EmitFPSaturate64(EmitContext& ctx, Id value); | 191 | Id EmitFPSaturate64(EmitContext& ctx, Id value); |
| 192 | Id EmitFPClamp16(EmitContext& ctx, Id value, Id min_value, Id max_value); | ||
| 193 | Id EmitFPClamp32(EmitContext& ctx, Id value, Id min_value, Id max_value); | ||
| 194 | Id EmitFPClamp64(EmitContext& ctx, Id value, Id min_value, Id max_value); | ||
| 192 | Id EmitFPRoundEven16(EmitContext& ctx, Id value); | 195 | Id EmitFPRoundEven16(EmitContext& ctx, Id value); |
| 193 | Id EmitFPRoundEven32(EmitContext& ctx, Id value); | 196 | Id EmitFPRoundEven32(EmitContext& ctx, Id value); |
| 194 | Id EmitFPRoundEven64(EmitContext& ctx, Id value); | 197 | Id EmitFPRoundEven64(EmitContext& ctx, Id value); |
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_floating_point.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_floating_point.cpp index 1fdf66cb6..24300af39 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_floating_point.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_floating_point.cpp | |||
| @@ -15,7 +15,7 @@ Id Decorate(EmitContext& ctx, IR::Inst* inst, Id op) { | |||
| 15 | return op; | 15 | return op; |
| 16 | } | 16 | } |
| 17 | 17 | ||
| 18 | Id Saturate(EmitContext& ctx, Id type, Id value, Id zero, Id one) { | 18 | Id Clamp(EmitContext& ctx, Id type, Id value, Id zero, Id one) { |
| 19 | if (ctx.profile.has_broken_spirv_clamp) { | 19 | if (ctx.profile.has_broken_spirv_clamp) { |
| 20 | return ctx.OpFMin(type, ctx.OpFMax(type, value, zero), one); | 20 | return ctx.OpFMin(type, ctx.OpFMax(type, value, zero), one); |
| 21 | } else { | 21 | } else { |
| @@ -139,19 +139,31 @@ Id EmitFPSqrt(EmitContext& ctx, Id value) { | |||
| 139 | Id EmitFPSaturate16(EmitContext& ctx, Id value) { | 139 | Id EmitFPSaturate16(EmitContext& ctx, Id value) { |
| 140 | const Id zero{ctx.Constant(ctx.F16[1], u16{0})}; | 140 | const Id zero{ctx.Constant(ctx.F16[1], u16{0})}; |
| 141 | const Id one{ctx.Constant(ctx.F16[1], u16{0x3c00})}; | 141 | const Id one{ctx.Constant(ctx.F16[1], u16{0x3c00})}; |
| 142 | return Saturate(ctx, ctx.F16[1], value, zero, one); | 142 | return Clamp(ctx, ctx.F16[1], value, zero, one); |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | Id EmitFPSaturate32(EmitContext& ctx, Id value) { | 145 | Id EmitFPSaturate32(EmitContext& ctx, Id value) { |
| 146 | const Id zero{ctx.Constant(ctx.F32[1], f32{0.0})}; | 146 | const Id zero{ctx.Constant(ctx.F32[1], f32{0.0})}; |
| 147 | const Id one{ctx.Constant(ctx.F32[1], f32{1.0})}; | 147 | const Id one{ctx.Constant(ctx.F32[1], f32{1.0})}; |
| 148 | return Saturate(ctx, ctx.F32[1], value, zero, one); | 148 | return Clamp(ctx, ctx.F32[1], value, zero, one); |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | Id EmitFPSaturate64(EmitContext& ctx, Id value) { | 151 | Id EmitFPSaturate64(EmitContext& ctx, Id value) { |
| 152 | const Id zero{ctx.Constant(ctx.F64[1], f64{0.0})}; | 152 | const Id zero{ctx.Constant(ctx.F64[1], f64{0.0})}; |
| 153 | const Id one{ctx.Constant(ctx.F64[1], f64{1.0})}; | 153 | const Id one{ctx.Constant(ctx.F64[1], f64{1.0})}; |
| 154 | return Saturate(ctx, ctx.F64[1], value, zero, one); | 154 | return Clamp(ctx, ctx.F64[1], value, zero, one); |
| 155 | } | ||
| 156 | |||
| 157 | Id EmitFPClamp16(EmitContext& ctx, Id value, Id min_value, Id max_value) { | ||
| 158 | return Clamp(ctx, ctx.F16[1], value, min_value, max_value); | ||
| 159 | } | ||
| 160 | |||
| 161 | Id EmitFPClamp32(EmitContext& ctx, Id value, Id min_value, Id max_value) { | ||
| 162 | return Clamp(ctx, ctx.F32[1], value, min_value, max_value); | ||
| 163 | } | ||
| 164 | |||
| 165 | Id EmitFPClamp64(EmitContext& ctx, Id value, Id min_value, Id max_value) { | ||
| 166 | return Clamp(ctx, ctx.F64[1], value, min_value, max_value); | ||
| 155 | } | 167 | } |
| 156 | 168 | ||
| 157 | Id EmitFPRoundEven16(EmitContext& ctx, Id value) { | 169 | Id EmitFPRoundEven16(EmitContext& ctx, Id value) { |