From 02e18b55faff56c037a76645c793b24b712fa375 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Tue, 6 Nov 2018 16:16:52 -0800 Subject: Translate NonUniformResourceIndex() calls to Vulkan GLSL (#713) These calls translate to uses of the `nonuniformEXT` qualifier introduced by the `GL_EXT_nonuniform_qualifier` extension. The standard library changes in this case are straightforward uses of existing compiler mechanisms. The test case is one of the less pleasant ones where we compare SPIR-V output against SPIR-V generated from a hand-coded GLSL baseline. This is a case where a simpler test type that just checks for specific textual matches in the output (and not whole files) would be better, but that is out of scope for this change. --- source/slang/hlsl.meta.slang | 5 +++++ source/slang/hlsl.meta.slang.h | 5 +++++ 2 files changed, 10 insertions(+) (limited to 'source') diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index fb03dfcfc..c666dadd3 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -871,7 +871,12 @@ __generic float noise(vector x); /// to this function as necessary in output code, rather than make this /// the user's responsibility, so that the default behavior of the language /// is more semantically "correct." +__target_intrinsic(glsl, nonuniformEXT) +__glsl_extension(GL_EXT_nonuniform_qualifier) uint NonUniformResourceIndex(uint index); + +__target_intrinsic(glsl, nonuniformEXT) +__glsl_extension(GL_EXT_nonuniform_qualifier) int NonUniformResourceIndex(int index); // Normalize a vector diff --git a/source/slang/hlsl.meta.slang.h b/source/slang/hlsl.meta.slang.h index e1e080d25..2db710ccb 100644 --- a/source/slang/hlsl.meta.slang.h +++ b/source/slang/hlsl.meta.slang.h @@ -916,7 +916,12 @@ SLANG_RAW("/// Note: a future version of Slang may take responsibility for inser SLANG_RAW("/// to this function as necessary in output code, rather than make this\n") SLANG_RAW("/// the user's responsibility, so that the default behavior of the language\n") SLANG_RAW("/// is more semantically \"correct.\"\n") +SLANG_RAW("__target_intrinsic(glsl, nonuniformEXT)\n") +SLANG_RAW("__glsl_extension(GL_EXT_nonuniform_qualifier)\n") SLANG_RAW("uint NonUniformResourceIndex(uint index);\n") +SLANG_RAW("\n") +SLANG_RAW("__target_intrinsic(glsl, nonuniformEXT)\n") +SLANG_RAW("__glsl_extension(GL_EXT_nonuniform_qualifier)\n") SLANG_RAW("int NonUniformResourceIndex(int index);\n") SLANG_RAW("\n") SLANG_RAW("// Normalize a vector\n") -- cgit v1.2.3