Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 30 additions & 24 deletions player/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,8 @@ impl GlobalExt for wgc::hub::Global<IdentityPassThroughFactory> {
commands,
dynamic_offsets,
} => unsafe {
let mut offsets = &dynamic_offsets[..];
let mut pass = wgc::command::RawPass::new_compute(encoder);
for com in commands {
pass.encode(&com);
if let wgc::command::ComputeCommand::SetBindGroup {
num_dynamic_offsets,
..
} = com
{
pass.encode_slice(&offsets[..num_dynamic_offsets as usize]);
offsets = &offsets[num_dynamic_offsets as usize..];
}
}
pass.fill_compute_commands(&commands, &dynamic_offsets);
let (data, _) = pass.finish_compute();
self.command_encoder_run_compute_pass::<B>(encoder, &data);
},
Expand All @@ -165,7 +154,6 @@ impl GlobalExt for wgc::hub::Global<IdentityPassThroughFactory> {
commands,
dynamic_offsets,
} => unsafe {
let mut offsets = &dynamic_offsets[..];
let mut pass = wgc::command::RawPass::new_render(
encoder,
&wgc::command::RenderPassDescriptor {
Expand All @@ -174,17 +162,7 @@ impl GlobalExt for wgc::hub::Global<IdentityPassThroughFactory> {
depth_stencil_attachment: target_depth_stencil.as_ref(),
},
);
for com in commands {
pass.encode(&com);
if let wgc::command::RenderCommand::SetBindGroup {
num_dynamic_offsets,
..
} = com
{
pass.encode_slice(&offsets[..num_dynamic_offsets as usize]);
offsets = &offsets[num_dynamic_offsets as usize..];
}
}
pass.fill_render_commands(&commands, &dynamic_offsets);
let (data, _) = pass.finish_render();
self.command_encoder_run_render_pass::<B>(encoder, &data);
},
Expand Down Expand Up @@ -408,6 +386,34 @@ impl GlobalExt for wgc::hub::Global<IdentityPassThroughFactory> {
A::DestroyRenderPipeline(id) => {
self.render_pipeline_destroy::<B>(id);
}
A::CreateRenderBundle {
id,
desc,
commands,
dynamic_offsets,
} => {
let label = Label::new(&desc.label);
let mut bundle_encoder = wgc::command::RenderBundleEncoder::new(
&wgt::RenderBundleEncoderDescriptor {
label: None,
color_formats: &desc.color_formats,
depth_stencil_format: desc.depth_stencil_format,
sample_count: desc.sample_count,
},
device,
);
bundle_encoder.fill_commands(&commands, &dynamic_offsets);
self.render_bundle_encoder_finish::<B>(
bundle_encoder,
&wgt::RenderBundleDescriptor {
label: label.as_ptr(),
},
id,
);
}
A::DestroyRenderBundle(id) => {
self.render_bundle_destroy::<B>(id);
}
A::WriteBuffer {
id,
data,
Expand Down
16 changes: 11 additions & 5 deletions wgpu-core/src/command/bind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ use crate::{
binding_model::BindGroup,
hub::GfxBackend,
id::{BindGroupId, BindGroupLayoutId, PipelineLayoutId},
Stored,
Stored, MAX_BIND_GROUPS,
};

use smallvec::{smallvec, SmallVec};
use arrayvec::ArrayVec;
use std::slice;
use wgt::DynamicOffset;

pub const DEFAULT_BIND_GROUPS: usize = 4;
type BindGroupMask = u8;

#[derive(Clone, Debug)]
Expand Down Expand Up @@ -134,17 +133,24 @@ impl BindGroupEntry {
#[derive(Debug)]
pub struct Binder {
pub(crate) pipeline_layout_id: Option<PipelineLayoutId>, //TODO: strongly `Stored`
pub(crate) entries: SmallVec<[BindGroupEntry; DEFAULT_BIND_GROUPS]>,
pub(crate) entries: ArrayVec<[BindGroupEntry; MAX_BIND_GROUPS]>,
}

impl Binder {
pub(crate) fn new(max_bind_groups: u32) -> Self {
Self {
pipeline_layout_id: None,
entries: smallvec![Default::default(); max_bind_groups as usize],
entries: (0..max_bind_groups)
.map(|_| BindGroupEntry::default())
.collect(),
}
}

pub(crate) fn reset(&mut self) {
self.pipeline_layout_id = None;
self.entries.clear();
}

pub(crate) fn reset_expectations(&mut self, length: usize) {
for entry in self.entries[length..].iter_mut() {
entry.expected_layout_id = None;
Expand Down
Loading