Skip to content
This repository has been archived by the owner on Jun 18, 2021. It is now read-only.

Commit

Permalink
Read-only depth-stencil support
Browse files Browse the repository at this point in the history
  • Loading branch information
kvark committed Jun 2, 2020
1 parent 50d1eb6 commit ac6f79c
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ vulkan = ["wgc/gfx-backend-vulkan"]
package = "wgpu-core"
version = "0.5"
git = "https://github.com/gfx-rs/wgpu"
rev = "3a6cdeec945b6e2795c5ad544101b273c3887037"
rev = "fbc2c87de61b0e7bab2583ddf305742e3cbf85e8"
features = ["raw-window-handle"]

[dependencies.wgt]
package = "wgpu-types"
version = "0.5"
git = "https://github.com/gfx-rs/wgpu"
rev = "3a6cdeec945b6e2795c5ad544101b273c3887037"
rev = "fbc2c87de61b0e7bab2583ddf305742e3cbf85e8"

[dependencies]
arrayvec = "0.5"
Expand Down
4 changes: 4 additions & 0 deletions examples/shadow/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -752,10 +752,12 @@ impl framework::Example for Example {
attachment: &light.target_view,
depth_load_op: wgpu::LoadOp::Clear,
depth_store_op: wgpu::StoreOp::Store,
depth_read_only: false,
stencil_load_op: wgpu::LoadOp::Clear,
stencil_store_op: wgpu::StoreOp::Store,
clear_depth: 1.0,
clear_stencil: 0,
stencil_read_only: false,
}),
});
pass.set_pipeline(&self.shadow_pass.pipeline);
Expand Down Expand Up @@ -788,10 +790,12 @@ impl framework::Example for Example {
attachment: &self.forward_depth,
depth_load_op: wgpu::LoadOp::Clear,
depth_store_op: wgpu::StoreOp::Store,
depth_read_only: false,
stencil_load_op: wgpu::LoadOp::Clear,
stencil_store_op: wgpu::StoreOp::Store,
clear_depth: 1.0,
clear_stencil: 0,
stencil_read_only: false,
}),
});
pass.set_pipeline(&self.forward_pass.pipeline);
Expand Down
18 changes: 15 additions & 3 deletions src/backend/direct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -684,11 +684,21 @@ impl crate::Context for Context {
fn swap_chain_get_next_texture(
&self,
swap_chain: &Self::SwapChainId,
) -> (Option<Self::TextureViewId>, SwapChainStatus, Self::SwapChainOutputDetail) {
let wgc::swap_chain::SwapChainOutput { status, view_id } =
) -> (
Option<Self::TextureViewId>,
SwapChainStatus,
Self::SwapChainOutputDetail,
) {
let wgc::swap_chain::SwapChainOutput { status, view_id } =
gfx_select!(*swap_chain => self.swap_chain_get_next_texture(*swap_chain, PhantomData));

(view_id, status, SwapChainOutputDetail { swap_chain_id: *swap_chain })
(
view_id,
status,
SwapChainOutputDetail {
swap_chain_id: *swap_chain,
},
)
}

fn swap_chain_present(&self, view: &Self::TextureViewId, detail: &Self::SwapChainOutputDetail) {
Expand Down Expand Up @@ -845,10 +855,12 @@ impl crate::Context for Context {
attachment: dsa.attachment.id,
depth_load_op: dsa.depth_load_op,
depth_store_op: dsa.depth_store_op,
depth_read_only: dsa.depth_read_only,
clear_depth: dsa.clear_depth,
stencil_load_op: dsa.stencil_load_op,
stencil_store_op: dsa.stencil_store_op,
clear_stencil: dsa.clear_stencil,
stencil_read_only: dsa.depth_read_only,
}
});

Expand Down
12 changes: 10 additions & 2 deletions src/backend/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1102,10 +1102,18 @@ impl crate::Context for Context {
fn swap_chain_get_next_texture(
&self,
swap_chain: &Self::SwapChainId,
) -> (Option<Self::TextureViewId>, SwapChainStatus, Self::SwapChainOutputDetail) {
) -> (
Option<Self::TextureViewId>,
SwapChainStatus,
Self::SwapChainOutputDetail,
) {
// TODO: Should we pass a descriptor here?
// Or is the default view always correct?
(Some(Sendable(swap_chain.0.get_current_texture().create_view())), SwapChainStatus::Good, ())
(
Some(Sendable(swap_chain.0.get_current_texture().create_view())),
SwapChainStatus::Good,
(),
)
}

fn swap_chain_present(
Expand Down
10 changes: 7 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ pub use wgt::{
DeviceDescriptor, DynamicOffset, Extensions, Extent3d, FilterMode, FrontFace, IndexFormat,
InputStepMode, Limits, LoadOp, Origin3d, PowerPreference, PresentMode, PrimitiveTopology,
RasterizationStateDescriptor, ShaderLocation, ShaderStage, StencilOperation,
StencilStateFaceDescriptor, StoreOp, SwapChainDescriptor, SwapChainStatus, TextureAspect,
TextureComponentType, TextureDataLayout, TextureDimension, TextureFormat, TextureUsage,
StencilStateFaceDescriptor, StoreOp, SwapChainDescriptor, SwapChainStatus, TextureAspect,
TextureComponentType, TextureDataLayout, TextureDimension, TextureFormat, TextureUsage,
TextureViewDimension, VertexAttributeDescriptor, VertexFormat, BIND_BUFFER_ALIGNMENT,
};

Expand Down Expand Up @@ -217,7 +217,11 @@ trait Context: Sized {
fn swap_chain_get_next_texture(
&self,
swap_chain: &Self::SwapChainId,
) -> (Option<Self::TextureViewId>, SwapChainStatus, Self::SwapChainOutputDetail);
) -> (
Option<Self::TextureViewId>,
SwapChainStatus,
Self::SwapChainOutputDetail,
);
fn swap_chain_present(&self, view: &Self::TextureViewId, detail: &Self::SwapChainOutputDetail);
fn texture_create_view(
&self,
Expand Down

0 comments on commit ac6f79c

Please sign in to comment.