From fda36f832bde1227df1c2925788b373883ea6e75 Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Sun, 25 Feb 2018 10:58:22 +0100 Subject: [PATCH] Fix function overload when SPIR-V overloads on pointer type. --- spirv_glsl.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp index 4a839c19..0b867191 100644 --- a/spirv_glsl.cpp +++ b/spirv_glsl.cpp @@ -7869,7 +7869,19 @@ void CompilerGLSL::add_function_overload(const SPIRFunction &func) { Hasher hasher; for (auto &arg : func.arguments) - hasher.u32(arg.type); + { + // Parameters can vary with pointer type or not, + // but that will not change the signature in GLSL/HLSL, + // so strip the pointer type before hashing. + uint32_t type_id = arg.type; + auto *type = &get(type_id); + while (type->pointer) + { + type_id = type->parent_type; + type = &get(type_id); + } + hasher.u32(type_id); + } uint64_t types_hash = hasher.get(); auto function_name = to_name(func.self);