fixing crashes
Test / build_and_test (push) Successful in 49s
Build / build (push) Successful in 1m28s

This commit is contained in:
2026-05-17 01:58:20 +02:00
parent 134925a16e
commit 3c9a864240
9 changed files with 292 additions and 97 deletions
+63 -7
View File
@@ -5,9 +5,11 @@ const base = @import("base");
const VkError = base.VkError;
const Device = base.Device;
const Buffer = base.Buffer;
const BufferView = base.BufferView;
const ImageView = base.ImageView;
const SoftBuffer = @import("SoftBuffer.zig");
const SoftBufferView = @import("SoftBufferView.zig");
const SoftImageView = @import("SoftImageView.zig");
const SoftSampler = @import("SoftSampler.zig");
@@ -31,10 +33,15 @@ const DescriptorImage = struct {
object: ?*SoftImageView,
};
const DescriptorTexel = struct {
object: ?*SoftBufferView,
};
const Descriptor = union(enum) {
buffer: []DescriptorBuffer,
texture: []DescriptorTexture,
image: []DescriptorImage,
texel_buffer: []DescriptorTexel,
unsupported: struct {},
};
@@ -61,8 +68,16 @@ pub fn create(device: *base.Device, allocator: std.mem.Allocator, layout: *base.
var size: usize = layout.bindings.len * @sizeOf(Descriptor);
for (layout.bindings) |binding| {
const struct_size: usize = switch (binding.descriptor_type) {
.storage_buffer, .storage_buffer_dynamic => @sizeOf(DescriptorBuffer),
.storage_image, .input_attachment => @sizeOf(DescriptorImage),
.uniform_buffer,
.storage_buffer,
.storage_buffer_dynamic,
=> @sizeOf(DescriptorBuffer),
.storage_image,
.input_attachment,
=> @sizeOf(DescriptorImage),
.storage_texel_buffer,
.uniform_texel_buffer,
=> @sizeOf(DescriptorTexel),
else => 0,
};
@@ -80,12 +95,22 @@ pub fn create(device: *base.Device, allocator: std.mem.Allocator, layout: *base.
const descriptors = local_allocator.alloc(Descriptor, layout.bindings.len) catch return VkError.OutOfHostMemory;
for (descriptors, layout.bindings) |*descriptor, binding| {
switch (binding.descriptor_type) {
.storage_buffer, .storage_buffer_dynamic => descriptor.* = .{
.uniform_buffer,
.storage_buffer,
.storage_buffer_dynamic,
=> descriptor.* = .{
.buffer = local_allocator.alloc(DescriptorBuffer, binding.array_size) catch return VkError.OutOfHostMemory,
},
.storage_image, .input_attachment => descriptor.* = .{
.storage_image,
.input_attachment,
=> descriptor.* = .{
.image = local_allocator.alloc(DescriptorImage, binding.array_size) catch return VkError.OutOfHostMemory,
},
.storage_texel_buffer,
.uniform_texel_buffer,
=> descriptor.* = .{
.texel_buffer = local_allocator.alloc(DescriptorTexel, binding.array_size) catch return VkError.OutOfHostMemory,
},
else => {},
}
}
@@ -108,10 +133,24 @@ pub fn copy(interface: *Interface, src_interface: *const Interface, data: vk.Cop
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
const src: *const Self = @alignCast(@fieldParentPtr("interface", src_interface));
for (self.descriptors[data.dst_binding..(data.dst_binding + data.descriptor_count)], src.descriptors[data.src_binding..(data.src_binding + data.descriptor_count)]) |*dst_desc, src_desc| {
const dst_start = @min(@as(usize, @intCast(data.dst_binding)), self.descriptors.len);
const src_start = @min(@as(usize, @intCast(data.src_binding)), src.descriptors.len);
const descriptor_count: usize = @intCast(data.descriptor_count);
const dst_remaining = self.descriptors.len - dst_start;
const src_remaining = src.descriptors.len - src_start;
const copy_count = @min(descriptor_count, dst_remaining, src_remaining);
const dst_slice = self.descriptors[dst_start .. dst_start + copy_count];
const src_slice = src.descriptors[src_start .. src_start + copy_count];
for (dst_slice, src_slice) |*dst_desc, src_desc| {
switch (dst_desc.*) {
.buffer => |dst_buffer| @memcpy(dst_buffer[0..], src_desc.buffer[0..]),
.image => |dst_image| @memcpy(dst_image[0..], src_desc.image[0..]),
.texel_buffer => |dst_texel| @memcpy(dst_texel[0..], src_desc.texel_buffer[0..]),
else => {
dst_desc.* = .{ .unsupported = .{} };
base.unsupported("descriptor type for copy", .{});
@@ -124,7 +163,10 @@ pub fn write(interface: *Interface, write_data: vk.WriteDescriptorSet) VkError!v
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
switch (write_data.descriptor_type) {
.storage_buffer, .storage_buffer_dynamic => {
.uniform_buffer,
.storage_buffer,
.storage_buffer_dynamic,
=> {
for (write_data.p_buffer_info, 0..write_data.descriptor_count) |buffer_info, i| {
const desc = &self.descriptors[write_data.dst_binding].buffer[i];
desc.* = .{
@@ -141,7 +183,9 @@ pub fn write(interface: *Interface, write_data: vk.WriteDescriptorSet) VkError!v
}
}
},
.storage_image, .input_attachment => {
.storage_image,
.input_attachment,
=> {
for (write_data.p_image_info, 0..write_data.descriptor_count) |image_info, i| {
const desc = &self.descriptors[write_data.dst_binding].image[i];
desc.* = .{ .object = null };
@@ -151,6 +195,18 @@ pub fn write(interface: *Interface, write_data: vk.WriteDescriptorSet) VkError!v
}
}
},
.storage_texel_buffer,
.uniform_texel_buffer,
=> {
for (write_data.p_texel_buffer_view, 0..write_data.descriptor_count) |view, i| {
const desc = &self.descriptors[write_data.dst_binding].texel_buffer[i];
desc.* = .{ .object = null };
if (view != .null_handle) {
const buffer_view = try NonDispatchable(BufferView).fromHandleObject(view);
desc.object = @as(*SoftBufferView, @alignCast(@fieldParentPtr("interface", buffer_view)));
}
}
},
else => {
self.descriptors[write_data.dst_binding] = .{ .unsupported = .{} };
base.unsupported("descriptor type {s} for writting", .{@tagName(write_data.descriptor_type)});
-2
View File
@@ -2,8 +2,6 @@ const std = @import("std");
const vk = @import("vulkan");
const base = @import("base");
const lib = @import("lib.zig");
const VkError = base.VkError;
const Device = base.Device;
+104 -66
View File
@@ -3,6 +3,10 @@ const vk = @import("vulkan");
const base = @import("base");
const spv = @import("spv");
const zm = base.zm;
const blitter = @import("device/blitter.zig");
const Device = base.Device;
const VkError = base.VkError;
const SpvRuntimeError = spv.Runtime.RuntimeError;
@@ -11,6 +15,8 @@ const NonDispatchable = base.NonDispatchable;
const ShaderModule = base.ShaderModule;
const SoftDevice = @import("SoftDevice.zig");
const SoftBuffer = @import("SoftBuffer.zig");
const SoftBufferView = @import("SoftBufferView.zig");
const SoftImage = @import("SoftImage.zig");
const SoftImageView = @import("SoftImageView.zig");
const SoftInstance = @import("SoftInstance.zig");
@@ -245,22 +251,30 @@ pub fn destroy(interface: *Interface, allocator: std.mem.Allocator) void {
allocator.destroy(self);
}
fn readImageFloat4(context: *anyopaque, x: i32, y: i32, z: i32) SpvRuntimeError!spv.Runtime.Vec4(f32) {
const image_view: *SoftImageView = @ptrCast(@alignCast(context));
const image: *SoftImage = @alignCast(@fieldParentPtr("interface", image_view.interface.image));
const pixel = image.readFloat4(
.{
.x = x,
.y = y,
.z = z,
},
.{
.aspect_mask = image_view.interface.subresource_range.aspect_mask,
.mip_level = image_view.interface.subresource_range.base_mip_level,
.array_layer = image_view.interface.subresource_range.base_array_layer,
},
image_view.interface.format,
) catch return SpvRuntimeError.Unknown;
fn readImageFloat4(context: *anyopaque, dim: spv.SpvDim, x: i32, y: i32, z: i32) SpvRuntimeError!spv.Runtime.Vec4(f32) {
var pixel = zm.f32x4s(0.0);
if (dim == .Buffer) {
const buffer_view: *SoftBufferView = @ptrCast(@alignCast(context));
const buffer: *SoftBuffer = @alignCast(@fieldParentPtr("interface", buffer_view.interface.buffer));
const map = buffer.mapAsSliceWithOffset(u8, buffer_view.interface.offset, buffer_view.interface.range) catch return SpvRuntimeError.Unknown;
pixel = blitter.readFloat4(map[(@as(usize, @intCast(x)) * base.format.texelSize(buffer_view.interface.format))..], buffer_view.interface.format);
} else {
const image_view: *SoftImageView = @ptrCast(@alignCast(context));
const image: *SoftImage = @alignCast(@fieldParentPtr("interface", image_view.interface.image));
pixel = image.readFloat4(
.{
.x = x,
.y = y,
.z = z,
},
.{
.aspect_mask = image_view.interface.subresource_range.aspect_mask,
.mip_level = image_view.interface.subresource_range.base_mip_level,
.array_layer = image_view.interface.subresource_range.base_array_layer,
},
image_view.interface.format,
) catch return SpvRuntimeError.Unknown;
}
return .{
.x = pixel[0],
.y = pixel[1],
@@ -269,22 +283,30 @@ fn readImageFloat4(context: *anyopaque, x: i32, y: i32, z: i32) SpvRuntimeError!
};
}
fn readImageInt4(context: *anyopaque, x: i32, y: i32, z: i32) SpvRuntimeError!spv.Runtime.Vec4(u32) {
const image_view: *SoftImageView = @ptrCast(@alignCast(context));
const image: *SoftImage = @alignCast(@fieldParentPtr("interface", image_view.interface.image));
const pixel = image.readInt4(
.{
.x = x,
.y = y,
.z = z,
},
.{
.aspect_mask = image_view.interface.subresource_range.aspect_mask,
.mip_level = image_view.interface.subresource_range.base_mip_level,
.array_layer = image_view.interface.subresource_range.base_array_layer,
},
image_view.interface.format,
) catch return SpvRuntimeError.Unknown;
fn readImageInt4(context: *anyopaque, dim: spv.SpvDim, x: i32, y: i32, z: i32) SpvRuntimeError!spv.Runtime.Vec4(u32) {
var pixel = @Vector(4, u32){ 0, 0, 0, 0 };
if (dim == .Buffer) {
const buffer_view: *SoftBufferView = @ptrCast(@alignCast(context));
const buffer: *SoftBuffer = @alignCast(@fieldParentPtr("interface", buffer_view.interface.buffer));
const map = buffer.mapAsSliceWithOffset(u8, buffer_view.interface.offset, buffer_view.interface.range) catch return SpvRuntimeError.Unknown;
pixel = blitter.readInt4(map[(@as(usize, @intCast(x)) * base.format.texelSize(buffer_view.interface.format))..], buffer_view.interface.format);
} else {
const image_view: *SoftImageView = @ptrCast(@alignCast(context));
const image: *SoftImage = @alignCast(@fieldParentPtr("interface", image_view.interface.image));
pixel = image.readInt4(
.{
.x = x,
.y = y,
.z = z,
},
.{
.aspect_mask = image_view.interface.subresource_range.aspect_mask,
.mip_level = image_view.interface.subresource_range.base_mip_level,
.array_layer = image_view.interface.subresource_range.base_array_layer,
},
image_view.interface.format,
) catch return SpvRuntimeError.Unknown;
}
return .{
.x = pixel[0],
.y = pixel[1],
@@ -293,40 +315,56 @@ fn readImageInt4(context: *anyopaque, x: i32, y: i32, z: i32) SpvRuntimeError!sp
};
}
fn writeImageFloat4(context: *anyopaque, x: i32, y: i32, z: i32, pixel: spv.Runtime.Vec4(f32)) SpvRuntimeError!void {
const image_view: *SoftImageView = @ptrCast(@alignCast(context));
const image: *SoftImage = @alignCast(@fieldParentPtr("interface", image_view.interface.image));
image.writeFloat4(
.{
.x = x,
.y = y,
.z = z,
},
.{
.aspect_mask = image_view.interface.subresource_range.aspect_mask,
.mip_level = image_view.interface.subresource_range.base_mip_level,
.array_layer = image_view.interface.subresource_range.base_array_layer,
},
image_view.interface.format,
.{ pixel.x, pixel.y, pixel.z, pixel.w },
) catch return SpvRuntimeError.Unknown;
fn writeImageFloat4(context: *anyopaque, dim: spv.SpvDim, x: i32, y: i32, z: i32, pixel: spv.Runtime.Vec4(f32)) SpvRuntimeError!void {
const vec_pixel = zm.f32x4(pixel.x, pixel.y, pixel.z, pixel.w);
if (dim == .Buffer) {
const buffer_view: *SoftBufferView = @ptrCast(@alignCast(context));
const buffer: *SoftBuffer = @alignCast(@fieldParentPtr("interface", buffer_view.interface.buffer));
const map = buffer.mapAsSliceWithOffset(u8, buffer_view.interface.offset, buffer_view.interface.range) catch return SpvRuntimeError.Unknown;
blitter.writeFloat4(vec_pixel, map[(@as(usize, @intCast(x)) * base.format.texelSize(buffer_view.interface.format))..], buffer_view.interface.format);
} else {
const image_view: *SoftImageView = @ptrCast(@alignCast(context));
const image: *SoftImage = @alignCast(@fieldParentPtr("interface", image_view.interface.image));
image.writeFloat4(
.{
.x = x,
.y = y,
.z = z,
},
.{
.aspect_mask = image_view.interface.subresource_range.aspect_mask,
.mip_level = image_view.interface.subresource_range.base_mip_level,
.array_layer = image_view.interface.subresource_range.base_array_layer,
},
image_view.interface.format,
vec_pixel,
) catch return SpvRuntimeError.Unknown;
}
}
fn writeImageInt4(context: *anyopaque, x: i32, y: i32, z: i32, pixel: spv.Runtime.Vec4(u32)) SpvRuntimeError!void {
const image_view: *SoftImageView = @ptrCast(@alignCast(context));
const image: *SoftImage = @alignCast(@fieldParentPtr("interface", image_view.interface.image));
image.writeInt4(
.{
.x = x,
.y = y,
.z = z,
},
.{
.aspect_mask = image_view.interface.subresource_range.aspect_mask,
.mip_level = image_view.interface.subresource_range.base_mip_level,
.array_layer = image_view.interface.subresource_range.base_array_layer,
},
image_view.interface.format,
.{ pixel.x, pixel.y, pixel.z, pixel.w },
) catch return SpvRuntimeError.Unknown;
fn writeImageInt4(context: *anyopaque, dim: spv.SpvDim, x: i32, y: i32, z: i32, pixel: spv.Runtime.Vec4(u32)) SpvRuntimeError!void {
const vec_pixel = @Vector(4, u32){ pixel.x, pixel.y, pixel.z, pixel.w };
if (dim == .Buffer) {
const buffer_view: *SoftBufferView = @ptrCast(@alignCast(context));
const buffer: *SoftBuffer = @alignCast(@fieldParentPtr("interface", buffer_view.interface.buffer));
const map = buffer.mapAsSliceWithOffset(u8, buffer_view.interface.offset, buffer_view.interface.range) catch return SpvRuntimeError.Unknown;
blitter.writeInt4(vec_pixel, map[(@as(usize, @intCast(x)) * base.format.texelSize(buffer_view.interface.format))..], buffer_view.interface.format);
} else {
const image_view: *SoftImageView = @ptrCast(@alignCast(context));
const image: *SoftImage = @alignCast(@fieldParentPtr("interface", image_view.interface.image));
image.writeInt4(
.{
.x = x,
.y = y,
.z = z,
},
.{
.aspect_mask = image_view.interface.subresource_range.aspect_mask,
.mip_level = image_view.interface.subresource_range.base_mip_level,
.array_layer = image_view.interface.subresource_range.base_array_layer,
},
image_view.interface.format,
vec_pixel,
) catch return SpvRuntimeError.Unknown;
}
}
+11
View File
@@ -194,6 +194,17 @@ fn writeDescriptorSets(self: *Self, rt: *spv.Runtime) !void {
);
}
},
.texel_buffer => |texel_data_array| for (texel_data_array, 0..) |texel_data, descriptor_index| {
if (texel_data.object) |buffer_view| {
const addr: usize = @intFromPtr(buffer_view);
try rt.writeDescriptorSet(
std.mem.asBytes(&addr),
@as(u32, @intCast(set_index)),
@as(u32, @intCast(binding_index)),
@as(u32, @intCast(descriptor_index)),
);
}
},
else => {},
}
}
+101 -14
View File
@@ -558,15 +558,22 @@ pub fn readFloat4(map: []const u8, src_format: vk.Format) F32x4 {
=> c[0] = @as(f32, @floatFromInt(std.mem.bytesToValue(u16, map))) / 255.0,
.r8g8b8a8_sint,
.r8g8b8a8_snorm,
.r8g8b8a8_unorm,
.r8g8b8a8_uint,
.r8g8b8a8_srgb,
.r8g8b8a8_unorm,
=> {
c[0] = @as(f32, @floatFromInt(map[0])) / 255.0;
c[1] = @as(f32, @floatFromInt(map[1])) / 255.0;
c[2] = @as(f32, @floatFromInt(map[2])) / 255.0;
c[3] = @as(f32, @floatFromInt(map[3])) / 255.0;
c[0] = @as(f32, @floatFromInt(map[0])) / std.math.maxInt(u8);
c[1] = @as(f32, @floatFromInt(map[1])) / std.math.maxInt(u8);
c[2] = @as(f32, @floatFromInt(map[2])) / std.math.maxInt(u8);
c[3] = @as(f32, @floatFromInt(map[3])) / std.math.maxInt(u8);
},
.r8g8b8a8_snorm,
=> {
c[0] = @as(f32, @floatFromInt(map[0])) / std.math.maxInt(i8);
c[1] = @as(f32, @floatFromInt(map[1])) / std.math.maxInt(i8);
c[2] = @as(f32, @floatFromInt(map[2])) / std.math.maxInt(i8);
c[3] = @as(f32, @floatFromInt(map[3])) / std.math.maxInt(i8);
},
.r16_sint,
@@ -581,10 +588,56 @@ pub fn readFloat4(map: []const u8, src_format: vk.Format) F32x4 {
.r32_sfloat,
=> c[0] = std.mem.bytesToValue(f32, map),
.r16g16b16a16_sint,
.r16g16b16a16_uint,
.r16g16b16a16_unorm,
.r16g16b16a16_snorm,
=> c = std.mem.bytesToValue(@Vector(4, u16), map) / zm.f32x4s(std.math.maxInt(u16)),
.r16g16b16a16_sfloat => c = std.mem.bytesToValue(@Vector(4, f16), map),
.r32g32b32a32_sfloat => c = std.mem.bytesToValue(F32x4, map),
.s8_uint => c[0] = @floatFromInt(map[0]),
.a8b8g8r8_uint_pack32,
.a8b8g8r8_sint_pack32,
.a8b8g8r8_unorm_pack32,
=> {
const pack = std.mem.bytesToValue(@Vector(4, u8), map);
c[0] = @as(f32, @floatFromInt(pack[0])) / std.math.maxInt(u8);
c[1] = @as(f32, @floatFromInt(pack[1])) / std.math.maxInt(u8);
c[2] = @as(f32, @floatFromInt(pack[2])) / std.math.maxInt(u8);
c[3] = @as(f32, @floatFromInt(pack[3])) / std.math.maxInt(u8);
},
.a8b8g8r8_snorm_pack32 => {
const pack = std.mem.bytesToValue(@Vector(4, u8), map);
c[0] = @as(f32, @floatFromInt(pack[0])) / std.math.maxInt(i8);
c[1] = @as(f32, @floatFromInt(pack[1])) / std.math.maxInt(i8);
c[2] = @as(f32, @floatFromInt(pack[2])) / std.math.maxInt(i8);
c[3] = @as(f32, @floatFromInt(pack[3])) / std.math.maxInt(i8);
},
.a2b10g10r10_uint_pack32,
.a2b10g10r10_unorm_pack32,
=> {
const pack = std.mem.bytesToValue(u32, map);
c[0] = @as(f32, @floatFromInt(pack & 0x000003FF)) / std.math.maxInt(u10);
c[1] = @as(f32, @floatFromInt((pack & 0x000FFC00) >> 10)) / std.math.maxInt(u10);
c[2] = @as(f32, @floatFromInt((pack & 0x3FF00000) >> 20)) / std.math.maxInt(u10);
c[3] = @as(f32, @floatFromInt((pack & 0xC0000000) >> 30)) / std.math.maxInt(u2);
},
.a2r10g10b10_uint_pack32,
.a2r10g10b10_unorm_pack32,
=> {
const pack = std.mem.bytesToValue(u32, map);
c[2] = @as(f32, @floatFromInt(pack & 0x000003FF)) / std.math.maxInt(u10);
c[1] = @as(f32, @floatFromInt((pack & 0x000FFC00) >> 10)) / std.math.maxInt(u10);
c[0] = @as(f32, @floatFromInt((pack & 0x3FF00000) >> 20)) / std.math.maxInt(u10);
c[3] = @as(f32, @floatFromInt((pack & 0xC0000000) >> 30)) / std.math.maxInt(u2);
},
else => base.unsupported("Blitter: read float from source format {any}", .{src_format}),
}
@@ -616,10 +669,10 @@ pub fn writeFloat4(color: F32x4, map: []u8, dst_format: vk.Format) void {
.b8g8r8a8_srgb,
.b8g8r8a8_unorm,
=> {
map[0] = @intFromFloat(@round(color[2] * 255.0));
map[1] = @intFromFloat(@round(color[1] * 255.0));
map[2] = @intFromFloat(@round(color[0] * 255.0));
map[3] = @intFromFloat(@round(color[3] * 255.0));
map[0] = @intFromFloat(@round(color[2] * std.math.maxInt(u8)));
map[1] = @intFromFloat(@round(color[1] * std.math.maxInt(u8)));
map[2] = @intFromFloat(@round(color[0] * std.math.maxInt(u8)));
map[3] = @intFromFloat(@round(color[3] * std.math.maxInt(u8)));
},
.a8b8g8r8_unorm_pack32,
@@ -631,10 +684,10 @@ pub fn writeFloat4(color: F32x4, map: []u8, dst_format: vk.Format) void {
.r8g8b8a8_uscaled,
.a8b8g8r8_uscaled_pack32,
=> {
map[0] = @intFromFloat(@round(color[0] * 255.0));
map[1] = @intFromFloat(@round(color[1] * 255.0));
map[2] = @intFromFloat(@round(color[2] * 255.0));
map[3] = @intFromFloat(@round(color[3] * 255.0));
map[0] = @intFromFloat(@round(color[0] * std.math.maxInt(u8)));
map[1] = @intFromFloat(@round(color[1] * std.math.maxInt(u8)));
map[2] = @intFromFloat(@round(color[2] * std.math.maxInt(u8)));
map[3] = @intFromFloat(@round(color[3] * std.math.maxInt(u8)));
},
.r32g32b32a32_sfloat => std.mem.bytesAsValue(F32x4, map).* = color,
@@ -651,9 +704,11 @@ pub fn readInt4(map: []const u8, src_format: vk.Format) U32x4 {
.r8_uint,
.s8_uint,
=> c[0] = map[0],
.r16_sint,
.r16_uint,
=> c[0] = std.mem.bytesToValue(u16, map),
.r32_sint,
.r32_uint,
=> c[0] = std.mem.bytesToValue(u32, map),
@@ -680,6 +735,38 @@ pub fn readInt4(map: []const u8, src_format: vk.Format) U32x4 {
.r32g32b32a32_uint,
=> c = std.mem.bytesToValue(U32x4, map),
.a8b8g8r8_uint_pack32,
.a8b8g8r8_sint_pack32,
.a8b8g8r8_unorm_pack32,
.a8b8g8r8_snorm_pack32,
=> {
const pack = std.mem.bytesToValue(@Vector(4, u8), map);
c[0] = pack[0];
c[1] = pack[1];
c[2] = pack[2];
c[3] = pack[3];
},
.a2b10g10r10_unorm_pack32,
.a2b10g10r10_uint_pack32,
=> {
const pack = std.mem.bytesToValue(u32, map);
c[0] = (pack & 0x000003FF);
c[1] = (pack & 0x000FFC00) >> 10;
c[2] = (pack & 0x3FF00000) >> 20;
c[3] = (pack & 0xC0000000) >> 30;
},
.a2r10g10b10_unorm_pack32,
.a2r10g10b10_uint_pack32,
=> {
const pack = std.mem.bytesToValue(u32, map);
c[0] = (pack & 0x000003FF);
c[1] = (pack & 0x000FFC00) >> 10;
c[2] = (pack & 0x3FF00000) >> 20;
c[3] = (pack & 0xC0000000) >> 30;
},
else => base.unsupported("Blitter: read int from source format {any}", .{src_format}),
}
+10 -3
View File
@@ -1,16 +1,20 @@
const std = @import("std");
const vk = @import("vulkan");
const NonDispatchable = @import("NonDispatchable.zig");
const VkError = @import("error_set.zig").VkError;
const NonDispatchable = @import("NonDispatchable.zig").NonDispatchable;
const Device = @import("Device.zig");
const Buffer = @import("Buffer.zig");
const Self = @This();
pub const ObjectType: vk.ObjectType = .buffer_view;
owner: *Device,
buffer: *Buffer,
format: vk.Format,
offset: vk.DeviceSize,
range: vk.DeviceSize,
vtable: *const VTable,
@@ -20,10 +24,13 @@ pub const VTable = struct {
pub fn init(device: *Device, allocator: std.mem.Allocator, info: *const vk.BufferViewCreateInfo) VkError!Self {
_ = allocator;
_ = info;
return .{
.owner = device,
.buffer = try NonDispatchable(Buffer).fromHandleObject(info.buffer),
.vtable = undefined,
.format = info.format,
.offset = info.offset,
.range = info.range,
};
}
-2
View File
@@ -6,8 +6,6 @@ const VkError = @import("error_set.zig").VkError;
const NonDispatchable = @import("NonDispatchable.zig").NonDispatchable;
const Device = @import("Device.zig");
const DeviceMemory = @import("DeviceMemory.zig");
const Image = @import("Image.zig");
const Self = @This();
+1 -1
View File
@@ -64,7 +64,7 @@ pub fn init(device: *Device, allocator: std.mem.Allocator, info: *const vk.Rende
else
null,
.depth_stencil_attachments = if (subpass_info.p_depth_stencil_attachment) |subpass_attachment|
subpass_attachment.*
if (subpass_attachment.attachment != vk.ATTACHMENT_UNUSED) subpass_attachment.* else null
else
null,
.preserve_attachments = if (subpass_info.p_preserve_attachments) |subpass_attachments|