Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EXPERIMENT: builder APIs via bon #96

Draft
wants to merge 33 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8fb8c38
build: add `bon` 3.0.0
ErichDonGubler Sep 8, 2024
f3512f9
WIP: refactor!: give `BufferDescriptor` a builder API
ErichDonGubler Sep 8, 2024
4bf1579
WIP: refactor!: give `TextureViewDescriptor` a builder API
ErichDonGubler Sep 8, 2024
77df9e2
refactor: remove unnecessary `TextureDescriptor::view_formats` specs.
ErichDonGubler Sep 8, 2024
1fa77a9
refactor: replace manual `TextureViewDescriptor::default()`
ErichDonGubler Sep 8, 2024
05e0b76
refactor: replace manual `Extend3d::default()`
ErichDonGubler Sep 8, 2024
0bebbdf
WIP: refactor!: give `TextureDescriptor` a builder API
ErichDonGubler Sep 8, 2024
3435f9d
WIP: refactor!: remove unnecessary fields in `TextureDescriptor` buil…
ErichDonGubler Sep 8, 2024
5e2e56c
WIP: refactor!: give `PipelineLayoutDescriptor` a builder API
ErichDonGubler Sep 8, 2024
4fc865e
WIP: refactor!: remove unnecessary fields in `PipelineLayoutDescripto…
ErichDonGubler Sep 9, 2024
5bea6ac
refactor: replace manual `MultisampleState::default()`
ErichDonGubler Sep 9, 2024
9923d1e
refactor: prefer default values for `MultisampleState` via `..Default…
ErichDonGubler Sep 9, 2024
7cb3c16
refactor!: replace manual `PrimitiveState::default()`
ErichDonGubler Sep 9, 2024
85683d0
refactor!: give `PrimitiveState` a builder API
ErichDonGubler Sep 8, 2024
db7b54b
WIP: refactor!: remove unnecessary fields in `PrimitiveState` builder…
ErichDonGubler Sep 9, 2024
09e894e
refactor!: give `VertexBufferLayout` a builder API
ErichDonGubler Sep 9, 2024
d906df9
WIP: refactor!: remove unnecessary fields in `VertexBufferLayout` bui…
ErichDonGubler Sep 9, 2024
975bcf2
refactor!: give `VertexState` a builder API
ErichDonGubler Sep 9, 2024
da7b491
WIP: refactor!: remove unnecessary fields in `VertexState` builder usage
ErichDonGubler Sep 9, 2024
43eecd2
refactor: add `VertexState::from_module` builder entrypoint
ErichDonGubler Sep 9, 2024
c5d208e
refactor!: give `BlendComponent` a builder API
ErichDonGubler Sep 9, 2024
127af08
WIP: refactor!: remove unnecessary fields in `BlendComponent` builder…
ErichDonGubler Sep 9, 2024
07eae28
refactor!: give `ColorTargetState` a builder API
ErichDonGubler Sep 9, 2024
62141b0
WIP: refactor!: remove unnecessary fields in `ColorTargetState` build…
ErichDonGubler Sep 9, 2024
860342c
refactor!: give `FragmentState` a builder API
ErichDonGubler Sep 9, 2024
51884e5
WIP: refactor!: remove unnecessary fields in `FragmentState` builder …
ErichDonGubler Sep 9, 2024
023378f
refactor: add `FragmentState::from_module` builder entrypoint
ErichDonGubler Sep 9, 2024
771e861
refactor: prefer default values for `DepthStencilState` via `..Defaul…
ErichDonGubler Sep 9, 2024
f420dbb
refactor!: give `DepthStencilState` a builder API
ErichDonGubler Sep 9, 2024
c839914
WIP: refactor!: remove unnecessary fields in `DepthStencilState` buil…
ErichDonGubler Sep 9, 2024
e46f8c5
refactor!: give `RenderPipelineDescriptor` a builder API
ErichDonGubler Sep 8, 2024
15cfbfd
WIP: refactor!: remove unnecessary fields in `RenderPipelineDescripto…
ErichDonGubler Sep 9, 2024
cb068f1
END: how did we do?
ErichDonGubler Sep 9, 2024
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
85 changes: 85 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ arrayvec = "0.7"
bincode = "1"
bit-vec = "0.8"
bitflags = "2.6"
bon = "3.0.0"
bytemuck = { version = "1.19" }
cfg_aliases = "0.1"
cfg-if = "1"
Expand Down
74 changes: 26 additions & 48 deletions benches/benches/computepass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,22 +126,14 @@ impl ComputepassState {

let mut texture_views = Vec::with_capacity(texture_count);
for i in 0..texture_count {
let texture = device_state
.device
.create_texture(&wgpu::TextureDescriptor {
label: Some(&format!("Texture {i}")),
size: wgpu::Extent3d {
width: 1,
height: 1,
depth_or_array_layers: 1,
},
mip_level_count: 1,
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: wgpu::TextureFormat::Rgba8UnormSrgb,
usage: wgpu::TextureUsages::TEXTURE_BINDING,
view_formats: &[],
});
let texture = device_state.device.create_texture(
&wgpu::TextureDescriptor::builder()
ErichDonGubler marked this conversation as resolved.
Show resolved Hide resolved
.label(&*format!("Texture {i}"))
.size(Default::default())
.format(wgpu::TextureFormat::Rgba8UnormSrgb)
.usage(wgpu::TextureUsages::TEXTURE_BINDING)
.build(),
);
texture_views.push(texture.create_view(&wgpu::TextureViewDescriptor {
label: Some(&format!("Texture View {i}")),
..Default::default()
Expand All @@ -152,22 +144,14 @@ impl ComputepassState {

let mut storage_texture_views = Vec::with_capacity(storage_texture_count);
for i in 0..storage_texture_count {
let texture = device_state
.device
.create_texture(&wgpu::TextureDescriptor {
label: Some(&format!("StorageTexture {i}")),
size: wgpu::Extent3d {
width: 1,
height: 1,
depth_or_array_layers: 1,
},
mip_level_count: 1,
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: wgpu::TextureFormat::R32Float,
usage: wgpu::TextureUsages::STORAGE_BINDING,
view_formats: &[],
});
let texture = device_state.device.create_texture(
&wgpu::TextureDescriptor::builder()
.label(&*format!("StorageTexture {i}"))
.size(Default::default())
.format(wgpu::TextureFormat::R32Float)
.usage(wgpu::TextureUsages::STORAGE_BINDING)
.build(),
);
storage_texture_views.push(texture.create_view(&wgpu::TextureViewDescriptor {
label: Some(&format!("StorageTexture View {i}")),
..Default::default()
Expand Down Expand Up @@ -238,14 +222,11 @@ impl ComputepassState {
.device
.create_shader_module(wgpu::include_wgsl!("computepass.wgsl"));

let pipeline_layout =
device_state
.device
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[],
});
let pipeline_layout = device_state.device.create_pipeline_layout(
&wgpu::PipelineLayoutDescriptor::builder()
.bind_group_layouts(&[&bind_group_layout])
.build(),
);

let pipeline =
device_state
Expand Down Expand Up @@ -333,14 +314,11 @@ impl ComputepassState {
.device
.create_shader_module(wgpu::include_wgsl!("computepass-bindless.wgsl"));

let bindless_pipeline_layout =
device_state
.device
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bindless_bind_group_layout],
push_constant_ranges: &[],
});
let bindless_pipeline_layout = device_state.device.create_pipeline_layout(
&wgpu::PipelineLayoutDescriptor::builder()
.bind_group_layouts(&[&bindless_bind_group_layout])
.build(),
);

let bindless_pipeline =
device_state
Expand Down
Loading
Loading