Dxc.cpp 15 KB

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