Add type to OverridableConstant
The overridable constants type can only be deducted from shader, those
passed into `record<USVString, GPUPipelineConstantValue> constants;`
are all double. In dawn pipeline (vulkan backend for exmaple) we need to
do type cast for these double values and passed in to native API
Bug: tint:1155, dawn:1041
Change-Id: I3abb43e61d63f054402ca8d3280b44a833a5f67e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/64601
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Shrek Shao <shrekshao@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
diff --git a/src/inspector/entry_point.h b/src/inspector/entry_point.h
index ca72cca..b652ba1 100644
--- a/src/inspector/entry_point.h
+++ b/src/inspector/entry_point.h
@@ -92,6 +92,17 @@
struct OverridableConstant {
/// Name of the constant
std::string name;
+
+ /// Type of the scalar
+ enum class Type {
+ kBool,
+ kFloat32,
+ kUint32,
+ kInt32,
+ };
+
+ /// Type of the scalar
+ Type type;
};
/// Reflection data for an entry point in the shader.
diff --git a/src/inspector/inspector.cc b/src/inspector/inspector.cc
index 1c1906e..9118f39 100644
--- a/src/inspector/inspector.cc
+++ b/src/inspector/inspector.cc
@@ -197,6 +197,20 @@
if (global && global->IsPipelineConstant()) {
OverridableConstant overridable_constant;
overridable_constant.name = name;
+ auto* type = var->Type();
+ TINT_ASSERT(Inspector, type->is_scalar());
+ if (type->is_bool_scalar_or_vector()) {
+ overridable_constant.type = OverridableConstant::Type::kBool;
+ } else if (type->is_float_scalar()) {
+ overridable_constant.type = OverridableConstant::Type::kFloat32;
+ } else if (type->is_signed_integer_scalar()) {
+ overridable_constant.type = OverridableConstant::Type::kInt32;
+ } else if (type->is_unsigned_integer_scalar()) {
+ overridable_constant.type = OverridableConstant::Type::kUint32;
+ } else {
+ TINT_UNREACHABLE(Inspector, diagnostics_);
+ }
+
entry_point.overridable_constants.push_back(overridable_constant);
}
}