adding VK_KHR_get_physical_device_properties2 and bug fixes

This commit is contained in:
2025-12-17 17:39:20 +01:00
parent 48af5e31f0
commit 64af182ecc
13 changed files with 290 additions and 72 deletions

View File

@@ -89,11 +89,13 @@ pub fn copyBuffer(interface: *Interface, src: *base.Buffer, dst: *base.Buffer, r
_ = regions;
}
pub fn copyImage(interface: *Interface, src: *base.Image, dst: *base.Image, regions: []const vk.ImageCopy) VkError!void {
pub fn copyImage(interface: *Interface, src: *base.Image, src_layout: vk.ImageLayout, dst: *base.Image, dst_layout: vk.ImageLayout, regions: []const vk.ImageCopy) VkError!void {
// No-op
_ = interface;
_ = src;
_ = src_layout;
_ = dst;
_ = dst_layout;
_ = regions;
}

View File

@@ -12,13 +12,26 @@ pub const Interface = base.Instance;
interface: Interface,
fn castExtension(comptime ext: vk.ApiInfo) vk.ExtensionProperties {
var props: vk.ExtensionProperties = .{
.extension_name = undefined,
.spec_version = @bitCast(ext.version),
};
@memcpy(props.extension_name[0..ext.name.len], ext.name);
return props;
}
pub const EXTENSIONS = [_]vk.ExtensionProperties{
castExtension(vk.extensions.khr_get_physical_device_properties_2),
};
pub fn create(allocator: std.mem.Allocator, infos: *const vk.InstanceCreateInfo) VkError!*Interface {
const self = allocator.create(Self) catch return VkError.OutOfHostMemory;
errdefer allocator.destroy(self);
self.interface = try base.Instance.init(allocator, infos);
self.interface.dispatch_table = &.{
.destroyInstance = destroyInstance,
.destroy = destroy,
};
self.interface.vtable = &.{
.requestPhysicalDevices = requestPhysicalDevices,
@@ -27,6 +40,11 @@ pub fn create(allocator: std.mem.Allocator, infos: *const vk.InstanceCreateInfo)
return &self.interface;
}
fn destroy(interface: *Interface, allocator: std.mem.Allocator) VkError!void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
allocator.destroy(self);
}
fn requestPhysicalDevices(interface: *Interface, allocator: std.mem.Allocator) VkError!void {
// Software driver has only one physical device (the CPU)
const physical_device = try SoftPhysicalDevice.create(allocator, interface);
@@ -42,8 +60,3 @@ fn releasePhysicalDevices(interface: *Interface, allocator: std.mem.Allocator) V
interface.physical_devices.deinit(allocator);
interface.physical_devices = .empty;
}
fn destroyInstance(interface: *Interface, allocator: std.mem.Allocator) VkError!void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
allocator.destroy(self);
}

View File

@@ -30,6 +30,7 @@ pub fn create(allocator: std.mem.Allocator, instance: *const base.Instance) VkEr
.getFormatProperties = getFormatProperties,
.getImageFormatProperties = getImageFormatProperties,
.getSparseImageFormatProperties = getSparseImageFormatProperties,
.getSparseImageFormatProperties2 = getSparseImageFormatProperties2,
.release = destroy,
};
@@ -670,6 +671,7 @@ pub fn getImageFormatProperties(
};
}
/// Soft does not support sparse images.
pub fn getSparseImageFormatProperties(
interface: *Interface,
format: vk.Format,
@@ -677,14 +679,34 @@ pub fn getSparseImageFormatProperties(
samples: vk.SampleCountFlags,
tiling: vk.ImageTiling,
usage: vk.ImageUsageFlags,
flags: vk.ImageCreateFlags,
) VkError!vk.SparseImageFormatProperties {
properties: ?[*]vk.SparseImageFormatProperties,
) VkError!u32 {
_ = interface;
_ = format;
_ = image_type;
_ = samples;
_ = tiling;
_ = usage;
_ = flags;
return undefined;
_ = properties;
return 0;
}
/// Soft does not support sparse images.
pub fn getSparseImageFormatProperties2(
interface: *Interface,
format: vk.Format,
image_type: vk.ImageType,
samples: vk.SampleCountFlags,
tiling: vk.ImageTiling,
usage: vk.ImageUsageFlags,
properties: ?[*]vk.SparseImageFormatProperties2,
) VkError!u32 {
_ = interface;
_ = format;
_ = image_type;
_ = samples;
_ = tiling;
_ = usage;
_ = properties;
return 0;
}