mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-12-01 07:46:27 -05:00
e7c8f8911f
plus some minor refactoring of implementations
203 lines
4.4 KiB
C++
203 lines
4.4 KiB
C++
// 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"
|
|
|
|
#ifdef _MSC_VER
|
|
#pragma warning(disable : 4100)
|
|
#endif
|
|
|
|
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& ctx) {}
|
|
|
|
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 EmitBranch(EmitContext& ctx, std::string_view label) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitBranchConditional(EmitContext& ctx, std::string_view condition,
|
|
std::string_view true_label, std::string_view false_label) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitLoopMerge(EmitContext& ctx, std::string_view merge_label,
|
|
std::string_view continue_label) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitSelectionMerge(EmitContext& ctx, std::string_view merge_label) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitReturn(EmitContext& ctx) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitJoin(EmitContext& ctx) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitUnreachable(EmitContext& ctx) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitDemoteToHelperInvocation(EmitContext& ctx, std::string_view continue_label) {
|
|
ctx.Add("discard;");
|
|
}
|
|
|
|
void EmitPrologue(EmitContext& ctx) {}
|
|
|
|
void EmitEpilogue(EmitContext& ctx) {}
|
|
|
|
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));
|
|
}
|
|
|
|
void EmitGetRegister(EmitContext& ctx) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitSetRegister(EmitContext& ctx) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitGetPred(EmitContext& ctx) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitSetPred(EmitContext& ctx) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitSetGotoVariable(EmitContext& ctx) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitGetGotoVariable(EmitContext& ctx) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitSetIndirectBranchVariable(EmitContext& ctx) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitGetIndirectBranchVariable(EmitContext& ctx) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitGetZFlag(EmitContext& ctx) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitGetSFlag(EmitContext& ctx) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitGetCFlag(EmitContext& ctx) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitGetOFlag(EmitContext& ctx) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitSetZFlag(EmitContext& ctx) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitSetSFlag(EmitContext& ctx) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitSetCFlag(EmitContext& ctx) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitSetOFlag(EmitContext& ctx) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitUndefU1(EmitContext& ctx, IR::Inst& inst) {
|
|
ctx.AddU1("{}=false;", inst);
|
|
}
|
|
|
|
void EmitUndefU8(EmitContext& ctx, IR::Inst& inst) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitUndefU16(EmitContext& ctx, IR::Inst& inst) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitUndefU32(EmitContext& ctx, IR::Inst& inst) {
|
|
ctx.AddU32("{}=0u;", inst);
|
|
}
|
|
|
|
void EmitUndefU64(EmitContext& ctx, IR::Inst& inst) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitGetZeroFromOp(EmitContext& ctx) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitGetSignFromOp(EmitContext& ctx) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitGetCarryFromOp(EmitContext& ctx) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitGetOverflowFromOp(EmitContext& ctx) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitGetSparseFromOp(EmitContext& ctx) {
|
|
NotImplemented();
|
|
}
|
|
|
|
void EmitGetInBoundsFromOp(EmitContext& ctx) {
|
|
NotImplemented();
|
|
}
|
|
|
|
} // namespace Shader::Backend::GLSL
|