gpu: improve how limits are represented
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
070126b85d
commit
39ab0105a9
6 changed files with 36 additions and 25 deletions
|
|
@ -20,7 +20,7 @@
|
|||
const std = @import("std");
|
||||
|
||||
const FeatureName = @import("feature_name.zig").FeatureName;
|
||||
const SupportedLimits = @import("supported_limits.zig").SupportedLimits;
|
||||
const Limits = @import("Limits.zig");
|
||||
const Device = @import("Device.zig");
|
||||
|
||||
const Adapter = @This();
|
||||
|
|
@ -31,7 +31,7 @@ features: []FeatureName,
|
|||
/// The best limits which can be used to create devices on this adapter.
|
||||
///
|
||||
/// Each adapter limit will be the same or better than its default value in supported limits.
|
||||
limits: SupportedLimits,
|
||||
limits: Limits,
|
||||
|
||||
/// If set to true indicates that the adapter is a fallback adapter.
|
||||
///
|
||||
|
|
@ -54,7 +54,8 @@ vtable: *const VTable,
|
|||
request_device_frame_size: usize,
|
||||
|
||||
pub const VTable = struct {
|
||||
// TODO:
|
||||
// TODO: is this method actually useful over requestDevice? Doesn't appear to be available in
|
||||
// web either:
|
||||
// WGPU_EXPORT WGPUDevice wgpuAdapterCreateDevice(WGPUAdapter adapter, WGPUDeviceDescriptor const * descriptor);
|
||||
reference: fn (ptr: *anyopaque) void,
|
||||
release: fn (ptr: *anyopaque) void,
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
//! https://gpuweb.github.io/gpuweb/#devices
|
||||
//! https://gpuweb.github.io/gpuweb/#gpuadapter
|
||||
const FeatureName = @import("feature_name.zig").FeatureName;
|
||||
const Limits = @import("Limits.zig");
|
||||
|
||||
const Device = @This();
|
||||
|
||||
|
|
@ -56,8 +57,7 @@ pub const VTable = struct {
|
|||
pub const Descriptor = struct {
|
||||
label: ?[]const u8 = null,
|
||||
required_features: ?[]FeatureName = null,
|
||||
// TODO:
|
||||
//required_limits: ?RequiredLimits = null,
|
||||
required_limits: ?Limits = null,
|
||||
};
|
||||
|
||||
test "syntax" {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
pub const SupportedLimits = struct {};
|
||||
// TODO: docs
|
||||
|
||||
// TODO:
|
||||
// typedef struct WGPUSupportedLimits {
|
||||
// WGPUChainedStructOut * nextInChain;
|
||||
// WGPULimits limits;
|
||||
// } WGPUSupportedLimits;
|
||||
|
||||
// TODO:
|
||||
// typedef struct WGPULimits {
|
||||
// uint32_t maxTextureDimension1D;
|
||||
// uint32_t maxTextureDimension2D;
|
||||
|
|
@ -2,20 +2,20 @@
|
|||
const std = @import("std");
|
||||
const c = @import("c.zig").c;
|
||||
|
||||
pub const Interface = @import("Interface.zig");
|
||||
pub const RequestAdapterOptions = Interface.RequestAdapterOptions;
|
||||
pub const RequestAdapterErrorCode = Interface.RequestAdapterErrorCode;
|
||||
pub const RequestAdapterError = Interface.RequestAdapterError;
|
||||
pub const RequestAdapterResponse = Interface.RequestAdapterResponse;
|
||||
const Interface = @import("Interface.zig");
|
||||
const RequestAdapterOptions = Interface.RequestAdapterOptions;
|
||||
const RequestAdapterErrorCode = Interface.RequestAdapterErrorCode;
|
||||
const RequestAdapterError = Interface.RequestAdapterError;
|
||||
const RequestAdapterResponse = Interface.RequestAdapterResponse;
|
||||
|
||||
pub const Adapter = @import("Adapter.zig");
|
||||
pub const RequestDeviceErrorCode = Adapter.RequestDeviceErrorCode;
|
||||
pub const RequestDeviceError = Adapter.RequestDeviceError;
|
||||
pub const RequestDeviceResponse = Adapter.RequestDeviceResponse;
|
||||
|
||||
pub const Device = @import("Device.zig");
|
||||
const Adapter = @import("Adapter.zig");
|
||||
const RequestDeviceErrorCode = Adapter.RequestDeviceErrorCode;
|
||||
const RequestDeviceError = Adapter.RequestDeviceError;
|
||||
const RequestDeviceResponse = Adapter.RequestDeviceResponse;
|
||||
|
||||
const Device = @import("Device.zig");
|
||||
const Surface = @import("Surface.zig");
|
||||
const Limits = @import("Limits.zig");
|
||||
|
||||
const NativeInstance = @This();
|
||||
|
||||
|
|
@ -233,12 +233,17 @@ const adapter_vtable = Adapter.VTable{
|
|||
pub fn requestDevice(ptr: *anyopaque, descriptor: *const Device.Descriptor) callconv(.Async) RequestDeviceResponse {
|
||||
const adapter = @ptrCast(c.WGPUAdapter, @alignCast(@alignOf(c.WGPUAdapter), ptr));
|
||||
|
||||
const required_limits = if (descriptor.required_limits) |l| c.WGPURequiredLimits{
|
||||
.nextInChain = null,
|
||||
.limits = convertLimits(l),
|
||||
} else null;
|
||||
|
||||
const desc = c.WGPUDeviceDescriptor{
|
||||
.nextInChain = null,
|
||||
.label = if (descriptor.label) |l| @ptrCast([*c]const u8, l) else null,
|
||||
.requiredFeaturesCount = if (descriptor.required_features) |f| @intCast(u32, f.len) else 0,
|
||||
.requiredFeatures = if (descriptor.required_features) |f| @ptrCast([*c]const c_uint, &f[0]) else null,
|
||||
.requiredLimits = null, // TODO
|
||||
.requiredLimits = if (required_limits) |*l| l else null,
|
||||
};
|
||||
|
||||
const callback = (struct {
|
||||
|
|
@ -295,6 +300,12 @@ const device_vtable = Device.VTable{
|
|||
}).release,
|
||||
};
|
||||
|
||||
fn convertLimits(l: Limits) c.WGPULimits {
|
||||
// TODO: implement!
|
||||
_ = l;
|
||||
return std.mem.zeroes(c.WGPULimits);
|
||||
}
|
||||
|
||||
test "syntax" {
|
||||
_ = wrap;
|
||||
_ = interface_vtable;
|
||||
|
|
@ -304,4 +315,5 @@ test "syntax" {
|
|||
_ = adapter_vtable;
|
||||
_ = wrapDevice;
|
||||
_ = device_vtable;
|
||||
_ = convertLimits;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -955,11 +955,6 @@ typedef struct WGPURenderPassColorAttachment {
|
|||
WGPUColor clearValue;
|
||||
} WGPURenderPassColorAttachment;
|
||||
|
||||
typedef struct WGPURequiredLimits {
|
||||
WGPUChainedStruct const * nextInChain;
|
||||
WGPULimits limits;
|
||||
} WGPURequiredLimits;
|
||||
|
||||
typedef struct WGPUTextureDescriptor {
|
||||
WGPUChainedStruct const * nextInChain;
|
||||
char const * label;
|
||||
|
|
|
|||
|
|
@ -30,9 +30,9 @@ pub const NativeInstance = @import("NativeInstance.zig");
|
|||
pub const Adapter = @import("Adapter.zig");
|
||||
pub const Device = @import("Device.zig");
|
||||
pub const Surface = @import("Surface.zig");
|
||||
pub const Limits = @import("Limits.zig");
|
||||
|
||||
pub const FeatureName = @import("feature_name.zig").FeatureName;
|
||||
pub const SupportedLimits = @import("supported_limits.zig").SupportedLimits;
|
||||
|
||||
test "syntax" {
|
||||
_ = Interface;
|
||||
|
|
@ -41,7 +41,7 @@ test "syntax" {
|
|||
_ = Adapter;
|
||||
_ = Device;
|
||||
_ = Surface;
|
||||
_ = Limits;
|
||||
|
||||
_ = FeatureName;
|
||||
_ = SupportedLimits;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue