diff --git a/.lintrunner.toml b/.lintrunner.toml index b366c141799..d0c9c6aef6a 100644 --- a/.lintrunner.toml +++ b/.lintrunner.toml @@ -449,3 +449,24 @@ command = [ "--", "@{{PATHSFILE}}", ] + +[[linter]] +code = 'ETVKNODEBUG' +include_patterns = [ + "backends/vulkan/**/*.glsl", +] +command = [ + 'python', + '-m', + 'lintrunner_adapters', + 'run', + 'grep_linter', + '--pattern=((DEBUG_MODE)|(GL_EXT_debug_printf))', + '--linter-name=ETVKNODEBUG', + '--error-name=Using DEBUG_MODE or GL_EXT_debug_printf in Vulkan shader', + """--error-description=\ + #define DEBUG_MODE or #extension GL_EXT_debug_printf should only be used during development! + """, + '--', + '@{{PATHSFILE}}', +] diff --git a/backends/vulkan/runtime/graph/ops/glsl/binary_q8ta_q8ta_q8to.glsl b/backends/vulkan/runtime/graph/ops/glsl/binary_q8ta_q8ta_q8to.glsl index 8b69642d2e9..d0bd1809d11 100644 --- a/backends/vulkan/runtime/graph/ops/glsl/binary_q8ta_q8ta_q8to.glsl +++ b/backends/vulkan/runtime/graph/ops/glsl/binary_q8ta_q8ta_q8to.glsl @@ -25,8 +25,6 @@ ${define_required_extensions(DTYPE)} layout(std430) buffer; -#extension GL_EXT_debug_printf : enable -#define DEBUG_MODE #include "indexing.glslh" #include "common.glslh" diff --git a/backends/vulkan/runtime/graph/ops/glsl/binary_scalar_texture.glsl b/backends/vulkan/runtime/graph/ops/glsl/binary_scalar_texture.glsl index 971f66f93e5..4f51e9ff679 100644 --- a/backends/vulkan/runtime/graph/ops/glsl/binary_scalar_texture.glsl +++ b/backends/vulkan/runtime/graph/ops/glsl/binary_scalar_texture.glsl @@ -22,7 +22,6 @@ ${define_required_extensions(DTYPE)} layout(std430) buffer; -#define DEBUG_MODE #include "indexing.glslh" ${layout_declare_tensor(B, "w", "t_out", DTYPE, STORAGE)} diff --git a/backends/vulkan/runtime/graph/ops/glsl/common.glslh b/backends/vulkan/runtime/graph/ops/glsl/common.glslh index 62c0922e3e3..8340a8b9b2f 100644 --- a/backends/vulkan/runtime/graph/ops/glsl/common.glslh +++ b/backends/vulkan/runtime/graph/ops/glsl/common.glslh @@ -9,6 +9,10 @@ #ifndef COMMON_GLSLH #define COMMON_GLSLH +#ifdef DEBUG_MODE +#extension GL_EXT_debug_printf : enable +#endif + #define mul_2(x) ((x) << 1) #define mul_4(x) ((x) << 2) #define mul_8(x) ((x) << 3) diff --git a/backends/vulkan/runtime/graph/ops/glsl/embedding_buffer.glsl b/backends/vulkan/runtime/graph/ops/glsl/embedding_buffer.glsl index 8b519a67eb6..c1a21e44c60 100644 --- a/backends/vulkan/runtime/graph/ops/glsl/embedding_buffer.glsl +++ b/backends/vulkan/runtime/graph/ops/glsl/embedding_buffer.glsl @@ -19,7 +19,6 @@ ${define_required_extensions(DTYPE)} layout(std430) buffer; -#define DEBUG_MODE #include "indexing.glslh" ${layout_declare_tensor(B, "w", "t_out", DTYPE, "buffer")} diff --git a/backends/vulkan/runtime/graph/ops/glsl/embedding_texture.glsl b/backends/vulkan/runtime/graph/ops/glsl/embedding_texture.glsl index ecfc10415a1..b064d8a3295 100644 --- a/backends/vulkan/runtime/graph/ops/glsl/embedding_texture.glsl +++ b/backends/vulkan/runtime/graph/ops/glsl/embedding_texture.glsl @@ -20,7 +20,6 @@ ${define_required_extensions(DTYPE)} layout(std430) buffer; -#define DEBUG_MODE #include "common.glslh" #include "indexing.glslh" diff --git a/backends/vulkan/runtime/graph/ops/glsl/indexing.glslh b/backends/vulkan/runtime/graph/ops/glsl/indexing.glslh index c4feb17ef2e..0e30faa5d66 100644 --- a/backends/vulkan/runtime/graph/ops/glsl/indexing.glslh +++ b/backends/vulkan/runtime/graph/ops/glsl/indexing.glslh @@ -278,8 +278,6 @@ TextureElementIndex tensor_idx_to_texture_element_idx_simple( #ifdef DEBUG_MODE -#extension GL_EXT_debug_printf : enable - void printTensorIndex(const TensorIndex tidx) { debugPrintfEXT( "TensorIndex: tidx=[%u %u %u %u %u %u %u %u]\\n",