[rs] Update wgpu with push constants API

This commit is contained in:
Dzmitry Malyshau
2020-10-11 22:01:02 -04:00
parent 9451c23bb7
commit d6843fca7b
4 changed files with 16 additions and 22 deletions

View File

@@ -26,14 +26,14 @@ vulkan-portability = ["wgc/gfx-backend-vulkan", "gfx-backend-vulkan"]
package = "wgpu-core"
#version = "0.6"
git = "https://github.com/gfx-rs/wgpu"
rev = "8059c03273bd7272688e3dac661e72c4973a2d0b"
rev = "44a41dc9a4eac8ddc37675f0d52486ded27bdbb3"
features = ["raw-window-handle"]
[dependencies.wgt]
package = "wgpu-types"
#version = "0.6"
git = "https://github.com/gfx-rs/wgpu"
rev = "8059c03273bd7272688e3dac661e72c4973a2d0b"
rev = "44a41dc9a4eac8ddc37675f0d52486ded27bdbb3"
[dependencies]
arrayvec = "0.5"

View File

@@ -88,14 +88,12 @@ mod pass_impl {
)
}
}
fn set_push_constants(&mut self, offset: u32, data: &[u32]) {
fn set_push_constants(&mut self, offset: u32, data: &[u8]) {
unsafe {
wgpu_compute_pass_set_push_constant(
self,
offset,
(data.len() * std::mem::size_of::<u32>())
.try_into()
.unwrap(),
data.len().try_into().unwrap(),
data.as_ptr(),
)
}
@@ -165,15 +163,13 @@ mod pass_impl {
) {
wgpu_render_pass_set_vertex_buffer(self, slot, buffer.id, offset, size)
}
fn set_push_constants(&mut self, stages: wgt::ShaderStage, offset: u32, data: &[u32]) {
fn set_push_constants(&mut self, stages: wgt::ShaderStage, offset: u32, data: &[u8]) {
unsafe {
wgpu_render_pass_set_push_constants(
self,
stages,
offset,
(data.len() * std::mem::size_of::<u32>())
.try_into()
.unwrap(),
data.len().try_into().unwrap(),
data.as_ptr(),
)
}
@@ -362,15 +358,13 @@ mod pass_impl {
wgpu_render_bundle_set_vertex_buffer(self, slot, buffer.id, offset, size)
}
fn set_push_constants(&mut self, stages: wgt::ShaderStage, offset: u32, data: &[u32]) {
fn set_push_constants(&mut self, stages: wgt::ShaderStage, offset: u32, data: &[u8]) {
unsafe {
wgpu_render_bundle_set_push_constants(
self,
stages,
offset,
(data.len() * std::mem::size_of::<u32>())
.try_into()
.unwrap(),
data.len().try_into().unwrap(),
data.as_ptr(),
)
}
@@ -1214,7 +1208,7 @@ impl crate::Context for Context {
fn texture_drop(&self, texture: &Self::TextureId) {
let global = &self.0;
wgc::gfx_select!(texture.id => global.texture_drop(texture.id))
wgc::gfx_select!(texture.id => global.texture_drop(texture.id, false))
}
fn texture_view_drop(&self, texture_view: &Self::TextureViewId) {
let global = &self.0;

View File

@@ -109,7 +109,7 @@ impl crate::ComputePassInner<Context> for ComputePass {
offsets.len() as u32,
);
}
fn set_push_constants(&mut self, _offset: u32, _data: &[u32]) {
fn set_push_constants(&mut self, _offset: u32, _data: &[u8]) {
panic!("PUSH_CONSTANTS feature must be enabled to call multi_draw_indexed_indirect")
}
@@ -184,7 +184,7 @@ impl crate::RenderInner<Context> for RenderPass {
self.0
.set_vertex_buffer_with_f64_and_f64(slot, &buffer.0, offset as f64, mapped_size);
}
fn set_push_constants(&mut self, _stages: wgt::ShaderStage, _offset: u32, _data: &[u32]) {
fn set_push_constants(&mut self, _stages: wgt::ShaderStage, _offset: u32, _data: &[u8]) {
panic!("PUSH_CONSTANTS feature must be enabled to call multi_draw_indexed_indirect")
}
fn draw(&mut self, vertices: Range<u32>, instances: Range<u32>) {

View File

@@ -55,7 +55,7 @@ trait ComputePassInner<Ctx: Context> {
bind_group: &Ctx::BindGroupId,
offsets: &[DynamicOffset],
);
fn set_push_constants(&mut self, offset: u32, data: &[u32]);
fn set_push_constants(&mut self, offset: u32, data: &[u8]);
fn insert_debug_marker(&mut self, label: &str);
fn push_debug_group(&mut self, group_label: &str);
fn pop_debug_group(&mut self);
@@ -88,7 +88,7 @@ trait RenderInner<Ctx: Context> {
offset: BufferAddress,
size: Option<BufferSize>,
);
fn set_push_constants(&mut self, stages: wgt::ShaderStage, offset: u32, data: &[u32]);
fn set_push_constants(&mut self, stages: wgt::ShaderStage, offset: u32, data: &[u8]);
fn draw(&mut self, vertices: Range<u32>, instances: Range<u32>);
fn draw_indexed(&mut self, indices: Range<u32>, base_vertex: i32, instances: Range<u32>);
fn draw_indirect(&mut self, indirect_buffer: &Ctx::BufferId, indirect_offset: BufferAddress);
@@ -2316,7 +2316,7 @@ impl<'a> RenderPass<'a> {
///
/// You would need to upload this in three set_push_constants calls. First for the `Vertex` only range 0..4, second
/// for the `Vertex | Fragment` range 4..8, third for the `Fragment` range 8..12.
pub fn set_push_constants(&mut self, stages: wgt::ShaderStage, offset: u32, data: &[u32]) {
pub fn set_push_constants(&mut self, stages: wgt::ShaderStage, offset: u32, data: &[u8]) {
self.id.set_push_constants(stages, offset, data);
}
}
@@ -2392,7 +2392,7 @@ impl<'a> ComputePass<'a> {
/// Data size must be a multiple of 4 and must be aligned to the 4s, so we take an array of u32.
/// For example, with an offset of 4 and an array of `[u32; 3]`, that will write to the range
/// of 4..16.
pub fn set_push_constants(&mut self, offset: u32, data: &[u32]) {
pub fn set_push_constants(&mut self, offset: u32, data: &[u8]) {
self.id.set_push_constants(offset, data);
}
}
@@ -2561,7 +2561,7 @@ impl<'a> RenderBundleEncoder<'a> {
///
/// You would need to upload this in three set_push_constants calls. First for the `Vertex` only range 0..4, second
/// for the `Vertex | Fragment` range 4..8, third for the `Fragment` range 8..12.
pub fn set_push_constants(&mut self, stages: wgt::ShaderStage, offset: u32, data: &[u32]) {
pub fn set_push_constants(&mut self, stages: wgt::ShaderStage, offset: u32, data: &[u8]) {
self.id.set_push_constants(stages, offset, data);
}
}