yuzu-emu
/
yuzu
Archived
1
0
Fork 0

glsl: More FP instructions/fixes

This commit is contained in:
ameerj 2021-05-22 02:32:57 -04:00
parent 5e9095ef22
commit 65c6f73e43
5 changed files with 41 additions and 28 deletions

View File

@ -33,12 +33,12 @@ void EmitFPAdd16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& i
void EmitFPAdd32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
[[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) {
ctx.AddF32("{}={}+{};", inst, a, b);
ctx.AddF32("{}=float({})+float({});", inst, a, b);
}
void EmitFPAdd64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
[[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) {
ctx.AddF64("{}={}+{};", inst, a, b);
ctx.AddF64("{}=double({})+double({});", inst, a, b);
}
void EmitFPFma16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
@ -180,14 +180,14 @@ void EmitFPClamp32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst&
[[maybe_unused]] std::string_view value,
[[maybe_unused]] std::string_view min_value,
[[maybe_unused]] std::string_view max_value) {
ctx.AddF32("{}=clamp({},{},{});", inst, value, min_value, max_value);
ctx.AddF32("{}=clamp({},float({}),float({}));", inst, value, min_value, max_value);
}
void EmitFPClamp64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
[[maybe_unused]] std::string_view value,
[[maybe_unused]] std::string_view min_value,
[[maybe_unused]] std::string_view max_value) {
ctx.AddF64("{}=clamp({},{},{});", inst, value, min_value, max_value);
ctx.AddF64("{}=clamp({},double({}),double({}));", inst, value, min_value, max_value);
}
void EmitFPRoundEven16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
@ -259,7 +259,7 @@ void EmitFPOrdEqual16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::In
void EmitFPOrdEqual32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
[[maybe_unused]] std::string_view lhs,
[[maybe_unused]] std::string_view rhs) {
throw NotImplementedException("GLSL");
ctx.AddU1("{}={}=={};", inst, lhs, rhs);
}
void EmitFPOrdEqual64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,

View File

@ -525,10 +525,10 @@ void EmitGlobalAtomicMinF16x2(EmitContext& ctx);
void EmitGlobalAtomicMinF32x2(EmitContext& ctx);
void EmitGlobalAtomicMaxF16x2(EmitContext& ctx);
void EmitGlobalAtomicMaxF32x2(EmitContext& ctx);
void EmitLogicalOr(EmitContext& ctx, std::string_view a, std::string_view b);
void EmitLogicalAnd(EmitContext& ctx, std::string_view a, std::string_view b);
void EmitLogicalXor(EmitContext& ctx, std::string_view a, std::string_view b);
void EmitLogicalNot(EmitContext& ctx, std::string_view value);
void EmitLogicalOr(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b);
void EmitLogicalAnd(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b);
void EmitLogicalXor(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b);
void EmitLogicalNot(EmitContext& ctx, IR::Inst& inst, std::string_view value);
void EmitConvertS16F16(EmitContext& ctx, IR::Inst& inst, std::string_view value);
void EmitConvertS16F32(EmitContext& ctx, IR::Inst& inst, std::string_view value);
void EmitConvertS16F64(EmitContext& ctx, IR::Inst& inst, std::string_view value);

View File

@ -0,0 +1,29 @@
// 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"
#include "shader_recompiler/profile.h"
namespace Shader::Backend::GLSL {
void EmitLogicalOr(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
ctx.AddU1("{}={}||{};", inst, a, b);
}
void EmitLogicalAnd(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
ctx.AddU1("{}={}&&{};", inst, a, b);
}
void EmitLogicalXor(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
ctx.AddU1("{}={}^^{};", inst, a, b);
}
void EmitLogicalNot(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
ctx.AddU1("{}=!{};", inst, value);
}
} // namespace Shader::Backend::GLSL

View File

@ -690,22 +690,6 @@ void EmitGlobalAtomicMaxF32x2(EmitContext& ctx) {
NotImplemented();
}
void EmitLogicalOr(EmitContext& ctx, std::string_view a, std::string_view b) {
NotImplemented();
}
void EmitLogicalAnd(EmitContext& ctx, std::string_view a, std::string_view b) {
NotImplemented();
}
void EmitLogicalXor(EmitContext& ctx, std::string_view a, std::string_view b) {
NotImplemented();
}
void EmitLogicalNot(EmitContext& ctx, std::string_view value) {
NotImplemented();
}
void EmitBindlessImageSampleImplicitLod(EmitContext&) {
NotImplemented();
}

View File

@ -30,11 +30,11 @@ std::string MakeImm(const IR::Value& value) {
case IR::Type::U1:
return fmt::format("{}", value.U1() ? "true" : "false");
case IR::Type::U32:
return fmt::format("{}", value.U32());
return fmt::format("{}u", value.U32());
case IR::Type::F32:
return fmt::format("{}", value.F32());
return fmt::format("{}f", value.F32());
case IR::Type::U64:
return fmt::format("{}", value.U64());
return fmt::format("{}ul", value.U64());
case IR::Type::F64:
return fmt::format("{}", value.F64());
default: