forked from vv/efemra
1
0
Fork 0

more fixes!

This commit is contained in:
Vivianne 2022-07-18 03:50:19 -07:00
parent 4b59b2d387
commit 32bf9e5817
7 changed files with 42 additions and 40 deletions

View File

@ -71,7 +71,7 @@ const DepthPass = struct {
pub fn init(device: *const Device, swapchain: *Swapchain) !void {
errdefer DepthPass.deinit();
const depth_buffer = swapchain.getDepthBuffer();
const depth_buffer = Targets.getDepthBuffer(swapchain);
var info = RenderPass.Description{
.src_stage_mask = .{ .early_fragment_tests_bit = true },
@ -152,7 +152,7 @@ const DepthPass = struct {
const world_to_clip = camera.getWorldToClip(swapchain.getAspect());
const attachments = &[_]*Image{swapchain.getDepthBuffer()};
const attachments = &[_]*Image{Targets.getDepthBuffer(swapchain)};
const rect = vk.Rect2D{
.offset = std.mem.zeroes(vk.Offset2D),
.extent = .{

View File

@ -54,6 +54,7 @@ pub fn get(device: *const Device, desc: Description) !vk.RenderPass {
var dst = &attachments[attachment_count];
dst.format = src.format;
dst.initial_layout = src.layout;
dst.final_layout = src.layout;
dst.samples = .{ .@"1_bit" = true };
dst.stencil_load_op = .dont_care;
dst.stencil_store_op = .dont_care;

View File

@ -11,6 +11,7 @@ const Swapchain = @import("swapchain.zig").Swapchain;
const Context = @import("Context.zig");
const MainPass = @import("MainPass.zig");
const Command = @import("Command.zig");
const Targets = @import("Targets.zig");
instance: Instance,
window: Window,
@ -19,7 +20,6 @@ swapchain: Swapchain,
// sampler: Sampler, TODO
// tex_table: TexTable, TODO
// bindings: Bindings, TODO
// targets: Targets, TODO
// mesh_sys: MeshSys, TODO
// im_sys: ImSys, TODO
@ -55,7 +55,7 @@ pub fn init() !Self {
// try self.sampler.init();
// try self.texTable.init();
// try self.bindings.init();
// try self.targets.init();
try Targets.init(&device, &swapchain);
// try self.meshSys.init();
// try self.imSys.init();
try MainPass.init(&device, &swapchain);

View File

@ -9,17 +9,17 @@ const Image = @import("image.zig").Image;
const Self = @This();
width: i32,
height: i32,
width: u32,
height: u32,
depth: [settings.resource_sets]Image,
scene: [settings.resource_sets]Image,
// TODO: scaled render resolution
pub fn getDesiredWidth(swapchain: *const Swapchain) i32 {
pub fn getDesiredWidth(swapchain: *const Swapchain) u32 {
getDisplayWidth(swapchain);
}
pub fn getDesiredHeight(swapchain: *const Swapchain) i32 {
pub fn getDesiredHeight(swapchain: *const Swapchain) u32 {
getDisplayHeight(swapchain);
}
@ -42,12 +42,13 @@ pub fn init(device: *const Device, swapchain: *const Swapchain) !void {
.transfer_src_bit = true,
.transfer_dst_bit = true,
};
const queue_family_indices = []u32{
const queue_family_indices = [_]u32{
queues.get(.graphics).family,
queues.get(.compute).family,
};
try Image.init(s, &.{
try Image.init(s, .{
.flags = .{},
.image_type = .@"2d",
.format = .r16g16b16a16_sfloat,
.extent = .{
@ -57,14 +58,14 @@ pub fn init(device: *const Device, swapchain: *const Swapchain) !void {
},
.mip_levels = 1,
.array_layers = 1,
.samples = .@"1_bit",
.samples = .{ .@"1_bit" = true },
.tiling = .optimal,
.usage = usage,
.sharing_mode = .exclusive,
.queue_family_index_count = queue_family_indices.len,
.p_queue_family_indices = queue_family_indices.ptr,
.p_queue_family_indices = &queue_family_indices,
.initial_layout = .@"undefined",
}, .gpu_only);
}, .gpuOnly);
}
for (s_targets.depth) |*d| {
@ -115,14 +116,26 @@ pub fn recreate(device: *const Device) void {
}
}
pub fn getDisplayWidth(swapchain: *const Swapchain) i32 {
pub fn getDisplayWidth(swapchain: *const Swapchain) u32 {
swapchain.getBackBuffer().width;
}
pub fn getDisplayHeight(swapchain: *const Swapchain) i32 {
pub fn getDisplayHeight(swapchain: *const Swapchain) u32 {
swapchain.getBackBuffer().height;
}
pub fn getDepthBuffer(swapchain: *const Swapchain) *Image {
const img = &s_targets.depth[swapchain.sync_index];
assert(img.handle != .null_handle);
return img;
}
pub fn getSceneBuffer(swapchain: *const Swapchain) *Image {
var img = &s_targets.scene[swapchain.sync_index];
assert(img.handle != .null_handle);
return img;
}
pub fn getRenderWidth() i32 {
return s_targets.width;
}

View File

@ -33,11 +33,8 @@ pub const Image = struct {
image_type: vk.ImageType,
imported: bool,
pub fn init(info: *const vk.ImageCreateInfo, mem_usage: memory.Usage) !Self {
const self = Self{};
memory.imageNew(self, info, mem_usage);
return self;
pub fn init(self: *Self, info: vk.ImageCreateInfo, mem_usage: vma.MemoryUsage) !void {
try memory.imageNew(self, info, mem_usage);
}
pub fn release(self: *const Self) !void {
@ -249,7 +246,10 @@ pub const Image = struct {
const prev = &img.state;
const prev_queue = queues.get(prev.owner);
const next_queue = queues.get(self.owner);
std.debug.print("stage: {}\n\n stage_mask: {}\n", .{ self.stage, next_queue.stage_mask });
assert(self.stage.intersect(next_queue.stage_mask).toInt() == self.stage.toInt());
std.debug.print("access: {}\n\n access_mask: {}\n", .{ self.access, next_queue.access_mask });
assert(self.access.intersect(next_queue.access_mask).toInt() == self.access.toInt());
if (prev.substates != null) {

View File

@ -37,7 +37,7 @@ pub fn finalize(device: *const Device) !void {
pub fn update() void {}
const pm_imgnew = profiler.ProfileMark.init("memory.imageNew");
pub fn imageNew(img: *Image, info: *const vk.ImageCreateInfo, mem_usage: vma.MemoryUsage) !void {
pub fn imageNew(img: *Image, info: vk.ImageCreateInfo, mem_usage: vma.MemoryUsage) !void {
pm_imgnew.begin();
defer pm_imgnew.end();
@ -45,17 +45,17 @@ pub fn imageNew(img: *Image, info: *const vk.ImageCreateInfo, mem_usage: vma.Mem
img.image_type = info.image_type;
img.format = info.format;
img.state.owner = .graphics;
img.state.stage = 0;
img.state.stage = .{};
img.state.layout = info.initial_layout;
img.usage = info.usage;
img.width = info.extent.width;
img.height = info.extent.height;
img.depth = info.extent.depth;
img.mip_levels = info.mip_levels;
img.array_layers = info.array_layers;
img.width = @intCast(u16, info.extent.width);
img.height = @intCast(u16, info.extent.height);
img.depth = @intCast(u12, info.extent.depth);
img.mip_levels = @intCast(u8, info.mip_levels);
img.array_layers = @intCast(u8, info.array_layers);
img.imported = false;
try vma.createImage(s_allocator.handle, info, &.{
try vma.Allocator.createImage(s_allocator.handle, info, &.{
.flags = .{
.withinBudget = true,
},

View File

@ -356,16 +356,4 @@ pub const Swapchain = struct {
assert(img.handle != .null_handle);
return img;
}
pub fn getDepthBuffer(self: *Self) *Image {
var img = &self.images[self.sync_index];
assert(img.handle != .null_handle);
return img;
}
pub fn getSceneBuffer(self: *Self) *Image {
var img = &self.images[self.sync_index];
assert(img.handle != .null_handle);
return img;
}
};