mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-18 09:25:25 +00:00
Add inspector support for DepthTexture reflection
BUG=tint:527 Change-Id: I4f017993ffa85515b5b646bd9cf15c4b6d50c441 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/43700 Auto-Submit: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
7732ca51c4
commit
04d93c88a0
@@ -126,6 +126,11 @@ class Function : public Castable<Function, CallTarget> {
|
||||
/// @returns the referenced storage textures
|
||||
VariableBindings ReferencedStorageTextureVariables() const;
|
||||
|
||||
/// Retrieves any referenced depth texture variables. Note, the variables
|
||||
/// must be decorated with both binding and group decorations.
|
||||
/// @returns the referenced storage textures
|
||||
VariableBindings ReferencedDepthTextureVariables() const;
|
||||
|
||||
/// Retrieves any locally referenced builtin variables
|
||||
/// @returns the <variable, decoration> pairs.
|
||||
std::vector<std::pair<const Variable*, ast::BuiltinDecoration*>>
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "src/ast/variable.h"
|
||||
#include "src/ast/variable_decoration.h"
|
||||
#include "src/semantic/variable.h"
|
||||
#include "src/type/depth_texture_type.h"
|
||||
#include "src/type/multisampled_texture_type.h"
|
||||
#include "src/type/sampled_texture_type.h"
|
||||
#include "src/type/storage_texture_type.h"
|
||||
@@ -43,6 +44,21 @@ ParameterList GetParameters(ast::Function* ast) {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
std::tuple<ast::BindingDecoration*, ast::GroupDecoration*> GetBindingAndGroup(
|
||||
const Variable* var) {
|
||||
ast::BindingDecoration* binding = nullptr;
|
||||
ast::GroupDecoration* group = nullptr;
|
||||
for (auto* deco : var->Declaration()->decorations()) {
|
||||
if (auto* b = deco->As<ast::BindingDecoration>()) {
|
||||
binding = b;
|
||||
}
|
||||
if (auto* s = deco->As<ast::GroupDecoration>()) {
|
||||
group = s;
|
||||
}
|
||||
}
|
||||
return {binding, group};
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Function::Function(ast::Function* declaration,
|
||||
@@ -82,13 +98,7 @@ Function::VariableBindings Function::ReferencedUniformVariables() const {
|
||||
|
||||
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* g = deco->As<ast::GroupDecoration>()) {
|
||||
group = g;
|
||||
}
|
||||
}
|
||||
std::tie(binding, group) = GetBindingAndGroup(var);
|
||||
if (binding == nullptr || group == nullptr) {
|
||||
continue;
|
||||
}
|
||||
@@ -108,13 +118,7 @@ Function::VariableBindings Function::ReferencedStorageBufferVariables() const {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
std::tie(binding, group) = GetBindingAndGroup(var);
|
||||
if (binding == nullptr || group == nullptr) {
|
||||
continue;
|
||||
}
|
||||
@@ -169,13 +173,29 @@ Function::VariableBindings Function::ReferencedStorageTextureVariables() const {
|
||||
|
||||
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;
|
||||
}
|
||||
std::tie(binding, group) = GetBindingAndGroup(var);
|
||||
if (binding == nullptr || group == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ret.push_back({var, BindingInfo{binding, group}});
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Function::VariableBindings Function::ReferencedDepthTextureVariables() const {
|
||||
VariableBindings ret;
|
||||
|
||||
for (auto* var : ReferencedModuleVariables()) {
|
||||
auto* unwrapped_type = var->Declaration()->type()->UnwrapIfNeeded();
|
||||
auto* storage_texture = unwrapped_type->As<type::DepthTexture>();
|
||||
if (storage_texture == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ast::BindingDecoration* binding = nullptr;
|
||||
ast::GroupDecoration* group = nullptr;
|
||||
std::tie(binding, group) = GetBindingAndGroup(var);
|
||||
if (binding == nullptr || group == nullptr) {
|
||||
continue;
|
||||
}
|
||||
@@ -222,14 +242,7 @@ Function::VariableBindings Function::ReferencedSamplerVariablesImpl(
|
||||
|
||||
ast::BindingDecoration* binding = nullptr;
|
||||
ast::GroupDecoration* group = nullptr;
|
||||
for (auto* deco : var->Declaration()->decorations()) {
|
||||
if (auto* b = deco->As<ast::BindingDecoration>()) {
|
||||
binding = b;
|
||||
}
|
||||
if (auto* s = deco->As<ast::GroupDecoration>()) {
|
||||
group = s;
|
||||
}
|
||||
}
|
||||
std::tie(binding, group) = GetBindingAndGroup(var);
|
||||
if (binding == nullptr || group == nullptr) {
|
||||
continue;
|
||||
}
|
||||
@@ -259,13 +272,7 @@ Function::VariableBindings Function::ReferencedSampledTextureVariablesImpl(
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
std::tie(binding, group) = GetBindingAndGroup(var);
|
||||
if (binding == nullptr || group == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user