Skip to content

Commit

Permalink
Merge #3697
Browse files Browse the repository at this point in the history
3697: [mtl] fix depth/stencil state in secondary command buffers r=kvark a=kvark

Fixes the current visual issues with running Dota2 on gfx-portability

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
  • Loading branch information
bors[bot] and kvark authored Mar 25, 2021
2 parents f3df513 + 146f661 commit 4619678
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/backend/metal/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ impl State {
})
}

#[must_use]
fn build_depth_stencil(&mut self) -> Option<pso::DepthStencilDesc> {
let mut desc = match self.render_pso {
Some(ref rp) => rp.ds_desc,
Expand Down Expand Up @@ -2626,6 +2627,12 @@ impl com::CommandBuffer<Backend> for CommandBuffer {

if let Some(framebuffer) = info.framebuffer {
self.state.target.extent = framebuffer.extent;
self.state.active_scissor = MTLScissorRect {
x: 0,
y: 0,
width: framebuffer.extent.width as u64,
height: framebuffer.extent.height as u64,
};
}
if let Some(sp) = info.subpass {
let subpass = &sp.main_pass.subpasses[sp.index as usize];
Expand All @@ -2640,6 +2647,7 @@ impl com::CommandBuffer<Backend> for CommandBuffer {
let aspects = rat.format.unwrap().surface_desc().aspects;
self.state.target.aspects |= aspects;
}
self.state.active_depth_stencil_desc = pso::DepthStencilDesc::default();

match inner.sink {
Some(CommandSink::Deferred {
Expand All @@ -2661,7 +2669,7 @@ impl com::CommandBuffer<Backend> for CommandBuffer {
));
}
_ => {
warn!("Unexpected inheritance info on a primary command buffer");
panic!("Unexpected inheritance info on a primary command buffer");
}
}
}
Expand Down Expand Up @@ -3073,6 +3081,7 @@ impl com::CommandBuffer<Backend> for CommandBuffer {

// reset all the affected states
let device_lock = &self.shared.device;
self.state.active_depth_stencil_desc = pso::DepthStencilDesc::default();
let com_ds = match self.state.build_depth_stencil() {
Some(desc) => {
ds_state = ds_store.get(desc, device_lock);
Expand Down Expand Up @@ -3635,19 +3644,12 @@ impl com::CommandBuffer<Backend> for CommandBuffer {

let ds_store = &self.shared.service_pipes.depth_stencil_states;
let ds_state;
let com_ds = if sin
.combined_aspects
.intersects(Aspects::DEPTH | Aspects::STENCIL)
{
match self.state.build_depth_stencil() {
Some(desc) => {
ds_state = ds_store.get(desc, &self.shared.device);
Some(soft::RenderCommand::SetDepthStencilState(&**ds_state))
}
None => None,
let com_ds = match self.state.build_depth_stencil() {
Some(desc) => {
ds_state = ds_store.get(desc, &self.shared.device);
Some(soft::RenderCommand::SetDepthStencilState(&**ds_state))
}
} else {
None
None => None,
};

let init_commands = self
Expand Down

0 comments on commit 4619678

Please sign in to comment.