Skip to content

Instantly share code, notes, and snippets.

@giordi91
Created August 14, 2020 09:46
Show Gist options
  • Save giordi91/eb5fbc52f3b91f2943d25549893dcf88 to your computer and use it in GitHub Desktop.
Save giordi91/eb5fbc52f3b91f2943d25549893dcf88 to your computer and use it in GitHub Desktop.
//compilation
// kick the compilation
pCompiler->Compile(
pSource, // program text
wshader, // file name, mostly for error messages
shaderArgs.entryPoint, // entry point function
shaderArgs.type, // target profile
const_cast<LPCWSTR *>(finalFlags.data()), // compilation arguments
flagsCount, // number of compilation arguments
nullptr, 0, // name/value defines and their count
includeHandle, // handler for #include directives
&pResult);
// checking whether or not compilation was successful
HRESULT hrCompilation;
pResult->GetStatus(&hrCompilation);
IDxcBlobEncoding *pPrintBlob;
pResult->GetErrorBuffer(&pPrintBlob);
size_t printBlobSize = pPrintBlob->GetBufferSize();
const char *outLog = nullptr;
if (printBlobSize != 0) {
outLog = frameConcatenation(
static_cast<char *>(pPrintBlob->GetBufferPointer()), "\n");
}
if (FAILED(hrCompilation)) {
SE_CORE_ERROR("ERROR_LOG:\n {0}", outLog);
pPrintBlob->Release();
return {nullptr, outLog};
}
if (printBlobSize != 0) {
SE_CORE_WARN("COMPILER LOG:\n {0}", outLog);
}
// extract compiled blob of data
IDxcBlob *pResultBlob;
pResult->GetResult(&pResultBlob);
//validation
CComPtr<IDxcOperationResult> pValResult;
HRESULT validationResult = pValidator->Validate(pResultBlob,DxcValidatorFlags_InPlaceEdit,&pValResult);
assert(SUCCEEDED(validationResult));
IDxcBlobEncoding *pPrintBlobValidation;
pValResult->GetErrorBuffer(&pPrintBlobValidation);
pValResult->GetStatus(&rr);
size_t printBlobSizeValidation = pPrintBlobValidation->GetBufferSize();
if (printBlobSizeValidation) {
outLog = frameConcatenation(
static_cast<char *>(pPrintBlobValidation->GetBufferPointer()), "\n");
SE_CORE_ERROR("ERROR_LOG:\n {0}", outLog);
return {nullptr, outLog};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment