command pool+buffer handles

This commit is contained in:
Greg Wells
2025-06-04 22:08:24 -04:00
parent 9faa96d5f5
commit 4349f76ede
11 changed files with 56 additions and 47 deletions

View File

@@ -2,21 +2,22 @@
#include "core/gryphn_platform_functions.h"
#include "stdio.h"
gnReturnCode gnCommandPoolAllocateCommandBuffers(struct gnCommandBuffer_t* buffers, uint32_t count, struct gnCommandPool_t* commandPool) {
gnReturnCode gnCommandPoolAllocateCommandBuffers(gnCommandBufferHandle* buffers, uint32_t count, gnCommandPoolHandle commandPool) {
for (int i = 0; i < count; i++) {
buffers[i].commandPool = commandPool;
buffers[i] = malloc(sizeof(struct gnCommandBuffer_t));
buffers[i]->commandPool = commandPool;
}
return commandPool->commandFunctions->_gnCommandPoolAllocateCommandBuffers(buffers, count, commandPool);
}
void gnResetCommandBuffer(struct gnCommandBuffer_t* commandBuffer) {
void gnResetCommandBuffer(gnCommandBufferHandle commandBuffer) {
commandBuffer->commandPool->commandFunctions->_gnResetCommandBuffer(commandBuffer);
}
gnReturnCode gnBeginCommandBuffer(struct gnCommandBuffer_t* commandBuffer) {
gnReturnCode gnBeginCommandBuffer(gnCommandBufferHandle commandBuffer) {
return commandBuffer->commandPool->commandFunctions->_gnBeginCommandBuffer(commandBuffer);
}
gnReturnCode gnEndCommandBuffer(struct gnCommandBuffer_t* commandBuffer) {
gnReturnCode gnEndCommandBuffer(gnCommandBufferHandle commandBuffer) {
return commandBuffer->commandPool->commandFunctions->_gnEndCommandBuffer(commandBuffer);
}

View File

@@ -1,13 +1,17 @@
#pragma once
#include <core/command/command_pool/gryphn_command_pool.h>
#include "stdint.h"
#include "utils/gryphn_error_code.h"
#include "core/gryphn_handles.h"
typedef struct gnCommandBuffer_t {
#ifdef GN_REVEAL_IMPL
struct gnCommandBuffer_t {
struct gnPlatformCommandBuffer_t* commandBuffer;
struct gnCommandPool_t* commandPool;
} gnCommandBuffer;
gnCommandPoolHandle commandPool;
};
#endif
gnReturnCode gnCommandPoolAllocateCommandBuffers(struct gnCommandBuffer_t* buffers, uint32_t count, struct gnCommandPool_t* commandPool);
gnReturnCode gnCommandPoolAllocateCommandBuffers(gnCommandBufferHandle* buffers, uint32_t count, gnCommandPoolHandle commandPool);
void gnResetCommandBuffer(struct gnCommandBuffer_t* commandBuffer);
gnReturnCode gnBeginCommandBuffer(struct gnCommandBuffer_t* commandBuffer);
gnReturnCode gnEndCommandBuffer(struct gnCommandBuffer_t* commandBuffer);
void gnResetCommandBuffer(gnCommandBufferHandle commandBuffer);
gnReturnCode gnBeginCommandBuffer(gnCommandBufferHandle commandBuffer);
gnReturnCode gnEndCommandBuffer(gnCommandBufferHandle commandBuffer);

View File

@@ -2,18 +2,19 @@
#include "core/gryphn_platform_functions.h"
#include "core/instance/init/gryphn_init.h"
gnReturnCode gnCreateCommandPool(struct gnCommandPool_t* commandPool, struct gnOutputDevice_t* device, struct gnCommandPoolInfo_t info) {
gnReturnCode gnCreateCommandPool(gnCommandPoolHandle* commandPool, gnOutputDeviceHandle device, struct gnCommandPoolInfo_t info) {
*commandPool = malloc(sizeof(struct gnCommandPool_t));
if (!device->instance->loadCommandFunctions) {
device->instance->commandFunctions = malloc(sizeof(struct gnCommandFunctions_t));
gnLoadCommandFunctions(device->instance->dynamicLib, device->instance->commandFunctions);
device->instance->loadCommandFunctions = gnTrue;
}
commandPool->commandFunctions = device->instance->commandFunctions;
(*commandPool)->commandFunctions = device->instance->commandFunctions;
commandPool->device = device;
return device->deviceFunctions->_gnCreateCommandPool(commandPool, device, info);
(*commandPool)->device = device;
return device->deviceFunctions->_gnCreateCommandPool((*commandPool), device, info);
}
void gnDestroyCommandPool(struct gnCommandPool_t* commandPool) {
void gnDestroyCommandPool(gnCommandPoolHandle commandPool) {
commandPool->device->deviceFunctions->_gnDestroyCommandPool(commandPool);
}

View File

@@ -1,17 +1,19 @@
#pragma once
#include "stdint.h"
#include <core/output_device/gryphn_output_device.h>
#include <utils/gryphn_error_code.h>
#include "core/gryphn_handles.h"
typedef struct gnCommandPoolInfo_t {
uint32_t queueIndex;
} gnCommandPoolInfo;
typedef struct gnCommandPool_t {
#ifdef GN_REVEAL_IMPL
struct gnCommandPool_t {
struct gnPlatformCommandPool_t* commandPool;
struct gnCommandFunctions_t* commandFunctions;
struct gnOutputDevice_t* device;
} gnCommandPool;
};
#endif
gnReturnCode gnCreateCommandPool(struct gnCommandPool_t* commandPool, struct gnOutputDevice_t* device, struct gnCommandPoolInfo_t info);
void gnDestroyCommandPool(struct gnCommandPool_t* commandPool);
gnReturnCode gnCreateCommandPool(gnCommandPoolHandle* commandPool, gnOutputDeviceHandle device, struct gnCommandPoolInfo_t info);
void gnDestroyCommandPool(gnCommandPoolHandle commandPool);

View File

@@ -13,3 +13,5 @@ GN_HANDLE(gnRenderPassDescriptor);
GN_HANDLE(gnOutputDevice);
GN_HANDLE(gnShaderModule);
GN_HANDLE(gnGraphicsPipeline);
GN_HANDLE(gnCommandPool);
GN_HANDLE(gnCommandBuffer);

View File

@@ -75,8 +75,8 @@ typedef struct gnDeviceFunctions_t {
gnReturnCode (*_gnCreateFramebuffer)(struct gnFramebuffer_t* framebuffer, gnOutputDeviceHandle device, struct gnFramebufferInfo_t framebufferInfo);
void (*_gnDestroyFramebuffer)(struct gnFramebuffer_t* framebuffer);
gnReturnCode (*_gnCreateCommandPool)(struct gnCommandPool_t* commandPool, gnOutputDeviceHandle device, struct gnCommandPoolInfo_t info);
void (*_gnDestroyCommandPool)(struct gnCommandPool_t* commandPool);
gnReturnCode (*_gnCreateCommandPool)(gnCommandPoolHandle commandPool, gnOutputDeviceHandle device, struct gnCommandPoolInfo_t info);
void (*_gnDestroyCommandPool)(gnCommandPoolHandle commandPool);
gnReturnCode (*_gnCreateSemaphore)(struct gnSemaphore_t* semaphore, gnOutputDeviceHandle device);
void (*_gnDestroySemaphore)(struct gnSemaphore_t* semaphore);
@@ -87,24 +87,24 @@ typedef struct gnDeviceFunctions_t {
void (*_gnResetFence)(struct gnFence_t* fence);
void (*_gnDestroyFence)(struct gnFence_t* fence);
gnReturnCode (*_gnSubmit)(gnOutputDeviceHandle device, struct gnSubmitInfo_t submit);
gnReturnCode (*_gnPresent)(gnOutputDeviceHandle device, struct gnPresentInfo_t info);
gnReturnCode (*_gnSubmit)(gnOutputDeviceHandle device, gnSubmitInfo submit);
gnReturnCode (*_gnPresent)(gnOutputDeviceHandle device, gnPresentInfo info);
void (*_gnWaitForDevice)(gnOutputDeviceHandle device);
} gnDeviceFunctions;
typedef struct gnCommandFunctions_t {
gnReturnCode (*_gnCommandPoolAllocateCommandBuffers)(struct gnCommandBuffer_t* commandBuffers, uint32_t count, struct gnCommandPool_t* pool);
gnReturnCode (*_gnBeginCommandBuffer)(struct gnCommandBuffer_t* commandBuffer);
void (*_gnResetCommandBuffer)(struct gnCommandBuffer_t* commandBuffer);
gnReturnCode (*_gnEndCommandBuffer)(struct gnCommandBuffer_t* commandBuffer);
gnReturnCode (*_gnCommandPoolAllocateCommandBuffers)(gnCommandBufferHandle* commandBuffers, uint32_t count, gnCommandPoolHandle pool);
gnReturnCode (*_gnBeginCommandBuffer)(gnCommandBufferHandle commandBuffer);
void (*_gnResetCommandBuffer)(gnCommandBufferHandle commandBuffer);
gnReturnCode (*_gnEndCommandBuffer)(gnCommandBufferHandle commandBuffer);
void (*_gnCommandBeginRenderPass)(struct gnCommandBuffer_t* buffer, struct gnRenderPassInfo_t passInfo);
void (*_gnCommandEndRenderPass)(struct gnCommandBuffer_t* buffer);
void (*_gnCommandBeginRenderPass)(gnCommandBufferHandle buffer, struct gnRenderPassInfo_t passInfo);
void (*_gnCommandEndRenderPass)(gnCommandBufferHandle buffer);
void (*_gnCommandBindGraphicsPipeline)(struct gnCommandBuffer_t* buffer, struct gnGraphicsPipeline_t* graphicsPipeline);
void (*_gnCommandSetViewport)(struct gnCommandBuffer_t* buffer, struct gnViewport_t viewport);
void (*_gnCommandSetScissor)(struct gnCommandBuffer_t* buffer, struct gnScissor_t scissor);
void (*_gnCommandBindGraphicsPipeline)(gnCommandBufferHandle buffer, gnGraphicsPipelineHandle graphicsPipeline);
void (*_gnCommandSetViewport)(gnCommandBufferHandle buffer, gnViewport viewport);
void (*_gnCommandSetScissor)(gnCommandBufferHandle buffer, gnScissor scissor);
void (*_gnCommandDraw)(struct gnCommandBuffer_t* buffer, int vertexCount, int firstVertex, int instanceCount, int firstInstance);
void (*_gnCommandDraw)(gnCommandBufferHandle buffer, int vertexCount, int firstVertex, int instanceCount, int firstInstance);
} gnCommandFunctions;

View File

@@ -2,7 +2,6 @@
#include "stdint.h"
#include "core/sync/semaphore/gryphn_semaphore.h"
#include "core/sync/fence/gryphn_fence.h"
#include "core/command/command_buffer/gryphn_command_buffer.h"
#include "core/output_device/gryphn_output_device.h"
typedef struct gnSubmitInfo_t {
@@ -12,7 +11,7 @@ typedef struct gnSubmitInfo_t {
uint32_t signalCount;
struct gnSemaphore_t* signalSemaphores;
uint32_t commandBufferCount;
struct gnCommandBuffer_t* commandBuffers;
gnCommandBufferHandle* commandBuffers;
uint32_t queueIndex;
struct gnFence_t* fence;
} gnSubmitInfo;