gpu: implement ExternalTexture
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
88e1894fbd
commit
616b1529f2
4 changed files with 52 additions and 11 deletions
28
gpu/src/ExternalTexture.zig
Normal file
28
gpu/src/ExternalTexture.zig
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
const ExternalTexture = @This();
|
||||
|
||||
/// The type erased pointer to the ExternalTexture implementation
|
||||
/// Equal to c.WGPUExternalTexture for NativeInstance.
|
||||
ptr: *anyopaque,
|
||||
vtable: *const VTable,
|
||||
|
||||
pub const VTable = struct {
|
||||
reference: fn (ptr: *anyopaque) void,
|
||||
release: fn (ptr: *anyopaque) void,
|
||||
// TODO:
|
||||
// WGPU_EXPORT void wgpuExternalTextureDestroy(WGPUExternalTexture externalTexture);
|
||||
// WGPU_EXPORT void wgpuExternalTextureSetLabel(WGPUExternalTexture externalTexture, char const * label);
|
||||
};
|
||||
|
||||
pub inline fn reference(texture: ExternalTexture) void {
|
||||
texture.vtable.reference(texture.ptr);
|
||||
}
|
||||
|
||||
pub inline fn release(texture: ExternalTexture) void {
|
||||
texture.vtable.release(texture.ptr);
|
||||
}
|
||||
|
||||
test "syntax" {
|
||||
_ = VTable;
|
||||
_ = reference;
|
||||
_ = release;
|
||||
}
|
||||
|
|
@ -29,6 +29,7 @@ const RenderBundleEncoder = @import("RenderBundleEncoder.zig");
|
|||
const RenderBundle = @import("RenderBundle.zig");
|
||||
const QuerySet = @import("QuerySet.zig");
|
||||
const PipelineLayout = @import("PipelineLayout.zig");
|
||||
const ExternalTexture = @import("ExternalTexture.zig");
|
||||
|
||||
const TextureUsage = @import("enums.zig").TextureUsage;
|
||||
const TextureFormat = @import("enums.zig").TextureFormat;
|
||||
|
|
@ -686,6 +687,26 @@ const pipeline_layout_vtable = PipelineLayout.VTable{
|
|||
}).release,
|
||||
};
|
||||
|
||||
fn wrapExternalTexture(texture: c.WGPUExternalTexture) ExternalTexture {
|
||||
return .{
|
||||
.ptr = texture.?,
|
||||
.vtable = &external_texture_vtable,
|
||||
};
|
||||
}
|
||||
|
||||
const external_texture_vtable = ExternalTexture.VTable{
|
||||
.reference = (struct {
|
||||
pub fn reference(ptr: *anyopaque) void {
|
||||
c.wgpuExternalTextureReference(@ptrCast(c.WGPUExternalTexture, ptr));
|
||||
}
|
||||
}).reference,
|
||||
.release = (struct {
|
||||
pub fn release(ptr: *anyopaque) void {
|
||||
c.wgpuExternalTextureRelease(@ptrCast(c.WGPUExternalTexture, ptr));
|
||||
}
|
||||
}).release,
|
||||
};
|
||||
|
||||
test "syntax" {
|
||||
_ = wrap;
|
||||
_ = interface_vtable;
|
||||
|
|
@ -708,4 +729,5 @@ test "syntax" {
|
|||
_ = wrapRenderBundle;
|
||||
_ = wrapQuerySet;
|
||||
_ = wrapPipelineLayout;
|
||||
_ = wrapExternalTexture;
|
||||
}
|
||||
|
|
|
|||
11
gpu/src/TODO
11
gpu/src/TODO
|
|
@ -593,17 +593,6 @@ WGPU_EXPORT void wgpuComputePipelineSetLabel(WGPUComputePipeline computePipeline
|
|||
WGPU_EXPORT void wgpuComputePipelineReference(WGPUComputePipeline computePipeline);
|
||||
WGPU_EXPORT void wgpuComputePipelineRelease(WGPUComputePipeline computePipeline);
|
||||
|
||||
// Methods of ExternalTexture
|
||||
WGPU_EXPORT void wgpuExternalTextureDestroy(WGPUExternalTexture externalTexture);
|
||||
WGPU_EXPORT void wgpuExternalTextureSetLabel(WGPUExternalTexture externalTexture, char const * label);
|
||||
WGPU_EXPORT void wgpuExternalTextureReference(WGPUExternalTexture externalTexture);
|
||||
WGPU_EXPORT void wgpuExternalTextureRelease(WGPUExternalTexture externalTexture);
|
||||
|
||||
// Methods of PipelineLayout
|
||||
WGPU_EXPORT void wgpuPipelineLayoutSetLabel(WGPUPipelineLayout pipelineLayout, char const * label);
|
||||
WGPU_EXPORT void wgpuPipelineLayoutReference(WGPUPipelineLayout pipelineLayout);
|
||||
WGPU_EXPORT void wgpuPipelineLayoutRelease(WGPUPipelineLayout pipelineLayout);
|
||||
|
||||
typedef enum WGPUSType {
|
||||
// webgpu.h upstream:
|
||||
WGPUSType_Invalid = 0x00000000,
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ pub const RenderBundleEncoder = @import("RenderBundleEncoder.zig");
|
|||
pub const RenderBundle = @import("RenderBundle.zig");
|
||||
pub const QuerySet = @import("QuerySet.zig");
|
||||
pub const PipelineLayout = @import("PipelineLayout.zig");
|
||||
pub const ExternalTexture = @import("ExternalTexture.zig");
|
||||
|
||||
pub const Feature = @import("enums.zig").Feature;
|
||||
pub const TextureUsage = @import("enums.zig").TextureUsage;
|
||||
|
|
@ -112,6 +113,7 @@ test "syntax" {
|
|||
_ = RenderBundle;
|
||||
_ = QuerySet;
|
||||
_ = PipelineLayout;
|
||||
_ = ExternalTexture;
|
||||
|
||||
_ = Feature;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue