hal/dx12: don't assume D3DCompile error is some

This commit is contained in:
Dzmitry Malyshau 2021-08-26 12:59:24 -04:00 committed by Dzmitry Malyshau
parent 42194168e0
commit 5fd4fffdde

View File

@ -244,17 +244,20 @@ impl super::Device {
let (result, log_level) = match hr.into_result() {
Ok(()) => (Ok(shader_data), log::Level::Info),
Err(e) => {
let mut full_msg = format!("D3DCompile error ({})", e);
if !error.is_null() {
use std::fmt::Write as _;
let message = unsafe {
let slice = slice::from_raw_parts(
slice::from_raw_parts(
error.GetBufferPointer() as *const u8,
error.GetBufferSize(),
);
String::from_utf8_lossy(slice)
)
};
let full_msg = format!("D3DCompile error ({}): {}", e, message);
write!(full_msg, ": {}", String::from_utf8_lossy(message));
unsafe {
error.destroy();
}
}
(
Err(crate::PipelineError::Linkage(stage_bit, full_msg)),
log::Level::Warn,