Skip to content

Commit

Permalink
fix: storage texture -> texture
Browse files Browse the repository at this point in the history
  • Loading branch information
mosure committed Dec 31, 2023
1 parent fee1d95 commit 24b0abe
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 54 deletions.
40 changes: 8 additions & 32 deletions src/render/bindings.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -59,52 +59,28 @@ struct Gaussian {


#ifdef PLANAR_TEXTURE_F16
#ifdef READ_WRITE_POINTS
@group(2) @binding(0) var position_visibility: texture_storage_2d<rgba32float, read_write>;

#if SH_VEC4_PLANES == 1
@group(2) @binding(1) var spherical_harmonics: texture_storage_2d<rgba32uint, read_write>;
#else
@group(2) @binding(1) var spherical_harmonics: texture_storage_2d_array<rgba32uint, read_write>;
#endif

@group(2) @binding(2) var rotation_scale_opacity: texture_storage_2d<rgba32uint, read_write>;
#else
@group(2) @binding(0) var position_visibility: texture_storage_2d<rgba32float, read>;
@group(2) @binding(0) var position_visibility: texture_2d<f32>;

#if SH_VEC4_PLANES == 1
@group(2) @binding(1) var spherical_harmonics: texture_storage_2d<rgba32uint, read>;
@group(2) @binding(1) var spherical_harmonics: texture_2d<u32>;
#else
@group(2) @binding(1) var spherical_harmonics: texture_storage_2d_array<rgba32uint, read>;
@group(2) @binding(1) var spherical_harmonics: texture_2d_array<u32>;
#endif

@group(2) @binding(2) var rotation_scale_opacity: texture_storage_2d<rgba32uint, read>;
#endif
@group(2) @binding(2) var rotation_scale_opacity: texture_2d<u32>;
#endif


#ifdef PLANAR_TEXTURE_F32
#ifdef READ_WRITE_POINTS
@group(2) @binding(0) var position_visibility: texture_storage_2d<rgba32float, read_write>;

#if SH_VEC4_PLANES == 1
@group(2) @binding(1) var spherical_harmonics: texture_storage_2d<rgba32float, read_write>;
#else
@group(2) @binding(1) var spherical_harmonics: texture_storage_2d_array<rgba32float, read_write>;
#endif

@group(2) @binding(2) var rotation_scale_opacity: texture_storage_2d<rgba32float, read_write>;
#else
@group(2) @binding(0) var position_visibility: texture_storage_2d<rgba32float, read>;
@group(2) @binding(0) var position_visibility: texture_2d<f32>;

#if SH_VEC4_PLANES == 1
@group(2) @binding(1) var spherical_harmonics: texture_storage_2d<rgba32float, read>;
@group(2) @binding(1) var spherical_harmonics: texture_2d<f32>;
#else
@group(2) @binding(1) var spherical_harmonics: texture_storage_2d_array<rgba32float, read>;
@group(2) @binding(1) var spherical_harmonics: texture_2d_array<f32>;
#endif

@group(2) @binding(2) var rotation_scale_opacity: texture_storage_2d<rgba32float, read>;
#endif
@group(2) @binding(2) var rotation_scale_opacity: texture_2d<f32>;
#endif


Expand Down
1 change: 1 addition & 0 deletions src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ impl FromWorld for GaussianCloudPipeline {
#[cfg(feature = "buffer_texture")]
let gaussian_cloud_layout = texture::get_bind_group_layout(&render_device, read_only);

// TODO: support sorted layout as a texture
let sorted_layout = render_device.create_bind_group_layout(&BindGroupLayoutDescriptor {
label: Some("sorted_layout"),
entries: &[
Expand Down
38 changes: 16 additions & 22 deletions src/render/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ fn queue_textures(
bytemuck::cast_slice(cloud.position_visibility.as_slice()).to_vec(),
TextureFormat::Rgba32Float,
);
position_visibility.texture_descriptor.usage = TextureUsages::COPY_DST | TextureUsages::STORAGE_BINDING | TextureUsages::TEXTURE_BINDING;
position_visibility.texture_descriptor.usage = TextureUsages::COPY_DST | TextureUsages::TEXTURE_BINDING;
let position_visibility = images.add(position_visibility);

let texture_buffers: TextureBuffers;
Expand Down Expand Up @@ -241,7 +241,7 @@ fn queue_textures(
bytemuck::cast_slice(planar_spherical_harmonics.as_slice()).to_vec(),
TextureFormat::Rgba32Uint,
);
spherical_harmonics.texture_descriptor.usage = TextureUsages::COPY_DST | TextureUsages::STORAGE_BINDING | TextureUsages::TEXTURE_BINDING;
spherical_harmonics.texture_descriptor.usage = TextureUsages::COPY_DST | TextureUsages::TEXTURE_BINDING;
let spherical_harmonics = images.add(spherical_harmonics);

let mut rotation_scale_opacity = Image::new(
Expand All @@ -250,7 +250,7 @@ fn queue_textures(
bytemuck::cast_slice(cloud.rotation_scale_opacity_packed128.as_slice()).to_vec(),
TextureFormat::Rgba32Uint,
);
rotation_scale_opacity.texture_descriptor.usage = TextureUsages::COPY_DST | TextureUsages::STORAGE_BINDING | TextureUsages::TEXTURE_BINDING;
rotation_scale_opacity.texture_descriptor.usage = TextureUsages::COPY_DST | TextureUsages::TEXTURE_BINDING;
let rotation_scale_opacity = images.add(rotation_scale_opacity);

texture_buffers = TextureBuffers {
Expand Down Expand Up @@ -278,14 +278,8 @@ fn queue_textures(
#[cfg(feature = "f16")]
pub fn get_bind_group_layout(
render_device: &RenderDevice,
read_only: bool
_read_only: bool
) -> BindGroupLayout {
let access = if read_only {
StorageTextureAccess::ReadOnly
} else {
StorageTextureAccess::ReadWrite
};

let sh_view_dimension = if SH_VEC4_PLANES == 1 {
TextureViewDimension::D2
} else {
Expand All @@ -297,31 +291,31 @@ pub fn get_bind_group_layout(
entries: &[
BindGroupLayoutEntry {
binding: 0,
visibility: ShaderStages::all(),
ty: BindingType::StorageTexture {
access,
format: TextureFormat::Rgba32Float,
visibility: ShaderStages::VERTEX_FRAGMENT,
ty: BindingType::Texture {
view_dimension: TextureViewDimension::D2,
sample_type: TextureSampleType::Uint,
multisampled: false,
},
count: None,
},
BindGroupLayoutEntry {
binding: 1,
visibility: ShaderStages::all(),
ty: BindingType::StorageTexture {
access,
format: TextureFormat::Rgba32Uint,
visibility: ShaderStages::VERTEX_FRAGMENT,
ty: BindingType::Texture {
view_dimension: sh_view_dimension,
sample_type: TextureSampleType::Uint,
multisampled: false,
},
count: None,
},
BindGroupLayoutEntry {
binding: 2,
visibility: ShaderStages::all(),
ty: BindingType::StorageTexture {
access,
format: TextureFormat::Rgba32Uint,
visibility: ShaderStages::VERTEX_FRAGMENT,
ty: BindingType::Texture {
view_dimension: TextureViewDimension::D2,
sample_type: TextureSampleType::Uint,
multisampled: false,
},
count: None,
},
Expand Down

0 comments on commit 24b0abe

Please sign in to comment.