Skip to content

Commit

Permalink
Begin moving to new header version
Browse files Browse the repository at this point in the history
  • Loading branch information
Beyley committed Aug 8, 2023
1 parent f35b60a commit 27e59cb
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 177 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = [
"Almar Klein <almar@almarklein.org>",
]
edition = "2021"
description = "WebGPU native implementation on gfx-hal"
description = "WebGPU native implementation on wgpu-core"
homepage = "https://github.com/gfx-rs/wgpu-native"
repository = "https://github.com/gfx-rs/wgpu-native"
keywords = ["graphics"]
Expand Down
1 change: 0 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ fn main() {
("WGPUSampler", "WGPUSamplerImpl"),
("WGPUShaderModule", "WGPUShaderModuleImpl"),
("WGPUSurface", "WGPUSurfaceImpl"),
("WGPUSwapChain", "WGPUSwapChainImpl"),
("WGPUTexture", "WGPUTextureImpl"),
("WGPUTextureView", "WGPUTextureViewImpl"),
];
Expand Down
2 changes: 1 addition & 1 deletion ffi/webgpu-headers
26 changes: 4 additions & 22 deletions ffi/wgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ typedef enum WGPUNativeSType {
WGPUSType_ShaderModuleGLSLDescriptor = 0x60000005,
WGPUSType_SupportedLimitsExtras = 0x60000003,
WGPUSType_InstanceExtras = 0x60000006,
WGPUSType_SwapChainDescriptorExtras = 0x60000007,
WGPUSType_SurfaceDescriptorExtras = 0x60000007,
WGPUNativeSType_Force32 = 0x7FFFFFFF
} WGPUNativeSType;

Expand Down Expand Up @@ -58,15 +58,6 @@ typedef enum WGPUDx12Compiler {
WGPUDx12Compiler_Force32 = 0x7FFFFFFF
} WGPUDx12Compiler;

typedef enum WGPUCompositeAlphaMode {
WGPUCompositeAlphaMode_Auto = 0x00000000,
WGPUCompositeAlphaMode_Opaque = 0x00000001,
WGPUCompositeAlphaMode_PreMultiplied = 0x00000002,
WGPUCompositeAlphaMode_PostMultiplied = 0x00000003,
WGPUCompositeAlphaMode_Inherit = 0x00000004,
WGPUCompositeAlphaMode_Force32 = 0x7FFFFFFF
} WGPUCompositeAlphaMode;

typedef struct WGPUInstanceExtras {
WGPUChainedStruct chain;
WGPUInstanceBackendFlags backends;
Expand Down Expand Up @@ -157,21 +148,12 @@ typedef struct WGPUGlobalReport {
WGPUHubReport gl;
} WGPUGlobalReport;

typedef struct WGPUSurfaceCapabilities {
size_t formatCount;
WGPUTextureFormat * formats;
size_t presentModeCount;
WGPUPresentMode * presentModes;
size_t alphaModeCount;
WGPUCompositeAlphaMode * alphaModes;
} WGPUSurfaceCapabilities;

typedef struct WGPUSwapChainDescriptorExtras {
typedef struct WGPUSurfaceDescriptorExtras {
WGPUChainedStruct chain;
WGPUCompositeAlphaMode alphaMode;
size_t viewFormatCount;
WGPUTextureFormat const * viewFormats;
} WGPUSwapChainDescriptorExtras;
} WGPUSurfaceDescriptorExtras;

typedef struct WGPUInstanceEnumerateAdapterOptions {
WGPUChainedStruct const * nextInChain;
Expand All @@ -190,7 +172,7 @@ size_t wgpuInstanceEnumerateAdapters(WGPUInstance instance, WGPUInstanceEnumerat
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.
bool wgpuDevicePoll(WGPUDevice device, bool wait, WGPUWrappedSubmissionIndex const * wrappedSubmissionIndex);
WGPUBool wgpuDevicePoll(WGPUDevice device, WGPUBool wait, WGPUWrappedSubmissionIndex const * wrappedSubmissionIndex);

void wgpuSetLogCallback(WGPULogCallback callback, void * userdata);

Expand Down
22 changes: 11 additions & 11 deletions src/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,11 @@ map_enum!(
map_composite_alpha_mode,
WGPUCompositeAlphaMode,
wgt::CompositeAlphaMode,
Auto,
Opaque,
PreMultiplied,
PostMultiplied,
Inherit
Auto: Auto,
Opaque: Opaque,
PreMultiplied: PreMultiplied,
UnPreMultiplied: PostMultiplied,
Inherit: Inherit
);

pub const WGPU_WHOLE_SIZE: ::std::os::raw::c_ulonglong = native::WGPU_WHOLE_SIZE as _;
Expand Down Expand Up @@ -895,7 +895,7 @@ pub fn map_primitive_state(
depth_clip_control: Option<&native::WGPUPrimitiveDepthClipControl>,
) -> bool {
if let Some(depth_clip_control) = depth_clip_control {
return depth_clip_control.unclippedDepth;
return depth_clip_control.unclippedDepth != 0;
}

false
Expand Down Expand Up @@ -1096,15 +1096,15 @@ pub fn to_native_composite_alpha_mode(
wgt::CompositeAlphaMode::Auto => native::WGPUCompositeAlphaMode_Auto,
wgt::CompositeAlphaMode::Opaque => native::WGPUCompositeAlphaMode_Opaque,
wgt::CompositeAlphaMode::PreMultiplied => native::WGPUCompositeAlphaMode_PreMultiplied,
wgt::CompositeAlphaMode::PostMultiplied => native::WGPUCompositeAlphaMode_PostMultiplied,
wgt::CompositeAlphaMode::PostMultiplied => native::WGPUCompositeAlphaMode_UnPreMultiplied,
wgt::CompositeAlphaMode::Inherit => native::WGPUCompositeAlphaMode_Inherit,
}
}

#[inline]
pub fn map_swapchain_descriptor(
desc: &native::WGPUSwapChainDescriptor,
extras: Option<&native::WGPUSwapChainDescriptorExtras>,
pub fn map_surface_configuration(
desc: &native::WGPUSurfaceConfiguration,
extras: Option<&native::WGPUSurfaceDescriptorExtras>,
) -> wgt::SurfaceConfiguration<Vec<wgt::TextureFormat>> {
let (alpha_mode, view_formats) = match extras {
Some(extras) => (
Expand All @@ -1114,7 +1114,7 @@ pub fn map_swapchain_descriptor(
native::WGPUCompositeAlphaMode_PreMultiplied => {
wgt::CompositeAlphaMode::PreMultiplied
}
native::WGPUCompositeAlphaMode_PostMultiplied => {
native::WGPUCompositeAlphaMode_UnPreMultiplied => {
wgt::CompositeAlphaMode::PostMultiplied
}
native::WGPUCompositeAlphaMode_Inherit => wgt::CompositeAlphaMode::Inherit,
Expand Down
Loading

0 comments on commit 27e59cb

Please sign in to comment.