Other compilers (DXC, FXC and glslang) support basic arithmetic in binding declarations, such as layout(binding = 1+2) resource or resource : register(t[1+2]). This is useful in complex shaders with manual layouts - although it may not be the preferred way of working with resources in Slang, this approach exists, and it would be nice to support it to make porting code to Slang easier.
Full example:
#define BASE 1
#define STRIDE 2
// GLSL version
layout(binding = BASE + (STRIDE * 0))
Texture2D tex1;
// HLSL version
Texture2D tex2 : register(t[BASE + (STRIDE * 1)]);
[numthreads(1,1,1)]
void main()
{
}
Other compilers (DXC, FXC and glslang) support basic arithmetic in binding declarations, such as
layout(binding = 1+2) resource
orresource : register(t[1+2])
. This is useful in complex shaders with manual layouts - although it may not be the preferred way of working with resources in Slang, this approach exists, and it would be nice to support it to make porting code to Slang easier.Full example:
Slangc output: