Skip to content

Commit

Permalink
Update wgpu to v22.1.0 (#402)
Browse files Browse the repository at this point in the history
* Update wgpu to v0.20.0

* Update wgpu to v22.1.0

* Cargo.toml: use git `tag` instead of `rev`+`version`
  • Loading branch information
rajveermalviya authored Aug 26, 2024
1 parent bcb0348 commit 2202274
Show file tree
Hide file tree
Showing 9 changed files with 990 additions and 733 deletions.
541 changes: 286 additions & 255 deletions Cargo.lock

Large diffs are not rendered by default.

51 changes: 37 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,22 @@ resolver = "2"
[workspace.dependencies.wgc]
package = "wgpu-core"
git = "https://github.com/gfx-rs/wgpu"
rev = "87576b72b37c6b78b41104eb25fc31893af94092"
version = "0.19"
tag = "v22.1.0"

[workspace.dependencies.wgt]
package = "wgpu-types"
git = "https://github.com/gfx-rs/wgpu"
rev = "87576b72b37c6b78b41104eb25fc31893af94092"
version = "0.19"
tag = "v22.1.0"

[workspace.dependencies.hal]
package = "wgpu-hal"
git = "https://github.com/gfx-rs/wgpu"
tag = "v22.1.0"

[workspace.dependencies.naga]
package = "naga"
git = "https://github.com/gfx-rs/wgpu"
rev = "87576b72b37c6b78b41104eb25fc31893af94092"
version = "0.19"
tag = "v22.1.0"

[lib]
crate-type = ["cdylib", "staticlib"]
Expand All @@ -47,7 +49,7 @@ default = ["wgsl", "spirv", "glsl", "dx12", "metal"]
#! ### Backends
# --------------------------------------------------------------------
#! ⚠️ WIP: Not all backends can be manually configured today.
#! On Windows & Linux the Vulkan & GLES backends are always enabled.
#! On Windows, Linux & Android the Vulkan & GLES backends are always enabled.
#! See [#3514](https://github.com/gfx-rs/wgpu/issues/3514) for more details.

## Enables the DX12 backend on Windows.
Expand All @@ -62,14 +64,18 @@ angle = ["wgc/gles"]
## Enables the Vulkan backend on macOS & iOS.
vulkan-portability = ["wgc/vulkan"]

#! **Note:** In the documentation, if you see that an item depends on a backend,
#! it means that the item is only available when that backend is enabled _and_ the backend
#! is supported on the current platform.

#! ### Shading language support
# --------------------------------------------------------------------

## Enable accepting SPIR-V shaders as input.
spirv = ["naga/spv-in"]
spirv = ["naga/spv-in", "wgc/spirv"]

## Enable accepting GLSL shaders as input.
glsl = ["naga/glsl-in"]
glsl = ["naga/glsl-in", "wgc/glsl"]

## Enable accepting WGSL shaders as input.
wgsl = ["wgc/wgsl"]
Expand All @@ -85,9 +91,12 @@ strict_asserts = ["wgc/strict_asserts", "wgt/strict_asserts"]
## Log all API entry points at info instead of trace level.
api_log_info = ["wgc/api_log_info"]

## Allow writing of trace capture files.
## See [`Adapter::request_device`].
trace = ["serde", "wgc/trace"]
## Enables serialization via `serde` on common wgpu types.
serde = ["dep:serde", "wgc/serde"]

# Uncomment once upstream adds it again — https://github.com/gfx-rs/wgpu/issues/5974
# ## Allow writing of trace capture files. See [`Adapter::request_device`].
# trace = ["serde", "wgc/trace"]

## Allow deserializing of trace capture files that were written with the `trace` feature.
## To replay a trace file use the [wgpu player](https://github.com/gfx-rs/wgpu/tree/trunk/player).
Expand All @@ -107,8 +116,8 @@ workspace = true
workspace = true
features = ["gles"]

# We want the wgpu-core Vulkan backend on Unix (but not emscripten, macOS, iOS) and Windows.
[target.'cfg(any(windows, all(unix, not(target_os = "emscripten"), not(target_os = "ios"), not(target_os = "macos"))))'.dependencies.wgc]
# We want the wgpu-core Vulkan backend on Unix (but not macOS, iOS) and Windows.
[target.'cfg(any(windows, all(unix, not(target_os = "ios"), not(target_os = "macos"))))'.dependencies.wgc]
workspace = true
features = ["vulkan"]

Expand All @@ -117,11 +126,25 @@ features = ["vulkan"]
workspace = true
features = ["gles"]

[dependencies.hal]
workspace = true

[target.'cfg(all(unix, not(target_os = "ios"), not(target_os = "macos")))'.dependencies]
hal = { workspace = true, features = ["renderdoc"] }

[target.'cfg(windows)'.dependencies]
hal = { workspace = true, features = [
"dxc_shader_compiler",
"renderdoc",
"windows_rs",
] }

[dependencies.wgt]
workspace = true

[dependencies.naga]
workspace = true
optional = true

[dependencies.serde]
version = "1"
Expand Down
2 changes: 1 addition & 1 deletion examples/capture/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ int main(int argc, char *argv[]) {
assert(render_pass_encoder);

wgpuRenderPassEncoderEnd(render_pass_encoder);
wgpuRenderPassEncoderRelease(render_pass_encoder);

wgpuCommandEncoderCopyTextureToBuffer(
command_encoder,
Expand Down Expand Up @@ -186,7 +187,6 @@ int main(int argc, char *argv[]) {

wgpuBufferUnmap(output_buffer);
wgpuCommandBufferRelease(command_buffer);
wgpuRenderPassEncoderRelease(render_pass_encoder);
wgpuCommandEncoderRelease(command_encoder);
wgpuTextureViewRelease(texture_view);
wgpuTextureRelease(texture);
Expand Down
2 changes: 1 addition & 1 deletion examples/compute/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ int main(int argc, char *argv[]) {
wgpuComputePassEncoderDispatchWorkgroups(compute_pass_encoder, numbers_length,
1, 1);
wgpuComputePassEncoderEnd(compute_pass_encoder);
wgpuComputePassEncoderRelease(compute_pass_encoder);

wgpuCommandEncoderCopyBufferToBuffer(command_encoder, storage_buffer, 0,
staging_buffer, 0, numbers_size);
Expand All @@ -149,7 +150,6 @@ int main(int argc, char *argv[]) {

wgpuBufferUnmap(staging_buffer);
wgpuCommandBufferRelease(command_buffer);
wgpuComputePassEncoderRelease(compute_pass_encoder);
wgpuCommandEncoderRelease(command_encoder);
wgpuBindGroupRelease(bind_group);
wgpuBindGroupLayoutRelease(bind_group_layout);
Expand Down
45 changes: 23 additions & 22 deletions examples/texture_arrays/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,27 +689,28 @@ int main(int argc, char *argv[]) {

WGPURenderPassEncoder render_pass_encoder =
wgpuCommandEncoderBeginRenderPass(
command_encoder, &(const WGPURenderPassDescriptor){
.label = "render_pass_encoder",
.colorAttachmentCount = 1,
.colorAttachments =
(const WGPURenderPassColorAttachment[]){
(const WGPURenderPassColorAttachment){
.view = frame,
.loadOp = WGPULoadOp_Clear,
.storeOp = WGPUStoreOp_Store,
.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED,
.clearValue =
(const WGPUColor){
.r = 0.0,
.g = 0.0,
.b = 0.0,
.a = 1.0,
},
},
},

});
command_encoder,
&(const WGPURenderPassDescriptor){
.label = "render_pass_encoder",
.colorAttachmentCount = 1,
.colorAttachments =
(const WGPURenderPassColorAttachment[]){
(const WGPURenderPassColorAttachment){
.view = frame,
.loadOp = WGPULoadOp_Clear,
.storeOp = WGPUStoreOp_Store,
.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED,
.clearValue =
(const WGPUColor){
.r = 0.0,
.g = 0.0,
.b = 0.0,
.a = 1.0,
},
},
},

});
assert(render_pass_encoder);

wgpuRenderPassEncoderSetPipeline(render_pass_encoder, pipeline);
Expand All @@ -730,6 +731,7 @@ int main(int argc, char *argv[]) {
wgpuRenderPassEncoderDrawIndexed(render_pass_encoder, 12, 1, 0, 0, 0);
}
wgpuRenderPassEncoderEnd(render_pass_encoder);
wgpuRenderPassEncoderRelease(render_pass_encoder);

WGPUCommandBuffer command_buffer = wgpuCommandEncoderFinish(
command_encoder, &(const WGPUCommandBufferDescriptor){
Expand All @@ -741,7 +743,6 @@ int main(int argc, char *argv[]) {
wgpuSurfacePresent(demo.surface);

wgpuCommandBufferRelease(command_buffer);
wgpuRenderPassEncoderRelease(render_pass_encoder);
wgpuCommandEncoderRelease(command_encoder);
wgpuTextureViewRelease(frame);
wgpuTextureRelease(surface_texture.texture);
Expand Down
43 changes: 22 additions & 21 deletions examples/triangle/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,31 +308,33 @@ int main(int argc, char *argv[]) {

WGPURenderPassEncoder render_pass_encoder =
wgpuCommandEncoderBeginRenderPass(
command_encoder, &(const WGPURenderPassDescriptor){
.label = "render_pass_encoder",
.colorAttachmentCount = 1,
.colorAttachments =
(const WGPURenderPassColorAttachment[]){
(const WGPURenderPassColorAttachment){
.view = frame,
.loadOp = WGPULoadOp_Clear,
.storeOp = WGPUStoreOp_Store,
.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED,
.clearValue =
(const WGPUColor){
.r = 0.0,
.g = 1.0,
.b = 0.0,
.a = 1.0,
},
},
},
});
command_encoder,
&(const WGPURenderPassDescriptor){
.label = "render_pass_encoder",
.colorAttachmentCount = 1,
.colorAttachments =
(const WGPURenderPassColorAttachment[]){
(const WGPURenderPassColorAttachment){
.view = frame,
.loadOp = WGPULoadOp_Clear,
.storeOp = WGPUStoreOp_Store,
.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED,
.clearValue =
(const WGPUColor){
.r = 0.0,
.g = 1.0,
.b = 0.0,
.a = 1.0,
},
},
},
});
assert(render_pass_encoder);

wgpuRenderPassEncoderSetPipeline(render_pass_encoder, render_pipeline);
wgpuRenderPassEncoderDraw(render_pass_encoder, 3, 1, 0, 0);
wgpuRenderPassEncoderEnd(render_pass_encoder);
wgpuRenderPassEncoderRelease(render_pass_encoder);

WGPUCommandBuffer command_buffer = wgpuCommandEncoderFinish(
command_encoder, &(const WGPUCommandBufferDescriptor){
Expand All @@ -344,7 +346,6 @@ int main(int argc, char *argv[]) {
wgpuSurfacePresent(demo.surface);

wgpuCommandBufferRelease(command_buffer);
wgpuRenderPassEncoderRelease(render_pass_encoder);
wgpuCommandEncoderRelease(command_encoder);
wgpuTextureViewRelease(frame);
wgpuTextureRelease(surface_texture.texture);
Expand Down
15 changes: 7 additions & 8 deletions ffi/wgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,13 @@ typedef enum WGPUNativeFeature {
// WGPUNativeFeature_SpirvShaderPassthrough = 0x00030017,
// WGPUNativeFeature_Multiview = 0x00030018,
WGPUNativeFeature_VertexAttribute64bit = 0x00030019,
WGPUNativeFeature_ShaderUnusedVertexOutput = 0x0003001A,
WGPUNativeFeature_TextureFormatNv12 = 0x0003001B,
WGPUNativeFeature_RayTracingAccelerationStructure = 0x0003001C,
WGPUNativeFeature_RayQuery = 0x0003001D,
WGPUNativeFeature_ShaderF64 = 0x0003001E,
WGPUNativeFeature_ShaderI16 = 0x0003001F,
WGPUNativeFeature_ShaderPrimitiveIndex = 0x00030020,
WGPUNativeFeature_ShaderEarlyDepthTest = 0x00030021,
WGPUNativeFeature_TextureFormatNv12 = 0x0003001A,
WGPUNativeFeature_RayTracingAccelerationStructure = 0x0003001B,
WGPUNativeFeature_RayQuery = 0x0003001C,
WGPUNativeFeature_ShaderF64 = 0x0003001D,
WGPUNativeFeature_ShaderI16 = 0x0003001E,
WGPUNativeFeature_ShaderPrimitiveIndex = 0x0003001F,
WGPUNativeFeature_ShaderEarlyDepthTest = 0x00030020,
WGPUNativeFeature_Force32 = 0x7FFFFFFF
} WGPUNativeFeature;

Expand Down
11 changes: 5 additions & 6 deletions src/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ pub(crate) fn map_device_descriptor<'a>(
},
None => base_limits,
},
// TODO(wgpu.h)
memory_hints: Default::default(),
},
match extras {
Some(extras) => extras.tracePath,
Expand Down Expand Up @@ -567,8 +569,8 @@ pub enum ShaderParseError {
#[error(transparent)]
Spirv(#[from] naga::front::spv::Error),
#[cfg(feature = "glsl")]
#[error("GLSL Parse Error: {0:?}")]
Glsl(Vec<naga::front::glsl::Error>),
#[error(transparent)]
Glsl(#[from] naga::front::glsl::ParseErrors),
}

#[inline]
Expand Down Expand Up @@ -1183,9 +1185,6 @@ pub fn features_to_native(features: wgt::Features) -> Vec<native::WGPUFeatureNam
if features.contains(wgt::Features::VERTEX_ATTRIBUTE_64BIT) {
temp.push(native::WGPUNativeFeature_VertexAttribute64bit);
}
if features.contains(wgt::Features::SHADER_UNUSED_VERTEX_OUTPUT) {
temp.push(native::WGPUNativeFeature_ShaderUnusedVertexOutput);
}
if features.contains(wgt::Features::TEXTURE_FORMAT_NV12) {
temp.push(native::WGPUNativeFeature_TextureFormatNv12);
}
Expand Down Expand Up @@ -1257,7 +1256,6 @@ pub fn map_feature(feature: native::WGPUFeatureName) -> Option<wgt::Features> {
// native::WGPUNativeFeature_SpirvShaderPassthrough => Some(Features::SPIRV_SHADER_PASSTHROUGH),
// native::WGPUNativeFeature_Multiview => Some(Features::MULTIVIEW),
native::WGPUNativeFeature_VertexAttribute64bit => Some(Features::VERTEX_ATTRIBUTE_64BIT),
native::WGPUNativeFeature_ShaderUnusedVertexOutput => Some(Features::SHADER_UNUSED_VERTEX_OUTPUT),
native::WGPUNativeFeature_TextureFormatNv12 => Some(Features::TEXTURE_FORMAT_NV12),
native::WGPUNativeFeature_RayTracingAccelerationStructure => Some(Features::RAY_TRACING_ACCELERATION_STRUCTURE),
native::WGPUNativeFeature_RayQuery => Some(Features::RAY_QUERY),
Expand Down Expand Up @@ -1646,6 +1644,7 @@ pub unsafe fn map_surface(
panic!("Error: Unsupported Surface");
}

#[inline]
pub fn map_surface_configuration(
config: &native::WGPUSurfaceConfiguration,
extras: Option<&native::WGPUSurfaceConfigurationExtras>,
Expand Down
Loading

0 comments on commit 2202274

Please sign in to comment.