Can we get an updated list of `#pragma require` options that Unity supports?

Here’s the 2023 version of the official documentation: Unity - Manual: Targeting shader models and GPU features in HLSL

It lists only a small subset of the #pragma require features that Unity supports. In particular, it doesn’t list any of the DX12 ones, eg wave operations (even though those are used in HDRP). The DXC doc lists some others: DXC shader compiler status & doc - Google Docs

However, even that list isn’t complete. For example, if you want to do raytracing in a compute shader, you need #pragma require inlineraytracing. The only place I found that mentioned is the example code in Unity - Scripting API: ComputeShader.SetRayTracingAccelerationStructure

I assume there are others. For example, is there one for floating point atomic operations?

1 Like

Nope :slight_smile:

Here’s a list of currently missing things while we work on updating the docs:

wavebasic
wavevote
waveballot
wavemath
wavemultiprefix
quadshuffle
int64
native16bit
barycentrics
int64bufferatomics
int64groupsharedatomics
waveshuffle
inlineraytracing
5 Likes

Thank you!

@aleksandrk Follow-up question… You can also enable some things via #pragma multi_compile with specific keywords instead of #pragma require. For example #pragma multi_compile _ UNITY_DEVICE_SUPPORTS_WAVE_32 UNITY_DEVICE_SUPPORTS_WAVE_64. If I do that, I can use wave operations in a compute shader without doing #pragma require wavebasic or whatever. And further, the UNITY_DEVICE_SUPPORTS_WAVE_32and UNITY_DEVICE_SUPPORTS_WAVE_64 versions will use DXC and produce a DXBC, while the default one will use FXC and produce DXIL.

This does not appear be documented anywhere; I learned about it from you or another Unity dev on the forum. But it begs the question… are there any other sets of keywords like that?

I think you got these flipped :slight_smile:
FXC produces DXBC, DXC produces DXIL.

That’s right. Some keywords require things (UNITY_DEVICE_SUPPORTS_WAVE_32 implies wavebasic), so we add those automatically.

1 Like

Here’s a list :slight_smile:

SHADOWS_SOFT: require target 3.0
DIRLIGHTMAP_COMBINED: require target 3.0
DYNAMICLIGHTMAP_ON: require target 3.0
SHADOWS_SCREEN: require target 3.0
INSTANCING_ON: require instancing
PROCEDURAL_INSTANCING_ON: require compute
STEREO_MULTIVIEW_ON: require target 3.5
STEREO_INSTANCING_ON: require target 3.5
UNITY_DEVICE_SUPPORTS_NATIVE_16BIT: require native16bit
UNITY_DEVICE_SUPPORTS_WAVE_ANY: require wavebasic
UNITY_DEVICE_SUPPORTS_WAVE_8: require wavebasic
UNITY_DEVICE_SUPPORTS_WAVE_16: require wavebasic
UNITY_DEVICE_SUPPORTS_WAVE_32: require wavebasic
UNITY_DEVICE_SUPPORTS_WAVE_64: require wavebasic
UNITY_DEVICE_SUPPORTS_WAVE_128: require wavebasic
3 Likes

What does waveshuffle add of intrinsics? Like in directx is it just explicit support in the compiler for WaveReadLaneAt with non-uniform index rendering it a shuffle rather than a broadcast operation? Or is it specifically for vulkan where there are perhaps bespoke functions for shuffle as opposed to the sort of implicit nature found in directx? Thanks!

@Ikaros looks like it corresponds to VK_SUBGROUP_FEATURE_SHUFFLE_BIT on Vulkan. See GLSL/extensions/khr/GL_KHR_shader_subgroup.txt at main · KhronosGroup/GLSL · GitHub for details.

Thanks! Are there/will there be any #pragma require that enable SM6.7 (interested in the “advanced texture operations”) and SM6.8 (curious about Wave Matrix even tho it’s experimental). I can see that at least newer versions of Unity ship with the AgilitySDK (found D3D12Core.dll in 2023.3 A14), which allowed me to us SM6.6 features on W10 that I couldn’t with 2022.1 which is neat, is it documented somewhere which version of Unity ship with what AgilitySDK?

Not that I know of currently. Maybe in the future :slight_smile:

No, it’s not. It’s updated as needed.

Hehe, then it was just a drive-by feature request in this hijacked thread, anyway thanks for all the answers!