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 latest wgpu #441

Open
wants to merge 10 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
301 changes: 128 additions & 173 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 5 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 = "v23.0.0"

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

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

[workspace.dependencies.naga]
package = "naga"
git = "https://github.com/gfx-rs/wgpu"
tag = "v22.1.0"
tag = "v23.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 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
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
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
21 changes: 2 additions & 19 deletions examples/framework/framework.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ WGPUBuffer frmwrk_device_create_buffer_init(
printf("%snumAllocated=%zu\n", prefix, report.numAllocated); \
printf("%snumKeptFromUser=%zu\n", prefix, report.numKeptFromUser); \
printf("%snumReleasedFromUser=%zu\n", prefix, report.numReleasedFromUser); \
printf("%snumError=%zu\n", prefix, report.numError); \
printf("%selementSize=%zu\n", prefix, report.elementSize)

#define print_hub_report(report, prefix) \
Expand All @@ -136,6 +135,7 @@ WGPUBuffer frmwrk_device_create_buffer_init(
print_registry_report(report.renderBundles, prefix "renderBundles."); \
print_registry_report(report.renderPipelines, prefix "renderPipelines."); \
print_registry_report(report.computePipelines, prefix "computePipelines."); \
print_registry_report(report.pipelineCaches, prefix "pipelineCaches."); \
print_registry_report(report.querySets, prefix "querySets."); \
print_registry_report(report.textures, prefix "textures."); \
print_registry_report(report.textureViews, prefix "textureViews."); \
Expand All @@ -144,24 +144,7 @@ WGPUBuffer frmwrk_device_create_buffer_init(
void frmwrk_print_global_report(WGPUGlobalReport report) {
printf("struct WGPUGlobalReport {\n");
print_registry_report(report.surfaces, "\tsurfaces.");

switch (report.backendType) {
case WGPUBackendType_D3D12:
print_hub_report(report.dx12, "\tdx12.");
break;
case WGPUBackendType_Metal:
print_hub_report(report.metal, "\tmetal.");
break;
case WGPUBackendType_Vulkan:
print_hub_report(report.vulkan, "\tvulkan.");
break;
case WGPUBackendType_OpenGL:
print_hub_report(report.gl, "\tgl.");
break;
default:
printf("[framework] frmwrk_print_global_report: invalid backend type: %d",
report.backendType);
}
print_hub_report(report.hub, "\thub.");
printf("}\n");
}

Expand Down
2 changes: 1 addition & 1 deletion examples/push_constants/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
2 changes: 1 addition & 1 deletion examples/texture_arrays/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ include_directories(${CMAKE_SOURCE_DIR}/framework)

if (WIN32)
add_definitions(-DGLFW_EXPOSE_NATIVE_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)
add_definitions(-DGLFW_EXPOSE_NATIVE_X11)
add_definitions(-DGLFW_EXPOSE_NATIVE_WAYLAND)
Expand Down
2 changes: 1 addition & 1 deletion examples/triangle/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ include_directories(${CMAKE_SOURCE_DIR}/framework)

if (WIN32)
add_definitions(-DGLFW_EXPOSE_NATIVE_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)
add_definitions(-DGLFW_EXPOSE_NATIVE_X11)
add_definitions(-DGLFW_EXPOSE_NATIVE_WAYLAND)
Expand Down
15 changes: 3 additions & 12 deletions ffi/wgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@ typedef struct WGPUPipelineLayoutExtras {

typedef uint64_t WGPUSubmissionIndex;

typedef struct WGPUWrappedSubmissionIndex {
WGPUQueue queue;
WGPUSubmissionIndex submissionIndex;
} WGPUWrappedSubmissionIndex;

typedef struct WGPUShaderDefine {
char const * name;
char const * value;
Expand All @@ -195,7 +190,6 @@ typedef struct WGPURegistryReport {
size_t numAllocated;
size_t numKeptFromUser;
size_t numReleasedFromUser;
size_t numError;
size_t elementSize;
} WGPURegistryReport;

Expand All @@ -211,6 +205,7 @@ typedef struct WGPUHubReport {
WGPURegistryReport renderBundles;
WGPURegistryReport renderPipelines;
WGPURegistryReport computePipelines;
WGPURegistryReport pipelineCaches;
WGPURegistryReport querySets;
WGPURegistryReport buffers;
WGPURegistryReport textures;
Expand All @@ -220,11 +215,7 @@ typedef struct WGPUHubReport {

typedef struct WGPUGlobalReport {
WGPURegistryReport surfaces;
WGPUBackendType backendType;
WGPUHubReport vulkan;
WGPUHubReport metal;
WGPUHubReport dx12;
WGPUHubReport gl;
WGPUHubReport hub;
} WGPUGlobalReport;

typedef struct WGPUInstanceEnumerateAdapterOptions {
Expand Down Expand Up @@ -282,7 +273,7 @@ size_t wgpuInstanceEnumerateAdapters(WGPUInstance instance, WGPU_NULLABLE WGPUIn
WGPUSubmissionIndex wgpuQueueSubmitForIndex(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands);

// Returns true if the queue is empty, or false if there are more queue submissions still in flight.
WGPUBool wgpuDevicePoll(WGPUDevice device, WGPUBool wait, WGPU_NULLABLE WGPUWrappedSubmissionIndex const * wrappedSubmissionIndex);
WGPUBool wgpuDevicePoll(WGPUDevice device, WGPUBool wait, WGPU_NULLABLE WGPUSubmissionIndex const * wrappedSubmissionIndex);
WGPUShaderModule wgpuDeviceCreateShaderModuleSpirV(WGPUDevice device, WGPUShaderModuleDescriptorSpirV const * descriptor);

void wgpuSetLogCallback(WGPULogCallback callback, void * userdata);
Expand Down
42 changes: 4 additions & 38 deletions src/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ pub fn map_texture_format(value: native::WGPUTextureFormat) -> Option<wgt::Textu
native::WGPUTextureFormat_BGRA8UnormSrgb => Some(wgt::TextureFormat::Bgra8UnormSrgb),
native::WGPUTextureFormat_RGB10A2Uint => Some(wgt::TextureFormat::Rgb10a2Uint),
native::WGPUTextureFormat_RGB10A2Unorm => Some(wgt::TextureFormat::Rgb10a2Unorm),
native::WGPUTextureFormat_RG11B10Ufloat => Some(wgt::TextureFormat::Rg11b10Float),
native::WGPUTextureFormat_RG11B10Ufloat => Some(wgt::TextureFormat::Rg11b10Ufloat),
native::WGPUTextureFormat_RGB9E5Ufloat => Some(wgt::TextureFormat::Rgb9e5Ufloat),
native::WGPUTextureFormat_RG32Float => Some(wgt::TextureFormat::Rg32Float),
native::WGPUTextureFormat_RG32Uint => Some(wgt::TextureFormat::Rg32Uint),
Expand Down Expand Up @@ -877,7 +877,7 @@ pub fn to_native_texture_format(rs_type: wgt::TextureFormat) -> Option<native::W
wgt::TextureFormat::Bgra8UnormSrgb => Some(native::WGPUTextureFormat_BGRA8UnormSrgb),
wgt::TextureFormat::Rgb10a2Uint => Some(native::WGPUTextureFormat_RGB10A2Uint),
wgt::TextureFormat::Rgb10a2Unorm => Some(native::WGPUTextureFormat_RGB10A2Unorm),
wgt::TextureFormat::Rg11b10Float => Some(native::WGPUTextureFormat_RG11B10Ufloat),
wgt::TextureFormat::Rg11b10Ufloat => Some(native::WGPUTextureFormat_RG11B10Ufloat),
wgt::TextureFormat::Rgb9e5Ufloat => Some(native::WGPUTextureFormat_RGB9E5Ufloat),
wgt::TextureFormat::Rg32Float => Some(native::WGPUTextureFormat_RG32Float),
wgt::TextureFormat::Rg32Uint => Some(native::WGPUTextureFormat_RG32Uint),
Expand Down Expand Up @@ -993,7 +993,6 @@ pub fn map_storage_report(report: &wgc::registry::RegistryReport) -> native::WGP
numAllocated: report.num_allocated,
numKeptFromUser: report.num_kept_from_user,
numReleasedFromUser: report.num_released_from_user,
numError: report.num_error,
elementSize: report.element_size,
}
}
Expand All @@ -1012,6 +1011,7 @@ pub fn map_hub_report(report: &wgc::hub::HubReport) -> native::WGPUHubReport {
renderBundles: map_storage_report(&report.render_bundles),
renderPipelines: map_storage_report(&report.render_pipelines),
computePipelines: map_storage_report(&report.compute_pipelines),
pipelineCaches: map_storage_report(&report.pipeline_caches),
querySets: map_storage_report(&report.query_sets),
buffers: map_storage_report(&report.buffers),
textures: map_storage_report(&report.textures),
Expand All @@ -1026,41 +1026,7 @@ pub fn write_global_report(
report: &wgc::global::GlobalReport,
) {
native_report.surfaces = map_storage_report(&report.surfaces);

#[cfg(any(
all(
any(target_os = "ios", target_os = "macos"),
feature = "vulkan-portability"
),
windows,
all(unix, not(target_os = "ios"), not(target_os = "macos"))
))]
if let Some(ref vulkan) = report.vulkan {
native_report.vulkan = map_hub_report(vulkan);
native_report.backendType = native::WGPUBackendType_Vulkan;
}

#[cfg(all(any(target_os = "ios", target_os = "macos"), feature = "metal"))]
if let Some(ref metal) = report.metal {
native_report.metal = map_hub_report(metal);
native_report.backendType = native::WGPUBackendType_Metal;
}

#[cfg(all(target_os = "windows", feature = "dx12"))]
if let Some(ref dx12) = report.dx12 {
native_report.dx12 = map_hub_report(dx12);
native_report.backendType = native::WGPUBackendType_D3D12;
}

#[cfg(any(
feature = "angle",
target_os = "windows",
all(unix, not(target_os = "ios"), not(target_os = "macos"))
))]
if let Some(ref gl) = report.gl {
native_report.gl = map_hub_report(gl);
native_report.backendType = native::WGPUBackendType_OpenGL;
}
native_report.hub = map_hub_report(&report.hub);
}

#[inline]
Expand Down
Loading
Loading