Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to wgpu 24.0.0 #455

Open
wants to merge 53 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
2baea09
Update library to latest webgpu-native headers
PJB3005 Sep 19, 2024
0c60733
Update C examples to new headers
PJB3005 Sep 19, 2024
980c2ff
Fix WGPUBufferMapAsyncStatus tomfoolery
PJB3005 Sep 19, 2024
8f34e48
Fix macOS typos in examples
PJB3005 Sep 19, 2024
b36e558
Update headers again
PJB3005 Sep 27, 2024
a4626db
Update wgpu.h to match new flag scheme
PJB3005 Sep 27, 2024
a256544
Update headers again, WGPUStringView
PJB3005 Oct 2, 2024
8947cf2
Only specify major version for bitflags dependency
PJB3005 Oct 2, 2024
fe965c8
Remove redundant unsafe block
PJB3005 Oct 2, 2024
f5040ed
Start upgrading, try to use Box<ComputePass>
eliemichel Oct 13, 2024
2afb356
Switch to *mut for ComputePass and RenderPass
eliemichel Oct 13, 2024
2293063
Adapt C examples
eliemichel Oct 13, 2024
eaa44b1
Clean up dependencies to point to wgpu repo
eliemichel Oct 13, 2024
23d8907
Format code
eliemichel Oct 13, 2024
482bc24
Add wgpuGetInstanceFeatures stuff
PJB3005 Oct 19, 2024
8f80a2c
I forgot to cargo fmt again
PJB3005 Oct 19, 2024
77dfe52
Implement "NotUsed" bind group entry types
PJB3005 Oct 19, 2024
3c3c292
Update to new undefined enums
PJB3005 Oct 20, 2024
aa6b617
Update for other enum changes
PJB3005 Oct 20, 2024
2cb389b
Update for new header features
PJB3005 Oct 20, 2024
b6b6903
Fix getFeatures chained struct handling.
PJB3005 Oct 20, 2024
4d49d7f
Flatten limits structures
PJB3005 Oct 20, 2024
24ec452
Merge remote-tracking branch 'upstream/trunk' into 24-09-19-update-he…
PJB3005 Oct 20, 2024
620405f
Some day I will learn to run cargo fmt and check compile before merges
PJB3005 Oct 20, 2024
ab33119
Merge branch 'trunk' into eliemichel/2024-10-14-upgrade-wgpu
eliemichel Oct 20, 2024
2d1888b
Upgrade timestamp functions
eliemichel Oct 20, 2024
e81dd63
Fix push_constant example
eliemichel Oct 20, 2024
76df580
Upgrade to what is almost wgpu 23.0.0
eliemichel Oct 27, 2024
ecc0266
Upgrade to official v23.0.0
eliemichel Nov 12, 2024
e36359f
Upgrade to latest webgpu.h
eliemichel Nov 12, 2024
6eb8945
Add missing unimplemented symbols
eliemichel Nov 15, 2024
cae717c
Update wgpu dependencies to v24 and multiple crate versions
ygdrasil-io Jan 24, 2025
5ff04d1
Add handling for R64Uint texture format in conversion logic
ygdrasil-io Jan 24, 2025
f8c1945
Handle unknown SurfaceStatus in texture status mapping
ygdrasil-io Jan 24, 2025
b5136f8
Update shader bound checks to runtime checks
ygdrasil-io Jan 24, 2025
ab9338b
Add usage mapping to TextureViewDescriptor construction
ygdrasil-io Jan 24, 2025
6a7cd2c
Remove unused texture view usage check and TODO comment
ygdrasil-io Jan 24, 2025
345e112
Refactor to remove unused `texture_usage` variable.
ygdrasil-io Jan 24, 2025
8e8de3c
Update error variant for surface capabilities retrieval
ygdrasil-io Jan 24, 2025
69aabec
Update ShaderModuleDescriptor to use runtime_checks field
ygdrasil-io Jan 24, 2025
0021838
Refactor texture copy types and update experimental features.
ygdrasil-io Jan 24, 2025
8e70d82
Remove redundant return statement in NULL_FUTURE usage
ygdrasil-io Jan 24, 2025
ee635ae
Refactor load/store op mapping and enhance DX12 compiler handling
ygdrasil-io Jan 24, 2025
e4cb7b5
Fix DXC path assignment and update backend options structure
ygdrasil-io Jan 24, 2025
90d7ce2
Refactor callback and closure handling for clarity
ygdrasil-io Jan 24, 2025
da90331
Remove redundant return statements for NULL_FUTURE
ygdrasil-io Jan 25, 2025
452b21e
Refactor surface handling logic in texture release.
ygdrasil-io Jan 25, 2025
61c9e75
Merge remote-tracking branch 'origin-real/trunk' into feature/upgrade…
ygdrasil-io Jan 25, 2025
2411bb8
Fix type mismatch in wgpuRenderBundleEncoderSetPushConstants
ygdrasil-io Jan 25, 2025
9ab239b
Run cargo fmt
ygdrasil-io Jan 25, 2025
70a8705
Fix incorrect initialization and state updates for command buffers
ygdrasil-io Jan 26, 2025
df33227
Remove `map_load_op_and_color` and update load operation mapping.
ygdrasil-io Jan 26, 2025
4fbdf65
Merge branch 'trunk' into feature/upgrade-to-wgpu-24.0.0
ygdrasil-io Jan 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
440 changes: 245 additions & 195 deletions Cargo.lock

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@ resolver = "2"
[workspace.dependencies.wgc]
package = "wgpu-core"
git = "https://github.com/gfx-rs/wgpu"
tag = "v22.1.0"
tag = "v24.0.0"

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

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

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

