diff options
author | ameerj <52414509+ameerj@users.noreply.github.com> | 2021-06-10 06:29:19 +0200 |
---|---|---|
committer | ameerj <52414509+ameerj@users.noreply.github.com> | 2021-07-23 03:51:37 +0200 |
commit | 85399e119d6d61375fd9304d69bdfb3a85522d2a (patch) | |
tree | 6b89d199c729ace799392a97268e228d81d9422e /src/shader_recompiler/backend/glsl/emit_glsl_special.cpp | |
parent | glsl: Implement SampleId and SetSampleMask (diff) | |
download | yuzu-85399e119d6d61375fd9304d69bdfb3a85522d2a.tar yuzu-85399e119d6d61375fd9304d69bdfb3a85522d2a.tar.gz yuzu-85399e119d6d61375fd9304d69bdfb3a85522d2a.tar.bz2 yuzu-85399e119d6d61375fd9304d69bdfb3a85522d2a.tar.lz yuzu-85399e119d6d61375fd9304d69bdfb3a85522d2a.tar.xz yuzu-85399e119d6d61375fd9304d69bdfb3a85522d2a.tar.zst yuzu-85399e119d6d61375fd9304d69bdfb3a85522d2a.zip |
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_glsl_special.cpp')
-rw-r--r-- | src/shader_recompiler/backend/glsl/emit_glsl_special.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_special.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_special.cpp index e69de29bb..2155b8802 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_special.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_special.cpp @@ -0,0 +1,61 @@ +// Copyright 2021 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include <string_view> + +#include "shader_recompiler/backend/glsl/emit_context.h" +#include "shader_recompiler/backend/glsl/emit_glsl_instructions.h" +#include "shader_recompiler/frontend/ir/value.h" + +namespace Shader::Backend::GLSL { + +void EmitPhi(EmitContext& ctx, IR::Inst& phi) { + const size_t num_args{phi.NumArgs()}; + for (size_t i = 0; i < num_args; ++i) { + ctx.var_alloc.Consume(phi.Arg(i)); + } + if (!phi.Definition<Id>().is_valid) { + // The phi node wasn't forward defined + ctx.var_alloc.PhiDefine(phi, phi.Arg(0).Type()); + } +} + +void EmitVoid(EmitContext&) {} + +void EmitReference(EmitContext& ctx, const IR::Value& value) { + ctx.var_alloc.Consume(value); +} + +void EmitPhiMove(EmitContext& ctx, const IR::Value& phi_value, const IR::Value& value) { + IR::Inst& phi{*phi_value.InstRecursive()}; + const auto phi_type{phi.Arg(0).Type()}; + if (!phi.Definition<Id>().is_valid) { + // The phi node wasn't forward defined + ctx.var_alloc.PhiDefine(phi, phi_type); + } + const auto phi_reg{ctx.var_alloc.Consume(IR::Value{&phi})}; + const auto val_reg{ctx.var_alloc.Consume(value)}; + if (phi_reg == val_reg) { + return; + } + ctx.Add("{}={};", phi_reg, val_reg); +} + +void EmitPrologue(EmitContext&) { + // TODO +} + +void EmitEpilogue(EmitContext&) { + // TODO +} + +void EmitEmitVertex(EmitContext& ctx, const IR::Value& stream) { + ctx.Add("EmitStreamVertex(int({}));", ctx.var_alloc.Consume(stream)); +} + +void EmitEndPrimitive(EmitContext& ctx, const IR::Value& stream) { + ctx.Add("EndStreamPrimitive(int({}));", ctx.var_alloc.Consume(stream)); +} + +} // namespace Shader::Backend::GLSL |