uniform pool
This commit is contained in:
@@ -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;
|
||||
};
|
Reference in New Issue
Block a user