mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-18 09:25:25 +00:00
Add support fo extracting information about Storage Textures
BUG=tint:489 Change-Id: I28e4b0e568aea463971e9d2f5a04f04e942e2564 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41600 Auto-Submit: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dan sinclair <dsinclair@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com> Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
652d40a3d1
commit
d086c147d0
@@ -95,7 +95,7 @@ class Function : public Castable<Function, CallTarget> {
|
||||
/// must be decorated with both binding and group decorations.
|
||||
/// @returns the referenced storagebuffers
|
||||
const std::vector<std::pair<const Variable*, BindingInfo>>
|
||||
ReferencedStoragebufferVariables() const;
|
||||
ReferencedStorageBufferVariables() const;
|
||||
|
||||
/// Retrieves any referenced regular Sampler variables. Note, the
|
||||
/// variables must be decorated with both binding and group decorations.
|
||||
@@ -121,6 +121,12 @@ class Function : public Castable<Function, CallTarget> {
|
||||
const std::vector<std::pair<const Variable*, BindingInfo>>
|
||||
ReferencedMultisampledTextureVariables() const;
|
||||
|
||||
/// Retrieves any referenced storage texture variables. Note, the variables
|
||||
/// must be decorated with both binding and group decorations.
|
||||
/// @returns the referenced storage textures
|
||||
const std::vector<std::pair<const Variable*, BindingInfo>>
|
||||
ReferencedStorageTextureVariables() const;
|
||||
|
||||
/// Retrieves any locally referenced builtin variables
|
||||
/// @returns the <variable, decoration> pairs.
|
||||
const std::vector<std::pair<const Variable*, ast::BuiltinDecoration*>>
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "src/semantic/variable.h"
|
||||
#include "src/type/multisampled_texture_type.h"
|
||||
#include "src/type/sampled_texture_type.h"
|
||||
#include "src/type/storage_texture_type.h"
|
||||
#include "src/type/texture_type.h"
|
||||
|
||||
TINT_INSTANTIATE_CLASS_ID(tint::semantic::Function);
|
||||
@@ -98,7 +99,7 @@ Function::ReferencedUniformVariables() const {
|
||||
}
|
||||
|
||||
const std::vector<std::pair<const Variable*, Function::BindingInfo>>
|
||||
Function::ReferencedStoragebufferVariables() const {
|
||||
Function::ReferencedStorageBufferVariables() const {
|
||||
std::vector<std::pair<const Variable*, Function::BindingInfo>> ret;
|
||||
|
||||
for (auto* var : ReferencedModuleVariables()) {
|
||||
@@ -159,6 +160,35 @@ Function::ReferencedMultisampledTextureVariables() const {
|
||||
return ReferencedSampledTextureVariablesImpl(true);
|
||||
}
|
||||
|
||||
const std::vector<std::pair<const Variable*, Function::BindingInfo>>
|
||||
Function::ReferencedStorageTextureVariables() const {
|
||||
std::vector<std::pair<const Variable*, Function::BindingInfo>> ret;
|
||||
|
||||
for (auto* var : ReferencedModuleVariables()) {
|
||||
auto* unwrapped_type = var->Declaration()->type()->UnwrapIfNeeded();
|
||||
auto* storage_texture = unwrapped_type->As<type::StorageTexture>();
|
||||
if (storage_texture == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ast::BindingDecoration* binding = nullptr;
|
||||
ast::GroupDecoration* group = nullptr;
|
||||
for (auto* deco : var->Declaration()->decorations()) {
|
||||
if (auto* b = deco->As<ast::BindingDecoration>()) {
|
||||
binding = b;
|
||||
} else if (auto* s = deco->As<ast::GroupDecoration>()) {
|
||||
group = s;
|
||||
}
|
||||
}
|
||||
if (binding == nullptr || group == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ret.push_back({var, BindingInfo{binding, group}});
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
const std::vector<std::pair<const Variable*, ast::BuiltinDecoration*>>
|
||||
Function::LocalReferencedBuiltinVariables() const {
|
||||
std::vector<std::pair<const Variable*, ast::BuiltinDecoration*>> ret;
|
||||
|
||||
Reference in New Issue
Block a user