diff options
author | ameerj <52414509+ameerj@users.noreply.github.com> | 2021-03-29 04:23:45 +0200 |
---|---|---|
committer | ameerj <52414509+ameerj@users.noreply.github.com> | 2021-07-23 03:51:25 +0200 |
commit | 6c51f496320f698e123207c09ca61e55180a31b5 (patch) | |
tree | c5ecbbce29797fd7ba3138e11f9c364899375e2b /src/shader_recompiler/backend/spirv/emit_spirv_warp.cpp | |
parent | shader: Implement BRX (diff) | |
download | yuzu-6c51f496320f698e123207c09ca61e55180a31b5.tar yuzu-6c51f496320f698e123207c09ca61e55180a31b5.tar.gz yuzu-6c51f496320f698e123207c09ca61e55180a31b5.tar.bz2 yuzu-6c51f496320f698e123207c09ca61e55180a31b5.tar.lz yuzu-6c51f496320f698e123207c09ca61e55180a31b5.tar.xz yuzu-6c51f496320f698e123207c09ca61e55180a31b5.tar.zst yuzu-6c51f496320f698e123207c09ca61e55180a31b5.zip |
Diffstat (limited to 'src/shader_recompiler/backend/spirv/emit_spirv_warp.cpp')
-rw-r--r-- | src/shader_recompiler/backend/spirv/emit_spirv_warp.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_warp.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_warp.cpp index 44d8a347f..cbc5b1c96 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_warp.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_warp.cpp @@ -132,4 +132,20 @@ Id EmitShuffleButterfly(EmitContext& ctx, IR::Inst* inst, Id value, Id index, Id return SelectValue(ctx, in_range, value, src_thread_id); } +Id EmitFSwizzleAdd(EmitContext& ctx, Id op_a, Id op_b, Id swizzle) { + const Id three{ctx.Constant(ctx.U32[1], 3)}; + Id mask{ctx.OpLoad(ctx.U32[1], ctx.subgroup_local_invocation_id)}; + mask = ctx.OpBitwiseAnd(ctx.U32[1], mask, three); + mask = ctx.OpShiftLeftLogical(ctx.U32[1], mask, ctx.Constant(ctx.U32[1], 1)); + mask = ctx.OpShiftRightLogical(ctx.U32[1], swizzle, mask); + mask = ctx.OpBitwiseAnd(ctx.U32[1], mask, three); + + const Id modifier_a{ctx.OpVectorExtractDynamic(ctx.F32[1], ctx.fswzadd_lut_a, mask)}; + const Id modifier_b{ctx.OpVectorExtractDynamic(ctx.F32[1], ctx.fswzadd_lut_b, mask)}; + + const Id result_a{ctx.OpFMul(ctx.F32[1], op_a, modifier_a)}; + const Id result_b{ctx.OpFMul(ctx.F32[1], op_b, modifier_b)}; + return ctx.OpFAdd(ctx.F32[1], result_a, result_b); +} + } // namespace Shader::Backend::SPIRV |