From 28d6763ef8e39ada5903cb6e8184414188b6d141 Mon Sep 17 00:00:00 2001 From: shrekshao Date: Tue, 21 Sep 2021 18:12:59 +0000 Subject: [PATCH] Add type to OverridableConstant The overridable constants type can only be deducted from shader, those passed into `record 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 Commit-Queue: Shrek Shao Reviewed-by: Ryan Harrison --- src/inspector/entry_point.h | 11 +++++++++++ src/inspector/inspector.cc | 14 ++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/inspector/entry_point.h b/src/inspector/entry_point.h index ca72cca0b5..b652ba1e1b 100644 --- a/src/inspector/entry_point.h +++ b/src/inspector/entry_point.h @@ -92,6 +92,17 @@ InterpolationSampling ASTToInspectorInterpolationSampling( 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 1c1906ea9c..9118f398f3 100644 --- a/src/inspector/inspector.cc +++ b/src/inspector/inspector.cc @@ -197,6 +197,20 @@ std::vector Inspector::GetEntryPoints() { 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); } }