Commit 248ef6fc by Ben Clayton

SpirvShaderDebugger: Handle None sizes for composite types

The spec states that opaque types can have a None size instead of a constant integer size. Bug: b/148401179 Change-Id: I52eeabe2336775643787599890857169825f3230 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/45353Tested-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarAntonio Maiorano <amaiorano@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com>
parent 0aec9b61
...@@ -513,6 +513,10 @@ private: ...@@ -513,6 +513,10 @@ private:
// addNone() registers given id as a None value or type. // addNone() registers given id as a None value or type.
void addNone(debug::Object::ID id); void addNone(debug::Object::ID id);
// isNone() returns true if the given id was registered as none with
// addNone().
bool isNone(debug::Object::ID id) const;
// get() returns the debug object with the given id. // get() returns the debug object with the given id.
// The object must exist and be of type (or derive from type) T. // The object must exist and be of type (or derive from type) T.
// A returned nullptr represents a None value or type. // A returned nullptr represents a None value or type.
...@@ -976,7 +980,7 @@ void SpirvShader::Impl::Debugger::process(const SpirvShader *shader, const InsnI ...@@ -976,7 +980,7 @@ void SpirvShader::Impl::Debugger::process(const SpirvShader *shader, const InsnI
type->column = insn.word(9); type->column = insn.word(9);
type->parent = get(debug::Object::ID(insn.word(10))); type->parent = get(debug::Object::ID(insn.word(10)));
type->linkage = shader->getString(insn.word(11)); type->linkage = shader->getString(insn.word(11));
type->size = shader->GetConstScalarInt(insn.word(12)); type->size = isNone(insn.word(12)) ? 0 : shader->GetConstScalarInt(insn.word(12));
type->flags = insn.word(13); type->flags = insn.word(13);
for(uint32_t i = 14; i < insn.wordCount(); i++) for(uint32_t i = 14; i < insn.wordCount(); i++)
{ {
...@@ -1218,6 +1222,13 @@ void SpirvShader::Impl::Debugger::addNone(debug::Object::ID id) ...@@ -1218,6 +1222,13 @@ void SpirvShader::Impl::Debugger::addNone(debug::Object::ID id)
ASSERT_MSG(added, "Debug object with %d already exists", id.value()); ASSERT_MSG(added, "Debug object with %d already exists", id.value());
} }
bool SpirvShader::Impl::Debugger::isNone(debug::Object::ID id) const
{
auto it = objects.find(debug::Object::ID(id.value()));
if(it == objects.end()) { return false; }
return it->second.get() == nullptr;
}
template<typename T> template<typename T>
T *SpirvShader::Impl::Debugger::get(SpirvID<T> id) const T *SpirvShader::Impl::Debugger::get(SpirvID<T> id) const
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment