mirror of
https://github.com/shadps4-emu/sirit.git
synced 2024-11-23 03:10:02 +00:00
Merge pull request #4 from baggins183/debug-print
Add NonSemantic DebugPrintf
This commit is contained in:
commit
6cecb95d67
@ -1347,8 +1347,13 @@ public:
|
|||||||
/// 3) store the New Value back through Pointer.
|
/// 3) store the New Value back through Pointer.
|
||||||
Id OpAtomicXor(Id result_type, Id pointer, Id memory, Id semantics, Id value);
|
Id OpAtomicXor(Id result_type, Id pointer, Id memory, Id semantics, Id value);
|
||||||
|
|
||||||
|
// Print a message for vulkan layers to use, e.g. renderdoc
|
||||||
|
// Usage is like C printf
|
||||||
|
Id OpDebugPrintf(Id fmt, std::span<const Id> fmt_args);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Id GetGLSLstd450();
|
Id GetGLSLstd450();
|
||||||
|
Id GetNonSemanticDebugPrintf();
|
||||||
|
|
||||||
std::uint32_t version{};
|
std::uint32_t version{};
|
||||||
std::uint32_t bound{};
|
std::uint32_t bound{};
|
||||||
@ -1356,6 +1361,7 @@ private:
|
|||||||
std::unordered_set<std::string> extensions;
|
std::unordered_set<std::string> extensions;
|
||||||
std::unordered_set<spv::Capability> capabilities;
|
std::unordered_set<spv::Capability> capabilities;
|
||||||
std::optional<Id> glsl_std_450;
|
std::optional<Id> glsl_std_450;
|
||||||
|
std::optional<Id> non_semantic_debug_printf;
|
||||||
|
|
||||||
spv::AddressingModel addressing_model{spv::AddressingModel::Logical};
|
spv::AddressingModel addressing_model{spv::AddressingModel::Logical};
|
||||||
spv::MemoryModel memory_model{spv::MemoryModel::GLSL450};
|
spv::MemoryModel memory_model{spv::MemoryModel::GLSL450};
|
||||||
@ -1364,6 +1370,7 @@ private:
|
|||||||
std::unique_ptr<Stream> entry_points;
|
std::unique_ptr<Stream> entry_points;
|
||||||
std::unique_ptr<Stream> execution_modes;
|
std::unique_ptr<Stream> execution_modes;
|
||||||
std::unique_ptr<Stream> debug;
|
std::unique_ptr<Stream> debug;
|
||||||
|
std::unique_ptr<Stream> debug_name;
|
||||||
std::unique_ptr<Stream> annotations;
|
std::unique_ptr<Stream> annotations;
|
||||||
std::unique_ptr<Declarations> declarations;
|
std::unique_ptr<Declarations> declarations;
|
||||||
std::unique_ptr<Stream> global_variables;
|
std::unique_ptr<Stream> global_variables;
|
||||||
|
@ -12,14 +12,14 @@
|
|||||||
namespace Sirit {
|
namespace Sirit {
|
||||||
|
|
||||||
Id Module::Name(Id target, std::string_view name) {
|
Id Module::Name(Id target, std::string_view name) {
|
||||||
debug->Reserve(3 + WordsInString(name));
|
debug_name->Reserve(3 + WordsInString(name));
|
||||||
*debug << spv::Op::OpName << target << name << EndOp{};
|
*debug_name << spv::Op::OpName << target << name << EndOp{};
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
Id Module::MemberName(Id type, u32 member, std::string_view name) {
|
Id Module::MemberName(Id type, u32 member, std::string_view name) {
|
||||||
debug->Reserve(4 + WordsInString(name));
|
debug_name->Reserve(4 + WordsInString(name));
|
||||||
*debug << spv::Op::OpMemberName << type << member << name << EndOp{};
|
*debug_name << spv::Op::OpMemberName << type << member << name << EndOp{};
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,9 @@
|
|||||||
* 3-Clause BSD License
|
* 3-Clause BSD License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <iterator>
|
||||||
#include <spirv/unified1/GLSL.std.450.h>
|
#include <spirv/unified1/GLSL.std.450.h>
|
||||||
|
#include <spirv/unified1/NonSemanticDebugPrintf.h>
|
||||||
|
|
||||||
#include "sirit/sirit.h"
|
#include "sirit/sirit.h"
|
||||||
|
|
||||||
@ -80,4 +82,12 @@ DEFINE_BINARY(OpCross, GLSLstd450Cross)
|
|||||||
DEFINE_UNARY(OpLength, GLSLstd450Length)
|
DEFINE_UNARY(OpLength, GLSLstd450Length)
|
||||||
DEFINE_TRINARY(OpFMix, GLSLstd450FMix)
|
DEFINE_TRINARY(OpFMix, GLSLstd450FMix)
|
||||||
|
|
||||||
|
Id Module::OpDebugPrintf(Id fmt, std::span<const Id> fmt_args) {
|
||||||
|
std::vector<Id> operands;
|
||||||
|
operands.push_back(fmt);
|
||||||
|
std::copy(fmt_args.begin(), fmt_args.end(), std::back_inserter(operands));
|
||||||
|
return OpExtInst(TypeVoid(), GetNonSemanticDebugPrintf(), NonSemanticDebugPrintfDebugPrintf,
|
||||||
|
operands);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Sirit
|
} // namespace Sirit
|
||||||
|
@ -21,8 +21,8 @@ Module::Module(u32 version_)
|
|||||||
: version{version_}, ext_inst_imports{std::make_unique<Stream>(&bound)},
|
: version{version_}, ext_inst_imports{std::make_unique<Stream>(&bound)},
|
||||||
entry_points{std::make_unique<Stream>(&bound)},
|
entry_points{std::make_unique<Stream>(&bound)},
|
||||||
execution_modes{std::make_unique<Stream>(&bound)}, debug{std::make_unique<Stream>(&bound)},
|
execution_modes{std::make_unique<Stream>(&bound)}, debug{std::make_unique<Stream>(&bound)},
|
||||||
annotations{std::make_unique<Stream>(&bound)}, declarations{std::make_unique<Declarations>(
|
debug_name{std::make_unique<Stream>(&bound)}, annotations{std::make_unique<Stream>(&bound)},
|
||||||
&bound)},
|
declarations{std::make_unique<Declarations>(&bound)},
|
||||||
global_variables{std::make_unique<Stream>(&bound)}, code{std::make_unique<Stream>(&bound)} {}
|
global_variables{std::make_unique<Stream>(&bound)}, code{std::make_unique<Stream>(&bound)} {}
|
||||||
|
|
||||||
Module::~Module() = default;
|
Module::~Module() = default;
|
||||||
@ -60,6 +60,7 @@ std::vector<u32> Module::Assemble() const {
|
|||||||
insert(entry_points->Words());
|
insert(entry_points->Words());
|
||||||
insert(execution_modes->Words());
|
insert(execution_modes->Words());
|
||||||
insert(debug->Words());
|
insert(debug->Words());
|
||||||
|
insert(debug_name->Words());
|
||||||
insert(annotations->Words());
|
insert(annotations->Words());
|
||||||
insert(declarations->Words());
|
insert(declarations->Words());
|
||||||
insert(global_variables->Words());
|
insert(global_variables->Words());
|
||||||
@ -131,12 +132,24 @@ Id Module::AddGlobalVariable(Id result_type, spv::StorageClass storage_class,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Id Module::GetGLSLstd450() {
|
Id Module::GetGLSLstd450() {
|
||||||
|
const char* extname = "GLSL.std.450";
|
||||||
|
size_t len = WordsInString(extname);
|
||||||
if (!glsl_std_450) {
|
if (!glsl_std_450) {
|
||||||
ext_inst_imports->Reserve(3 + 4);
|
ext_inst_imports->Reserve(3 + len);
|
||||||
glsl_std_450 = *ext_inst_imports << OpId{spv::Op::OpExtInstImport} << "GLSL.std.450"
|
glsl_std_450 = *ext_inst_imports << OpId{spv::Op::OpExtInstImport} << extname << EndOp{};
|
||||||
<< EndOp{};
|
|
||||||
}
|
}
|
||||||
return *glsl_std_450;
|
return *glsl_std_450;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Id Module::GetNonSemanticDebugPrintf() {
|
||||||
|
const char* extname = "NonSemantic.DebugPrintf";
|
||||||
|
size_t len = WordsInString(extname);
|
||||||
|
if (!non_semantic_debug_printf) {
|
||||||
|
ext_inst_imports->Reserve(3 + len);
|
||||||
|
non_semantic_debug_printf = *ext_inst_imports << OpId{spv::Op::OpExtInstImport} << extname
|
||||||
|
<< EndOp{};
|
||||||
|
}
|
||||||
|
return *non_semantic_debug_printf;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Sirit
|
} // namespace Sirit
|
||||||
|
Loading…
Reference in New Issue
Block a user