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>
This commit is contained in:
shrekshao 2021-09-21 18:12:59 +00:00 committed by Tint LUCI CQ
parent 92265504fe
commit 28d6763ef8
2 changed files with 25 additions and 0 deletions

View File

@ -92,6 +92,17 @@ InterpolationSampling ASTToInspectorInterpolationSampling(
struct OverridableConstant { struct OverridableConstant {
/// Name of the constant /// Name of the constant
std::string name; 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. /// Reflection data for an entry point in the shader.

View File

@ -197,6 +197,20 @@ std::vector<EntryPoint> Inspector::GetEntryPoints() {
if (global && global->IsPipelineConstant()) { if (global && global->IsPipelineConstant()) {
OverridableConstant overridable_constant; OverridableConstant overridable_constant;
overridable_constant.name = name; 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); entry_point.overridable_constants.push_back(overridable_constant);
} }
} }