finish new loader structure for vulkan
This commit is contained in:
24
projects/apis/vulkan/loader/vulkan_command_loader.c
Normal file
24
projects/apis/vulkan/loader/vulkan_command_loader.c
Normal 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,
|
||||||
|
};
|
||||||
|
}
|
@@ -6,7 +6,13 @@
|
|||||||
#include <framebuffers/vulkan_framebuffer.h>
|
#include <framebuffers/vulkan_framebuffer.h>
|
||||||
#include <textures/vulkan_texture.h>
|
#include <textures/vulkan_texture.h>
|
||||||
#include <uniforms/vulkan_uniform_pool.h>
|
#include <uniforms/vulkan_uniform_pool.h>
|
||||||
|
#include <uniforms/vulkan_uniform.h>
|
||||||
#include <commands/command_pool/vulkan_command_pool.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>
|
#include <output_device/vulkan_output_devices.h>
|
||||||
|
|
||||||
gnDeviceFunctions loadVulkanDeviceFunctions() {
|
gnDeviceFunctions loadVulkanDeviceFunctions() {
|
||||||
@@ -30,33 +36,32 @@ gnDeviceFunctions loadVulkanDeviceFunctions() {
|
|||||||
._gnCreateCommandPool = createCommandPool,
|
._gnCreateCommandPool = createCommandPool,
|
||||||
._gnDestroyCommandPool = destroyCommandPool,
|
._gnDestroyCommandPool = destroyCommandPool,
|
||||||
|
|
||||||
// gnReturnCode (*_gnCreateSemaphore)(gnSemaphoreHandle semaphore, gnOutputDeviceHandle device);
|
._gnCreateSemaphore = createSemaphore,
|
||||||
// void (*_gnDestroySemaphore)(gnSemaphoreHandle semaphore);
|
._gnDestroySemaphore = destroySemaphore,
|
||||||
|
|
||||||
// gnReturnCode (*_gnCreateBuffer)(gnBufferHandle buffer, gnDeviceHandle device, gnBufferInfo info);
|
._gnCreateBuffer = createBuffer,
|
||||||
// void (*_gnBufferData)(gnBufferHandle buffer, size_t size, void* data);
|
._gnBufferData = bufferData,
|
||||||
// void* (*_gnMapBuffer)(gnBufferHandle buffer);
|
._gnMapBuffer = mapBuffer,
|
||||||
// void (*_gnDestroyBuffer)(gnBufferHandle buffer);
|
._gnDestroyBuffer = destroyBuffer,
|
||||||
|
|
||||||
._gnCreateUniformPool = createUniformPool,
|
._gnCreateUniformPool = createUniformPool,
|
||||||
._gnUniformPoolAllocateUniforms = allocateUniforms,
|
._gnUniformPoolAllocateUniforms = allocateUniforms,
|
||||||
._gnDestroyUniformPool = destroyUniformPool,
|
._gnDestroyUniformPool = destroyUniformPool,
|
||||||
|
|
||||||
// void (*_gnUpdateBufferUniform)(gnUniform uniform, gnBufferUniformInfo* bufferInfo);
|
._gnUpdateBufferUniform = updateBufferUniform,
|
||||||
// void (*_gnUpdateImageUniform)(gnUniform uniform, gnImageUniformInfo* imageInfo);
|
._gnUpdateImageUniform = updateImageUniform,
|
||||||
|
|
||||||
._gnCreateTexture = createTexture,
|
._gnCreateTexture = createTexture,
|
||||||
._gnTextureData = textureData,
|
._gnTextureData = textureData,
|
||||||
._gnDestroyTexture = destroyTexture,
|
._gnDestroyTexture = destroyTexture,
|
||||||
|
|
||||||
// gnReturnCode (*_gnCreateFence)(gnFenceHandle fence, gnOutputDeviceHandle device);
|
._gnCreateFence = createFence,
|
||||||
// void (*_gnSignalFence)(gnFenceHandle fence);
|
._gnWaitForFence = waitForFence,
|
||||||
// void (*_gnWaitForFence)(gnFenceHandle fence, uint64_t timeout);
|
._gnResetFence = resetFence,
|
||||||
// void (*_gnResetFence)(gnFenceHandle fence);
|
._gnDestroyFence = destroyFence,
|
||||||
// void (*_gnDestroyFence)(gnFenceHandle fence);
|
|
||||||
|
|
||||||
// gnReturnCode (*_gnSubmit)(gnOutputDeviceHandle device, gnSubmitInfo submit);
|
._gnSubmit = submit,
|
||||||
// gnReturnCode (*_gnPresent)(gnOutputDeviceHandle device, gnPresentInfo info);
|
._gnPresent = present,
|
||||||
|
|
||||||
._gnWaitForDevice = waitForDevice
|
._gnWaitForDevice = waitForDevice
|
||||||
};
|
};
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "loader/src/gryphn_instance_functions.h"
|
#include "loader/src/gryphn_instance_functions.h"
|
||||||
#include "loader/src/gryphn_device_functions.h"
|
#include "loader/src/gryphn_device_functions.h"
|
||||||
|
#include "loader/src/gryphn_command_functions.h"
|
||||||
|
|
||||||
gnInstanceFunctions loadVulkanInstanceFunctions();
|
gnInstanceFunctions loadVulkanInstanceFunctions();
|
||||||
gnDeviceFunctions loadVulkanDeviceFunctions();
|
gnDeviceFunctions loadVulkanDeviceFunctions();
|
||||||
|
gnCommandFunctions loadVulkanCommandFunctions();
|
||||||
|
@@ -66,7 +66,7 @@ void VkCopyBuffer(VkBuffer source, VkBuffer destination, size_t size, VkCommandP
|
|||||||
VkEndTransferOperation(transferBuffer, pool, queue, device);
|
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));
|
buffer->buffer = malloc(sizeof(struct gnPlatformBuffer_t));
|
||||||
VkBufferUsageFlags usage = vkGryphnBufferType(info.type);
|
VkBufferUsageFlags usage = vkGryphnBufferType(info.type);
|
||||||
buffer->buffer->useStagingBuffer = gnFalse;
|
buffer->buffer->useStagingBuffer = gnFalse;
|
||||||
@@ -98,7 +98,7 @@ gnReturnCode gnCreateBufferFn(gnBufferHandle buffer, gnOutputDeviceHandle device
|
|||||||
|
|
||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
}
|
}
|
||||||
void gnBufferDataFn(gnBufferHandle buffer, size_t dataSize, void* data) {
|
void bufferData(gnBufferHandle buffer, size_t dataSize, void* data) {
|
||||||
void* bufferData;
|
void* bufferData;
|
||||||
if (buffer->buffer->useStagingBuffer) {
|
if (buffer->buffer->useStagingBuffer) {
|
||||||
vkMapMemory(buffer->device->outputDevice->device, buffer->buffer->stagingBuffer.memory, 0, dataSize, 0, &bufferData);
|
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);
|
vkUnmapMemory(buffer->device->outputDevice->device, buffer->buffer->buffer.memory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void* gnMapBufferFn(gnBufferHandle buffer) {
|
void* mapBuffer(gnBufferHandle buffer) {
|
||||||
void* data;
|
void* data;
|
||||||
vkMapMemory(buffer->device->outputDevice->device, buffer->buffer->buffer.memory, 0, buffer->info.size, 0, &data);
|
vkMapMemory(buffer->device->outputDevice->device, buffer->buffer->buffer.memory, 0, buffer->info.size, 0, &data);
|
||||||
return data;
|
return data;
|
||||||
@@ -125,7 +125,7 @@ void gnDestroyVulkanBuffer(VkGryphnBuffer* buffer, VkDevice device) {
|
|||||||
vkFreeMemory(device, buffer->memory, NULL);
|
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);
|
if (buffer->buffer->useStagingBuffer == gnTrue) gnDestroyVulkanBuffer(&buffer->buffer->stagingBuffer, buffer->device->outputDevice->device);
|
||||||
gnDestroyVulkanBuffer(&buffer->buffer->buffer, buffer->device->outputDevice->device);
|
gnDestroyVulkanBuffer(&buffer->buffer->buffer, buffer->device->outputDevice->device);
|
||||||
free(buffer->buffer);
|
free(buffer->buffer);
|
||||||
|
@@ -22,3 +22,8 @@ gnReturnCode VkCreateBuffer(
|
|||||||
VkMemoryPropertyFlags flags, VkBufferUsageFlags usage
|
VkMemoryPropertyFlags flags, VkBufferUsageFlags usage
|
||||||
);
|
);
|
||||||
uint32_t VkMemoryIndex(VkPhysicalDevice device, uint32_t memoryType, VkMemoryPropertyFlags flags, gnBool* foundMemory);
|
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);
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
#include "commands/command_pool/vulkan_command_pool.h"
|
#include "commands/command_pool/vulkan_command_pool.h"
|
||||||
#include "output_device/vulkan_output_devices.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 = {
|
VkCommandBufferAllocateInfo allocInfo = {
|
||||||
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
|
||||||
.commandPool = pool->commandPool->commandPool,
|
.commandPool = pool->commandPool->commandPool,
|
||||||
@@ -23,12 +23,12 @@ gnReturnCode gnCommandPoolAllocateCommandBuffersFn(gnCommandBufferHandle* comman
|
|||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gnResetCommandBufferFn(struct gnCommandBuffer_t* commandBuffer) {
|
void resetCommandBuffer(gnCommandBufferHandle commandBuffer) {
|
||||||
vkResetCommandBuffer(commandBuffer->commandBuffer->buffer, 0);
|
vkResetCommandBuffer(commandBuffer->commandBuffer->buffer, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gnReturnCode gnBeginCommandBufferFn(struct gnCommandBuffer_t* commandBuffer) {
|
gnReturnCode beginCommandBuffer(gnCommandBufferHandle commandBuffer) {
|
||||||
VkCommandBufferBeginInfo beginInfo = {
|
VkCommandBufferBeginInfo beginInfo = {
|
||||||
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO
|
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO
|
||||||
};
|
};
|
||||||
@@ -39,7 +39,7 @@ gnReturnCode gnBeginCommandBufferFn(struct gnCommandBuffer_t* commandBuffer) {
|
|||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
gnReturnCode gnEndCommandBufferFn(struct gnCommandBuffer_t* commandBuffer) {
|
gnReturnCode endCommandBuffer(gnCommandBufferHandle commandBuffer) {
|
||||||
if (vkEndCommandBuffer(commandBuffer->commandBuffer->buffer) != VK_SUCCESS)
|
if (vkEndCommandBuffer(commandBuffer->commandBuffer->buffer) != VK_SUCCESS)
|
||||||
return GN_FAIELD_TO_END_RECORDING;
|
return GN_FAIELD_TO_END_RECORDING;
|
||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
|
@@ -13,3 +13,9 @@ typedef struct gnPlatformCommandBuffer_t {
|
|||||||
|
|
||||||
VkCommandBuffer VkBeginTransferOperation(VkDevice device, VkCommandPool pool);
|
VkCommandBuffer VkBeginTransferOperation(VkDevice device, VkCommandPool pool);
|
||||||
void VkEndTransferOperation(VkCommandBuffer transferBuffer, VkCommandPool pool, VkQueue syncQueue, VkDevice device);
|
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);
|
||||||
|
@@ -1,14 +1,6 @@
|
|||||||
#include <vulkan/vulkan.h>
|
#include "vulkan_commands.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 gnCommandBeginRenderPassFn(gnCommandBuffer buffer, gnRenderPassInfo passInfo) {
|
void beginRenderPass(gnCommandBuffer buffer, gnRenderPassInfo passInfo) {
|
||||||
VkClearValue* values = malloc(sizeof(VkClearValue) * passInfo.clearValueCount);
|
VkClearValue* values = malloc(sizeof(VkClearValue) * passInfo.clearValueCount);
|
||||||
for (int i = 0; i < passInfo.clearValueCount; i++) {
|
for (int i = 0; i < passInfo.clearValueCount; i++) {
|
||||||
values[i] = (VkClearValue){{{
|
values[i] = (VkClearValue){{{
|
||||||
@@ -33,14 +25,14 @@ void gnCommandBeginRenderPassFn(gnCommandBuffer buffer, gnRenderPassInfo passInf
|
|||||||
|
|
||||||
vkCmdBeginRenderPass(buffer->commandBuffer->buffer, &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE);
|
vkCmdBeginRenderPass(buffer->commandBuffer->buffer, &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE);
|
||||||
}
|
}
|
||||||
void gnCommandEndRenderPassFn(gnCommandBuffer buffer) {
|
void endRenderPass(gnCommandBuffer buffer) {
|
||||||
vkCmdEndRenderPass(buffer->commandBuffer->buffer);
|
vkCmdEndRenderPass(buffer->commandBuffer->buffer);
|
||||||
}
|
}
|
||||||
void gnCommandBindGraphicsPipelineFn(gnCommandBuffer buffer, gnGraphicsPipeline graphicsPipeline) {
|
void bindGraphicsPipeline(gnCommandBuffer buffer, gnGraphicsPipeline graphicsPipeline) {
|
||||||
buffer->commandBuffer->boundGraphicsPipeline = graphicsPipeline;
|
buffer->commandBuffer->boundGraphicsPipeline = graphicsPipeline;
|
||||||
vkCmdBindPipeline(buffer->commandBuffer->buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, graphicsPipeline->graphicsPipeline->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 = {
|
VkViewport vkViewport = {
|
||||||
.x = viewport.position.x,
|
.x = viewport.position.x,
|
||||||
.y = viewport.size.y,
|
.y = viewport.size.y,
|
||||||
@@ -51,7 +43,7 @@ void gnCommandSetViewportFn(gnCommandBuffer buffer, gnViewport viewport) {
|
|||||||
};
|
};
|
||||||
vkCmdSetViewport(buffer->commandBuffer->buffer, 0, 1, &vkViewport);
|
vkCmdSetViewport(buffer->commandBuffer->buffer, 0, 1, &vkViewport);
|
||||||
}
|
}
|
||||||
void gnCommandSetScissorFn(gnCommandBuffer buffer, gnScissor scissor) {
|
void setScissor(gnCommandBuffer buffer, gnScissor scissor) {
|
||||||
VkRect2D vkScissor = {
|
VkRect2D vkScissor = {
|
||||||
.extent = { scissor.size.x, scissor.size.y },
|
.extent = { scissor.size.x, scissor.size.y },
|
||||||
.offset = { scissor.position.x, scissor.position.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);
|
vkCmdSetScissor(buffer->commandBuffer->buffer, 0, 1, &vkScissor);
|
||||||
}
|
}
|
||||||
VkDeviceSize offsets[] = {0};
|
VkDeviceSize offsets[] = {0};
|
||||||
void gnCommandBindBufferFn(gnCommandBufferHandle buffer, gnBufferHandle bufferToBind, gnBufferType type) {
|
void bindBuffer(gnCommandBufferHandle buffer, gnBufferHandle bufferToBind, gnBufferType type) {
|
||||||
if (type == GN_VERTEX_BUFFER)
|
if (type == GN_VERTEX_BUFFER)
|
||||||
vkCmdBindVertexBuffers(buffer->commandBuffer->buffer, 0, 1, &bufferToBind->buffer->buffer.buffer, offsets);
|
vkCmdBindVertexBuffers(buffer->commandBuffer->buffer, 0, 1, &bufferToBind->buffer->buffer.buffer, offsets);
|
||||||
else if (type == GN_INDEX_BUFFER) {
|
else if (type == GN_INDEX_BUFFER) {
|
||||||
@@ -67,16 +59,16 @@ void gnCommandBindBufferFn(gnCommandBufferHandle buffer, gnBufferHandle bufferTo
|
|||||||
buffer->commandBuffer->boundIndexBuffer = bufferToBind;
|
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);
|
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);
|
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);
|
vkCmdDrawIndexed(buffer->commandBuffer->buffer, indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
|
||||||
buffer->commandBuffer->changedBuffer = gnFalse;
|
buffer->commandBuffer->changedBuffer = gnFalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gnCommandBindUniformFn(gnCommandBufferHandle buffer, gnUniform uniform, uint32_t set) {
|
void bindUniform(gnCommandBufferHandle buffer, gnUniform uniform, uint32_t set) {
|
||||||
vkCmdBindDescriptorSets(
|
vkCmdBindDescriptorSets(
|
||||||
buffer->commandBuffer->buffer,
|
buffer->commandBuffer->buffer,
|
||||||
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
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(
|
vkCmdPushConstants(
|
||||||
buffer->commandBuffer->buffer,
|
buffer->commandBuffer->buffer,
|
||||||
buffer->commandBuffer->boundGraphicsPipeline->graphicsPipeline->pipelineLayout,
|
buffer->commandBuffer->boundGraphicsPipeline->graphicsPipeline->pipelineLayout,
|
||||||
|
21
projects/apis/vulkan/src/commands/commands/vulkan_commands.h
Normal file
21
projects/apis/vulkan/src/commands/commands/vulkan_commands.h
Normal 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);
|
@@ -1,9 +1,6 @@
|
|||||||
#include "present/gryphn_present.h"
|
#include "vulkan_present.h"
|
||||||
#include "sync/semaphore/vulkan_semaphore.h"
|
|
||||||
#include "presentation_queue/vulkan_presentation_queue.h"
|
|
||||||
#include "output_device/vulkan_output_devices.h"
|
|
||||||
|
|
||||||
gnReturnCode gnPresentFn(gnDevice device, gnPresentInfo info) {
|
gnReturnCode present(gnDevice device, gnPresentInfo info) {
|
||||||
VkSemaphore* waitSemaphores = malloc(sizeof(VkSemaphore) * info.waitCount);
|
VkSemaphore* waitSemaphores = malloc(sizeof(VkSemaphore) * info.waitCount);
|
||||||
for (int i = 0; i < info.waitCount; i++) waitSemaphores[i] = info.waitSemaphores[i]->semaphore->semaphore;
|
for (int i = 0; i < info.waitCount; i++) waitSemaphores[i] = info.waitSemaphores[i]->semaphore->semaphore;
|
||||||
|
|
||||||
|
6
projects/apis/vulkan/src/present/vulkan_present.h
Normal file
6
projects/apis/vulkan/src/present/vulkan_present.h
Normal 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);
|
@@ -1,13 +1,7 @@
|
|||||||
#include <vulkan/vulkan.h>
|
#include "vulkan_submit.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 gnSubmitFn(gnDevice device, gnSubmitInfo info) {
|
gnReturnCode submit(gnDevice device, gnSubmitInfo info) {
|
||||||
VkSemaphore* waitSemaphores = malloc(sizeof(VkSemaphore) * info.waitCount);
|
VkSemaphore* waitSemaphores = malloc(sizeof(VkSemaphore) * info.waitCount);
|
||||||
VkPipelineStageFlags* waitStages = malloc(sizeof(VkPipelineStageFlags) * info.waitCount);
|
VkPipelineStageFlags* waitStages = malloc(sizeof(VkPipelineStageFlags) * info.waitCount);
|
||||||
for (int i = 0; i < info.waitCount; i++) waitSemaphores[i] = info.waitSemaphores[i]->semaphore->semaphore;
|
for (int i = 0; i < info.waitCount; i++) waitSemaphores[i] = info.waitSemaphores[i]->semaphore->semaphore;
|
||||||
|
9
projects/apis/vulkan/src/submit/vulkan_submit.h
Normal file
9
projects/apis/vulkan/src/submit/vulkan_submit.h
Normal 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);
|
@@ -1,7 +1,7 @@
|
|||||||
#include "vulkan_fence.h"
|
#include "vulkan_fence.h"
|
||||||
#include "output_device/vulkan_output_devices.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));
|
fence->fence = malloc(sizeof(gnPlatformFence));
|
||||||
VkFenceCreateInfo fenceInfo = {
|
VkFenceCreateInfo fenceInfo = {
|
||||||
.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO
|
.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_FAILED_TO_CREATE_FENCE;
|
||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
}
|
}
|
||||||
void gnSignalFenceFn(struct gnFence_t* fence) {}
|
void waitForFence(gnFence fence, uint64_t timeout) {
|
||||||
void gnWaitForFenceFn(struct gnFence_t* fence, uint64_t timeout) {
|
|
||||||
vkWaitForFences(fence->device->outputDevice->device, 1, &fence->fence->fence, VK_TRUE, 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);
|
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);
|
vkDestroyFence(fence->device->outputDevice->device, fence->fence->fence, NULL);
|
||||||
free(fence->fence);
|
free(fence->fence);
|
||||||
}
|
}
|
||||||
|
@@ -5,3 +5,8 @@
|
|||||||
typedef struct gnPlatformFence_t {
|
typedef struct gnPlatformFence_t {
|
||||||
VkFence fence;
|
VkFence fence;
|
||||||
} gnPlatformFence;
|
} gnPlatformFence;
|
||||||
|
|
||||||
|
gnReturnCode createFence(gnFence fence, gnDevice device);
|
||||||
|
void waitForFence(gnFence fence, uint64_t timeout);
|
||||||
|
void resetFence(gnFence fence);
|
||||||
|
void destroyFence(gnFence fence);
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
#include "vulkan_semaphore.h"
|
#include "vulkan_semaphore.h"
|
||||||
#include "output_device/vulkan_output_devices.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));
|
semaphore->semaphore = malloc(sizeof(gnPlatformSemaphore));
|
||||||
VkSemaphoreCreateInfo semaphoreInfo = {
|
VkSemaphoreCreateInfo semaphoreInfo = {
|
||||||
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO
|
.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_FAILED_TO_CREATE_SEMAPHORE;
|
||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
}
|
}
|
||||||
void gnDestroySemaphoreFn(struct gnSemaphore_t* semaphore) {
|
void destroySemaphore(gnSemaphore semaphore) {
|
||||||
vkDestroySemaphore(semaphore->device->outputDevice->device, semaphore->semaphore->semaphore, NULL);
|
vkDestroySemaphore(semaphore->device->outputDevice->device, semaphore->semaphore->semaphore, NULL);
|
||||||
free(semaphore->semaphore);
|
free(semaphore->semaphore);
|
||||||
}
|
}
|
||||||
|
@@ -5,3 +5,6 @@
|
|||||||
typedef struct gnPlatformSemaphore_t {
|
typedef struct gnPlatformSemaphore_t {
|
||||||
VkSemaphore semaphore;
|
VkSemaphore semaphore;
|
||||||
} gnPlatformSemaphore;
|
} gnPlatformSemaphore;
|
||||||
|
|
||||||
|
gnReturnCode createSemaphore(gnSemaphore semaphore, gnDevice device);
|
||||||
|
void destroySemaphore(gnSemaphore semaphore);
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
#include "uniforms/gryphn_uniform_pool.h"
|
#include "uniforms/gryphn_uniform_pool.h"
|
||||||
#include "textures/vulkan_texture.h"
|
#include "textures/vulkan_texture.h"
|
||||||
|
|
||||||
void gnUpdateBufferUniformFn(gnUniform uniform, gnBufferUniformInfo* info) {
|
void updateBufferUniform(gnUniform uniform, gnBufferUniformInfo* info) {
|
||||||
VkDescriptorBufferInfo bufferInfo = {
|
VkDescriptorBufferInfo bufferInfo = {
|
||||||
.buffer = info->buffer->buffer->buffer.buffer,
|
.buffer = info->buffer->buffer->buffer.buffer,
|
||||||
.offset = info->offset,
|
.offset = info->offset,
|
||||||
@@ -24,7 +24,7 @@ void gnUpdateBufferUniformFn(gnUniform uniform, gnBufferUniformInfo* info) {
|
|||||||
vkUpdateDescriptorSets(uniform->pool->device->outputDevice->device, 1, &write, 0, NULL);
|
vkUpdateDescriptorSets(uniform->pool->device->outputDevice->device, 1, &write, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gnUpdateImageUniformFn(gnUniform uniform, gnImageUniformInfo* info) {
|
void updateImageUniform(gnUniform uniform, gnImageUniformInfo* info) {
|
||||||
VkDescriptorImageInfo imageInfo = {
|
VkDescriptorImageInfo imageInfo = {
|
||||||
.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||||
.imageView = info->texture->texture->image.imageView,
|
.imageView = info->texture->texture->image.imageView,
|
||||||
|
@@ -5,3 +5,6 @@
|
|||||||
typedef struct gnPlatformUniform_t {
|
typedef struct gnPlatformUniform_t {
|
||||||
VkDescriptorSet set;
|
VkDescriptorSet set;
|
||||||
} gnPlatformUniform;
|
} gnPlatformUniform;
|
||||||
|
|
||||||
|
void updateBufferUniform(gnUniform uniform, gnBufferUniformInfo* info);
|
||||||
|
void updateImageUniform(gnUniform uniform, gnImageUniformInfo* info);
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
#include "gryphn_buffer.h"
|
#include "gryphn_buffer.h"
|
||||||
#include "output_device/gryphn_output_device.h"
|
#include "output_device/gryphn_output_device.h"
|
||||||
#include "gryphn_platform_functions.h"
|
|
||||||
|
|
||||||
gnReturnCode gnCreateBuffer(gnBufferHandle* buffer, gnOutputDeviceHandle device, gnBufferInfo info) {
|
gnReturnCode gnCreateBuffer(gnBufferHandle* buffer, gnOutputDeviceHandle device, gnBufferInfo info) {
|
||||||
*buffer = malloc(sizeof(struct gnBuffer_t));
|
*buffer = malloc(sizeof(struct gnBuffer_t));
|
||||||
|
@@ -1,8 +1,11 @@
|
|||||||
#include "gryphn_command_pool.h"
|
#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) {
|
gnReturnCode gnCreateCommandPool(gnCommandPoolHandle* commandPool, gnOutputDeviceHandle device, gnCommandPoolInfo info) {
|
||||||
*commandPool = malloc(sizeof(struct gnCommandPool_t));
|
*commandPool = malloc(sizeof(struct gnCommandPool_t));
|
||||||
(*commandPool)->commandFunctions = device->instance->commandFunctions;
|
(*commandPool)->commandFunctions = &device->instance->commandFunctions;
|
||||||
|
|
||||||
(*commandPool)->device = device;
|
(*commandPool)->device = device;
|
||||||
return device->deviceFunctions->_gnCreateCommandPool((*commandPool), device, info);
|
return device->deviceFunctions->_gnCreateCommandPool((*commandPool), device, info);
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
#include "stdint.h"
|
#include "stdint.h"
|
||||||
#include <utils/gryphn_error_code.h>
|
#include <utils/gryphn_error_code.h>
|
||||||
#include "gryphn_handles.h"
|
#include "gryphn_handles.h"
|
||||||
#include <gryphn_platform_functions.h>
|
#include "loader/src/gryphn_command_functions.h"
|
||||||
|
|
||||||
typedef struct gnCommandPoolInfo {
|
typedef struct gnCommandPoolInfo {
|
||||||
uint32_t queueIndex;
|
uint32_t queueIndex;
|
||||||
@@ -11,8 +11,8 @@ typedef struct gnCommandPoolInfo {
|
|||||||
#ifdef GN_REVEAL_IMPL
|
#ifdef GN_REVEAL_IMPL
|
||||||
struct gnCommandPool_t {
|
struct gnCommandPool_t {
|
||||||
struct gnPlatformCommandPool_t* commandPool;
|
struct gnPlatformCommandPool_t* commandPool;
|
||||||
struct gnCommandFunctions_t* commandFunctions;
|
gnCommandFunctions* commandFunctions;
|
||||||
struct gnOutputDevice_t* device;
|
gnDevice device;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
#include "gryphn_command.h"
|
#include "gryphn_command.h"
|
||||||
#include "command/command_buffer/gryphn_command_buffer.h"
|
#include "command/command_buffer/gryphn_command_buffer.h"
|
||||||
#include "command/command_pool/gryphn_command_pool.h"
|
#include "command/command_pool/gryphn_command_pool.h"
|
||||||
#include "gryphn_platform_functions.h"
|
|
||||||
|
|
||||||
void gnCommandBeginRenderPass(gnCommandBufferHandle buffer, gnRenderPassInfo passInfo) {
|
void gnCommandBeginRenderPass(gnCommandBufferHandle buffer, gnRenderPassInfo passInfo) {
|
||||||
buffer->commandPool->commandFunctions->_gnCommandBeginRenderPass(buffer, passInfo);
|
buffer->commandPool->commandFunctions->_gnCommandBeginRenderPass(buffer, passInfo);
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
#include "gryphn_debugger.h"
|
#include "gryphn_debugger.h"
|
||||||
#include <gryphn_platform_functions.h>
|
|
||||||
|
|
||||||
gnReturnCode gnCreateDebugger(gnDebuggerHandle* debugger, const gnDebuggerInfo info) {
|
gnReturnCode gnCreateDebugger(gnDebuggerHandle* debugger, const gnDebuggerInfo info) {
|
||||||
*debugger = malloc(sizeof(struct gnDebugger_t));
|
*debugger = malloc(sizeof(struct gnDebugger_t));
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
#include "gryphn_framebuffer.h"
|
#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) {
|
gnReturnCode gnCreateFramebuffer(gnFramebuffer* framebuffer, gnOutputDeviceHandle device, gnFramebufferInfo framebufferInfo) {
|
||||||
*framebuffer = malloc(sizeof(struct gnFramebuffer_t));
|
*framebuffer = malloc(sizeof(struct gnFramebuffer_t));
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
#include "gryphn_instance.h"
|
#include "gryphn_instance.h"
|
||||||
#include <gryphn_platform_functions.h>
|
|
||||||
#include "instance/gryphn_instance.h"
|
#include "instance/gryphn_instance.h"
|
||||||
#include <loader/src/gryphn_instance_functions.h>
|
#include <loader/src/gryphn_instance_functions.h>
|
||||||
#include "loader/src/gryphn_loader.h"
|
#include "loader/src/gryphn_loader.h"
|
||||||
@@ -13,6 +12,7 @@ gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceInfo info) {
|
|||||||
|
|
||||||
(*instance)->instanceFunctions = loadInstanceFunctions(loadInfo);
|
(*instance)->instanceFunctions = loadInstanceFunctions(loadInfo);
|
||||||
(*instance)->deviceFunctions = loadDeviceFunctions(loadInfo);
|
(*instance)->deviceFunctions = loadDeviceFunctions(loadInfo);
|
||||||
|
(*instance)->commandFunctions = loadCommandFunctions(loadInfo);
|
||||||
(*instance)->debugger = info.debugger;
|
(*instance)->debugger = info.debugger;
|
||||||
return (*instance)->instanceFunctions._gnCreateInstance((*instance), info);
|
return (*instance)->instanceFunctions._gnCreateInstance((*instance), info);
|
||||||
}
|
}
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
#include "utils/gryphn_error_code.h"
|
#include "utils/gryphn_error_code.h"
|
||||||
#include "loader/src/gryphn_instance_functions.h"
|
#include "loader/src/gryphn_instance_functions.h"
|
||||||
#include "loader/src/gryphn_device_functions.h"
|
#include "loader/src/gryphn_device_functions.h"
|
||||||
|
#include "loader/src/gryphn_command_functions.h"
|
||||||
|
|
||||||
typedef struct gnInstanceInfo {
|
typedef struct gnInstanceInfo {
|
||||||
gnString applicationName;
|
gnString applicationName;
|
||||||
@@ -24,7 +25,7 @@ struct gnInstance_t {
|
|||||||
|
|
||||||
gnInstanceFunctions instanceFunctions;
|
gnInstanceFunctions instanceFunctions;
|
||||||
gnDeviceFunctions deviceFunctions;
|
gnDeviceFunctions deviceFunctions;
|
||||||
struct gnCommandFunctions_t* commandFunctions;
|
gnCommandFunctions commandFunctions;
|
||||||
|
|
||||||
gnDebuggerHandle debugger;
|
gnDebuggerHandle debugger;
|
||||||
};
|
};
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
#include "gryphn_graphics_pipeline.h"
|
#include "gryphn_graphics_pipeline.h"
|
||||||
#include "gryphn_platform_functions.h"
|
|
||||||
|
|
||||||
gnReturnCode gnCreateGraphicsPipeline(gnGraphicsPipelineHandle* graphicsPipeline, gnDevice device, gnGraphicsPipelineInfo info) {
|
gnReturnCode gnCreateGraphicsPipeline(gnGraphicsPipelineHandle* graphicsPipeline, gnDevice device, gnGraphicsPipelineInfo info) {
|
||||||
*graphicsPipeline = malloc(sizeof(struct gnGraphicsPipeline_t));
|
*graphicsPipeline = malloc(sizeof(struct gnGraphicsPipeline_t));
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
#include "utils/math/gryphn_vec2.h"
|
#include "utils/math/gryphn_vec2.h"
|
||||||
#include "gryphn_handles.h"
|
#include "gryphn_handles.h"
|
||||||
|
|
||||||
typedef struct gnRenderPassInfo_t {
|
typedef struct gnRenderPassInfo {
|
||||||
gnRenderPassDescriptorHandle renderPassDescriptor;
|
gnRenderPassDescriptorHandle renderPassDescriptor;
|
||||||
gnFramebuffer framebuffer;
|
gnFramebuffer framebuffer;
|
||||||
gnUInt2 offset;
|
gnUInt2 offset;
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
#include "gryphn_render_pass_descriptor.h"
|
#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) {
|
gnReturnCode gnCreateRenderPassDescriptor(gnRenderPassDescriptorHandle* renderPass, gnOutputDeviceHandle device, gnRenderPassDescriptorInfo info) {
|
||||||
*renderPass = malloc(sizeof(struct gnRenderPassDescriptor_t));
|
*renderPass = malloc(sizeof(struct gnRenderPassDescriptor_t));
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
#include <gryphn_platform_functions.h>
|
|
||||||
#include "gryphn_shader_module.h"
|
#include "gryphn_shader_module.h"
|
||||||
|
#include "output_device/gryphn_output_device.h"
|
||||||
|
|
||||||
gnReturnCode gnCreateShaderModule(gnShaderModuleHandle* module, gnOutputDeviceHandle device, struct gnShaderModuleInfo shaderModuleInfo) {
|
gnReturnCode gnCreateShaderModule(gnShaderModuleHandle* module, gnOutputDeviceHandle device, struct gnShaderModuleInfo shaderModuleInfo) {
|
||||||
*module = malloc(sizeof(struct gnShaderModule_t));
|
*module = malloc(sizeof(struct gnShaderModule_t));
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
#include "gryphn_fence.h"
|
#include "gryphn_fence.h"
|
||||||
#include "gryphn_platform_functions.h"
|
#include "output_device/gryphn_output_device.h"
|
||||||
|
|
||||||
gnReturnCode gnCreateFence(gnFenceHandle* fence, struct gnOutputDevice_t* device) {
|
gnReturnCode gnCreateFence(gnFenceHandle* fence, struct gnOutputDevice_t* device) {
|
||||||
*fence = malloc(sizeof(struct gnFence_t));
|
*fence = malloc(sizeof(struct gnFence_t));
|
||||||
@@ -9,7 +9,6 @@ gnReturnCode gnCreateFence(gnFenceHandle* fence, struct gnOutputDevice_t* device
|
|||||||
}
|
}
|
||||||
void gnSignalFence(gnFenceHandle fence) {
|
void gnSignalFence(gnFenceHandle fence) {
|
||||||
fence->signaled = gnTrue;
|
fence->signaled = gnTrue;
|
||||||
// fence->device->deviceFunctions->_gnSignalFence(fence);
|
|
||||||
}
|
}
|
||||||
void gnWaitForFence(gnFenceHandle fence, uint64_t timeout) {
|
void gnWaitForFence(gnFenceHandle fence, uint64_t timeout) {
|
||||||
if (fence->signaled == gnTrue) return;
|
if (fence->signaled == gnTrue) return;
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
#include "gryphn_semaphore.h"
|
#include "gryphn_semaphore.h"
|
||||||
#include "gryphn_platform_functions.h"
|
#include "output_device/gryphn_output_device.h"
|
||||||
|
|
||||||
gnReturnCode gnCreateSemaphore(gnSemaphore* semaphore, struct gnOutputDevice_t* device) {
|
gnReturnCode gnCreateSemaphore(gnSemaphore* semaphore, struct gnOutputDevice_t* device) {
|
||||||
*semaphore = malloc(sizeof(struct gnSemaphore_t));
|
*semaphore = malloc(sizeof(struct gnSemaphore_t));
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
#include "gryphn_texture.h"
|
#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) {
|
gnReturnCode gnCreateTexture(gnTexture* texture, gnDevice device, const gnTextureInfo info) {
|
||||||
*texture = malloc(sizeof(struct gnTexture_t));
|
*texture = malloc(sizeof(struct gnTexture_t));
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
#include "gryphn_uniform.h"
|
#include "gryphn_uniform.h"
|
||||||
#include "gryphn_uniform_pool.h"
|
#include "gryphn_uniform_pool.h"
|
||||||
#include "output_device/gryphn_output_device.h"
|
#include "output_device/gryphn_output_device.h"
|
||||||
#include "gryphn_platform_functions.h"
|
|
||||||
|
|
||||||
void gnUpdateBufferUniform(gnUniform uniform, gnBufferUniformInfo bufferInfo) {
|
void gnUpdateBufferUniform(gnUniform uniform, gnBufferUniformInfo bufferInfo) {
|
||||||
uniform->pool->device->deviceFunctions->_gnUpdateBufferUniform(uniform, &bufferInfo);
|
uniform->pool->device->deviceFunctions->_gnUpdateBufferUniform(uniform, &bufferInfo);
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
#include "gryphn_uniform_pool.h"
|
#include "gryphn_uniform_pool.h"
|
||||||
#include "output_device/gryphn_output_device.h"
|
#include "output_device/gryphn_output_device.h"
|
||||||
#include "gryphn_platform_functions.h"
|
|
||||||
#include "gryphn_uniform.h"
|
#include "gryphn_uniform.h"
|
||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
|
|
||||||
|
@@ -1,12 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
// theoretically you could have multible gryphn instances running in one application,
|
#include "stdint.h"
|
||||||
// why I dont know
|
#include "utils/gryphn_error_code.h"
|
||||||
#include "instance/gryphn_instance.h"
|
#include "gryphn_handles.h"
|
||||||
#include <debugger/gryphn_debugger.h>
|
|
||||||
#include <window_surface/gryphn_surface_create_functions.h>
|
typedef struct gnRenderPassInfo gnRenderPassInfo;
|
||||||
#include "pipelines/graphics_pipeline/gryphn_graphics_pipeline.h"
|
typedef struct gnViewport gnViewport;
|
||||||
#include "renderpass/gryphn_render_pass.h"
|
typedef struct gnScissor gnScissor;
|
||||||
#include "buffers/gryphn_buffer.h"
|
typedef struct gnPushConstantLayout gnPushConstantLayout;
|
||||||
|
typedef enum gnBufferType gnBufferType;
|
||||||
|
typedef enum gnIndexType gnIndexType;
|
||||||
|
|
||||||
typedef struct gnCommandFunctions_t {
|
typedef struct gnCommandFunctions_t {
|
||||||
gnReturnCode (*_gnCommandPoolAllocateCommandBuffers)(gnCommandBufferHandle* commandBuffers, uint32_t count, gnCommandPoolHandle pool);
|
gnReturnCode (*_gnCommandPoolAllocateCommandBuffers)(gnCommandBufferHandle* commandBuffers, uint32_t count, gnCommandPoolHandle pool);
|
@@ -58,7 +58,6 @@ typedef struct gnDeviceFunctions {
|
|||||||
void (*_gnDestroyTexture)(gnTexture texture);
|
void (*_gnDestroyTexture)(gnTexture texture);
|
||||||
|
|
||||||
gnReturnCode (*_gnCreateFence)(gnFenceHandle fence, gnOutputDeviceHandle device);
|
gnReturnCode (*_gnCreateFence)(gnFenceHandle fence, gnOutputDeviceHandle device);
|
||||||
void (*_gnSignalFence)(gnFenceHandle fence);
|
|
||||||
void (*_gnWaitForFence)(gnFenceHandle fence, uint64_t timeout);
|
void (*_gnWaitForFence)(gnFenceHandle fence, uint64_t timeout);
|
||||||
void (*_gnResetFence)(gnFenceHandle fence);
|
void (*_gnResetFence)(gnFenceHandle fence);
|
||||||
void (*_gnDestroyFence)(gnFenceHandle fence);
|
void (*_gnDestroyFence)(gnFenceHandle fence);
|
||||||
|
@@ -26,3 +26,16 @@ gnDeviceFunctions loadDeviceFunctions(loaderInfo info) {
|
|||||||
case GN_RENDERINGAPI_METAL: return (gnDeviceFunctions){ NULL };
|
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 };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
#include "gryphn_rendering_api.h"
|
#include "gryphn_rendering_api.h"
|
||||||
#include "gryphn_instance_functions.h"
|
#include "gryphn_instance_functions.h"
|
||||||
#include "gryphn_device_functions.h"
|
#include "gryphn_device_functions.h"
|
||||||
|
#include "gryphn_command_functions.h"
|
||||||
|
|
||||||
typedef struct loaderInfo {
|
typedef struct loaderInfo {
|
||||||
gnRenderingAPI api;
|
gnRenderingAPI api;
|
||||||
@@ -9,3 +10,4 @@ typedef struct loaderInfo {
|
|||||||
|
|
||||||
gnInstanceFunctions loadInstanceFunctions(loaderInfo info);
|
gnInstanceFunctions loadInstanceFunctions(loaderInfo info);
|
||||||
gnDeviceFunctions loadDeviceFunctions(loaderInfo info);
|
gnDeviceFunctions loadDeviceFunctions(loaderInfo info);
|
||||||
|
gnCommandFunctions loadCommandFunctions(loaderInfo info);
|
||||||
|
Reference in New Issue
Block a user