Hardware defines
DSHL supports some built-in hardware defines. You can use them in shaders to toggle hardware specific features, change shader behavior depending on the target platform, etc.
These defines are accessed via hardware.<platform>
syntax.
Here is a list of the available defines:
metal
– Metal APImetaliOS
– Metal API for iOSvulkan
– Vulkan APIpc
– deprecated, alias for DirectX 11 APIdx11
– DirectX 11 APIdx12
– DirectX 12 APIxbox
– Xbox One platformscarlett
– Scarlett platform (a.k.a Xbox Series X/S)ps4
– PlayStation 4 platformps5
– PlayStation 5 platformfsh_4_0
– HLSL Shader Model 4.0 versionfsh_5_0
– HLSL Shader Model 5.0 versionfsh_6_0
– HLSL Shader Model 6.0 versionfsh_6_6
– HLSL Shader Model 6.6 versionmesh
– if platform supports mesh shadersbindless
– if platform supports bindless textures
Usage example:
shader example_shader
{
if (hardware.metal) {
dont_render;
// this shader will not be compiled for metal platform
}
hlsl {
int var = 0;
##if hardware.dx12
var = 12;
##elif hardware.dx11
var = 11;
##endif
// value of var will be different for dx11 and dx12 platforms
}
}