2021-02-08 05:54:35 +00:00
|
|
|
// Copyright 2021 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include "shader_recompiler/backend/spirv/emit_spirv.h"
|
|
|
|
#include "shader_recompiler/frontend/ir/modifiers.h"
|
|
|
|
|
|
|
|
namespace Shader::Backend::SPIRV {
|
|
|
|
namespace {
|
|
|
|
Id Decorate(EmitContext& ctx, IR::Inst* inst, Id op) {
|
|
|
|
const auto flags{inst->Flags<IR::FpControl>()};
|
|
|
|
if (flags.no_contraction) {
|
|
|
|
ctx.Decorate(op, spv::Decoration::NoContraction);
|
|
|
|
}
|
|
|
|
switch (flags.rounding) {
|
|
|
|
case IR::FpRounding::RN:
|
|
|
|
break;
|
|
|
|
case IR::FpRounding::RM:
|
|
|
|
ctx.Decorate(op, spv::Decoration::FPRoundingMode, spv::FPRoundingMode::RTN);
|
|
|
|
break;
|
|
|
|
case IR::FpRounding::RP:
|
|
|
|
ctx.Decorate(op, spv::Decoration::FPRoundingMode, spv::FPRoundingMode::RTP);
|
|
|
|
break;
|
|
|
|
case IR::FpRounding::RZ:
|
|
|
|
ctx.Decorate(op, spv::Decoration::FPRoundingMode, spv::FPRoundingMode::RTZ);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (flags.fmz_mode != IR::FmzMode::FTZ) {
|
|
|
|
throw NotImplementedException("Denorm management not implemented");
|
|
|
|
}
|
|
|
|
return op;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // Anonymous namespace
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
void EmitFPAbs16(EmitContext&) {
|
2021-02-08 05:54:35 +00:00
|
|
|
throw NotImplementedException("SPIR-V Instruction");
|
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
void EmitFPAbs32(EmitContext&) {
|
2021-02-08 05:54:35 +00:00
|
|
|
throw NotImplementedException("SPIR-V Instruction");
|
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
void EmitFPAbs64(EmitContext&) {
|
2021-02-08 05:54:35 +00:00
|
|
|
throw NotImplementedException("SPIR-V Instruction");
|
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
Id EmitFPAdd16(EmitContext& ctx, IR::Inst* inst, Id a, Id b) {
|
2021-02-16 07:10:22 +00:00
|
|
|
return Decorate(ctx, inst, ctx.OpFAdd(ctx.F16[1], a, b));
|
2021-02-08 05:54:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
Id EmitFPAdd32(EmitContext& ctx, IR::Inst* inst, Id a, Id b) {
|
2021-02-16 07:10:22 +00:00
|
|
|
return Decorate(ctx, inst, ctx.OpFAdd(ctx.F32[1], a, b));
|
2021-02-08 05:54:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
Id EmitFPAdd64(EmitContext& ctx, IR::Inst* inst, Id a, Id b) {
|
2021-02-16 07:10:22 +00:00
|
|
|
return Decorate(ctx, inst, ctx.OpFAdd(ctx.F64[1], a, b));
|
2021-02-08 05:54:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
Id EmitFPFma16(EmitContext& ctx, IR::Inst* inst, Id a, Id b, Id c) {
|
2021-02-16 07:10:22 +00:00
|
|
|
return Decorate(ctx, inst, ctx.OpFma(ctx.F16[1], a, b, c));
|
2021-02-08 05:54:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
Id EmitFPFma32(EmitContext& ctx, IR::Inst* inst, Id a, Id b, Id c) {
|
2021-02-16 07:10:22 +00:00
|
|
|
return Decorate(ctx, inst, ctx.OpFma(ctx.F32[1], a, b, c));
|
2021-02-08 05:54:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
Id EmitFPFma64(EmitContext& ctx, IR::Inst* inst, Id a, Id b, Id c) {
|
2021-02-16 07:10:22 +00:00
|
|
|
return Decorate(ctx, inst, ctx.OpFma(ctx.F64[1], a, b, c));
|
2021-02-08 05:54:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
void EmitFPMax32(EmitContext&) {
|
2021-02-08 05:54:35 +00:00
|
|
|
throw NotImplementedException("SPIR-V Instruction");
|
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
void EmitFPMax64(EmitContext&) {
|
2021-02-08 05:54:35 +00:00
|
|
|
throw NotImplementedException("SPIR-V Instruction");
|
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
void EmitFPMin32(EmitContext&) {
|
2021-02-08 05:54:35 +00:00
|
|
|
throw NotImplementedException("SPIR-V Instruction");
|
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
void EmitFPMin64(EmitContext&) {
|
2021-02-08 05:54:35 +00:00
|
|
|
throw NotImplementedException("SPIR-V Instruction");
|
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
Id EmitFPMul16(EmitContext& ctx, IR::Inst* inst, Id a, Id b) {
|
2021-02-16 07:10:22 +00:00
|
|
|
return Decorate(ctx, inst, ctx.OpFMul(ctx.F16[1], a, b));
|
2021-02-08 05:54:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
Id EmitFPMul32(EmitContext& ctx, IR::Inst* inst, Id a, Id b) {
|
2021-02-16 07:10:22 +00:00
|
|
|
return Decorate(ctx, inst, ctx.OpFMul(ctx.F32[1], a, b));
|
2021-02-08 05:54:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
Id EmitFPMul64(EmitContext& ctx, IR::Inst* inst, Id a, Id b) {
|
2021-02-16 07:10:22 +00:00
|
|
|
return Decorate(ctx, inst, ctx.OpFMul(ctx.F64[1], a, b));
|
2021-02-08 05:54:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
void EmitFPNeg16(EmitContext&) {
|
2021-02-08 05:54:35 +00:00
|
|
|
throw NotImplementedException("SPIR-V Instruction");
|
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
void EmitFPNeg32(EmitContext&) {
|
2021-02-08 05:54:35 +00:00
|
|
|
throw NotImplementedException("SPIR-V Instruction");
|
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
void EmitFPNeg64(EmitContext&) {
|
2021-02-08 05:54:35 +00:00
|
|
|
throw NotImplementedException("SPIR-V Instruction");
|
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
void EmitFPRecip32(EmitContext&) {
|
2021-02-08 05:54:35 +00:00
|
|
|
throw NotImplementedException("SPIR-V Instruction");
|
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
void EmitFPRecip64(EmitContext&) {
|
2021-02-08 05:54:35 +00:00
|
|
|
throw NotImplementedException("SPIR-V Instruction");
|
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
void EmitFPRecipSqrt32(EmitContext&) {
|
2021-02-08 05:54:35 +00:00
|
|
|
throw NotImplementedException("SPIR-V Instruction");
|
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
void EmitFPRecipSqrt64(EmitContext&) {
|
2021-02-08 05:54:35 +00:00
|
|
|
throw NotImplementedException("SPIR-V Instruction");
|
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
void EmitFPSqrt(EmitContext&) {
|
2021-02-08 05:54:35 +00:00
|
|
|
throw NotImplementedException("SPIR-V Instruction");
|
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
void EmitFPSin(EmitContext&) {
|
2021-02-08 05:54:35 +00:00
|
|
|
throw NotImplementedException("SPIR-V Instruction");
|
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
void EmitFPSinNotReduced(EmitContext&) {
|
2021-02-08 05:54:35 +00:00
|
|
|
throw NotImplementedException("SPIR-V Instruction");
|
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
void EmitFPExp2(EmitContext&) {
|
2021-02-08 05:54:35 +00:00
|
|
|
throw NotImplementedException("SPIR-V Instruction");
|
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
void EmitFPExp2NotReduced(EmitContext&) {
|
2021-02-08 05:54:35 +00:00
|
|
|
throw NotImplementedException("SPIR-V Instruction");
|
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
void EmitFPCos(EmitContext&) {
|
2021-02-08 05:54:35 +00:00
|
|
|
throw NotImplementedException("SPIR-V Instruction");
|
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
void EmitFPCosNotReduced(EmitContext&) {
|
2021-02-08 05:54:35 +00:00
|
|
|
throw NotImplementedException("SPIR-V Instruction");
|
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
void EmitFPLog2(EmitContext&) {
|
2021-02-08 05:54:35 +00:00
|
|
|
throw NotImplementedException("SPIR-V Instruction");
|
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
void EmitFPSaturate16(EmitContext&) {
|
2021-02-08 05:54:35 +00:00
|
|
|
throw NotImplementedException("SPIR-V Instruction");
|
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
void EmitFPSaturate32(EmitContext&) {
|
2021-02-08 05:54:35 +00:00
|
|
|
throw NotImplementedException("SPIR-V Instruction");
|
|
|
|
}
|
|
|
|
|
2021-02-17 03:59:28 +00:00
|
|
|
void EmitFPSaturate64(EmitContext&) {
|
2021-02-08 05:54:35 +00:00
|
|
|
throw NotImplementedException("SPIR-V Instruction");
|
|
|
|
}
|
|
|
|
|
2021-02-19 21:10:18 +00:00
|
|
|
Id EmitFPRoundEven16(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpRoundEven(ctx.F16[1], value);
|
2021-02-08 05:54:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-19 21:10:18 +00:00
|
|
|
Id EmitFPRoundEven32(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpRoundEven(ctx.F32[1], value);
|
2021-02-08 05:54:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-19 21:10:18 +00:00
|
|
|
Id EmitFPRoundEven64(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpRoundEven(ctx.F64[1], value);
|
2021-02-08 05:54:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-19 21:10:18 +00:00
|
|
|
Id EmitFPFloor16(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpFloor(ctx.F16[1], value);
|
2021-02-08 05:54:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-19 21:10:18 +00:00
|
|
|
Id EmitFPFloor32(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpFloor(ctx.F32[1], value);
|
2021-02-08 05:54:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-19 21:10:18 +00:00
|
|
|
Id EmitFPFloor64(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpFloor(ctx.F64[1], value);
|
2021-02-08 05:54:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-19 21:10:18 +00:00
|
|
|
Id EmitFPCeil16(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpCeil(ctx.F16[1], value);
|
2021-02-08 05:54:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-19 21:10:18 +00:00
|
|
|
Id EmitFPCeil32(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpCeil(ctx.F32[1], value);
|
2021-02-08 05:54:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-19 21:10:18 +00:00
|
|
|
Id EmitFPCeil64(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpCeil(ctx.F64[1], value);
|
2021-02-08 05:54:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-19 21:10:18 +00:00
|
|
|
Id EmitFPTrunc16(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpTrunc(ctx.F16[1], value);
|
2021-02-08 05:54:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-19 21:10:18 +00:00
|
|
|
Id EmitFPTrunc32(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpTrunc(ctx.F32[1], value);
|
2021-02-08 05:54:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-19 21:10:18 +00:00
|
|
|
Id EmitFPTrunc64(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpTrunc(ctx.F64[1], value);
|
2021-02-08 05:54:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Shader::Backend::SPIRV
|