Dxc.cpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. // Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #include <AnKi/ShaderCompiler/Dxc.h>
  6. #include <AnKi/Util/Process.h>
  7. #include <AnKi/Util/Filesystem.h>
  8. #include <AnKi/Util/File.h>
  9. #include <AnKi/Util/HighRezTimer.h>
  10. #include <AnKi/Util/StringList.h>
  11. #include <string>
  12. #if ANKI_OS_WINDOWS
  13. # include <windows.h>
  14. # include <wrl/client.h>
  15. # include <ThirdParty/Dxc/d3d12shader.h>
  16. # define CComPtr Microsoft::WRL::ComPtr
  17. #else
  18. # pragma GCC diagnostic push
  19. # pragma GCC diagnostic ignored "-Wimplicit-int-conversion"
  20. # pragma GCC diagnostic ignored "-Wambiguous-reversed-operator"
  21. # define __EMULATE_UUID
  22. # include <ThirdParty/Dxc/WinAdapter.h>
  23. # pragma GCC diagnostic pop
  24. #endif
  25. #include <ThirdParty/Dxc/dxcapi.h>
  26. namespace anki {
  27. static Atomic<U32> g_nextFileId = {1};
  28. #if ANKI_OS_WINDOWS
  29. static HMODULE g_dxilLib = 0;
  30. #endif
  31. static HMODULE g_dxcLib = 0;
  32. static DxcCreateInstanceProc g_DxcCreateInstance = nullptr;
  33. static Mutex g_dxcLibMtx;
  34. #define ANKI_DXC_CHECK(x) \
  35. do \
  36. { \
  37. HRESULT rez; \
  38. if((rez = (x)) < 0) [[unlikely]] \
  39. { \
  40. errorMessage.sprintf("DXC function failed (HRESULT: %d): %s", rez, #x); \
  41. return Error::kFunctionFailed; \
  42. } \
  43. } while(0)
  44. static Error lazyDxcInit(ShaderCompilerString& errorMessage)
  45. {
  46. LockGuard lock(g_dxcLibMtx);
  47. if(g_dxcLib == 0)
  48. {
  49. // Init DXC
  50. #if ANKI_OS_WINDOWS
  51. g_dxilLib = LoadLibraryA(ANKI_SOURCE_DIRECTORY "/ThirdParty/Dxc/dxil.dll");
  52. if(g_dxilLib == 0)
  53. {
  54. errorMessage = "dxil.dll missing or wrong architecture";
  55. return Error::kFunctionFailed;
  56. }
  57. g_dxcLib = LoadLibraryA(ANKI_SOURCE_DIRECTORY "/ThirdParty/Dxc/dxcompiler.dll");
  58. #else
  59. g_dxcLib = dlopen(ANKI_SOURCE_DIRECTORY "/ThirdParty/Dxc/libdxcompiler.so", RTLD_LAZY);
  60. #endif
  61. if(g_dxcLib == 0)
  62. {
  63. errorMessage = "dxcompiler.dll/libdxcompiler.so missing or wrong architecture";
  64. return Error::kFunctionFailed;
  65. }
  66. #if ANKI_OS_WINDOWS
  67. g_DxcCreateInstance = reinterpret_cast<DxcCreateInstanceProc>(GetProcAddress(g_dxcLib, "DxcCreateInstance"));
  68. #else
  69. g_DxcCreateInstance = reinterpret_cast<DxcCreateInstanceProc>(dlsym(g_dxcLib, "DxcCreateInstance"));
  70. #endif
  71. if(g_DxcCreateInstance == nullptr)
  72. {
  73. errorMessage = "DxcCreateInstance was not found in the dxcompiler.dll/libdxcompiler.so";
  74. return Error::kFunctionFailed;
  75. }
  76. }
  77. return Error::kNone;
  78. }
  79. static const WChar* profile(ShaderType shaderType, ShaderModel sm)
  80. {
  81. #define ANKI_SM(stage) out = (sm == ShaderModel::k6_7) ? L"" #stage "_6_7" : L"" #stage "_6_8"
  82. const WChar* out = L"";
  83. switch(shaderType)
  84. {
  85. case ShaderType::kVertex:
  86. ANKI_SM(vs);
  87. break;
  88. case ShaderType::kPixel:
  89. ANKI_SM(ps);
  90. break;
  91. case ShaderType::kDomain:
  92. ANKI_SM(ds);
  93. break;
  94. case ShaderType::kHull:
  95. ANKI_SM(hs);
  96. break;
  97. case ShaderType::kGeometry:
  98. ANKI_SM(gs);
  99. break;
  100. case ShaderType::kAmplification:
  101. ANKI_SM(as);
  102. break;
  103. case ShaderType::kMesh:
  104. ANKI_SM(ms);
  105. break;
  106. case ShaderType::kCompute:
  107. ANKI_SM(cs);
  108. break;
  109. case ShaderType::kRayGen:
  110. case ShaderType::kAnyHit:
  111. case ShaderType::kClosestHit:
  112. case ShaderType::kMiss:
  113. case ShaderType::kIntersection:
  114. case ShaderType::kCallable:
  115. case ShaderType::kWorkGraph:
  116. ANKI_SM(lib);
  117. break;
  118. default:
  119. ANKI_ASSERT(0);
  120. };
  121. return out;
  122. #undef ANKI_SM
  123. }
  124. static Error compileHlsl(CString src, ShaderType shaderType, Bool compileWith16bitTypes, Bool debugInfo, ShaderModel sm,
  125. ConstWeakArray<CString> compilerArgs, Bool spirv, ShaderCompilerDynamicArray<U8>& bin, ShaderCompilerString& errorMessage)
  126. {
  127. ANKI_CHECK(lazyDxcInit(errorMessage));
  128. // Call DXC
  129. std::vector<std::wstring> dxcArgs;
  130. dxcArgs.push_back(L"-Fo");
  131. dxcArgs.push_back(L"-Wall");
  132. dxcArgs.push_back(L"-Wextra");
  133. dxcArgs.push_back(L"-Wno-conversion");
  134. dxcArgs.push_back(L"-Werror");
  135. dxcArgs.push_back(L"-Wfatal-errors");
  136. dxcArgs.push_back(L"-Wundef");
  137. dxcArgs.push_back(L"-Wno-unused-const-variable");
  138. dxcArgs.push_back(L"-Wno-unused-parameter");
  139. dxcArgs.push_back(L"-Wno-unneeded-internal-declaration");
  140. dxcArgs.push_back(L"-Wno-payload-access-perf"); // Doesn't always work
  141. dxcArgs.push_back(L"-HV");
  142. dxcArgs.push_back(L"2021");
  143. dxcArgs.push_back(L"-E");
  144. dxcArgs.push_back(L"main");
  145. dxcArgs.push_back(L"-T");
  146. dxcArgs.push_back(profile(shaderType, sm));
  147. if(ANKI_COMPILER_MSVC)
  148. {
  149. dxcArgs.push_back(L"-fdiagnostics-format=msvc"); // Make errors clickable in visual studio
  150. }
  151. if(spirv)
  152. {
  153. dxcArgs.push_back(L"-spirv");
  154. dxcArgs.push_back(L"-fspv-target-env=vulkan1.1spirv1.4");
  155. // dxcArgs.push_back(L"-fvk-support-nonzero-base-instance"); // Match DX12's behavior, SV_INSTANCEID starts from zero
  156. // Shift the bindings in order to identify the registers when doing reflection
  157. for(U32 ds = 0; ds < kMaxRegisterSpaces; ++ds)
  158. {
  159. dxcArgs.push_back(L"-fvk-b-shift");
  160. dxcArgs.push_back(std::to_wstring(kDxcVkBindingShifts[ds][HlslResourceType::kCbv]));
  161. dxcArgs.push_back(std::to_wstring(ds));
  162. dxcArgs.push_back(L"-fvk-t-shift");
  163. dxcArgs.push_back(std::to_wstring(kDxcVkBindingShifts[ds][HlslResourceType::kSrv]));
  164. dxcArgs.push_back(std::to_wstring(ds));
  165. dxcArgs.push_back(L"-fvk-u-shift");
  166. dxcArgs.push_back(std::to_wstring(kDxcVkBindingShifts[ds][HlslResourceType::kUav]));
  167. dxcArgs.push_back(std::to_wstring(ds));
  168. dxcArgs.push_back(L"-fvk-s-shift");
  169. dxcArgs.push_back(std::to_wstring(kDxcVkBindingShifts[ds][HlslResourceType::kSampler]));
  170. dxcArgs.push_back(std::to_wstring(ds));
  171. }
  172. }
  173. else
  174. {
  175. dxcArgs.push_back(L"-Wno-ignored-attributes"); // TODO remove that at some point
  176. dxcArgs.push_back(L"-Wno-inline-asm"); // Workaround a DXC bug
  177. }
  178. if(debugInfo)
  179. {
  180. dxcArgs.push_back(L"-Zi");
  181. }
  182. if(compileWith16bitTypes)
  183. {
  184. dxcArgs.push_back(L"-enable-16bit-types");
  185. }
  186. for(CString extraArg : compilerArgs)
  187. {
  188. WChar wstr[128];
  189. extraArg.toWideChars(wstr, 128);
  190. dxcArgs.push_back(wstr);
  191. }
  192. std::vector<const WChar*> dxcArgsRaw;
  193. dxcArgsRaw.reserve(dxcArgs.size());
  194. for(const auto& x : dxcArgs)
  195. {
  196. dxcArgsRaw.push_back(x.c_str());
  197. }
  198. // Compile
  199. CComPtr<IDxcCompiler3> dxcCompiler;
  200. ANKI_DXC_CHECK(g_DxcCreateInstance(CLSID_DxcCompiler, IID_PPV_ARGS(&dxcCompiler)));
  201. const DxcBuffer buff = {src.getBegin(), src.getLength(), 0};
  202. CComPtr<IDxcResult> pResults;
  203. ANKI_DXC_CHECK(dxcCompiler->Compile(&buff, dxcArgsRaw.data(), U32(dxcArgsRaw.size()), nullptr, IID_PPV_ARGS(&pResults)));
  204. CComPtr<IDxcBlobUtf8> pErrors = nullptr;
  205. ANKI_DXC_CHECK(pResults->GetOutput(DXC_OUT_ERRORS, IID_PPV_ARGS(&pErrors), nullptr));
  206. if(pErrors != nullptr && pErrors->GetStringLength() != 0)
  207. {
  208. errorMessage = pErrors->GetStringPointer();
  209. }
  210. HRESULT hrStatus;
  211. ANKI_DXC_CHECK(pResults->GetStatus(&hrStatus));
  212. if(FAILED(hrStatus))
  213. {
  214. return Error::kFunctionFailed;
  215. }
  216. CComPtr<IDxcBlob> pShader = nullptr;
  217. ANKI_DXC_CHECK(pResults->GetOutput(DXC_OUT_OBJECT, IID_PPV_ARGS(&pShader), nullptr));
  218. if(pShader != nullptr)
  219. {
  220. bin.resize(U32(pShader->GetBufferSize()));
  221. memcpy(bin.getBegin(), pShader->GetBufferPointer(), pShader->GetBufferSize());
  222. }
  223. return Error::kNone;
  224. }
  225. Error compileHlslToSpirv(CString src, ShaderType shaderType, Bool compileWith16bitTypes, Bool debugInfo, ShaderModel sm,
  226. ConstWeakArray<CString> compilerArgs, ShaderCompilerDynamicArray<U8>& spirv, ShaderCompilerString& errorMessage)
  227. {
  228. return compileHlsl(src, shaderType, compileWith16bitTypes, debugInfo, sm, compilerArgs, true, spirv, errorMessage);
  229. }
  230. Error compileHlslToDxil(CString src, ShaderType shaderType, Bool compileWith16bitTypes, Bool debugInfo, ShaderModel sm,
  231. ConstWeakArray<CString> compilerArgs, ShaderCompilerDynamicArray<U8>& dxil, ShaderCompilerString& errorMessage)
  232. {
  233. return compileHlsl(src, shaderType, compileWith16bitTypes, debugInfo, sm, compilerArgs, false, dxil, errorMessage);
  234. }
  235. #if ANKI_OS_WINDOWS
  236. Error doReflectionDxil(ConstWeakArray<U8> dxil, ShaderType type, ShaderReflection& refl, ShaderCompilerString& errorMessage)
  237. {
  238. using Microsoft::WRL::ComPtr;
  239. // Lazyly load the DXC DLL
  240. {
  241. LockGuard lock(g_dxcLibMtx);
  242. if(g_dxcLib == 0)
  243. {
  244. // Init DXC
  245. g_dxcLib = LoadLibraryA(ANKI_SOURCE_DIRECTORY "/ThirdParty/Bin/Windows64/dxcompiler.dll");
  246. if(g_dxcLib == 0)
  247. {
  248. ANKI_SHADER_COMPILER_LOGE("dxcompiler.dll missing or wrong architecture");
  249. return Error::kFunctionFailed;
  250. }
  251. g_DxcCreateInstance = reinterpret_cast<DxcCreateInstanceProc>(GetProcAddress(g_dxcLib, "DxcCreateInstance"));
  252. if(g_DxcCreateInstance == nullptr)
  253. {
  254. ANKI_SHADER_COMPILER_LOGE("DxcCreateInstance was not found in the dxcompiler.dll");
  255. return Error::kFunctionFailed;
  256. }
  257. }
  258. }
  259. const Bool isLib = (type >= ShaderType::kFirstRayTracing && type <= ShaderType::kLastRayTracing) || type == ShaderType::kWorkGraph;
  260. ComPtr<IDxcUtils> utils;
  261. ANKI_DXC_CHECK(g_DxcCreateInstance(CLSID_DxcUtils, IID_PPV_ARGS(&utils)));
  262. ComPtr<ID3D12ShaderReflection> dxRefl;
  263. ComPtr<ID3D12LibraryReflection> libRefl;
  264. ShaderCompilerDynamicArray<ID3D12FunctionReflection*> funcReflections;
  265. D3D12_SHADER_DESC shaderDesc = {};
  266. if(isLib)
  267. {
  268. const DxcBuffer buff = {dxil.getBegin(), dxil.getSizeInBytes(), 0};
  269. ANKI_DXC_CHECK(utils->CreateReflection(&buff, IID_PPV_ARGS(&libRefl)));
  270. D3D12_LIBRARY_DESC libDesc = {};
  271. libRefl->GetDesc(&libDesc);
  272. if(libDesc.FunctionCount == 0)
  273. {
  274. errorMessage.sprintf("Expecting at least 1 in D3D12_LIBRARY_DESC::FunctionCount");
  275. return Error::kUserData;
  276. }
  277. funcReflections.resize(libDesc.FunctionCount);
  278. for(U32 i = 0; i < libDesc.FunctionCount; ++i)
  279. {
  280. funcReflections[i] = libRefl->GetFunctionByIndex(i);
  281. }
  282. }
  283. else
  284. {
  285. const DxcBuffer buff = {dxil.getBegin(), dxil.getSizeInBytes(), 0};
  286. ANKI_DXC_CHECK(utils->CreateReflection(&buff, IID_PPV_ARGS(&dxRefl)));
  287. ANKI_DXC_CHECK(dxRefl->GetDesc(&shaderDesc));
  288. }
  289. for(U32 ifunc = 0; ifunc < ((isLib) ? funcReflections.getSize() : 1); ++ifunc)
  290. {
  291. U32 bindingCount;
  292. if(isLib)
  293. {
  294. D3D12_FUNCTION_DESC funcDesc;
  295. ANKI_DXC_CHECK(funcReflections[ifunc]->GetDesc(&funcDesc));
  296. bindingCount = funcDesc.BoundResources;
  297. }
  298. else
  299. {
  300. bindingCount = shaderDesc.BoundResources;
  301. }
  302. for(U32 i = 0; i < bindingCount; ++i)
  303. {
  304. D3D12_SHADER_INPUT_BIND_DESC bindDesc;
  305. if(isLib)
  306. {
  307. ANKI_DXC_CHECK(funcReflections[ifunc]->GetResourceBindingDesc(i, &bindDesc));
  308. }
  309. else
  310. {
  311. ANKI_DXC_CHECK(dxRefl->GetResourceBindingDesc(i, &bindDesc));
  312. }
  313. ShaderReflectionBinding akBinding;
  314. akBinding.m_type = DescriptorType::kCount;
  315. akBinding.m_arraySize = U16(bindDesc.BindCount);
  316. akBinding.m_registerBindingPoint = bindDesc.BindPoint;
  317. if(bindDesc.Type == D3D_SIT_CBUFFER)
  318. {
  319. // ConstantBuffer
  320. if(bindDesc.Space == 3000 && bindDesc.BindPoint == 0)
  321. {
  322. // It's push/root constants
  323. ID3D12ShaderReflectionConstantBuffer* cbuffer =
  324. (isLib) ? funcReflections[ifunc]->GetConstantBufferByName(bindDesc.Name) : dxRefl->GetConstantBufferByName(bindDesc.Name);
  325. D3D12_SHADER_BUFFER_DESC desc;
  326. ANKI_DXC_CHECK(cbuffer->GetDesc(&desc));
  327. refl.m_descriptor.m_fastConstantsSize = desc.Size;
  328. continue;
  329. }
  330. akBinding.m_type = DescriptorType::kConstantBuffer;
  331. }
  332. else if(bindDesc.Type == D3D_SIT_TEXTURE && bindDesc.Dimension != D3D_SRV_DIMENSION_BUFFER)
  333. {
  334. // Texture2D etc
  335. akBinding.m_type = DescriptorType::kSrvTexture;
  336. }
  337. else if(bindDesc.Type == D3D_SIT_TEXTURE && bindDesc.Dimension == D3D_SRV_DIMENSION_BUFFER)
  338. {
  339. // Buffer
  340. akBinding.m_type = DescriptorType::kSrvTexelBuffer;
  341. }
  342. else if(bindDesc.Type == D3D_SIT_SAMPLER)
  343. {
  344. // SamplerState
  345. akBinding.m_type = DescriptorType::kSampler;
  346. }
  347. else if(bindDesc.Type == D3D_SIT_UAV_RWTYPED && bindDesc.Dimension == D3D_SRV_DIMENSION_BUFFER)
  348. {
  349. // RWBuffer
  350. akBinding.m_type = DescriptorType::kUavTexelBuffer;
  351. }
  352. else if(bindDesc.Type == D3D_SIT_UAV_RWTYPED && bindDesc.Dimension != D3D_SRV_DIMENSION_BUFFER)
  353. {
  354. // RWTexture2D etc
  355. akBinding.m_type = DescriptorType::kUavTexture;
  356. }
  357. else if(bindDesc.Type == D3D_SIT_BYTEADDRESS)
  358. {
  359. // ByteAddressBuffer
  360. akBinding.m_type = DescriptorType::kSrvByteAddressBuffer;
  361. akBinding.m_d3dStructuredBufferStride = sizeof(U32);
  362. }
  363. else if(bindDesc.Type == D3D_SIT_UAV_RWBYTEADDRESS)
  364. {
  365. // RWByteAddressBuffer
  366. akBinding.m_type = DescriptorType::kUavByteAddressBuffer;
  367. akBinding.m_d3dStructuredBufferStride = sizeof(U32);
  368. }
  369. else if(bindDesc.Type == D3D_SIT_RTACCELERATIONSTRUCTURE)
  370. {
  371. // RaytracingAccelerationStructure
  372. akBinding.m_type = DescriptorType::kAccelerationStructure;
  373. }
  374. else if(bindDesc.Type == D3D_SIT_STRUCTURED)
  375. {
  376. // StructuredBuffer
  377. akBinding.m_type = DescriptorType::kSrvStructuredBuffer;
  378. akBinding.m_d3dStructuredBufferStride = U16(bindDesc.NumSamples);
  379. }
  380. else if(bindDesc.Type == D3D_SIT_UAV_RWSTRUCTURED)
  381. {
  382. // RWStructuredBuffer
  383. akBinding.m_type = DescriptorType::kUavStructuredBuffer;
  384. akBinding.m_d3dStructuredBufferStride = U16(bindDesc.NumSamples);
  385. }
  386. else
  387. {
  388. errorMessage.sprintf("Unrecognized type for binding: %s", bindDesc.Name);
  389. return Error::kUserData;
  390. }
  391. Bool skip = false;
  392. if(isLib)
  393. {
  394. // Search if the binding exists because it may repeat
  395. for(U32 i = 0; i < refl.m_descriptor.m_bindingCounts[bindDesc.Space]; ++i)
  396. {
  397. if(refl.m_descriptor.m_bindings[bindDesc.Space][i] == akBinding)
  398. {
  399. skip = true;
  400. break;
  401. }
  402. }
  403. }
  404. if(!skip)
  405. {
  406. refl.m_descriptor.m_bindings[bindDesc.Space][refl.m_descriptor.m_bindingCounts[bindDesc.Space]] = akBinding;
  407. ++refl.m_descriptor.m_bindingCounts[bindDesc.Space];
  408. }
  409. }
  410. }
  411. for(U32 i = 0; i < kMaxRegisterSpaces; ++i)
  412. {
  413. std::sort(refl.m_descriptor.m_bindings[i].getBegin(), refl.m_descriptor.m_bindings[i].getBegin() + refl.m_descriptor.m_bindingCounts[i]);
  414. }
  415. if(type == ShaderType::kVertex)
  416. {
  417. for(U32 i = 0; i < shaderDesc.InputParameters; ++i)
  418. {
  419. D3D12_SIGNATURE_PARAMETER_DESC in;
  420. ANKI_DXC_CHECK(dxRefl->GetInputParameterDesc(i, &in));
  421. VertexAttributeSemantic a = VertexAttributeSemantic::kCount;
  422. # define ANKI_ATTRIB_NAME(x, idx) CString(in.SemanticName) == # x&& in.SemanticIndex == idx
  423. if(ANKI_ATTRIB_NAME(POSITION, 0))
  424. {
  425. a = VertexAttributeSemantic::kPosition;
  426. }
  427. else if(ANKI_ATTRIB_NAME(NORMAL, 0))
  428. {
  429. a = VertexAttributeSemantic::kNormal;
  430. }
  431. else if(ANKI_ATTRIB_NAME(TEXCOORD, 0))
  432. {
  433. a = VertexAttributeSemantic::kTexCoord;
  434. }
  435. else if(ANKI_ATTRIB_NAME(COLOR, 0))
  436. {
  437. a = VertexAttributeSemantic::kColor;
  438. }
  439. else if(ANKI_ATTRIB_NAME(MISC, 0))
  440. {
  441. a = VertexAttributeSemantic::kMisc0;
  442. }
  443. else if(ANKI_ATTRIB_NAME(MISC, 1))
  444. {
  445. a = VertexAttributeSemantic::kMisc1;
  446. }
  447. else if(ANKI_ATTRIB_NAME(MISC, 2))
  448. {
  449. a = VertexAttributeSemantic::kMisc2;
  450. }
  451. else if(ANKI_ATTRIB_NAME(MISC, 3))
  452. {
  453. a = VertexAttributeSemantic::kMisc3;
  454. }
  455. else if(ANKI_ATTRIB_NAME(SV_VERTEXID, 0) || ANKI_ATTRIB_NAME(SV_INSTANCEID, 0))
  456. {
  457. // Ignore
  458. continue;
  459. }
  460. else
  461. {
  462. errorMessage.sprintf("Unexpected attribute name: %s", in.SemanticName);
  463. return Error::kUserData;
  464. }
  465. # undef ANKI_ATTRIB_NAME
  466. refl.m_vertex.m_vertexAttributeMask |= VertexAttributeSemanticBit(1 << a);
  467. refl.m_vertex.m_vkVertexAttributeLocations[a] = U8(i); // Just set something
  468. }
  469. }
  470. if(type == ShaderType::kPixel)
  471. {
  472. for(U32 i = 0; i < shaderDesc.OutputParameters; ++i)
  473. {
  474. D3D12_SIGNATURE_PARAMETER_DESC desc;
  475. ANKI_DXC_CHECK(dxRefl->GetOutputParameterDesc(i, &desc));
  476. if(CString(desc.SemanticName) == "SV_TARGET")
  477. {
  478. refl.m_pixel.m_colorRenderTargetWritemask.set(desc.SemanticIndex);
  479. }
  480. }
  481. }
  482. return Error::kNone;
  483. }
  484. #endif
  485. } // end namespace anki