mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-25 00:03:29 +00:00
Buffer bindings no longer depend on hal api struct, but directly on buffer type
This commit is contained in:
parent
d2508d9ad6
commit
cda9d9af65
@ -1889,7 +1889,7 @@ impl<A: HalApi> Device<A> {
|
||||
used: &mut BindGroupStates<A>,
|
||||
limits: &wgt::Limits,
|
||||
snatch_guard: &'a SnatchGuard<'a>,
|
||||
) -> Result<hal::BufferBinding<'a, A>, binding_model::CreateBindGroupError> {
|
||||
) -> Result<hal::BufferBinding<'a, A::Buffer>, binding_model::CreateBindGroupError> {
|
||||
use crate::binding_model::CreateBindGroupError as Error;
|
||||
|
||||
let (binding_ty, dynamic, min_size) = match decl.ty {
|
||||
|
@ -970,7 +970,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
||||
|
||||
unsafe fn set_index_buffer<'a>(
|
||||
&mut self,
|
||||
binding: crate::BufferBinding<'a, super::Api>,
|
||||
binding: crate::BufferBinding<'a, super::Buffer>,
|
||||
format: wgt::IndexFormat,
|
||||
) {
|
||||
self.list.as_ref().unwrap().set_index_buffer(
|
||||
@ -982,7 +982,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
||||
unsafe fn set_vertex_buffer<'a>(
|
||||
&mut self,
|
||||
index: u32,
|
||||
binding: crate::BufferBinding<'a, super::Api>,
|
||||
binding: crate::BufferBinding<'a, super::Buffer>,
|
||||
) {
|
||||
let vb = &mut self.pass.vertex_buffers[index as usize];
|
||||
vb.BufferLocation = binding.resolve_address();
|
||||
|
@ -428,7 +428,7 @@ unsafe impl Sync for Buffer {}
|
||||
|
||||
impl crate::DynBuffer for Buffer {}
|
||||
|
||||
impl crate::BufferBinding<'_, Api> {
|
||||
impl crate::BufferBinding<'_, Buffer> {
|
||||
fn resolve_size(&self) -> wgt::BufferAddress {
|
||||
match self.size {
|
||||
Some(size) => size.get(),
|
||||
|
@ -391,11 +391,15 @@ impl crate::CommandEncoder for Encoder {
|
||||
|
||||
unsafe fn set_index_buffer<'a>(
|
||||
&mut self,
|
||||
binding: crate::BufferBinding<'a, Api>,
|
||||
binding: crate::BufferBinding<'a, Resource>,
|
||||
format: wgt::IndexFormat,
|
||||
) {
|
||||
}
|
||||
unsafe fn set_vertex_buffer<'a>(&mut self, index: u32, binding: crate::BufferBinding<'a, Api>) {
|
||||
unsafe fn set_vertex_buffer<'a>(
|
||||
&mut self,
|
||||
index: u32,
|
||||
binding: crate::BufferBinding<'a, Resource>,
|
||||
) {
|
||||
}
|
||||
unsafe fn set_viewport(&mut self, rect: &crate::Rect<f32>, depth_range: Range<f32>) {}
|
||||
unsafe fn set_scissor_rect(&mut self, rect: &crate::Rect<u32>) {}
|
||||
|
@ -978,7 +978,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
||||
|
||||
unsafe fn set_index_buffer<'a>(
|
||||
&mut self,
|
||||
binding: crate::BufferBinding<'a, super::Api>,
|
||||
binding: crate::BufferBinding<'a, super::Buffer>,
|
||||
format: wgt::IndexFormat,
|
||||
) {
|
||||
self.state.index_offset = binding.offset;
|
||||
@ -990,7 +990,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
||||
unsafe fn set_vertex_buffer<'a>(
|
||||
&mut self,
|
||||
index: u32,
|
||||
binding: crate::BufferBinding<'a, super::Api>,
|
||||
binding: crate::BufferBinding<'a, super::Buffer>,
|
||||
) {
|
||||
self.state.dirty_vbuf_mask |= 1 << index;
|
||||
let (_, ref mut vb) = self.state.vertex_buffers[index as usize];
|
||||
|
@ -1235,10 +1235,14 @@ pub trait CommandEncoder: WasmNotSendSync + fmt::Debug {
|
||||
|
||||
unsafe fn set_index_buffer<'a>(
|
||||
&mut self,
|
||||
binding: BufferBinding<'a, Self::A>,
|
||||
binding: BufferBinding<'a, <Self::A as Api>::Buffer>,
|
||||
format: wgt::IndexFormat,
|
||||
);
|
||||
unsafe fn set_vertex_buffer<'a>(&mut self, index: u32, binding: BufferBinding<'a, Self::A>);
|
||||
unsafe fn set_vertex_buffer<'a>(
|
||||
&mut self,
|
||||
index: u32,
|
||||
binding: BufferBinding<'a, <Self::A as Api>::Buffer>,
|
||||
);
|
||||
unsafe fn set_viewport(&mut self, rect: &Rect<f32>, depth_range: Range<f32>);
|
||||
unsafe fn set_scissor_rect(&mut self, rect: &Rect<u32>);
|
||||
unsafe fn set_stencil_reference(&mut self, value: u32);
|
||||
@ -1736,9 +1740,9 @@ pub struct PipelineLayoutDescriptor<'a, A: Api> {
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct BufferBinding<'a, A: Api> {
|
||||
pub struct BufferBinding<'a, B: DynBuffer + ?Sized> {
|
||||
/// The buffer being bound.
|
||||
pub buffer: &'a A::Buffer,
|
||||
pub buffer: &'a B,
|
||||
|
||||
/// The offset at which the bound region starts.
|
||||
///
|
||||
@ -1762,7 +1766,7 @@ pub struct BufferBinding<'a, A: Api> {
|
||||
}
|
||||
|
||||
// Rust gets confused about the impl requirements for `A`
|
||||
impl<A: Api> Clone for BufferBinding<'_, A> {
|
||||
impl<B: DynBuffer> Clone for BufferBinding<'_, B> {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
buffer: self.buffer,
|
||||
@ -1808,7 +1812,7 @@ pub struct BindGroupEntry {
|
||||
pub struct BindGroupDescriptor<'a, A: Api> {
|
||||
pub label: Label<'a>,
|
||||
pub layout: &'a A::BindGroupLayout,
|
||||
pub buffers: &'a [BufferBinding<'a, A>],
|
||||
pub buffers: &'a [BufferBinding<'a, A::Buffer>],
|
||||
pub samplers: &'a [&'a A::Sampler],
|
||||
pub textures: &'a [TextureBinding<'a, A>],
|
||||
pub entries: &'a [BindGroupEntry],
|
||||
|
@ -915,7 +915,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
||||
|
||||
unsafe fn set_index_buffer<'a>(
|
||||
&mut self,
|
||||
binding: crate::BufferBinding<'a, super::Api>,
|
||||
binding: crate::BufferBinding<'a, super::Buffer>,
|
||||
format: wgt::IndexFormat,
|
||||
) {
|
||||
let (stride, raw_type) = match format {
|
||||
@ -933,7 +933,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
||||
unsafe fn set_vertex_buffer<'a>(
|
||||
&mut self,
|
||||
index: u32,
|
||||
binding: crate::BufferBinding<'a, super::Api>,
|
||||
binding: crate::BufferBinding<'a, super::Buffer>,
|
||||
) {
|
||||
let buffer_index = self.shared.private_caps.max_vertex_buffers as u64 - 1 - index as u64;
|
||||
let encoder = self.state.render.as_ref().unwrap();
|
||||
|
@ -486,7 +486,7 @@ impl Buffer {
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::BufferBinding<'_, Api> {
|
||||
impl crate::BufferBinding<'_, Buffer> {
|
||||
fn resolve_size(&self) -> wgt::BufferAddress {
|
||||
match self.size {
|
||||
Some(size) => size.get(),
|
||||
|
@ -870,7 +870,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
||||
|
||||
unsafe fn set_index_buffer<'a>(
|
||||
&mut self,
|
||||
binding: crate::BufferBinding<'a, super::Api>,
|
||||
binding: crate::BufferBinding<'a, super::Buffer>,
|
||||
format: wgt::IndexFormat,
|
||||
) {
|
||||
unsafe {
|
||||
@ -885,7 +885,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
||||
unsafe fn set_vertex_buffer<'a>(
|
||||
&mut self,
|
||||
index: u32,
|
||||
binding: crate::BufferBinding<'a, super::Api>,
|
||||
binding: crate::BufferBinding<'a, super::Buffer>,
|
||||
) {
|
||||
let vk_buffers = [binding.buffer.raw];
|
||||
let vk_offsets = [binding.offset];
|
||||
|
Loading…
Reference in New Issue
Block a user