gpu: move TextureFormat -> Texture.Format
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
281d6a2016
commit
2e68792f0d
6 changed files with 108 additions and 109 deletions
|
|
@ -50,7 +50,7 @@ pub fn main() !void {
|
|||
descriptor.implementation = c.machUtilsBackendBinding_getSwapChainImplementation(binding);
|
||||
window_data.swap_chain = setup.device.nativeCreateSwapChain(null, &descriptor);
|
||||
|
||||
window_data.swap_chain_format = @intToEnum(gpu.TextureFormat, @intCast(u32, c.machUtilsBackendBinding_getPreferredSwapChainTextureFormat(binding)));
|
||||
window_data.swap_chain_format = @intToEnum(gpu.Texture.Format, @intCast(u32, c.machUtilsBackendBinding_getPreferredSwapChainTextureFormat(binding)));
|
||||
window_data.swap_chain.?.configure(
|
||||
window_data.swap_chain_format,
|
||||
.render_attachment,
|
||||
|
|
@ -159,7 +159,7 @@ pub fn main() !void {
|
|||
const WindowData = struct {
|
||||
surface: ?gpu.Surface,
|
||||
swap_chain: ?gpu.SwapChain,
|
||||
swap_chain_format: gpu.TextureFormat,
|
||||
swap_chain_format: gpu.Texture.Format,
|
||||
current_desc: gpu.SwapChain.Descriptor,
|
||||
target_desc: gpu.SwapChain.Descriptor,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ const CommandEncoder = @import("CommandEncoder.zig");
|
|||
const ComputePassEncoder = @import("ComputePassEncoder.zig");
|
||||
const ComputePipeline = @import("ComputePipeline.zig");
|
||||
|
||||
const TextureFormat = @import("enums.zig").TextureFormat;
|
||||
const PresentMode = @import("enums.zig").PresentMode;
|
||||
|
||||
const NativeInstance = @This();
|
||||
|
|
@ -510,7 +509,7 @@ const swap_chain_vtable = SwapChain.VTable{
|
|||
}
|
||||
}).release,
|
||||
.configure = (struct {
|
||||
pub fn configure(ptr: *anyopaque, format: TextureFormat, allowed_usage: Texture.Usage, width: u32, height: u32) void {
|
||||
pub fn configure(ptr: *anyopaque, format: Texture.Format, allowed_usage: Texture.Usage, width: u32, height: u32) void {
|
||||
c.wgpuSwapChainConfigure(
|
||||
@ptrCast(c.WGPUSwapChain, ptr),
|
||||
@enumToInt(format),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
const std = @import("std");
|
||||
const Texture = @import("Texture.zig");
|
||||
const TextureFormat = @import("enums.zig").TextureFormat;
|
||||
const PresentMode = @import("enums.zig").PresentMode;
|
||||
|
||||
const SwapChain = @This();
|
||||
|
|
@ -13,7 +12,7 @@ vtable: *const VTable,
|
|||
pub const VTable = struct {
|
||||
reference: fn (ptr: *anyopaque) void,
|
||||
release: fn (ptr: *anyopaque) void,
|
||||
configure: fn (ptr: *anyopaque, format: TextureFormat, allowed_usage: Texture.Usage, width: u32, height: u32) void,
|
||||
configure: fn (ptr: *anyopaque, format: Texture.Format, allowed_usage: Texture.Usage, width: u32, height: u32) void,
|
||||
// TODO:
|
||||
// WGPU_EXPORT WGPUTextureView wgpuSwapChainGetCurrentTextureView(WGPUSwapChain swapChain);
|
||||
// WGPU_EXPORT void wgpuSwapChainPresent(WGPUSwapChain swapChain);
|
||||
|
|
@ -29,7 +28,7 @@ pub inline fn release(swap_chain: SwapChain) void {
|
|||
|
||||
pub inline fn configure(
|
||||
swap_chain: SwapChain,
|
||||
format: TextureFormat,
|
||||
format: Texture.Format,
|
||||
allowed_usage: Texture.Usage,
|
||||
width: u32,
|
||||
height: u32,
|
||||
|
|
@ -40,7 +39,7 @@ pub inline fn configure(
|
|||
pub const Descriptor = struct {
|
||||
label: ?[:0]const u8 = null,
|
||||
usage: Texture.Usage,
|
||||
format: TextureFormat,
|
||||
format: Texture.Format,
|
||||
width: u32,
|
||||
height: u32,
|
||||
present_mode: PresentMode,
|
||||
|
|
|
|||
|
|
@ -40,9 +40,111 @@ pub const Usage = enum(u32) {
|
|||
present = 0x00000020,
|
||||
};
|
||||
|
||||
pub const Format = enum(u32) {
|
||||
none = 0x00000000,
|
||||
r8_unorm = 0x00000001,
|
||||
r8_snorm = 0x00000002,
|
||||
r8_uint = 0x00000003,
|
||||
r8_sint = 0x00000004,
|
||||
r16_uint = 0x00000005,
|
||||
r16_sint = 0x00000006,
|
||||
r16_float = 0x00000007,
|
||||
rg8_unorm = 0x00000008,
|
||||
rg8_snorm = 0x00000009,
|
||||
rg8_uint = 0x0000000a,
|
||||
rg8_sint = 0x0000000b,
|
||||
r32_float = 0x0000000c,
|
||||
r32_uint = 0x0000000d,
|
||||
r32_sint = 0x0000000e,
|
||||
rg16_uint = 0x0000000f,
|
||||
rg16_sint = 0x00000010,
|
||||
rg16_float = 0x00000011,
|
||||
rgba8_unorm = 0x00000012,
|
||||
rgba8_unorm_srgb = 0x00000013,
|
||||
rgba8_snorm = 0x00000014,
|
||||
rgba8_uint = 0x00000015,
|
||||
rgba8_sint = 0x00000016,
|
||||
bgra8_unorm = 0x00000017,
|
||||
bgra8_unorm_srgb = 0x00000018,
|
||||
rgb10a2_unorm = 0x00000019,
|
||||
rg11b10u_float = 0x0000001a,
|
||||
rgb9e5u_float = 0x0000001b,
|
||||
rg32_float = 0x0000001c,
|
||||
rg32_uint = 0x0000001d,
|
||||
rg32_sint = 0x0000001e,
|
||||
rgba16_uint = 0x0000001f,
|
||||
rgba16_sint = 0x00000020,
|
||||
rgba16_float = 0x00000021,
|
||||
rgba32_float = 0x00000022,
|
||||
rgba32_uint = 0x00000023,
|
||||
rgba32_sint = 0x00000024,
|
||||
stencil8 = 0x00000025,
|
||||
depth16_unorm = 0x00000026,
|
||||
depth24_plus = 0x00000027,
|
||||
depth24_plus_stencil8 = 0x00000028,
|
||||
depth24_unorm_stencil8 = 0x00000029,
|
||||
depth32_float = 0x0000002a,
|
||||
depth32_float_stencil8 = 0x0000002b,
|
||||
bc1rgba_unorm = 0x0000002c,
|
||||
bc1rgba_unorm_srgb = 0x0000002d,
|
||||
bc2rgba_unorm = 0x0000002e,
|
||||
bc2rgba_unorm_srgb = 0x0000002f,
|
||||
bc3rgba_unorm = 0x00000030,
|
||||
bc3rgba_unorm_srgb = 0x00000031,
|
||||
bc4r_unorm = 0x00000032,
|
||||
bc4r_snorm = 0x00000033,
|
||||
bc5rg_unorm = 0x00000034,
|
||||
bc5rg_snorm = 0x00000035,
|
||||
bc6hrgbu_float = 0x00000036,
|
||||
bc6hrgb_float = 0x00000037,
|
||||
bc7rgba_unorm = 0x00000038,
|
||||
bc7rgba_unorm_srgb = 0x00000039,
|
||||
etc2rgb8_unorm = 0x0000003a,
|
||||
etc2rgb8_unorm_srgb = 0x0000003b,
|
||||
etc2rgb8a1_unorm = 0x0000003c,
|
||||
etc2rgb8a1_unorm_srgb = 0x0000003d,
|
||||
etc2rgba8_unorm = 0x0000003e,
|
||||
etc2rgba8_unorm_srgb = 0x0000003f,
|
||||
eacr11_unorm = 0x00000040,
|
||||
eacr11_snorm = 0x00000041,
|
||||
eacrg11_unorm = 0x00000042,
|
||||
eacrg11_snorm = 0x00000043,
|
||||
astc4x4_unorm = 0x00000044,
|
||||
astc4x4_unorm_srgb = 0x00000045,
|
||||
astc5x4_unorm = 0x00000046,
|
||||
astc5x4_unorm_srgb = 0x00000047,
|
||||
astc5x5_unorm = 0x00000048,
|
||||
astc5x5_unorm_srgb = 0x00000049,
|
||||
astc6x5_unorm = 0x0000004a,
|
||||
astc6x5_unorm_srgb = 0x0000004b,
|
||||
astc6x6_unorm = 0x0000004c,
|
||||
astc6x6_unorm_srgb = 0x0000004d,
|
||||
astc8x5_unorm = 0x0000004e,
|
||||
astc8x5_unorm_srgb = 0x0000004f,
|
||||
astc8x6_unorm = 0x00000050,
|
||||
astc8x6_unorm_srgb = 0x00000051,
|
||||
astc8x8_unorm = 0x00000052,
|
||||
astc8x8_unorm_srgb = 0x00000053,
|
||||
astc10x5_unorm = 0x00000054,
|
||||
astc10x5_unorm_srgb = 0x00000055,
|
||||
astc10x6_unorm = 0x00000056,
|
||||
astc10x6_unorm_srgb = 0x00000057,
|
||||
astc10x8_unorm = 0x00000058,
|
||||
astc10x8_unorm_srgb = 0x00000059,
|
||||
astc10x10_unorm = 0x0000005a,
|
||||
astc10x10_unorm_srgb = 0x0000005b,
|
||||
astc12x10_unorm = 0x0000005c,
|
||||
astc12x10_unorm_srgb = 0x0000005d,
|
||||
astc12x12_unorm = 0x0000005e,
|
||||
astc12x12_unorm_srgb = 0x0000005f,
|
||||
r8bg8biplanar420_unorm = 0x00000060,
|
||||
};
|
||||
|
||||
test "syntax" {
|
||||
_ = VTable;
|
||||
_ = reference;
|
||||
_ = release;
|
||||
_ = destroy;
|
||||
_ = Usage;
|
||||
_ = Format;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,106 +28,6 @@ pub const PresentMode = enum(u32) {
|
|||
fifo = 0x00000002,
|
||||
};
|
||||
|
||||
pub const TextureFormat = enum(u32) {
|
||||
none = 0x00000000,
|
||||
r8_unorm = 0x00000001,
|
||||
r8_snorm = 0x00000002,
|
||||
r8_uint = 0x00000003,
|
||||
r8_sint = 0x00000004,
|
||||
r16_uint = 0x00000005,
|
||||
r16_sint = 0x00000006,
|
||||
r16_float = 0x00000007,
|
||||
rg8_unorm = 0x00000008,
|
||||
rg8_snorm = 0x00000009,
|
||||
rg8_uint = 0x0000000a,
|
||||
rg8_sint = 0x0000000b,
|
||||
r32_float = 0x0000000c,
|
||||
r32_uint = 0x0000000d,
|
||||
r32_sint = 0x0000000e,
|
||||
rg16_uint = 0x0000000f,
|
||||
rg16_sint = 0x00000010,
|
||||
rg16_float = 0x00000011,
|
||||
rgba8_unorm = 0x00000012,
|
||||
rgba8_unorm_srgb = 0x00000013,
|
||||
rgba8_snorm = 0x00000014,
|
||||
rgba8_uint = 0x00000015,
|
||||
rgba8_sint = 0x00000016,
|
||||
bgra8_unorm = 0x00000017,
|
||||
bgra8_unorm_srgb = 0x00000018,
|
||||
rgb10a2_unorm = 0x00000019,
|
||||
rg11b10u_float = 0x0000001a,
|
||||
rgb9e5u_float = 0x0000001b,
|
||||
rg32_float = 0x0000001c,
|
||||
rg32_uint = 0x0000001d,
|
||||
rg32_sint = 0x0000001e,
|
||||
rgba16_uint = 0x0000001f,
|
||||
rgba16_sint = 0x00000020,
|
||||
rgba16_float = 0x00000021,
|
||||
rgba32_float = 0x00000022,
|
||||
rgba32_uint = 0x00000023,
|
||||
rgba32_sint = 0x00000024,
|
||||
stencil8 = 0x00000025,
|
||||
depth16_unorm = 0x00000026,
|
||||
depth24_plus = 0x00000027,
|
||||
depth24_plus_stencil8 = 0x00000028,
|
||||
depth24_unorm_stencil8 = 0x00000029,
|
||||
depth32_float = 0x0000002a,
|
||||
depth32_float_stencil8 = 0x0000002b,
|
||||
bc1rgba_unorm = 0x0000002c,
|
||||
bc1rgba_unorm_srgb = 0x0000002d,
|
||||
bc2rgba_unorm = 0x0000002e,
|
||||
bc2rgba_unorm_srgb = 0x0000002f,
|
||||
bc3rgba_unorm = 0x00000030,
|
||||
bc3rgba_unorm_srgb = 0x00000031,
|
||||
bc4r_unorm = 0x00000032,
|
||||
bc4r_snorm = 0x00000033,
|
||||
bc5rg_unorm = 0x00000034,
|
||||
bc5rg_snorm = 0x00000035,
|
||||
bc6hrgbu_float = 0x00000036,
|
||||
bc6hrgb_float = 0x00000037,
|
||||
bc7rgba_unorm = 0x00000038,
|
||||
bc7rgba_unorm_srgb = 0x00000039,
|
||||
etc2rgb8_unorm = 0x0000003a,
|
||||
etc2rgb8_unorm_srgb = 0x0000003b,
|
||||
etc2rgb8a1_unorm = 0x0000003c,
|
||||
etc2rgb8a1_unorm_srgb = 0x0000003d,
|
||||
etc2rgba8_unorm = 0x0000003e,
|
||||
etc2rgba8_unorm_srgb = 0x0000003f,
|
||||
eacr11_unorm = 0x00000040,
|
||||
eacr11_snorm = 0x00000041,
|
||||
eacrg11_unorm = 0x00000042,
|
||||
eacrg11_snorm = 0x00000043,
|
||||
astc4x4_unorm = 0x00000044,
|
||||
astc4x4_unorm_srgb = 0x00000045,
|
||||
astc5x4_unorm = 0x00000046,
|
||||
astc5x4_unorm_srgb = 0x00000047,
|
||||
astc5x5_unorm = 0x00000048,
|
||||
astc5x5_unorm_srgb = 0x00000049,
|
||||
astc6x5_unorm = 0x0000004a,
|
||||
astc6x5_unorm_srgb = 0x0000004b,
|
||||
astc6x6_unorm = 0x0000004c,
|
||||
astc6x6_unorm_srgb = 0x0000004d,
|
||||
astc8x5_unorm = 0x0000004e,
|
||||
astc8x5_unorm_srgb = 0x0000004f,
|
||||
astc8x6_unorm = 0x00000050,
|
||||
astc8x6_unorm_srgb = 0x00000051,
|
||||
astc8x8_unorm = 0x00000052,
|
||||
astc8x8_unorm_srgb = 0x00000053,
|
||||
astc10x5_unorm = 0x00000054,
|
||||
astc10x5_unorm_srgb = 0x00000055,
|
||||
astc10x6_unorm = 0x00000056,
|
||||
astc10x6_unorm_srgb = 0x00000057,
|
||||
astc10x8_unorm = 0x00000058,
|
||||
astc10x8_unorm_srgb = 0x00000059,
|
||||
astc10x10_unorm = 0x0000005a,
|
||||
astc10x10_unorm_srgb = 0x0000005b,
|
||||
astc12x10_unorm = 0x0000005c,
|
||||
astc12x10_unorm_srgb = 0x0000005d,
|
||||
astc12x12_unorm = 0x0000005e,
|
||||
astc12x12_unorm_srgb = 0x0000005f,
|
||||
r8bg8biplanar420_unorm = 0x00000060,
|
||||
};
|
||||
|
||||
pub const AlphaMode = enum(u32) {
|
||||
premultiplied = 0x00000000,
|
||||
unpremultiplied = 0x00000001,
|
||||
|
|
|
|||
|
|
@ -94,7 +94,6 @@ pub const PrimitiveState = @import("structs.zig").PrimitiveState;
|
|||
|
||||
// Enumerations
|
||||
pub const Feature = @import("enums.zig").Feature;
|
||||
pub const TextureFormat = @import("enums.zig").TextureFormat;
|
||||
pub const PresentMode = @import("enums.zig").PresentMode;
|
||||
pub const AddressMode = @import("enums.zig").AddressMode;
|
||||
pub const AlphaMode = @import("enums.zig").AlphaMode;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue