Skip to content

Commit

Permalink
Update to wgpu 0.18 (#10266)
Browse files Browse the repository at this point in the history
# Objective

Keep up to date with wgpu.

## Solution

Update the wgpu version.

Currently blocked on naga_oil updating to naga 0.14 and releasing a new
version.

3d scenes (or maybe any scene with lighting?) currently don't render
anything due to
```
error: naga_oil bug, please file a report: composer failed to build a valid header: Type [2] '' is invalid
 = Capability Capabilities(CUBE_ARRAY_TEXTURES) is required
 ```

I'm not sure what should be passed in for `wgpu::InstanceFlags`, or if we want to make the gles3minorversion configurable (might be useful for debugging?)

Currently blocked on bevyengine/naga_oil#63, and gfx-rs/wgpu#4569 to be fixed upstream in wgpu first.

## Known issues

Amd+windows+vulkan has issues with texture_binding_arrays (see the image [here](#10266 (comment))), but that'll be fixed in the next wgpu/naga version, and you can just use dx12 as a workaround for now (Amd+linux mesa+vulkan texture_binding_arrays are fixed though).

---

## Changelog

Updated wgpu to 0.18, naga to 0.14.2, and naga_oil to 0.11.
- Windows desktop GL should now be less painful as it no longer requires Angle.
- You can now toggle shader validation and debug information for debug and release builds using `WgpuSettings.instance_flags` and [InstanceFlags](https://docs.rs/wgpu/0.18.0/wgpu/struct.InstanceFlags.html)

## Migration Guide

- `RenderPassDescriptor` `color_attachments`  (as well as `RenderPassColorAttachment`, and `RenderPassDepthStencilAttachment`) now use `StoreOp::Store` or `StoreOp::Discard` instead of a `boolean` to declare whether or not they should be stored.
- `RenderPassDescriptor` now have `timestamp_writes` and `occlusion_query_set` fields. These can safely be set to `None`.
- `ComputePassDescriptor` now have a `timestamp_writes` field. This can be set to `None` for now.
- See the [wgpu changelog](https://github.com/gfx-rs/wgpu/blob/trunk/CHANGELOG.md#v0180-2023-10-25) for additional details
  • Loading branch information
Elabajaba authored Dec 14, 2023
1 parent 0159df3 commit 70a592f
Show file tree
Hide file tree
Showing 29 changed files with 125 additions and 44 deletions.
12 changes: 10 additions & 2 deletions crates/bevy_core_pipeline/src/bloom/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ impl ViewNode for BloomNode {
ops: Operations::default(),
})],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
});
downsampling_first_pass.set_render_pipeline(downsampling_first_pipeline);
downsampling_first_pass.set_bind_group(
Expand All @@ -211,6 +213,8 @@ impl ViewNode for BloomNode {
ops: Operations::default(),
})],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
});
downsampling_pass.set_render_pipeline(downsampling_pipeline);
downsampling_pass.set_bind_group(
Expand All @@ -232,10 +236,12 @@ impl ViewNode for BloomNode {
resolve_target: None,
ops: Operations {
load: LoadOp::Load,
store: true,
store: StoreOp::Store,
},
})],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
});
upsampling_pass.set_render_pipeline(upsampling_pipeline);
upsampling_pass.set_bind_group(
Expand All @@ -262,10 +268,12 @@ impl ViewNode for BloomNode {
color_attachments: &[Some(view_target.get_unsampled_color_attachment(
Operations {
load: LoadOp::Load,
store: true,
store: StoreOp::Store,
},
))],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
});
upsampling_final_pass.set_render_pipeline(upsampling_final_pipeline);
upsampling_final_pass.set_bind_group(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ impl Node for CASNode {
ops: Operations::default(),
})],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
};

let mut render_pass = render_context
Expand Down
10 changes: 7 additions & 3 deletions crates/bevy_core_pipeline/src/core_2d/main_pass_2d_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use bevy_render::{
camera::ExtractedCamera,
render_graph::{Node, NodeRunError, RenderGraphContext},
render_phase::RenderPhase,
render_resource::{LoadOp, Operations, RenderPassDescriptor},
render_resource::{LoadOp, Operations, RenderPassDescriptor, StoreOp},
renderer::RenderContext,
view::{ExtractedView, ViewTarget},
};
Expand Down Expand Up @@ -66,9 +66,11 @@ impl Node for MainPass2dNode {
ClearColorConfig::Custom(color) => LoadOp::Clear(color.into()),
ClearColorConfig::None => LoadOp::Load,
},
store: true,
store: StoreOp::Store,
}))],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
});

if let Some(viewport) = camera.viewport.as_ref() {
Expand All @@ -88,9 +90,11 @@ impl Node for MainPass2dNode {
label: Some("reset_viewport_pass_2d"),
color_attachments: &[Some(target.get_color_attachment(Operations {
load: LoadOp::Load,
store: true,
store: StoreOp::Store,
}))],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
};

render_context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use bevy_render::{
render_phase::RenderPhase,
render_resource::{
LoadOp, Operations, PipelineCache, RenderPassDepthStencilAttachment, RenderPassDescriptor,
StoreOp,
},
renderer::RenderContext,
view::{ViewDepthTexture, ViewTarget, ViewUniformOffset},
Expand Down Expand Up @@ -82,9 +83,10 @@ impl ViewNode for MainOpaquePass3dNode {
label: Some("main_opaque_pass_3d"),
// NOTE: The opaque pass loads the color
// buffer as well as writing to it.
color_attachments: &[Some(
target.get_color_attachment(Operations { load, store: true }),
)],
color_attachments: &[Some(target.get_color_attachment(Operations {
load,
store: StoreOp::Store,
}))],
depth_stencil_attachment: Some(RenderPassDepthStencilAttachment {
view: &depth.view,
// NOTE: The opaque main pass loads the depth buffer and possibly overwrites it
Expand All @@ -102,10 +104,12 @@ impl ViewNode for MainOpaquePass3dNode {
camera_3d.depth_load_op.clone()
}
.into(),
store: true,
store: StoreOp::Store,
}),
stencil_ops: None,
}),
timestamp_writes: None,
occlusion_query_set: None,
});

