Skip to content

Commit 7c41446

Browse files
authored
Require GL_EXT_samplerless_texture_functions only if needed (shader-slang#5527)
* Require GL_EXT_samplerless_texture_functions only if needed This extension is only necessary when using texture functions on non-combined texture/samplers. Fixes shader-slang#5518
1 parent f66b046 commit 7c41446

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

source/slang/slang-core-module-textures.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,8 @@ void TextureTypeInfo::writeGetDimensionFunctions()
374374
glsl << ", ($" << aa++ << " = textureQueryLevels($0))";
375375
}
376376
};
377+
glsl << "if (isCombined == 0) { "
378+
"__requireGLSLExtension(\"GL_EXT_samplerless_texture_functions\"); }\n";
377379
glsl << "if (access == " << kCoreModule_ResourceAccessReadOnly
378380
<< ") __intrinsic_asm \"";
379381
emitIntrinsic(toSlice("textureSize"), !isMultisample);
@@ -491,7 +493,6 @@ void TextureTypeInfo::writeGetDimensionFunctions()
491493
}
492494

493495
sb << " __glsl_version(450)\n";
494-
sb << " __glsl_extension(GL_EXT_samplerless_texture_functions)\n";
495496

496497
sb << " [require(cpp";
497498
if (glsl.getLength())

tests/bugs/gh-5518.slang

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//TEST:SIMPLE(filecheck=GLSL): -profile spirv_1_5+fragment -entry fragmentMain -target glsl
2+
3+
// Ensure that the use of combined samplers does not needlessly require
4+
// GL_EXT_samplerless_texture_functions
5+
6+
// GLSL-NOT: #extension GL_EXT_samplerless_texture_functions : require
7+
8+
layout(binding=1) Sampler3D sampler;
9+
10+
[shader("fragment")]
11+
float4 fragmentMain() : SV_Target
12+
{
13+
int sizeX;
14+
int sizeY;
15+
int sizeZ;
16+
sampler.GetDimensions(sizeX, sizeY, sizeZ);
17+
return float4(sizeX, sizeY, sizeZ, 1.0);
18+
}

0 commit comments

Comments
 (0)