tint/cmd: Dump disassembly with --verbose
Change-Id: I2701117b6c253b632091a59fc1a63d97526d5ce2 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97500 Auto-Submit: Ben Clayton <bclayton@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
92f2cb79b5
commit
86329e286b
|
@ -868,9 +868,13 @@ bool GenerateHlsl(const tint::Program* program, const Options& options) {
|
|||
if (options.verbose) {
|
||||
if (fxc_found && !fxc_res.failed) {
|
||||
std::cout << "Passed FXC validation" << std::endl;
|
||||
std::cout << fxc_res.output;
|
||||
std::cout << std::endl;
|
||||
}
|
||||
if (dxc_found && !dxc_res.failed) {
|
||||
std::cout << "Passed DXC validation" << std::endl;
|
||||
std::cout << dxc_res.output;
|
||||
std::cout << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,13 +114,21 @@ Result HlslUsingFXC(const std::string& fxc_path,
|
|||
return result;
|
||||
}
|
||||
|
||||
pD3DCompile d3dCompile = reinterpret_cast<pD3DCompile>(
|
||||
auto* d3dCompile = reinterpret_cast<pD3DCompile>(
|
||||
reinterpret_cast<void*>(GetProcAddress(fxcLib, "D3DCompile")));
|
||||
auto* d3dDisassemble = reinterpret_cast<pD3DDisassemble>(
|
||||
reinterpret_cast<void*>(GetProcAddress(fxcLib, "D3DDisassemble")));
|
||||
|
||||
if (d3dCompile == nullptr) {
|
||||
result.output = "Couldn't load D3DCompile from FXC";
|
||||
result.failed = true;
|
||||
return result;
|
||||
}
|
||||
if (d3dDisassemble == nullptr) {
|
||||
result.output = "Couldn't load D3DDisassemble from FXC";
|
||||
result.failed = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
for (auto ep : entry_points) {
|
||||
const char* profile = "";
|
||||
|
@ -147,7 +155,7 @@ Result HlslUsingFXC(const std::string& fxc_path,
|
|||
|
||||
ComPtr<ID3DBlob> compiledShader;
|
||||
ComPtr<ID3DBlob> errors;
|
||||
HRESULT cr = d3dCompile(source.c_str(), // pSrcData
|
||||
HRESULT res = d3dCompile(source.c_str(), // pSrcData
|
||||
source.length(), // SrcDataSize
|
||||
nullptr, // pSourceName
|
||||
nullptr, // pDefines
|
||||
|
@ -158,10 +166,19 @@ Result HlslUsingFXC(const std::string& fxc_path,
|
|||
0, // Flags2
|
||||
&compiledShader, // ppCode
|
||||
&errors); // ppErrorMsgs
|
||||
if (FAILED(cr)) {
|
||||
if (FAILED(res)) {
|
||||
result.output = static_cast<char*>(errors->GetBufferPointer());
|
||||
result.failed = true;
|
||||
return result;
|
||||
} else {
|
||||
ComPtr<ID3DBlob> disassembly;
|
||||
res = d3dDisassemble(compiledShader->GetBufferPointer(),
|
||||
compiledShader->GetBufferSize(), 0, "", &disassembly);
|
||||
if (FAILED(res)) {
|
||||
result.output = "failed to disassemble shader";
|
||||
} else {
|
||||
result.output = static_cast<char*>(disassembly->GetBufferPointer());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue