No more staging buffer; generic buffer doubles as staging
This commit is contained in:
@@ -10,7 +10,6 @@ const vm = @import("vecmath");
|
||||
const CommandBuffer = @import("CommandBuffer.zig");
|
||||
const Engine = @import("Engine.zig");
|
||||
const GenericBuffer = @import("GenericBuffer.zig").GenericBuffer;
|
||||
const StagingBuffer = @import("StagingBuffer.zig");
|
||||
const Swapchain = @import("Swapchain.zig");
|
||||
const Texture = @import("Texture.zig");
|
||||
|
||||
@@ -69,15 +68,21 @@ pub fn load(
|
||||
|
||||
// --- LOAD IMAGE INTO STAGING BUFFER --------------------------------------
|
||||
|
||||
var staging_buffer = try StagingBuffer.init(.{
|
||||
.capacity = @intCast(img.width * img.height * @sizeOf(vm.ColorHdr)),
|
||||
var staging_buffer = try GenericBuffer(vm.ColorHdr).init(.{
|
||||
.usage = .staging,
|
||||
.target_queue = .compute,
|
||||
.mappable = true,
|
||||
.capacity = img.width * img.height,
|
||||
});
|
||||
defer staging_buffer.deinit();
|
||||
|
||||
const staging_memory = try staging_buffer.map();
|
||||
@memcpy(staging_memory, @as([*]const u8, @ptrCast(img.data)));
|
||||
staging_buffer.unmap();
|
||||
{
|
||||
const staging_memory = try staging_buffer.mapSlice();
|
||||
defer staging_buffer.unmap();
|
||||
|
||||
@memcpy(staging_memory, img.data);
|
||||
try staging_buffer.flush(0, img.width * img.height);
|
||||
}
|
||||
|
||||
// --- CREATE EQUIRECTANGULAR IMAGE ----------------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user