Skip to content

Commit f29ebee

Browse files
ygdrasil-ioPJB3005eliemichel
authored
upgrade to wgpu 24.0.0 (#455)
Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com> Co-authored-by: Elie Michel <elie.michel@exppad.com> Co-authored-by: Elie Michel <eliemichel@users.noreply.github.com>
1 parent a522b7a commit f29ebee

File tree

25 files changed

+1642
-1399
lines changed

25 files changed

+1642
-1399
lines changed

Cargo.lock

Lines changed: 245 additions & 195 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ resolver = "2"
2323
[workspace.dependencies.wgc]
2424
package = "wgpu-core"
2525
git = "https://github.com/gfx-rs/wgpu"
26-
tag = "v22.1.0"
26+
tag = "v24.0.0"
2727

2828
[workspace.dependencies.wgt]
2929
package = "wgpu-types"
3030
git = "https://github.com/gfx-rs/wgpu"
31-
tag = "v22.1.0"
31+
tag = "v24.0.0"
3232

3333
[workspace.dependencies.hal]
3434
package = "wgpu-hal"
3535
git = "https://github.com/gfx-rs/wgpu"
36-
tag = "v22.1.0"
36+
tag = "v24.0.0"
3737

3838
[workspace.dependencies.naga]
3939
package = "naga"
4040
git = "https://github.com/gfx-rs/wgpu"
41-
tag = "v22.1.0"
41+
tag = "v24.0.0"
4242

4343
[lib]
4444
crate-type = ["cdylib", "staticlib"]
@@ -134,9 +134,8 @@ hal = { workspace = true, features = ["renderdoc"] }
134134

135135
[target.'cfg(windows)'.dependencies]
136136
hal = { workspace = true, features = [
137-
"dxc_shader_compiler",
137+
"dx12",
138138
"renderdoc",
139-
"windows_rs",
140139
] }
141140

142141
[dependencies.wgt]
@@ -157,6 +156,10 @@ log = "0.4"
157156
thiserror = "1"
158157
parking_lot = "0.12"
159158
smallvec = "1"
159+
bitflags = "2"
160+
161+
# This is required to compile but not sure why because we are not targeting JS
162+
js-sys = "0.3.77"
160163

161164
[build-dependencies]
162165
bindgen = "0.70"

build.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ fn main() {
4141
.prepend_enum_name(false)
4242
.size_t_is_usize(true)
4343
.ignore_functions()
44-
.layout_tests(true);
44+
.layout_tests(true)
45+
.clang_macro_fallback();
4546

4647
for (old_name, new_name) in types_to_rename {
4748
let line = format!("pub type {old_name} = *const crate::{new_name};");

examples/capture/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ include_directories(${CMAKE_SOURCE_DIR}/../ffi/webgpu-headers)
1616
include_directories(${CMAKE_SOURCE_DIR}/framework)
1717

1818
if (WIN32)
19-
set(OS_LIBRARIES d3dcompiler ws2_32 userenv bcrypt ntdll opengl32)
19+
set(OS_LIBRARIES d3dcompiler ws2_32 userenv bcrypt ntdll opengl32 Propsys RuntimeObject)
2020
elseif(UNIX AND NOT APPLE)
2121
set(OS_LIBRARIES "-lm -ldl")
2222
elseif(APPLE)

examples/capture/main.c

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,27 @@ const size_t IMAGE_HEIGHT = 200;
1414
const size_t COPY_BYTES_PER_ROW_ALIGNMENT = 256;
1515

1616
static void handle_request_adapter(WGPURequestAdapterStatus status,
17-
WGPUAdapter adapter, char const *message,
18-
void *userdata) {
17+
WGPUAdapter adapter, WGPUStringView message,
18+
void *userdata1, void *userdata2) {
1919
UNUSED(status)
2020
UNUSED(message)
21-
*(WGPUAdapter *)userdata = adapter;
21+
UNUSED(userdata2)
22+
*(WGPUAdapter *)userdata1 = adapter;
2223
}
2324
static void handle_request_device(WGPURequestDeviceStatus status,
24-
WGPUDevice device, char const *message,
25-
void *userdata) {
25+
WGPUDevice device, WGPUStringView message,
26+
void *userdata1, void *userdata2) {
2627
UNUSED(status)
2728
UNUSED(message)
28-
*(WGPUDevice *)userdata = device;
29+
UNUSED(userdata2)
30+
*(WGPUDevice *)userdata1 = device;
2931
}
30-
static void handle_buffer_map(WGPUBufferMapAsyncStatus status, void *userdata) {
31-
UNUSED(userdata)
32+
static void handle_buffer_map(WGPUMapAsyncStatus status,
33+
WGPUStringView message,
34+
void *userdata1, void *userdata2) {
35+
UNUSED(message)
36+
UNUSED(userdata1)
37+
UNUSED(userdata2)
3238
printf(LOG_PREFIX " buffer_map status=%#.8x\n", status);
3339
}
3440

@@ -67,14 +73,21 @@ int main(int argc, char *argv[]) {
6773
assert(instance);
6874

6975
WGPUAdapter adapter = NULL;
70-
wgpuInstanceRequestAdapter(instance, NULL, handle_request_adapter,
71-
(void *)&adapter);
76+
wgpuInstanceRequestAdapter(instance, NULL,
77+
(const WGPURequestAdapterCallbackInfo){
78+
.callback = handle_request_adapter,
79+
.userdata1 = &adapter
80+
});
7281
assert(adapter);
7382

7483
WGPUDevice device = NULL;
75-
wgpuAdapterRequestDevice(adapter, NULL, handle_request_device,
76-
(void *)&device);
84+
wgpuAdapterRequestDevice(adapter, NULL,
85+
(const WGPURequestDeviceCallbackInfo){
86+
.callback = handle_request_device,
87+
.userdata1 = &device
88+
});
7789
assert(device);
90+
7891
WGPUQueue queue = wgpuDeviceGetQueue(device);
7992
assert(queue);
8093

@@ -86,7 +99,7 @@ int main(int argc, char *argv[]) {
8699

87100
WGPUBuffer output_buffer = wgpuDeviceCreateBuffer(
88101
device, &(const WGPUBufferDescriptor){
89-
.label = "output_buffer",
102+
.label = {"output_buffer", WGPU_STRLEN},
90103
.size = buffer_size,
91104
.usage = WGPUBufferUsage_MapRead | WGPUBufferUsage_CopyDst,
92105
.mappedAtCreation = false,
@@ -102,7 +115,7 @@ int main(int argc, char *argv[]) {
102115
WGPUTexture texture = wgpuDeviceCreateTexture(
103116
device,
104117
&(const WGPUTextureDescriptor){
105-
.label = "texture",
118+
.label = {"texture", WGPU_STRLEN},
106119
.size = texture_extent,
107120
.mipLevelCount = 1,
108121
.sampleCount = 1,
@@ -116,13 +129,13 @@ int main(int argc, char *argv[]) {
116129

117130
WGPUCommandEncoder command_encoder = wgpuDeviceCreateCommandEncoder(
118131
device, &(const WGPUCommandEncoderDescriptor){
119-
.label = "command_encoder",
132+
.label = {"command_encoder", WGPU_STRLEN},
120133
});
121134
assert(command_encoder);
122135

123136
WGPURenderPassEncoder render_pass_encoder = wgpuCommandEncoderBeginRenderPass(
124137
command_encoder, &(const WGPURenderPassDescriptor){
125-
.label = "rende_pass_encoder",
138+
.label = {"rende_pass_encoder", WGPU_STRLEN},
126139
.colorAttachmentCount = 1,
127140
.colorAttachments =
128141
(const WGPURenderPassColorAttachment[]){
@@ -148,16 +161,16 @@ int main(int argc, char *argv[]) {
148161

149162
wgpuCommandEncoderCopyTextureToBuffer(
150163
command_encoder,
151-
&(const WGPUImageCopyTexture){
164+
&(const WGPUTexelCopyTextureInfo){
152165
.texture = texture,
153166
.mipLevel = 0,
154167
.origin = (const WGPUOrigin3D){.x = 0, .y = 0, .z = 0},
155168
.aspect = WGPUTextureAspect_All,
156169
},
157-
&(const WGPUImageCopyBuffer){
170+
&(const WGPUTexelCopyBufferInfo){
158171
.buffer = output_buffer,
159172
.layout =
160-
(const WGPUTextureDataLayout){
173+
(const WGPUTexelCopyBufferLayout){
161174
.offset = 0,
162175
.bytesPerRow = buffer_dimensions.padded_bytes_per_row,
163176
.rowsPerImage = WGPU_COPY_STRIDE_UNDEFINED,
@@ -167,14 +180,16 @@ int main(int argc, char *argv[]) {
167180

168181
WGPUCommandBuffer command_buffer = wgpuCommandEncoderFinish(
169182
command_encoder, &(const WGPUCommandBufferDescriptor){
170-
.label = "command_buffer",
183+
.label = {"command_buffer", WGPU_STRLEN},
171184
});
172185
assert(command_buffer);
173186

174187
wgpuQueueSubmit(queue, 1, (const WGPUCommandBuffer[]){command_buffer});
175188

176189
wgpuBufferMapAsync(output_buffer, WGPUMapMode_Read, 0, buffer_size,
177-
handle_buffer_map, NULL);
190+
(const WGPUBufferMapCallbackInfo){
191+
.callback = handle_buffer_map
192+
});
178193
wgpuDevicePoll(device, true, NULL);
179194

180195
uint8_t *buf =

examples/compute/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ include_directories(${CMAKE_SOURCE_DIR}/../ffi/webgpu-headers)
1414
include_directories(${CMAKE_SOURCE_DIR}/framework)
1515

1616
if (WIN32)
17-
set(OS_LIBRARIES d3dcompiler ws2_32 userenv bcrypt ntdll opengl32)
17+
set(OS_LIBRARIES d3dcompiler ws2_32 userenv bcrypt ntdll opengl32 Propsys RuntimeObject)
1818
elseif(UNIX AND NOT APPLE)
1919
set(OS_LIBRARIES "-lm -ldl")
2020
elseif(APPLE)

examples/compute/main.c

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,26 @@
77
#define LOG_PREFIX "[compute]"
88

99
static void handle_request_adapter(WGPURequestAdapterStatus status,
10-
WGPUAdapter adapter, char const *message,
11-
void *userdata) {
10+
WGPUAdapter adapter, WGPUStringView message,
11+
void *userdata1, void *userdata2) {
1212
UNUSED(status)
1313
UNUSED(message)
14-
*(WGPUAdapter *)userdata = adapter;
14+
UNUSED(userdata2)
15+
*(WGPUAdapter *)userdata1 = adapter;
1516
}
1617
static void handle_request_device(WGPURequestDeviceStatus status,
17-
WGPUDevice device, char const *message,
18-
void *userdata) {
18+
WGPUDevice device, WGPUStringView message,
19+
void *userdata1, void *userdata2) {
1920
UNUSED(status)
2021
UNUSED(message)
21-
*(WGPUDevice *)userdata = device;
22+
UNUSED(userdata2)
23+
*(WGPUDevice *)userdata1 = device;
2224
}
23-
static void handle_buffer_map(WGPUBufferMapAsyncStatus status, void *userdata) {
24-
UNUSED(userdata)
25+
static void handle_buffer_map(WGPUMapAsyncStatus status,
26+
WGPUStringView message,
27+
void *userdata1, void *userdata2) {
28+
UNUSED(userdata1)
29+
UNUSED(userdata2)
2530
printf(LOG_PREFIX " buffer_map status=%#.8x\n", status);
2631
}
2732

@@ -38,13 +43,19 @@ int main(int argc, char *argv[]) {
3843
assert(instance);
3944

4045
WGPUAdapter adapter = NULL;
41-
wgpuInstanceRequestAdapter(instance, NULL, handle_request_adapter,
42-
(void *)&adapter);
46+
wgpuInstanceRequestAdapter(instance, NULL,
47+
(const WGPURequestAdapterCallbackInfo){
48+
.callback = handle_request_adapter,
49+
.userdata1 = &adapter
50+
});
4351
assert(adapter);
4452

4553
WGPUDevice device = NULL;
46-
wgpuAdapterRequestDevice(adapter, NULL, handle_request_device,
47-
(void *)&device);
54+
wgpuAdapterRequestDevice(adapter, NULL,
55+
(const WGPURequestDeviceCallbackInfo){
56+
.callback = handle_request_device,
57+
.userdata1 = &device
58+
});
4859
assert(device);
4960

5061
WGPUQueue queue = wgpuDeviceGetQueue(device);
@@ -56,7 +67,7 @@ int main(int argc, char *argv[]) {
5667

5768
WGPUBuffer staging_buffer = wgpuDeviceCreateBuffer(
5869
device, &(const WGPUBufferDescriptor){
59-
.label = "staging_buffer",
70+
.label = {"staging_buffer", WGPU_STRLEN},
6071
.usage = WGPUBufferUsage_MapRead | WGPUBufferUsage_CopyDst,
6172
.size = numbers_size,
6273
.mappedAtCreation = false,
@@ -65,7 +76,7 @@ int main(int argc, char *argv[]) {
6576

6677
WGPUBuffer storage_buffer = wgpuDeviceCreateBuffer(
6778
device, &(const WGPUBufferDescriptor){
68-
.label = "storage_buffer",
79+
.label = {"storage_buffer", WGPU_STRLEN},
6980
.usage = WGPUBufferUsage_Storage | WGPUBufferUsage_CopyDst |
7081
WGPUBufferUsage_CopySrc,
7182
.size = numbers_size,
@@ -75,11 +86,11 @@ int main(int argc, char *argv[]) {
7586

7687
WGPUComputePipeline compute_pipeline = wgpuDeviceCreateComputePipeline(
7788
device, &(const WGPUComputePipelineDescriptor){
78-
.label = "compute_pipeline",
89+
.label = {"compute_pipeline", WGPU_STRLEN},
7990
.compute =
8091
(const WGPUProgrammableStageDescriptor){
8192
.module = shader_module,
82-
.entryPoint = "main",
93+
.entryPoint = {"main", WGPU_STRLEN},
8394
},
8495
});
8596
assert(compute_pipeline);
@@ -90,7 +101,7 @@ int main(int argc, char *argv[]) {
90101

91102
WGPUBindGroup bind_group = wgpuDeviceCreateBindGroup(
92103
device, &(const WGPUBindGroupDescriptor){
93-
.label = "bind_group",
104+
.label = {"bind_group", WGPU_STRLEN},
94105
.layout = bind_group_layout,
95106
.entryCount = 1,
96107
.entries =
@@ -107,14 +118,14 @@ int main(int argc, char *argv[]) {
107118

108119
WGPUCommandEncoder command_encoder = wgpuDeviceCreateCommandEncoder(
109120
device, &(const WGPUCommandEncoderDescriptor){
110-
.label = "command_encoder",
121+
.label = {"command_encoder", WGPU_STRLEN},
111122
});
112123
assert(command_encoder);
113124

114125
WGPUComputePassEncoder compute_pass_encoder =
115126
wgpuCommandEncoderBeginComputePass(command_encoder,
116127
&(const WGPUComputePassDescriptor){
117-
.label = "compute_pass",
128+
.label = {"compute_pass", WGPU_STRLEN},
118129
});
119130
assert(compute_pass_encoder);
120131

@@ -131,15 +142,17 @@ int main(int argc, char *argv[]) {
131142

132143
WGPUCommandBuffer command_buffer = wgpuCommandEncoderFinish(
133144
command_encoder, &(const WGPUCommandBufferDescriptor){
134-
.label = "command_buffer",
145+
.label = {"command_buffer", WGPU_STRLEN},
135146
});
136147
assert(command_buffer);
137148

138149
wgpuQueueWriteBuffer(queue, storage_buffer, 0, &numbers, numbers_size);
139150
wgpuQueueSubmit(queue, 1, &command_buffer);
140151

141152
wgpuBufferMapAsync(staging_buffer, WGPUMapMode_Read, 0, numbers_size,
142-
handle_buffer_map, NULL);
153+
(const WGPUBufferMapCallbackInfo){
154+
.callback = handle_buffer_map
155+
});
143156
wgpuDevicePoll(device, true, NULL);
144157

145158
uint32_t *buf =

examples/enumerate_adapters/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ include_directories(${CMAKE_SOURCE_DIR}/../ffi/webgpu-headers)
1414
include_directories(${CMAKE_SOURCE_DIR}/framework)
1515

1616
if (WIN32)
17-
set(OS_LIBRARIES d3dcompiler ws2_32 userenv bcrypt ntdll opengl32)
17+
set(OS_LIBRARIES d3dcompiler ws2_32 userenv bcrypt ntdll opengl32 Propsys RuntimeObject)
1818
elseif(UNIX AND NOT APPLE)
1919
set(OS_LIBRARIES "-lm -ldl")
2020
elseif(APPLE)

examples/enumerate_adapters/main.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,17 @@ int main(int argc, char *argv[]) {
2626
wgpuAdapterGetInfo(adapter, &info);
2727
printf("WGPUAdapter: %d\n", i);
2828
printf("WGPUAdapterInfo {\n"
29-
"\tvendor: %s\n"
30-
"\tarchitecture: %s\n"
31-
"\tdevice: %s\n"
32-
"\tdescription: %s\n"
29+
"\tvendor: %.*s\n"
30+
"\tarchitecture: %.*s\n"
31+
"\tdevice: %.*s\n"
32+
"\tdescription: %.*s\n"
3333
"\tbackendType: %#.8x\n"
3434
"\tadapterType: %#.8x\n"
3535
"\tvendorID: %" PRIu32 "\n"
3636
"\tdeviceID: %" PRIu32 "\n"
3737
"}\n",
38-
info.vendor, info.architecture, info.device, info.description,
38+
(int) info.vendor.length, info.vendor.data, (int) info.architecture.length, info.architecture.data,
39+
(int) info.device.length, info.device.data, (int) info.description.length, info.description.data,
3940
info.backendType, info.adapterType, info.vendorID, info.deviceID);
4041

4142
wgpuAdapterInfoFreeMembers(info);

0 commit comments

Comments
 (0)