Skip to content

Commit 260351b

Browse files
committed
Require SM 6.0 for HLSL source and remove profile strings from API
1 parent 5bb06d3 commit 260351b

File tree

3 files changed

+193
-189
lines changed

3 files changed

+193
-189
lines changed

include/SDL3_gpu_shadercross/SDL_gpu_shadercross.h

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ typedef enum SDL_ShaderCross_ShaderStage
5353
SDL_SHADERCROSS_SHADERSTAGE_COMPUTE
5454
} SDL_ShaderCross_ShaderStage;
5555

56+
typedef enum SDL_ShaderCross_ShaderModel
57+
{
58+
SDL_SHADERCROSS_SHADERMODEL_5_0,
59+
SDL_SHADERCROSS_SHADERMODEL_6_0
60+
} SDL_ShaderCross_ShaderModel;
61+
5662
/**
5763
* Initializes SDL_gpu_shadercross
5864
*
@@ -99,14 +105,16 @@ extern SDL_DECLSPEC void * SDLCALL SDL_ShaderCross_TranspileMSLFromSPIRV(
99105
* \param bytecode the SPIRV bytecode.
100106
* \param bytecodeSize the length of the SPIRV bytecode.
101107
* \param entrypoint the entry point function name for the shader in UTF-8.
102-
* \param shaderProfile the HLSL shader profile to transpile with.
108+
* \param shaderStage the shader stage to transpile the shader with.
109+
* \param shaderModel the shader model to transpile the shader with.
103110
* \returns an SDL_malloc'd string containing HLSL code.
104111
*/
105112
extern SDL_DECLSPEC void * SDLCALL SDL_ShaderCross_TranspileHLSLFromSPIRV(
106113
const Uint8 *bytecode,
107114
size_t bytecodeSize,
108115
const char *entrypoint,
109-
const char *shaderProfile);
116+
SDL_ShaderCross_ShaderStage shaderStage,
117+
SDL_ShaderCross_ShaderModel shaderModel);
110118

