mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-20 18:29:23 +00:00
[inspector] Extract UBO information
Also includes adding in sizing information for various types. BUG=tint:257 Change-Id: Iaaa8a7c28851d14790285b5bd14636bf3ae2b9b0 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30704 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dan sinclair <dsinclair@chromium.org> Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
8f7c80347d
commit
88d705dc85
@@ -25,6 +25,7 @@
|
||||
#include "src/ast/null_literal.h"
|
||||
#include "src/ast/scalar_constructor_expression.h"
|
||||
#include "src/ast/sint_literal.h"
|
||||
#include "src/ast/type/struct_type.h"
|
||||
#include "src/ast/uint_literal.h"
|
||||
|
||||
namespace tint {
|
||||
@@ -134,5 +135,43 @@ std::map<uint32_t, Scalar> Inspector::GetConstantIDs() {
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<ResourceBinding> Inspector::GetUniformBufferResourceBindings(
|
||||
const std::string& entry_point) {
|
||||
auto* func = module_.FindFunctionByName(entry_point);
|
||||
if (!func) {
|
||||
error_ += entry_point + " was not found!";
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!func->IsEntryPoint()) {
|
||||
error_ += entry_point + " is not an entry point!";
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<ResourceBinding> result;
|
||||
|
||||
for (auto& ruv : func->referenced_uniform_variables()) {
|
||||
ResourceBinding entry;
|
||||
ast::Variable* var = nullptr;
|
||||
ast::Function::BindingInfo binding_info;
|
||||
std::tie(var, binding_info) = ruv;
|
||||
if (!var->type()->IsStruct()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!var->type()->AsStruct()->IsBlockDecorated()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
entry.bind_group = binding_info.set->value();
|
||||
entry.binding = binding_info.binding->value();
|
||||
entry.min_buffer_binding_size = var->type()->MinBufferBindingSize();
|
||||
|
||||
result.push_back(std::move(entry));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace inspector
|
||||
} // namespace tint
|
||||
|
||||
Reference in New Issue
Block a user