command pool+buffer handles
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
#include "core/commands/command_pool/metal_command_pool.h"
|
||||
#import <Metal/Metal.h>
|
||||
|
||||
gnReturnCode gnCommandPoolAllocateCommandBuffersFn(struct gnCommandBuffer_t* commandBuffers, uint32_t count, struct gnCommandPool_t* pool) {
|
||||
gnReturnCode gnCommandPoolAllocateCommandBuffersFn(gnCommandBufferHandle* commandBuffers, uint32_t count, struct gnCommandPool_t* pool) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
commandBuffers[i].commandBuffer = malloc(sizeof(gnPlatformCommandBuffer));
|
||||
commandBuffers[i]->commandBuffer = malloc(sizeof(gnPlatformCommandBuffer));
|
||||
}
|
||||
|
||||
return GN_SUCCESS;
|
||||
|
@@ -15,8 +15,8 @@ gnReturnCode gnSubmitFn(struct gnOutputDevice_t* device, struct gnSubmitInfo_t i
|
||||
__block gnFence* fenceToSignal = info.fence;
|
||||
|
||||
for (int i = 0; i < info.commandBufferCount; i++) {
|
||||
id<MTLCommandBuffer> commandBuffer = info.commandBuffers[i].commandBuffer->commandBuffer;
|
||||
[info.commandBuffers[i].commandBuffer->commandBuffer addCompletedHandler:^(id<MTLCommandBuffer> buffer) {
|
||||
id<MTLCommandBuffer> commandBuffer = info.commandBuffers[i]->commandBuffer->commandBuffer;
|
||||
[info.commandBuffers[i]->commandBuffer->commandBuffer addCompletedHandler:^(id<MTLCommandBuffer> buffer) {
|
||||
for (int c = 0; c < semsToSignalCount; c++) {
|
||||
semsToSignal[c].semaphore->eventTriggered = gnTrue;
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
#include "commands/command_pool/vulkan_command_pool.h"
|
||||
#include "output_device/vulkan_output_devices.h"
|
||||
|
||||
gnReturnCode gnCommandPoolAllocateCommandBuffersFn(struct gnCommandBuffer_t* commandBuffers, uint32_t count, struct gnCommandPool_t* pool) {
|
||||
gnReturnCode gnCommandPoolAllocateCommandBuffersFn(gnCommandBufferHandle* commandBuffers, uint32_t count, struct gnCommandPool_t* pool) {
|
||||
VkCommandBufferAllocateInfo allocInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
|
||||
.commandPool = pool->commandPool->commandPool,
|
||||
@@ -16,8 +16,8 @@ gnReturnCode gnCommandPoolAllocateCommandBuffersFn(struct gnCommandBuffer_t* com
|
||||
return GN_FAILED_TO_ALLOCATE_COMMAND_BUFFERS;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
commandBuffers[i].commandBuffer = malloc(sizeof(gnPlatformCommandBuffer));
|
||||
commandBuffers[i].commandBuffer->buffer = buffers[i];
|
||||
commandBuffers[i]->commandBuffer = malloc(sizeof(gnPlatformCommandBuffer));
|
||||
commandBuffers[i]->commandBuffer->buffer = buffers[i];
|
||||
}
|
||||
|
||||
return GN_SUCCESS;
|
||||
|
@@ -21,7 +21,7 @@ gnReturnCode gnSubmitFn(struct gnOutputDevice_t* device, struct gnSubmitInfo_t i
|
||||
for (int i = 0; i < info.waitCount; i++) waitStages[i] = vkGryphnWaitStage(info.waitStages[i]);
|
||||
|
||||
VkCommandBuffer* commandBuffers = malloc(sizeof(VkCommandBuffer) * info.commandBufferCount);
|
||||
for (int i = 0; i < info.commandBufferCount; i++) commandBuffers[i] = info.commandBuffers[i].commandBuffer->buffer;
|
||||
for (int i = 0; i < info.commandBufferCount; i++) commandBuffers[i] = info.commandBuffers[i]->commandBuffer->buffer;
|
||||
|
||||
VkSemaphore* signalSemaphores = malloc(sizeof(VkSemaphore) * info.signalCount);
|
||||
for (int i = 0; i < info.signalCount; i++) signalSemaphores[i] = info.signalSemaphores[i].semaphore->semaphore;
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
|
@@ -13,3 +13,5 @@ GN_HANDLE(gnRenderPassDescriptor);
|
||||
GN_HANDLE(gnOutputDevice);
|
||||
GN_HANDLE(gnShaderModule);
|
||||
GN_HANDLE(gnGraphicsPipeline);
|
||||
GN_HANDLE(gnCommandPool);
|
||||
GN_HANDLE(gnCommandBuffer);
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user