#WASM 16 bytes alignment / min_binding_size error

3 messages · Page 1 of 1 (latest)

left crane
#

hello!
I have this runtime error on my wasm build (works fine on native windows and linux), on the only custom material in my game

wgpu error: Validation Error

Caused by:
  In Device::create_render_pipeline, label = 'opaque_mesh_pipeline'
    In the provided shader, the type given for group 2 binding 0 has a size of 4. As the device does not support `DownlevelFlags::BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED`, the type must have a size that is a multiple of 16 bytes.

So I added the padding like so:

#[derive(Asset, AsBindGroup, TypePath, Debug, Clone)]
pub struct SkyboxCustomMaterial {
    #[uniform(0)]
    time_t0: f32,

    #[texture(1, dimension = "cube")]
    #[sampler(2)]
    sky_texture1: Handle<Image>,

    #[texture(3, dimension = "cube")]
    #[sampler(4)]
    sky_texture2: Handle<Image>,

    #[cfg(target_arch = "wasm32")]
    _padding_0: f32,
    #[cfg(target_arch = "wasm32")]
    _padding_1: f32,
    #[cfg(target_arch = "wasm32")]
    _padding_2: f32,
}
struct SkyboxCustomMaterial {
    time_t0: f32,
    #ifdef SIXTEEN_BYTE_ALIGNMENT
      // WebGL2 structs must be 16 byte aligned.
      _padding_0: f32,
      _padding_1: f32,
      _padding_2: f32,
    #endif
}

@group(2) @binding(0)
var<uniform> material: SkyboxCustomMaterial;

@group(2) @binding(1)
var skybox_texture1: texture_cube<f32>;
@group(2) @binding(2)
var skybox_texture1_sampler: sampler;

@group(2) @binding(3)
var skybox_texture2: texture_cube<f32>;
@group(2) @binding(4)
var skybox_texture2_sampler: sampler;
#

but now I get:

wgpu error: Validation Error

Caused by:
  In Device::create_render_pipeline, label = 'opaque_mesh_pipeline'
    Error matching ShaderStages(FRAGMENT) shader requirements against the pipeline
      Shader global ResourceBinding { group: 2, binding: 0 } is not available in the pipeline layout
        Buffer structure size 16, added to one element of an unbound array, if it's the last field, ended up greater than the given `min_binding_size`, which is 4

I dont really understand this error. Does anyone know what to do?

wicked beacon