if let Some(viewport) = camera.viewport.as_ref() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use bevy_render::{
render_phase::RenderPhase,
render_resource::{
Extent3d, LoadOp, Operations, RenderPassDepthStencilAttachment, RenderPassDescriptor,
StoreOp,
},
renderer::RenderContext,
view::{ViewDepthTexture, ViewTarget},
Expand Down Expand Up @@ -47,17 +48,19 @@ impl ViewNode for MainTransmissivePass3dNode {
// NOTE: The transmissive pass loads the color buffer as well as overwriting it where appropriate.
color_attachments: &[Some(target.get_color_attachment(Operations {
load: LoadOp::Load,
store: true,
store: StoreOp::Store,
}))],
depth_stencil_attachment: Some(RenderPassDepthStencilAttachment {
view: &depth.view,
// NOTE: The transmissive main pass loads the depth buffer and possibly overwrites it
depth_ops: Some(Operations {
load: LoadOp::Load,
store: true,
store: StoreOp::Store,
}),
stencil_ops: None,
}),
timestamp_writes: None,
occlusion_query_set: None,
};

// Run the transmissive pass, sorted back-to-front
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ use bevy_render::{
camera::ExtractedCamera,
render_graph::{NodeRunError, RenderGraphContext, ViewNode},
render_phase::RenderPhase,
render_resource::{LoadOp, Operations, RenderPassDepthStencilAttachment, RenderPassDescriptor},
render_resource::{
LoadOp, Operations, RenderPassDepthStencilAttachment, RenderPassDescriptor, StoreOp,
},
renderer::RenderContext,
view::{ViewDepthTexture, ViewTarget},
};
Expand Down Expand Up @@ -42,7 +44,7 @@ impl ViewNode for MainTransparentPass3dNode {
// NOTE: The transparent pass loads the color buffer as well as overwriting it where appropriate.
color_attachments: &[Some(target.get_color_attachment(Operations {
load: LoadOp::Load,
store: true,
store: StoreOp::Store,
}))],
depth_stencil_attachment: Some(RenderPassDepthStencilAttachment {
view: &depth.view,
Expand All @@ -54,10 +56,12 @@ impl ViewNode for MainTransparentPass3dNode {
// transparent ones.
depth_ops: Some(Operations {
load: LoadOp::Load,
store: true,
store: StoreOp::Store,
}),
stencil_ops: None,
}),
timestamp_writes: None,
occlusion_query_set: None,
});

if let Some(viewport) = camera.viewport.as_ref() {
Expand All @@ -77,9 +81,11 @@ impl ViewNode for MainTransparentPass3dNode {
label: Some("reset_viewport_pass_3d"),
color_attachments: &[Some(target.get_color_attachment(Operations {
load: LoadOp::Load,
store: true,
store: StoreOp::Store,
}))],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
};

render_context
Expand Down
4 changes: 3 additions & 1 deletion crates/bevy_core_pipeline/src/deferred/copy_lighting_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,12 @@ impl ViewNode for CopyDeferredLightingIdNode {
view: &deferred_lighting_id_depth_texture.texture.default_view,
depth_ops: Some(Operations {
load: LoadOp::Clear(0.0),
store: true,
store: StoreOp::Store,
}),
stencil_ops: None,
}),
timestamp_writes: None,
occlusion_query_set: None,
});

render_pass.set_render_pipeline(pipeline);
Expand Down
13 changes: 8 additions & 5 deletions crates/bevy_core_pipeline/src/deferred/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use bevy_ecs::prelude::*;
use bevy_ecs::query::QueryItem;
use bevy_render::render_graph::ViewNode;

use bevy_render::render_resource::StoreOp;
use bevy_render::{
camera::ExtractedCamera,
prelude::Color,
Expand Down Expand Up @@ -76,7 +77,7 @@ impl ViewNode for DeferredGBufferPrepassNode {
} else {
LoadOp::Clear(Color::BLACK.into())
},
store: true,
store: StoreOp::Store,
},
}),
);
Expand All @@ -92,7 +93,7 @@ impl ViewNode for DeferredGBufferPrepassNode {
} else {
LoadOp::Clear(Color::BLACK.into())
},
store: true,
store: StoreOp::Store,
},
},
));
Expand Down Expand Up @@ -122,7 +123,7 @@ impl ViewNode for DeferredGBufferPrepassNode {
load: LoadOp::Load,
#[cfg(not(all(feature = "webgl", target_arch = "wasm32")))]
load: LoadOp::Clear(Default::default()),
store: true,
store: StoreOp::Store,
},
}),
);
Expand All @@ -136,7 +137,7 @@ impl ViewNode for DeferredGBufferPrepassNode {
resolve_target: None,
ops: Operations {
load: LoadOp::Clear(Default::default()),
store: true,
store: StoreOp::Store,
},
}),
);
Expand Down Expand Up @@ -165,10 +166,12 @@ impl ViewNode for DeferredGBufferPrepassNode {
camera_3d.depth_load_op.clone()
}
.into(),
store: true,
store: StoreOp::Store,
}),
stencil_ops: None,
}),
timestamp_writes: None,
occlusion_query_set: None,
});

if let Some(viewport) = camera.viewport.as_ref() {
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_core_pipeline/src/fxaa/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ impl ViewNode for FxaaNode {
ops: Operations::default(),
})],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
};

