fix the last few vulkan warnings
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
#include <commands/command_buffer/vulkan_command_buffer.h>
|
#include <commands/command_buffer/vulkan_command_buffer.h>
|
||||||
#include <commands/commands/vulkan_commands.h>
|
#include <commands/commands/vulkan_commands.h>
|
||||||
|
|
||||||
gnCommandFunctions loadVulkanCommandFunctions() {
|
gnCommandFunctions loadVulkanCommandFunctions(void) {
|
||||||
return (gnCommandFunctions){
|
return (gnCommandFunctions){
|
||||||
._gnCommandPoolAllocateCommandBuffers = allocateCommandBuffers,
|
._gnCommandPoolAllocateCommandBuffers = allocateCommandBuffers,
|
||||||
._gnBeginCommandBuffer = beginCommandBuffer,
|
._gnBeginCommandBuffer = beginCommandBuffer,
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
#include <submit/vulkan_submit.h>
|
#include <submit/vulkan_submit.h>
|
||||||
#include <output_device/vulkan_output_devices.h>
|
#include <output_device/vulkan_output_devices.h>
|
||||||
|
|
||||||
gnDeviceFunctions loadVulkanDeviceFunctions() {
|
gnDeviceFunctions loadVulkanDeviceFunctions(void) {
|
||||||
return (gnDeviceFunctions){
|
return (gnDeviceFunctions){
|
||||||
._gnCreatePresentationQueue = createPresentationQueue,
|
._gnCreatePresentationQueue = createPresentationQueue,
|
||||||
._gnPresentationQueueGetImage = getVulkanPresentQueueImage,
|
._gnPresentationQueueGetImage = getVulkanPresentQueueImage,
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
#include <output_device/vulkan_output_devices.h>
|
#include <output_device/vulkan_output_devices.h>
|
||||||
#include <vulkan_surface/vulkan_surface.h>
|
#include <vulkan_surface/vulkan_surface.h>
|
||||||
|
|
||||||
gryphnInstanceFunctionLayers loadVulkanAPILayer() {
|
gryphnInstanceFunctionLayers loadVulkanAPILayer(void) {
|
||||||
return (gryphnInstanceFunctionLayers) {
|
return (gryphnInstanceFunctionLayers) {
|
||||||
.createInstance = vulkanCreateInstance,
|
.createInstance = vulkanCreateInstance,
|
||||||
.destroyInstance = vulkanDestroyInstance,
|
.destroyInstance = vulkanDestroyInstance,
|
||||||
@@ -12,7 +12,7 @@ gryphnInstanceFunctionLayers loadVulkanAPILayer() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
gnInstanceFunctions loadVulkanInstanceFunctions() {
|
gnInstanceFunctions loadVulkanInstanceFunctions(void) {
|
||||||
return (gnInstanceFunctions){
|
return (gnInstanceFunctions){
|
||||||
|
|
||||||
._gnGetPhysicalDevices = getPhysicalDevices,
|
._gnGetPhysicalDevices = getPhysicalDevices,
|
||||||
|
@@ -7,12 +7,12 @@
|
|||||||
#include "core/gryphn_extensions.h"
|
#include "core/gryphn_extensions.h"
|
||||||
|
|
||||||
typedef struct gryphnInstanceFunctionLayers gryphnInstanceFunctionLayers;
|
typedef struct gryphnInstanceFunctionLayers gryphnInstanceFunctionLayers;
|
||||||
gryphnInstanceFunctionLayers loadVulkanAPILayer();
|
gryphnInstanceFunctionLayers loadVulkanAPILayer(void);
|
||||||
|
|
||||||
gnInstanceFunctions loadVulkanInstanceFunctions();
|
gnInstanceFunctions loadVulkanInstanceFunctions(void);
|
||||||
gnDeviceFunctions loadVulkanDeviceFunctions();
|
gnDeviceFunctions loadVulkanDeviceFunctions(void);
|
||||||
gnCommandFunctions loadVulkanCommandFunctions();
|
gnCommandFunctions loadVulkanCommandFunctions(void);
|
||||||
gnSyncExtFunctions loadVulkanSyncFunctions();
|
gnSyncExtFunctions loadVulkanSyncFunctions(void);
|
||||||
gnQueueExtFunctions loadVulkanQueueFunctions();
|
gnQueueExtFunctions loadVulkanQueueFunctions(void);
|
||||||
|
|
||||||
gnBool vulkanIsExtensionSupported(gnExtension extension);
|
gnBool vulkanIsExtensionSupported(gnExtension extension);
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
#include <submit/vulkan_submit.h>
|
#include <submit/vulkan_submit.h>
|
||||||
#include <present/vulkan_present.h>
|
#include <present/vulkan_present.h>
|
||||||
|
|
||||||
gnQueueExtFunctions loadVulkanQueueFunctions() {
|
gnQueueExtFunctions loadVulkanQueueFunctions(void) {
|
||||||
return (gnQueueExtFunctions) {
|
return (gnQueueExtFunctions) {
|
||||||
._gnGetPhysicalDeviceQueueProperties = vulkanPhysicalDeviceQueueProperties,
|
._gnGetPhysicalDeviceQueueProperties = vulkanPhysicalDeviceQueueProperties,
|
||||||
._gnQueueSubmit = vulkanSubmitQueue,
|
._gnQueueSubmit = vulkanSubmitQueue,
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
#include "submit/vulkan_submit.h"
|
#include "submit/vulkan_submit.h"
|
||||||
#include "present/vulkan_present.h"
|
#include "present/vulkan_present.h"
|
||||||
|
|
||||||
gnSyncExtFunctions loadVulkanSyncFunctions() {
|
gnSyncExtFunctions loadVulkanSyncFunctions(void) {
|
||||||
return (gnSyncExtFunctions){
|
return (gnSyncExtFunctions){
|
||||||
._gnPresentationQueueGetImageAsync = getPresentQueueImageAsync,
|
._gnPresentationQueueGetImageAsync = getPresentQueueImageAsync,
|
||||||
|
|
||||||
|
@@ -66,7 +66,6 @@ void VkCopyBuffer(gnDevice device, VkBuffer source, VkBuffer destination, VkBuff
|
|||||||
|
|
||||||
gnReturnCode createBuffer(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);
|
|
||||||
buffer->buffer->useStagingBuffer = (info.usage == GN_STATIC_DRAW);
|
buffer->buffer->useStagingBuffer = (info.usage == GN_STATIC_DRAW);
|
||||||
if (info.usage == GN_STATIC_DRAW) {
|
if (info.usage == GN_STATIC_DRAW) {
|
||||||
return VkCreateBuffer(
|
return VkCreateBuffer(
|
||||||
@@ -91,14 +90,13 @@ void vulkanBufferData(gnBufferHandle buffer, size_t dataSize, void* data) {
|
|||||||
}
|
}
|
||||||
void vulkanBufferSubData(gnBufferHandle buffer, size_t offset, size_t dataSize, void* data) {
|
void vulkanBufferSubData(gnBufferHandle buffer, size_t offset, size_t dataSize, void* data) {
|
||||||
void* bufferData;
|
void* bufferData;
|
||||||
|
|
||||||
if (buffer->buffer->useStagingBuffer) {
|
if (buffer->buffer->useStagingBuffer) {
|
||||||
VkGryphnBuffer* stagingBuffer = &buffer->device->outputDevice->stagingBuffer;
|
VkGryphnBuffer* stagingBuffer = &buffer->device->outputDevice->stagingBuffer;
|
||||||
VkDeviceSize sizeLeft = dataSize;
|
VkDeviceSize sizeLeft = dataSize;
|
||||||
while (sizeLeft > 0) {
|
while (sizeLeft > 0) {
|
||||||
VkDeviceSize chunkSize = (buffer->device->outputDevice->stagingBufferSize < sizeLeft) ? buffer->device->outputDevice->stagingBufferSize : sizeLeft;
|
VkDeviceSize chunkSize = (buffer->device->outputDevice->stagingBufferSize < sizeLeft) ? buffer->device->outputDevice->stagingBufferSize : sizeLeft;
|
||||||
vkMapMemory(buffer->device->outputDevice->device, stagingBuffer->memory, 0, chunkSize, 0, &bufferData);
|
vkMapMemory(buffer->device->outputDevice->device, stagingBuffer->memory, 0, chunkSize, 0, &bufferData);
|
||||||
memcpy(bufferData, data + (dataSize - sizeLeft), chunkSize);
|
memcpy(bufferData, (char*)data + (dataSize - sizeLeft), chunkSize);
|
||||||
vkUnmapMemory(buffer->device->outputDevice->device, stagingBuffer->memory);
|
vkUnmapMemory(buffer->device->outputDevice->device, stagingBuffer->memory);
|
||||||
|
|
||||||
VkBufferCopy copyRegion = {
|
VkBufferCopy copyRegion = {
|
||||||
@@ -111,7 +109,7 @@ void vulkanBufferSubData(gnBufferHandle buffer, size_t offset, size_t dataSize,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
vkMapMemory(buffer->device->outputDevice->device, buffer->buffer->buffer.memory, 0, dataSize, 0, &bufferData);
|
vkMapMemory(buffer->device->outputDevice->device, buffer->buffer->buffer.memory, 0, dataSize, 0, &bufferData);
|
||||||
memcpy(bufferData + offset, data, dataSize);
|
memcpy((char*)bufferData + offset, data, dataSize);
|
||||||
vkUnmapMemory(buffer->device->outputDevice->device, buffer->buffer->buffer.memory);
|
vkUnmapMemory(buffer->device->outputDevice->device, buffer->buffer->buffer.memory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,7 @@ gnReturnCode allocateCommandBuffers(gnCommandBufferHandle* commandBuffers, uint3
|
|||||||
|
|
||||||
VkResult allocationResult = vkAllocateCommandBuffers(pool->device->outputDevice->device, &allocInfo, buffers);
|
VkResult allocationResult = vkAllocateCommandBuffers(pool->device->outputDevice->device, &allocInfo, buffers);
|
||||||
if (allocationResult == VK_SUCCESS)
|
if (allocationResult == VK_SUCCESS)
|
||||||
for (int i = 0; i < count; i++) {
|
for (uint32_t i = 0; i < count; i++) {
|
||||||
commandBuffers[i]->commandBuffer = malloc(sizeof(gnPlatformCommandBuffer));
|
commandBuffers[i]->commandBuffer = malloc(sizeof(gnPlatformCommandBuffer));
|
||||||
commandBuffers[i]->commandBuffer->buffer = buffers[i];
|
commandBuffers[i]->commandBuffer->buffer = buffers[i];
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
void beginRenderPass(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 (uint32_t i = 0; i < passInfo.clearValueCount; i++) {
|
||||||
values[i] = (VkClearValue){{{
|
values[i] = (VkClearValue){{{
|
||||||
passInfo.clearValues[i].red,
|
passInfo.clearValues[i].red,
|
||||||
passInfo.clearValues[i].green,
|
passInfo.clearValues[i].green,
|
||||||
|
@@ -38,18 +38,13 @@ void vulkanLoadNeededQueues(VkPhysicalDevice vulkanDevice, gnPhysicalDevice gryp
|
|||||||
vkGetPhysicalDeviceQueueFamilyProperties(vulkanDevice, &queueFamilyCount, queueFamilies);
|
vkGetPhysicalDeviceQueueFamilyProperties(vulkanDevice, &queueFamilyCount, queueFamilies);
|
||||||
|
|
||||||
gryphnDevice->physicalDevice->neededQueues = malloc(sizeof(vulkanNeededQueue) * queueFamilyCount);
|
gryphnDevice->physicalDevice->neededQueues = malloc(sizeof(vulkanNeededQueue) * queueFamilyCount);
|
||||||
gnBool foundGraphicsQueueFamily = GN_FALSE, foundTransferQueueFamily = GN_FALSE;
|
for (uint32_t c = 0; c < queueFamilyCount; c++) {
|
||||||
for (int c = 0; c < queueFamilyCount; c++) {
|
|
||||||
gnBool hasNeededQueue = GN_FALSE;
|
gnBool hasNeededQueue = GN_FALSE;
|
||||||
|
|
||||||
if ((queueFamilies[c].queueFlags & VK_QUEUE_GRAPHICS_BIT) == VK_QUEUE_GRAPHICS_BIT) {
|
if ((queueFamilies[c].queueFlags & VK_QUEUE_GRAPHICS_BIT) == VK_QUEUE_GRAPHICS_BIT)
|
||||||
foundGraphicsQueueFamily = GN_TRUE;
|
|
||||||
hasNeededQueue = GN_TRUE;
|
hasNeededQueue = GN_TRUE;
|
||||||
}
|
if ((queueFamilies[c].queueFlags & VK_QUEUE_TRANSFER_BIT) == VK_QUEUE_TRANSFER_BIT)
|
||||||
if ((queueFamilies[c].queueFlags & VK_QUEUE_TRANSFER_BIT) == VK_QUEUE_TRANSFER_BIT) {
|
|
||||||
foundTransferQueueFamily = GN_TRUE;
|
|
||||||
hasNeededQueue = GN_TRUE;
|
hasNeededQueue = GN_TRUE;
|
||||||
}
|
|
||||||
|
|
||||||
if (hasNeededQueue) {
|
if (hasNeededQueue) {
|
||||||
vulkanNeededQueue neededQueue = {
|
vulkanNeededQueue neededQueue = {
|
||||||
@@ -77,7 +72,7 @@ gnPhysicalDevice* getPhysicalDevices(gnInstanceHandle instance, uint32_t* device
|
|||||||
vkEnumeratePhysicalDevices(instance->instance->vk_instance, deviceCount, physicalDevices);
|
vkEnumeratePhysicalDevices(instance->instance->vk_instance, deviceCount, physicalDevices);
|
||||||
gnPhysicalDevice* outputDevices = (gnPhysicalDevice*)malloc(sizeof(gnPhysicalDevice) * *deviceCount);
|
gnPhysicalDevice* outputDevices = (gnPhysicalDevice*)malloc(sizeof(gnPhysicalDevice) * *deviceCount);
|
||||||
|
|
||||||
for (int i = 0; i < *deviceCount; i++) {
|
for (uint32_t i = 0; i < *deviceCount; i++) {
|
||||||
outputDevices[i] = malloc(sizeof(gnPhysicalOutputDevice_t));
|
outputDevices[i] = malloc(sizeof(gnPhysicalOutputDevice_t));
|
||||||
outputDevices[i]->physicalDevice = malloc(sizeof(struct gnPlatformPhysicalDevice_t));
|
outputDevices[i]->physicalDevice = malloc(sizeof(struct gnPlatformPhysicalDevice_t));
|
||||||
outputDevices[i]->physicalDevice->device = physicalDevices[i];
|
outputDevices[i]->physicalDevice->device = physicalDevices[i];
|
||||||
@@ -112,7 +107,7 @@ gnPhysicalDevice* getPhysicalDevices(gnInstanceHandle instance, uint32_t* device
|
|||||||
|
|
||||||
gnBool deviceCanPresentToSurface(gnPhysicalDevice device, gnWindowSurface surface) {
|
gnBool deviceCanPresentToSurface(gnPhysicalDevice device, gnWindowSurface surface) {
|
||||||
gnBool foundQueue = GN_FALSE;
|
gnBool foundQueue = GN_FALSE;
|
||||||
for (int i = 0; i < device->physicalDevice->neededQueueCount; i++) {
|
for (uint32_t i = 0; i < device->physicalDevice->neededQueueCount; i++) {
|
||||||
VkBool32 supportsPresent = VK_FALSE;
|
VkBool32 supportsPresent = VK_FALSE;
|
||||||
vkGetPhysicalDeviceSurfaceSupportKHR(device->physicalDevice->device, device->physicalDevice->neededQueues[i].queueIndex, surface->windowSurface->surface, &supportsPresent);
|
vkGetPhysicalDeviceSurfaceSupportKHR(device->physicalDevice->device, device->physicalDevice->neededQueues[i].queueIndex, surface->windowSurface->surface, &supportsPresent);
|
||||||
if (supportsPresent) {
|
if (supportsPresent) {
|
||||||
@@ -127,7 +122,7 @@ gnBool deviceCanPresentToSurface(gnPhysicalDevice device, gnWindowSurface surfac
|
|||||||
uint32_t queueFamilyCount = 0;
|
uint32_t queueFamilyCount = 0;
|
||||||
vkGetPhysicalDeviceQueueFamilyProperties(device->physicalDevice->device, &queueFamilyCount, NULL);
|
vkGetPhysicalDeviceQueueFamilyProperties(device->physicalDevice->device, &queueFamilyCount, NULL);
|
||||||
|
|
||||||
for (int i = 0; i < queueFamilyCount; i++) {
|
for (uint32_t i = 0; i < queueFamilyCount; i++) {
|
||||||
VkBool32 supportsPresent = VK_FALSE;
|
VkBool32 supportsPresent = VK_FALSE;
|
||||||
vkGetPhysicalDeviceSurfaceSupportKHR(device->physicalDevice->device, i, surface->windowSurface->surface, &supportsPresent);
|
vkGetPhysicalDeviceSurfaceSupportKHR(device->physicalDevice->device, i, surface->windowSurface->surface, &supportsPresent);
|
||||||
if (supportsPresent) {
|
if (supportsPresent) {
|
||||||
|
@@ -4,11 +4,13 @@
|
|||||||
#include "vulkan_result_converter.h"
|
#include "vulkan_result_converter.h"
|
||||||
|
|
||||||
gnReturnCode vulkanQueuePresentSync(gnDevice device, gnQueue queue, gnPresentSyncInfo info) {
|
gnReturnCode vulkanQueuePresentSync(gnDevice device, gnQueue queue, gnPresentSyncInfo info) {
|
||||||
|
if (device == GN_NULL_HANDLE) return GN_INVALID_HANDLE;
|
||||||
|
|
||||||
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 (uint32_t i = 0; i < info.waitCount; i++) waitSemaphores[i] = info.waitSemaphores[i]->semaphore->semaphore;
|
||||||
|
|
||||||
VkSwapchainKHR* swapchains = malloc(sizeof(VkSwapchainKHR) * info.presentationQueueCount);
|
VkSwapchainKHR* swapchains = malloc(sizeof(VkSwapchainKHR) * info.presentationQueueCount);
|
||||||
for (int i = 0; i < info.presentationQueueCount; i++) swapchains[i] = info.presentationQueues[i]->presentationQueue->swapChain;
|
for (uint32_t i = 0; i < info.presentationQueueCount; i++) swapchains[i] = info.presentationQueues[i]->presentationQueue->swapChain;
|
||||||
|
|
||||||
VkPresentInfoKHR presentInfo = {
|
VkPresentInfoKHR presentInfo = {
|
||||||
.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,
|
.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,
|
||||||
@@ -27,8 +29,10 @@ gnReturnCode vulkanPresentSync(gnDevice device, gnPresentSyncInfo info) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gnReturnCode vulkanQueuePresent(gnDevice device, gnQueue queue, gnPresentInfo info) {
|
gnReturnCode vulkanQueuePresent(gnDevice device, gnQueue queue, gnPresentInfo info) {
|
||||||
|
if (device == GN_NULL_HANDLE) return GN_INVALID_HANDLE;
|
||||||
|
|
||||||
VkSwapchainKHR* swapchains = malloc(sizeof(VkSwapchainKHR) * info.presentationQueueCount);
|
VkSwapchainKHR* swapchains = malloc(sizeof(VkSwapchainKHR) * info.presentationQueueCount);
|
||||||
for (int i = 0; i < info.presentationQueueCount; i++) swapchains[i] = info.presentationQueues[i]->presentationQueue->swapChain;
|
for (uint32_t i = 0; i < info.presentationQueueCount; i++) swapchains[i] = info.presentationQueues[i]->presentationQueue->swapChain;
|
||||||
|
|
||||||
VkPresentInfoKHR presentInfo = {
|
VkPresentInfoKHR presentInfo = {
|
||||||
.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,
|
.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,
|
||||||
|
@@ -19,42 +19,42 @@ gnReturnCode createPresentationQueue(gnPresentationQueueHandle presentationQueue
|
|||||||
.height = presentationInfo.imageSize.y
|
.height = presentationInfo.imageSize.y
|
||||||
};
|
};
|
||||||
|
|
||||||
VkSwapchainCreateInfoKHR createInfo = {};
|
VkSwapchainCreateInfoKHR presentQueueCreateInfo = {
|
||||||
createInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
|
.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,
|
||||||
createInfo.surface = presentationInfo.surface->windowSurface->surface;
|
.surface = presentationInfo.surface->windowSurface->surface,
|
||||||
|
.minImageCount = presentationInfo.minImageCount,
|
||||||
createInfo.minImageCount = presentationInfo.minImageCount;
|
.imageFormat = convertedFormat,
|
||||||
createInfo.imageFormat = convertedFormat;
|
.imageColorSpace = convertedColorSpace,
|
||||||
createInfo.imageColorSpace = convertedColorSpace;
|
.imageExtent = extent,
|
||||||
createInfo.imageExtent = extent;
|
.imageArrayLayers = 1,
|
||||||
createInfo.imageArrayLayers = 1;
|
.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
|
||||||
createInfo.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
.preTransform = details.capabilities.currentTransform,
|
||||||
|
.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR,
|
||||||
|
.presentMode = presentMode,
|
||||||
|
.clipped = VK_TRUE,
|
||||||
|
.oldSwapchain = VK_NULL_HANDLE
|
||||||
|
};
|
||||||
|
|
||||||
if (device->instance->enabledExtensions[GN_EXT_QUEUES]) {
|
if (device->instance->enabledExtensions[GN_EXT_QUEUES]) {
|
||||||
createInfo.imageSharingMode = (presentationInfo.imageSharingMode == GN_SHARING_MODE_CONCURRENT) ? VK_SHARING_MODE_CONCURRENT : VK_SHARING_MODE_EXCLUSIVE;
|
presentQueueCreateInfo.imageSharingMode = (presentationInfo.imageSharingMode == GN_SHARING_MODE_CONCURRENT) ? VK_SHARING_MODE_CONCURRENT : VK_SHARING_MODE_EXCLUSIVE;
|
||||||
createInfo.queueFamilyIndexCount = presentationInfo.queueFamilyCount;
|
presentQueueCreateInfo.queueFamilyIndexCount = presentationInfo.queueFamilyCount;
|
||||||
createInfo.pQueueFamilyIndices = presentationInfo.queueFamilies;
|
presentQueueCreateInfo.pQueueFamilyIndices = presentationInfo.queueFamilies;
|
||||||
} else {
|
} else {
|
||||||
if (presentationInfo.surface->windowSurface->presentQueueIndex != device->outputDevice->graphicsQueueIndex) {
|
if (presentationInfo.surface->windowSurface->presentQueueIndex != device->outputDevice->graphicsQueueIndex) {
|
||||||
createInfo.imageSharingMode = VK_SHARING_MODE_CONCURRENT;
|
presentQueueCreateInfo.imageSharingMode = VK_SHARING_MODE_CONCURRENT;
|
||||||
createInfo.queueFamilyIndexCount = 2;
|
presentQueueCreateInfo.queueFamilyIndexCount = 2;
|
||||||
createInfo.pQueueFamilyIndices = (uint32_t[]){
|
presentQueueCreateInfo.pQueueFamilyIndices = (uint32_t[]){
|
||||||
device->outputDevice->queues[presentationInfo.surface->windowSurface->presentQueueIndex].queueInfo.queueIndex,
|
device->outputDevice->queues[presentationInfo.surface->windowSurface->presentQueueIndex].queueInfo.queueIndex,
|
||||||
device->outputDevice->queues[device->outputDevice->graphicsQueueIndex].queueInfo.queueIndex
|
device->outputDevice->queues[device->outputDevice->graphicsQueueIndex].queueInfo.queueIndex
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
createInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
presentQueueCreateInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||||
createInfo.queueFamilyIndexCount = 1;
|
presentQueueCreateInfo.queueFamilyIndexCount = 1;
|
||||||
createInfo.pQueueFamilyIndices = &device->outputDevice->queues[presentationInfo.surface->windowSurface->presentQueueIndex].queueInfo.queueIndex;
|
presentQueueCreateInfo.pQueueFamilyIndices = &device->outputDevice->queues[presentationInfo.surface->windowSurface->presentQueueIndex].queueInfo.queueIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
createInfo.preTransform = details.capabilities.currentTransform;
|
|
||||||
createInfo.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
|
|
||||||
createInfo.presentMode = presentMode;
|
|
||||||
createInfo.clipped = VK_TRUE;
|
|
||||||
createInfo.oldSwapchain = VK_NULL_HANDLE;
|
|
||||||
|
|
||||||
VkResult result = vkCreateSwapchainKHR(device->outputDevice->device, &createInfo, NULL, &presentationQueue->presentationQueue->swapChain);
|
VkResult result = vkCreateSwapchainKHR(device->outputDevice->device, &presentQueueCreateInfo, NULL, &presentationQueue->presentationQueue->swapChain);
|
||||||
if (result != VK_SUCCESS) return VkResultToGnReturnCode(result);
|
if (result != VK_SUCCESS) return VkResultToGnReturnCode(result);
|
||||||
|
|
||||||
vkGetSwapchainImagesKHR(device->outputDevice->device, presentationQueue->presentationQueue->swapChain, &presentationQueue->imageCount, NULL);
|
vkGetSwapchainImagesKHR(device->outputDevice->device, presentationQueue->presentationQueue->swapChain, &presentationQueue->imageCount, NULL);
|
||||||
@@ -62,22 +62,23 @@ gnReturnCode createPresentationQueue(gnPresentationQueueHandle presentationQueue
|
|||||||
presentationQueue->presentationQueue->swapChainImageViews = malloc(sizeof(VkImageView) * presentationQueue->imageCount);
|
presentationQueue->presentationQueue->swapChainImageViews = malloc(sizeof(VkImageView) * presentationQueue->imageCount);
|
||||||
vkGetSwapchainImagesKHR(device->outputDevice->device, presentationQueue->presentationQueue->swapChain, &presentationQueue->imageCount, presentationQueue->presentationQueue->swapChainImages);
|
vkGetSwapchainImagesKHR(device->outputDevice->device, presentationQueue->presentationQueue->swapChain, &presentationQueue->imageCount, presentationQueue->presentationQueue->swapChainImages);
|
||||||
|
|
||||||
VkImageViewCreateInfo imageViewCreateInfo = {};
|
VkImageViewCreateInfo imageViewCreateInfo = {
|
||||||
imageViewCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
|
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
|
||||||
imageViewCreateInfo.viewType = VK_IMAGE_VIEW_TYPE_2D;
|
.viewType = VK_IMAGE_VIEW_TYPE_2D,
|
||||||
imageViewCreateInfo.format = convertedFormat;
|
.format = convertedFormat,
|
||||||
imageViewCreateInfo.components.r = VK_COMPONENT_SWIZZLE_IDENTITY;
|
.components.r = VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||||
imageViewCreateInfo.components.g = VK_COMPONENT_SWIZZLE_IDENTITY;
|
.components.g = VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||||
imageViewCreateInfo.components.b = VK_COMPONENT_SWIZZLE_IDENTITY;
|
.components.b = VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||||
imageViewCreateInfo.components.a = VK_COMPONENT_SWIZZLE_IDENTITY;
|
.components.a = VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||||
imageViewCreateInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
|
||||||
imageViewCreateInfo.subresourceRange.baseMipLevel = 0;
|
.subresourceRange.baseMipLevel = 0,
|
||||||
imageViewCreateInfo.subresourceRange.levelCount = 1;
|
.subresourceRange.levelCount = 1,
|
||||||
imageViewCreateInfo.subresourceRange.baseArrayLayer = 0;
|
.subresourceRange.baseArrayLayer = 0,
|
||||||
imageViewCreateInfo.subresourceRange.layerCount = 1;
|
.subresourceRange.layerCount = 1
|
||||||
|
};
|
||||||
|
|
||||||
presentationQueue->images = malloc(sizeof(gnTextureHandle) * presentationQueue->imageCount);
|
presentationQueue->images = malloc(sizeof(gnTextureHandle) * presentationQueue->imageCount);
|
||||||
for (int i = 0; i < presentationQueue->imageCount; i++) {
|
for (uint32_t i = 0; i < presentationQueue->imageCount; i++) {
|
||||||
presentationQueue->images[i] = malloc(sizeof(struct gnTexture_t));
|
presentationQueue->images[i] = malloc(sizeof(struct gnTexture_t));
|
||||||
presentationQueue->images[i]->texture = malloc(sizeof(gnPlatformTexture));
|
presentationQueue->images[i]->texture = malloc(sizeof(gnPlatformTexture));
|
||||||
imageViewCreateInfo.image = presentationQueue->presentationQueue->swapChainImages[i];
|
imageViewCreateInfo.image = presentationQueue->presentationQueue->swapChainImages[i];
|
||||||
@@ -99,23 +100,18 @@ gnReturnCode getVulkanPresentQueueImage(gnPresentationQueueHandle presentationQu
|
|||||||
presentationQueue->presentationQueue->swapChain,
|
presentationQueue->presentationQueue->swapChain,
|
||||||
UINT64_MAX, VK_NULL_HANDLE, presentationQueue->outputDevice->outputDevice->barrierFence, imageIndex);
|
UINT64_MAX, VK_NULL_HANDLE, presentationQueue->outputDevice->outputDevice->barrierFence, imageIndex);
|
||||||
vkWaitForFences(presentationQueue->outputDevice->outputDevice->device, 1, &presentationQueue->outputDevice->outputDevice->barrierFence, VK_TRUE, UINT64_MAX);
|
vkWaitForFences(presentationQueue->outputDevice->outputDevice->device, 1, &presentationQueue->outputDevice->outputDevice->barrierFence, VK_TRUE, UINT64_MAX);
|
||||||
if (result == VK_ERROR_OUT_OF_DATE_KHR) return GN_OUT_OF_DATE_PRESENTATION_QUEUE;
|
return VkResultToGnReturnCode(result);
|
||||||
if (result == VK_SUBOPTIMAL_KHR) return GN_SUBOPTIMAL_PRESENTATION_QUEUE;
|
|
||||||
return GN_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gnReturnCode getPresentQueueImageAsync(gnPresentationQueueHandle presentationQueue, uint64_t timeout, gnSemaphore semaphore, uint32_t* imageIndex) {
|
gnReturnCode getPresentQueueImageAsync(gnPresentationQueueHandle presentationQueue, uint64_t timeout, gnSemaphore semaphore, uint32_t* imageIndex) {
|
||||||
VkResult result = vkAcquireNextImageKHR(
|
return VkResultToGnReturnCode(vkAcquireNextImageKHR(
|
||||||
presentationQueue->outputDevice->outputDevice->device,
|
presentationQueue->outputDevice->outputDevice->device,
|
||||||
presentationQueue->presentationQueue->swapChain,
|
presentationQueue->presentationQueue->swapChain,
|
||||||
timeout, semaphore->semaphore->semaphore, VK_NULL_HANDLE, imageIndex);
|
timeout, semaphore->semaphore->semaphore, VK_NULL_HANDLE, imageIndex));
|
||||||
if (result == VK_ERROR_OUT_OF_DATE_KHR) return GN_OUT_OF_DATE_PRESENTATION_QUEUE;
|
|
||||||
if (result == VK_SUBOPTIMAL_KHR) return GN_SUBOPTIMAL_PRESENTATION_QUEUE;
|
|
||||||
return GN_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroyPresentationQueue(gnPresentationQueueHandle queue) {
|
void destroyPresentationQueue(gnPresentationQueueHandle queue) {
|
||||||
for (int i = 0; i < queue->imageCount; i++)
|
for (uint32_t i = 0; i < queue->imageCount; i++)
|
||||||
vkDestroyImageView(queue->outputDevice->outputDevice->device, queue->presentationQueue->swapChainImageViews[i], NULL);
|
vkDestroyImageView(queue->outputDevice->outputDevice->device, queue->presentationQueue->swapChainImageViews[i], NULL);
|
||||||
vkDestroySwapchainKHR(queue->outputDevice->outputDevice->device, queue->presentationQueue->swapChain, NULL);
|
vkDestroySwapchainKHR(queue->outputDevice->outputDevice->device, queue->presentationQueue->swapChain, NULL);
|
||||||
free(queue->presentationQueue->swapChainImageViews);
|
free(queue->presentationQueue->swapChainImageViews);
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
#include "vulkan_swapchain_support.h"
|
#include "vulkan_swapchain_support.h"
|
||||||
|
|
||||||
struct vkSwapchainSupportDetails_t vkGetSwapchainSupport(
|
vkSwapchainSupportDetails vkGetSwapchainSupport(
|
||||||
const VkPhysicalDevice device,
|
const VkPhysicalDevice device,
|
||||||
const VkSurfaceKHR surface
|
const VkSurfaceKHR surface
|
||||||
) {
|
) {
|
||||||
struct vkSwapchainSupportDetails_t details;
|
vkSwapchainSupportDetails details;
|
||||||
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(device, surface, &details.capabilities);
|
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(device, surface, &details.capabilities);
|
||||||
|
|
||||||
vkGetPhysicalDeviceSurfaceFormatsKHR(device, surface, &details.formatCount, NULL);
|
vkGetPhysicalDeviceSurfaceFormatsKHR(device, surface, &details.formatCount, NULL);
|
||||||
@@ -21,15 +21,3 @@ struct vkSwapchainSupportDetails_t vkGetSwapchainSupport(
|
|||||||
|
|
||||||
return details;
|
return details;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct vkSwapchainDetails_t vkGetSwapchainDetails(
|
|
||||||
const struct vkSwapchainSupportDetails_t supportDetails
|
|
||||||
) {
|
|
||||||
struct vkSwapchainDetails_t details;
|
|
||||||
|
|
||||||
for (int i = 0; i < supportDetails.formatCount; i++) {
|
|
||||||
// if (supportDetails.)
|
|
||||||
}
|
|
||||||
|
|
||||||
return details;
|
|
||||||
}
|
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <output_device/vulkan_output_devices.h>
|
#include <output_device/vulkan_output_devices.h>
|
||||||
|
|
||||||
typedef struct vkSwapchainSupportDetails_t {
|
typedef struct vkSwapchainSupportDetails {
|
||||||
VkSurfaceCapabilitiesKHR capabilities;
|
VkSurfaceCapabilitiesKHR capabilities;
|
||||||
uint32_t formatCount;
|
uint32_t formatCount;
|
||||||
VkSurfaceFormatKHR* formats;
|
VkSurfaceFormatKHR* formats;
|
||||||
@@ -11,15 +11,11 @@ typedef struct vkSwapchainSupportDetails_t {
|
|||||||
VkPresentModeKHR* presentModes;
|
VkPresentModeKHR* presentModes;
|
||||||
} vkSwapchainSupportDetails;
|
} vkSwapchainSupportDetails;
|
||||||
|
|
||||||
typedef struct vkSwapchainDetails_t {
|
typedef struct vkSwapchainDetails {
|
||||||
VkSurfaceFormatKHR surfaceFormat;
|
VkSurfaceFormatKHR surfaceFormat;
|
||||||
} vkSwapchainDetails;
|
} vkSwapchainDetails;
|
||||||
|
|
||||||
struct vkSwapchainSupportDetails_t vkGetSwapchainSupport(
|
struct vkSwapchainSupportDetails vkGetSwapchainSupport(
|
||||||
const VkPhysicalDevice device,
|
const VkPhysicalDevice device,
|
||||||
const VkSurfaceKHR surface
|
const VkSurfaceKHR surface
|
||||||
);
|
);
|
||||||
|
|
||||||
struct vkSwapchainDetails_t vkGetSwapchainDetails(
|
|
||||||
const struct vkSwapchainSupportDetails_t supportDetails
|
|
||||||
);
|
|
||||||
|
@@ -38,19 +38,17 @@ VkPipelineStageFlags vkGryphnRenderPassStage(gnRenderPassStage stage) {
|
|||||||
|
|
||||||
VkAccessFlags vkGryphnRenderPassAccess(gnRenderPassAccess access) {
|
VkAccessFlags vkGryphnRenderPassAccess(gnRenderPassAccess access) {
|
||||||
VkAccessFlags flags = 0;
|
VkAccessFlags flags = 0;
|
||||||
if ((flags & GN_COLOR_ATTACHMENT_WRITE) == GN_COLOR_ATTACHMENT_WRITE) flags |= VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
if ((access & GN_COLOR_ATTACHMENT_WRITE) == GN_COLOR_ATTACHMENT_WRITE) flags |= VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||||
if ((flags & GN_DEPTH_STENCIL_WRITE) == GN_DEPTH_STENCIL_WRITE) flags |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
|
if ((access & GN_DEPTH_STENCIL_WRITE) == GN_DEPTH_STENCIL_WRITE) flags |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
gnReturnCode createRenderPass(gnRenderPassDescriptor renderPass, gnDevice device, gnRenderPassDescriptorInfo info) {
|
gnReturnCode createRenderPass(gnRenderPassDescriptor renderPass, gnDevice device, gnRenderPassDescriptorInfo info) {
|
||||||
|
|
||||||
|
|
||||||
renderPass->renderPassDescriptor = malloc(sizeof(gnPlatformRenderPassDescriptor));
|
renderPass->renderPassDescriptor = malloc(sizeof(gnPlatformRenderPassDescriptor));
|
||||||
|
|
||||||
renderPass->renderPassDescriptor->attachmentCount = info.attachmentCount;
|
renderPass->renderPassDescriptor->attachmentCount = info.attachmentCount;
|
||||||
renderPass->renderPassDescriptor->attachments = malloc(sizeof(VkAttachmentDescription) * info.attachmentCount);
|
renderPass->renderPassDescriptor->attachments = malloc(sizeof(VkAttachmentDescription) * info.attachmentCount);
|
||||||
for (int i = 0; i < info.attachmentCount; i++) {
|
for (uint32_t i = 0; i < info.attachmentCount; i++) {
|
||||||
renderPass->renderPassDescriptor->attachments[i].format = vkGryphnFormatToVulkanFormat(info.attachmentInfos[i].format);
|
renderPass->renderPassDescriptor->attachments[i].format = vkGryphnFormatToVulkanFormat(info.attachmentInfos[i].format);
|
||||||
renderPass->renderPassDescriptor->attachments[i].flags = 0;
|
renderPass->renderPassDescriptor->attachments[i].flags = 0;
|
||||||
renderPass->renderPassDescriptor->attachments[i].samples = gnSampleCountToVulkan(info.attachmentInfos[i].samples);
|
renderPass->renderPassDescriptor->attachments[i].samples = gnSampleCountToVulkan(info.attachmentInfos[i].samples);
|
||||||
@@ -72,11 +70,11 @@ gnReturnCode createRenderPass(gnRenderPassDescriptor renderPass, gnDevice device
|
|||||||
renderPass->renderPassDescriptor->resolveAttachments = malloc(sizeof(VkAttachmentReference*) * info.subpassCount);
|
renderPass->renderPassDescriptor->resolveAttachments = malloc(sizeof(VkAttachmentReference*) * info.subpassCount);
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < info.subpassCount; i++) {
|
for (uint32_t i = 0; i < info.subpassCount; i++) {
|
||||||
renderPass->renderPassDescriptor->colorAttachments[i] = malloc(sizeof(VkAttachmentReference) * info.subpassInfos[i].colorAttachmentCount);
|
renderPass->renderPassDescriptor->colorAttachments[i] = malloc(sizeof(VkAttachmentReference) * info.subpassInfos[i].colorAttachmentCount);
|
||||||
renderPass->renderPassDescriptor->resolveAttachments[i] = malloc(sizeof(VkAttachmentReference) * info.subpassInfos[i].colorAttachmentCount);
|
renderPass->renderPassDescriptor->resolveAttachments[i] = malloc(sizeof(VkAttachmentReference) * info.subpassInfos[i].colorAttachmentCount);
|
||||||
|
|
||||||
for (int c = 0; c < info.subpassInfos[i].colorAttachmentCount; c++) {
|
for (uint32_t c = 0; c < info.subpassInfos[i].colorAttachmentCount; c++) {
|
||||||
renderPass->renderPassDescriptor->colorAttachments[i][c] = (VkAttachmentReference){
|
renderPass->renderPassDescriptor->colorAttachments[i][c] = (VkAttachmentReference){
|
||||||
.attachment = info.subpassInfos[i].colorAttachments[c].index,
|
.attachment = info.subpassInfos[i].colorAttachments[c].index,
|
||||||
.layout = vkGryphnImageLayout(info.subpassInfos[i].colorAttachments[c].imageLayout)
|
.layout = vkGryphnImageLayout(info.subpassInfos[i].colorAttachments[c].imageLayout)
|
||||||
@@ -108,7 +106,7 @@ gnReturnCode createRenderPass(gnRenderPassDescriptor renderPass, gnDevice device
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderPass->renderPassDescriptor->dependencies = malloc(sizeof(VkSubpassDependency) * info.dependencyCount);
|
renderPass->renderPassDescriptor->dependencies = malloc(sizeof(VkSubpassDependency) * info.dependencyCount);
|
||||||
for (int i = 0; i < info.dependencyCount; i++) {
|
for (uint32_t i = 0; i < info.dependencyCount; i++) {
|
||||||
renderPass->renderPassDescriptor->dependencies[i] = (VkSubpassDependency) {
|
renderPass->renderPassDescriptor->dependencies[i] = (VkSubpassDependency) {
|
||||||
.srcSubpass = (info.dependencies[i].source == GN_SUBPASS_EXTERNAL) ? VK_SUBPASS_EXTERNAL : info.dependencies[i].source,
|
.srcSubpass = (info.dependencies[i].source == GN_SUBPASS_EXTERNAL) ? VK_SUBPASS_EXTERNAL : info.dependencies[i].source,
|
||||||
.dstSubpass = (info.dependencies[i].destination == GN_SUBPASS_EXTERNAL) ? VK_SUBPASS_EXTERNAL : info.dependencies[i].destination,
|
.dstSubpass = (info.dependencies[i].destination == GN_SUBPASS_EXTERNAL) ? VK_SUBPASS_EXTERNAL : info.dependencies[i].destination,
|
||||||
|
@@ -2,16 +2,18 @@
|
|||||||
#include "vulkan_result_converter.h"
|
#include "vulkan_result_converter.h"
|
||||||
|
|
||||||
gnReturnCode vulkanSubmitSyncQueue(gnOutputDevice device, gnQueue queue, gnSubmitSyncInfo info) {
|
gnReturnCode vulkanSubmitSyncQueue(gnOutputDevice device, gnQueue queue, gnSubmitSyncInfo info) {
|
||||||
|
if (device == GN_NULL_HANDLE) return GN_INVALID_HANDLE;
|
||||||
|
|
||||||
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 (uint32_t i = 0; i < info.waitCount; i++) waitSemaphores[i] = info.waitSemaphores[i]->semaphore->semaphore;
|
||||||
for (int i = 0; i < info.waitCount; i++) waitStages[i] = vkGryphnRenderPassStage(info.waitStages[i]);
|
for (uint32_t i = 0; i < info.waitCount; i++) waitStages[i] = vkGryphnRenderPassStage(info.waitStages[i]);
|
||||||
|
|
||||||
VkCommandBuffer* commandBuffers = malloc(sizeof(VkCommandBuffer) * info.commandBufferCount);
|
VkCommandBuffer* commandBuffers = malloc(sizeof(VkCommandBuffer) * info.commandBufferCount);
|
||||||
for (int i = 0; i < info.commandBufferCount; i++) commandBuffers[i] = info.commandBuffers[i]->commandBuffer->buffer;
|
for (uint32_t i = 0; i < info.commandBufferCount; i++) commandBuffers[i] = info.commandBuffers[i]->commandBuffer->buffer;
|
||||||
|
|
||||||
VkSemaphore* signalSemaphores = malloc(sizeof(VkSemaphore) * info.signalCount);
|
VkSemaphore* signalSemaphores = malloc(sizeof(VkSemaphore) * info.signalCount);
|
||||||
for (int i = 0; i < info.signalCount; i++) signalSemaphores[i] = info.signalSemaphores[i]->semaphore->semaphore;
|
for (uint32_t i = 0; i < info.signalCount; i++) signalSemaphores[i] = info.signalSemaphores[i]->semaphore->semaphore;
|
||||||
|
|
||||||
VkSubmitInfo submitInfo = {
|
VkSubmitInfo submitInfo = {
|
||||||
.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
|
.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
|
||||||
@@ -33,7 +35,7 @@ gnReturnCode vulkanSubmitSync(gnDevice device, gnSubmitSyncInfo info) {
|
|||||||
|
|
||||||
gnReturnCode vulkanSubmitQueue(gnOutputDevice device, gnQueue queue, gnSubmitInfo info) {
|
gnReturnCode vulkanSubmitQueue(gnOutputDevice device, gnQueue queue, gnSubmitInfo info) {
|
||||||
VkCommandBuffer* commandBuffers = malloc(sizeof(VkCommandBuffer) * info.commandBufferCount);
|
VkCommandBuffer* commandBuffers = malloc(sizeof(VkCommandBuffer) * info.commandBufferCount);
|
||||||
for (int i = 0; i < info.commandBufferCount; i++) commandBuffers[i] = info.commandBuffers[i]->commandBuffer->buffer;
|
for (uint32_t i = 0; i < info.commandBufferCount; i++) commandBuffers[i] = info.commandBuffers[i]->commandBuffer->buffer;
|
||||||
|
|
||||||
VkSubmitInfo submitInfo = {
|
VkSubmitInfo submitInfo = {
|
||||||
.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
|
.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
|
||||||
|
@@ -4,9 +4,11 @@
|
|||||||
#include "output_device/vulkan_output_devices.h"
|
#include "output_device/vulkan_output_devices.h"
|
||||||
#include "uniforms/gryphn_uniform.h"
|
#include "uniforms/gryphn_uniform.h"
|
||||||
#include "vulkan_uniform.h"
|
#include "vulkan_uniform.h"
|
||||||
#include "stdio.h"
|
|
||||||
|
|
||||||
VkGryphnUniformPool* GetLastUniformPool(VkGryphnUniformPoolArrayList* list) { return &list->data[list->count - 1]; }
|
VkGryphnUniformPool* GetLastUniformPool(VkGryphnUniformPoolArrayList list) {
|
||||||
|
uint32_t count = VkGryphnUniformPoolArrayListCount(list);
|
||||||
|
return VkGryphnUniformPoolArrayListRefAt(list, count);
|
||||||
|
}
|
||||||
|
|
||||||
gnReturnCode createUniformPool(gnUniformPool pool, gnDeviceHandle device) {
|
gnReturnCode createUniformPool(gnUniformPool pool, gnDeviceHandle device) {
|
||||||
pool->uniformPool = malloc(sizeof(struct gnPlatformUniformPool_t));
|
pool->uniformPool = malloc(sizeof(struct gnPlatformUniformPool_t));
|
||||||
@@ -18,10 +20,10 @@ gnReturnCode createUniformPool(gnUniformPool pool, gnDeviceHandle device) {
|
|||||||
.pool = VK_NULL_HANDLE,
|
.pool = VK_NULL_HANDLE,
|
||||||
.layouts = VkDescriptorSetLayoutArrayListCreate()
|
.layouts = VkDescriptorSetLayoutArrayListCreate()
|
||||||
};
|
};
|
||||||
VkGryphnUniformPoolArrayListAdd(&pool->uniformPool->pools, firstPool);
|
VkGryphnUniformPoolArrayListAdd(pool->uniformPool->pools, firstPool);
|
||||||
} // scopped because the add function copies and I don't want it lying around
|
} // scopped because the add function copies and I don't want it lying around
|
||||||
|
|
||||||
VkGryphnUniformPool* currentPool = GetLastUniformPool(&pool->uniformPool->pools);
|
VkGryphnUniformPool* currentPool = GetLastUniformPool(pool->uniformPool->pools);
|
||||||
VkDescriptorPoolCreateInfo poolInfo = {
|
VkDescriptorPoolCreateInfo poolInfo = {
|
||||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
|
||||||
.flags = VK_DESCRIPTOR_POOL_CREATE_ALLOW_OVERALLOCATION_SETS_BIT_NV,
|
.flags = VK_DESCRIPTOR_POOL_CREATE_ALLOW_OVERALLOCATION_SETS_BIT_NV,
|
||||||
@@ -50,13 +52,13 @@ gnUniform* allocateUniforms(gnUniformPool pool, gnUniformAllocationInfo allocInf
|
|||||||
};
|
};
|
||||||
|
|
||||||
// TODO: redo this, its not warning me IDK why cuz its totally wrong
|
// TODO: redo this, its not warning me IDK why cuz its totally wrong
|
||||||
VkDescriptorPoolSize poolSizes[GN_UNIFORM_TYPE_MAX] = { };
|
VkDescriptorPoolSize poolSizes[GN_UNIFORM_TYPE_MAX];
|
||||||
for (int i = 0; i < allocInfo.setCount; i++)
|
for (uint32_t i = 0; i < allocInfo.setCount; i++)
|
||||||
for (int c = 0; c < allocInfo.sets[i].uniformBindingCount; c++)
|
for (uint32_t c = 0; c < allocInfo.sets[i].uniformBindingCount; c++)
|
||||||
poolSizes[allocInfo.sets[i].uniformBindings[c].type].descriptorCount++;
|
poolSizes[allocInfo.sets[i].uniformBindings[c].type].descriptorCount++;
|
||||||
|
|
||||||
uint32_t count = 0;
|
uint32_t count = 0;
|
||||||
VkDescriptorPoolSize realPoolSizes[GN_UNIFORM_TYPE_MAX] = {};
|
VkDescriptorPoolSize realPoolSizes[GN_UNIFORM_TYPE_MAX];
|
||||||
|
|
||||||
for (int i = 0; i < GN_UNIFORM_TYPE_MAX; i++) {
|
for (int i = 0; i < GN_UNIFORM_TYPE_MAX; i++) {
|
||||||
poolSizes[i].type = vkGryphnUniformType(i);
|
poolSizes[i].type = vkGryphnUniformType(i);
|
||||||
@@ -79,17 +81,17 @@ gnUniform* allocateUniforms(gnUniformPool pool, gnUniformAllocationInfo allocInf
|
|||||||
) != VK_SUCCESS)
|
) != VK_SUCCESS)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
VkGryphnUniformPoolArrayListAdd(&pool->uniformPool->pools, newPool);
|
VkGryphnUniformPoolArrayListAdd(pool->uniformPool->pools, newPool);
|
||||||
} // scopped for same reasons as before
|
} // scopped for same reasons as before
|
||||||
|
|
||||||
VkGryphnUniformPool* currentPool = GetLastUniformPool(&pool->uniformPool->pools);
|
VkGryphnUniformPool* currentPool = GetLastUniformPool(pool->uniformPool->pools);
|
||||||
|
|
||||||
uint32_t startingCount = currentPool->layouts.count;
|
uint32_t startingCount = VkDescriptorSetLayoutArrayListCount(currentPool->layouts);
|
||||||
VkDescriptorSetLayoutArrayListExpand(¤tPool->layouts, allocInfo.setCount);
|
VkDescriptorSetLayoutArrayListExpand(currentPool->layouts, allocInfo.setCount);
|
||||||
|
|
||||||
for (int i = 0; i < allocInfo.setCount; i++) {
|
for (uint32_t i = 0; i < allocInfo.setCount; i++) {
|
||||||
VkDescriptorSetLayoutArrayListAdd(
|
VkDescriptorSetLayoutArrayListAdd(
|
||||||
¤tPool->layouts,
|
currentPool->layouts,
|
||||||
vkGryphnCreateSetLayouts(&allocInfo.sets[i], pool->device->outputDevice->device)
|
vkGryphnCreateSetLayouts(&allocInfo.sets[i], pool->device->outputDevice->device)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -98,7 +100,7 @@ gnUniform* allocateUniforms(gnUniformPool pool, gnUniformAllocationInfo allocInf
|
|||||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
|
||||||
.descriptorPool = currentPool->pool,
|
.descriptorPool = currentPool->pool,
|
||||||
.descriptorSetCount = allocInfo.setCount,
|
.descriptorSetCount = allocInfo.setCount,
|
||||||
.pSetLayouts = ¤tPool->layouts.data[startingCount]
|
.pSetLayouts = VkDescriptorSetLayoutArrayListRefAt(currentPool->layouts, startingCount)
|
||||||
};
|
};
|
||||||
|
|
||||||
VkDescriptorSet* sets = malloc(sizeof(VkDescriptorSet) * allocInfo.setCount);
|
VkDescriptorSet* sets = malloc(sizeof(VkDescriptorSet) * allocInfo.setCount);
|
||||||
@@ -106,7 +108,7 @@ gnUniform* allocateUniforms(gnUniformPool pool, gnUniformAllocationInfo allocInf
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
gnUniform* uniforms = malloc(sizeof(gnUniform) * allocInfo.setCount);
|
gnUniform* uniforms = malloc(sizeof(gnUniform) * allocInfo.setCount);
|
||||||
for (int i = 0; i < allocInfo.setCount; i++) {
|
for (uint32_t i = 0; i < allocInfo.setCount; i++) {
|
||||||
uniforms[i] = malloc(sizeof(struct gnUniform_t));
|
uniforms[i] = malloc(sizeof(struct gnUniform_t));
|
||||||
uniforms[i]->uniform = malloc(sizeof(struct gnPlatformUniform_t));
|
uniforms[i]->uniform = malloc(sizeof(struct gnPlatformUniform_t));
|
||||||
uniforms[i]->uniform->set = sets[i];
|
uniforms[i]->uniform->set = sets[i];
|
||||||
@@ -115,9 +117,15 @@ gnUniform* allocateUniforms(gnUniformPool pool, gnUniformAllocationInfo allocInf
|
|||||||
}
|
}
|
||||||
|
|
||||||
void destroyUniformPool(gnUniformPool pool) {
|
void destroyUniformPool(gnUniformPool pool) {
|
||||||
for (int k = 0; k < pool->uniformPool->pools.count; k++) {
|
for (uint32_t k = 0; k < VkGryphnUniformPoolArrayListCount(pool->uniformPool->pools); k++) {
|
||||||
vkDestroyDescriptorPool(pool->device->outputDevice->device, pool->uniformPool->pools.data[k].pool, NULL);
|
VkGryphnUniformPool* ref = VkGryphnUniformPoolArrayListRefAt(pool->uniformPool->pools, k);
|
||||||
for (int i = 0; i < pool->uniformPool->pools.data[k].layouts.count; i++)
|
vkDestroyDescriptorPool(pool->device->outputDevice->device, ref->pool, NULL);
|
||||||
vkDestroyDescriptorSetLayout(pool->device->outputDevice->device, pool->uniformPool->pools.data[k].layouts.data[i], NULL);
|
for (uint32_t i = 0; i < VkDescriptorSetLayoutArrayListCount(ref->layouts); i++)
|
||||||
|
vkDestroyDescriptorSetLayout(pool->device->outputDevice->device, VkDescriptorSetLayoutArrayListAt(ref->layouts, i), NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GN_ARRAY_LIST_DEFINITION(VkDescriptorSetLayout)
|
||||||
|
GN_ARRAY_LIST_DEFINITION(VkGryphnUniformPool)
|
||||||
|
@@ -2,13 +2,13 @@
|
|||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <uniforms/gryphn_uniform_pool.h>
|
#include <uniforms/gryphn_uniform_pool.h>
|
||||||
|
|
||||||
GN_ARRAY_LIST(VkDescriptorSetLayout);
|
|
||||||
|
|
||||||
|
GN_ARRAY_LIST_HEADER(VkDescriptorSetLayout);
|
||||||
typedef struct VkGryphnUniformPool {
|
typedef struct VkGryphnUniformPool {
|
||||||
VkDescriptorPool pool;
|
VkDescriptorPool pool;
|
||||||
VkDescriptorSetLayoutArrayList layouts;
|
VkDescriptorSetLayoutArrayList layouts;
|
||||||
} VkGryphnUniformPool;
|
} VkGryphnUniformPool;
|
||||||
GN_ARRAY_LIST(VkGryphnUniformPool);
|
GN_ARRAY_LIST_HEADER(VkGryphnUniformPool);
|
||||||
|
|
||||||
struct gnPlatformUniformPool_t {
|
struct gnPlatformUniformPool_t {
|
||||||
VkGryphnUniformPoolArrayList pools;
|
VkGryphnUniformPoolArrayList pools;
|
||||||
|
@@ -71,7 +71,7 @@ gnSurfaceFormat* vkGetSurfaceFormats(
|
|||||||
|
|
||||||
if (*formatCount > 0) {
|
if (*formatCount > 0) {
|
||||||
vkGetPhysicalDeviceSurfaceFormatsKHR(device->physicalDevice->device, windowSurface->windowSurface->surface, formatCount, vkFormats);
|
vkGetPhysicalDeviceSurfaceFormatsKHR(device->physicalDevice->device, windowSurface->windowSurface->surface, formatCount, vkFormats);
|
||||||
for (int i = 0; i < *formatCount; i++) {
|
for (uint32_t i = 0; i < *formatCount; i++) {
|
||||||
switch (vkFormats[i].format) {
|
switch (vkFormats[i].format) {
|
||||||
case VK_FORMAT_B8G8R8A8_SRGB: { formats[i].format = GN_FORMAT_BGRA8_SRGB; break; }
|
case VK_FORMAT_B8G8R8A8_SRGB: { formats[i].format = GN_FORMAT_BGRA8_SRGB; break; }
|
||||||
case VK_FORMAT_B8G8R8A8_UNORM: { formats[i].format = GN_FORMAT_BGRA8; break; }
|
case VK_FORMAT_B8G8R8A8_UNORM: { formats[i].format = GN_FORMAT_BGRA8; break; }
|
||||||
@@ -100,9 +100,9 @@ gnSurfaceDetails getSurfaceDetails(
|
|||||||
surfaceDetails.minImageCount = details.minImageCount;
|
surfaceDetails.minImageCount = details.minImageCount;
|
||||||
surfaceDetails.maxImageCount = details.maxImageCount;
|
surfaceDetails.maxImageCount = details.maxImageCount;
|
||||||
|
|
||||||
surfaceDetails.minImageSize = (gnUInt2){ details.minImageExtent.width, details.minImageExtent.height };
|
surfaceDetails.minImageSize = (gnUInt2){ .x = details.minImageExtent.width, .y = details.minImageExtent.height };
|
||||||
surfaceDetails.maxImageSize = (gnUInt2){ details.maxImageExtent.width, details.maxImageExtent.height };
|
surfaceDetails.maxImageSize = (gnUInt2){ .x = details.maxImageExtent.width, .y = details.maxImageExtent.height };
|
||||||
surfaceDetails.currentSize = (gnUInt2){ details.currentExtent.width, details.currentExtent.height };
|
surfaceDetails.currentSize = (gnUInt2){ .x = details.currentExtent.width, .y = details.currentExtent.height };
|
||||||
|
|
||||||
return surfaceDetails;
|
return surfaceDetails;
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
typedef enum gnRenderPassStage {
|
typedef enum gnRenderPassStage {
|
||||||
GN_COLOR_ATTACHMENT_OUTPUT = 1,
|
GN_COLOR_ATTACHMENT_OUTPUT = 1,
|
||||||
GN_EARLY_FRAGMENT_TEST = 2
|
GN_EARLY_FRAGMENT_TEST = 2
|
||||||
} gnRenderPassStage; // I stole these from vulkan to make that conversion easier
|
} gnRenderPassStage;
|
||||||
|
|
||||||
typedef enum gnRenderPassAccess {
|
typedef enum gnRenderPassAccess {
|
||||||
GN_COLOR_ATTACHMENT_WRITE = 1,
|
GN_COLOR_ATTACHMENT_WRITE = 1,
|
||||||
|
Submodule projects/utils updated: 203928aa81...c426f9ab6d
Reference in New Issue
Block a user