Add gpuFlushBuffer

This commit is contained in:
abdelrahman committed 2026-11-01 00:22:59 +00:00
1 parent 6c6dd5626c
commit f308900207
2 files changed
+15

No files matched your search

+8
View File
@@ -354,6 +354,13 @@ typedef struct GpuBufferCreateRequest {
GpuBufferUsage usage;
} GpuBufferCreateRequest;
typedef struct GpuBufferFlushRequest {
GpuDevice *device;
GpuBuffer buffer;
u64 offset;
u64 size;
} GpuBufferFlushRequest;
typedef struct GpuFence GpuFence;
typedef GpuFence **GpuFencePtrArray;
@@ -1192,6 +1199,7 @@ GpuImage *gpuLoadImageFromFile(const WpAllocator *allocator
ivec3s gpuGetImageSize(GpuImage *image);
GpuBuffer gpuCreateBuffer(const WpAllocator *allocator, GpuBufferCreateRequest request);
void gpuDestroyBuffer(GpuBuffer *buffer);
void gpuFlushBuffer(GpuBufferFlushRequest request);
GpuFence *gpuCreateFence(const WpAllocator *allocator, GpuDevice *device);
void gpuDestroyFence(GpuFence *fence);
void gpuResetFences(const WpAllocator *temp, GpuResetFencesRequest request);
+7
View File
@@ -1037,6 +1037,13 @@ void gpuDestroyBuffer(GpuBuffer *buffer) {
buffer->size = 0;
}
void gpuFlushBuffer(GpuBufferFlushRequest request) {
u64 size = request.size > 0 ? request.size : VK_WHOLE_SIZE;
VkResult vk_result = vmaFlushAllocation(request.device->allocator, request.buffer.internal->allocation,
request.offset, size);
assertWithLogger(vk_result == VK_SUCCESS, &logger, "Failed to flush buffer");
}
GpuFence *gpuCreateFence(const WpAllocator *allocator, GpuDevice *device) {
GpuFence *fence = wpMemAllocatorAlloc(allocator, sizeof(GpuFence));
assertWithLogger(fence != NULL, &logger, "Failed to allocate fence internal");