2022-04-23 10:59:50 +02:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2021-05-22 07:52:03 +02:00
|
|
|
|
|
|
|
#include <string_view>
|
|
|
|
|
2021-05-29 08:09:29 +02:00
|
|
|
#include "shader_recompiler/backend/glsl/emit_glsl_instructions.h"
|
2021-12-05 22:42:03 +01:00
|
|
|
#include "shader_recompiler/backend/glsl/glsl_emit_context.h"
|
2021-05-22 07:52:03 +02:00
|
|
|
#include "shader_recompiler/frontend/ir/value.h"
|
|
|
|
|
|
|
|
namespace Shader::Backend::GLSL {
|
|
|
|
void EmitConvertS16F16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
|
|
|
[[maybe_unused]] std::string_view value) {
|
2021-05-31 18:53:40 +02:00
|
|
|
NotImplemented();
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 06:29:19 +02:00
|
|
|
void EmitConvertS16F32(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
2021-06-11 06:41:28 +02:00
|
|
|
ctx.AddU32("{}=(int({})&0xffff)|(bitfieldExtract(int({}),31,1)<<15);", inst, value, value);
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EmitConvertS16F64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
|
|
|
[[maybe_unused]] std::string_view value) {
|
2021-05-31 18:53:40 +02:00
|
|
|
NotImplemented();
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EmitConvertS32F16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
|
|
|
[[maybe_unused]] std::string_view value) {
|
2021-05-31 18:53:40 +02:00
|
|
|
NotImplemented();
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 06:29:19 +02:00
|
|
|
void EmitConvertS32F32(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
2021-06-11 06:41:28 +02:00
|
|
|
ctx.AddU32("{}=int({});", inst, value);
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 06:29:19 +02:00
|
|
|
void EmitConvertS32F64(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
2021-06-11 06:41:28 +02:00
|
|
|
ctx.AddU32("{}=int({});", inst, value);
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EmitConvertS64F16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
|
|
|
[[maybe_unused]] std::string_view value) {
|
2021-05-31 18:53:40 +02:00
|
|
|
NotImplemented();
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 06:29:19 +02:00
|
|
|
void EmitConvertS64F32(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
2021-06-12 07:36:33 +02:00
|
|
|
ctx.AddU64("{}=int64_t({});", inst, value);
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 06:29:19 +02:00
|
|
|
void EmitConvertS64F64(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
2021-06-11 06:41:28 +02:00
|
|
|
ctx.AddU64("{}=int64_t({});", inst, value);
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EmitConvertU16F16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
|
|
|
[[maybe_unused]] std::string_view value) {
|
2021-05-31 18:53:40 +02:00
|
|
|
NotImplemented();
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EmitConvertU16F32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
|
|
|
[[maybe_unused]] std::string_view value) {
|
2021-05-31 18:53:40 +02:00
|
|
|
NotImplemented();
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EmitConvertU16F64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
|
|
|
[[maybe_unused]] std::string_view value) {
|
2021-05-31 18:53:40 +02:00
|
|
|
NotImplemented();
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EmitConvertU32F16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
|
|
|
[[maybe_unused]] std::string_view value) {
|
2021-05-31 18:53:40 +02:00
|
|
|
NotImplemented();
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 06:29:19 +02:00
|
|
|
void EmitConvertU32F32(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
2021-06-11 06:33:33 +02:00
|
|
|
ctx.AddU32("{}=uint({});", inst, value);
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 06:29:19 +02:00
|
|
|
void EmitConvertU32F64(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
2021-06-11 06:33:33 +02:00
|
|
|
ctx.AddU32("{}=uint({});", inst, value);
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EmitConvertU64F16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
|
|
|
[[maybe_unused]] std::string_view value) {
|
2021-05-31 18:53:40 +02:00
|
|
|
NotImplemented();
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 06:29:19 +02:00
|
|
|
void EmitConvertU64F32(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
2021-06-11 06:33:33 +02:00
|
|
|
ctx.AddU64("{}=uint64_t({});", inst, value);
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 06:29:19 +02:00
|
|
|
void EmitConvertU64F64(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
2021-06-11 06:33:33 +02:00
|
|
|
ctx.AddU64("{}=uint64_t({});", inst, value);
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 06:29:19 +02:00
|
|
|
void EmitConvertU64U32(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
2021-06-11 06:33:33 +02:00
|
|
|
ctx.AddU64("{}=uint64_t({});", inst, value);
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 06:29:19 +02:00
|
|
|
void EmitConvertU32U64(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
2021-06-11 06:33:33 +02:00
|
|
|
ctx.AddU32("{}=uint({});", inst, value);
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EmitConvertF16F32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
|
|
|
[[maybe_unused]] std::string_view value) {
|
2021-05-31 18:53:40 +02:00
|
|
|
NotImplemented();
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EmitConvertF32F16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
|
|
|
[[maybe_unused]] std::string_view value) {
|
2021-05-31 18:53:40 +02:00
|
|
|
NotImplemented();
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 06:29:19 +02:00
|
|
|
void EmitConvertF32F64(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
2021-06-11 06:33:33 +02:00
|
|
|
ctx.AddF32("{}=float({});", inst, value);
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 06:29:19 +02:00
|
|
|
void EmitConvertF64F32(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
2021-06-11 06:33:33 +02:00
|
|
|
ctx.AddF64("{}=double({});", inst, value);
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EmitConvertF16S8([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
|
|
|
[[maybe_unused]] std::string_view value) {
|
2021-05-31 18:53:40 +02:00
|
|
|
NotImplemented();
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EmitConvertF16S16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
|
|
|
[[maybe_unused]] std::string_view value) {
|
2021-05-31 18:53:40 +02:00
|
|
|
NotImplemented();
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EmitConvertF16S32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
|
|
|
[[maybe_unused]] std::string_view value) {
|
2021-05-31 18:53:40 +02:00
|
|
|
NotImplemented();
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EmitConvertF16S64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
|
|
|
[[maybe_unused]] std::string_view value) {
|
2021-05-31 18:53:40 +02:00
|
|
|
NotImplemented();
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EmitConvertF16U8([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
|
|
|
[[maybe_unused]] std::string_view value) {
|
2021-05-31 18:53:40 +02:00
|
|
|
NotImplemented();
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EmitConvertF16U16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
|
|
|
[[maybe_unused]] std::string_view value) {
|
2021-05-31 18:53:40 +02:00
|
|
|
NotImplemented();
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EmitConvertF16U32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
|
|
|
[[maybe_unused]] std::string_view value) {
|
2021-05-31 18:53:40 +02:00
|
|
|
NotImplemented();
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EmitConvertF16U64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
|
|
|
[[maybe_unused]] std::string_view value) {
|
2021-05-31 18:53:40 +02:00
|
|
|
NotImplemented();
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EmitConvertF32S8([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
|
|
|
[[maybe_unused]] std::string_view value) {
|
2021-05-31 18:53:40 +02:00
|
|
|
NotImplemented();
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EmitConvertF32S16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
|
|
|
[[maybe_unused]] std::string_view value) {
|
2021-05-31 18:53:40 +02:00
|
|
|
NotImplemented();
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 06:29:19 +02:00
|
|
|
void EmitConvertF32S32(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
2021-05-28 22:32:01 +02:00
|
|
|
ctx.AddF32("{}=float(int({}));", inst, value);
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 06:29:19 +02:00
|
|
|
void EmitConvertF32S64(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
2021-06-11 06:33:33 +02:00
|
|
|
ctx.AddF32("{}=float(int64_t({}));", inst, value);
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EmitConvertF32U8([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
|
|
|
[[maybe_unused]] std::string_view value) {
|
2021-05-31 18:53:40 +02:00
|
|
|
NotImplemented();
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 06:29:19 +02:00
|
|
|
void EmitConvertF32U16(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
2021-06-11 06:33:33 +02:00
|
|
|
ctx.AddF32("{}=float({}&0xffff);", inst, value);
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 06:29:19 +02:00
|
|
|
void EmitConvertF32U32(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
2021-06-11 06:33:33 +02:00
|
|
|
ctx.AddF32("{}=float({});", inst, value);
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 06:29:19 +02:00
|
|
|
void EmitConvertF32U64(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
2021-06-11 06:33:33 +02:00
|
|
|
ctx.AddF32("{}=float({});", inst, value);
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EmitConvertF64S8([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
|
|
|
[[maybe_unused]] std::string_view value) {
|
2021-05-31 18:53:40 +02:00
|
|
|
NotImplemented();
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EmitConvertF64S16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
|
|
|
[[maybe_unused]] std::string_view value) {
|
2021-05-31 18:53:40 +02:00
|
|
|
NotImplemented();
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 06:29:19 +02:00
|
|
|
void EmitConvertF64S32(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
2021-05-28 22:32:01 +02:00
|
|
|
ctx.AddF64("{}=double(int({}));", inst, value);
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 06:29:19 +02:00
|
|
|
void EmitConvertF64S64(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
2021-05-28 22:32:01 +02:00
|
|
|
ctx.AddF64("{}=double(int64_t({}));", inst, value);
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EmitConvertF64U8([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
|
|
|
[[maybe_unused]] std::string_view value) {
|
2021-05-31 18:53:40 +02:00
|
|
|
NotImplemented();
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EmitConvertF64U16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
|
|
|
[[maybe_unused]] std::string_view value) {
|
2021-05-31 18:53:40 +02:00
|
|
|
NotImplemented();
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 06:29:19 +02:00
|
|
|
void EmitConvertF64U32(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
2021-06-11 06:33:33 +02:00
|
|
|
ctx.AddF64("{}=double({});", inst, value);
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 06:29:19 +02:00
|
|
|
void EmitConvertF64U64(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
2021-06-11 06:33:33 +02:00
|
|
|
ctx.AddF64("{}=double({});", inst, value);
|
2021-05-22 07:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Shader::Backend::GLSL
|