diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e4cc7947..f6903ca0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Change Log +## wgpu-core-0.6.5 (2020-10-14) + - fix setting the stencil reference on an incompatible pipeline + ## wgpu-core-0.6.4 (2020-10-05) - don't request device features that aren't needed - fix texture depth == 0 checks diff --git a/Cargo.lock b/Cargo.lock index def87599f..a0c35697a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1619,7 +1619,7 @@ dependencies = [ [[package]] name = "wgpu-core" -version = "0.6.4" +version = "0.6.5" dependencies = [ "arrayvec", "bitflags", diff --git a/wgpu-core/Cargo.toml b/wgpu-core/Cargo.toml index 1ed57474a..cb865a9dd 100644 --- a/wgpu-core/Cargo.toml +++ b/wgpu-core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wgpu-core" -version = "0.6.4" +version = "0.6.5" authors = ["wgpu developers"] edition = "2018" description = "WebGPU core logic on gfx-hal" diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 6dc994d99..7bcb07648 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -269,9 +269,10 @@ impl VertexState { #[derive(Debug)] struct State { + pipeline_flags: PipelineFlags, binder: Binder, blend_color: OptionalState, - stencil_reference: OptionalState, + stencil_reference: u32, pipeline: OptionalState, index: IndexState, vertex: VertexState, @@ -294,9 +295,6 @@ impl State { if self.blend_color == OptionalState::Required { return Err(DrawError::MissingBlendColor); } - if self.stencil_reference == OptionalState::Required { - return Err(DrawError::MissingStencilReference); - } Ok(()) } @@ -929,9 +927,10 @@ impl Global { }; let mut state = State { + pipeline_flags: PipelineFlags::empty(), binder: Binder::new(cmd_buf.limits.max_bind_groups), blend_color: OptionalState::Unused, - stencil_reference: OptionalState::Unused, + stencil_reference: 0, pipeline: OptionalState::Required, index: IndexState::default(), vertex: VertexState::default(), @@ -995,12 +994,14 @@ impl Global { }; } RenderCommand::SetPipeline(pipeline_id) => { - state.pipeline = OptionalState::Set; let pipeline = trackers .render_pipes .use_extend(&*pipeline_guard, pipeline_id, (), ()) .unwrap(); + state.pipeline = OptionalState::Set; + state.pipeline_flags = pipeline.flags; + if !context.compatible(&pipeline.pass_context) { return Err(RenderCommandError::IncompatiblePipeline.into()); } @@ -1013,14 +1014,20 @@ impl Global { state .blend_color .require(pipeline.flags.contains(PipelineFlags::BLEND_COLOR)); - state - .stencil_reference - .require(pipeline.flags.contains(PipelineFlags::STENCIL_REFERENCE)); unsafe { raw.bind_graphics_pipeline(&pipeline.raw); } + if pipeline.flags.contains(PipelineFlags::STENCIL_REFERENCE) { + unsafe { + raw.set_stencil_reference( + hal::pso::Face::all(), + state.stencil_reference, + ); + } + } + // Rebind resource if state.binder.pipeline_layout_id != Some(pipeline.layout_id.value) { let pipeline_layout = &pipeline_layout_guard[pipeline.layout_id.value]; @@ -1187,9 +1194,14 @@ impl Global { } } RenderCommand::SetStencilReference(value) => { - state.stencil_reference = OptionalState::Set; - unsafe { - raw.set_stencil_reference(hal::pso::Face::all(), value); + state.stencil_reference = value; + if state + .pipeline_flags + .contains(PipelineFlags::STENCIL_REFERENCE) + { + unsafe { + raw.set_stencil_reference(hal::pso::Face::all(), value); + } } } RenderCommand::SetViewport { diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index b81a742a2..2ddb3872a 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -2928,7 +2928,7 @@ impl Global { } } if let Some(ds) = depth_stencil_state.as_ref() { - if ds.stencil.needs_ref_value() { + if ds.stencil.is_enabled() && ds.stencil.needs_ref_value() { flags |= pipeline::PipelineFlags::STENCIL_REFERENCE; } if !ds.is_read_only() {