mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-08 15:43:41 +00:00
Log HLSL for dump_shaders even if HLSL compilation fails
Fixed: dawn:1681 Change-Id: I56abb56c47d97105fac541a49c377cc0222feb10 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/130460 Reviewed-by: Antonio Maiorano <amaiorano@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
a246d8d3c2
commit
94bc4cf046
@ -347,12 +347,17 @@ void DumpCompiledShader(Device* device,
|
|||||||
const CompiledShader& compiledShader,
|
const CompiledShader& compiledShader,
|
||||||
uint32_t compileFlags) {
|
uint32_t compileFlags) {
|
||||||
std::ostringstream dumpedMsg;
|
std::ostringstream dumpedMsg;
|
||||||
|
// The HLSL may be empty if compilation failed.
|
||||||
|
if (!compiledShader.hlslSource.empty()) {
|
||||||
dumpedMsg << "/* Dumped generated HLSL */" << std::endl
|
dumpedMsg << "/* Dumped generated HLSL */" << std::endl
|
||||||
<< compiledShader.hlslSource << std::endl;
|
<< compiledShader.hlslSource << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The blob may be empty if FXC/DXC compilation failed.
|
||||||
|
const Blob& shaderBlob = compiledShader.shaderBlob;
|
||||||
|
if (!shaderBlob.Empty()) {
|
||||||
if (device->IsToggleEnabled(Toggle::UseDXC)) {
|
if (device->IsToggleEnabled(Toggle::UseDXC)) {
|
||||||
dumpedMsg << "/* Dumped disassembled DXIL */" << std::endl;
|
dumpedMsg << "/* Dumped disassembled DXIL */" << std::endl;
|
||||||
const Blob& shaderBlob = compiledShader.shaderBlob;
|
|
||||||
ComPtr<IDxcBlobEncoding> dxcBlob;
|
ComPtr<IDxcBlobEncoding> dxcBlob;
|
||||||
ComPtr<IDxcBlobEncoding> disassembly;
|
ComPtr<IDxcBlobEncoding> disassembly;
|
||||||
if (FAILED(device->GetDxcLibrary()->CreateBlobWithEncodingFromPinned(
|
if (FAILED(device->GetDxcLibrary()->CreateBlobWithEncodingFromPinned(
|
||||||
@ -360,7 +365,8 @@ void DumpCompiledShader(Device* device,
|
|||||||
FAILED(device->GetDxcCompiler()->Disassemble(dxcBlob.Get(), &disassembly))) {
|
FAILED(device->GetDxcCompiler()->Disassemble(dxcBlob.Get(), &disassembly))) {
|
||||||
dumpedMsg << "DXC disassemble failed" << std::endl;
|
dumpedMsg << "DXC disassemble failed" << std::endl;
|
||||||
} else {
|
} else {
|
||||||
dumpedMsg << std::string_view(static_cast<const char*>(disassembly->GetBufferPointer()),
|
dumpedMsg << std::string_view(
|
||||||
|
static_cast<const char*>(disassembly->GetBufferPointer()),
|
||||||
disassembly->GetBufferSize());
|
disassembly->GetBufferSize());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -368,7 +374,6 @@ void DumpCompiledShader(Device* device,
|
|||||||
<< CompileFlagsToStringFXC(compileFlags) << std::endl;
|
<< CompileFlagsToStringFXC(compileFlags) << std::endl;
|
||||||
dumpedMsg << "/* Dumped disassembled DXBC */" << std::endl;
|
dumpedMsg << "/* Dumped disassembled DXBC */" << std::endl;
|
||||||
ComPtr<ID3DBlob> disassembly;
|
ComPtr<ID3DBlob> disassembly;
|
||||||
const Blob& shaderBlob = compiledShader.shaderBlob;
|
|
||||||
UINT flags =
|
UINT flags =
|
||||||
// Some literals are printed as floats with precision(6) which is not enough
|
// Some literals are printed as floats with precision(6) which is not enough
|
||||||
// precision for values very close to 0, so always print literals as hex values.
|
// precision for values very close to 0, so always print literals as hex values.
|
||||||
@ -377,11 +382,17 @@ void DumpCompiledShader(Device* device,
|
|||||||
flags, nullptr, &disassembly))) {
|
flags, nullptr, &disassembly))) {
|
||||||
dumpedMsg << "D3D disassemble failed" << std::endl;
|
dumpedMsg << "D3D disassemble failed" << std::endl;
|
||||||
} else {
|
} else {
|
||||||
dumpedMsg << std::string_view(static_cast<const char*>(disassembly->GetBufferPointer()),
|
dumpedMsg << std::string_view(
|
||||||
|
static_cast<const char*>(disassembly->GetBufferPointer()),
|
||||||
disassembly->GetBufferSize());
|
disassembly->GetBufferSize());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
device->EmitLog(WGPULoggingType_Info, dumpedMsg.str().c_str());
|
}
|
||||||
|
|
||||||
|
std::string logMessage = dumpedMsg.str();
|
||||||
|
if (!logMessage.empty()) {
|
||||||
|
device->EmitLog(WGPULoggingType_Info, logMessage.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace dawn::native::d3d
|
} // namespace dawn::native::d3d
|
||||||
|
@ -158,13 +158,20 @@ ResultOrError<d3d::CompiledShader> ShaderModule::Compile(
|
|||||||
req.hlsl.limits = LimitsForCompilationRequest::Create(limits.v1);
|
req.hlsl.limits = LimitsForCompilationRequest::Create(limits.v1);
|
||||||
|
|
||||||
CacheResult<d3d::CompiledShader> compiledShader;
|
CacheResult<d3d::CompiledShader> compiledShader;
|
||||||
|
MaybeError compileError = [&]() -> MaybeError {
|
||||||
DAWN_TRY_LOAD_OR_RUN(compiledShader, device, std::move(req), d3d::CompiledShader::FromBlob,
|
DAWN_TRY_LOAD_OR_RUN(compiledShader, device, std::move(req), d3d::CompiledShader::FromBlob,
|
||||||
d3d::CompileShader);
|
d3d::CompileShader);
|
||||||
|
return {};
|
||||||
|
}();
|
||||||
|
|
||||||
if (req.hlsl.dumpShaders) {
|
if (device->IsToggleEnabled(Toggle::DumpShaders)) {
|
||||||
d3d::DumpCompiledShader(device, *compiledShader, compileFlags);
|
d3d::DumpCompiledShader(device, *compiledShader, compileFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (compileError.IsError()) {
|
||||||
|
return {compileError.AcquireError()};
|
||||||
|
}
|
||||||
|
|
||||||
device->GetBlobCache()->EnsureStored(compiledShader);
|
device->GetBlobCache()->EnsureStored(compiledShader);
|
||||||
|
|
||||||
// Clear the hlslSource. It is only used for logging and should not be used
|
// Clear the hlslSource. It is only used for logging and should not be used
|
||||||
|
@ -207,13 +207,20 @@ ResultOrError<d3d::CompiledShader> ShaderModule::Compile(
|
|||||||
req.hlsl.limits = LimitsForCompilationRequest::Create(limits.v1);
|
req.hlsl.limits = LimitsForCompilationRequest::Create(limits.v1);
|
||||||
|
|
||||||
CacheResult<d3d::CompiledShader> compiledShader;
|
CacheResult<d3d::CompiledShader> compiledShader;
|
||||||
|
MaybeError compileError = [&]() -> MaybeError {
|
||||||
DAWN_TRY_LOAD_OR_RUN(compiledShader, device, std::move(req), d3d::CompiledShader::FromBlob,
|
DAWN_TRY_LOAD_OR_RUN(compiledShader, device, std::move(req), d3d::CompiledShader::FromBlob,
|
||||||
d3d::CompileShader);
|
d3d::CompileShader);
|
||||||
|
return {};
|
||||||
|
}();
|
||||||
|
|
||||||
if (device->IsToggleEnabled(Toggle::DumpShaders)) {
|
if (device->IsToggleEnabled(Toggle::DumpShaders)) {
|
||||||
d3d::DumpCompiledShader(device, *compiledShader, compileFlags);
|
d3d::DumpCompiledShader(device, *compiledShader, compileFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (compileError.IsError()) {
|
||||||
|
return {compileError.AcquireError()};
|
||||||
|
}
|
||||||
|
|
||||||
device->GetBlobCache()->EnsureStored(compiledShader);
|
device->GetBlobCache()->EnsureStored(compiledShader);
|
||||||
|
|
||||||
// Clear the hlslSource. It is only used for logging and should not be used
|
// Clear the hlslSource. It is only used for logging and should not be used
|
||||||
|
Loading…
x
Reference in New Issue
Block a user