fix(renderer): merge IBL into group(3) to stay within max_bind_groups limit of 4

wgpu's default max_bind_groups is 4 (groups 0-3), but the PBR shader was
using group(4) for BRDF LUT bindings. This merges IBL bindings into the
shadow bind group (group 3) at binding slots 3-4, removes the standalone
IBL bind group layout/creation, and updates all examples accordingly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-24 21:38:45 +09:00
parent 9202bfadef
commit 080ac92fbb
8 changed files with 39 additions and 76 deletions

View File

@@ -41,7 +41,6 @@ struct AppState {
shadow_bind_group: wgpu::BindGroup,
_shadow_map: ShadowMap,
_ibl: IblResources,
ibl_bind_group: wgpu::BindGroup,
input: InputState,
timer: GameTimer,
cam_aligned_size: u32,
@@ -179,8 +178,6 @@ impl ApplicationHandler for IblDemoApp {
// IBL resources
let ibl = IblResources::new(&gpu.device, &gpu.queue);
let ibl_layout = IblResources::bind_group_layout(&gpu.device);
let ibl_bind_group = ibl.create_bind_group(&gpu.device, &ibl_layout);
// Material bind group
let material_bind_group = gpu.device.create_bind_group(&wgpu::BindGroupDescriptor {
@@ -216,6 +213,8 @@ impl ApplicationHandler for IblDemoApp {
&gpu.device,
&shadow_layout,
&shadow_uniform_buffer,
&ibl.brdf_lut_view,
&ibl.brdf_lut_sampler,
);
// PBR pipeline
@@ -226,7 +225,6 @@ impl ApplicationHandler for IblDemoApp {
&pbr_tex_layout,
&mat_layout,
&shadow_layout,
&ibl_layout,
);
self.state = Some(AppState {
@@ -247,7 +245,6 @@ impl ApplicationHandler for IblDemoApp {
shadow_bind_group,
_shadow_map: shadow_map,
_ibl: ibl,
ibl_bind_group,
input: InputState::new(),
timer: GameTimer::new(60),
cam_aligned_size,
@@ -490,7 +487,6 @@ impl ApplicationHandler for IblDemoApp {
render_pass.set_pipeline(&state.pipeline);
render_pass.set_bind_group(1, &state.pbr_texture_bind_group, &[]);
render_pass.set_bind_group(3, &state.shadow_bind_group, &[]);
render_pass.set_bind_group(4, &state.ibl_bind_group, &[]);
render_pass.set_vertex_buffer(0, state.mesh.vertex_buffer.slice(..));
render_pass.set_index_buffer(
state.mesh.index_buffer.slice(..),

View File

@@ -40,7 +40,6 @@ struct AppState {
shadow_bind_group: wgpu::BindGroup,
_shadow_map: ShadowMap,
_ibl: IblResources,
ibl_bind_group: wgpu::BindGroup,
input: InputState,
timer: GameTimer,
cam_aligned_size: u32,
@@ -190,8 +189,6 @@ impl ApplicationHandler for MultiLightApp {
// IBL resources
let ibl = IblResources::new(&gpu.device, &gpu.queue);
let ibl_layout = IblResources::bind_group_layout(&gpu.device);
let ibl_bind_group = ibl.create_bind_group(&gpu.device, &ibl_layout);
// Material bind group
let material_bind_group = gpu.device.create_bind_group(&wgpu::BindGroupDescriptor {
@@ -227,6 +224,8 @@ impl ApplicationHandler for MultiLightApp {
&gpu.device,
&shadow_layout,
&shadow_uniform_buffer,
&ibl.brdf_lut_view,
&ibl.brdf_lut_sampler,
);
// PBR pipeline
@@ -237,7 +236,6 @@ impl ApplicationHandler for MultiLightApp {
&pbr_tex_layout,
&mat_layout,
&shadow_layout,
&ibl_layout,
);
self.state = Some(AppState {
@@ -259,7 +257,6 @@ impl ApplicationHandler for MultiLightApp {
shadow_bind_group,
_shadow_map: shadow_map,
_ibl: ibl,
ibl_bind_group,
input: InputState::new(),
timer: GameTimer::new(60),
cam_aligned_size,
@@ -545,7 +542,6 @@ impl ApplicationHandler for MultiLightApp {
render_pass.set_pipeline(&state.pipeline);
render_pass.set_bind_group(1, &state.pbr_texture_bind_group, &[]);
render_pass.set_bind_group(3, &state.shadow_bind_group, &[]);
render_pass.set_bind_group(4, &state.ibl_bind_group, &[]);
// Draw 5 spheres (objects 0..4)
render_pass.set_vertex_buffer(0, state.sphere_mesh.vertex_buffer.slice(..));

View File

@@ -41,7 +41,6 @@ struct AppState {
shadow_bind_group: wgpu::BindGroup,
_shadow_map: ShadowMap,
_ibl: IblResources,
ibl_bind_group: wgpu::BindGroup,
input: InputState,
timer: GameTimer,
cam_aligned_size: u32,
@@ -175,8 +174,6 @@ impl ApplicationHandler for PbrDemoApp {
// IBL resources
let ibl = IblResources::new(&gpu.device, &gpu.queue);
let ibl_layout = IblResources::bind_group_layout(&gpu.device);
let ibl_bind_group = ibl.create_bind_group(&gpu.device, &ibl_layout);
// Material bind group
let material_bind_group = gpu.device.create_bind_group(&wgpu::BindGroupDescriptor {
@@ -212,6 +209,8 @@ impl ApplicationHandler for PbrDemoApp {
&gpu.device,
&shadow_layout,
&shadow_uniform_buffer,
&ibl.brdf_lut_view,
&ibl.brdf_lut_sampler,
);
// PBR pipeline
@@ -222,7 +221,6 @@ impl ApplicationHandler for PbrDemoApp {
&pbr_tex_layout,
&mat_layout,
&shadow_layout,
&ibl_layout,
);
self.state = Some(AppState {
@@ -243,7 +241,6 @@ impl ApplicationHandler for PbrDemoApp {
shadow_bind_group,
_shadow_map: shadow_map,
_ibl: ibl,
ibl_bind_group,
input: InputState::new(),
timer: GameTimer::new(60),
cam_aligned_size,
@@ -481,7 +478,6 @@ impl ApplicationHandler for PbrDemoApp {
render_pass.set_pipeline(&state.pipeline);
render_pass.set_bind_group(1, &state.pbr_texture_bind_group, &[]);
render_pass.set_bind_group(3, &state.shadow_bind_group, &[]);
render_pass.set_bind_group(4, &state.ibl_bind_group, &[]);
render_pass.set_vertex_buffer(0, state.mesh.vertex_buffer.slice(..));
render_pass.set_index_buffer(
state.mesh.index_buffer.slice(..),

View File

@@ -48,7 +48,6 @@ struct AppState {
shadow_pass_buffer: wgpu::Buffer,
shadow_pass_bind_group: wgpu::BindGroup,
_ibl: IblResources,
ibl_bind_group: wgpu::BindGroup,
// Misc
input: InputState,
timer: GameTimer,
@@ -227,8 +226,6 @@ impl ApplicationHandler for ShadowDemoApp {
// IBL resources
let ibl = IblResources::new(&gpu.device, &gpu.queue);
let ibl_layout = IblResources::bind_group_layout(&gpu.device);
let ibl_bind_group = ibl.create_bind_group(&gpu.device, &ibl_layout);
// Material bind group
let material_bind_group = gpu.device.create_bind_group(&wgpu::BindGroupDescriptor {
@@ -263,6 +260,8 @@ impl ApplicationHandler for ShadowDemoApp {
&gpu.device,
&shadow_layout,
&shadow_uniform_buffer,
&ibl.brdf_lut_view,
&ibl.brdf_lut_sampler,
);
// Shadow pass dynamic UBO (one ShadowPassUniform per object)
@@ -295,7 +294,6 @@ impl ApplicationHandler for ShadowDemoApp {
&pbr_tex_layout,
&mat_layout,
&shadow_layout,
&ibl_layout,
);
self.state = Some(AppState {
@@ -321,7 +319,6 @@ impl ApplicationHandler for ShadowDemoApp {
shadow_pass_buffer,
shadow_pass_bind_group,
_ibl: ibl,
ibl_bind_group,
input: InputState::new(),
timer: GameTimer::new(60),
cam_aligned_size,
@@ -584,7 +581,6 @@ impl ApplicationHandler for ShadowDemoApp {
render_pass.set_pipeline(&state.pbr_pipeline);
render_pass.set_bind_group(1, &state.pbr_texture_bind_group, &[]);
render_pass.set_bind_group(3, &state.shadow_bind_group, &[]);
render_pass.set_bind_group(4, &state.ibl_bind_group, &[]);
for i in 0..NUM_OBJECTS {
let cam_offset = (i as u32) * state.cam_aligned_size;