gryphn+vulkan command buffers
This commit is contained in:
18
src/core/command/command_buffer/gryphn_command_buffer.c
Normal file
18
src/core/command/command_buffer/gryphn_command_buffer.c
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "gryphn_command_buffer.h"
|
||||
#include "core/gryphn_platform_functions.h"
|
||||
#include "stdio.h"
|
||||
|
||||
gnReturnCode gnCommandPoolAllocateCommandBuffers(struct gnCommandBuffer_t* buffers, uint32_t count, struct gnCommandPool_t* commandPool) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
buffers[i].commandPool = commandPool;
|
||||
}
|
||||
return commandPool->commandFunctions->_gnCommandPoolAllocateCommandBuffers(buffers, count, commandPool);
|
||||
}
|
||||
|
||||
gnReturnCode gnBeginCommandBuffer(struct gnCommandBuffer_t* commandBuffer) {
|
||||
return commandBuffer->commandPool->commandFunctions->_gnBeginCommandBuffer(commandBuffer);
|
||||
}
|
||||
|
||||
gnReturnCode gnEndCommandBuffer(struct gnCommandBuffer_t* commandBuffer) {
|
||||
return commandBuffer->commandPool->commandFunctions->_gnEndCommandBuffer(commandBuffer);
|
||||
}
|
@@ -1,10 +1,12 @@
|
||||
#pragma once
|
||||
#include <core/command/command_pool/gryphn_command_pool.h>
|
||||
#include "core/renderpass/gryphn_render_pass.h"
|
||||
|
||||
typedef struct gnCommandBuffer_t {
|
||||
struct gnPlatformCommandBuffer_t* commandBuffer;
|
||||
struct gnCommandPool_t* commandPool;
|
||||
} gnCommandBuffer;
|
||||
|
||||
gnReturnCode gnCommandPoolAllocateCommandBuffers(struct gnCommandBuffer_t* buffers, uint32_t count, struct gnCommandPool_t* commandPool);
|
||||
|
||||
gnReturnCode gnBeginCommandBuffer(struct gnCommandBuffer_t* commandBuffer);
|
||||
void gnCommandBufferBeginRenderPass(struct gnRenderPassInfo_t passInfo);
|
||||
gnReturnCode gnEndCommandBuffer(struct gnCommandBuffer_t* commandBuffer);
|
||||
|
@@ -1,7 +1,15 @@
|
||||
#include "gryphn_command_pool.h"
|
||||
#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) {
|
||||
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->device = device;
|
||||
return device->deviceFunctions->_gnCreateCommandPool(commandPool, device, info);
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@ typedef struct gnCommandPoolInfo_t {
|
||||
|
||||
typedef struct gnCommandPool_t {
|
||||
struct gnPlatformCommandPool_t* commandPool;
|
||||
struct gnCommandFunctions_t* commandFunctions;
|
||||
struct gnOutputDevice_t* device;
|
||||
} gnCommandPool;
|
||||
|
||||
|
23
src/core/command/commands/gryphn_command.c
Normal file
23
src/core/command/commands/gryphn_command.c
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "gryphn_command.h"
|
||||
#include "core/gryphn_platform_functions.h"
|
||||
|
||||
void gnCommandBeginRenderPass(struct gnCommandBuffer_t* buffer, struct gnRenderPassInfo_t passInfo) {
|
||||
buffer->commandPool->commandFunctions->_gnCommandBeginRenderPass(buffer, passInfo);
|
||||
}
|
||||
void gnCommandEndRenderPass(struct gnCommandBuffer_t* buffer) {
|
||||
buffer->commandPool->commandFunctions->_gnCommandEndRenderPass(buffer);
|
||||
}
|
||||
|
||||
void gnCommandBindGraphicsPipeline(struct gnCommandBuffer_t* buffer, struct gnGraphicsPipeline_t* graphicsPipeline) {
|
||||
buffer->commandPool->commandFunctions->_gnCommandBindGraphicsPipeline(buffer, graphicsPipeline);
|
||||
}
|
||||
void gnCommandSetViewport(struct gnCommandBuffer_t* buffer, struct gnViewport_t viewport) {
|
||||
buffer->commandPool->commandFunctions->_gnCommandSetViewport(buffer, viewport);
|
||||
}
|
||||
void gnCommandSetScissor(struct gnCommandBuffer_t* buffer, struct gnScissor_t scissor) {
|
||||
buffer->commandPool->commandFunctions->_gnCommandSetScissor(buffer, scissor);
|
||||
}
|
||||
|
||||
void gnCommandDraw(struct gnCommandBuffer_t* buffer, int vertexCount, int firstVertex, int instanceCount, int firstInstance) {
|
||||
buffer->commandPool->commandFunctions->_gnCommandDraw(buffer, vertexCount, firstVertex, instanceCount, firstInstance);
|
||||
}
|
13
src/core/command/commands/gryphn_command.h
Normal file
13
src/core/command/commands/gryphn_command.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#include "core/command/command_buffer/gryphn_command_buffer.h"
|
||||
|
||||
|
||||
#include "core/renderpass/gryphn_render_pass.h"
|
||||
void gnCommandBeginRenderPass(struct gnCommandBuffer_t* buffer, struct gnRenderPassInfo_t passInfo);
|
||||
void gnCommandEndRenderPass(struct gnCommandBuffer_t* buffer);
|
||||
|
||||
#include "core/pipelines/graphics_pipeline/gryphn_graphics_pipeline.h"
|
||||
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 gnCommandDraw(struct gnCommandBuffer_t* buffer, int vertexCount, int firstVertex, int instanceCount, int firstInstance);
|
@@ -53,7 +53,7 @@ typedef struct gnDebugger_t {
|
||||
gnReturnCode gnCreateDebugger(gnDebugger* debugger, const struct gnDebuggerInfo_t info);
|
||||
void gnDestroyDebugger(gnDebugger* debugger);
|
||||
|
||||
void gnDebuggerSetErrorMessage(gnDebugger* debugger, gnMessageData data) {
|
||||
static void gnDebuggerSetErrorMessage(gnDebugger* debugger, gnMessageData data) {
|
||||
debugger->info.callback(
|
||||
GN_MESSAGE_ERROR,
|
||||
GN_DEBUG_MESSAGE_VALIDATION,
|
||||
|
@@ -13,6 +13,7 @@
|
||||
#include "framebuffer/gryphn_framebuffer.h"
|
||||
#include "command/command_pool/gryphn_command_pool.h"
|
||||
#include "command/command_buffer/gryphn_command_buffer.h"
|
||||
#include "renderpass/gryphn_render_pass.h"
|
||||
|
||||
typedef struct gnFunctions_t {
|
||||
gnReturnCode (*_gnCreateInstance)(gnInstance* instance, struct gnInstanceInfo_t info);
|
||||
@@ -75,4 +76,15 @@ typedef struct gnDeviceFunctions_t {
|
||||
|
||||
typedef struct gnCommandFunctions_t {
|
||||
gnReturnCode (*_gnCommandPoolAllocateCommandBuffers)(struct gnCommandBuffer_t* commandBuffers, uint32_t count, struct gnCommandPool_t* pool);
|
||||
gnReturnCode (*_gnBeginCommandBuffer)(struct gnCommandBuffer_t* commandBuffer);
|
||||
gnReturnCode (*_gnEndCommandBuffer)(struct gnCommandBuffer_t* commandBuffer);
|
||||
|
||||
void (*_gnCommandBeginRenderPass)(struct gnCommandBuffer_t* buffer, struct gnRenderPassInfo_t passInfo);
|
||||
void (*_gnCommandEndRenderPass)(struct gnCommandBuffer_t* 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 (*_gnCommandDraw)(struct gnCommandBuffer_t* buffer, int vertexCount, int firstVertex, int instanceCount, int firstInstance);
|
||||
} gnCommandFunctions;
|
||||
|
@@ -11,7 +11,7 @@ typedef enum gnRenderingAPI_t {
|
||||
GN_RENDERINGAPI_METAL
|
||||
} gnRenderingAPI;
|
||||
|
||||
gnString gnRenderingAPIName(gnRenderingAPI api) {
|
||||
static gnString gnRenderingAPIName(gnRenderingAPI api) {
|
||||
switch (api) {
|
||||
case GN_RENDERINGAPI_NONE: return gnCreateString("GN_RENDERINGAPI_NONE");
|
||||
case GN_RENDERINGAPI_SOFTWARE: return gnCreateString("GN_RENDERINGAPI_SOFTWARE");
|
||||
|
@@ -82,3 +82,13 @@ void gnLoadDeviceFunctions(struct gnDynamicLibrary_t* lib, struct gnDeviceFuncti
|
||||
gnLoadDLLFunction(lib, functions->_gnCreateCommandPool, "gnCreateCommandPoolFn");
|
||||
gnLoadDLLFunction(lib, functions->_gnDestroyCommandPool, "gnDestroyCommandPoolFn");
|
||||
}
|
||||
|
||||
void gnLoadCommandFunctions(struct gnDynamicLibrary_t* lib, struct gnCommandFunctions_t* functions) {
|
||||
gnLoadDLLFunction(lib, functions->_gnCommandPoolAllocateCommandBuffers, "gnCommandPoolAllocateCommandBuffersFn");
|
||||
gnLoadDLLFunction(lib, functions->_gnBeginCommandBuffer, "gnBeginCommandBufferFn");
|
||||
gnLoadDLLFunction(lib, functions->_gnCommandBeginRenderPass, "gnCommandBeginRenderPassFn");
|
||||
gnLoadDLLFunction(lib, functions->_gnCommandEndRenderPass, "gnCommandEndRenderPassFn");
|
||||
gnLoadDLLFunction(lib, functions->_gnCommandSetViewport, "gnCommandSetViewportFn");
|
||||
gnLoadDLLFunction(lib, functions->_gnCommandSetScissor, "gnCommandSetScissorFn");
|
||||
gnLoadDLLFunction(lib, functions->_gnCommandDraw, "gnCommandDraw");
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@ gnBool gnIsAPISupported(gnRenderingAPI RenderingAPI);
|
||||
struct gnDynamicLibrary_t* gnLoadRenderingDLL(gnRenderingAPI RenderingAPI);
|
||||
void gnLoadFunctions(struct gnDynamicLibrary_t* lib, struct gnFunctions_t* functions);
|
||||
void gnLoadDeviceFunctions(struct gnDynamicLibrary_t* lib, struct gnDeviceFunctions_t* functions);
|
||||
void gnLoadCommandFunctions(struct gnDynamicLibrary_t* lib, struct gnCommandFunctions_t* function);
|
||||
|
||||
// #ifdef GN_REVEAL_IMPL
|
||||
// gnErrorCode gnInit(gnRenderingAPI RenderingAPI);
|
||||
|
@@ -1,10 +1,13 @@
|
||||
#pragma once
|
||||
#include "gryphn_render_pass_descriptor.h"
|
||||
#include "core/framebuffer/gryphn_framebuffer.h"
|
||||
#include "utils/types/gryphn_color.h"
|
||||
|
||||
typedef struct gnRenderPassInfo_t {
|
||||
struct gnRenderPassDescriptor_t* renderPassDescriptor;
|
||||
struct gnFramebuffer_t* framebuffer;
|
||||
gnUInt2 offset;
|
||||
gnUInt2 size;
|
||||
uint32_t clearValueCount;
|
||||
gnClearValue* clearValues;
|
||||
} gnRenderPassInfo;
|
||||
|
Reference in New Issue
Block a user