remove BindGroupInfo

This commit is contained in:
Carter Anderson 2020-03-25 17:40:14 -07:00
parent 64cd924413
commit 47ef339e7b
2 changed files with 8 additions and 12 deletions

View File

@ -45,9 +45,9 @@ impl<'a, 'b, 'c, 'd> RenderPass for WgpuRenderPass<'a, 'b, 'c, 'd> {
let pipeline_layout = self.pipeline_descriptor.get_layout().unwrap();
for bind_group in pipeline_layout.bind_groups.iter() {
let bind_group_id = bind_group.get_hash().unwrap();
let bind_group_info = match self.wgpu_resources.bind_groups.get(&bind_group_id) {
let wgpu_bind_group = match self.wgpu_resources.bind_groups.get(&bind_group_id) {
// if there is a "global" bind group, use that
Some(bind_group_info) => bind_group_info,
Some(wgpu_bind_group) => wgpu_bind_group,
// otherwise try to get an entity-specific bind group
None => {
if let Some(assignments) = render_resource_assignments {
@ -95,7 +95,7 @@ impl<'a, 'b, 'c, 'd> RenderPass for WgpuRenderPass<'a, 'b, 'c, 'd> {
// TODO: check to see if bind group is already set
self.render_pass.set_bind_group(
bind_group.index,
&bind_group_info.bind_group,
&wgpu_bind_group,
dynamic_uniform_indices.as_slice(),
);
}

View File

@ -10,19 +10,15 @@ use crate::render::{
};
use std::collections::HashMap;
pub struct BindGroupInfo {
pub bind_group: wgpu::BindGroup,
}
pub struct WgpuResources {
pub render_resources: RenderResources,
pub buffers: HashMap<RenderResource, wgpu::Buffer>,
pub textures: HashMap<RenderResource, wgpu::TextureView>,
pub samplers: HashMap<RenderResource, wgpu::Sampler>,
pub resource_info: HashMap<RenderResource, ResourceInfo>,
pub bind_groups: HashMap<u64, BindGroupInfo>,
pub bind_groups: HashMap<u64, wgpu::BindGroup>,
pub bind_group_layouts: HashMap<u64, wgpu::BindGroupLayout>,
pub assignment_bind_groups: HashMap<(RenderResourceAssignmentsId, u64), BindGroupInfo>,
pub assignment_bind_groups: HashMap<(RenderResourceAssignmentsId, u64), wgpu::BindGroup>,
}
impl WgpuResources {
@ -99,14 +95,14 @@ impl WgpuResources {
let bind_group = device.create_bind_group(&bind_group_descriptor);
self.bind_groups
.insert(bind_group_id, BindGroupInfo { bind_group });
.insert(bind_group_id, bind_group);
}
}
pub fn get_assignments_bind_group(
&self,
render_resource_assignment_id: RenderResourceAssignmentsId,
bind_group_id: u64,
) -> Option<&BindGroupInfo> {
) -> Option<&wgpu::BindGroup> {
self.assignment_bind_groups
.get(&(render_resource_assignment_id, bind_group_id))
}
@ -177,7 +173,7 @@ impl WgpuResources {
// TODO: storing a large number entity bind groups might actually be really bad. make sure this is ok
self.assignment_bind_groups.insert(
(render_resource_assignments.get_id(), bind_group_id),
BindGroupInfo { bind_group },
bind_group,
);
}