removed unused RenderResourceId and SwapChainFrame (#2890)

# Objective

- removed unused RenderResourceId and SwapChainFrame (already unified with TextureView)
- added deref to BindGroup, this makes conversion to wgpu::BindGroup easier

## Solution

- cleans up the API
This commit is contained in:
Kurt Kühnert 2021-10-06 00:24:01 +00:00
parent 0eb11df394
commit bf19ddf191
5 changed files with 11 additions and 74 deletions

View file

@ -127,7 +127,7 @@ impl<'a> TrackedRenderPass<'a> {
);
}
self.pass
.set_bind_group(index as u32, bind_group.value(), dynamic_uniform_indices);
.set_bind_group(index as u32, bind_group, dynamic_uniform_indices);
self.state
.set_bind_group(index as usize, bind_group.id(), dynamic_uniform_indices);
}

View file

@ -1,5 +1,5 @@
use bevy_reflect::Uuid;
use std::sync::Arc;
use std::{ops::Deref, sync::Arc};
#[derive(Copy, Clone, Hash, Eq, PartialEq, Debug)]
pub struct BindGroupId(Uuid);
@ -15,11 +15,6 @@ impl BindGroup {
pub fn id(&self) -> BindGroupId {
self.id
}
#[inline]
pub fn value(&self) -> &wgpu::BindGroup {
&self.value
}
}
impl From<wgpu::BindGroup> for BindGroup {
@ -30,3 +25,12 @@ impl From<wgpu::BindGroup> for BindGroup {
}
}
}
impl Deref for BindGroup {
type Target = wgpu::BindGroup;
#[inline]
fn deref(&self) -> &Self::Target {
&self.value
}
}

View file

@ -2,7 +2,6 @@ mod bind_group;
mod buffer;
mod buffer_vec;
mod pipeline;
mod render_resource_id;
mod texture;
mod uniform_vec;
@ -10,7 +9,6 @@ pub use bind_group::*;
pub use buffer::*;
pub use buffer_vec::*;
pub use pipeline::*;
pub use render_resource_id::*;
pub use texture::*;
pub use uniform_vec::*;

View file

@ -1,34 +0,0 @@
use crate::render_resource::{BufferId, SamplerId, TextureViewId};
#[derive(Debug, Clone, Hash, Eq, PartialEq)]
pub enum RenderResourceId {
Buffer(BufferId),
TextureView(TextureViewId),
Sampler(SamplerId),
}
impl RenderResourceId {
pub fn get_texture_view(&self) -> Option<TextureViewId> {
if let RenderResourceId::TextureView(id) = self {
Some(*id)
} else {
None
}
}
pub fn get_buffer(&self) -> Option<BufferId> {
if let RenderResourceId::Buffer(id) = self {
Some(*id)
} else {
None
}
}
pub fn get_sampler(&self) -> Option<SamplerId> {
if let RenderResourceId::Sampler(id) = self {
Some(*id)
} else {
None
}
}
}

View file

@ -124,34 +124,3 @@ impl Deref for Sampler {
&self.value
}
}
#[derive(Clone, Debug)]
pub struct SwapChainFrame {
id: TextureViewId,
value: Arc<wgpu::SwapChainFrame>,
}
impl SwapChainFrame {
#[inline]
pub fn id(&self) -> TextureViewId {
self.id
}
}
impl From<wgpu::SwapChainFrame> for SwapChainFrame {
fn from(value: wgpu::SwapChainFrame) -> Self {
Self {
id: TextureViewId(Uuid::new_v4()),
value: Arc::new(value),
}
}
}
impl Deref for SwapChainFrame {
type Target = wgpu::SwapChainFrame;
#[inline]
fn deref(&self) -> &Self::Target {
&self.value
}
}