mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 22:33:49 +00:00
implement transition_textures for DynCommandEncoder
This commit is contained in:
parent
eeaf27749c
commit
39b408218f
@ -272,7 +272,10 @@ impl PendingTransition<hal::BufferUses> {
|
||||
|
||||
impl PendingTransition<hal::TextureUses> {
|
||||
/// Produce the hal barrier corresponding to the transition.
|
||||
pub fn into_hal<'a, A: HalApi>(self, texture: &'a A::Texture) -> hal::TextureBarrier<'a, A> {
|
||||
pub fn into_hal<'a, T: hal::DynTexture + ?Sized>(
|
||||
self,
|
||||
texture: &'a T,
|
||||
) -> hal::TextureBarrier<'a, T> {
|
||||
// These showing up in a barrier is always a bug
|
||||
strict_assert_ne!(self.usage.start, hal::TextureUses::UNKNOWN);
|
||||
strict_assert_ne!(self.usage.end, hal::TextureUses::UNKNOWN);
|
||||
|
@ -754,7 +754,7 @@ impl<A: HalApi> DeviceTextureTracker<A> {
|
||||
&'a mut self,
|
||||
tracker: &'a TextureTracker<A>,
|
||||
snatch_guard: &'b SnatchGuard<'b>,
|
||||
) -> impl Iterator<Item = TextureBarrier<'a, A>> {
|
||||
) -> impl Iterator<Item = TextureBarrier<'a, A::Texture>> {
|
||||
for index in tracker.metadata.owned_indices() {
|
||||
self.tracker_assert_in_bounds(index);
|
||||
|
||||
@ -798,7 +798,7 @@ impl<A: HalApi> DeviceTextureTracker<A> {
|
||||
&'a mut self,
|
||||
scope: &'a TextureUsageScope<A>,
|
||||
snatch_guard: &'b SnatchGuard<'b>,
|
||||
) -> impl Iterator<Item = TextureBarrier<'a, A>> {
|
||||
) -> impl Iterator<Item = TextureBarrier<'a, A::Texture>> {
|
||||
for index in scope.metadata.owned_indices() {
|
||||
self.tracker_assert_in_bounds(index);
|
||||
|
||||
|
@ -359,7 +359,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
||||
|
||||
unsafe fn transition_textures<'a, T>(&mut self, barriers: T)
|
||||
where
|
||||
T: Iterator<Item = crate::TextureBarrier<'a, super::Api>>,
|
||||
T: Iterator<Item = crate::TextureBarrier<'a, super::Texture>>,
|
||||
{
|
||||
self.temp.barriers.clear();
|
||||
|
||||
|
@ -3,12 +3,12 @@ use std::ops::Range;
|
||||
use crate::{
|
||||
Api, Attachment, BufferBarrier, BufferBinding, BufferCopy, ColorAttachment, CommandEncoder,
|
||||
ComputePassDescriptor, DepthStencilAttachment, DeviceError, Label, MemoryRange,
|
||||
PassTimestampWrites, Rect, RenderPassDescriptor,
|
||||
PassTimestampWrites, Rect, RenderPassDescriptor, TextureBarrier,
|
||||
};
|
||||
|
||||
use super::{
|
||||
DynBindGroup, DynBuffer, DynComputePipeline, DynPipelineLayout, DynQuerySet, DynRenderPipeline,
|
||||
DynResourceExt as _, DynTextureView,
|
||||
DynResourceExt as _, DynTexture, DynTextureView,
|
||||
};
|
||||
|
||||
pub trait DynCommandEncoder: std::fmt::Debug {
|
||||
@ -17,6 +17,7 @@ pub trait DynCommandEncoder: std::fmt::Debug {
|
||||
unsafe fn discard_encoding(&mut self);
|
||||
|
||||
unsafe fn transition_buffers(&mut self, barriers: &[BufferBarrier<'_, dyn DynBuffer>]);
|
||||
unsafe fn transition_textures(&mut self, barriers: &[TextureBarrier<'_, dyn DynTexture>]);
|
||||
|
||||
unsafe fn clear_buffer(&mut self, buffer: &dyn DynBuffer, range: MemoryRange);
|
||||
|
||||
@ -167,6 +168,15 @@ impl<C: CommandEncoder> DynCommandEncoder for C {
|
||||
unsafe { self.transition_buffers(barriers) };
|
||||
}
|
||||
|
||||
unsafe fn transition_textures(&mut self, barriers: &[TextureBarrier<'_, dyn DynTexture>]) {
|
||||
let barriers = barriers.iter().map(|barrier| TextureBarrier {
|
||||
texture: barrier.texture.expect_downcast_ref(),
|
||||
usage: barrier.usage.clone(),
|
||||
range: barrier.range,
|
||||
});
|
||||
unsafe { self.transition_textures(barriers) };
|
||||
}
|
||||
|
||||
unsafe fn clear_buffer(&mut self, buffer: &dyn DynBuffer, range: MemoryRange) {
|
||||
let buffer = buffer.expect_downcast_ref();
|
||||
unsafe { C::clear_buffer(self, buffer, range) };
|
||||
|
@ -314,7 +314,7 @@ impl crate::CommandEncoder for Encoder {
|
||||
|
||||
unsafe fn transition_textures<'a, T>(&mut self, barriers: T)
|
||||
where
|
||||
T: Iterator<Item = crate::TextureBarrier<'a, Api>>,
|
||||
T: Iterator<Item = crate::TextureBarrier<'a, Resource>>,
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -298,7 +298,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
||||
|
||||
unsafe fn transition_textures<'a, T>(&mut self, barriers: T)
|
||||
where
|
||||
T: Iterator<Item = crate::TextureBarrier<'a, super::Api>>,
|
||||
T: Iterator<Item = crate::TextureBarrier<'a, super::Texture>>,
|
||||
{
|
||||
if !self
|
||||
.private_caps
|
||||
|
@ -1110,7 +1110,7 @@ pub trait CommandEncoder: WasmNotSendSync + fmt::Debug {
|
||||
|
||||
unsafe fn transition_textures<'a, T>(&mut self, barriers: T)
|
||||
where
|
||||
T: Iterator<Item = TextureBarrier<'a, Self::A>>;
|
||||
T: Iterator<Item = TextureBarrier<'a, <Self::A as Api>::Texture>>;
|
||||
|
||||
// copy operations
|
||||
|
||||
@ -1990,8 +1990,8 @@ pub struct BufferBarrier<'a, B: DynBuffer + ?Sized> {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TextureBarrier<'a, A: Api> {
|
||||
pub texture: &'a A::Texture,
|
||||
pub struct TextureBarrier<'a, T: DynTexture + ?Sized> {
|
||||
pub texture: &'a T,
|
||||
pub range: wgt::ImageSubresourceRange,
|
||||
pub usage: Range<TextureUses>,
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
||||
|
||||
unsafe fn transition_textures<'a, T>(&mut self, _barriers: T)
|
||||
where
|
||||
T: Iterator<Item = crate::TextureBarrier<'a, super::Api>>,
|
||||
T: Iterator<Item = crate::TextureBarrier<'a, super::Texture>>,
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
||||
|
||||
unsafe fn transition_textures<'a, T>(&mut self, barriers: T)
|
||||
where
|
||||
T: Iterator<Item = crate::TextureBarrier<'a, super::Api>>,
|
||||
T: Iterator<Item = crate::TextureBarrier<'a, super::Texture>>,
|
||||
{
|
||||
let mut src_stages = vk::PipelineStageFlags::empty();
|
||||
let mut dst_stages = vk::PipelineStageFlags::empty();
|
||||
|
Loading…
Reference in New Issue
Block a user