mirror of
https://github.com/yuzu-emu/sirit.git
synced 2024-11-22 06:25:37 +01:00
Add support for GLSLstd450 and OpFAbs
This commit is contained in:
parent
44043bca56
commit
6742afd6dd
@ -292,6 +292,15 @@ class Module {
|
||||
/// Integer addition of Operand 1 and Operand 2.
|
||||
Id OpIAdd(Id result_type, Id operand_1, Id operand_2);
|
||||
|
||||
// Extensions
|
||||
|
||||
/// Execute an instruction in an imported set of extended instructions.
|
||||
Id OpExtInst(Id result_type, Id set, std::uint32_t instruction,
|
||||
const std::vector<Id>& operands);
|
||||
|
||||
/// Result is x if x >= 0; otherwise result is -x.
|
||||
Id OpFAbs(Id result_type, Id x);
|
||||
|
||||
private:
|
||||
Id AddCode(std::unique_ptr<Op> op);
|
||||
|
||||
@ -301,27 +310,23 @@ class Module {
|
||||
|
||||
Id AddAnnotation(std::unique_ptr<Op> op);
|
||||
|
||||
Id GetGLSLstd450();
|
||||
|
||||
const std::uint32_t version;
|
||||
|
||||
std::uint32_t bound{1};
|
||||
|
||||
std::set<spv::Capability> capabilities;
|
||||
|
||||
std::set<std::string> extensions;
|
||||
|
||||
std::unique_ptr<Op> glsl_std_450;
|
||||
std::set<std::unique_ptr<Op>> ext_inst_import;
|
||||
|
||||
spv::AddressingModel addressing_model{spv::AddressingModel::Logical};
|
||||
spv::MemoryModel memory_model{spv::MemoryModel::GLSL450};
|
||||
|
||||
std::vector<std::unique_ptr<Op>> entry_points;
|
||||
|
||||
std::vector<std::unique_ptr<Op>> execution_mode;
|
||||
|
||||
std::vector<std::unique_ptr<Op>> debug;
|
||||
|
||||
std::vector<std::unique_ptr<Op>> annotations;
|
||||
|
||||
std::vector<std::unique_ptr<Op>> declarations;
|
||||
|
||||
std::vector<Id> global_variables;
|
||||
|
@ -24,6 +24,7 @@ add_library(sirit
|
||||
insts/conversion.cpp
|
||||
insts/bit.cpp
|
||||
insts/arithmetic.cpp
|
||||
insts/extension.cpp
|
||||
)
|
||||
target_include_directories(sirit
|
||||
PUBLIC ../include
|
||||
|
28
src/insts/extension.cpp
Normal file
28
src/insts/extension.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
/* This file is part of the sirit project.
|
||||
* Copyright (c) 2018 ReinUsesLisp
|
||||
* This software may be used and distributed according to the terms of the GNU
|
||||
* Lesser General Public License version 2.1 or any later version.
|
||||
*/
|
||||
|
||||
#include "common_types.h"
|
||||
#include "op.h"
|
||||
#include "sirit/sirit.h"
|
||||
#include <memory>
|
||||
#include <spirv/unified1/GLSL.std.450.h>
|
||||
|
||||
namespace Sirit {
|
||||
|
||||
Id Module::OpExtInst(Id result_type, Id set, u32 instruction,
|
||||
const std::vector<Id>& operands) {
|
||||
auto op{std::make_unique<Op>(spv::Op::OpExtInst, bound++, result_type)};
|
||||
op->Add(set);
|
||||
op->Add(instruction);
|
||||
op->Add(operands);
|
||||
return AddCode(std::move(op));
|
||||
}
|
||||
|
||||
Id Module::OpFAbs(Id result_type, Id x) {
|
||||
return OpExtInst(result_type, GetGLSLstd450(), GLSLstd450FAbs, {x});
|
||||
}
|
||||
|
||||
} // namespace Sirit
|
@ -43,7 +43,9 @@ std::vector<u8> Module::Assemble() const {
|
||||
for (const auto capability : capabilities) {
|
||||
WriteEnum(stream, spv::Op::OpCapability, capability);
|
||||
}
|
||||
// TODO write extensions
|
||||
if (glsl_std_450) {
|
||||
glsl_std_450->Write(stream);
|
||||
}
|
||||
// TODO write ext inst imports
|
||||
|
||||
Op memory_model_ref{spv::Op::OpMemoryModel};
|
||||
@ -123,4 +125,11 @@ Id Module::AddAnnotation(std::unique_ptr<Op> op) {
|
||||
return id;
|
||||
}
|
||||
|
||||
Id Module::GetGLSLstd450() {
|
||||
if (!glsl_std_450) {
|
||||
glsl_std_450 = std::make_unique<Op>(spv::Op::OpExtInstImport, bound++);
|
||||
}
|
||||
return glsl_std_450.get();
|
||||
}
|
||||
|
||||
} // namespace Sirit
|
||||
|
Loading…
Reference in New Issue
Block a user