diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 44b280ecc..1d1597d59 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -156,7 +156,7 @@ jobs: # check with all features # explicitly don't mention wgpu-hal so that --all-features don't apply to it - cargo ${{matrix.tool}} --target ${{ matrix.target }} -p wgpu -p wgpu-core -p wgpu-info -p player --examples --tests --all-features + cargo ${{matrix.tool}} --target ${{ matrix.target }} -p wgpu -p wgpu-core -p wgpu-info -p player --examples --tests --all-features # build docs cargo doc --target ${{ matrix.target }} --no-deps @@ -167,7 +167,10 @@ jobs: shell: bash run: | # run wgpu-info - cargo run --target ${{ matrix.target }} --bin wgpu-info + cargo run --bin wgpu-info + # run player tests + cargo test -p player + for backend in ${{ matrix.backends }}; do echo "======= NATIVE TESTS $backend ======"; # run player tests diff --git a/deno_webgpu/src/command_encoder.rs b/deno_webgpu/src/command_encoder.rs index d5f8d4f4d..f6e969381 100644 --- a/deno_webgpu/src/command_encoder.rs +++ b/deno_webgpu/src/command_encoder.rs @@ -431,7 +431,7 @@ pub fn op_webgpu_command_encoder_copy_texture_to_texture( #[derive(Deserialize)] #[serde(rename_all = "camelCase")] -pub struct CommandEncoderFillBufferArgs { +pub struct CommandEncoderClearBufferArgs { command_encoder_rid: u32, destination_rid: u32, destination_offset: u64, @@ -440,7 +440,7 @@ pub struct CommandEncoderFillBufferArgs { pub fn op_webgpu_command_encoder_clear_buffer( state: &mut OpState, - args: CommandEncoderFillBufferArgs, + args: CommandEncoderClearBufferArgs, _: (), ) -> Result { let instance = state.borrow::(); diff --git a/player/tests/data/all.ron b/player/tests/data/all.ron index 8d74fa884..e8157b9ea 100644 --- a/player/tests/data/all.ron +++ b/player/tests/data/all.ron @@ -1,5 +1,5 @@ ( - backends: (bits: 0xF), + backends: 0x3E, tests: [ "bind-group.ron", "buffer-copy.ron", diff --git a/player/tests/data/bind-group.ron b/player/tests/data/bind-group.ron index f47b75d47..00ecf0b20 100644 --- a/player/tests/data/bind-group.ron +++ b/player/tests/data/bind-group.ron @@ -1,5 +1,5 @@ ( - features: (bits: 0x0), + features: 0x0, expectations: [], //not crash! actions: [ CreatePipelineLayout(Id(0, 1, Empty), ( @@ -29,9 +29,7 @@ CreateBuffer(Id(0, 1, Empty), ( label: None, size: 16, - usage: ( - bits: 64, - ), + usage: 64, mapped_at_creation: false, )), CreateBindGroupLayout(Id(0, 1, Empty), ( @@ -39,7 +37,7 @@ entries: [ ( binding: 0, - visibility: (bits: 0x3), + visibility: 0x3, ty: Buffer( ty: Uniform, ), diff --git a/player/tests/data/buffer-copy.ron b/player/tests/data/buffer-copy.ron index b9cb8d454..c2fad09a2 100644 --- a/player/tests/data/buffer-copy.ron +++ b/player/tests/data/buffer-copy.ron @@ -1,5 +1,5 @@ ( - features: (bits: 0x0), + features: 0x0, expectations: [ ( name: "basic", @@ -14,9 +14,7 @@ ( label: Some("dummy"), size: 16, - usage: ( - bits: 41, - ), + usage: 41, mapped_at_creation: false, ), ), diff --git a/player/tests/data/clear-buffer-texture.ron b/player/tests/data/clear-buffer-texture.ron index c98ca110c..bd01fb61d 100644 --- a/player/tests/data/clear-buffer-texture.ron +++ b/player/tests/data/clear-buffer-texture.ron @@ -1,5 +1,5 @@ ( - features: (bits: 0x0000_0008_0000_0000), + features: 0x0000_0020_0000_0000, expectations: [ ( name: "Quad", @@ -25,15 +25,12 @@ size: ( width: 64, height: 64, - depth_or_array_layers: 1, ), mip_level_count: 1, sample_count: 1, - dimension: D2, - format: Rgba8Unorm, - usage: ( - bits: 27, - ), + dimension: r#2d, + format: rgba8unorm, + usage: 27, )), // First fill the texture to ensure it wasn't just zero initialized or "happened" to be zero. WriteTexture( @@ -51,7 +48,6 @@ size: ( width: 64, height: 64, - depth_or_array_layers: 1, ), ), CreateBuffer( @@ -59,9 +55,7 @@ ( label: Some("Output Buffer"), size: 16384, - usage: ( - bits: 9, - ), + usage: 9, mapped_at_creation: false, ), ), @@ -71,9 +65,7 @@ ( label: Some("Buffer to be cleared"), size: 16, - usage: ( - bits: 41, - ), + usage: 41, mapped_at_creation: false, ), ), @@ -91,7 +83,7 @@ ClearTexture( dst: Id(0, 1, Empty), subresource_range: ImageSubresourceRange( - aspect: All, + aspect: all, base_mip_level: 0, mip_level_count: None, base_array_layer: 0, @@ -115,7 +107,6 @@ size: ( width: 64, height: 64, - depth_or_array_layers: 1, ), ), // Partial clear to prove diff --git a/player/tests/data/pipeline-statistics-query.ron b/player/tests/data/pipeline-statistics-query.ron index bdf9b850a..6e0f10e9a 100644 --- a/player/tests/data/pipeline-statistics-query.ron +++ b/player/tests/data/pipeline-statistics-query.ron @@ -1,5 +1,5 @@ ( - features: (bits: 0x0000_0000_0000_0008), // PIPELINE_STATISTICS_QUERY + features: 0x0000_0000_0000_0010, // PIPELINE_STATISTICS_QUERY expectations: [ ( name: "Queried number of compute invocations is correct", @@ -38,7 +38,7 @@ desc: ( label: Some("Compute Invocation QuerySet"), count: 2, - ty: PipelineStatistics((bits: 0x18)), // FRAGMENT_SHADER_INVOCATIONS | COMPUTE_SHADER_INVOCATIONS + ty: PipelineStatistics(0x18), // FRAGMENT_SHADER_INVOCATIONS | COMPUTE_SHADER_INVOCATIONS ), ), CreateBuffer( @@ -46,9 +46,7 @@ ( label: Some("Compute Invocation Result Buffer"), size: 16, - usage: ( - bits: 9, // COPY_DST | MAP_READ - ), + usage: 9, // COPY_DST | MAP_READ mapped_at_creation: false, ), ), diff --git a/player/tests/data/quad.ron b/player/tests/data/quad.ron index 2a72c61b1..b6153b2f6 100644 --- a/player/tests/data/quad.ron +++ b/player/tests/data/quad.ron @@ -1,5 +1,5 @@ ( - features: (bits: 0x0), + features: 0x0, expectations: [ ( name: "Quad", @@ -22,15 +22,12 @@ size: ( width: 64, height: 64, - depth_or_array_layers: 1, ), mip_level_count: 1, sample_count: 1, - dimension: D2, - format: Rgba8Unorm, - usage: ( - bits: 27, - ), + dimension: r#2d, + format: rgba8unorm, + usage: 27, )), CreateTextureView( id: Id(0, 1, Empty), @@ -42,9 +39,7 @@ ( label: Some("Output Buffer"), size: 16384, - usage: ( - bits: 9, - ), + usage: 9, mapped_at_creation: false, ), ), @@ -72,7 +67,7 @@ ), targets: [ ( - format: Rgba8Unorm, + format: rgba8unorm, ), ], )), @@ -99,8 +94,8 @@ view: Id(0, 1, Empty), resolve_target: None, channel: ( - load_op: Clear, - store_op: Store, + load_op: clear, + store_op: store, clear_value: ( r: 0, g: 0, @@ -130,7 +125,6 @@ size: ( width: 64, height: 64, - depth_or_array_layers: 1, ), ), ]), diff --git a/player/tests/data/zero-init-buffer.ron b/player/tests/data/zero-init-buffer.ron index a51c5cc4f..1381ea739 100644 --- a/player/tests/data/zero-init-buffer.ron +++ b/player/tests/data/zero-init-buffer.ron @@ -1,5 +1,5 @@ ( - features: (bits: 0x0), + features: 0x0, expectations: [ // Ensuring that mapping zero-inits buffers. ( @@ -43,9 +43,7 @@ ( label: Some("mapped_at_creation: false, with MAP_WRITE"), size: 16, - usage: ( - bits: 131, // STORAGE + MAP_READ + MAP_WRITE - ), + usage: 131, // STORAGE + MAP_READ + MAP_WRITE mapped_at_creation: false, ), ), @@ -54,9 +52,7 @@ ( label: Some("mapped_at_creation: false, without MAP_WRITE"), size: 16, - usage: ( - bits: 129, // STORAGE + MAP_READ - ), + usage: 129, // STORAGE + MAP_READ mapped_at_creation: false, ), ), @@ -65,9 +61,7 @@ ( label: Some("partially written"), size: 24, - usage: ( - bits: 9, // MAP_READ + COPY_DST - ), + usage: 9, // MAP_READ + COPY_DST mapped_at_creation: false, ), ), @@ -91,9 +85,7 @@ CreateBuffer(Id(3, 1, Empty), ( label: Some("used in binding"), size: 16, - usage: ( - bits: 129, // STORAGE + MAP_READ - ), + usage: 129, // STORAGE + MAP_READ mapped_at_creation: false, )), CreateBindGroupLayout(Id(0, 1, Empty), ( @@ -101,9 +93,7 @@ entries: [ ( binding: 0, - visibility: ( - bits: 4, - ), + visibility: 4, ty: Buffer( ty: Storage( read_only: false, diff --git a/player/tests/data/zero-init-texture-binding.ron b/player/tests/data/zero-init-texture-binding.ron index 408d5eb20..f1e51396f 100644 --- a/player/tests/data/zero-init-texture-binding.ron +++ b/player/tests/data/zero-init-texture-binding.ron @@ -1,5 +1,5 @@ ( - features: (bits: 0x0), + features: 0x0, expectations: [ ( name: "Sampled Texture", @@ -22,15 +22,12 @@ size: ( width: 64, height: 64, - depth_or_array_layers: 1, ), mip_level_count: 1, sample_count: 1, - dimension: D2, - format: Rgba8Unorm, - usage: ( - bits: 5, // SAMPLED + COPY_SRC - ), + dimension: r#2d, + format: rgba8unorm, + usage: 5, // SAMPLED + COPY_SRC )), CreateTextureView( id: Id(0, 1, Empty), @@ -42,9 +39,7 @@ ( label: Some("Sampled Texture Buffer"), size: 16384, - usage: ( - bits: 9, - ), + usage: 9, mapped_at_creation: false, ), ), @@ -53,15 +48,12 @@ size: ( width: 64, height: 64, - depth_or_array_layers: 1, ), mip_level_count: 1, sample_count: 1, - dimension: D2, - format: Rgba8Unorm, - usage: ( - bits: 9, // STORAGE + COPY_SRC - ), + dimension: r#2d, + format: rgba8unorm, + usage: 9, // STORAGE + COPY_SRC )), CreateTextureView( id: Id(1, 1, Empty), @@ -73,9 +65,7 @@ ( label: Some("Storage Texture Buffer"), size: 16384, - usage: ( - bits: 9, - ), + usage: 9, mapped_at_creation: false, ), ), @@ -86,25 +76,21 @@ entries: [ ( binding: 0, - visibility: ( - bits: 4, // COMPUTE - ), + visibility: 4, // COMPUTE ty: Texture ( sample_type: Float(filterable: true), - view_dimension: D2, + view_dimension: r#2d, multisampled: false, ), count: None, ), ( binding: 1, - visibility: ( - bits: 4, // COMPUTE - ), + visibility: 4, // COMPUTE ty: StorageTexture ( - access: WriteOnly, - format: Rgba8Unorm, - view_dimension: D2, + access: r#write-only, + format: rgba8unorm, + view_dimension: r#2d, ), count: None, ), @@ -185,7 +171,6 @@ size: ( width: 64, height: 64, - depth_or_array_layers: 1, ), ), CopyTextureToBuffer( @@ -205,7 +190,6 @@ size: ( width: 64, height: 64, - depth_or_array_layers: 1, ), ), ]), diff --git a/player/tests/data/zero-init-texture-binding.wgsl b/player/tests/data/zero-init-texture-binding.wgsl index 94968b704..a7ff6b7b6 100644 --- a/player/tests/data/zero-init-texture-binding.wgsl +++ b/player/tests/data/zero-init-texture-binding.wgsl @@ -1,5 +1,5 @@ [[group(0), binding(0)]] var tex: texture_2d; -[[group(0), binding(1)]] var tex_storage: texture_storage_2d; +[[group(0), binding(1)]] var tex_storage: texture_storage_2d; [[stage(compute), workgroup_size(1)]] fn main([[builtin(global_invocation_id)]] global_id: vec3) { diff --git a/player/tests/data/zero-init-texture-copytobuffer.ron b/player/tests/data/zero-init-texture-copytobuffer.ron index c006e9c09..684272140 100644 --- a/player/tests/data/zero-init-texture-copytobuffer.ron +++ b/player/tests/data/zero-init-texture-copytobuffer.ron @@ -1,5 +1,5 @@ ( - features: (bits: 0x0), + features: 0x0, expectations: [ ( name: "Copy to Buffer", @@ -15,24 +15,19 @@ size: ( width: 64, height: 64, - depth_or_array_layers: 1, ), mip_level_count: 1, sample_count: 1, - dimension: D2, - format: Rgba8Unorm, - usage: ( - bits: 1, // COPY_SRC - ), + dimension: r#2d, + format: rgba8unorm, + usage: 1, // COPY_SRC )), CreateBuffer( Id(0, 1, Empty), ( label: Some("Copy to Buffer Buffer"), size: 16384, - usage: ( - bits: 9, - ), + usage: 9, mapped_at_creation: false, ), ), @@ -54,7 +49,6 @@ size: ( width: 64, height: 64, - depth_or_array_layers: 1, ), ), ]), diff --git a/player/tests/data/zero-init-texture-rendertarget.ron b/player/tests/data/zero-init-texture-rendertarget.ron index 59ce62b5b..836198d79 100644 --- a/player/tests/data/zero-init-texture-rendertarget.ron +++ b/player/tests/data/zero-init-texture-rendertarget.ron @@ -1,5 +1,5 @@ ( - features: (bits: 0x0), + features: 0x0, expectations: [ ( name: "Render Target", @@ -15,15 +15,12 @@ size: ( width: 64, height: 64, - depth_or_array_layers: 1, ), mip_level_count: 1, sample_count: 1, - dimension: D2, - format: Rgba8Unorm, - usage: ( - bits: 17, // RENDER_ATTACHMENT + COPY_SRC - ), + dimension: r#2d, + format: rgba8unorm, + usage: 17, // RENDER_ATTACHMENT + COPY_SRC )), CreateTextureView( id: Id(0, 1, Empty), @@ -35,9 +32,7 @@ ( label: Some("Render Target Buffer"), size: 16384, - usage: ( - bits: 9, - ), + usage: 9, mapped_at_creation: false, ), ), @@ -55,8 +50,8 @@ view: Id(0, 1, Empty), resolve_target: None, channel: ( - load_op: Load, - store_op: Store, + load_op: load, + store_op: store, clear_value: ( r: 1, g: 1, b: 1, a: 1, ), @@ -83,7 +78,6 @@ size: ( width: 64, height: 64, - depth_or_array_layers: 1, ), ), ]), diff --git a/player/tests/test.rs b/player/tests/test.rs index d5d6642f3..6fa3395ae 100644 --- a/player/tests/test.rs +++ b/player/tests/test.rs @@ -89,7 +89,7 @@ impl Test<'_> { adapter, &wgt::DeviceDescriptor { label: None, - features: self.features | wgt::Features::MAPPABLE_PRIMARY_BUFFERS, + features: self.features, limits: wgt::Limits::default(), }, None, diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index ec44f5004..10ec405ee 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -48,6 +48,7 @@ use super::{memory_init::TextureSurfaceDiscard, CommandBufferTextureMemoryAction #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)] #[cfg_attr(any(feature = "serial-pass", feature = "trace"), derive(Serialize))] #[cfg_attr(any(feature = "serial-pass", feature = "replay"), derive(Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "kebab-case"))] pub enum LoadOp { /// Clear the output attachment with the clear color. Clearing is faster than loading. Clear = 0, diff --git a/wgpu-core/src/pipeline.rs b/wgpu-core/src/pipeline.rs index 099ecd3a7..946cb8376 100644 --- a/wgpu-core/src/pipeline.rs +++ b/wgpu-core/src/pipeline.rs @@ -29,6 +29,7 @@ pub enum ShaderModuleSource<'a> { #[cfg_attr(feature = "replay", derive(serde::Deserialize))] pub struct ShaderModuleDescriptor<'a> { pub label: Label<'a>, + #[cfg_attr(feature = "serde", serde(default))] pub shader_bound_checks: wgt::ShaderBoundChecks, } diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 88e7627fa..c7a5b93cd 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -2755,9 +2755,15 @@ pub struct Extent3d { /// pub height: u32, /// + #[cfg_attr(feature = "serde", serde(default = "default_depth"))] pub depth_or_array_layers: u32, } +#[cfg(feature = "serde")] +fn default_depth() -> u32 { + 1 +} + impl Default for Extent3d { fn default() -> Self { Self {