texture.zig (4659B)
1 const c = @import("c.zig").c; 2 const TextureView = @import("texture_view.zig").TextureView; 3 4 pub const Texture = opaque { 5 pub const Aspect = enum(u32) { 6 all = 0x00000000, 7 stencil_only = 0x00000001, 8 depth_only = 0x00000002, 9 }; 10 11 pub const Format = enum(u32) { 12 undefined = 0x00000000, 13 r8_unorm = 0x00000001, 14 r8_snorm = 0x00000002, 15 r8_uint = 0x00000003, 16 r8_sint = 0x00000004, 17 r16_uint = 0x00000005, 18 r16_sint = 0x00000006, 19 r16_float = 0x00000007, 20 rg8_unorm = 0x00000008, 21 rg8_snorm = 0x00000009, 22 rg8_uint = 0x0000000A, 23 rg8_sint = 0x0000000B, 24 r32_float = 0x0000000C, 25 r32_uint = 0x0000000D, 26 r32_sint = 0x0000000E, 27 rg16_uint = 0x0000000F, 28 rg16_sint = 0x00000010, 29 rg16_float = 0x00000011, 30 rgba8_unorm = 0x00000012, 31 rgba8_unorm_srgb = 0x00000013, 32 rgba8_snorm = 0x00000014, 33 rgba8_uint = 0x00000015, 34 rgba8_sint = 0x00000016, 35 bgra8_unorm = 0x00000017, 36 bgra8_unorm_srgb = 0x00000018, 37 rgb10a2_uint = 0x00000019, 38 rgb10a2_unorm = 0x0000001A, 39 rg11b10_ufloat = 0x0000001B, 40 rgb9e5_ufloat = 0x0000001C, 41 rg32_float = 0x0000001D, 42 rg32_uint = 0x0000001E, 43 rg32_sint = 0x0000001F, 44 rgba16_uint = 0x00000020, 45 rgba16_sint = 0x00000021, 46 rgba16_float = 0x00000022, 47 rgba32_float = 0x00000023, 48 rgba32_uint = 0x00000024, 49 rgba32_sint = 0x00000025, 50 stencil8 = 0x00000026, 51 depth16_unorm = 0x00000027, 52 depth24_plus = 0x00000028, 53 depth24_plus_stencil8 = 0x00000029, 54 depth32_float = 0x0000002A, 55 depth32_float_stencil8 = 0x0000002B, 56 bc1rgba_unorm = 0x0000002C, 57 bc1rgba_unorm_srgb = 0x0000002D, 58 bc2rgba_unorm = 0x0000002E, 59 bc2rgba_unorm_srgb = 0x0000002F, 60 bc3rgba_unorm = 0x00000030, 61 bc3rgba_unorm_srgb = 0x00000031, 62 bc4r_unorm = 0x00000032, 63 bc4r_snorm = 0x00000033, 64 bc5rg_unorm = 0x00000034, 65 bc5rg_snorm = 0x00000035, 66 bc6hrgb_ufloat = 0x00000036, 67 bc6hrgb_float = 0x00000037, 68 bc7rgba_unorm = 0x00000038, 69 bc7rgba_unorm_srgb = 0x00000039, 70 etc2rgb8_unorm = 0x0000003A, 71 etc2rgb8_unorm_srgb = 0x0000003B, 72 etc2rgb8a1_unorm = 0x0000003C, 73 etc2rgb8a1_unorm_srgb = 0x0000003D, 74 etc2rgba8_unorm = 0x0000003E, 75 etc2rgba8_unorm_srgb = 0x0000003F, 76 eacr11_unorm = 0x00000040, 77 eacr11_snorm = 0x00000041, 78 eacrg11_unorm = 0x00000042, 79 eacrg11_snorm = 0x00000043, 80 astc4x4_unorm = 0x00000044, 81 astc4x4_unorm_srgb = 0x00000045, 82 astc5x4_unorm = 0x00000046, 83 astc5x4_unorm_srgb = 0x00000047, 84 astc5x5_unorm = 0x00000048, 85 astc5x5_unorm_srgb = 0x00000049, 86 astc6x5_unorm = 0x0000004A, 87 astc6x5_unorm_srgb = 0x0000004B, 88 astc6x6_unorm = 0x0000004C, 89 astc6x6_unorm_srgb = 0x0000004D, 90 astc8x5_unorm = 0x0000004E, 91 astc8x5_unorm_srgb = 0x0000004F, 92 astc8x6_unorm = 0x00000050, 93 astc8x6_unorm_srgb = 0x00000051, 94 astc8x8_unorm = 0x00000052, 95 astc8x8_unorm_srgb = 0x00000053, 96 astc10x5_unorm = 0x00000054, 97 astc10x5_unorm_srgb = 0x00000055, 98 astc10x6_unorm = 0x00000056, 99 astc10x6_unorm_srgb = 0x00000057, 100 astc10x8_unorm = 0x00000058, 101 astc10x8_unorm_srgb = 0x00000059, 102 astc10x10_unorm = 0x0000005A, 103 astc10x10_unorm_srgb = 0x0000005B, 104 astc12x10_unorm = 0x0000005C, 105 astc12x10_unorm_srgb = 0x0000005D, 106 astc12x12_unorm = 0x0000005E, 107 astc12x12_unorm_srgb = 0x0000005F, 108 }; 109 110 pub const Usage = packed struct(u64) { 111 copy_src: bool = false, 112 copy_dst: bool = false, 113 texture_binding: bool = false, 114 storage_binding: bool = false, 115 render_attachment: bool = false, 116 _padding: u59 = 0, 117 }; 118 119 pub const SampleType = enum(u32) { 120 binding_not_used = 0x00000000, 121 undefined = 0x00000001, 122 float = 0x00000002, 123 unfilterable_float = 0x00000003, 124 depth = 0x00000004, 125 sint = 0x00000005, 126 uint = 0x00000006, 127 }; 128 129 pub fn createView( 130 texture: *Texture, 131 descriptor: *const TextureView.Descriptor, 132 ) ?*TextureView { 133 return @ptrCast( 134 c.wgpuTextureCreateView(@ptrCast(texture), @ptrCast(descriptor)), 135 ); 136 } 137 138 pub fn release(texture: *Texture) void { 139 c.wgpuTextureRelease(@ptrCast(texture)); 140 } 141 };