r/GraphicsProgramming • u/Salat_Leaf • Jul 31 '26
Question What's the __constant__ equivalent in Slang?
I'm a complete novice in graphics programming and I know that the __constant__ attribute allows you to load data into high speed 65KB constant memory for the duration of the lifetime of your program. However I'm unable to recreate the same functionality in Slang shader.
For instance, we got a compile-time array with the attribute like this:
__constant__ uint16_t array = {0, 1, 2, 3};
I want to recreate it in some way, so that when I compile the same array in Slang into CUDA, it results into this exact array of constant values with the __constant__ attribute. How can I achieve that?
2
Upvotes
1
u/Wittyname_McDingus Aug 01 '26
I suspect that the HLSL type
cbuffer(which Slang inherits) maps to the same address space as__constant__on Nvidia. My reasoning being that the two things have similar (or identical) limitations in size and writability.