ci skip; start of update to zig 0.16
This commit is contained in:
@@ -177,7 +177,7 @@ pub fn blitImage(interface: *Interface, src: *base.Image, _: vk.ImageLayout, dst
|
||||
|
||||
pub fn execute(impl: *const Impl, device: *ExecutionDevice) VkError!void {
|
||||
for (impl.regions[0..]) |region| {
|
||||
try device.blitter.blitRegion(impl.src, impl.dst, region);
|
||||
try device.blitter.blitRegion(impl.src, impl.dst, region, impl.filter);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -14,6 +14,8 @@ pub const Interface = base.DescriptorPool;
|
||||
|
||||
interface: Interface,
|
||||
|
||||
list: std.ArrayList(*SoftDescriptorSet),
|
||||
|
||||
pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const vk.DescriptorPoolCreateInfo) VkError!*Self {
|
||||
const self = allocator.create(Self) catch return VkError.OutOfHostMemory;
|
||||
errdefer allocator.destroy(self);
|
||||
@@ -24,27 +26,48 @@ pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const v
|
||||
.allocateDescriptorSet = allocateDescriptorSet,
|
||||
.destroy = destroy,
|
||||
.freeDescriptorSet = freeDescriptorSet,
|
||||
.reset = reset,
|
||||
};
|
||||
|
||||
self.* = .{
|
||||
.interface = interface,
|
||||
.list = std.ArrayList(*SoftDescriptorSet).initCapacity(allocator, info.max_sets) catch return VkError.OutOfHostMemory,
|
||||
};
|
||||
return self;
|
||||
}
|
||||
|
||||
pub fn allocateDescriptorSet(interface: *Interface, layout: *base.DescriptorSetLayout) VkError!*base.DescriptorSet {
|
||||
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
|
||||
const allocator = VulkanAllocator.init(null, .object).allocator();
|
||||
const set = try SoftDescriptorSet.create(interface.owner, allocator, layout);
|
||||
self.list.appendAssumeCapacity(set);
|
||||
return &set.interface;
|
||||
}
|
||||
|
||||
pub fn destroy(interface: *Interface, allocator: std.mem.Allocator) void {
|
||||
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
|
||||
self.list.deinit(allocator);
|
||||
allocator.destroy(self);
|
||||
}
|
||||
|
||||
pub fn freeDescriptorSet(interface: *Interface, set: *base.DescriptorSet) VkError!void {
|
||||
_ = interface;
|
||||
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
|
||||
const soft_set: *SoftDescriptorSet = @alignCast(@fieldParentPtr("interface", set));
|
||||
|
||||
if (std.mem.indexOfScalar(*SoftDescriptorSet, self.list.items, soft_set)) |pos| {
|
||||
_ = self.list.orderedRemove(pos);
|
||||
}
|
||||
|
||||
const allocator = VulkanAllocator.init(null, .object).allocator();
|
||||
allocator.destroy(set);
|
||||
allocator.destroy(soft_set);
|
||||
}
|
||||
|
||||
pub fn reset(interface: *Interface, _: vk.DescriptorPoolResetFlags) VkError!void {
|
||||
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
|
||||
const allocator = VulkanAllocator.init(null, .object).allocator();
|
||||
|
||||
for (self.list.items) |set| {
|
||||
allocator.destroy(set);
|
||||
}
|
||||
self.list.clearRetainingCapacity();
|
||||
}
|
||||
|
||||
+121
-4
@@ -101,8 +101,125 @@ fn fastClear(self: *Self, clear_value: vk.ClearValue, clear_format: vk.Format, d
|
||||
return false;
|
||||
}
|
||||
|
||||
pub fn blitRegion(_: *Self, src: *const SoftImage, dst: *SoftImage, region: vk.ImageBlit) VkError!void {
|
||||
_ = src;
|
||||
_ = dst;
|
||||
_ = region;
|
||||
pub fn blitRegion(_: *Self, src: *const SoftImage, dst: *SoftImage, region: vk.ImageBlit, filter: vk.Filter) VkError!void {
|
||||
var dst_offset_0 = region.dst_offsets[0];
|
||||
var dst_offset_1 = region.dst_offsets[1];
|
||||
var src_offset_0 = region.src_offsets[0];
|
||||
var src_offset_1 = region.src_offsets[1];
|
||||
|
||||
if (dst_offset_0.x > dst_offset_1.x) {
|
||||
std.mem.swap(i32, &src_offset_0.x, &src_offset_1.x);
|
||||
std.mem.swap(i32, &dst_offset_0.x, &dst_offset_1.x);
|
||||
}
|
||||
|
||||
if (dst_offset_0.y > dst_offset_1.y) {
|
||||
std.mem.swap(i32, &src_offset_0.y, &src_offset_1.y);
|
||||
std.mem.swap(i32, &dst_offset_0.y, &dst_offset_1.y);
|
||||
}
|
||||
|
||||
if (dst_offset_0.z > dst_offset_1.z) {
|
||||
std.mem.swap(i32, &src_offset_0.z, &src_offset_1.z);
|
||||
std.mem.swap(i32, &dst_offset_0.z, &dst_offset_1.z);
|
||||
}
|
||||
|
||||
const src_extent = src.getMipLevelExtent(region.src_subresource.mip_level);
|
||||
|
||||
_ = src_extent;
|
||||
|
||||
const width_ratio = @as(f32, @floatFromInt(src_offset_1.x - src_offset_0.x)) / @as(f32, @floatFromInt(dst_offset_1.x - dst_offset_0.x));
|
||||
const height_ratio = @as(f32, @floatFromInt(src_offset_1.y - src_offset_0.y)) / @as(f32, @floatFromInt(dst_offset_1.y - dst_offset_0.y));
|
||||
const depth_ratio = @as(f32, @floatFromInt(src_offset_1.z - src_offset_0.z)) / @as(f32, @floatFromInt(dst_offset_1.z - dst_offset_0.z));
|
||||
const x0 = @as(f32, @floatFromInt(src_offset_0.x)) + (0.5 - @as(f32, @floatFromInt(dst_offset_0.x))) * width_ratio;
|
||||
const y0 = @as(f32, @floatFromInt(src_offset_0.y)) + (0.5 - @as(f32, @floatFromInt(dst_offset_0.y))) * height_ratio;
|
||||
const z0 = @as(f32, @floatFromInt(src_offset_0.z)) + (0.5 - @as(f32, @floatFromInt(dst_offset_0.z))) * depth_ratio;
|
||||
|
||||
_ = x0;
|
||||
_ = y0;
|
||||
_ = z0;
|
||||
|
||||
const src_format = base.format.fromAspect(src.interface.format, region.src_subresource.aspect_mask);
|
||||
const dst_format = base.format.fromAspect(dst.interface.format, region.dst_subresource.aspect_mask);
|
||||
|
||||
const apply_filter = (filter != .nearest);
|
||||
const allow_srgb_conversion = apply_filter or base.format.isSrgb(src_format) != base.format.isSrgb(dst_format);
|
||||
|
||||
_ = allow_srgb_conversion;
|
||||
}
|
||||
|
||||
// State state(srcFormat, dstFormat, src->getSampleCount(), dst->getSampleCount(),
|
||||
// Options{ doFilter, allowSRGBConversion });
|
||||
// state.clampToEdge = (region.srcOffsets[0].x < 0) ||
|
||||
// (region.srcOffsets[0].y < 0) ||
|
||||
// (static_cast<uint32_t>(region.srcOffsets[1].x) > srcExtent.width) ||
|
||||
// (static_cast<uint32_t>(region.srcOffsets[1].y) > srcExtent.height) ||
|
||||
// (doFilter && ((x0 < 0.5f) || (y0 < 0.5f)));
|
||||
// state.filter3D = (region.srcOffsets[1].z - region.srcOffsets[0].z) !=
|
||||
// (region.dstOffsets[1].z - region.dstOffsets[0].z);
|
||||
//
|
||||
// auto blitRoutine = getBlitRoutine(state);
|
||||
// if(!blitRoutine)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// BlitData data = {
|
||||
// nullptr, // source
|
||||
// nullptr, // dest
|
||||
// assert_cast<uint32_t>(src->rowPitchBytes(srcAspect, region.srcSubresource.mipLevel)), // sPitchB
|
||||
// assert_cast<uint32_t>(dst->rowPitchBytes(dstAspect, region.dstSubresource.mipLevel)), // dPitchB
|
||||
// assert_cast<uint32_t>(src->slicePitchBytes(srcAspect, region.srcSubresource.mipLevel)), // sSliceB
|
||||
// assert_cast<uint32_t>(dst->slicePitchBytes(dstAspect, region.dstSubresource.mipLevel)), // dSliceB
|
||||
//
|
||||
// x0,
|
||||
// y0,
|
||||
// z0,
|
||||
// widthRatio,
|
||||
// heightRatio,
|
||||
// depthRatio,
|
||||
//
|
||||
// region.dstOffsets[0].x, // x0d
|
||||
// region.dstOffsets[1].x, // x1d
|
||||
// region.dstOffsets[0].y, // y0d
|
||||
// region.dstOffsets[1].y, // y1d
|
||||
// region.dstOffsets[0].z, // z0d
|
||||
// region.dstOffsets[1].z, // z1d
|
||||
//
|
||||
// static_cast<int>(srcExtent.width), // sWidth
|
||||
// static_cast<int>(srcExtent.height), // sHeight
|
||||
// static_cast<int>(srcExtent.depth), // sDepth
|
||||
//
|
||||
// false, // filter3D
|
||||
// };
|
||||
//
|
||||
// VkImageSubresource srcSubres = {
|
||||
// region.srcSubresource.aspectMask,
|
||||
// region.srcSubresource.mipLevel,
|
||||
// region.srcSubresource.baseArrayLayer
|
||||
// };
|
||||
//
|
||||
// VkImageSubresource dstSubres = {
|
||||
// region.dstSubresource.aspectMask,
|
||||
// region.dstSubresource.mipLevel,
|
||||
// region.dstSubresource.baseArrayLayer
|
||||
// };
|
||||
//
|
||||
// VkImageSubresourceRange dstSubresRange = {
|
||||
// region.dstSubresource.aspectMask,
|
||||
// region.dstSubresource.mipLevel,
|
||||
// 1, // levelCount
|
||||
// region.dstSubresource.baseArrayLayer,
|
||||
// region.dstSubresource.layerCount
|
||||
// };
|
||||
//
|
||||
// uint32_t lastLayer = src->getLastLayerIndex(dstSubresRange);
|
||||
//
|
||||
// for(; dstSubres.arrayLayer <= lastLayer; srcSubres.arrayLayer++, dstSubres.arrayLayer++)
|
||||
// {
|
||||
// data.source = src->getTexelPointer({ 0, 0, 0 }, srcSubres);
|
||||
// data.dest = dst->getTexelPointer({ 0, 0, 0 }, dstSubres);
|
||||
//
|
||||
// ASSERT(data.source < src->end());
|
||||
// ASSERT(data.dest < dst->end());
|
||||
//
|
||||
// blitRoutine(&data);
|
||||
// }
|
||||
|
||||
@@ -21,6 +21,7 @@ pub const VTable = struct {
|
||||
allocateDescriptorSet: *const fn (*Self, *DescriptorSetLayout) VkError!*DescriptorSet,
|
||||
destroy: *const fn (*Self, std.mem.Allocator) void,
|
||||
freeDescriptorSet: *const fn (*Self, *DescriptorSet) VkError!void,
|
||||
reset: *const fn (*Self, vk.DescriptorPoolResetFlags) VkError!void,
|
||||
};
|
||||
|
||||
pub fn init(device: *Device, allocator: std.mem.Allocator, info: *const vk.DescriptorPoolCreateInfo) VkError!Self {
|
||||
@@ -43,3 +44,7 @@ pub inline fn destroy(self: *Self, allocator: std.mem.Allocator) void {
|
||||
pub inline fn freeDescriptorSet(self: *Self, set: *DescriptorSet) VkError!void {
|
||||
try self.vtable.freeDescriptorSet(self, set);
|
||||
}
|
||||
|
||||
pub inline fn reset(self: *Self, flags: vk.DescriptorPoolResetFlags) VkError!void {
|
||||
try self.vtable.reset(self, flags);
|
||||
}
|
||||
|
||||
@@ -72,15 +72,6 @@ pub inline fn getMemoryRequirements(self: *Self, requirements: *vk.MemoryRequire
|
||||
try self.vtable.getMemoryRequirements(self, requirements);
|
||||
}
|
||||
|
||||
pub inline fn getClearFormat(self: *Self) vk.Format {
|
||||
return if (lib.vku.vkuFormatIsSINT(@intCast(@intFromEnum(self.format))))
|
||||
.r32g32b32a32_sint
|
||||
else if (lib.vku.vkuFormatIsUINT(@intCast(@intFromEnum(self.format))))
|
||||
.r32g32b32a32_uint
|
||||
else
|
||||
.r32g32b32a32_sfloat;
|
||||
}
|
||||
|
||||
pub inline fn getTexelSize(self: *const Self) usize {
|
||||
return lib.format.texelSize(self.format);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const vk = @import("vulkan");
|
||||
const config = @import("config");
|
||||
|
||||
const logger = @import("lib.zig").logger;
|
||||
|
||||
@@ -21,7 +22,15 @@ comptime {
|
||||
const Self = @This();
|
||||
pub const ObjectType: vk.ObjectType = .instance;
|
||||
|
||||
const DeviceAllocator = struct {
|
||||
pub inline fn allocator(_: @This()) std.mem.Allocator {
|
||||
return std.heap.smp_allocator;
|
||||
}
|
||||
};
|
||||
|
||||
physical_devices: std.ArrayList(*Dispatchable(PhysicalDevice)),
|
||||
threaded: std.Io.Threaded,
|
||||
allocator: if (config.debug_allocator) std.heap.DebugAllocator(.{}) else DeviceAllocator,
|
||||
dispatch_table: *const DispatchTable,
|
||||
vtable: *const VTable,
|
||||
|
||||
|
||||
@@ -90,3 +90,31 @@ pub inline fn sliceMemSize(format: vk.Format, width: usize, height: usize) usize
|
||||
pub inline fn isDepthAndStencil(format: vk.Format) bool {
|
||||
return lib.vku.vkuFormatIsDepthAndStencil(@intCast(@intFromEnum(format)));
|
||||
}
|
||||
|
||||
pub inline fn isSrgb(format: vk.Format) bool {
|
||||
return lib.vku.vkuFormatIsSRGB(@intCast(@intFromEnum(format)));
|
||||
}
|
||||
|
||||
pub inline fn isSfloat(format: vk.Format) bool {
|
||||
return lib.vku.vkuFormatIsSFLOAT(@intCast(@intFromEnum(format)));
|
||||
}
|
||||
|
||||
pub inline fn isSint(format: vk.Format) bool {
|
||||
return lib.vku.vkuFormatIsSINT(@intCast(@intFromEnum(format)));
|
||||
}
|
||||
|
||||
pub inline fn isSnorm(format: vk.Format) bool {
|
||||
return lib.vku.vkuFormatIsSNORM(@intCast(@intFromEnum(format)));
|
||||
}
|
||||
|
||||
pub inline fn isUfloat(format: vk.Format) bool {
|
||||
return lib.vku.vkuFormatIsUFLOAT(@intCast(@intFromEnum(format)));
|
||||
}
|
||||
|
||||
pub inline fn isUint(format: vk.Format) bool {
|
||||
return lib.vku.vkuFormatIsUINT(@intCast(@intFromEnum(format)));
|
||||
}
|
||||
|
||||
pub inline fn isUnorm(format: vk.Format) bool {
|
||||
return lib.vku.vkuFormatIsUNORM(@intCast(@intFromEnum(format)));
|
||||
}
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ pub const LogVerboseLevel = enum {
|
||||
TooMuch,
|
||||
};
|
||||
|
||||
pub inline fn getLogVerboseLevel() LogVerboseLevel {
|
||||
pub fn getLogVerboseLevel() LogVerboseLevel {
|
||||
const allocator = std.heap.c_allocator;
|
||||
const level = std.process.getEnvVarOwned(allocator, DRIVER_LOGS_ENV_NAME) catch return .None;
|
||||
defer allocator.free(level);
|
||||
|
||||
@@ -1517,28 +1517,18 @@ pub export fn strollResetCommandPool(p_device: vk.Device, p_pool: vk.CommandPool
|
||||
|
||||
Dispatchable(Device).checkHandleValidity(p_device) catch |err| return toVkResult(err);
|
||||
const pool = NonDispatchable(CommandPool).fromHandleObject(p_pool) catch |err| return toVkResult(err);
|
||||
|
||||
notImplementedWarning();
|
||||
|
||||
_ = pool;
|
||||
_ = flags;
|
||||
|
||||
return .error_unknown;
|
||||
pool.reset(flags) catch |err| return toVkResult(err);
|
||||
return .success;
|
||||
}
|
||||
|
||||
pub export fn strollResetDescriptorPool(p_device: vk.Device, p_pool: vk.DescriptorPool, flags: vk.CommandPoolResetFlags) callconv(vk.vulkan_call_conv) vk.Result {
|
||||
pub export fn strollResetDescriptorPool(p_device: vk.Device, p_pool: vk.DescriptorPool, flags: vk.DescriptorPoolResetFlags) callconv(vk.vulkan_call_conv) vk.Result {
|
||||
entryPointBeginLogTrace(.vkResetDescriptorPool);
|
||||
defer entryPointEndLogTrace();
|
||||
|
||||
Dispatchable(Device).checkHandleValidity(p_device) catch |err| return toVkResult(err);
|
||||
const pool = NonDispatchable(DescriptorPool).fromHandleObject(p_pool) catch |err| return toVkResult(err);
|
||||
|
||||
notImplementedWarning();
|
||||
|
||||
_ = pool;
|
||||
_ = flags;
|
||||
|
||||
return .error_unknown;
|
||||
pool.reset(flags) catch |err| return toVkResult(err);
|
||||
return .success;
|
||||
}
|
||||
|
||||
pub export fn strollResetEvent(p_device: vk.Device, p_event: vk.Fence) callconv(vk.vulkan_call_conv) vk.Result {
|
||||
|
||||
@@ -4,14 +4,18 @@ const Manager = @import("Manager.zig");
|
||||
const Self = @This();
|
||||
|
||||
managers: std.AutoArrayHashMapUnmanaged(std.Thread.Id, Manager),
|
||||
allocator: std.heap.ThreadSafeAllocator,
|
||||
mutex: std.Thread.Mutex,
|
||||
allocator: std.mem.Allocator,
|
||||
mutex: std.Io.Mutex,
|
||||
io: std.Io,
|
||||
|
||||
pub const init: Self = .{
|
||||
.managers = .empty,
|
||||
.allocator = .{ .child_allocator = std.heap.c_allocator },
|
||||
.mutex = .{},
|
||||
};
|
||||
pub fn init(io: std.Io, allocator: std.mem.Allocator) Self {
|
||||
return .{
|
||||
.managers = .empty,
|
||||
.allocator = allocator,
|
||||
.mutex = .init,
|
||||
.io = io,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn get(self: *Self) *Manager {
|
||||
const allocator = self.allocator.allocator();
|
||||
@@ -23,17 +27,14 @@ pub fn get(self: *Self) *Manager {
|
||||
}
|
||||
|
||||
pub fn deinit(self: *Self) void {
|
||||
{
|
||||
self.mutex.lock();
|
||||
defer self.mutex.unlock();
|
||||
self.mutex.lockUncancelable();
|
||||
defer self.mutex.unlock();
|
||||
|
||||
if (self.managers.getPtr(std.Thread.getCurrentId())) |manager| {
|
||||
manager.deinit();
|
||||
_ = self.managers.orderedRemove(std.Thread.getCurrentId());
|
||||
}
|
||||
if (self.managers.getPtr(std.Thread.getCurrentId())) |manager| {
|
||||
manager.deinit();
|
||||
_ = self.managers.orderedRemove(std.Thread.getCurrentId());
|
||||
}
|
||||
if (self.managers.count() == 0) {
|
||||
self.managers.deinit(self.allocator.allocator());
|
||||
self.* = .init;
|
||||
self.managers.deinit(self.allocator);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const zdt = @import("zdt");
|
||||
const root = @import("root");
|
||||
const lib = @import("../lib.zig");
|
||||
|
||||
@@ -39,7 +38,7 @@ pub inline fn nestedFixme(comptime format: []const u8, args: anytype) void {
|
||||
std.log.scoped(.FIXME).warn("FIXME: " ++ format, args);
|
||||
}
|
||||
|
||||
pub fn log(comptime level: std.log.Level, comptime scope: @Type(.enum_literal), comptime format: []const u8, args: anytype) void {
|
||||
pub fn log(comptime level: std.log.Level, comptime scope: @EnumLiteral(), comptime format: []const u8, args: anytype) void {
|
||||
if (lib.getLogVerboseLevel() == .None) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user