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
280 changes: 128 additions & 152 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion crates/wgpu_playground_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ description = "Core WebGPU functionality for wgpu_playground"
dawn = []

[dependencies]
wgpu = { version = "28.0", features = ["wgsl"] }
wgpu = { version = "29.0", features = ["wgsl"] }
wgpu-core = "29.0"
wgpu-types = "29.0"
naga = { version = "29.0", features = ["wgsl-in"] }
Expand Down
4 changes: 2 additions & 2 deletions crates/wgpu_playground_core/src/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ pub fn backend_input_options() -> Vec<&'static str> {
/// Create a wgpu Instance with the specified backends
pub fn create_instance(backends: Backends) -> Instance {
log::debug!("Creating wgpu Instance with backends: {:?}", backends);
let instance = Instance::new(&wgpu::InstanceDescriptor {
let instance = Instance::new(wgpu::InstanceDescriptor {
backends,
..Default::default()
..wgpu::InstanceDescriptor::new_without_display_handle()
});
log::trace!("Instance created successfully");
instance
Expand Down
2 changes: 1 addition & 1 deletion crates/wgpu_playground_core/src/buffer_preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ fn fs_main(input: VertexOutput) -> @location(0) vec4<f32> {
tracker.record(ApiCategory::PipelineLayout, "create_pipeline_layout");
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Uniform Preview Pipeline Layout"),
bind_group_layouts: &[&bind_group_layout],
bind_group_layouts: &[Some(&bind_group_layout)],
immediate_size: 0,
});

Expand Down
8 changes: 4 additions & 4 deletions crates/wgpu_playground_core/src/code_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,9 @@ impl CodeGenerator {
async fn new(window: Arc<Window>) -> Self {{\n \
let size = window.inner_size();\n\
\n \
let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {{\n \
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {{\n \
backends: wgpu::Backends::all(),\n \
..Default::default()\n \
..wgpu::InstanceDescriptor::new_without_display_handle()\n \
}});\n\
\n \
let surface = instance.create_surface(window.clone()).unwrap();\n\
Expand Down Expand Up @@ -650,9 +650,9 @@ impl CodeGenerator {
code.push_str(
" let size = window.inner_size();\n\
\n \
let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {\n \
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {\n \
backends: wgpu::Backends::all(),\n \
..Default::default()\n \
..wgpu::InstanceDescriptor::new_without_display_handle()\n \
});\n\
\n \
let surface = instance.create_surface(window.clone()).unwrap();\n\
Expand Down
2 changes: 1 addition & 1 deletion crates/wgpu_playground_core/src/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ impl ComputePanel {
tracker.record(ApiCategory::PipelineLayout, "create_pipeline_layout");
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Compute Pipeline Layout"),
bind_group_layouts: &[&bind_group_layout],
bind_group_layouts: &[Some(&bind_group_layout)],
immediate_size: 0,
});

Expand Down
4 changes: 2 additions & 2 deletions crates/wgpu_playground_core/src/dawn_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ impl DawnInstance {

log::info!("Creating Dawn-compatible WebGPU instance using wgpu-core backend");

let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
..Default::default()
..wgpu::InstanceDescriptor::new_without_display_handle()
});

log::info!("Dawn-compatible instance created successfully");
Expand Down
6 changes: 3 additions & 3 deletions crates/wgpu_playground_core/src/device_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl DeviceConfigPanel {
self.render_feature_checkbox(
ui,
"Shader Primitive Index",
Features::SHADER_PRIMITIVE_INDEX,
Features::PRIMITIVE_INDEX,
);
});
}
Expand Down Expand Up @@ -245,15 +245,15 @@ impl DeviceConfigPanel {
);

// Buffer limits
Self::render_limit_u32(
Self::render_limit_u64(
ui,
"Max Uniform Buffer Binding Size",
&mut config_limits.max_uniform_buffer_binding_size,
adapter_limits.max_uniform_buffer_binding_size,
1,
);

Self::render_limit_u32(
Self::render_limit_u64(
ui,
"Max Storage Buffer Binding Size",
&mut config_limits.max_storage_buffer_binding_size,
Expand Down
2 changes: 1 addition & 1 deletion crates/wgpu_playground_core/src/device_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl DeviceInfo {
limits.max_vertex_buffer_array_stride,
limits.min_uniform_buffer_offset_alignment,
limits.min_storage_buffer_offset_alignment,
limits.max_inter_stage_shader_components,
limits.max_inter_stage_shader_variables,
limits.max_compute_workgroup_storage_size,
limits.max_compute_invocations_per_workgroup,
limits.max_compute_workgroup_size_x,
Expand Down
9 changes: 5 additions & 4 deletions crates/wgpu_playground_core/src/pipeline_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pub struct PipelineLayoutDescriptor<'a> {
/// Optional label for debugging
label: Option<String>,
/// Bind group layouts that will be used with this pipeline layout
bind_group_layouts: Vec<&'a BindGroupLayout>,
bind_group_layouts: Vec<Option<&'a BindGroupLayout>>,
/// Push constant ranges (if supported)
push_constant_ranges: Vec<PushConstantRange>,
}
Expand Down Expand Up @@ -156,7 +156,7 @@ impl<'a> PipelineLayoutDescriptor<'a> {
/// # }
/// ```
pub fn with_bind_group_layout(mut self, layout: &'a BindGroupLayout) -> Self {
self.bind_group_layouts.push(layout);
self.bind_group_layouts.push(Some(layout));
self
}

Expand All @@ -168,7 +168,8 @@ impl<'a> PipelineLayoutDescriptor<'a> {
/// # Returns
/// Self for method chaining
pub fn with_bind_group_layouts(mut self, layouts: &[&'a BindGroupLayout]) -> Self {
self.bind_group_layouts.extend_from_slice(layouts);
self.bind_group_layouts
.extend(layouts.iter().map(|l| Some(*l)));
self
}

Expand Down Expand Up @@ -215,7 +216,7 @@ impl<'a> PipelineLayoutDescriptor<'a> {
}

/// Get the bind group layouts
pub fn bind_group_layouts(&self) -> &[&'a BindGroupLayout] {
pub fn bind_group_layouts(&self) -> &[Option<&'a BindGroupLayout>] {
&self.bind_group_layouts
}

Expand Down
6 changes: 3 additions & 3 deletions crates/wgpu_playground_core/src/pipeline_preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ fn fs_main(input: VertexOutput) -> @location(0) vec4<f32> {
tracker.record(ApiCategory::PipelineLayout, "create_pipeline_layout");
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Pipeline Preview Layout"),
bind_group_layouts: &[&bind_group_layout],
bind_group_layouts: &[Some(&bind_group_layout)],
immediate_size: 0,
});

Expand Down Expand Up @@ -398,8 +398,8 @@ fn fs_main(input: VertexOutput) -> @location(0) vec4<f32> {

wgpu::DepthStencilState {
format: wgpu::TextureFormat::Depth24Plus,
depth_write_enabled: ds.depth_write_enabled,
depth_compare: compare,
depth_write_enabled: Some(ds.depth_write_enabled),
depth_compare: Some(compare),
stencil: wgpu::StencilState {
front: wgpu::StencilFaceState::IGNORE,
back: wgpu::StencilFaceState::IGNORE,
Expand Down
4 changes: 2 additions & 2 deletions crates/wgpu_playground_core/src/render_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,8 +793,8 @@ impl DepthStencilState {
pub fn to_wgpu(&self) -> wgpu::DepthStencilState {
wgpu::DepthStencilState {
format: self.format,
depth_write_enabled: self.depth_write_enabled,
depth_compare: self.depth_compare.to_wgpu(),
depth_write_enabled: Some(self.depth_write_enabled),
depth_compare: Some(self.depth_compare.to_wgpu()),
stencil: wgpu::StencilState {
front: self.stencil_front.to_wgpu(),
back: self.stencil_back.to_wgpu(),
Expand Down
8 changes: 4 additions & 4 deletions crates/wgpu_playground_core/src/rendering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
tracker.record(ApiCategory::PipelineLayout, "create_pipeline_layout");
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Cube Pipeline Layout"),
bind_group_layouts: &[&bind_group_layout],
bind_group_layouts: &[Some(&bind_group_layout)],
immediate_size: 0,
});

Expand Down Expand Up @@ -632,8 +632,8 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
},
depth_stencil: Some(wgpu::DepthStencilState {
format: wgpu::TextureFormat::Depth32Float,
depth_write_enabled: true,
depth_compare: wgpu::CompareFunction::Less,
depth_write_enabled: Some(true),
depth_compare: Some(wgpu::CompareFunction::Less),
stencil: wgpu::StencilState::default(),
bias: wgpu::DepthBiasState::default(),
}),
Expand Down Expand Up @@ -868,7 +868,7 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
tracker.record(ApiCategory::PipelineLayout, "create_pipeline_layout");
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Texture Pipeline Layout"),
bind_group_layouts: &[&bind_group_layout],
bind_group_layouts: &[Some(&bind_group_layout)],
immediate_size: 0,
});

Expand Down
30 changes: 14 additions & 16 deletions crates/wgpu_playground_core/src/surface.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use wgpu::{
CompositeAlphaMode, Device, Instance, PresentMode, Surface, SurfaceConfiguration,
SurfaceTexture, TextureFormat, TextureUsages,
CompositeAlphaMode, CurrentSurfaceTexture, Device, Instance, PresentMode, Surface,
SurfaceConfiguration, TextureFormat, TextureUsages,
};

/// Builder for creating and configuring GPU surfaces
Expand Down Expand Up @@ -169,26 +169,24 @@ pub fn configure_surface(surface: &Surface, device: &Device, config: &SurfaceCon
/// * `surface` - The surface to get the texture from
///
/// # Returns
/// The current surface texture, or an error if the surface is invalid
///
/// # Errors
/// Returns a `SurfaceError` if:
/// - The surface was lost and needs to be reconfigured
/// - The presentation system ran out of memory
/// - The surface timed out waiting for the next frame
/// - The surface is outdated and needs to be reconfigured
/// A [`wgpu::CurrentSurfaceTexture`] indicating the result of the operation.
/// On success, contains the surface texture ready for rendering.
///
/// # Examples
/// ```no_run
/// use wgpu_playground_core::surface::get_current_texture;
/// # async fn example(surface: &wgpu::Surface<'_>) -> Result<(), wgpu::SurfaceError> {
/// let texture = get_current_texture(surface)?;
/// // Use the texture for rendering
/// texture.present();
/// # Ok(())
/// use wgpu::CurrentSurfaceTexture;
/// # fn example(surface: &wgpu::Surface<'_>) {
/// match get_current_texture(surface) {
/// CurrentSurfaceTexture::Success(texture) | CurrentSurfaceTexture::Suboptimal(texture) => {
/// // Use the texture for rendering
/// texture.present();
/// }
/// _ => {} // Handle other cases (lost, outdated, timeout, etc.)
/// }
/// # }
/// ```
pub fn get_current_texture(surface: &Surface) -> Result<SurfaceTexture, wgpu::SurfaceError> {
pub fn get_current_texture(surface: &Surface) -> CurrentSurfaceTexture {
surface.get_current_texture()
}

Expand Down
2 changes: 1 addition & 1 deletion crates/wgpu_playground_core/src/texture_preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ fn fs_main(input: VertexOutput) -> @location(0) vec4<f32> {
tracker.record(ApiCategory::PipelineLayout, "create_pipeline_layout");
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Texture Preview Pipeline Layout"),
bind_group_layouts: &[&bind_group_layout],
bind_group_layouts: &[Some(&bind_group_layout)],
immediate_size: 0,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use wgpu_playground_core::adapter_selection::AdapterSelectionPanel;

// Helper function to create a test adapter
async fn create_test_adapter() -> Option<wgpu::Adapter> {
let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
..Default::default()
..wgpu::InstanceDescriptor::new_without_display_handle()
});

instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,9 @@ mod bind_group_creation_tests {

// Helper to create a device for testing
async fn create_test_device() -> Option<(wgpu::Device, wgpu::Queue)> {
let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
..Default::default()
..wgpu::InstanceDescriptor::new_without_display_handle()
});

let adapter = instance
Expand Down
5 changes: 2 additions & 3 deletions crates/wgpu_playground_core/tests/buffer_integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -779,9 +779,8 @@ fn test_buffer_map_write_modify_read() {
BufferOps::map_write(&write_buffer).await.unwrap();
{
let mut view = BufferOps::get_mapped_range_mut(&write_buffer);
for (i, byte) in view.iter_mut().enumerate() {
*byte = (i % 256) as u8;
}
let data: Vec<u8> = (0..256).map(|i| (i % 256) as u8).collect();
view.copy_from_slice(&data);
}
BufferOps::unmap(&write_buffer);

Expand Down
16 changes: 8 additions & 8 deletions crates/wgpu_playground_core/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ pub async fn create_test_device() -> Option<(Device, Queue)> {
wgpu::Backends::all()
};

let instance = Instance::new(&wgpu::InstanceDescriptor {
let instance = Instance::new(wgpu::InstanceDescriptor {
backends,
..Default::default()
..wgpu::InstanceDescriptor::new_without_display_handle()
});

let adapter = instance
Expand Down Expand Up @@ -96,9 +96,9 @@ pub async fn create_test_device_with_features(features: wgpu::Features) -> Optio
wgpu::Backends::all()
};

let instance = Instance::new(&wgpu::InstanceDescriptor {
let instance = Instance::new(wgpu::InstanceDescriptor {
backends,
..Default::default()
..wgpu::InstanceDescriptor::new_without_display_handle()
});

let adapter = instance
Expand Down Expand Up @@ -148,9 +148,9 @@ pub async fn create_test_device_with_limits(limits: wgpu::Limits) -> Option<(Dev
wgpu::Backends::all()
};

let instance = Instance::new(&wgpu::InstanceDescriptor {
let instance = Instance::new(wgpu::InstanceDescriptor {
backends,
..Default::default()
..wgpu::InstanceDescriptor::new_without_display_handle()
});

let adapter = instance
Expand Down Expand Up @@ -191,9 +191,9 @@ pub async fn create_test_instance_and_adapter() -> Option<(Instance, Adapter)> {
wgpu::Backends::all()
};

let instance = Instance::new(&wgpu::InstanceDescriptor {
let instance = Instance::new(wgpu::InstanceDescriptor {
backends,
..Default::default()
..wgpu::InstanceDescriptor::new_without_display_handle()
});

let adapter = instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ fn test_shader_editor_set_valid_shader() {
fn test_shader_editor_compile_with_device() {
// This test requires a GPU device
pollster::block_on(async {
let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
..Default::default()
..wgpu::InstanceDescriptor::new_without_display_handle()
});

let adapter = instance
Expand Down
4 changes: 2 additions & 2 deletions crates/wgpu_playground_core/tests/wasm_canvas_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,9 @@ async fn test_wgpu_surface_from_canvas() {
canvas.set_height(600);

// Create wgpu instance
let instance = Instance::new(&wgpu::InstanceDescriptor {
let instance = Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::BROWSER_WEBGPU,
..Default::default()
..wgpu::InstanceDescriptor::new_without_display_handle()
});

// Create surface from canvas
Expand Down
Loading
Loading