mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 14:55:05 +00:00
render/compute pass descriptors work now with dyn types
This commit is contained in:
parent
bdf6710d58
commit
a47a0cb3d9
@ -1041,7 +1041,7 @@ impl<'d, A: HalApi> RenderPassInfo<'d, A> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut color_attachments_hal =
|
let mut color_attachments_hal =
|
||||||
ArrayVec::<Option<hal::ColorAttachment<A>>, { hal::MAX_COLOR_ATTACHMENTS }>::new();
|
ArrayVec::<Option<hal::ColorAttachment<_>>, { hal::MAX_COLOR_ATTACHMENTS }>::new();
|
||||||
for (index, attachment) in color_attachments.iter().enumerate() {
|
for (index, attachment) in color_attachments.iter().enumerate() {
|
||||||
let at = if let Some(attachment) = attachment.as_ref() {
|
let at = if let Some(attachment) = attachment.as_ref() {
|
||||||
attachment
|
attachment
|
||||||
|
@ -661,7 +661,10 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
|||||||
|
|
||||||
// render
|
// render
|
||||||
|
|
||||||
unsafe fn begin_render_pass(&mut self, desc: &crate::RenderPassDescriptor<super::Api>) {
|
unsafe fn begin_render_pass(
|
||||||
|
&mut self,
|
||||||
|
desc: &crate::RenderPassDescriptor<super::QuerySet, super::TextureView>,
|
||||||
|
) {
|
||||||
unsafe { self.begin_pass(super::PassKind::Render, desc.label) };
|
unsafe { self.begin_pass(super::PassKind::Render, desc.label) };
|
||||||
|
|
||||||
// Start timestamp if any (before all other commands but after debug marker)
|
// Start timestamp if any (before all other commands but after debug marker)
|
||||||
@ -1130,7 +1133,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
|||||||
|
|
||||||
unsafe fn begin_compute_pass<'a>(
|
unsafe fn begin_compute_pass<'a>(
|
||||||
&mut self,
|
&mut self,
|
||||||
desc: &crate::ComputePassDescriptor<'a, super::Api>,
|
desc: &crate::ComputePassDescriptor<'a, super::QuerySet>,
|
||||||
) {
|
) {
|
||||||
unsafe { self.begin_pass(super::PassKind::Compute, desc.label) };
|
unsafe { self.begin_pass(super::PassKind::Compute, desc.label) };
|
||||||
|
|
||||||
|
@ -370,7 +370,8 @@ impl crate::CommandEncoder for Encoder {
|
|||||||
|
|
||||||
// render
|
// render
|
||||||
|
|
||||||
unsafe fn begin_render_pass(&mut self, desc: &crate::RenderPassDescriptor<Api>) {}
|
unsafe fn begin_render_pass(&mut self, desc: &crate::RenderPassDescriptor<Resource, Resource>) {
|
||||||
|
}
|
||||||
unsafe fn end_render_pass(&mut self) {}
|
unsafe fn end_render_pass(&mut self) {}
|
||||||
|
|
||||||
unsafe fn set_bind_group(
|
unsafe fn set_bind_group(
|
||||||
@ -465,7 +466,7 @@ impl crate::CommandEncoder for Encoder {
|
|||||||
|
|
||||||
// compute
|
// compute
|
||||||
|
|
||||||
unsafe fn begin_compute_pass(&mut self, desc: &crate::ComputePassDescriptor<Api>) {}
|
unsafe fn begin_compute_pass(&mut self, desc: &crate::ComputePassDescriptor<Resource>) {}
|
||||||
unsafe fn end_compute_pass(&mut self) {}
|
unsafe fn end_compute_pass(&mut self) {}
|
||||||
|
|
||||||
unsafe fn set_compute_pipeline(&mut self, pipeline: &Resource) {}
|
unsafe fn set_compute_pipeline(&mut self, pipeline: &Resource) {}
|
||||||
|
@ -494,7 +494,10 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
|||||||
|
|
||||||
// render
|
// render
|
||||||
|
|
||||||
unsafe fn begin_render_pass(&mut self, desc: &crate::RenderPassDescriptor<super::Api>) {
|
unsafe fn begin_render_pass(
|
||||||
|
&mut self,
|
||||||
|
desc: &crate::RenderPassDescriptor<super::QuerySet, super::TextureView>,
|
||||||
|
) {
|
||||||
debug_assert!(self.state.end_of_pass_timestamp.is_none());
|
debug_assert!(self.state.end_of_pass_timestamp.is_none());
|
||||||
if let Some(ref t) = desc.timestamp_writes {
|
if let Some(ref t) = desc.timestamp_writes {
|
||||||
if let Some(index) = t.beginning_of_pass_write_index {
|
if let Some(index) = t.beginning_of_pass_write_index {
|
||||||
@ -1137,7 +1140,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
|||||||
|
|
||||||
// compute
|
// compute
|
||||||
|
|
||||||
unsafe fn begin_compute_pass(&mut self, desc: &crate::ComputePassDescriptor<super::Api>) {
|
unsafe fn begin_compute_pass(&mut self, desc: &crate::ComputePassDescriptor<super::QuerySet>) {
|
||||||
debug_assert!(self.state.end_of_pass_timestamp.is_none());
|
debug_assert!(self.state.end_of_pass_timestamp.is_none());
|
||||||
if let Some(ref t) = desc.timestamp_writes {
|
if let Some(ref t) = desc.timestamp_writes {
|
||||||
if let Some(index) = t.beginning_of_pass_write_index {
|
if let Some(index) = t.beginning_of_pass_write_index {
|
||||||
|
@ -1231,7 +1231,10 @@ pub trait CommandEncoder: WasmNotSendSync + fmt::Debug {
|
|||||||
// render passes
|
// render passes
|
||||||
|
|
||||||
// Begins a render pass, clears all active bindings.
|
// Begins a render pass, clears all active bindings.
|
||||||
unsafe fn begin_render_pass(&mut self, desc: &RenderPassDescriptor<Self::A>);
|
unsafe fn begin_render_pass(
|
||||||
|
&mut self,
|
||||||
|
desc: &RenderPassDescriptor<<Self::A as Api>::QuerySet, <Self::A as Api>::TextureView>,
|
||||||
|
);
|
||||||
unsafe fn end_render_pass(&mut self);
|
unsafe fn end_render_pass(&mut self);
|
||||||
|
|
||||||
unsafe fn set_render_pipeline(&mut self, pipeline: &<Self::A as Api>::RenderPipeline);
|
unsafe fn set_render_pipeline(&mut self, pipeline: &<Self::A as Api>::RenderPipeline);
|
||||||
@ -1298,7 +1301,10 @@ pub trait CommandEncoder: WasmNotSendSync + fmt::Debug {
|
|||||||
// compute passes
|
// compute passes
|
||||||
|
|
||||||
// Begins a compute pass, clears all active bindings.
|
// Begins a compute pass, clears all active bindings.
|
||||||
unsafe fn begin_compute_pass(&mut self, desc: &ComputePassDescriptor<Self::A>);
|
unsafe fn begin_compute_pass(
|
||||||
|
&mut self,
|
||||||
|
desc: &ComputePassDescriptor<<Self::A as Api>::QuerySet>,
|
||||||
|
);
|
||||||
unsafe fn end_compute_pass(&mut self);
|
unsafe fn end_compute_pass(&mut self);
|
||||||
|
|
||||||
unsafe fn set_compute_pipeline(&mut self, pipeline: &<Self::A as Api>::ComputePipeline);
|
unsafe fn set_compute_pipeline(&mut self, pipeline: &<Self::A as Api>::ComputePipeline);
|
||||||
@ -2028,47 +2034,25 @@ pub struct BufferTextureCopy {
|
|||||||
pub size: CopyExtent,
|
pub size: CopyExtent,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Attachment<'a, A: Api> {
|
pub struct Attachment<'a, T: DynTextureView + ?Sized> {
|
||||||
pub view: &'a A::TextureView,
|
pub view: &'a T,
|
||||||
/// Contains either a single mutating usage as a target,
|
/// Contains either a single mutating usage as a target,
|
||||||
/// or a valid combination of read-only usages.
|
/// or a valid combination of read-only usages.
|
||||||
pub usage: TextureUses,
|
pub usage: TextureUses,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rust gets confused about the impl requirements for `A`
|
#[derive(Clone, Debug)]
|
||||||
impl<A: Api> Clone for Attachment<'_, A> {
|
pub struct ColorAttachment<'a, T: DynTextureView + ?Sized> {
|
||||||
fn clone(&self) -> Self {
|
pub target: Attachment<'a, T>,
|
||||||
Self {
|
pub resolve_target: Option<Attachment<'a, T>>,
|
||||||
view: self.view,
|
|
||||||
usage: self.usage,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct ColorAttachment<'a, A: Api> {
|
|
||||||
pub target: Attachment<'a, A>,
|
|
||||||
pub resolve_target: Option<Attachment<'a, A>>,
|
|
||||||
pub ops: AttachmentOps,
|
pub ops: AttachmentOps,
|
||||||
pub clear_value: wgt::Color,
|
pub clear_value: wgt::Color,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rust gets confused about the impl requirements for `A`
|
|
||||||
impl<A: Api> Clone for ColorAttachment<'_, A> {
|
|
||||||
fn clone(&self) -> Self {
|
|
||||||
Self {
|
|
||||||
target: self.target.clone(),
|
|
||||||
resolve_target: self.resolve_target.clone(),
|
|
||||||
ops: self.ops,
|
|
||||||
clear_value: self.clear_value,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct DepthStencilAttachment<'a, A: Api> {
|
pub struct DepthStencilAttachment<'a, T: DynTextureView + ?Sized> {
|
||||||
pub target: Attachment<'a, A>,
|
pub target: Attachment<'a, T>,
|
||||||
pub depth_ops: AttachmentOps,
|
pub depth_ops: AttachmentOps,
|
||||||
pub stencil_ops: AttachmentOps,
|
pub stencil_ops: AttachmentOps,
|
||||||
pub clear_value: (f32, u32),
|
pub clear_value: (f32, u32),
|
||||||
@ -2082,21 +2066,21 @@ pub struct PassTimestampWrites<'a, Q: DynQuerySet + ?Sized> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct RenderPassDescriptor<'a, A: Api> {
|
pub struct RenderPassDescriptor<'a, Q: DynQuerySet + ?Sized, T: DynTextureView + ?Sized> {
|
||||||
pub label: Label<'a>,
|
pub label: Label<'a>,
|
||||||
pub extent: wgt::Extent3d,
|
pub extent: wgt::Extent3d,
|
||||||
pub sample_count: u32,
|
pub sample_count: u32,
|
||||||
pub color_attachments: &'a [Option<ColorAttachment<'a, A>>],
|
pub color_attachments: &'a [Option<ColorAttachment<'a, T>>],
|
||||||
pub depth_stencil_attachment: Option<DepthStencilAttachment<'a, A>>,
|
pub depth_stencil_attachment: Option<DepthStencilAttachment<'a, T>>,
|
||||||
pub multiview: Option<NonZeroU32>,
|
pub multiview: Option<NonZeroU32>,
|
||||||
pub timestamp_writes: Option<PassTimestampWrites<'a, A::QuerySet>>,
|
pub timestamp_writes: Option<PassTimestampWrites<'a, Q>>,
|
||||||
pub occlusion_query_set: Option<&'a A::QuerySet>,
|
pub occlusion_query_set: Option<&'a Q>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct ComputePassDescriptor<'a, A: Api> {
|
pub struct ComputePassDescriptor<'a, Q: DynQuerySet + ?Sized> {
|
||||||
pub label: Label<'a>,
|
pub label: Label<'a>,
|
||||||
pub timestamp_writes: Option<PassTimestampWrites<'a, A::QuerySet>>,
|
pub timestamp_writes: Option<PassTimestampWrites<'a, Q>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stores the text of any validation errors that have occurred since
|
/// Stores the text of any validation errors that have occurred since
|
||||||
|
@ -501,7 +501,10 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
|||||||
|
|
||||||
// render
|
// render
|
||||||
|
|
||||||
unsafe fn begin_render_pass(&mut self, desc: &crate::RenderPassDescriptor<super::Api>) {
|
unsafe fn begin_render_pass(
|
||||||
|
&mut self,
|
||||||
|
desc: &crate::RenderPassDescriptor<super::QuerySet, super::TextureView>,
|
||||||
|
) {
|
||||||
self.begin_pass();
|
self.begin_pass();
|
||||||
self.state.index = None;
|
self.state.index = None;
|
||||||
|
|
||||||
@ -1128,7 +1131,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
|||||||
|
|
||||||
// compute
|
// compute
|
||||||
|
|
||||||
unsafe fn begin_compute_pass(&mut self, desc: &crate::ComputePassDescriptor<super::Api>) {
|
unsafe fn begin_compute_pass(&mut self, desc: &crate::ComputePassDescriptor<super::QuerySet>) {
|
||||||
self.begin_pass();
|
self.begin_pass();
|
||||||
|
|
||||||
debug_assert!(self.state.blit.is_none());
|
debug_assert!(self.state.blit.is_none());
|
||||||
|
@ -644,7 +644,10 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
|||||||
}
|
}
|
||||||
// render
|
// render
|
||||||
|
|
||||||
unsafe fn begin_render_pass(&mut self, desc: &crate::RenderPassDescriptor<super::Api>) {
|
unsafe fn begin_render_pass(
|
||||||
|
&mut self,
|
||||||
|
desc: &crate::RenderPassDescriptor<super::QuerySet, super::TextureView>,
|
||||||
|
) {
|
||||||
let mut vk_clear_values =
|
let mut vk_clear_values =
|
||||||
ArrayVec::<vk::ClearValue, { super::MAX_TOTAL_ATTACHMENTS }>::new();
|
ArrayVec::<vk::ClearValue, { super::MAX_TOTAL_ATTACHMENTS }>::new();
|
||||||
let mut vk_image_views = ArrayVec::<vk::ImageView, { super::MAX_TOTAL_ATTACHMENTS }>::new();
|
let mut vk_image_views = ArrayVec::<vk::ImageView, { super::MAX_TOTAL_ATTACHMENTS }>::new();
|
||||||
@ -1067,7 +1070,10 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
|||||||
|
|
||||||
// compute
|
// compute
|
||||||
|
|
||||||
unsafe fn begin_compute_pass(&mut self, desc: &crate::ComputePassDescriptor<'_, super::Api>) {
|
unsafe fn begin_compute_pass(
|
||||||
|
&mut self,
|
||||||
|
desc: &crate::ComputePassDescriptor<'_, super::QuerySet>,
|
||||||
|
) {
|
||||||
self.bind_point = vk::PipelineBindPoint::COMPUTE;
|
self.bind_point = vk::PipelineBindPoint::COMPUTE;
|
||||||
if let Some(label) = desc.label {
|
if let Some(label) = desc.label {
|
||||||
unsafe { self.begin_debug_marker(label) };
|
unsafe { self.begin_debug_marker(label) };
|
||||||
|
@ -178,7 +178,7 @@ pub fn map_vk_surface_formats(sf: vk::SurfaceFormatKHR) -> Option<wgt::TextureFo
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
impl crate::Attachment<'_, super::Api> {
|
impl crate::Attachment<'_, super::TextureView> {
|
||||||
pub(super) fn make_attachment_key(
|
pub(super) fn make_attachment_key(
|
||||||
&self,
|
&self,
|
||||||
ops: crate::AttachmentOps,
|
ops: crate::AttachmentOps,
|
||||||
@ -192,7 +192,7 @@ impl crate::Attachment<'_, super::Api> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl crate::ColorAttachment<'_, super::Api> {
|
impl crate::ColorAttachment<'_, super::TextureView> {
|
||||||
pub(super) unsafe fn make_vk_clear_color(&self) -> vk::ClearColorValue {
|
pub(super) unsafe fn make_vk_clear_color(&self) -> vk::ClearColorValue {
|
||||||
let cv = &self.clear_value;
|
let cv = &self.clear_value;
|
||||||
match self
|
match self
|
||||||
|
Loading…
Reference in New Issue
Block a user