finish new loader structure for vulkan

This commit is contained in:
Gregory Wells
2025-06-24 14:43:59 -04:00
parent 4ec3d62146
commit 8cc44c709e
40 changed files with 178 additions and 93 deletions

View File

@@ -0,0 +1,24 @@
#include "vulkan_loader.h"
#include <commands/command_buffer/vulkan_command_buffer.h>
#include <commands/commands/vulkan_commands.h>
gnCommandFunctions loadVulkanCommandFunctions() {
return (gnCommandFunctions){
._gnCommandPoolAllocateCommandBuffers = allocateCommandBuffers,
._gnBeginCommandBuffer = beginCommandBuffer,
._gnResetCommandBuffer = resetCommandBuffer,
._gnEndCommandBuffer = endCommandBuffer,
._gnCommandBeginRenderPass = beginRenderPass,
._gnCommandEndRenderPass = endRenderPass,
._gnCommandBindGraphicsPipeline = bindGraphicsPipeline,
._gnCommandSetViewport = setViewport,
._gnCommandSetScissor = setScissor,
._gnCommandBindUniform = bindUniform,
._gnCommandPushConstant = pushConstant,
._gnCommandBindBuffer = bindBuffer,
._gnCommandDraw = draw,
._gnCommandDrawIndexed = drawIndexed,
};
}

View File

