diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-03-22 11:21:45 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-03-22 11:21:45 -0700 |
| commit | 5e720e7e7e8be20017e331b515024586e1a88c52 (patch) | |
| tree | f5a65ff8c53e8573625b13463baceb4099bc5499 /source/slang/profile-defs.h | |
| parent | d421988f91d0d6fda78b9aea4cba763f9c662ffe (diff) | |
Add support for DirectX Raytracing (DXR) (#451)
* Add support for DirectX Raytracing (DXR)
This is an initial pass to add support to Slang for the shader stages introduced by DirectX Raytracing (DXR).
* Add declarations for DXR intrinsic types and functions to the Slang standard library. The way our compilation works, these will then get propagated through the IR as intrinsics and get spit back out again as-is during HLSL code emission.
* Declare the DXR-related stages. This is the main work that affects the compiler's C++ implementation rather than being something we can add via the standard library today.
* Switch around the encoding of the `Profile` type so that the stage is in the low bits, allowing API users to pass an ordinary `SlangStage` to operations that expect a `SlangProfileID`.
- This represents a direction I'd like to push in long term, where the user specifies stage and "feature level" separately rather than using composite profiles like `vs_6_0`. The introduction of these new stages seems like a good point to try and make a clean break here and not introduce, e.g., `rgs_6_1` for ray generatin shaders.
* Upgrade "effective profile" computation so that it advances the required version based on the specified stage (e.g., DXR stages seem to require at least shader model 6.1).
- This is a bit of a kludge overall, but ideally we don't want a typical user to have to think about "feature level" stuff much at all. The ideal workflow is that they just hand us a source file and we work out entry points and their required feature levels in the compiler (and let the user query it when we are done). Until we implement that for real, stopgaps like this are required.
Overall these are relatively small changes for supporting some major new API behavior. Slang's design helps out here, by allowing a lot of things to be specified in the stdlib (including generic intrinsic functions), but some of this is also owed to the DXIL-influenced design of DXR - e.g., the use of global functions in place of `SV_*` semantics.
* fixup: typos
* Fixup: use `pixel` instead of `fragment` as primary stage name
This is to match HLSL conventions when generating output code, even if the Slang project officially favors the more correct term "fragment shader."
Diffstat (limited to 'source/slang/profile-defs.h')
| -rw-r--r-- | source/slang/profile-defs.h | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/source/slang/profile-defs.h b/source/slang/profile-defs.h index 177c4a0c5..e7000bfa2 100644 --- a/source/slang/profile-defs.h +++ b/source/slang/profile-defs.h @@ -23,7 +23,7 @@ #endif #ifndef PROFILE_STAGE_ALIAS -#define PROFILE_STAGE_ALIAS(TAG, NAME) /* empty */ +#define PROFILE_STAGE_ALIAS(TAG, NAME, VAL) /* empty */ #endif @@ -57,10 +57,25 @@ PROFILE_STAGE(Vertex, vertex, SLANG_STAGE_VERTEX) PROFILE_STAGE(Hull, hull, SLANG_STAGE_HULL) PROFILE_STAGE(Domain, domain, SLANG_STAGE_DOMAIN) PROFILE_STAGE(Geometry, geometry, SLANG_STAGE_GEOMETRY) -PROFILE_STAGE(Fragment, fragment, SLANG_STAGE_FRAGMENT) +PROFILE_STAGE(Pixel, pixel, SLANG_STAGE_FRAGMENT) PROFILE_STAGE(Compute, compute, SLANG_STAGE_COMPUTE) -PROFILE_STAGE_ALIAS(Fragment, pixel) +PROFILE_STAGE(RayGeneration, raygeneration, SLANG_STAGE_RAY_GENERATION) +PROFILE_STAGE(Intersection, intersection, SLANG_STAGE_INTERSECTION) +PROFILE_STAGE(AnyHit, anyhit, SLANG_STAGE_ANY_HIT) +PROFILE_STAGE(ClosestHit, closesthit, SLANG_STAGE_CLOSEST_HIT) +PROFILE_STAGE(Miss, miss, SLANG_STAGE_MISS) +PROFILE_STAGE(Callable, callable, SLANG_STAGE_CALLABLE) + + +// Note: HLSL and Direct3D convention erroneously uses the term "Pixel Shader" +// for the thing that shades *fragments*. Slang strives to treat the more correct +// term "Fragment Shader" as the primary one, but in order to be compatible with +// existing HLSL conventions, we need to treat `pixel` as the official stage +// name and `fragment` as an alias for it here, because the lower-case stage +// names are used to drive output HLSL generation. +// +PROFILE_STAGE_ALIAS(Fragment, fragment, Pixel) // Profile families @@ -151,6 +166,18 @@ PROFILE(DX_Vertex_6_0, vs_6_0, Vertex, DX_6_0) PROFILE(DX_Vertex_6_1, vs_6_1, Vertex, DX_6_1) PROFILE(DX_Vertex_6_2, vs_6_2, Vertex, DX_6_2) +// TODO: consider making `lib_*_*` alias these... +PROFILE(DX_None_4_0, sm_4_0, Unknown, DX_4_0) +PROFILE(DX_None_4_0_Level_9_0, sm_4_0_level_9_0, Unknown, DX_4_0_Level_9_0) +PROFILE(DX_None_4_0_Level_9_1, sm_4_0_level_9_1, Unknown, DX_4_0_Level_9_1) +PROFILE(DX_None_4_0_Level_9_3, sm_4_0_level_9_3, Unknown, DX_4_0_Level_9_3) +PROFILE(DX_None_4_1, sm_4_1, Unknown, DX_4_1) +PROFILE(DX_None_5_0, sm_5_0, Unknown, DX_5_0) +PROFILE(DX_None_5_1, sm_5_1, Unknown, DX_5_1) +PROFILE(DX_None_6_0, sm_6_0, Unknown, DX_6_0) +PROFILE(DX_None_6_1, sm_6_1, Unknown, DX_6_1) +PROFILE(DX_None_6_2, sm_6_2, Unknown, DX_6_2) + // Define all the GLSL profiles #define P(UPPER, LOWER, VERSION) \ |