[lib]
crate-type = ["cdylib", "staticlib"]
Expand Down Expand Up @@ -134,9 +134,8 @@ hal = { workspace = true, features = ["renderdoc"] }

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

[dependencies.wgt]
Expand All @@ -157,6 +156,10 @@ log = "0.4"
thiserror = "1"
parking_lot = "0.12"
smallvec = "1"
bitflags = "2"

# This is required to compile but not sure why because we are not targeting JS
js-sys = "0.3.77"

[build-dependencies]
bindgen = "0.70"
3 changes: 2 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ fn main() {
.prepend_enum_name(false)
.size_t_is_usize(true)
.ignore_functions()
.layout_tests(true);
.layout_tests(true)
.clang_macro_fallback();

for (old_name, new_name) in types_to_rename {
let line = format!("pub type {old_name} = *const crate::{new_name};");
Expand Down
2 changes: 1 addition & 1 deletion examples/capture/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ include_directories(${CMAKE_SOURCE_DIR}/../ffi/webgpu-headers)
include_directories(${CMAKE_SOURCE_DIR}/framework)

if (WIN32)
set(OS_LIBRARIES d3dcompiler ws2_32 userenv bcrypt ntdll opengl32)
set(OS_LIBRARIES d3dcompiler ws2_32 userenv bcrypt ntdll opengl32 Propsys RuntimeObject)
elseif(UNIX AND NOT APPLE)
set(OS_LIBRARIES "-lm -ldl")
elseif(APPLE)
Expand Down
57 changes: 36 additions & 21 deletions examples/capture/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,27 @@ const size_t IMAGE_HEIGHT = 200;
const size_t COPY_BYTES_PER_ROW_ALIGNMENT = 256;

static void handle_request_adapter(WGPURequestAdapterStatus status,
WGPUAdapter adapter, char const *message,
void *userdata) {
WGPUAdapter adapter, WGPUStringView message,
void *userdata1, void *userdata2) {
UNUSED(status)
UNUSED(message)
*(WGPUAdapter *)userdata = adapter;
UNUSED(userdata2)
*(WGPUAdapter *)userdata1 = adapter;
}
static void handle_request_device(WGPURequestDeviceStatus status,
WGPUDevice device, char const *message,
void *userdata) {
WGPUDevice device, WGPUStringView message,
void *userdata1, void *userdata2) {
UNUSED(status)
UNUSED(message)
*(WGPUDevice *)userdata = device;
UNUSED(userdata2)
*(WGPUDevice *)userdata1 = device;
}
static void handle_buffer_map(WGPUBufferMapAsyncStatus status, void *userdata) {
UNUSED(userdata)
static void handle_buffer_map(WGPUMapAsyncStatus status,
WGPUStringView message,
void *userdata1, void *userdata2) {
UNUSED(message)
UNUSED(userdata1)
UNUSED(userdata2)
printf(LOG_PREFIX " buffer_map status=%#.8x\n", status);
}

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

WGPUAdapter adapter = NULL;
wgpuInstanceRequestAdapter(instance, NULL, handle_request_adapter,
(void *)&adapter);
wgpuInstanceRequestAdapter(instance, NULL,
(const WGPURequestAdapterCallbackInfo){
.callback = handle_request_adapter,
.userdata1 = &adapter
});
assert(adapter);

WGPUDevice device = NULL;
wgpuAdapterRequestDevice(adapter, NULL, handle_request_device,
(void *)&device);
wgpuAdapterRequestDevice(adapter, NULL,
(const WGPURequestDeviceCallbackInfo){
.callback = handle_request_device,
.userdata1 = &device
});
assert(device);

WGPUQueue queue = wgpuDeviceGetQueue(device);
assert(queue);

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

WGPUBuffer output_buffer = wgpuDeviceCreateBuffer(
device, &(const WGPUBufferDescriptor){
.label = "output_buffer",
.label = {"output_buffer", WGPU_STRLEN},
.size = buffer_size,
.usage = WGPUBufferUsage_MapRead | WGPUBufferUsage_CopyDst,
.mappedAtCreation = false,
Expand All @@ -102,7 +115,7 @@ int main(int argc, char *argv[]) {
WGPUTexture texture = wgpuDeviceCreateTexture(
device,
&(const WGPUTextureDescriptor){
.label = "texture",
.label = {"texture", WGPU_STRLEN},
.size = texture_extent,
.mipLevelCount = 1,
.sampleCount = 1,
Expand All @@ -116,13 +129,13 @@ int main(int argc, char *argv[]) {

WGPUCommandEncoder command_encoder = wgpuDeviceCreateCommandEncoder(
device, &(const WGPUCommandEncoderDescriptor){
.label = "command_encoder",
.label = {"command_encoder", WGPU_STRLEN},
});
assert(command_encoder);

WGPURenderPassEncoder render_pass_encoder = wgpuCommandEncoderBeginRenderPass(
command_encoder, &(const WGPURenderPassDescriptor){
.label = "rende_pass_encoder",
.label = {"rende_pass_encoder", WGPU_STRLEN},
.colorAttachmentCount = 1,
.colorAttachments =
(const WGPURenderPassColorAttachment[]){
Expand All @@ -148,16 +161,16 @@ int main(int argc, char *argv[]) {

wgpuCommandEncoderCopyTextureToBuffer(
command_encoder,
&(const WGPUImageCopyTexture){
&(const WGPUTexelCopyTextureInfo){
.texture = texture,
.mipLevel = 0,
.origin = (const WGPUOrigin3D){.x = 0, .y = 0, .z = 0},
.aspect = WGPUTextureAspect_All,
},
&(const WGPUImageCopyBuffer){
&(const WGPUTexelCopyBufferInfo){
.buffer = output_buffer,
.layout =
(const WGPUTextureDataLayout){
(const WGPUTexelCopyBufferLayout){
.offset = 0,
.bytesPerRow = buffer_dimensions.padded_bytes_per_row,
.rowsPerImage = WGPU_COPY_STRIDE_UNDEFINED,
Expand All @@ -167,14 +180,16 @@ int main(int argc, char *argv[]) {

WGPUCommandBuffer command_buffer = wgpuCommandEncoderFinish(
command_encoder, &(const WGPUCommandBufferDescriptor){
.label = "command_buffer",
.label = {"command_buffer", WGPU_STRLEN},
});
assert(command_buffer);

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

wgpuBufferMapAsync(output_buffer, WGPUMapMode_Read, 0, buffer_size,
handle_buffer_map, NULL);
(const WGPUBufferMapCallbackInfo){
.callback = handle_buffer_map
});
wgpuDevicePoll(device, true, NULL);

uint8_t *buf =
Expand Down
2 changes: 1 addition & 1 deletion examples/compute/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ include_directories(${CMAKE_SOURCE_DIR}/../ffi/webgpu-headers)
include_directories(${CMAKE_SOURCE_DIR}/framework)

if (WIN32)
set(OS_LIBRARIES d3dcompiler ws2_32 userenv bcrypt ntdll opengl32)
set(OS_LIBRARIES d3dcompiler ws2_32 userenv bcrypt ntdll opengl32 Propsys RuntimeObject)
elseif(UNIX AND NOT APPLE)
set(OS_LIBRARIES "-lm -ldl")
elseif(APPLE)
Expand Down
55 changes: 34 additions & 21 deletions examples/compute/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,26 @@
#define LOG_PREFIX "[compute]"

static void handle_request_adapter(WGPURequestAdapterStatus status,
WGPUAdapter adapter, char const *message,
void *userdata) {
WGPUAdapter adapter, WGPUStringView message,
void *userdata1, void *userdata2) {
UNUSED(status)
UNUSED(message)
*(WGPUAdapter *)userdata = adapter;
UNUSED(userdata2)
*(WGPUAdapter *)userdata1 = adapter;
}
static void handle_request_device(WGPURequestDeviceStatus status,
WGPUDevice device, char const *message,
void *userdata) {
WGPUDevice device, WGPUStringView message,
void *userdata1, void *userdata2) {
UNUSED(status)
UNUSED(message)
*(WGPUDevice *)userdata = device;
UNUSED(userdata2)
*(WGPUDevice *)userdata1 = device;
}
static void handle_buffer_map(WGPUBufferMapAsyncStatus status, void *userdata) {
UNUSED(userdata)
static void handle_buffer_map(WGPUMapAsyncStatus status,
WGPUStringView message,
void *userdata1, void *userdata2) {
UNUSED(userdata1)
UNUSED(userdata2)
printf(LOG_PREFIX " buffer_map status=%#.8x\n", status);
}

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

WGPUAdapter adapter = NULL;
wgpuInstanceRequestAdapter(instance, NULL, handle_request_adapter,
(void *)&adapter);
wgpuInstanceRequestAdapter(instance, NULL,
(const WGPURequestAdapterCallbackInfo){
.callback = handle_request_adapter,
.userdata1 = &adapter
});
assert(adapter);

WGPUDevice device = NULL;
wgpuAdapterRequestDevice(adapter, NULL, handle_request_device,
(void *)&device);
wgpuAdapterRequestDevice(adapter, NULL,
(const WGPURequestDeviceCallbackInfo){
.callback = handle_request_device,
.userdata1 = &device
});
assert(device);

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

WGPUBuffer staging_buffer = wgpuDeviceCreateBuffer(
device, &(const WGPUBufferDescriptor){
.label = "staging_buffer",
.label = {"staging_buffer", WGPU_STRLEN},
.usage = WGPUBufferUsage_MapRead | WGPUBufferUsage_CopyDst,
.size = numbers_size,
.mappedAtCreation = false,
Expand All @@ -65,7 +76,7 @@ int main(int argc, char *argv[]) {

WGPUBuffer storage_buffer = wgpuDeviceCreateBuffer(
device, &(const WGPUBufferDescriptor){
.label = "storage_buffer",
.label = {"storage_buffer", WGPU_STRLEN},
.usage = WGPUBufferUsage_Storage | WGPUBufferUsage_CopyDst |
WGPUBufferUsage_CopySrc,
.size = numbers_size,
Expand All @@ -75,11 +86,11 @@ int main(int argc, char *argv[]) {

WGPUComputePipeline compute_pipeline = wgpuDeviceCreateComputePipeline(
device, &(const WGPUComputePipelineDescriptor){
.label = "compute_pipeline",
.label = {"compute_pipeline", WGPU_STRLEN},
.compute =
(const WGPUProgrammableStageDescriptor){
.module = shader_module,
.entryPoint = "main",
.entryPoint = {"main", WGPU_STRLEN},
},
});
assert(compute_pipeline);
Expand All @@ -90,7 +101,7 @@ int main(int argc, char *argv[]) {

WGPUBindGroup bind_group = wgpuDeviceCreateBindGroup(
device, &(const WGPUBindGroupDescriptor){
.label = "bind_group",
.label = {"bind_group", WGPU_STRLEN},
.layout = bind_group_layout,
.entryCount = 1,
.entries =
Expand All @@ -107,14 +118,14 @@ int main(int argc, char *argv[]) {

WGPUCommandEncoder command_encoder = wgpuDeviceCreateCommandEncoder(
device, &(const WGPUCommandEncoderDescriptor){
.label = "command_encoder",
.label = {"command_encoder", WGPU_STRLEN},
});
assert(command_encoder);

WGPUComputePassEncoder compute_pass_encoder =
wgpuCommandEncoderBeginComputePass(command_encoder,
&(const WGPUComputePassDescriptor){
.label = "compute_pass",
.label = {"compute_pass", WGPU_STRLEN},
});
assert(compute_pass_encoder);

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

WGPUCommandBuffer command_buffer = wgpuCommandEncoderFinish(
command_encoder, &(const WGPUCommandBufferDescriptor){
.label = "command_buffer",
.label = {"command_buffer", WGPU_STRLEN},
});
assert(command_buffer);

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

wgpuBufferMapAsync(staging_buffer, WGPUMapMode_Read, 0, numbers_size,
handle_buffer_map, NULL);
(const WGPUBufferMapCallbackInfo){
.callback = handle_buffer_map
});
wgpuDevicePoll(device, true, NULL);

uint32_t *buf =
Expand Down
2 changes: 1 addition & 1 deletion examples/enumerate_adapters/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ include_directories(${CMAKE_SOURCE_DIR}/../ffi/webgpu-headers)
include_directories(${CMAKE_SOURCE_DIR}/framework)

if (WIN32)
set(OS_LIBRARIES d3dcompiler ws2_32 userenv bcrypt ntdll opengl32)
set(OS_LIBRARIES d3dcompiler ws2_32 userenv bcrypt ntdll opengl32 Propsys RuntimeObject)
elseif(UNIX AND NOT APPLE)
set(OS_LIBRARIES "-lm -ldl")
elseif(APPLE)
Expand Down
11 changes: 6 additions & 5 deletions examples/enumerate_adapters/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ int main(int argc, char *argv[]) {
wgpuAdapterGetInfo(adapter, &info);
printf("WGPUAdapter: %d\n", i);
printf("WGPUAdapterInfo {\n"
"\tvendor: %s\n"
"\tarchitecture: %s\n"
"\tdevice: %s\n"
"\tdescription: %s\n"
"\tvendor: %.*s\n"
"\tarchitecture: %.*s\n"
"\tdevice: %.*s\n"
"\tdescription: %.*s\n"
"\tbackendType: %#.8x\n"
"\tadapterType: %#.8x\n"
"\tvendorID: %" PRIu32 "\n"
"\tdeviceID: %" PRIu32 "\n"
"}\n",
info.vendor, info.architecture, info.device, info.description,
(int) info.vendor.length, info.vendor.data, (int) info.architecture.length, info.architecture.data,
(int) info.device.length, info.device.data, (int) info.description.length, info.description.data,
info.backendType, info.adapterType, info.vendorID, info.deviceID);

wgpuAdapterInfoFreeMembers(info);
Expand Down
Loading
Loading