uniform pool
This commit is contained in:
@@ -22,3 +22,4 @@
|
||||
#include <core/present/gryphn_present.h>
|
||||
#include <core/shader_input/gryphn_shader_layout.h>
|
||||
#include <core/buffers/gryphn_buffer.h>
|
||||
#include <core/uniforms/gryphn_uniform_pool.h>
|
||||
|
@@ -5,10 +5,13 @@
|
||||
#include "output_device/vulkan_physical_device.h"
|
||||
|
||||
VkBufferUsageFlags vkGryphnBufferType(gnBufferType type) {
|
||||
switch (type) {
|
||||
case GN_VERTEX_BUFFER: return VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
|
||||
case GN_INDEX_BUFFER: return VK_BUFFER_USAGE_INDEX_BUFFER_BIT;
|
||||
}
|
||||
VkBufferUsageFlags usageFlags = 0;
|
||||
switch (type) {
|
||||
case GN_VERTEX_BUFFER: usageFlags |= VK_BUFFER_USAGE_VERTEX_BUFFER_BIT; break;
|
||||
case GN_INDEX_BUFFER: usageFlags |= VK_BUFFER_USAGE_INDEX_BUFFER_BIT; break;
|
||||
case GN_UNIFORM_BUFFER: usageFlags |= VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; break;
|
||||
}
|
||||
return usageFlags;
|
||||
}
|
||||
|
||||
gnReturnCode VkCreateBuffer(
|
||||
@@ -93,20 +96,29 @@ gnReturnCode gnCreateBufferFn(gnBufferHandle buffer, gnOutputDeviceHandle device
|
||||
VkBufferUsageFlags usage = vkGryphnBufferType(info.type);
|
||||
buffer->buffer->useStagingBuffer = gnFalse;
|
||||
if (info.usage == GN_STATIC_DRAW) {
|
||||
gnReturnCode createdBuffer = VkCreateBuffer(
|
||||
buffer->buffer->useStagingBuffer = gnTrue;
|
||||
VkCreateBuffer(
|
||||
&buffer->buffer->stagingBuffer, &buffer->buffer->stagingBufferMemory,
|
||||
info, device->outputDevice->device, device->physicalDevice.physicalDevice->device,
|
||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, VK_BUFFER_USAGE_TRANSFER_SRC_BIT
|
||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
|
||||
VK_BUFFER_USAGE_TRANSFER_SRC_BIT
|
||||
);
|
||||
|
||||
return VkCreateBuffer(
|
||||
&buffer->buffer->buffer, &buffer->buffer->bufferMemory,
|
||||
info, device->outputDevice->device, device->physicalDevice.physicalDevice->device,
|
||||
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
|
||||
vkGryphnBufferType(info.type) | VK_BUFFER_USAGE_TRANSFER_DST_BIT
|
||||
);
|
||||
} else {
|
||||
return VkCreateBuffer(
|
||||
&buffer->buffer->buffer, &buffer->buffer->bufferMemory,
|
||||
info, device->outputDevice->device, device->physicalDevice.physicalDevice->device,
|
||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
|
||||
vkGryphnBufferType(info.type)
|
||||
);
|
||||
usage |= VK_BUFFER_USAGE_TRANSFER_DST_BIT;
|
||||
buffer->buffer->useStagingBuffer = gnTrue;
|
||||
}
|
||||
|
||||
gnReturnCode createdBuffer = VkCreateBuffer(
|
||||
&buffer->buffer->buffer, &buffer->buffer->bufferMemory,
|
||||
info, device->outputDevice->device, device->physicalDevice.physicalDevice->device,
|
||||
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, usage
|
||||
);
|
||||
|
||||
|
||||
return GN_SUCCESS;
|
||||
|
@@ -7,7 +7,7 @@ gnReturnCode gnCreateCommandPoolFn(struct gnCommandPool_t* commandPool, struct g
|
||||
VkCommandPoolCreateInfo poolInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
|
||||
.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,
|
||||
.queueFamilyIndex = info.queueIndex
|
||||
.queueFamilyIndex = info.queueIndex,
|
||||
};
|
||||
|
||||
if (vkCreateCommandPool(device->outputDevice->device, &poolInfo, NULL, &commandPool->commandPool->commandPool) != VK_SUCCESS) {
|
||||
|
@@ -62,7 +62,7 @@ VkFormat vkGryphnVertexFormat(gnVertexFormat format) {
|
||||
|
||||
VkDescriptorType vkGryphnUniformType(gnUniformType type) {
|
||||
switch(type) {
|
||||
case GN_UNIFORM_BUFFER: return VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||
case GN_UNIFORM_BUFFER_DESCRIPTOR: return VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||
}
|
||||
}
|
||||
|
||||
|
11
rendering_api/vulkan/src/uniforms/vulkan_uniform_pool.c
Normal file
11
rendering_api/vulkan/src/uniforms/vulkan_uniform_pool.c
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "vulkan_uniform_pool.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
gnReturnCode gnCreateUniformPoolFn(gnUniformPool pool, gnDeviceHandle device) {
|
||||
pool->uniformPool = malloc(sizeof(struct gnPlatformUniformPool_t));
|
||||
|
||||
pool->uniformPool->maxUniformPools = 0;
|
||||
pool->uniformPool->uniformPoolCount = 0;
|
||||
|
||||
return GN_SUCCESS;
|
||||
}
|
15
rendering_api/vulkan/src/uniforms/vulkan_uniform_pool.h
Normal file
15
rendering_api/vulkan/src/uniforms/vulkan_uniform_pool.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <core/uniforms/gryphn_uniform_pool.h>
|
||||
#include "core/uniforms/gryphn_uniform_layout.h"
|
||||
|
||||
typedef struct VkGryphnUniformPool {
|
||||
VkDescriptorPool pool;
|
||||
gnUniformType type;
|
||||
} VkGryphnUniformPool;
|
||||
|
||||
struct gnPlatformUniformPool_t {
|
||||
int maxUniformPools;
|
||||
int uniformPoolCount;
|
||||
VkGryphnUniformPool* pools;
|
||||
};
|
@@ -8,8 +8,9 @@ typedef enum gnIndexType {
|
||||
} gnIndexType;
|
||||
|
||||
typedef enum gnBufferType {
|
||||
GN_VERTEX_BUFFER = 0x00000001f,
|
||||
GN_INDEX_BUFFER = 0x00000002f,
|
||||
GN_VERTEX_BUFFER = 0x00000001,
|
||||
GN_INDEX_BUFFER = 0x00000002,
|
||||
GN_UNIFORM_BUFFER = 0x00000004
|
||||
} gnBufferType;
|
||||
|
||||
typedef enum gnBufferUsage {
|
||||
|
@@ -24,3 +24,4 @@ GN_HANDLE(gnSemaphore);
|
||||
GN_HANDLE(gnFence);
|
||||
GN_HANDLE(gnFramebuffer);
|
||||
GN_HANDLE(gnBuffer);
|
||||
GN_HANDLE(gnUniformPool);
|
||||
|
@@ -87,6 +87,8 @@ typedef struct gnDeviceFunctions_t {
|
||||
void* (*_gnMapBuffer)(gnBufferHandle buffer);
|
||||
void (*_gnDestroyBuffer)(gnBufferHandle buffer);
|
||||
|
||||
gnReturnCode (*_gnCreateUniformPool)(gnUniformPool pool, gnDeviceHandle device);
|
||||
|
||||
gnReturnCode (*_gnCreateFence)(gnFenceHandle fence, gnOutputDeviceHandle device);
|
||||
void (*_gnSignalFence)(gnFenceHandle fence);
|
||||
void (*_gnWaitForFence)(gnFenceHandle fence, uint64_t timeout);
|
||||
|
@@ -88,6 +88,7 @@ void gnLoadDeviceFunctions(struct gnDynamicLibrary_t* lib, struct gnDeviceFuncti
|
||||
gnLoadDLLFunction(lib, functions->_gnBufferData, "gnBufferDataFn");
|
||||
gnLoadDLLFunction(lib, functions->_gnMapBuffer, "gnMapBufferFn");
|
||||
gnLoadDLLFunction(lib, functions->_gnDestroyBuffer, "gnDestroyBufferFn");
|
||||
gnLoadDLLFunction(lib, functions->_gnCreateUniformPool, "gnCreateUniformPoolFn");
|
||||
gnLoadDLLFunction(lib, functions->_gnCreateFence, "gnCreateFenceFn");
|
||||
gnLoadDLLFunction(lib, functions->_gnSignalFence, "gnSignalFenceFn");
|
||||
gnLoadDLLFunction(lib, functions->_gnWaitForFence, "gnWaitForFenceFn");
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include <core/output_device/gryphn_output_device.h>
|
||||
#include <core/pipelines/gryphn_uniform_layout.h>
|
||||
#include <core/uniforms/gryphn_uniform_layout.h>
|
||||
#include <core/renderpass/gryphn_render_pass_descriptor.h>
|
||||
#include <core/shader_module/gryphn_shader_module.h>
|
||||
#include "utils/math/gryphn_vec2.h"
|
||||
|
7
src/core/uniforms/gryphn_uniform.h
Normal file
7
src/core/uniforms/gryphn_uniform.h
Normal file
@@ -0,0 +1,7 @@
|
||||
// #pragma once
|
||||
|
||||
// #ifdef GN_REVEAL_IMPL
|
||||
// struct gnUniform_t {
|
||||
|
||||
// };
|
||||
// #endif
|
@@ -3,7 +3,7 @@
|
||||
#include "core/shader_module/gryphn_shader_module.h"
|
||||
|
||||
typedef enum gnUniformType {
|
||||
GN_UNIFORM_BUFFER
|
||||
GN_UNIFORM_BUFFER_DESCRIPTOR
|
||||
} gnUniformType;
|
||||
|
||||
typedef struct gnUniformBinding {
|
10
src/core/uniforms/gryphn_uniform_pool.c
Normal file
10
src/core/uniforms/gryphn_uniform_pool.c
Normal file
@@ -0,0 +1,10 @@
|
||||
#include "gryphn_uniform_pool.h"
|
||||
#include "core/output_device/gryphn_output_device.h"
|
||||
#include "core/gryphn_platform_functions.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
gnReturnCode gnCreateUniformPool(gnUniformPool* pool, gnDeviceHandle device) {
|
||||
*pool = malloc(sizeof(struct gnUniformPool_t));
|
||||
(*pool)->device = device;
|
||||
return device->deviceFunctions->_gnCreateUniformPool(*pool, device);
|
||||
}
|
13
src/core/uniforms/gryphn_uniform_pool.h
Normal file
13
src/core/uniforms/gryphn_uniform_pool.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include "core/gryphn_handles.h"
|
||||
#include "utils/gryphn_error_code.h"
|
||||
|
||||
#ifdef GN_REVEAL_IMPL
|
||||
struct gnUniformPool_t {
|
||||
struct gnPlatformUniformPool_t* uniformPool;
|
||||
gnDeviceHandle device;
|
||||
};
|
||||
#endif
|
||||
|
||||
gnReturnCode gnCreateUniformPool(gnUniformPool* pool, gnDeviceHandle device);
|
||||
// void gnUniformPoolAllocateUniforms
|
Reference in New Issue
Block a user