let mut render_pass = render_context
Expand Down
4 changes: 3 additions & 1 deletion crates/bevy_core_pipeline/src/msaa_writeback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ impl Node for MsaaWritebackNode {
// the MSAA resolve step.
color_attachments: &[Some(target.get_color_attachment(Operations {
load: LoadOp::Clear(Default::default()),
store: true,
store: StoreOp::Store,
}))],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
};

let bind_group = render_context.render_device().create_bind_group(
Expand Down
9 changes: 6 additions & 3 deletions crates/bevy_core_pipeline/src/prepass/node.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use bevy_ecs::prelude::*;
use bevy_ecs::query::QueryItem;
use bevy_render::render_graph::ViewNode;
use bevy_render::render_resource::StoreOp;
use bevy_render::{
camera::ExtractedCamera,
prelude::Color,
Expand Down Expand Up @@ -59,7 +60,7 @@ impl ViewNode for PrepassNode {
resolve_target: None,
ops: Operations {
load: LoadOp::Clear(Color::BLACK.into()),
store: true,
store: StoreOp::Store,
},
}),
view_prepass_textures
Expand All @@ -73,7 +74,7 @@ impl ViewNode for PrepassNode {
// Blue channel doesn't matter, but set to 0.0 for possible faster clear
// https://gpuopen.com/performance/#clears
load: LoadOp::Clear(Color::BLACK.into()),
store: true,
store: StoreOp::Store,
},
}),
// Use None in place of Deferred attachments
Expand All @@ -95,10 +96,12 @@ impl ViewNode for PrepassNode {
view: &view_depth_texture.view,
depth_ops: Some(Operations {
load: LoadOp::Clear(0.0),
store: true,
store: StoreOp::Store,
}),
stencil_ops: None,
}),
timestamp_writes: None,
occlusion_query_set: None,
});
if let Some(viewport) = camera.viewport.as_ref() {
render_pass.set_camera_viewport(viewport);
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_core_pipeline/src/taa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ impl ViewNode for TemporalAntiAliasNode {
}),
],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
});
taa_pass.set_render_pipeline(taa_pipeline);
taa_pass.set_bind_group(0, &taa_bind_group, &[]);
Expand Down
6 changes: 4 additions & 2 deletions crates/bevy_core_pipeline/src/tonemapping/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use bevy_render::{
render_graph::{NodeRunError, RenderGraphContext, ViewNode},
render_resource::{
BindGroup, BindGroupEntries, BufferId, LoadOp, Operations, PipelineCache,
RenderPassColorAttachment, RenderPassDescriptor, SamplerDescriptor, TextureViewId,
RenderPassColorAttachment, RenderPassDescriptor, SamplerDescriptor, StoreOp, TextureViewId,
},
renderer::RenderContext,
texture::Image,
Expand Down Expand Up @@ -113,10 +113,12 @@ impl ViewNode for TonemappingNode {
resolve_target: None,
ops: Operations {
load: LoadOp::Clear(Default::default()), // TODO shouldn't need to be cleared
store: true,
store: StoreOp::Store,
},
})],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
};

let mut render_pass = render_context
Expand Down
6 changes: 4 additions & 2 deletions crates/bevy_core_pipeline/src/upscaling/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use bevy_render::{
render_graph::{NodeRunError, RenderGraphContext, ViewNode},
render_resource::{
BindGroup, BindGroupEntries, LoadOp, Operations, PipelineCache, RenderPassColorAttachment,
RenderPassDescriptor, SamplerDescriptor, TextureViewId,
RenderPassDescriptor, SamplerDescriptor, StoreOp, TextureViewId,
},
renderer::RenderContext,
view::ViewTarget,
Expand Down Expand Up @@ -78,10 +78,12 @@ impl ViewNode for UpscalingNode {
resolve_target: None,
ops: Operations {
load: color_attachment_load_op,
store: true,
store: StoreOp::Store,
},
})],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
};

let mut render_pass = render_context
Expand Down
Loading

0 comments on commit 70a592f

Please sign in to comment.