committed by
ameerj
21 changed files with 1401 additions and 3300 deletions
-
2externals/sirit
-
15src/shader_recompiler/CMakeLists.txt
-
134src/shader_recompiler/backend/spirv/emit_spirv.cpp
-
314src/shader_recompiler/backend/spirv/emit_spirv.h
-
57src/shader_recompiler/backend/spirv/emit_spirv_bitwise_conversion.cpp
-
105src/shader_recompiler/backend/spirv/emit_spirv_composite.cpp
-
102src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp
-
30src/shader_recompiler/backend/spirv/emit_spirv_control_flow.cpp
-
220src/shader_recompiler/backend/spirv/emit_spirv_floating_point.cpp
-
132src/shader_recompiler/backend/spirv/emit_spirv_integer.cpp
-
89src/shader_recompiler/backend/spirv/emit_spirv_logical.cpp
-
125src/shader_recompiler/backend/spirv/emit_spirv_memory.cpp
-
25src/shader_recompiler/backend/spirv/emit_spirv_select.cpp
-
29src/shader_recompiler/backend/spirv/emit_spirv_undefined.cpp
-
12src/shader_recompiler/frontend/ir/ir_emitter.cpp
-
12src/shader_recompiler/frontend/ir/opcodes.inc
-
10src/shader_recompiler/frontend/maxwell/translate/translate.cpp
-
2src/shader_recompiler/ir_opt/identity_removal_pass.cpp
-
21src/shader_recompiler/main.cpp
-
3166src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
-
99src/video_core/renderer_vulkan/vk_shader_decompiler.h
@ -1 +1 @@ |
|||||
Subproject commit eefca56afd49379bdebc97ded8b480839f930881 |
|
||||
|
Subproject commit 1f7b70730d610cfbd5099ab93dd38ec8a78e7e35 |
||||
@ -0,0 +1,134 @@ |
|||||
|
// Copyright 2021 yuzu Emulator Project
|
||||
|
// Licensed under GPLv2 or any later version
|
||||
|
// Refer to the license.txt file included.
|
||||
|
|
||||
|
#include <numeric>
|
||||
|
#include <type_traits>
|
||||
|
|
||||
|
#include "shader_recompiler/backend/spirv/emit_spirv.h"
|
||||
|
#include "shader_recompiler/frontend/ir/basic_block.h"
|
||||
|
#include "shader_recompiler/frontend/ir/function.h"
|
||||
|
#include "shader_recompiler/frontend/ir/microinstruction.h"
|
||||
|
#include "shader_recompiler/frontend/ir/program.h"
|
||||
|
|
||||
|
namespace Shader::Backend::SPIRV { |
||||
|
|
||||
|
EmitContext::EmitContext(IR::Program& program) { |
||||
|
AddCapability(spv::Capability::Shader); |
||||
|
AddCapability(spv::Capability::Float16); |
||||
|
AddCapability(spv::Capability::Float64); |
||||
|
void_id = TypeVoid(); |
||||
|
|
||||
|
u1 = Name(TypeBool(), "u1"); |
||||
|
f32.Define(*this, TypeFloat(32), "f32"); |
||||
|
u32.Define(*this, TypeInt(32, false), "u32"); |
||||
|
f16.Define(*this, TypeFloat(16), "f16"); |
||||
|
f64.Define(*this, TypeFloat(64), "f64"); |
||||
|
|
||||
|
for (const IR::Function& function : program.functions) { |
||||
|
for (IR::Block* const block : function.blocks) { |
||||
|
block_label_map.emplace_back(block, OpLabel()); |
||||
|
} |
||||
|
} |
||||
|
std::ranges::sort(block_label_map, {}, &std::pair<IR::Block*, Id>::first); |
||||
|
} |
||||
|
|
||||
|
EmitContext::~EmitContext() = default; |
||||
|
|
||||
|
EmitSPIRV::EmitSPIRV(IR::Program& program) { |
||||
|
EmitContext ctx{program}; |
||||
|
const Id void_function{ctx.TypeFunction(ctx.void_id)}; |
||||
|
// FIXME: Forward declare functions (needs sirit support)
|
||||
|
Id func{}; |
||||
|
for (IR::Function& function : program.functions) { |
||||
|
func = ctx.OpFunction(ctx.void_id, spv::FunctionControlMask::MaskNone, void_function); |
||||
|
for (IR::Block* const block : function.blocks) { |
||||
|
ctx.AddLabel(ctx.BlockLabel(block)); |
||||
|
for (IR::Inst& inst : block->Instructions()) { |
||||
|
EmitInst(ctx, &inst); |
||||
|
} |
||||
|
} |
||||
|
ctx.OpFunctionEnd(); |
||||
|
} |
||||
|
ctx.AddEntryPoint(spv::ExecutionModel::GLCompute, func, "main"); |
||||
|
|
||||
|
std::vector<u32> result{ctx.Assemble()}; |
||||
|
std::FILE* file{std::fopen("shader.spv", "wb")}; |
||||
|
std::fwrite(result.data(), sizeof(u32), result.size(), file); |
||||
|
std::fclose(file); |
||||
|
std::system("spirv-dis shader.spv"); |
||||
|
std::system("spirv-val shader.spv"); |
||||
|
} |
||||
|
|
||||
|
template <auto method> |
||||
|
static void Invoke(EmitSPIRV& emit, EmitContext& ctx, IR::Inst* inst) { |
||||
|
using M = decltype(method); |
||||
|
using std::is_invocable_r_v; |
||||
|
if constexpr (is_invocable_r_v<Id, M, EmitSPIRV&, EmitContext&>) { |
||||
|
ctx.Define(inst, (emit.*method)(ctx)); |
||||
|
} else if constexpr (is_invocable_r_v<Id, M, EmitSPIRV&, EmitContext&, Id>) { |
||||
|
ctx.Define(inst, (emit.*method)(ctx, ctx.Def(inst->Arg(0)))); |
||||
|
} else if constexpr (is_invocable_r_v<Id, M, EmitSPIRV&, EmitContext&, Id, Id>) { |
||||
|
ctx.Define(inst, (emit.*method)(ctx, ctx.Def(inst->Arg(0)), ctx.Def(inst->Arg(1)))); |
||||
|
} else if constexpr (is_invocable_r_v<Id, M, EmitSPIRV&, EmitContext&, Id, Id, Id>) { |
||||
|
ctx.Define(inst, (emit.*method)(ctx, ctx.Def(inst->Arg(0)), ctx.Def(inst->Arg(1)), |
||||
|
ctx.Def(inst->Arg(2)))); |
||||
|
} else if constexpr (is_invocable_r_v<Id, M, EmitSPIRV&, EmitContext&, IR::Inst*, Id, Id>) { |
||||
|
ctx.Define(inst, (emit.*method)(ctx, inst, ctx.Def(inst->Arg(0)), ctx.Def(inst->Arg(1)))); |
||||
|
} else if constexpr (is_invocable_r_v<Id, M, EmitSPIRV&, EmitContext&, IR::Inst*, Id, Id, Id>) { |
||||
|
ctx.Define(inst, (emit.*method)(ctx, inst, ctx.Def(inst->Arg(0)), ctx.Def(inst->Arg(1)), |
||||
|
ctx.Def(inst->Arg(2)))); |
||||
|
} else if constexpr (is_invocable_r_v<Id, M, EmitSPIRV&, EmitContext&, Id, u32>) { |
||||
|
ctx.Define(inst, (emit.*method)(ctx, ctx.Def(inst->Arg(0)), inst->Arg(1).U32())); |
||||
|
} else if constexpr (is_invocable_r_v<Id, M, EmitSPIRV&, EmitContext&, const IR::Value&>) { |
||||
|
ctx.Define(inst, (emit.*method)(ctx, inst->Arg(0))); |
||||
|
} else if constexpr (is_invocable_r_v<Id, M, EmitSPIRV&, EmitContext&, const IR::Value&, |
||||
|
const IR::Value&>) { |
||||
|
ctx.Define(inst, (emit.*method)(ctx, inst->Arg(0), inst->Arg(1))); |
||||
|
} else if constexpr (is_invocable_r_v<void, M, EmitSPIRV&, EmitContext&, IR::Inst*>) { |
||||
|
(emit.*method)(ctx, inst); |
||||
|
} else if constexpr (is_invocable_r_v<void, M, EmitSPIRV&, EmitContext&>) { |
||||
|
(emit.*method)(ctx); |
||||
|
} else { |
||||
|
static_assert(false, "Bad format"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitInst(EmitContext& ctx, IR::Inst* inst) { |
||||
|
switch (inst->Opcode()) { |
||||
|
#define OPCODE(name, result_type, ...) \
|
||||
|
case IR::Opcode::name: \ |
||||
|
return Invoke<&EmitSPIRV::Emit##name>(*this, ctx, inst); |
||||
|
#include "shader_recompiler/frontend/ir/opcodes.inc"
|
||||
|
#undef OPCODE
|
||||
|
} |
||||
|
throw LogicError("Invalid opcode {}", inst->Opcode()); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitPhi(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitVoid(EmitContext&) {} |
||||
|
|
||||
|
void EmitSPIRV::EmitIdentity(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitGetZeroFromOp(EmitContext&) { |
||||
|
throw LogicError("Unreachable instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitGetSignFromOp(EmitContext&) { |
||||
|
throw LogicError("Unreachable instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitGetCarryFromOp(EmitContext&) { |
||||
|
throw LogicError("Unreachable instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitGetOverflowFromOp(EmitContext&) { |
||||
|
throw LogicError("Unreachable instruction"); |
||||
|
} |
||||
|
|
||||
|
} // namespace Shader::Backend::SPIRV
|
||||
@ -0,0 +1,57 @@ |
|||||
|
// 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 { |
||||
|
|
||||
|
void EmitSPIRV::EmitBitCastU16F16(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
Id EmitSPIRV::EmitBitCastU32F32(EmitContext& ctx, Id value) { |
||||
|
return ctx.OpBitcast(ctx.u32[1], value); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitBitCastU64F64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitBitCastF16U16(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
Id EmitSPIRV::EmitBitCastF32U32(EmitContext& ctx, Id value) { |
||||
|
return ctx.OpBitcast(ctx.f32[1], value); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitBitCastF64U64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitPackUint2x32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitUnpackUint2x32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitPackFloat2x16(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitUnpackFloat2x16(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitPackDouble2x32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitUnpackDouble2x32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
} // namespace Shader::Backend::SPIRV
|
||||
@ -0,0 +1,105 @@ |
|||||
|
// 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 { |
||||
|
|
||||
|
void EmitSPIRV::EmitCompositeConstructU32x2(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitCompositeConstructU32x3(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitCompositeConstructU32x4(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitCompositeExtractU32x2(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
Id EmitSPIRV::EmitCompositeExtractU32x3(EmitContext& ctx, Id vector, u32 index) { |
||||
|
return ctx.OpCompositeExtract(ctx.u32[1], vector, index); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitCompositeExtractU32x4(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitCompositeConstructF16x2(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitCompositeConstructF16x3(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitCompositeConstructF16x4(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitCompositeExtractF16x2(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitCompositeExtractF16x3(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitCompositeExtractF16x4(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitCompositeConstructF32x2(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitCompositeConstructF32x3(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitCompositeConstructF32x4(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitCompositeExtractF32x2(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitCompositeExtractF32x3(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitCompositeExtractF32x4(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitCompositeConstructF64x2(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitCompositeConstructF64x3(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitCompositeConstructF64x4(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitCompositeExtractF64x2(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitCompositeExtractF64x3(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitCompositeExtractF64x4(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
} // namespace Shader::Backend::SPIRV
|
||||
@ -0,0 +1,102 @@ |
|||||
|
// 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 { |
||||
|
|
||||
|
void EmitSPIRV::EmitGetRegister(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitSetRegister(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitGetPred(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitSetPred(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
Id EmitSPIRV::EmitGetCbuf(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset) { |
||||
|
if (!binding.IsImmediate()) { |
||||
|
throw NotImplementedException("Constant buffer indexing"); |
||||
|
} |
||||
|
if (!offset.IsImmediate()) { |
||||
|
throw NotImplementedException("Variable constant buffer offset"); |
||||
|
} |
||||
|
return ctx.Name(ctx.OpUndef(ctx.u32[1]), "unimplemented_cbuf"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitGetAttribute(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitSetAttribute(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitGetAttributeIndexed(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitSetAttributeIndexed(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitGetZFlag(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitGetSFlag(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitGetCFlag(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitGetOFlag(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitSetZFlag(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitSetSFlag(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitSetCFlag(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitSetOFlag(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
Id EmitSPIRV::EmitWorkgroupId(EmitContext& ctx) { |
||||
|
if (ctx.workgroup_id.value == 0) { |
||||
|
ctx.workgroup_id = ctx.AddGlobalVariable( |
||||
|
ctx.TypePointer(spv::StorageClass::Input, ctx.u32[3]), spv::StorageClass::Input); |
||||
|
ctx.Decorate(ctx.workgroup_id, spv::Decoration::BuiltIn, spv::BuiltIn::WorkgroupId); |
||||
|
} |
||||
|
return ctx.OpLoad(ctx.u32[3], ctx.workgroup_id); |
||||
|
} |
||||
|
|
||||
|
Id EmitSPIRV::EmitLocalInvocationId(EmitContext& ctx) { |
||||
|
if (ctx.local_invocation_id.value == 0) { |
||||
|
ctx.local_invocation_id = ctx.AddGlobalVariable( |
||||
|
ctx.TypePointer(spv::StorageClass::Input, ctx.u32[3]), spv::StorageClass::Input); |
||||
|
ctx.Decorate(ctx.local_invocation_id, spv::Decoration::BuiltIn, |
||||
|
spv::BuiltIn::LocalInvocationId); |
||||
|
} |
||||
|
return ctx.OpLoad(ctx.u32[3], ctx.local_invocation_id); |
||||
|
} |
||||
|
|
||||
|
} // namespace Shader::Backend::SPIRV
|
||||
@ -0,0 +1,30 @@ |
|||||
|
// 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 { |
||||
|
|
||||
|
void EmitSPIRV::EmitBranch(EmitContext& ctx, IR::Inst* inst) { |
||||
|
ctx.OpBranch(ctx.BlockLabel(inst->Arg(0).Label())); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitBranchConditional(EmitContext& ctx, IR::Inst* inst) { |
||||
|
ctx.OpBranchConditional(ctx.Def(inst->Arg(0)), ctx.BlockLabel(inst->Arg(1).Label()), |
||||
|
ctx.BlockLabel(inst->Arg(2).Label())); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitExit(EmitContext& ctx) { |
||||
|
ctx.OpReturn(); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitReturn(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitUnreachable(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
} // namespace Shader::Backend::SPIRV
|
||||
@ -0,0 +1,220 @@ |
|||||
|
// 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
|
||||
|
|
||||
|
void EmitSPIRV::EmitFPAbs16(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPAbs32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPAbs64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
Id EmitSPIRV::EmitFPAdd16(EmitContext& ctx, IR::Inst* inst, Id a, Id b) { |
||||
|
return Decorate(ctx, inst, ctx.OpFAdd(ctx.f16[1], a, b)); |
||||
|
} |
||||
|
|
||||
|
Id EmitSPIRV::EmitFPAdd32(EmitContext& ctx, IR::Inst* inst, Id a, Id b) { |
||||
|
return Decorate(ctx, inst, ctx.OpFAdd(ctx.f32[1], a, b)); |
||||
|
} |
||||
|
|
||||
|
Id EmitSPIRV::EmitFPAdd64(EmitContext& ctx, IR::Inst* inst, Id a, Id b) { |
||||
|
return Decorate(ctx, inst, ctx.OpFAdd(ctx.f64[1], a, b)); |
||||
|
} |
||||
|
|
||||
|
Id EmitSPIRV::EmitFPFma16(EmitContext& ctx, IR::Inst* inst, Id a, Id b, Id c) { |
||||
|
return Decorate(ctx, inst, ctx.OpFma(ctx.f16[1], a, b, c)); |
||||
|
} |
||||
|
|
||||
|
Id EmitSPIRV::EmitFPFma32(EmitContext& ctx, IR::Inst* inst, Id a, Id b, Id c) { |
||||
|
return Decorate(ctx, inst, ctx.OpFma(ctx.f32[1], a, b, c)); |
||||
|
} |
||||
|
|
||||
|
Id EmitSPIRV::EmitFPFma64(EmitContext& ctx, IR::Inst* inst, Id a, Id b, Id c) { |
||||
|
return Decorate(ctx, inst, ctx.OpFma(ctx.f64[1], a, b, c)); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPMax32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPMax64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPMin32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPMin64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
Id EmitSPIRV::EmitFPMul16(EmitContext& ctx, IR::Inst* inst, Id a, Id b) { |
||||
|
return Decorate(ctx, inst, ctx.OpFMul(ctx.f16[1], a, b)); |
||||
|
} |
||||
|
|
||||
|
Id EmitSPIRV::EmitFPMul32(EmitContext& ctx, IR::Inst* inst, Id a, Id b) { |
||||
|
return Decorate(ctx, inst, ctx.OpFMul(ctx.f32[1], a, b)); |
||||
|
} |
||||
|
|
||||
|
Id EmitSPIRV::EmitFPMul64(EmitContext& ctx, IR::Inst* inst, Id a, Id b) { |
||||
|
return Decorate(ctx, inst, ctx.OpFMul(ctx.f64[1], a, b)); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPNeg16(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPNeg32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPNeg64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPRecip32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPRecip64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPRecipSqrt32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPRecipSqrt64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPSqrt(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPSin(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPSinNotReduced(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPExp2(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPExp2NotReduced(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPCos(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPCosNotReduced(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPLog2(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPSaturate16(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPSaturate32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPSaturate64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPRoundEven16(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPRoundEven32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPRoundEven64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPFloor16(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPFloor32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPFloor64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPCeil16(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPCeil32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPCeil64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPTrunc16(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPTrunc32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitFPTrunc64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
} // namespace Shader::Backend::SPIRV
|
||||
@ -0,0 +1,132 @@ |
|||||
|
// 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 EmitSPIRV::EmitIAdd32(EmitContext& ctx, IR::Inst* inst, Id a, Id b) { |
||||
|
if (inst->HasAssociatedPseudoOperation()) { |
||||
|
throw NotImplementedException("Pseudo-operations on IAdd32"); |
||||
|
} |
||||
|
return ctx.OpIAdd(ctx.u32[1], a, b); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitIAdd64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
Id EmitSPIRV::EmitISub32(EmitContext& ctx, Id a, Id b) { |
||||
|
return ctx.OpISub(ctx.u32[1], a, b); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitISub64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
Id EmitSPIRV::EmitIMul32(EmitContext& ctx, Id a, Id b) { |
||||
|
return ctx.OpIMul(ctx.u32[1], a, b); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitINeg32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitIAbs32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
Id EmitSPIRV::EmitShiftLeftLogical32(EmitContext& ctx, Id base, Id shift) { |
||||
|
return ctx.OpShiftLeftLogical(ctx.u32[1], base, shift); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitShiftRightLogical32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitShiftRightArithmetic32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitBitwiseAnd32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitBitwiseOr32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitBitwiseXor32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitBitFieldInsert(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitBitFieldSExtract(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
Id EmitSPIRV::EmitBitFieldUExtract(EmitContext& ctx, Id base, Id offset, Id count) { |
||||
|
return ctx.OpBitFieldUExtract(ctx.u32[1], base, offset, count); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitSLessThan(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitULessThan(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitIEqual(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitSLessThanEqual(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitULessThanEqual(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitSGreaterThan(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitUGreaterThan(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitINotEqual(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitSGreaterThanEqual(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
Id EmitSPIRV::EmitUGreaterThanEqual(EmitContext& ctx, Id lhs, Id rhs) { |
||||
|
return ctx.OpUGreaterThanEqual(ctx.u1, lhs, rhs); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitLogicalOr(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitLogicalAnd(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitLogicalXor(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitLogicalNot(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
} // namespace Shader::Backend::SPIRV
|
||||
@ -0,0 +1,89 @@ |
|||||
|
// 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 { |
||||
|
|
||||
|
void EmitSPIRV::EmitConvertS16F16(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitConvertS16F32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitConvertS16F64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitConvertS32F16(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitConvertS32F32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitConvertS32F64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitConvertS64F16(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitConvertS64F32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitConvertS64F64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitConvertU16F16(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitConvertU16F32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitConvertU16F64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitConvertU32F16(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitConvertU32F32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitConvertU32F64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitConvertU64F16(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitConvertU64F32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitConvertU64F64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitConvertU64U32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitConvertU32U64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
} // namespace Shader::Backend::SPIRV
|
||||
@ -0,0 +1,125 @@ |
|||||
|
// 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 { |
||||
|
|
||||
|
void EmitSPIRV::EmitLoadGlobalU8(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitLoadGlobalS8(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitLoadGlobalU16(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitLoadGlobalS16(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitLoadGlobal32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitLoadGlobal64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitLoadGlobal128(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitWriteGlobalU8(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitWriteGlobalS8(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitWriteGlobalU16(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitWriteGlobalS16(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitWriteGlobal32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitWriteGlobal64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitWriteGlobal128(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitLoadStorageU8(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitLoadStorageS8(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitLoadStorageU16(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitLoadStorageS16(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
Id EmitSPIRV::EmitLoadStorage32(EmitContext& ctx, const IR::Value& binding, |
||||
|
[[maybe_unused]] const IR::Value& offset) { |
||||
|
if (!binding.IsImmediate()) { |
||||
|
throw NotImplementedException("Storage buffer indexing"); |
||||
|
} |
||||
|
return ctx.Name(ctx.OpUndef(ctx.u32[1]), "unimplemented_sbuf"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitLoadStorage64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitLoadStorage128(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitWriteStorageU8(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitWriteStorageS8(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitWriteStorageU16(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitWriteStorageS16(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitWriteStorage32(EmitContext& ctx) { |
||||
|
ctx.Name(ctx.OpUndef(ctx.u32[1]), "unimplemented_sbuf_store"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitWriteStorage64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitWriteStorage128(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
} // namespace Shader::Backend::SPIRV
|
||||
@ -0,0 +1,25 @@ |
|||||
|
// 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 { |
||||
|
|
||||
|
void EmitSPIRV::EmitSelect8(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitSelect16(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitSelect32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitSelect64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
} // namespace Shader::Backend::SPIRV
|
||||
@ -0,0 +1,29 @@ |
|||||
|
// 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 { |
||||
|
|
||||
|
void EmitSPIRV::EmitUndef1(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitUndef8(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitUndef16(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitUndef32(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
void EmitSPIRV::EmitUndef64(EmitContext&) { |
||||
|
throw NotImplementedException("SPIR-V Instruction"); |
||||
|
} |
||||
|
|
||||
|
} // namespace Shader::Backend::SPIRV
|
||||
3166
src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,99 +0,0 @@ |
|||||
// Copyright 2019 yuzu Emulator Project |
|
||||
// Licensed under GPLv2 or any later version |
|
||||
// Refer to the license.txt file included. |
|
||||
|
|
||||
#pragma once |
|
||||
|
|
||||
#include <array> |
|
||||
#include <set> |
|
||||
#include <vector> |
|
||||
|
|
||||
#include "common/common_types.h" |
|
||||
#include "video_core/engines/maxwell_3d.h" |
|
||||
#include "video_core/engines/shader_type.h" |
|
||||
#include "video_core/shader/registry.h" |
|
||||
#include "video_core/shader/shader_ir.h" |
|
||||
|
|
||||
namespace Vulkan { |
|
||||
|
|
||||
class Device; |
|
||||
|
|
||||
using Maxwell = Tegra::Engines::Maxwell3D::Regs; |
|
||||
using UniformTexelEntry = VideoCommon::Shader::SamplerEntry; |
|
||||
using SamplerEntry = VideoCommon::Shader::SamplerEntry; |
|
||||
using StorageTexelEntry = VideoCommon::Shader::ImageEntry; |
|
||||
using ImageEntry = VideoCommon::Shader::ImageEntry; |
|
||||
|
|
||||
constexpr u32 DESCRIPTOR_SET = 0; |
|
||||
|
|
||||
class ConstBufferEntry : public VideoCommon::Shader::ConstBuffer { |
|
||||
public: |
|
||||
explicit constexpr ConstBufferEntry(const ConstBuffer& entry_, u32 index_) |
|
||||
: ConstBuffer{entry_}, index{index_} {} |
|
||||
|
|
||||
constexpr u32 GetIndex() const { |
|
||||
return index; |
|
||||
} |
|
||||
|
|
||||
private: |
|
||||
u32 index{}; |
|
||||
}; |
|
||||
|
|
||||
struct GlobalBufferEntry { |
|
||||
u32 cbuf_index{}; |
|
||||
u32 cbuf_offset{}; |
|
||||
bool is_written{}; |
|
||||
}; |
|
||||
|
|
||||
struct ShaderEntries { |
|
||||
u32 NumBindings() const { |
|
||||
return static_cast<u32>(const_buffers.size() + global_buffers.size() + |
|
||||
uniform_texels.size() + samplers.size() + storage_texels.size() + |
|
||||
images.size()); |
|
||||
} |
|
||||
|
|
||||
std::vector<ConstBufferEntry> const_buffers; |
|
||||
std::vector<GlobalBufferEntry> global_buffers; |
|
||||
std::vector<UniformTexelEntry> uniform_texels; |
|
||||
std::vector<SamplerEntry> samplers; |
|
||||
std::vector<StorageTexelEntry> storage_texels; |
|
||||
std::vector<ImageEntry> images; |
|
||||
std::set<u32> attributes; |
|
||||
std::array<bool, Maxwell::NumClipDistances> clip_distances{}; |
|
||||
std::size_t shader_length{}; |
|
||||
u32 enabled_uniform_buffers{}; |
|
||||
bool uses_warps{}; |
|
||||
}; |
|
||||
|
|
||||
struct Specialization final { |
|
||||
u32 base_binding{}; |
|
||||
|
|
||||
// Compute specific |
|
||||
std::array<u32, 3> workgroup_size{}; |
|
||||
u32 shared_memory_size{}; |
|
||||
|
|
||||
// Graphics specific |
|
||||
std::optional<float> point_size; |
|
||||
std::bitset<Maxwell::NumVertexAttributes> enabled_attributes; |
|
||||
std::array<Maxwell::VertexAttribute::Type, Maxwell::NumVertexAttributes> attribute_types{}; |
|
||||
bool ndc_minus_one_to_one{}; |
|
||||
bool early_fragment_tests{}; |
|
||||
float alpha_test_ref{}; |
|
||||
Maxwell::ComparisonOp alpha_test_func{}; |
|
||||
}; |
|
||||
// Old gcc versions don't consider this trivially copyable. |
|
||||
// static_assert(std::is_trivially_copyable_v<Specialization>); |
|
||||
|
|
||||
struct SPIRVShader { |
|
||||
std::vector<u32> code; |
|
||||
ShaderEntries entries; |
|
||||
}; |
|
||||
|
|
||||
ShaderEntries GenerateShaderEntries(const VideoCommon::Shader::ShaderIR& ir); |
|
||||
|
|
||||
std::vector<u32> Decompile(const Device& device, const VideoCommon::Shader::ShaderIR& ir, |
|
||||
Tegra::Engines::ShaderType stage, |
|
||||
const VideoCommon::Shader::Registry& registry, |
|
||||
const Specialization& specialization); |
|
||||
|
|
||||
} // namespace Vulkan |
|
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue