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);
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user