@@ -6,7 +6,13 @@
#include <framebuffers/vulkan_framebuffer.h>
#include <textures/vulkan_texture.h>
#include <uniforms/vulkan_uniform_pool.h>
#include <uniforms/vulkan_uniform.h>
#include <commands/command_pool/vulkan_command_pool.h>
#include <buffers/vulkan_buffer.h>
#include <sync/semaphore/vulkan_semaphore.h>
#include <sync/fence/vulkan_fence.h>
#include <present/vulkan_present.h>
#include <submit/vulkan_submit.h>
#include <output_device/vulkan_output_devices.h>
gnDeviceFunctions loadVulkanDeviceFunctions() {
@@ -30,33 +36,32 @@ gnDeviceFunctions loadVulkanDeviceFunctions() {
._gnCreateCommandPool = createCommandPool,
._gnDestroyCommandPool = destroyCommandPool,
// gnReturnCode (*_gnCreateSemaphore)(gnSemaphoreHandle semaphore, gnOutputDeviceHandle device);
// void (*_gnDestroySemaphore)(gnSemaphoreHandle semaphore);
._gnCreateSemaphore = createSemaphore,
._gnDestroySemaphore = destroySemaphore,
// gnReturnCode (*_gnCreateBuffer)(gnBufferHandle buffer, gnDeviceHandle device, gnBufferInfo info);
// void (*_gnBufferData)(gnBufferHandle buffer, size_t size, void* data);
// void* (*_gnMapBuffer)(gnBufferHandle buffer);
// void (*_gnDestroyBuffer)(gnBufferHandle buffer);
._gnCreateBuffer = createBuffer,
._gnBufferData = bufferData,
._gnMapBuffer = mapBuffer,
._gnDestroyBuffer = destroyBuffer,
._gnCreateUniformPool = createUniformPool,
._gnUniformPoolAllocateUniforms = allocateUniforms,
._gnDestroyUniformPool = destroyUniformPool,
// void (*_gnUpdateBufferUniform)(gnUniform uniform, gnBufferUniformInfo* bufferInfo);
// void (*_gnUpdateImageUniform)(gnUniform uniform, gnImageUniformInfo* imageInfo);
._gnUpdateBufferUniform = updateBufferUniform,
._gnUpdateImageUniform = updateImageUniform,
._gnCreateTexture = createTexture,
._gnTextureData = textureData,
._gnDestroyTexture = destroyTexture,
// gnReturnCode (*_gnCreateFence)(gnFenceHandle fence, gnOutputDeviceHandle device);
// void (*_gnSignalFence)(gnFenceHandle fence);
// void (*_gnWaitForFence)(gnFenceHandle fence, uint64_t timeout);
// void (*_gnResetFence)(gnFenceHandle fence);
// void (*_gnDestroyFence)(gnFenceHandle fence);
._gnCreateFence = createFence,
._gnWaitForFence = waitForFence,
._gnResetFence = resetFence,
._gnDestroyFence = destroyFence,
// gnReturnCode (*_gnSubmit)(gnOutputDeviceHandle device, gnSubmitInfo submit);
// gnReturnCode (*_gnPresent)(gnOutputDeviceHandle device, gnPresentInfo info);
._gnSubmit = submit,
._gnPresent = present,
._gnWaitForDevice = waitForDevice
};

View File

@@ -1,6 +1,8 @@
#pragma once
#include "loader/src/gryphn_instance_functions.h"
#include "loader/src/gryphn_device_functions.h"
#include "loader/src/gryphn_command_functions.h"
gnInstanceFunctions loadVulkanInstanceFunctions();
gnDeviceFunctions loadVulkanDeviceFunctions();
gnCommandFunctions loadVulkanCommandFunctions();

View File

@@ -66,7 +66,7 @@ void VkCopyBuffer(VkBuffer source, VkBuffer destination, size_t size, VkCommandP
VkEndTransferOperation(transferBuffer, pool, queue, device);
}
gnReturnCode gnCreateBufferFn(gnBufferHandle buffer, gnOutputDeviceHandle device, gnBufferInfo info) {
gnReturnCode createBuffer(gnBufferHandle buffer, gnOutputDeviceHandle device, gnBufferInfo info) {
buffer->buffer = malloc(sizeof(struct gnPlatformBuffer_t));
VkBufferUsageFlags usage = vkGryphnBufferType(info.type);
buffer->buffer->useStagingBuffer = gnFalse;
@@ -98,7 +98,7 @@ gnReturnCode gnCreateBufferFn(gnBufferHandle buffer, gnOutputDeviceHandle device
return GN_SUCCESS;
}
void gnBufferDataFn(gnBufferHandle buffer, size_t dataSize, void* data) {
void bufferData(gnBufferHandle buffer, size_t dataSize, void* data) {
void* bufferData;
if (buffer->buffer->useStagingBuffer) {
vkMapMemory(buffer->device->outputDevice->device, buffer->buffer->stagingBuffer.memory, 0, dataSize, 0, &bufferData);
@@ -114,7 +114,7 @@ void gnBufferDataFn(gnBufferHandle buffer, size_t dataSize, void* data) {
vkUnmapMemory(buffer->device->outputDevice->device, buffer->buffer->buffer.memory);
}
}
void* gnMapBufferFn(gnBufferHandle buffer) {
void* mapBuffer(gnBufferHandle buffer) {
void* data;
vkMapMemory(buffer->device->outputDevice->device, buffer->buffer->buffer.memory, 0, buffer->info.size, 0, &data);
return data;
@@ -125,7 +125,7 @@ void gnDestroyVulkanBuffer(VkGryphnBuffer* buffer, VkDevice device) {
vkFreeMemory(device, buffer->memory, NULL);
}
void gnDestroyBufferFn(gnBufferHandle buffer) {
void destroyBuffer(gnBufferHandle buffer) {
if (buffer->buffer->useStagingBuffer == gnTrue) gnDestroyVulkanBuffer(&buffer->buffer->stagingBuffer, buffer->device->outputDevice->device);
gnDestroyVulkanBuffer(&buffer->buffer->buffer, buffer->device->outputDevice->device);
free(buffer->buffer);

View File

@@ -22,3 +22,8 @@ gnReturnCode VkCreateBuffer(
VkMemoryPropertyFlags flags, VkBufferUsageFlags usage
);
uint32_t VkMemoryIndex(VkPhysicalDevice device, uint32_t memoryType, VkMemoryPropertyFlags flags, gnBool* foundMemory);
gnReturnCode createBuffer(gnBufferHandle buffer, gnOutputDeviceHandle device, gnBufferInfo info);
void bufferData(gnBufferHandle buffer, size_t dataSize, void* data);
void* mapBuffer(gnBufferHandle buffer);
void destroyBuffer(gnBufferHandle buffer);

View File

@@ -2,7 +2,7 @@
#include "commands/command_pool/vulkan_command_pool.h"
#include "output_device/vulkan_output_devices.h"
gnReturnCode gnCommandPoolAllocateCommandBuffersFn(gnCommandBufferHandle* commandBuffers, uint32_t count, struct gnCommandPool_t* pool) {
gnReturnCode allocateCommandBuffers(gnCommandBufferHandle* commandBuffers, uint32_t count, gnCommandPool pool) {
VkCommandBufferAllocateInfo allocInfo = {
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
.commandPool = pool->commandPool->commandPool,
@@ -23,12 +23,12 @@ gnReturnCode gnCommandPoolAllocateCommandBuffersFn(gnCommandBufferHandle* comman
return GN_SUCCESS;
}
void gnResetCommandBufferFn(struct gnCommandBuffer_t* commandBuffer) {
void resetCommandBuffer(gnCommandBufferHandle commandBuffer) {
vkResetCommandBuffer(commandBuffer->commandBuffer->buffer, 0);
}
gnReturnCode gnBeginCommandBufferFn(struct gnCommandBuffer_t* commandBuffer) {
gnReturnCode beginCommandBuffer(gnCommandBufferHandle commandBuffer) {
VkCommandBufferBeginInfo beginInfo = {
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO
};
@@ -39,7 +39,7 @@ gnReturnCode gnBeginCommandBufferFn(struct gnCommandBuffer_t* commandBuffer) {
return GN_SUCCESS;
}
gnReturnCode gnEndCommandBufferFn(struct gnCommandBuffer_t* commandBuffer) {
gnReturnCode endCommandBuffer(gnCommandBufferHandle commandBuffer) {
if (vkEndCommandBuffer(commandBuffer->commandBuffer->buffer) != VK_SUCCESS)
return GN_FAIELD_TO_END_RECORDING;
return GN_SUCCESS;

View File

@@ -13,3 +13,9 @@ typedef struct gnPlatformCommandBuffer_t {
VkCommandBuffer VkBeginTransferOperation(VkDevice device, VkCommandPool pool);
void VkEndTransferOperation(VkCommandBuffer transferBuffer, VkCommandPool pool, VkQueue syncQueue, VkDevice device);
gnReturnCode allocateCommandBuffers(gnCommandBufferHandle* commandBuffers, uint32_t count, gnCommandPool pool);
gnReturnCode beginCommandBuffer(gnCommandBufferHandle commandBuffer);
void resetCommandBuffer(gnCommandBufferHandle commandBuffer);
gnReturnCode endCommandBuffer(gnCommandBufferHandle commandBuffer);

View File

@@ -1,14 +1,6 @@
#include <vulkan/vulkan.h>
#include "command/commands/gryphn_command.h"
#include <renderpass/vulkan_render_pass_descriptor.h>
#include "framebuffers/vulkan_framebuffer.h"
#include "commands/command_buffer/vulkan_command_buffer.h"
#include "pipelines/graphics_pipeline/vulkan_graphics_pipeline.h"
#include "buffers/vulkan_buffer.h"
#include "uniforms/vulkan_uniform.h"
#include "shader_module/vulkan_shader_module.h"
#include "vulkan_commands.h"
void gnCommandBeginRenderPassFn(gnCommandBuffer buffer, gnRenderPassInfo passInfo) {
void beginRenderPass(gnCommandBuffer buffer, gnRenderPassInfo passInfo) {
VkClearValue* values = malloc(sizeof(VkClearValue) * passInfo.clearValueCount);
for (int i = 0; i < passInfo.clearValueCount; i++) {
values[i] = (VkClearValue){{{
@@ -33,14 +25,14 @@ void gnCommandBeginRenderPassFn(gnCommandBuffer buffer, gnRenderPassInfo passInf
vkCmdBeginRenderPass(buffer->commandBuffer->buffer, &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE);
}
void gnCommandEndRenderPassFn(gnCommandBuffer buffer) {
void endRenderPass(gnCommandBuffer buffer) {
vkCmdEndRenderPass(buffer->commandBuffer->buffer);
}
void gnCommandBindGraphicsPipelineFn(gnCommandBuffer buffer, gnGraphicsPipeline graphicsPipeline) {
void bindGraphicsPipeline(gnCommandBuffer buffer, gnGraphicsPipeline graphicsPipeline) {
buffer->commandBuffer->boundGraphicsPipeline = graphicsPipeline;
vkCmdBindPipeline(buffer->commandBuffer->buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, graphicsPipeline->graphicsPipeline->graphicsPipeline);
}
void gnCommandSetViewportFn(gnCommandBuffer buffer, gnViewport viewport) {
void setViewport(gnCommandBuffer buffer, gnViewport viewport) {
VkViewport vkViewport = {
.x = viewport.position.x,
.y = viewport.size.y,
@@ -51,7 +43,7 @@ void gnCommandSetViewportFn(gnCommandBuffer buffer, gnViewport viewport) {
};
vkCmdSetViewport(buffer->commandBuffer->buffer, 0, 1, &vkViewport);
}
void gnCommandSetScissorFn(gnCommandBuffer buffer, gnScissor scissor) {
void setScissor(gnCommandBuffer buffer, gnScissor scissor) {
VkRect2D vkScissor = {
.extent = { scissor.size.x, scissor.size.y },
.offset = { scissor.position.x, scissor.position.y }
@@ -59,7 +51,7 @@ void gnCommandSetScissorFn(gnCommandBuffer buffer, gnScissor scissor) {
vkCmdSetScissor(buffer->commandBuffer->buffer, 0, 1, &vkScissor);
}
VkDeviceSize offsets[] = {0};
void gnCommandBindBufferFn(gnCommandBufferHandle buffer, gnBufferHandle bufferToBind, gnBufferType type) {
void bindBuffer(gnCommandBufferHandle buffer, gnBufferHandle bufferToBind, gnBufferType type) {
if (type == GN_VERTEX_BUFFER)
vkCmdBindVertexBuffers(buffer->commandBuffer->buffer, 0, 1, &bufferToBind->buffer->buffer.buffer, offsets);
else if (type == GN_INDEX_BUFFER) {
@@ -67,16 +59,16 @@ void gnCommandBindBufferFn(gnCommandBufferHandle buffer, gnBufferHandle bufferTo
buffer->commandBuffer->boundIndexBuffer = bufferToBind;
}
}
void gnCommandDrawFn(gnCommandBuffer buffer, int vertexCount, int firstVertex, int instanceCount, int firstInstance) {
void draw(gnCommandBuffer buffer, int vertexCount, int firstVertex, int instanceCount, int firstInstance) {
vkCmdDraw(buffer->commandBuffer->buffer, vertexCount, instanceCount, firstVertex, firstInstance);
}
void gnCommandDrawIndexedFn(gnCommandBufferHandle buffer, gnIndexType type, int indexCount, int firstIndex, int vertexOffset, int instanceCount, int firstInstance) {
void drawIndexed(gnCommandBufferHandle buffer, gnIndexType type, int indexCount, int firstIndex, int vertexOffset, int instanceCount, int firstInstance) {
if (buffer->commandBuffer->changedBuffer) vkCmdBindIndexBuffer(buffer->commandBuffer->buffer, buffer->commandBuffer->boundIndexBuffer->buffer->buffer.buffer, 0, (type == GN_UINT32) ? VK_INDEX_TYPE_UINT32 : VK_INDEX_TYPE_UINT16);
vkCmdDrawIndexed(buffer->commandBuffer->buffer, indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
buffer->commandBuffer->changedBuffer = gnFalse;
}
void gnCommandBindUniformFn(gnCommandBufferHandle buffer, gnUniform uniform, uint32_t set) {
void bindUniform(gnCommandBufferHandle buffer, gnUniform uniform, uint32_t set) {
vkCmdBindDescriptorSets(
buffer->commandBuffer->buffer,
VK_PIPELINE_BIND_POINT_GRAPHICS,
@@ -85,7 +77,7 @@ void gnCommandBindUniformFn(gnCommandBufferHandle buffer, gnUniform uniform, uin
);
}
void gnCommandPushConstantFn(gnCommandBufferHandle buffer, gnPushConstantLayout layout, void* data) {
void pushConstant(gnCommandBufferHandle buffer, gnPushConstantLayout layout, void* data) {
vkCmdPushConstants(
buffer->commandBuffer->buffer,
buffer->commandBuffer->boundGraphicsPipeline->graphicsPipeline->pipelineLayout,

View File

@@ -0,0 +1,21 @@
#pragma once
#include <vulkan/vulkan.h>
#include "command/commands/gryphn_command.h"
#include <renderpass/vulkan_render_pass_descriptor.h>
#include <framebuffers/vulkan_framebuffer.h>
#include <commands/command_buffer/vulkan_command_buffer.h>
#include <pipelines/graphics_pipeline/vulkan_graphics_pipeline.h>
#include <buffers/vulkan_buffer.h>
#include <uniforms/vulkan_uniform.h>
#include <shader_module/vulkan_shader_module.h>
void beginRenderPass(gnCommandBuffer buffer, gnRenderPassInfo passInfo);
void endRenderPass(gnCommandBuffer buffer);
void bindGraphicsPipeline(gnCommandBuffer buffer, gnGraphicsPipeline graphicsPipeline);
void setViewport(gnCommandBuffer buffer, gnViewport viewport);
void setScissor(gnCommandBuffer buffer, gnScissor scissor);
void bindBuffer(gnCommandBufferHandle buffer, gnBufferHandle bufferToBind, gnBufferType type);
void draw(gnCommandBuffer buffer, int vertexCount, int firstVertex, int instanceCount, int firstInstance);
void drawIndexed(gnCommandBufferHandle buffer, gnIndexType type, int indexCount, int firstIndex, int vertexOffset, int instanceCount, int firstInstance);
void bindUniform(gnCommandBufferHandle buffer, gnUniform uniform, uint32_t set);
void pushConstant(gnCommandBufferHandle buffer, gnPushConstantLayout layout, void* data);

View File

@@ -1,9 +1,6 @@
#include "present/gryphn_present.h"
#include "sync/semaphore/vulkan_semaphore.h"
#include "presentation_queue/vulkan_presentation_queue.h"
#include "output_device/vulkan_output_devices.h"
#include "vulkan_present.h"
gnReturnCode gnPresentFn(gnDevice device, gnPresentInfo info) {
gnReturnCode present(gnDevice device, gnPresentInfo info) {
VkSemaphore* waitSemaphores = malloc(sizeof(VkSemaphore) * info.waitCount);
for (int i = 0; i < info.waitCount; i++) waitSemaphores[i] = info.waitSemaphores[i]->semaphore->semaphore;

View File

@@ -0,0 +1,6 @@
#include "present/gryphn_present.h"
#include <sync/semaphore/vulkan_semaphore.h>
#include <presentation_queue/vulkan_presentation_queue.h>
#include <output_device/vulkan_output_devices.h>
gnReturnCode present(gnDevice device, gnPresentInfo info);

View File

@@ -1,13 +1,7 @@
#include <vulkan/vulkan.h>
#include "submit/gryphn_submit.h"
#include "sync/semaphore/vulkan_semaphore.h"
#include "sync/fence/vulkan_fence.h"
#include "commands/command_buffer/vulkan_command_buffer.h"
#include "output_device/vulkan_output_devices.h"
#include "renderpass/vulkan_render_pass_descriptor.h"
#include "vulkan_submit.h"
gnReturnCode gnSubmitFn(gnDevice device, gnSubmitInfo info) {
gnReturnCode submit(gnDevice device, gnSubmitInfo info) {
VkSemaphore* waitSemaphores = malloc(sizeof(VkSemaphore) * info.waitCount);
VkPipelineStageFlags* waitStages = malloc(sizeof(VkPipelineStageFlags) * info.waitCount);
for (int i = 0; i < info.waitCount; i++) waitSemaphores[i] = info.waitSemaphores[i]->semaphore->semaphore;

View File

@@ -0,0 +1,9 @@
#include <vulkan/vulkan.h>
#include <submit/gryphn_submit.h>
#include <sync/semaphore/vulkan_semaphore.h>
#include <sync/fence/vulkan_fence.h>
#include <commands/command_buffer/vulkan_command_buffer.h>
#include <output_device/vulkan_output_devices.h>
#include <renderpass/vulkan_render_pass_descriptor.h>
gnReturnCode submit(gnDevice device, gnSubmitInfo info);

View File

@@ -1,7 +1,7 @@
#include "vulkan_fence.h"
#include "output_device/vulkan_output_devices.h"
gnReturnCode gnCreateFenceFn(struct gnFence_t* fence, struct gnOutputDevice_t* device) {
gnReturnCode createFence(gnFence fence, gnDevice device) {
fence->fence = malloc(sizeof(gnPlatformFence));
VkFenceCreateInfo fenceInfo = {
.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO
@@ -10,14 +10,13 @@ gnReturnCode gnCreateFenceFn(struct gnFence_t* fence, struct gnOutputDevice_t* d
return GN_FAILED_TO_CREATE_FENCE;
return GN_SUCCESS;
}
void gnSignalFenceFn(struct gnFence_t* fence) {}
void gnWaitForFenceFn(struct gnFence_t* fence, uint64_t timeout) {
void waitForFence(gnFence fence, uint64_t timeout) {
vkWaitForFences(fence->device->outputDevice->device, 1, &fence->fence->fence, VK_TRUE, timeout);
}
void gnResetFenceFn(struct gnFence_t* fence) {
void resetFence(gnFence fence) {
vkResetFences(fence->device->outputDevice->device, 1, &fence->fence->fence);
}
void gnDestroyFenceFn(struct gnFence_t* fence) {
void destroyFence(gnFence fence) {
vkDestroyFence(fence->device->outputDevice->device, fence->fence->fence, NULL);
free(fence->fence);
}

View File

@@ -5,3 +5,8 @@
typedef struct gnPlatformFence_t {
VkFence fence;
} gnPlatformFence;
gnReturnCode createFence(gnFence fence, gnDevice device);
void waitForFence(gnFence fence, uint64_t timeout);
void resetFence(gnFence fence);
void destroyFence(gnFence fence);

View File

@@ -1,7 +1,7 @@
#include "vulkan_semaphore.h"
#include "output_device/vulkan_output_devices.h"
gnReturnCode gnCreateSemaphoreFn(struct gnSemaphore_t* semaphore, struct gnOutputDevice_t* device) {
gnReturnCode createSemaphore(gnSemaphore semaphore, gnDevice device) {
semaphore->semaphore = malloc(sizeof(gnPlatformSemaphore));
VkSemaphoreCreateInfo semaphoreInfo = {
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO
@@ -11,7 +11,7 @@ gnReturnCode gnCreateSemaphoreFn(struct gnSemaphore_t* semaphore, struct gnOutpu
return GN_FAILED_TO_CREATE_SEMAPHORE;
return GN_SUCCESS;
}
void gnDestroySemaphoreFn(struct gnSemaphore_t* semaphore) {
void destroySemaphore(gnSemaphore semaphore) {
vkDestroySemaphore(semaphore->device->outputDevice->device, semaphore->semaphore->semaphore, NULL);
free(semaphore->semaphore);
}

View File

@@ -5,3 +5,6 @@
typedef struct gnPlatformSemaphore_t {
VkSemaphore semaphore;
} gnPlatformSemaphore;
gnReturnCode createSemaphore(gnSemaphore semaphore, gnDevice device);
void destroySemaphore(gnSemaphore semaphore);

View File

@@ -4,7 +4,7 @@
#include "uniforms/gryphn_uniform_pool.h"
#include "textures/vulkan_texture.h"
void gnUpdateBufferUniformFn(gnUniform uniform, gnBufferUniformInfo* info) {
void updateBufferUniform(gnUniform uniform, gnBufferUniformInfo* info) {
VkDescriptorBufferInfo bufferInfo = {
.buffer = info->buffer->buffer->buffer.buffer,
.offset = info->offset,
@@ -24,7 +24,7 @@ void gnUpdateBufferUniformFn(gnUniform uniform, gnBufferUniformInfo* info) {
vkUpdateDescriptorSets(uniform->pool->device->outputDevice->device, 1, &write, 0, NULL);
}
void gnUpdateImageUniformFn(gnUniform uniform, gnImageUniformInfo* info) {
void updateImageUniform(gnUniform uniform, gnImageUniformInfo* info) {
VkDescriptorImageInfo imageInfo = {
.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
.imageView = info->texture->texture->image.imageView,

View File

@@ -5,3 +5,6 @@
typedef struct gnPlatformUniform_t {
VkDescriptorSet set;
} gnPlatformUniform;
void updateBufferUniform(gnUniform uniform, gnBufferUniformInfo* info);
void updateImageUniform(gnUniform uniform, gnImageUniformInfo* info);

View File

@@ -1,6 +1,5 @@
#include "gryphn_buffer.h"
#include "output_device/gryphn_output_device.h"
#include "gryphn_platform_functions.h"
gnReturnCode gnCreateBuffer(gnBufferHandle* buffer, gnOutputDeviceHandle device, gnBufferInfo info) {
*buffer = malloc(sizeof(struct gnBuffer_t));

View File

@@ -1,8 +1,11 @@
#include "gryphn_command_pool.h"
#include "stdlib.h"
#include "output_device/gryphn_output_device.h"
#include "instance/gryphn_instance.h"
gnReturnCode gnCreateCommandPool(gnCommandPoolHandle* commandPool, gnOutputDeviceHandle device, gnCommandPoolInfo info) {
*commandPool = malloc(sizeof(struct gnCommandPool_t));
(*commandPool)->commandFunctions = device->instance->commandFunctions;
(*commandPool)->commandFunctions = &device->instance->commandFunctions;
(*commandPool)->device = device;
return device->deviceFunctions->_gnCreateCommandPool((*commandPool), device, info);

View File

@@ -2,7 +2,7 @@
#include "stdint.h"
#include <utils/gryphn_error_code.h>
#include "gryphn_handles.h"
#include <gryphn_platform_functions.h>
#include "loader/src/gryphn_command_functions.h"
typedef struct gnCommandPoolInfo {
uint32_t queueIndex;
@@ -11,8 +11,8 @@ typedef struct gnCommandPoolInfo {
#ifdef GN_REVEAL_IMPL
struct gnCommandPool_t {
struct gnPlatformCommandPool_t* commandPool;
struct gnCommandFunctions_t* commandFunctions;
struct gnOutputDevice_t* device;
gnCommandFunctions* commandFunctions;
gnDevice device;
};
#endif

View File

@@ -1,7 +1,6 @@
#include "gryphn_command.h"
#include "command/command_buffer/gryphn_command_buffer.h"
#include "command/command_pool/gryphn_command_pool.h"
#include "gryphn_platform_functions.h"
void gnCommandBeginRenderPass(gnCommandBufferHandle buffer, gnRenderPassInfo passInfo) {
buffer->commandPool->commandFunctions->_gnCommandBeginRenderPass(buffer, passInfo);

View File

@@ -1,5 +1,4 @@
#include "gryphn_debugger.h"
#include <gryphn_platform_functions.h>
gnReturnCode gnCreateDebugger(gnDebuggerHandle* debugger, const gnDebuggerInfo info) {
*debugger = malloc(sizeof(struct gnDebugger_t));

View File

@@ -1,5 +1,6 @@
#include "gryphn_framebuffer.h"
#include "gryphn_platform_functions.h"
#include "stdlib.h"
#include "output_device/gryphn_output_device.h"
gnReturnCode gnCreateFramebuffer(gnFramebuffer* framebuffer, gnOutputDeviceHandle device, gnFramebufferInfo framebufferInfo) {
*framebuffer = malloc(sizeof(struct gnFramebuffer_t));

View File

@@ -1,5 +1,4 @@
#include "gryphn_instance.h"
#include <gryphn_platform_functions.h>
#include "instance/gryphn_instance.h"
#include <loader/src/gryphn_instance_functions.h>
#include "loader/src/gryphn_loader.h"
@@ -13,6 +12,7 @@ gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceInfo info) {
(*instance)->instanceFunctions = loadInstanceFunctions(loadInfo);
(*instance)->deviceFunctions = loadDeviceFunctions(loadInfo);
(*instance)->commandFunctions = loadCommandFunctions(loadInfo);
(*instance)->debugger = info.debugger;
return (*instance)->instanceFunctions._gnCreateInstance((*instance), info);
}

View File

@@ -5,6 +5,7 @@
#include "utils/gryphn_error_code.h"
#include "loader/src/gryphn_instance_functions.h"
#include "loader/src/gryphn_device_functions.h"
#include "loader/src/gryphn_command_functions.h"
typedef struct gnInstanceInfo {
gnString applicationName;
@@ -24,7 +25,7 @@ struct gnInstance_t {
gnInstanceFunctions instanceFunctions;
gnDeviceFunctions deviceFunctions;
struct gnCommandFunctions_t* commandFunctions;
gnCommandFunctions commandFunctions;
gnDebuggerHandle debugger;
};

View File

@@ -1,5 +1,4 @@
#include "gryphn_graphics_pipeline.h"
#include "gryphn_platform_functions.h"
gnReturnCode gnCreateGraphicsPipeline(gnGraphicsPipelineHandle* graphicsPipeline, gnDevice device, gnGraphicsPipelineInfo info) {
*graphicsPipeline = malloc(sizeof(struct gnGraphicsPipeline_t));

View File

@@ -3,7 +3,7 @@
#include "utils/math/gryphn_vec2.h"
#include "gryphn_handles.h"
typedef struct gnRenderPassInfo_t {
typedef struct gnRenderPassInfo {
gnRenderPassDescriptorHandle renderPassDescriptor;
gnFramebuffer framebuffer;
gnUInt2 offset;

View File

@@ -1,5 +1,5 @@
#include "gryphn_render_pass_descriptor.h"
#include "gryphn_platform_functions.h"
#include "output_device/gryphn_output_device.h"
gnReturnCode gnCreateRenderPassDescriptor(gnRenderPassDescriptorHandle* renderPass, gnOutputDeviceHandle device, gnRenderPassDescriptorInfo info) {
*renderPass = malloc(sizeof(struct gnRenderPassDescriptor_t));

View File

@@ -1,5 +1,5 @@
#include <gryphn_platform_functions.h>
#include "gryphn_shader_module.h"
#include "output_device/gryphn_output_device.h"
gnReturnCode gnCreateShaderModule(gnShaderModuleHandle* module, gnOutputDeviceHandle device, struct gnShaderModuleInfo shaderModuleInfo) {
*module = malloc(sizeof(struct gnShaderModule_t));

View File

@@ -1,5 +1,5 @@
#include "gryphn_fence.h"
#include "gryphn_platform_functions.h"
#include "output_device/gryphn_output_device.h"
gnReturnCode gnCreateFence(gnFenceHandle* fence, struct gnOutputDevice_t* device) {
*fence = malloc(sizeof(struct gnFence_t));
@@ -9,7 +9,6 @@ gnReturnCode gnCreateFence(gnFenceHandle* fence, struct gnOutputDevice_t* device
}
void gnSignalFence(gnFenceHandle fence) {
fence->signaled = gnTrue;
// fence->device->deviceFunctions->_gnSignalFence(fence);
}
void gnWaitForFence(gnFenceHandle fence, uint64_t timeout) {
if (fence->signaled == gnTrue) return;

View File

@@ -1,5 +1,5 @@
#include "gryphn_semaphore.h"
#include "gryphn_platform_functions.h"
#include "output_device/gryphn_output_device.h"
gnReturnCode gnCreateSemaphore(gnSemaphore* semaphore, struct gnOutputDevice_t* device) {
*semaphore = malloc(sizeof(struct gnSemaphore_t));

View File

@@ -1,5 +1,5 @@
#include "gryphn_texture.h"
#include "gryphn_platform_functions.h"
#include "output_device/gryphn_output_device.h"
gnReturnCode gnCreateTexture(gnTexture* texture, gnDevice device, const gnTextureInfo info) {
*texture = malloc(sizeof(struct gnTexture_t));

View File

@@ -1,7 +1,6 @@
#include "gryphn_uniform.h"
#include "gryphn_uniform_pool.h"
#include "output_device/gryphn_output_device.h"
#include "gryphn_platform_functions.h"
void gnUpdateBufferUniform(gnUniform uniform, gnBufferUniformInfo bufferInfo) {
uniform->pool->device->deviceFunctions->_gnUpdateBufferUniform(uniform, &bufferInfo);

View File

@@ -1,6 +1,5 @@
#include "gryphn_uniform_pool.h"
#include "output_device/gryphn_output_device.h"
#include "gryphn_platform_functions.h"
#include "gryphn_uniform.h"
#include "stdlib.h"

View File

@@ -1,12 +1,14 @@
#pragma once
// theoretically you could have multible gryphn instances running in one application,
// why I dont know
#include "instance/gryphn_instance.h"
#include <debugger/gryphn_debugger.h>
#include <window_surface/gryphn_surface_create_functions.h>
#include "pipelines/graphics_pipeline/gryphn_graphics_pipeline.h"
#include "renderpass/gryphn_render_pass.h"
#include "buffers/gryphn_buffer.h"
#include "stdint.h"
#include "utils/gryphn_error_code.h"
#include "gryphn_handles.h"
typedef struct gnRenderPassInfo gnRenderPassInfo;
typedef struct gnViewport gnViewport;
typedef struct gnScissor gnScissor;
typedef struct gnPushConstantLayout gnPushConstantLayout;
typedef enum gnBufferType gnBufferType;
typedef enum gnIndexType gnIndexType;
typedef struct gnCommandFunctions_t {
gnReturnCode (*_gnCommandPoolAllocateCommandBuffers)(gnCommandBufferHandle* commandBuffers, uint32_t count, gnCommandPoolHandle pool);

View File

@@ -58,7 +58,6 @@ typedef struct gnDeviceFunctions {
void (*_gnDestroyTexture)(gnTexture texture);
gnReturnCode (*_gnCreateFence)(gnFenceHandle fence, gnOutputDeviceHandle device);
void (*_gnSignalFence)(gnFenceHandle fence);
void (*_gnWaitForFence)(gnFenceHandle fence, uint64_t timeout);
void (*_gnResetFence)(gnFenceHandle fence);
void (*_gnDestroyFence)(gnFenceHandle fence);

View File

@@ -26,3 +26,16 @@ gnDeviceFunctions loadDeviceFunctions(loaderInfo info) {
case GN_RENDERINGAPI_METAL: return (gnDeviceFunctions){ NULL };
}
}
gnCommandFunctions loadCommandFunctions(loaderInfo info) {
switch (info.api) {
case GN_RENDERINGAPI_NONE: return (gnCommandFunctions){ NULL };
case GN_RENDERINGAPI_VULKAN: return loadVulkanCommandFunctions();
case GN_RENDERINGAPI_SOFTWARE: return (gnCommandFunctions){ NULL };
case GN_RENDERINGAPI_DIRECTX11: return (gnCommandFunctions){ NULL };
case GN_RENDERINGAPI_DIRECTX12: return (gnCommandFunctions){ NULL };
case GN_RENDERINGAPI_OPENGL: return (gnCommandFunctions){ NULL };
case GN_RENDERINGAPI_METAL: return (gnCommandFunctions){ NULL };
}
}

View File

@@ -2,6 +2,7 @@
#include "gryphn_rendering_api.h"
#include "gryphn_instance_functions.h"
#include "gryphn_device_functions.h"
#include "gryphn_command_functions.h"
typedef struct loaderInfo {
gnRenderingAPI api;
@@ -9,3 +10,4 @@ typedef struct loaderInfo {
gnInstanceFunctions loadInstanceFunctions(loaderInfo info);
gnDeviceFunctions loadDeviceFunctions(loaderInfo info);
gnCommandFunctions loadCommandFunctions(loaderInfo info);