Skip to content

Commit

Permalink
Use r32f for storage for better compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Wumpf committed Jun 29, 2024
1 parent 7409c77 commit ce1960b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions benches/benches/computepass-bindless.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var tex: binding_array<texture_2d<f32>>;

@group(0) @binding(1)
// TODO(https://github.com/gfx-rs/wgpu/issues/5765): The extra whitespace between the angle brackets is needed to workaround a parsing bug.
var images: binding_array<texture_storage_2d<rgba32float, read_write> >;
var images: binding_array<texture_storage_2d<r32float, read_write> >;
struct BufferElement {
element: vec4f,
}
Expand All @@ -21,6 +21,6 @@ fn cs_main(@builtin(global_invocation_id) global_invocation_id: vec3<u32>) {

let tex = textureLoad(tex[idx0], vec2u(0), 0) + textureLoad(tex[idx0], vec2u(0), 0);
let image = textureLoad(images[idx0], vec2u(0)) + textureLoad(images[idx1], vec2u(0));
buffers[idx0].element = tex;
buffers[idx1].element = image;
buffers[idx0].element = tex.rrrr;
buffers[idx1].element = image.rrrr;
}
6 changes: 3 additions & 3 deletions benches/benches/computepass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl ComputepassState {
visibility: wgpu::ShaderStages::COMPUTE,
ty: wgpu::BindingType::StorageTexture {
access: wgpu::StorageTextureAccess::ReadWrite,
format: wgpu::TextureFormat::Rgba32Float,
format: wgpu::TextureFormat::R32Float,
view_dimension: wgpu::TextureViewDimension::D2,
},
count: None,
Expand Down Expand Up @@ -144,7 +144,7 @@ impl ComputepassState {
mip_level_count: 1,
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: wgpu::TextureFormat::Rgba32Float,
format: wgpu::TextureFormat::R32Float,
usage: wgpu::TextureUsages::STORAGE_BINDING,
view_formats: &[],
});
Expand Down Expand Up @@ -263,7 +263,7 @@ impl ComputepassState {
visibility: wgpu::ShaderStages::COMPUTE,
ty: wgpu::BindingType::StorageTexture {
access: wgpu::StorageTextureAccess::ReadWrite,
format: wgpu::TextureFormat::Rgba32Float,
format: wgpu::TextureFormat::R32Float,
view_dimension: wgpu::TextureViewDimension::D2,
},
count: Some(NonZeroU32::new(STORAGE_TEXTURE_COUNT as u32).unwrap()),
Expand Down
8 changes: 4 additions & 4 deletions benches/benches/computepass.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ var tex_0: texture_2d<f32>;
var tex_1: texture_2d<f32>;

@group(0) @binding(2)
var image_0: texture_storage_2d<rgba32float, read_write>;
var image_0: texture_storage_2d<r32float, read_write>;

@group(0) @binding(3)
var image_1: texture_storage_2d<rgba32float, read_write>;
var image_1: texture_storage_2d<r32float, read_write>;

@group(0) @binding(4)
var<storage, read_write> buffer0 : array<vec4f>;
Expand All @@ -21,6 +21,6 @@ var<storage, read_write> buffer1 : array<vec4f>;
fn cs_main(@builtin(global_invocation_id) global_invocation_id: vec3<u32>) {
let tex = textureLoad(tex_0, vec2u(0), 0) + textureLoad(tex_1, vec2u(0), 0);
let image = textureLoad(image_0, vec2u(0)) + textureLoad(image_1, vec2u(0));
buffer0[0] = tex;
buffer1[0] = image;
buffer0[0] = tex.rrrr;
buffer1[0] = image.rrrr;
}

0 comments on commit ce1960b

Please sign in to comment.