diff options
| author | 2021-03-21 19:28:37 -0400 | |
|---|---|---|
| committer | 2021-07-22 21:51:24 -0400 | |
| commit | e4e1cc11b8f7649171fe922b2899e57120bfba53 (patch) | |
| tree | 5aaac48ac64018bcaa5f7faf17c4eff886d29b12 /src/shader_recompiler/backend/spirv/emit_spirv.cpp | |
| parent | shader: Implement FADD32I (diff) | |
| download | yuzu-e4e1cc11b8f7649171fe922b2899e57120bfba53.tar.gz yuzu-e4e1cc11b8f7649171fe922b2899e57120bfba53.tar.xz yuzu-e4e1cc11b8f7649171fe922b2899e57120bfba53.zip | |
shader: Implement DMNMX, DSET, DSETP
Diffstat (limited to 'src/shader_recompiler/backend/spirv/emit_spirv.cpp')
| -rw-r--r-- | src/shader_recompiler/backend/spirv/emit_spirv.cpp | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv.cpp b/src/shader_recompiler/backend/spirv/emit_spirv.cpp index efd0b70b7..93e851133 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv.cpp | |||
| @@ -152,24 +152,7 @@ void DefineEntryPoint(Environment& env, EmitContext& ctx, Id main) { | |||
| 152 | 152 | ||
| 153 | void SetupDenormControl(const Profile& profile, const IR::Program& program, EmitContext& ctx, | 153 | void SetupDenormControl(const Profile& profile, const IR::Program& program, EmitContext& ctx, |
| 154 | Id main_func) { | 154 | Id main_func) { |
| 155 | if (!profile.support_float_controls) { | ||
| 156 | return; | ||
| 157 | } | ||
| 158 | const Info& info{program.info}; | 155 | const Info& info{program.info}; |
| 159 | if (!info.uses_fp32_denorms_flush && !info.uses_fp32_denorms_preserve && | ||
| 160 | !info.uses_fp16_denorms_flush && !info.uses_fp16_denorms_preserve) { | ||
| 161 | return; | ||
| 162 | } | ||
| 163 | ctx.AddExtension("SPV_KHR_float_controls"); | ||
| 164 | |||
| 165 | if (info.uses_fp16 && profile.support_fp16_signed_zero_nan_preserve) { | ||
| 166 | ctx.AddCapability(spv::Capability::SignedZeroInfNanPreserve); | ||
| 167 | ctx.AddExecutionMode(main_func, spv::ExecutionMode::SignedZeroInfNanPreserve, 16U); | ||
| 168 | } | ||
| 169 | if (profile.support_fp32_signed_zero_nan_preserve) { | ||
| 170 | ctx.AddCapability(spv::Capability::SignedZeroInfNanPreserve); | ||
| 171 | ctx.AddExecutionMode(main_func, spv::ExecutionMode::SignedZeroInfNanPreserve, 32U); | ||
| 172 | } | ||
| 173 | if (info.uses_fp32_denorms_flush && info.uses_fp32_denorms_preserve) { | 156 | if (info.uses_fp32_denorms_flush && info.uses_fp32_denorms_preserve) { |
| 174 | // LOG_ERROR(HW_GPU, "Fp32 denorm flush and preserve on the same shader"); | 157 | // LOG_ERROR(HW_GPU, "Fp32 denorm flush and preserve on the same shader"); |
| 175 | } else if (info.uses_fp32_denorms_flush) { | 158 | } else if (info.uses_fp32_denorms_flush) { |
| @@ -210,6 +193,22 @@ void SetupDenormControl(const Profile& profile, const IR::Program& program, Emit | |||
| 210 | } | 193 | } |
| 211 | } | 194 | } |
| 212 | 195 | ||
| 196 | void SetupSignedNanCapabilities(const Profile& profile, const IR::Program& program, | ||
| 197 | EmitContext& ctx, Id main_func) { | ||
| 198 | if (program.info.uses_fp16 && profile.support_fp16_signed_zero_nan_preserve) { | ||
| 199 | ctx.AddCapability(spv::Capability::SignedZeroInfNanPreserve); | ||
| 200 | ctx.AddExecutionMode(main_func, spv::ExecutionMode::SignedZeroInfNanPreserve, 16U); | ||
| 201 | } | ||
| 202 | if (profile.support_fp32_signed_zero_nan_preserve) { | ||
| 203 | ctx.AddCapability(spv::Capability::SignedZeroInfNanPreserve); | ||
| 204 | ctx.AddExecutionMode(main_func, spv::ExecutionMode::SignedZeroInfNanPreserve, 32U); | ||
| 205 | } | ||
| 206 | if (program.info.uses_fp64 && profile.support_fp64_signed_zero_nan_preserve) { | ||
| 207 | ctx.AddCapability(spv::Capability::SignedZeroInfNanPreserve); | ||
| 208 | ctx.AddExecutionMode(main_func, spv::ExecutionMode::SignedZeroInfNanPreserve, 64U); | ||
| 209 | } | ||
| 210 | } | ||
| 211 | |||
| 213 | void SetupCapabilities(const Profile& profile, const Info& info, EmitContext& ctx) { | 212 | void SetupCapabilities(const Profile& profile, const Info& info, EmitContext& ctx) { |
| 214 | if (info.uses_sampled_1d) { | 213 | if (info.uses_sampled_1d) { |
| 215 | ctx.AddCapability(spv::Capability::Sampled1D); | 214 | ctx.AddCapability(spv::Capability::Sampled1D); |
| @@ -260,7 +259,11 @@ std::vector<u32> EmitSPIRV(const Profile& profile, Environment& env, IR::Program | |||
| 260 | EmitContext ctx{profile, program, binding}; | 259 | EmitContext ctx{profile, program, binding}; |
| 261 | const Id main{DefineMain(ctx, program)}; | 260 | const Id main{DefineMain(ctx, program)}; |
| 262 | DefineEntryPoint(env, ctx, main); | 261 | DefineEntryPoint(env, ctx, main); |
| 263 | SetupDenormControl(profile, program, ctx, main); | 262 | if (profile.support_float_controls) { |
| 263 | ctx.AddExtension("SPV_KHR_float_controls"); | ||
| 264 | SetupDenormControl(profile, program, ctx, main); | ||
| 265 | SetupSignedNanCapabilities(profile, program, ctx, main); | ||
| 266 | } | ||
| 264 | SetupCapabilities(profile, program.info, ctx); | 267 | SetupCapabilities(profile, program.info, ctx); |
| 265 | return ctx.Assemble(); | 268 | return ctx.Assemble(); |
| 266 | } | 269 | } |