Skip to content

Commit 7852a2b

Browse files
author
Tim Foley
authored
Add basic support for Shader Model 6.3 profiles (shader-slang#594)
* Add basic support for Shader Model 6.3 profiles This adds `vs_6_3` and friends as available profiles, but doesn't add any new builtins specific to Shader Model 6.3. In order to better support the ray tracing shader stages, Slang will not automatically map any attempt to compile a DXR shader up to SM 6.3 (the shader model officially required for these stages) and to the `lib_*` profiles (because there are no stage-specific profiles for these cases). As an added detail, when invoking `dxcompiler.dll` to generate DXIL for DXR shaders, specify an empty entry-point name, since that is expected for `lib_*` profiles. * Fixup: don't drop [shader(...)] attributes The previous change makes the "effective profile" for DXR compiles no longer include a stage, but we had been using the stage stored on the effective profile in exactly one place: when determining what to output for a `[shader("...")]` attribute. This fixup makes it so that we use the stage from the profile on the entry-point layout instead, which seems like the right choice anyway, if we are ever going to emit multiple entry points at once.
1 parent 1a69812 commit 7852a2b

File tree

4 files changed

+48
-15
lines changed

4 files changed

+48
-15
lines changed

source/slang/dxc-support.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ namespace Slang
133133
IDxcOperationResult* dxcResult = nullptr;
134134
if (FAILED(dxcCompiler->Compile(dxcSourceBlob,
135135
L"slang",
136-
wideEntryPointName.begin(),
136+
profile.GetStage() == Stage::Unknown ? L"" : wideEntryPointName.begin(),
137137
wideProfileName.begin(),
138138
args,
139139
argCount,

source/slang/emit.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4134,7 +4134,7 @@ struct EmitVisitor
41344134
EntryPointLayout* entryPointLayout)
41354135
{
41364136
auto profile = ctx->shared->effectiveProfile;
4137-
auto stage = profile.GetStage();
4137+
auto stage = entryPointLayout->profile.GetStage();
41384138

41394139
if(profile.getFamily() == ProfileFamily::DX)
41404140
{

source/slang/profile-defs.h

+37-12
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,17 @@ PROFILE_FAMILY(SPRIV)
8686
// Profile versions
8787

8888

89-
PROFILE_VERSION(DX_4_0, DX)
90-
PROFILE_VERSION(DX_4_0_Level_9_0, DX)
91-
PROFILE_VERSION(DX_4_0_Level_9_1, DX)
92-
PROFILE_VERSION(DX_4_0_Level_9_3, DX)
93-
PROFILE_VERSION(DX_4_1, DX)
94-
PROFILE_VERSION(DX_5_0, DX)
95-
PROFILE_VERSION(DX_5_1, DX)
96-
PROFILE_VERSION(DX_6_0, DX)
97-
PROFILE_VERSION(DX_6_1, DX)
98-
PROFILE_VERSION(DX_6_2, DX)
89+
PROFILE_VERSION(DX_4_0, DX)
90+
PROFILE_VERSION(DX_4_0_Level_9_0, DX)
91+
PROFILE_VERSION(DX_4_0_Level_9_1, DX)
92+
PROFILE_VERSION(DX_4_0_Level_9_3, DX)
93+
PROFILE_VERSION(DX_4_1, DX)
94+
PROFILE_VERSION(DX_5_0, DX)
95+
PROFILE_VERSION(DX_5_1, DX)
96+
PROFILE_VERSION(DX_6_0, DX)
97+
PROFILE_VERSION(DX_6_1, DX)
98+
PROFILE_VERSION(DX_6_2, DX)
99+
PROFILE_VERSION(DX_6_3, DX)
99100

100101
PROFILE_VERSION(GLSL_110, GLSL)
101102
PROFILE_VERSION(GLSL_120, GLSL)
@@ -120,12 +121,14 @@ PROFILE(DX_Compute_5_1, cs_5_1, Compute, DX_5_1)
120121
PROFILE(DX_Compute_6_0, cs_6_0, Compute, DX_6_0)
121122
PROFILE(DX_Compute_6_1, cs_6_1, Compute, DX_6_1)
122123
PROFILE(DX_Compute_6_2, cs_6_2, Compute, DX_6_2)
124+
PROFILE(DX_Compute_6_3, cs_6_3, Compute, DX_6_3)
123125

124126
PROFILE(DX_Domain_5_0, ds_5_0, Domain, DX_5_0)
125127
PROFILE(DX_Domain_5_1, ds_5_1, Domain, DX_5_1)
126128
PROFILE(DX_Domain_6_0, ds_6_0, Domain, DX_6_0)
127129
PROFILE(DX_Domain_6_1, ds_6_1, Domain, DX_6_1)
128130
PROFILE(DX_Domain_6_2, ds_6_2, Domain, DX_6_2)
131+
PROFILE(DX_Domain_6_3, ds_6_3, Domain, DX_6_3)
129132

130133
PROFILE(DX_Geometry_4_0, gs_4_0, Geometry, DX_4_0)
131134
PROFILE(DX_Geometry_4_1, gs_4_1, Geometry, DX_4_1)
@@ -134,13 +137,15 @@ PROFILE(DX_Geometry_5_1, gs_5_1, Geometry, DX_5_1)
134137
PROFILE(DX_Geometry_6_0, gs_6_0, Geometry, DX_6_0)
135138
PROFILE(DX_Geometry_6_1, gs_6_1, Geometry, DX_6_1)
136139
PROFILE(DX_Geometry_6_2, gs_6_2, Geometry, DX_6_2)
140+
PROFILE(DX_Geometry_6_3, gs_6_3, Geometry, DX_6_3)
137141

138142

139143
PROFILE(DX_Hull_5_0, hs_5_0, Hull, DX_5_0)
140144
PROFILE(DX_Hull_5_1, hs_5_1, Hull, DX_5_1)
141145
PROFILE(DX_Hull_6_0, hs_6_0, Hull, DX_6_0)
142146
PROFILE(DX_Hull_6_1, hs_6_1, Hull, DX_6_1)
143147
PROFILE(DX_Hull_6_2, hs_6_2, Hull, DX_6_2)
148+
PROFILE(DX_Hull_6_3, hs_6_3, Hull, DX_6_3)
144149

145150

146151
PROFILE(DX_Fragment_4_0, ps_4_0, Fragment, DX_4_0)
@@ -153,6 +158,7 @@ PROFILE(DX_Fragment_5_1, ps_5_1, Fragment, DX_5_1)
153158
PROFILE(DX_Fragment_6_0, ps_6_0, Fragment, DX_6_0)
154159
PROFILE(DX_Fragment_6_1, ps_6_1, Fragment, DX_6_1)
155160
PROFILE(DX_Fragment_6_2, ps_6_2, Fragment, DX_6_2)
161+
PROFILE(DX_Fragment_6_3, ps_6_3, Fragment, DX_6_3)
156162

157163

158164
PROFILE(DX_Vertex_4_0, vs_4_0, Vertex, DX_4_0)
@@ -165,6 +171,7 @@ PROFILE(DX_Vertex_5_1, vs_5_1, Vertex, DX_5_1)
165171
PROFILE(DX_Vertex_6_0, vs_6_0, Vertex, DX_6_0)
166172
PROFILE(DX_Vertex_6_1, vs_6_1, Vertex, DX_6_1)
167173
PROFILE(DX_Vertex_6_2, vs_6_2, Vertex, DX_6_2)
174+
PROFILE(DX_Vertex_6_3, vs_6_3, Vertex, DX_6_3)
168175

169176
// TODO: consider making `lib_*_*` alias these...
170177
PROFILE(DX_None_4_0, sm_4_0, Unknown, DX_4_0)
@@ -175,8 +182,26 @@ PROFILE(DX_None_4_1, sm_4_1, Unknown, DX_4_1)
175182
PROFILE(DX_None_5_0, sm_5_0, Unknown, DX_5_0)
176183
PROFILE(DX_None_5_1, sm_5_1, Unknown, DX_5_1)
177184
PROFILE(DX_None_6_0, sm_6_0, Unknown, DX_6_0)
178-
PROFILE(DX_None_6_1, sm_6_1, Unknown, DX_6_1)
179-
PROFILE(DX_None_6_2, sm_6_2, Unknown, DX_6_2)
185+
186+
// From Shader Model 6.1 on, the dxc compiler recognizes a `lib` profile
187+
// that can be used to compile multiple entry points. We want that
188+
// `lib` name to be the default for how we render these profiles when
189+
// invoking downstream tools, so we use that instead of the `sm_`
190+
// prefix, and then re-introduce the `sm_` variants as aliases.
191+
//
192+
// TODO: We may eventually want a split between how Slang represents
193+
// profiles and their names to users, vs. how it renders them when
194+
// invoking downstream tools, so that the profile name in any
195+
// error messages can be consistent with our `sm_*` naems above
196+
//
197+
PROFILE(DX_Lib_6_1, lib_6_1, Unknown, DX_6_1)
198+
PROFILE(DX_Lib_6_2, lib_6_2, Unknown, DX_6_2)
199+
PROFILE(DX_Lib_6_3, lib_6_3, Unknown, DX_6_3)
200+
201+
PROFILE_ALIAS(DX_None_6_1, DX_Lib_6_1, sm_6_1)
202+
PROFILE_ALIAS(DX_None_6_2, DX_Lib_6_2, sm_6_2)
203+
PROFILE_ALIAS(DX_None_6_3, DX_Lib_6_3, sm_6_3)
204+
180205

181206
// Define all the GLSL profiles
182207

source/slang/slang.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,15 @@ Profile getEffectiveProfile(EntryPointRequest* entryPoint, TargetRequest* target
154154
case Stage::AnyHit:
155155
case Stage::Miss:
156156
case Stage::Callable:
157-
stageMinVersion = ProfileVersion::DX_6_1;
157+
stageMinVersion = ProfileVersion::DX_6_3;
158+
159+
// When compiling for DXR, we don't actually have distinct
160+
// profiles for all of the DXR stages (e.g., there is no
161+
// `raygeneration_6_3` profile), so we will clear out
162+
// the stage part of the effective profile to avoid
163+
// using a stage that isn't allowed downstream.
164+
//
165+
effectiveProfile.setStage(Stage::Unknown);
158166
break;
159167

160168
// TODO: Add equivalent logic for geometry, tessellation, and compute stages.

0 commit comments

Comments
 (0)