gpu: rename FeatureName -> Feature

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-03-09 09:46:07 -07:00 committed by Stephen Gutekanst
parent bb18701609
commit 2c392bbae6
5 changed files with 14 additions and 15 deletions

View file

@ -19,14 +19,14 @@
//! https://gpuweb.github.io/gpuweb/#gpuadapter //! https://gpuweb.github.io/gpuweb/#gpuadapter
const std = @import("std"); const std = @import("std");
const FeatureName = @import("enums.zig").FeatureName; const Feature = @import("enums.zig").Feature;
const Limits = @import("Limits.zig"); const Limits = @import("Limits.zig");
const Device = @import("Device.zig"); const Device = @import("Device.zig");
const Adapter = @This(); const Adapter = @This();
/// The features which can be used to create devices on this adapter. /// The features which can be used to create devices on this adapter.
features: []FeatureName, features: []Feature,
/// The best limits which can be used to create devices on this adapter. /// The best limits which can be used to create devices on this adapter.
/// ///
@ -71,7 +71,7 @@ pub inline fn release(adapter: Adapter) void {
} }
/// Tests of the given feature can be used to create devices on this adapter. /// Tests of the given feature can be used to create devices on this adapter.
pub fn hasFeature(adapter: Adapter, feature: FeatureName) bool { pub fn hasFeature(adapter: Adapter, feature: Feature) bool {
for (adapter.features) |f| { for (adapter.features) |f| {
if (f == feature) return true; if (f == feature) return true;
} }

View file

@ -6,7 +6,7 @@
//! //!
//! https://gpuweb.github.io/gpuweb/#devices //! https://gpuweb.github.io/gpuweb/#devices
//! https://gpuweb.github.io/gpuweb/#gpuadapter //! https://gpuweb.github.io/gpuweb/#gpuadapter
const FeatureName = @import("enums.zig").FeatureName; const Feature = @import("enums.zig").Feature;
const Limits = @import("Limits.zig"); const Limits = @import("Limits.zig");
const Queue = @import("Queue.zig"); const Queue = @import("Queue.zig");
const ShaderModule = @import("ShaderModule.zig"); const ShaderModule = @import("ShaderModule.zig");
@ -40,10 +40,10 @@ pub const VTable = struct {
nativeCreateSwapChain: fn (ptr: *anyopaque, surface: ?Surface, descriptor: *const SwapChain.Descriptor) SwapChain, nativeCreateSwapChain: fn (ptr: *anyopaque, surface: ?Surface, descriptor: *const SwapChain.Descriptor) SwapChain,
// WGPU_EXPORT WGPUTexture wgpuDeviceCreateTexture(WGPUDevice device, WGPUTextureDescriptor const * descriptor); // WGPU_EXPORT WGPUTexture wgpuDeviceCreateTexture(WGPUDevice device, WGPUTextureDescriptor const * descriptor);
// WGPU_EXPORT void wgpuDeviceDestroy(WGPUDevice device); // WGPU_EXPORT void wgpuDeviceDestroy(WGPUDevice device);
// WGPU_EXPORT size_t wgpuDeviceEnumerateFeatures(WGPUDevice device, WGPUFeatureName * features); // WGPU_EXPORT size_t wgpuDeviceEnumerateFeatures(WGPUDevice device, WGPUFeature * features);
// WGPU_EXPORT bool wgpuDeviceGetLimits(WGPUDevice device, WGPUSupportedLimits * limits); // WGPU_EXPORT bool wgpuDeviceGetLimits(WGPUDevice device, WGPUSupportedLimits * limits);
getQueue: fn (ptr: *anyopaque) Queue, getQueue: fn (ptr: *anyopaque) Queue,
// WGPU_EXPORT bool wgpuDeviceHasFeature(WGPUDevice device, WGPUFeatureName feature); // WGPU_EXPORT bool wgpuDeviceHasFeature(WGPUDevice device, WGPUFeature feature);
// WGPU_EXPORT void wgpuDeviceInjectError(WGPUDevice device, WGPUErrorType type, char const * message); // WGPU_EXPORT void wgpuDeviceInjectError(WGPUDevice device, WGPUErrorType type, char const * message);
// WGPU_EXPORT void wgpuDeviceLoseForTesting(WGPUDevice device); // WGPU_EXPORT void wgpuDeviceLoseForTesting(WGPUDevice device);
// WGPU_EXPORT bool wgpuDevicePopErrorScope(WGPUDevice device, WGPUErrorCallback callback, void * userdata); // WGPU_EXPORT bool wgpuDevicePopErrorScope(WGPUDevice device, WGPUErrorCallback callback, void * userdata);
@ -80,7 +80,7 @@ pub inline fn nativeCreateSwapChain(device: Device, surface: ?Surface, descripto
// TODO: docs // TODO: docs
pub const Descriptor = struct { pub const Descriptor = struct {
label: ?[]const u8 = null, label: ?[]const u8 = null,
required_features: ?[]FeatureName = null, required_features: ?[]Feature = null,
required_limits: ?Limits = null, required_limits: ?Limits = null,
}; };

View file

@ -202,8 +202,8 @@ fn wrapAdapter(adapter: c.WGPUAdapter) Adapter {
}; };
// TODO: implement Adapter interface: // TODO: implement Adapter interface:
// WGPU_EXPORT size_t wgpuAdapterEnumerateFeatures(WGPUAdapter adapter, WGPUFeatureName * features); // WGPU_EXPORT size_t wgpuAdapterEnumerateFeatures(WGPUAdapter adapter, WGPUFeature * features);
// WGPU_EXPORT bool wgpuAdapterHasFeature(WGPUAdapter adapter, WGPUFeatureName feature); // WGPU_EXPORT bool wgpuAdapterHasFeature(WGPUAdapter adapter, WGPUFeature feature);
// WGPU_EXPORT bool wgpuAdapterGetLimits(WGPUAdapter adapter, WGPUSupportedLimits * limits); // WGPU_EXPORT bool wgpuAdapterGetLimits(WGPUAdapter adapter, WGPUSupportedLimits * limits);
return .{ return .{

View file

@ -1,4 +1,4 @@
pub const FeatureName = enum(u32) { pub const Feature = enum(u32) {
depth24_unorm_stencil8 = 0x00000002, depth24_unorm_stencil8 = 0x00000002,
depth32_float_stencil8 = 0x00000003, depth32_float_stencil8 = 0x00000003,
timestamp_query = 0x00000004, timestamp_query = 0x00000004,
@ -14,9 +14,8 @@ pub const FeatureName = enum(u32) {
dawn_native = 0x000003ec, dawn_native = 0x000003ec,
}; };
// TODO: add featureNameString method // TODO: add featureName stringer method
// TODO: should featureName be renamed to just feature?
test "syntax" { test "syntax" {
_ = FeatureName; _ = Feature;
} }

View file

@ -36,7 +36,7 @@ pub const CommandBuffer = @import("CommandBuffer.zig");
pub const ShaderModule = @import("ShaderModule.zig"); pub const ShaderModule = @import("ShaderModule.zig");
pub const SwapChain = @import("SwapChain.zig"); pub const SwapChain = @import("SwapChain.zig");
pub const FeatureName = @import("enums.zig").FeatureName; pub const Feature = @import("enums.zig").Feature;
pub const TextureUsage = @import("texture_usage.zig").TextureUsage; pub const TextureUsage = @import("texture_usage.zig").TextureUsage;
pub const TextureFormat = @import("texture_format.zig").TextureFormat; pub const TextureFormat = @import("texture_format.zig").TextureFormat;
pub const PresentMode = @import("present_mode.zig").PresentMode; pub const PresentMode = @import("present_mode.zig").PresentMode;
@ -55,5 +55,5 @@ test "syntax" {
_ = ShaderModule; _ = ShaderModule;
_ = SwapChain; _ = SwapChain;
_ = FeatureName; _ = Feature;
} }