BufferBarrier no longer depend on hal api struct, but directly on buffer type

This commit is contained in:
Andreas Reich 2024-07-14 23:18:18 +02:00
parent cda9d9af65
commit a4d9d38d03
8 changed files with 11 additions and 11 deletions

View File

@ -284,7 +284,7 @@ impl<A: HalApi> BufferTracker<A> {
pub fn drain_transitions<'a, 'b: 'a>( pub fn drain_transitions<'a, 'b: 'a>(
&'b mut self, &'b mut self,
snatch_guard: &'a SnatchGuard<'a>, snatch_guard: &'a SnatchGuard<'a>,
) -> impl Iterator<Item = BufferBarrier<'a, A>> { ) -> impl Iterator<Item = BufferBarrier<'a, A::Buffer>> {
let buffer_barriers = self.temp.drain(..).map(|pending| { let buffer_barriers = self.temp.drain(..).map(|pending| {
let buf = unsafe { self.metadata.get_resource_unchecked(pending.id as _) }; let buf = unsafe { self.metadata.get_resource_unchecked(pending.id as _) };
pending.into_hal(buf, snatch_guard) pending.into_hal(buf, snatch_guard)
@ -557,7 +557,7 @@ impl<A: HalApi> DeviceBufferTracker<A> {
&'a mut self, &'a mut self,
tracker: &'a BufferTracker<A>, tracker: &'a BufferTracker<A>,
snatch_guard: &'b SnatchGuard<'b>, snatch_guard: &'b SnatchGuard<'b>,
) -> impl Iterator<Item = BufferBarrier<'a, A>> { ) -> impl Iterator<Item = BufferBarrier<'a, A::Buffer>> {
for index in tracker.metadata.owned_indices() { for index in tracker.metadata.owned_indices() {
self.tracker_assert_in_bounds(index); self.tracker_assert_in_bounds(index);

View File

@ -261,7 +261,7 @@ impl PendingTransition<hal::BufferUses> {
self, self,
buf: &'a resource::Buffer<A>, buf: &'a resource::Buffer<A>,
snatch_guard: &'a SnatchGuard<'a>, snatch_guard: &'a SnatchGuard<'a>,
) -> hal::BufferBarrier<'a, A> { ) -> hal::BufferBarrier<'a, A::Buffer> {
let buffer = buf.raw(snatch_guard).expect("Buffer is destroyed"); let buffer = buf.raw(snatch_guard).expect("Buffer is destroyed");
hal::BufferBarrier { hal::BufferBarrier {
buffer, buffer,

View File

@ -310,7 +310,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
unsafe fn transition_buffers<'a, T>(&mut self, barriers: T) unsafe fn transition_buffers<'a, T>(&mut self, barriers: T)
where where
T: Iterator<Item = crate::BufferBarrier<'a, super::Api>>, T: Iterator<Item = crate::BufferBarrier<'a, super::Buffer>>,
{ {
self.temp.barriers.clear(); self.temp.barriers.clear();

View File

@ -301,7 +301,7 @@ impl crate::CommandEncoder for Encoder {
unsafe fn transition_buffers<'a, T>(&mut self, barriers: T) unsafe fn transition_buffers<'a, T>(&mut self, barriers: T)
where where
T: Iterator<Item = crate::BufferBarrier<'a, Api>>, T: Iterator<Item = crate::BufferBarrier<'a, Resource>>,
{ {
} }

View File

@ -273,7 +273,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
unsafe fn transition_buffers<'a, T>(&mut self, barriers: T) unsafe fn transition_buffers<'a, T>(&mut self, barriers: T)
where where
T: Iterator<Item = crate::BufferBarrier<'a, super::Api>>, T: Iterator<Item = crate::BufferBarrier<'a, super::Buffer>>,
{ {
if !self if !self
.private_caps .private_caps

View File

@ -1103,7 +1103,7 @@ pub trait CommandEncoder: WasmNotSendSync + fmt::Debug {
unsafe fn transition_buffers<'a, T>(&mut self, barriers: T) unsafe fn transition_buffers<'a, T>(&mut self, barriers: T)
where where
T: Iterator<Item = BufferBarrier<'a, Self::A>>; T: Iterator<Item = BufferBarrier<'a, <Self::A as Api>::Buffer>>;
unsafe fn transition_textures<'a, T>(&mut self, barriers: T) unsafe fn transition_textures<'a, T>(&mut self, barriers: T)
where where
@ -1975,8 +1975,8 @@ pub struct Rect<T> {
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct BufferBarrier<'a, A: Api> { pub struct BufferBarrier<'a, B: DynBuffer + ?Sized> {
pub buffer: &'a A::Buffer, pub buffer: &'a B,
pub usage: Range<BufferUses>, pub usage: Range<BufferUses>,
} }

View File

@ -241,7 +241,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
unsafe fn transition_buffers<'a, T>(&mut self, _barriers: T) unsafe fn transition_buffers<'a, T>(&mut self, _barriers: T)
where where
T: Iterator<Item = crate::BufferBarrier<'a, super::Api>>, T: Iterator<Item = crate::BufferBarrier<'a, super::Buffer>>,
{ {
} }

View File

@ -116,7 +116,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
unsafe fn transition_buffers<'a, T>(&mut self, barriers: T) unsafe fn transition_buffers<'a, T>(&mut self, barriers: T)
where where
T: Iterator<Item = crate::BufferBarrier<'a, super::Api>>, T: Iterator<Item = crate::BufferBarrier<'a, super::Buffer>>,
{ {
//Note: this is done so that we never end up with empty stage flags //Note: this is done so that we never end up with empty stage flags
let mut src_stages = vk::PipelineStageFlags::TOP_OF_PIPE; let mut src_stages = vk::PipelineStageFlags::TOP_OF_PIPE;