520: Update naming of bindings to entries r=kvark a=kvark

Matches https://github.com/gpuweb/gpuweb/pull/611

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
This commit is contained in:
bors[bot]andDzmitry Malyshau authored and GitHub committed 2020-03-16 14:07:42 +00:00
commit 75fdfc0ef7
5 files changed
+29 -29

No files matched your search

+5 -5
View File
@@ -13,7 +13,7 @@
#include <stdlib.h>
#include <string.h>
#define BINDINGS_LENGTH (1)
#define BIND_ENTRIES_LENGTH (1)
#define BIND_GROUP_LAYOUTS_LENGTH (1)
void request_adapter_callback(WGPUAdapterId received, void *userdata) {
@@ -80,11 +80,11 @@ int main(
WGPUBindGroupLayoutId bind_group_layout =
wgpu_device_create_bind_group_layout(device,
&(WGPUBindGroupLayoutDescriptor){
.bindings = &(WGPUBindGroupLayoutEntry){
.entries = &(WGPUBindGroupLayoutEntry){
.binding = 0,
.visibility = WGPUShaderStage_COMPUTE,
.ty = WGPUBindingType_StorageBuffer},
.bindings_length = BINDINGS_LENGTH});
.entries_length = BIND_ENTRIES_LENGTH});
WGPUBindingResource resource = {
.tag = WGPUBindingResource_Buffer,
@@ -95,10 +95,10 @@ int main(
WGPUBindGroupId bind_group = wgpu_device_create_bind_group(device,
&(WGPUBindGroupDescriptor){.layout = bind_group_layout,
.bindings = &(WGPUBindGroupEntry){
.entries = &(WGPUBindGroupEntry){
.binding = 0,
.resource = resource},
.bindings_length = BINDINGS_LENGTH});
.entries_length = BIND_ENTRIES_LENGTH});
WGPUBindGroupLayoutId bind_group_layouts[BIND_GROUP_LAYOUTS_LENGTH] = {
bind_group_layout};
+4 -4
View File
@@ -79,15 +79,15 @@ int main() {
WGPUBindGroupLayoutId bind_group_layout =
wgpu_device_create_bind_group_layout(device,
&(WGPUBindGroupLayoutDescriptor){
.bindings = NULL,
.bindings_length = 0,
.entries = NULL,
.entries_length = 0,
});
WGPUBindGroupId bind_group =
wgpu_device_create_bind_group(device,
&(WGPUBindGroupDescriptor){
.layout = bind_group_layout,
.bindings = NULL,
.bindings_length = 0,
.entries = NULL,
.entries_length = 0,
});
WGPUBindGroupLayoutId bind_group_layouts[BIND_GROUP_LAYOUTS_LENGTH] = {
+4 -4
View File
@@ -465,8 +465,8 @@ typedef struct {
typedef struct {
WGPUBindGroupLayoutId layout;
const WGPUBindGroupEntry *bindings;
uintptr_t bindings_length;
const WGPUBindGroupEntry *entries;
uintptr_t entries_length;
} WGPUBindGroupDescriptor;
typedef uint32_t WGPUShaderStage;
@@ -486,8 +486,8 @@ typedef struct {
} WGPUBindGroupLayoutEntry;
typedef struct {
const WGPUBindGroupLayoutEntry *bindings;
uintptr_t bindings_length;
const WGPUBindGroupLayoutEntry *entries;
uintptr_t entries_length;
} WGPUBindGroupLayoutDescriptor;
typedef uint32_t WGPUBufferUsage;
+5 -5
View File
@@ -49,14 +49,14 @@ pub struct BindGroupLayoutEntry {
#[repr(C)]
#[derive(Debug)]
pub struct BindGroupLayoutDescriptor {
pub bindings: *const BindGroupLayoutEntry,
pub bindings_length: usize,
pub entries: *const BindGroupLayoutEntry,
pub entries_length: usize,
}
#[derive(Debug)]
pub struct BindGroupLayout<B: hal::Backend> {
pub(crate) raw: B::DescriptorSetLayout,
pub(crate) bindings: FastHashMap<u32, BindGroupLayoutEntry>,
pub(crate) entries: FastHashMap<u32, BindGroupLayoutEntry>,
pub(crate) desc_ranges: DescriptorRanges,
pub(crate) dynamic_count: usize,
}
@@ -104,8 +104,8 @@ pub struct BindGroupEntry {
#[derive(Debug)]
pub struct BindGroupDescriptor {
pub layout: BindGroupLayoutId,
pub bindings: *const BindGroupEntry,
pub bindings_length: usize,
pub entries: *const BindGroupEntry,
pub entries_length: usize,
}
#[derive(Debug)]
+11 -11
View File
@@ -876,8 +876,8 @@ impl<F: IdentityFilter<id::BindGroupLayoutId>> Global<F> {
) -> id::BindGroupLayoutId {
let mut token = Token::root();
let hub = B::hub(self);
let bindings = unsafe { slice::from_raw_parts(desc.bindings, desc.bindings_length) };
let bindings_map: FastHashMap<_, _> = bindings
let entries = unsafe { slice::from_raw_parts(desc.entries, desc.entries_length) };
let entry_map: FastHashMap<_, _> = entries
.iter()
.cloned()
.map(|b| (b.binding, b))
@@ -890,14 +890,14 @@ impl<F: IdentityFilter<id::BindGroupLayoutId>> Global<F> {
let (bgl_guard, _) = hub.bind_group_layouts.read(&mut token);
let bind_group_layout_id = bgl_guard
.iter(device_id.backend())
.find(|(_, bgl)| bgl.bindings == bindings_map);
.find(|(_, bgl)| bgl.entries == entry_map);
if let Some((id, _)) = bind_group_layout_id {
return id;
}
}
let raw_bindings = bindings
let raw_bindings = entries
.iter()
.map(|binding| hal::pso::DescriptorSetLayoutBinding {
binding: binding.binding,
@@ -918,9 +918,9 @@ impl<F: IdentityFilter<id::BindGroupLayoutId>> Global<F> {
let layout = binding_model::BindGroupLayout {
raw,
bindings: bindings_map,
entries: entry_map,
desc_ranges: DescriptorRanges::from_bindings(&raw_bindings),
dynamic_count: bindings.iter().filter(|b| b.has_dynamic_offset).count(),
dynamic_count: entries.iter().filter(|b| b.has_dynamic_offset).count(),
};
hub.bind_group_layouts
@@ -998,9 +998,9 @@ impl<F: IdentityFilter<id::BindGroupId>> Global<F> {
let device = &device_guard[device_id];
let (bind_group_layout_guard, mut token) = hub.bind_group_layouts.read(&mut token);
let bind_group_layout = &bind_group_layout_guard[desc.layout];
let bindings =
unsafe { slice::from_raw_parts(desc.bindings, desc.bindings_length as usize) };
assert_eq!(bindings.len(), bind_group_layout.bindings.len());
let entries =
unsafe { slice::from_raw_parts(desc.entries, desc.entries_length as usize) };
assert_eq!(entries.len(), bind_group_layout.entries.len());
let desc_set = unsafe {
let mut desc_sets = ArrayVec::<[_; 1]>::new();
@@ -1028,8 +1028,8 @@ impl<F: IdentityFilter<id::BindGroupId>> Global<F> {
//TODO: group writes into contiguous sections
let mut writes = Vec::new();
for b in bindings.iter() {
let decl = bind_group_layout.bindings.get(&b.binding)
for b in entries.iter() {
let decl = bind_group_layout.entries.get(&b.binding)
.expect("Failed to find binding declaration for binding");
let descriptor = match b.resource {
binding_model::BindingResource::Buffer(ref bb) => {