2021-02-19 16:10:18 -05: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"
|
|
|
|
|
|
|
|
namespace Shader::Backend::SPIRV {
|
|
|
|
|
|
|
|
Id EmitConvertS16F16(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpUConvert(ctx.U32[1], ctx.OpConvertFToS(ctx.U16, value));
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertS16F32(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpUConvert(ctx.U32[1], ctx.OpConvertFToS(ctx.U16, value));
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertS16F64(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpUConvert(ctx.U32[1], ctx.OpConvertFToS(ctx.U16, value));
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertS32F16(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertFToS(ctx.U32[1], value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertS32F32(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertFToS(ctx.U32[1], value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertS32F64(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertFToS(ctx.U32[1], value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertS64F16(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertFToS(ctx.U64, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertS64F32(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertFToS(ctx.U64, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertS64F64(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertFToS(ctx.U64, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertU16F16(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpUConvert(ctx.U32[1], ctx.OpConvertFToU(ctx.U16, value));
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertU16F32(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpUConvert(ctx.U32[1], ctx.OpConvertFToU(ctx.U16, value));
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertU16F64(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpUConvert(ctx.U32[1], ctx.OpConvertFToU(ctx.U16, value));
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertU32F16(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertFToU(ctx.U32[1], value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertU32F32(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertFToU(ctx.U32[1], value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertU32F64(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertFToU(ctx.U32[1], value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertU64F16(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertFToU(ctx.U64, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertU64F32(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertFToU(ctx.U64, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertU64F64(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertFToU(ctx.U64, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertU64U32(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpUConvert(ctx.U64, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertU32U64(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpUConvert(ctx.U32[1], value);
|
|
|
|
}
|
|
|
|
|
2021-03-03 01:07:19 -05:00
|
|
|
Id EmitConvertF16F32(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpFConvert(ctx.F16[1], value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertF32F16(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpFConvert(ctx.F32[1], value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertF32F64(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpFConvert(ctx.F32[1], value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertF64F32(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpFConvert(ctx.F64[1], value);
|
|
|
|
}
|
|
|
|
|
2021-03-20 04:04:12 -04:00
|
|
|
Id EmitConvertF16S8(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertSToF(ctx.F16[1], value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertF16S16(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertSToF(ctx.F16[1], value);
|
|
|
|
}
|
|
|
|
|
2021-03-08 16:31:53 -05:00
|
|
|
Id EmitConvertF16S32(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertSToF(ctx.F16[1], value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertF16S64(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertSToF(ctx.F16[1], value);
|
|
|
|
}
|
|
|
|
|
2021-03-20 04:04:12 -04:00
|
|
|
Id EmitConvertF16U8(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertUToF(ctx.F16[1], value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertF16U16(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertUToF(ctx.F16[1], value);
|
|
|
|
}
|
|
|
|
|
2021-03-08 16:31:53 -05:00
|
|
|
Id EmitConvertF16U32(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertUToF(ctx.F16[1], value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertF16U64(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertUToF(ctx.F16[1], value);
|
|
|
|
}
|
|
|
|
|
2021-03-20 04:04:12 -04:00
|
|
|
Id EmitConvertF32S8(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertSToF(ctx.F32[1], ctx.OpUConvert(ctx.U8, value));
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertF32S16(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertSToF(ctx.F32[1], ctx.OpUConvert(ctx.U16, value));
|
|
|
|
}
|
|
|
|
|
2021-03-08 16:31:53 -05:00
|
|
|
Id EmitConvertF32S32(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertSToF(ctx.F32[1], value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertF32S64(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertSToF(ctx.F32[1], value);
|
|
|
|
}
|
|
|
|
|
2021-03-20 04:04:12 -04:00
|
|
|
Id EmitConvertF32U8(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertUToF(ctx.F32[1], ctx.OpUConvert(ctx.U8, value));
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertF32U16(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertUToF(ctx.F32[1], ctx.OpUConvert(ctx.U16, value));
|
|
|
|
}
|
|
|
|
|
2021-03-08 16:31:53 -05:00
|
|
|
Id EmitConvertF32U32(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertUToF(ctx.F32[1], value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertF32U64(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertUToF(ctx.F32[1], value);
|
|
|
|
}
|
|
|
|
|
2021-03-20 04:04:12 -04:00
|
|
|
Id EmitConvertF64S8(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertSToF(ctx.F64[1], ctx.OpUConvert(ctx.U8, value));
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertF64S16(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertSToF(ctx.F64[1], ctx.OpUConvert(ctx.U16, value));
|
|
|
|
}
|
|
|
|
|
2021-03-08 16:31:53 -05:00
|
|
|
Id EmitConvertF64S32(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertSToF(ctx.F64[1], value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertF64S64(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertSToF(ctx.F64[1], value);
|
|
|
|
}
|
|
|
|
|
2021-03-20 04:04:12 -04:00
|
|
|
Id EmitConvertF64U8(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertUToF(ctx.F64[1], ctx.OpUConvert(ctx.U8, value));
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertF64U16(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertUToF(ctx.F64[1], ctx.OpUConvert(ctx.U16, value));
|
|
|
|
}
|
|
|
|
|
2021-03-08 16:31:53 -05:00
|
|
|
Id EmitConvertF64U32(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertUToF(ctx.F64[1], value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Id EmitConvertF64U64(EmitContext& ctx, Id value) {
|
|
|
|
return ctx.OpConvertUToF(ctx.F64[1], value);
|
|
|
|
}
|
|
|
|
|
2021-02-19 16:10:18 -05:00
|
|
|
} // namespace Shader::Backend::SPIRV
|