瀏覽代碼

sokol_gfx.h: allow #include directive for d3d11 shaders

Reuben Dunnington 4 周之前
父節點
當前提交
fbe735a58f
共有 1 個文件被更改,包括 9 次插入6 次删除
  1. 9 6
      sokol_gfx.h

+ 9 - 6
sokol_gfx.h

@@ -3443,6 +3443,8 @@ typedef struct sg_sampler_desc {
     source code, you can provide an optional target string via
     source code, you can provide an optional target string via
     sg_shader_stage_desc.d3d11_target, the default target is "vs_4_0" for the
     sg_shader_stage_desc.d3d11_target, the default target is "vs_4_0" for the
     vertex shader stage and "ps_4_0" for the pixel shader stage.
     vertex shader stage and "ps_4_0" for the pixel shader stage.
+    You may optionally provide the file path to enable the default #include handler
+    behavior when compiling source code.
 */
 */
 typedef enum sg_shader_stage {
 typedef enum sg_shader_stage {
     SG_SHADERSTAGE_NONE,
     SG_SHADERSTAGE_NONE,
@@ -3457,6 +3459,7 @@ typedef struct sg_shader_function {
     sg_range bytecode;
     sg_range bytecode;
     const char* entry;
     const char* entry;
     const char* d3d11_target;   // default: "vs_4_0" or "ps_4_0"
     const char* d3d11_target;   // default: "vs_4_0" or "ps_4_0"
+    const char* d3d11_filepath;
 } sg_shader_function;
 } sg_shader_function;
 
 
 typedef enum sg_shader_attr_base_type {
 typedef enum sg_shader_attr_base_type {
@@ -12445,13 +12448,13 @@ _SOKOL_PRIVATE ID3DBlob* _sg_d3d11_compile_shader(const sg_shader_function* shd_
     ID3DBlob* output = NULL;
     ID3DBlob* output = NULL;
     ID3DBlob* errors_or_warnings = NULL;
     ID3DBlob* errors_or_warnings = NULL;
     HRESULT hr = _sg.d3d11.D3DCompile_func(
     HRESULT hr = _sg.d3d11.D3DCompile_func(
-        shd_func->source,               // pSrcData
-        strlen(shd_func->source),       // SrcDataSize
-        NULL,                           // pSourceName
-        NULL,                           // pDefines
-        NULL,                           // pInclude
+        shd_func->source,                  // pSrcData
+        strlen(shd_func->source),          // SrcDataSize
+        shd_func->d3d11_filepath,          // pSourceName
+        NULL,                              // pDefines
+        D3D_COMPILE_STANDARD_FILE_INCLUDE, // pInclude
         shd_func->entry ? shd_func->entry : "main", // pEntryPoint
         shd_func->entry ? shd_func->entry : "main", // pEntryPoint
-        shd_func->d3d11_target,         // pTarget
+        shd_func->d3d11_target,            // pTarget
         flags1,     // Flags1
         flags1,     // Flags1
         0,          // Flags2
         0,          // Flags2
         &output,    // ppCode
         &output,    // ppCode