dxcdxrfallbackcompiler.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // //
  3. // dxcapi.h //
  4. // Copyright (C) Microsoft Corporation. All rights reserved. //
  5. // This file is distributed under the University of Illinois Open Source //
  6. // License. See LICENSE.TXT for details. //
  7. // //
  8. // Provides declarations for the DirectX Compiler API entry point. //
  9. // //
  10. ///////////////////////////////////////////////////////////////////////////////
  11. #ifndef __DXC_DXR_FALLBACK_COMPILER_API__
  12. #define __DXC_DXR_FALLBACK_COMPILER_API__
  13. #include "dxcapi.h"
  14. enum class ShaderType : unsigned int
  15. {
  16. Raygen,
  17. AnyHit,
  18. ClosestHit,
  19. Intersection,
  20. Miss,
  21. Callable,
  22. Lib,
  23. };
  24. struct DxcShaderInfo
  25. {
  26. UINT32 Identifier;
  27. UINT32 StackSize;
  28. ShaderType Type;
  29. };
  30. struct DxcShaderBytecode
  31. {
  32. LPBYTE pData;
  33. UINT32 Size;
  34. };
  35. struct DxcExportDesc
  36. {
  37. LPCWSTR ExportToRename;
  38. LPCWSTR ExportName;
  39. };
  40. struct __declspec(uuid("76bb3c85-006d-4b72-9e10-63cd97df57f0"))
  41. IDxcDxrFallbackCompiler : public IUnknown {
  42. // If set to true then shaders not listed in pShaderNames in Compile() but
  43. // called by shaders in pShaderNames are added to the final computer shader.
  44. // Otherwise these are considered errors. This is intended for testing purposes.
  45. virtual HRESULT STDMETHODCALLTYPE SetFindCalledShaders(bool val) = 0;
  46. virtual HRESULT STDMETHODCALLTYPE SetDebugOutput(int val) = 0;
  47. virtual HRESULT STDMETHODCALLTYPE RenameAndLink(
  48. _In_count_(libCount) DxcShaderBytecode *pLibs,
  49. UINT32 libCount,
  50. _In_count_(ExportCount) DxcExportDesc *pExports,
  51. UINT32 ExportCount,
  52. _COM_Outptr_ IDxcOperationResult **ppResult
  53. ) = 0;
  54. virtual HRESULT STDMETHODCALLTYPE PatchShaderBindingTables(
  55. _In_ const LPCWSTR pEntryName,
  56. _In_ DxcShaderBytecode *pShaderBytecode,
  57. _In_ void *pShaderInfo,
  58. _COM_Outptr_ IDxcOperationResult **ppResult
  59. ) = 0;
  60. // Compiles libs together to create a raytracing compute shader. One of the libs
  61. // should be the fallback implementation lib that defines functions like
  62. // Fallback_TraceRay(), Fallback_ReportHit(), etc. Fallback_TraceRay() should
  63. // be one of the shader names so that it gets included in the compile.
  64. virtual HRESULT STDMETHODCALLTYPE Compile(
  65. _In_count_(libCount) DxcShaderBytecode *pLibs, // Array of libraries containing shaders
  66. UINT32 libCount, // Number of libraries containing shaders
  67. _In_count_(shaderCount) const LPCWSTR *pShaderNames, // Array of shader names to compile
  68. _Out_writes_(shaderCount) DxcShaderInfo *pShaderInfo, // Array of shaderInfo corresponding to pShaderNames
  69. UINT32 shaderCount, // Number of shaders to compile
  70. UINT32 maxAttributeSize,
  71. _COM_Outptr_ IDxcOperationResult **ppResult // Compiler output status, buffer, and errors
  72. ) = 0;
  73. virtual HRESULT STDMETHODCALLTYPE Link(
  74. _In_ const LPCWSTR pEntryName, // Name of entry function, null if compiling a collection
  75. _In_count_(libCount) IDxcBlob **pLibs, // Array of libraries containing shaders
  76. UINT32 libCount, // Number of libraries containing shaders
  77. _In_count_(shaderCount) const LPCWSTR *pShaderNames, // Array of shader names to compile
  78. _In_count_(shaderCount) DxcShaderInfo *pShaderInfo, // Array of shaderInfo corresponding to pShaderNames
  79. UINT32 shaderCount, // Number of shaders to compile
  80. UINT32 maxAttributeSize,
  81. UINT32 stackSizeInBytes, // Continuation stack size. Use 0 for default.
  82. _COM_Outptr_ IDxcOperationResult **ppResult // Compiler output status, buffer, and errors
  83. ) = 0;
  84. };
  85. // Note: __declspec(selectany) requires 'extern'
  86. // On Linux __declspec(selectany) is removed and using 'extern' results in link error.
  87. #ifdef _MSC_VER
  88. #define CLSID_SCOPE __declspec(selectany) extern
  89. #else
  90. #define CLSID_SCOPE
  91. #endif
  92. // {76bb3c85-006d-4b72-9e10-63cd97df57f0}
  93. CLSID_SCOPE const GUID CLSID_DxcDxrFallbackCompiler = {
  94. 0x76bb3c85,
  95. 0x006d,
  96. 0x4b72,
  97. { 0x9e, 0x10, 0x63, 0xcd, 0x97, 0xdf, 0x57, 0xf0 }
  98. };
  99. typedef HRESULT(__stdcall *DxcCreateDxrFallbackCompilerProc)(
  100. _In_ REFCLSID rclsid,
  101. _In_ REFIID riid,
  102. _Out_ LPVOID* ppv
  103. );
  104. #endif