111119
/**
112120
* Compile DXBC bytecode from SPIRV code.
@@ -180,13 +188,13 @@ extern SDL_DECLSPEC SDL_GPUComputePipeline * SDLCALL SDL_ShaderCross_CompileComp
180188
extern SDL_DECLSPEC SDL_GPUShaderFormat SDLCALL SDL_ShaderCross_GetHLSLShaderFormats(void);
181189

182190
/**
183-
* Compile to DXBC bytecode from HLSL code.
191+
* Compile to DXBC bytecode from HLSL Shader Model 6.0 code via a SPIRV-Cross round trip.
184192
*
185193
* You must SDL_free the returned buffer once you are done with it.
186194
*
187195
* \param hlslSource the HLSL source code for the shader.
188196
* \param entrypoint the entry point function name for the shader in UTF-8.
189-
* \param shaderProfile the shader profile to compile the shader with.
197+
* \param shaderStage the shader stage to compile the shader with.
190198
* \param size filled in with the bytecode buffer size.
191199
* \returns an SDL_malloc'd buffer containing DXBC bytecode.
192200
*
@@ -195,17 +203,17 @@ extern SDL_DECLSPEC SDL_GPUShaderFormat SDLCALL SDL_ShaderCross_GetHLSLShaderFor
195203
extern SDL_DECLSPEC void * SDLCALL SDL_ShaderCross_CompileDXBCFromHLSL(
196204
const char *hlslSource,
197205
const char *entrypoint,
198-
const char *shaderProfile,
206+
SDL_ShaderCross_ShaderStage shaderStage,
199207
size_t *size);
200208

201209
/**
202-
* Compile to DXIL bytecode from HLSL code.
210+
* Compile to DXIL bytecode from HLSL Shader Model 6.0 code via a SPIRV-Cross round trip.
203211
*
204212
* You must SDL_free the returned buffer once you are done with it.
205213
*
206214
* \param hlslSource the HLSL source code for the shader.
207215
* \param entrypoint the entry point function name for the shader in UTF-8.
208-
* \param shaderProfile the shader profile to compile the shader with.
216+
* \param shaderStage the shader stage to compile the shader with.
209217
* \param size filled in with the bytecode buffer size.
210218
* \returns an SDL_malloc'd buffer containing DXIL bytecode.
211219
*
@@ -214,17 +222,17 @@ extern SDL_DECLSPEC void * SDLCALL SDL_ShaderCross_CompileDXBCFromHLSL(
214222
extern SDL_DECLSPEC void * SDLCALL SDL_ShaderCross_CompileDXILFromHLSL(
215223
const char *hlslSource,
216224
const char *entrypoint,
217-
const char *shaderProfile,
225+
SDL_ShaderCross_ShaderStage shaderStage,
218226
size_t *size);
219227

220228
/**
221-
* Compile to SPIRV bytecode from HLSL code.
229+
* Compile to SPIRV bytecode from HLSL Shader Model 6.0 code.
222230
*
223231
* You must SDL_free the returned buffer once you are done with it.
224232
*
225233
* \param hlslSource the HLSL source code for the shader.
226234
* \param entrypoint the entry point function name for the shader in UTF-8.
227-
* \param shaderProfile the shader profile to compile the shader with.
235+
* \param shaderStage the shader stage to compile the shader with.
228236
* \param size filled in with the bytecode buffer size.
229237
* \returns an SDL_malloc'd buffer containing SPIRV bytecode.
230238
*
@@ -233,16 +241,16 @@ extern SDL_DECLSPEC void * SDLCALL SDL_ShaderCross_CompileDXILFromHLSL(
233241
extern SDL_DECLSPEC void * SDLCALL SDL_ShaderCross_CompileSPIRVFromHLSL(
234242
const char *hlslSource,
235243
const char *entrypoint,
236-
const char *shaderProfile,
244+
SDL_ShaderCross_ShaderStage shaderStage,
237245
size_t *size);
238246

239247
/**
240-
* Compile an SDL GPU shader from HLSL code.
248+
* Compile an SDL GPU shader from HLSL Shader Model 6.0 code.
241249
*
242250
* \param device the SDL GPU device.
243251
* \param createInfo a pointer to an SDL_GPUShaderCreateInfo.
244252
* \param hlslSource the HLSL source code for the shader.
245-
* \param shaderProfile the shader profile to compile the shader with.
253+
* \param graphicsShaderStage the shader stage to compile the shader with.
246254
* \returns a compiled SDL_GPUShader
247255
*
248256
* \threadsafety It is safe to call this function from any thread.
@@ -251,24 +259,24 @@ extern SDL_DECLSPEC SDL_GPUShader * SDLCALL SDL_ShaderCross_CompileGraphicsShade
251259
SDL_GPUDevice *device,
252260
const SDL_GPUShaderCreateInfo *createInfo,
253261
const char *hlslSource,
254-
const char *shaderProfile);
262+
SDL_GPUShaderStage graphicsShaderStage);
255263

256264
/**
257-
* Compile an SDL GPU compute pipeline from HLSL code.
265+
* Compile an SDL GPU compute pipeline from HLSL Shader Model 6.0 code.
258266
*
259267
* \param device the SDL GPU device.
260268
* \param createInfo a pointer to an SDL_GPUComputePipelineCreateInfo.
261269
* \param hlslSource the HLSL source code for the shader.
262-
* \param shaderProfile the shader profile to compile the shader with.
270+
* \param shaderStage the shader stage to compile the shader with.
263271
* \returns a compiled SDL_GPUComputePipeline
264272
*
265273
* \threadsafety It is safe to call this function from any thread.
266274
*/
267275
extern SDL_DECLSPEC SDL_GPUComputePipeline * SDLCALL SDL_ShaderCross_CompileComputePipelineFromHLSL(
268276
SDL_GPUDevice *device,
269277
const SDL_GPUComputePipelineCreateInfo *createInfo,
270-
const char *hlslSource,
271-
const char *shaderProfile);
278+
const char *hlslSource);
279+
272280
#endif /* SDL_GPU_SHADERCROSS_HLSL */
273281

274282
#endif /* SDL_GPU_SHADERCROSS_H */

0 commit comments

Comments
 (0)