mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 23:04:07 +00:00
Merge #1273
1273: Properly return native shader module errors to users r=kvark a=Gordon-F
**Testing**
Disable `cross` feature, break `naga` and see what happens 😄
```log
wgpu error: Validation Error
Caused by:
In Device::create_render_pipeline
Internal error in stage VERTEX: Error compiling the shader "\"Compilation failed: \\n\\nprogram_source:1:1: error: unknown type name \\\'sadgasdgasdgasdg\\\'\\nsadgasdgasdgasdg aasdgadsgb>\\n^\\nprogram_source:1:28: error: expected \\\';\\\' after top level declarator\\nsadgasdgasdgasdg aasdgadsgb>\\n
```
Co-authored-by: Gordon-F <ishaposhnik@icloud.com>
This commit is contained in:
commit
c831c5512a
@ -154,6 +154,25 @@ pub fn map_shader_stage_flags(shader_stage_flags: wgt::ShaderStage) -> hal::pso:
|
||||
value
|
||||
}
|
||||
|
||||
pub fn map_hal_flags_to_shader_stage(
|
||||
shader_stage_flags: hal::pso::ShaderStageFlags,
|
||||
) -> wgt::ShaderStage {
|
||||
use hal::pso::ShaderStageFlags as H;
|
||||
use wgt::ShaderStage as Ss;
|
||||
|
||||
let mut value = Ss::empty();
|
||||
if shader_stage_flags.contains(H::VERTEX) {
|
||||
value |= Ss::VERTEX;
|
||||
}
|
||||
if shader_stage_flags.contains(H::FRAGMENT) {
|
||||
value |= Ss::FRAGMENT;
|
||||
}
|
||||
if shader_stage_flags.contains(H::COMPUTE) {
|
||||
value |= Ss::COMPUTE;
|
||||
}
|
||||
value
|
||||
}
|
||||
|
||||
pub fn map_extent(extent: &wgt::Extent3d, dim: wgt::TextureDimension) -> hal::image::Extent {
|
||||
hal::image::Extent {
|
||||
width: extent.width,
|
||||
|
@ -1940,10 +1940,15 @@ impl<B: GfxBackend> Device<B> {
|
||||
let raw =
|
||||
unsafe { self.raw.create_compute_pipeline(&pipeline_desc, None) }.map_err(|err| {
|
||||
match err {
|
||||
hal::pso::CreationError::OutOfMemory(_) => DeviceError::OutOfMemory,
|
||||
hal::pso::CreationError::OutOfMemory(_) => {
|
||||
pipeline::CreateComputePipelineError::Device(DeviceError::OutOfMemory)
|
||||
}
|
||||
hal::pso::CreationError::ShaderCreationError(_, error) => {
|
||||
pipeline::CreateComputePipelineError::Internal(error)
|
||||
}
|
||||
_ => {
|
||||
log::error!("failed to create compute pipeline: {}", err);
|
||||
DeviceError::OutOfMemory
|
||||
pipeline::CreateComputePipelineError::Device(DeviceError::OutOfMemory)
|
||||
}
|
||||
}
|
||||
})?;
|
||||
@ -2391,10 +2396,18 @@ impl<B: GfxBackend> Device<B> {
|
||||
let raw =
|
||||
unsafe { self.raw.create_graphics_pipeline(&pipeline_desc, None) }.map_err(|err| {
|
||||
match err {
|
||||
hal::pso::CreationError::OutOfMemory(_) => DeviceError::OutOfMemory,
|
||||
hal::pso::CreationError::OutOfMemory(_) => {
|
||||
pipeline::CreateRenderPipelineError::Device(DeviceError::OutOfMemory)
|
||||
}
|
||||
hal::pso::CreationError::ShaderCreationError(stage, error) => {
|
||||
pipeline::CreateRenderPipelineError::Internal {
|
||||
stage: conv::map_hal_flags_to_shader_stage(stage),
|
||||
error,
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
log::error!("failed to create graphics pipeline: {}", err);
|
||||
DeviceError::OutOfMemory
|
||||
pipeline::CreateRenderPipelineError::Device(DeviceError::OutOfMemory)
|
||||
}
|
||||
}
|
||||
})?;
|
||||
|
@ -113,6 +113,8 @@ pub enum CreateComputePipelineError {
|
||||
Implicit(#[from] ImplicitLayoutError),
|
||||
#[error(transparent)]
|
||||
Stage(validation::StageError),
|
||||
#[error("Internal error: {0}")]
|
||||
Internal(String),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -234,6 +236,11 @@ pub enum CreateRenderPipelineError {
|
||||
#[source]
|
||||
error: validation::StageError,
|
||||
},
|
||||
#[error("Internal error in stage {stage:?}: {error}")]
|
||||
Internal {
|
||||
stage: wgt::ShaderStage,
|
||||
error: String,
|
||||
},
|
||||
}
|
||||
|
||||
bitflags::bitflags! {
|
||||
|
Loading…
Reference in New Issue
Block a user