Skip to content

Commit ccbc9cd

Browse files
dj2Dawn LUCI CQ
authored andcommitted
[DirectVariableAccess] Add option for external handles to be processed.
Currently the DVA transform will only process handles if the `transform_handles` flag is set. This CL splits the flag into a `none`, `external`, and `full` set of options. The current behaviour being either `none` or `full` in all cases. The SPIR-V backend is updated to use either `external` or `full` instead of `none` and `full` so we can flatten any external textures before running multiplanar. Bug: 491363837 Change-Id: Iad7e8348e3ff278fcf6e134503626a1b071c2f1b Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/296696 Commit-Queue: dan sinclair <dsinclair@chromium.org> Reviewed-by: James Price <jrprice@google.com>
1 parent 9037a8e commit ccbc9cd

7 files changed

Lines changed: 1945 additions & 1197 deletions

File tree

src/tint/lang/core/ir/transform/direct_variable_access.cc

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "src/tint/lang/core/ir/user_call.h"
3838
#include "src/tint/lang/core/ir/validator.h"
3939
#include "src/tint/lang/core/ir/var.h"
40+
#include "src/tint/lang/core/type/external_texture.h"
4041
#include "src/tint/utils/containers/reverse.h"
4142

4243
using namespace tint::core::fluent_types; // NOLINT
@@ -608,6 +609,17 @@ struct State {
608609
}
609610
}
610611

612+
bool TransformHandle(const type::Type* param) const {
613+
if (!param->IsHandle()) {
614+
return false;
615+
}
616+
if (options.transform_handle == HandleTransformLevel::kFull) {
617+
return true;
618+
}
619+
return options.transform_handle == HandleTransformLevel::kExternal &&
620+
param->Is<type::ExternalTexture>();
621+
}
622+
611623
/// @return true if @p param is a parameter that requires transforming, based on the
612624
/// transform options.
613625
/// @param param the function parameter
@@ -631,12 +643,7 @@ struct State {
631643
break;
632644
}
633645
}
634-
635-
if (param_type->IsHandle()) {
636-
return options.transform_handle;
637-
}
638-
639-
return false;
646+
return TransformHandle(param_type);
640647
}
641648

642649
/// Walks the instructions that built @p value, deleting those that are no longer used.
@@ -659,7 +666,7 @@ struct State {
659666
return let->Value();
660667
},
661668
[&](Load* load) {
662-
if (options.transform_handle) {
669+
if (TransformHandle(load->From()->Type()->UnwrapPtr())) {
663670
TINT_DEFER(load->Destroy());
664671
return load->From();
665672
}

src/tint/lang/core/ir/transform/direct_variable_access.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,22 @@ const core::ir::Capabilities kDirectVariableAccessCapabilities{
4747
core::ir::Capability::kAllow8BitIntegers,
4848
};
4949

50+
/// The level of handle workspace change
51+
enum class HandleTransformLevel {
52+
kNone,
53+
kExternal,
54+
kFull,
55+
};
56+
5057
/// DirectVariableAccessOptions adjusts the behaviour of the transform.
5158
struct DirectVariableAccessOptions {
5259
/// If true, then 'private' sub-object pointer arguments will be transformed.
5360
bool transform_private = false;
5461
/// If true, then 'function' sub-object pointer arguments will be transformed.
5562
bool transform_function = false;
56-
/// If true, then 'handle' sub-object handle type arguments will be transformed.
57-
bool transform_handle = false;
63+
/// If `kExternal` the external textures are transformed, if `kFull` then all 'handle'
64+
/// sub-object handle type arguments will be transformed.
65+
HandleTransformLevel transform_handle = HandleTransformLevel::kNone;
5866

5967
/// Reflection for this class
6068
TINT_REFLECT(DirectVariableAccessOptions,
@@ -82,4 +90,8 @@ Result<SuccessType> DirectVariableAccess(Module& module,
8290

8391
} // namespace tint::core::ir::transform
8492

93+
namespace tint {
94+
TINT_REFLECT_ENUM_RANGE(tint::core::ir::transform::HandleTransformLevel, kNone, kFull);
95+
}
96+
8597
#endif // SRC_TINT_LANG_CORE_IR_TRANSFORM_DIRECT_VARIABLE_ACCESS_H_

0 commit comments

Comments
 (0)