update gryphn to use GN_FALSE + GN_TRUE
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
#include "metal_loader.h"
|
#include "metal_loader.h"
|
||||||
|
|
||||||
gnBool metalIsExtensionSupported(gnExtension extension) {
|
gnBool metalIsExtensionSupported(gnExtension extension) {
|
||||||
if (extension == GN_EXT_SYNCHRONIZATION) return gnTrue;
|
if (extension == GN_EXT_SYNCHRONIZATION) return GN_TRUE;
|
||||||
if (extension == GN_EXT_QUEUES) return gnFalse;
|
if (extension == GN_EXT_QUEUES) return GN_FALSE;
|
||||||
return gnFalse;
|
return GN_FALSE;
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ gnReturnCode allocateMetalCommandBuffers(gnCommandBufferHandle* commandBuffers,
|
|||||||
|
|
||||||
// write a command log at some point
|
// write a command log at some point
|
||||||
if ((pool->info.flags & GN_REUSE_COMMAND_BUFFERS) == GN_REUSE_COMMAND_BUFFERS)
|
if ((pool->info.flags & GN_REUSE_COMMAND_BUFFERS) == GN_REUSE_COMMAND_BUFFERS)
|
||||||
commandBuffers[i]->commandBuffer->isIndirectCommandBuffer = gnTrue;
|
commandBuffers[i]->commandBuffer->isIndirectCommandBuffer = GN_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
|
@@ -117,7 +117,7 @@ void metalBindUniform(gnCommandBufferHandle buffer, gnUniform uniform, uint32_t
|
|||||||
if (uniform->uniform->isDynamic[c]) {
|
if (uniform->uniform->isDynamic[c]) {
|
||||||
gnBufferUniformInfo updateInfo = {
|
gnBufferUniformInfo updateInfo = {
|
||||||
.binding = c,
|
.binding = c,
|
||||||
.dynamic = gnTrue,
|
.dynamic = GN_TRUE,
|
||||||
.offset = dynamicOffsets[i],
|
.offset = dynamicOffsets[i],
|
||||||
.size = 0
|
.size = 0
|
||||||
};
|
};
|
||||||
|
@@ -23,14 +23,6 @@ gnPhysicalDevice* getMetalDevices(gnInstanceHandle instance, uint32_t* deviceCou
|
|||||||
else if (deviceLocation == MTLDeviceLocationExternal)
|
else if (deviceLocation == MTLDeviceLocationExternal)
|
||||||
devicesList[i]->properties.deviceType = GN_EXTERNAL_DEVICE;
|
devicesList[i]->properties.deviceType = GN_EXTERNAL_DEVICE;
|
||||||
|
|
||||||
// below I am going to fake that there is one queue that can support graphics, compute, and transfer queues
|
|
||||||
// devicesList[i]->queueProperties.queueCount = 1;
|
|
||||||
// devicesList[i]->queueProperties.queueProperties = malloc(sizeof(gnQueueProperties));
|
|
||||||
// devicesList[i]->queueProperties.queueProperties[0] = (gnQueueProperties){
|
|
||||||
// .queueCount = 1,
|
|
||||||
// .queueType = GN_QUEUE_GRAPHICS | GN_QUEUE_COMPUTE | GN_QUEUE_TRANSFER
|
|
||||||
// };
|
|
||||||
|
|
||||||
devicesList[i]->features.maxColorSamples = GN_SAMPLE_BIT_1;
|
devicesList[i]->features.maxColorSamples = GN_SAMPLE_BIT_1;
|
||||||
if ([device supportsTextureSampleCount:2]) { devicesList[i]->features.maxColorSamples |= GN_SAMPLE_BIT_2; } else {}
|
if ([device supportsTextureSampleCount:2]) { devicesList[i]->features.maxColorSamples |= GN_SAMPLE_BIT_2; } else {}
|
||||||
if ([device supportsTextureSampleCount:4]) { devicesList[i]->features.maxColorSamples |= GN_SAMPLE_BIT_4; } else {}
|
if ([device supportsTextureSampleCount:4]) { devicesList[i]->features.maxColorSamples |= GN_SAMPLE_BIT_4; } else {}
|
||||||
@@ -47,5 +39,5 @@ gnPhysicalDevice* getMetalDevices(gnInstanceHandle instance, uint32_t* deviceCou
|
|||||||
}
|
}
|
||||||
|
|
||||||
gnBool metalCanDevicePresent(gnPhysicalDevice device, gnWindowSurface windowSurface) {
|
gnBool metalCanDevicePresent(gnPhysicalDevice device, gnWindowSurface windowSurface) {
|
||||||
return gnTrue; // I belive that a window should always be able to present to a surface in metal
|
return GN_TRUE; // I belive that a window should always be able to present to a surface in metal
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ gnReturnCode createMetalFramebuffer(gnFramebuffer framebuffer, gnOutputDevice de
|
|||||||
framebuffer->framebuffer->clearCopyCount = info.attachmentCount;
|
framebuffer->framebuffer->clearCopyCount = info.attachmentCount;
|
||||||
framebuffer->framebuffer->clearCopies = malloc(sizeof(mtlClearCopy) * info.attachmentCount);
|
framebuffer->framebuffer->clearCopies = malloc(sizeof(mtlClearCopy) * info.attachmentCount);
|
||||||
for (int i = 0; i < info.attachmentCount; i++) {
|
for (int i = 0; i < info.attachmentCount; i++) {
|
||||||
framebuffer->framebuffer->clearCopies[i].clear = gnFalse;
|
framebuffer->framebuffer->clearCopies[i].clear = GN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
framebuffer->framebuffer->subpassCount = info.renderPassDescriptor->renderPassDescriptor->subpassCount;
|
framebuffer->framebuffer->subpassCount = info.renderPassDescriptor->renderPassDescriptor->subpassCount;
|
||||||
@@ -27,7 +27,7 @@ gnReturnCode createMetalFramebuffer(gnFramebuffer framebuffer, gnOutputDevice de
|
|||||||
colorPass.texture = info.attachments[info.renderPassDescriptor->renderPassDescriptor->copyInfos[i].colorAttachments[c].attachmentIndex]->texture->texture;
|
colorPass.texture = info.attachments[info.renderPassDescriptor->renderPassDescriptor->copyInfos[i].colorAttachments[c].attachmentIndex]->texture->texture;
|
||||||
if (info.renderPassDescriptor->renderPassDescriptor->copyInfos[i].colorAttachments[c].resolveAttachmentIndex >= 0)
|
if (info.renderPassDescriptor->renderPassDescriptor->copyInfos[i].colorAttachments[c].resolveAttachmentIndex >= 0)
|
||||||
colorPass.resolveTexture = info.attachments[info.renderPassDescriptor->renderPassDescriptor->copyInfos[i].colorAttachments[c].resolveAttachmentIndex]->texture->texture;
|
colorPass.resolveTexture = info.attachments[info.renderPassDescriptor->renderPassDescriptor->copyInfos[i].colorAttachments[c].resolveAttachmentIndex]->texture->texture;
|
||||||
framebuffer->framebuffer->clearCopies[info.renderPassDescriptor->renderPassDescriptor->copyInfos[i].colorAttachments[c].attachmentIndex].clear = gnTrue;
|
framebuffer->framebuffer->clearCopies[info.renderPassDescriptor->renderPassDescriptor->copyInfos[i].colorAttachments[c].attachmentIndex].clear = GN_TRUE;
|
||||||
framebuffer->framebuffer->clearCopies[info.renderPassDescriptor->renderPassDescriptor->copyInfos[i].colorAttachments[c].attachmentIndex].descriptor = colorPass;
|
framebuffer->framebuffer->clearCopies[info.renderPassDescriptor->renderPassDescriptor->copyInfos[i].colorAttachments[c].attachmentIndex].descriptor = colorPass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -53,7 +53,7 @@ gnReturnCode createMetalGraphicsPipeline(gnGraphicsPipeline graphicsPipeline, gn
|
|||||||
MTLRenderPassColorAttachmentDescriptor* colorPass = subpass.colorAttachments[i];
|
MTLRenderPassColorAttachmentDescriptor* colorPass = subpass.colorAttachments[i];
|
||||||
|
|
||||||
descriptor.colorAttachments[i].pixelFormat = copyInfo.colorAttachments[i].format;
|
descriptor.colorAttachments[i].pixelFormat = copyInfo.colorAttachments[i].format;
|
||||||
if (info.colorBlending.enable == gnTrue) {
|
if (info.colorBlending.enable == GN_TRUE) {
|
||||||
[descriptor.colorAttachments objectAtIndexedSubscript:i].blendingEnabled = YES;
|
[descriptor.colorAttachments objectAtIndexedSubscript:i].blendingEnabled = YES;
|
||||||
[descriptor.colorAttachments objectAtIndexedSubscript:i].rgbBlendOperation = mtlGryphnBlendOperation(info.colorBlending.colorBlendOperation);
|
[descriptor.colorAttachments objectAtIndexedSubscript:i].rgbBlendOperation = mtlGryphnBlendOperation(info.colorBlending.colorBlendOperation);
|
||||||
[descriptor.colorAttachments objectAtIndexedSubscript:i].alphaBlendOperation = mtlGryphnBlendOperation(info.colorBlending.alphaBlendOperation);
|
[descriptor.colorAttachments objectAtIndexedSubscript:i].alphaBlendOperation = mtlGryphnBlendOperation(info.colorBlending.alphaBlendOperation);
|
||||||
|
@@ -22,7 +22,7 @@ gnReturnCode metalSyncSubmit(gnOutputDevice device, gnSubmitSyncInfo info) {
|
|||||||
NSLog(@"Command buffer error: %s", buffer.error.localizedDescription.UTF8String);
|
NSLog(@"Command buffer error: %s", buffer.error.localizedDescription.UTF8String);
|
||||||
}
|
}
|
||||||
if (atomic_fetch_sub_explicit(&buffersLeft, 1, memory_order_acq_rel) == 1) {
|
if (atomic_fetch_sub_explicit(&buffersLeft, 1, memory_order_acq_rel) == 1) {
|
||||||
fenceToSignal->signaled = gnTrue;
|
fenceToSignal->signaled = GN_TRUE;
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
@@ -15,7 +15,7 @@ void singalMetalFence(gnFence fence) {
|
|||||||
}
|
}
|
||||||
void waitForMetalFence(gnFence fence, uint64_t timeout) {
|
void waitForMetalFence(gnFence fence, uint64_t timeout) {
|
||||||
// dispatch_semaphore_wait(fence->fence->semaphore, timeout);
|
// dispatch_semaphore_wait(fence->fence->semaphore, timeout);
|
||||||
while (fence->signaled == gnFalse) {}
|
while (fence->signaled == GN_FALSE) {}
|
||||||
}
|
}
|
||||||
void resetMetalFence(gnFence fence) {
|
void resetMetalFence(gnFence fence) {
|
||||||
// dispatch_semaphore_signal(fence->fence->semaphore);
|
// dispatch_semaphore_signal(fence->fence->semaphore);
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
#include "vulkan_loader.h"
|
#include "vulkan_loader.h"
|
||||||
|
|
||||||
gnBool vulkanIsExtensionSupported(gnExtension extension){
|
gnBool vulkanIsExtensionSupported(gnExtension extension){
|
||||||
if (extension == GN_EXT_SYNCHRONIZATION) return gnTrue;
|
if (extension == GN_EXT_SYNCHRONIZATION) return GN_TRUE;
|
||||||
if (extension == GN_EXT_QUEUES) return gnTrue;
|
if (extension == GN_EXT_QUEUES) return GN_TRUE;
|
||||||
return gnFalse;
|
return GN_FALSE;
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,7 @@ uint32_t VkMemoryIndex(VkPhysicalDevice device, uint32_t memoryType, VkMemoryPro
|
|||||||
vkGetPhysicalDeviceMemoryProperties(device, &memoryProperties);
|
vkGetPhysicalDeviceMemoryProperties(device, &memoryProperties);
|
||||||
for (uint32_t i = 0; i < memoryProperties.memoryTypeCount; i++) {
|
for (uint32_t i = 0; i < memoryProperties.memoryTypeCount; i++) {
|
||||||
if ((memoryType & (1 << i)) && (memoryProperties.memoryTypes[i].propertyFlags & flags) == flags) {
|
if ((memoryType & (1 << i)) && (memoryProperties.memoryTypes[i].propertyFlags & flags) == flags) {
|
||||||
*foundMemory = gnTrue;
|
*foundMemory = GN_TRUE;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
} // this whole thing was adapted from vulkan-tutorial.com
|
} // this whole thing was adapted from vulkan-tutorial.com
|
||||||
@@ -43,7 +43,7 @@ gnReturnCode VkCreateBuffer(
|
|||||||
VkMemoryRequirements bufferRequirements;
|
VkMemoryRequirements bufferRequirements;
|
||||||
vkGetBufferMemoryRequirements(device->outputDevice->device, buffer->buffer, &bufferRequirements);
|
vkGetBufferMemoryRequirements(device->outputDevice->device, buffer->buffer, &bufferRequirements);
|
||||||
|
|
||||||
gnBool foundMemory = gnFalse;
|
gnBool foundMemory = GN_FALSE;
|
||||||
VkMemoryAllocateInfo memoryAllocateInfo = {
|
VkMemoryAllocateInfo memoryAllocateInfo = {
|
||||||
.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
|
||||||
.allocationSize = bufferRequirements.size,
|
.allocationSize = bufferRequirements.size,
|
||||||
|
@@ -56,7 +56,7 @@ void bindBuffer(gnCommandBufferHandle buffer, gnBufferHandle bufferToBind, gnBuf
|
|||||||
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) {
|
||||||
buffer->commandBuffer->changedBuffer = gnTrue;
|
buffer->commandBuffer->changedBuffer = GN_TRUE;
|
||||||
buffer->commandBuffer->boundIndexBuffer = bufferToBind;
|
buffer->commandBuffer->boundIndexBuffer = bufferToBind;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,7 @@ void draw(gnCommandBuffer buffer, int vertexCount, int firstVertex, int instance
|
|||||||
void drawIndexed(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 = GN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bindUniform(gnCommandBufferHandle buffer, gnUniform uniform, uint32_t set, uint32_t dynamicOffsetCount, uint32_t* dynamicOffsets) {
|
void bindUniform(gnCommandBufferHandle buffer, gnUniform uniform, uint32_t set, uint32_t dynamicOffsetCount, uint32_t* dynamicOffsets) {
|
||||||
|
@@ -36,7 +36,7 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL vk_debuggerDebugCallback(
|
|||||||
vkUserData* userData = (vkUserData*)pUserData;
|
vkUserData* userData = (vkUserData*)pUserData;
|
||||||
gnDebuggerCallback callback = userData->debuggerCallback;
|
gnDebuggerCallback callback = userData->debuggerCallback;
|
||||||
gnBool result = callback(severity, type, data, userData->userData);
|
gnBool result = callback(severity, type, data, userData->userData);
|
||||||
if (result == gnFalse) return VK_FALSE;
|
if (result == GN_FALSE) return VK_FALSE;
|
||||||
return VK_TRUE;
|
return VK_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,12 +110,12 @@ gnReturnCode createInstance(gnInstanceHandle instance, gnInstanceInfo instanceIn
|
|||||||
VkResult result = vkCreateInstance(&createInfo, NULL, &instance->instance->vk_instance);
|
VkResult result = vkCreateInstance(&createInfo, NULL, &instance->instance->vk_instance);
|
||||||
if (result != VK_SUCCESS)
|
if (result != VK_SUCCESS)
|
||||||
return GN_FAILED_CREATE_INSTANCE;
|
return GN_FAILED_CREATE_INSTANCE;
|
||||||
instance->valid = gnTrue;
|
instance->valid = GN_TRUE;
|
||||||
|
|
||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroyInstance(gnInstanceHandle instance) {
|
void destroyInstance(gnInstanceHandle instance) {
|
||||||
instance->valid = gnFalse;
|
instance->valid = GN_FALSE;
|
||||||
vkDestroyInstance(instance->instance->vk_instance, NULL);
|
vkDestroyInstance(instance->instance->vk_instance, NULL);
|
||||||
}
|
}
|
||||||
|
@@ -20,10 +20,10 @@ const char* *vkGetGryphnDeviceExtensions(uint32_t* outCount, VkPhysicalDevice de
|
|||||||
VkExtensionProperties* vkExtensions = malloc(sizeof(VkExtensionProperties) * extensionCount);
|
VkExtensionProperties* vkExtensions = malloc(sizeof(VkExtensionProperties) * extensionCount);
|
||||||
vkEnumerateDeviceExtensionProperties(device, NULL, &extensionCount, vkExtensions);
|
vkEnumerateDeviceExtensionProperties(device, NULL, &extensionCount, vkExtensions);
|
||||||
|
|
||||||
gnBool supportsDescriptorPoolOverallocation = gnFalse;
|
gnBool supportsDescriptorPoolOverallocation = GN_FALSE;
|
||||||
for (uint32_t i = 0; i < extensionCount; i++) {
|
for (uint32_t i = 0; i < extensionCount; i++) {
|
||||||
if (strcmp(VK_NV_DESCRIPTOR_POOL_OVERALLOCATION_EXTENSION_NAME, vkExtensions[i].extensionName) == 0) {
|
if (strcmp(VK_NV_DESCRIPTOR_POOL_OVERALLOCATION_EXTENSION_NAME, vkExtensions[i].extensionName) == 0) {
|
||||||
supportsDescriptorPoolOverallocation = gnTrue;
|
supportsDescriptorPoolOverallocation = GN_TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -46,9 +46,9 @@ gnReturnCode createOutputDevice(gnOutputDeviceHandle outputDevice, gnInstanceHan
|
|||||||
};
|
};
|
||||||
deviceCreateInfo.ppEnabledExtensionNames = vkGetGryphnDeviceExtensions(&deviceCreateInfo.enabledExtensionCount, deviceInfo.physicalDevice->physicalDevice->device);
|
deviceCreateInfo.ppEnabledExtensionNames = vkGetGryphnDeviceExtensions(&deviceCreateInfo.enabledExtensionCount, deviceInfo.physicalDevice->physicalDevice->device);
|
||||||
|
|
||||||
outputDevice->outputDevice->enabledOversizedDescriptorPools = gnFalse;
|
outputDevice->outputDevice->enabledOversizedDescriptorPools = GN_FALSE;
|
||||||
for (int i = 0; i < deviceCreateInfo.enabledExtensionCount; i++)
|
for (int i = 0; i < deviceCreateInfo.enabledExtensionCount; i++)
|
||||||
if (strcmp(deviceCreateInfo.ppEnabledExtensionNames[i], VK_NV_DESCRIPTOR_POOL_OVERALLOCATION_EXTENSION_NAME) == 0) outputDevice->outputDevice->enabledOversizedDescriptorPools = gnTrue;
|
if (strcmp(deviceCreateInfo.ppEnabledExtensionNames[i], VK_NV_DESCRIPTOR_POOL_OVERALLOCATION_EXTENSION_NAME) == 0) outputDevice->outputDevice->enabledOversizedDescriptorPools = GN_TRUE;
|
||||||
|
|
||||||
if (instance->hasDebugger)
|
if (instance->hasDebugger)
|
||||||
deviceCreateInfo.enabledLayerCount = 0;
|
deviceCreateInfo.enabledLayerCount = 0;
|
||||||
|
@@ -38,24 +38,24 @@ 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 = gnFalse, foundTransferQueueFamily = gnFalse;
|
gnBool foundGraphicsQueueFamily = GN_FALSE, foundTransferQueueFamily = GN_FALSE;
|
||||||
for (int c = 0; c < queueFamilyCount; c++) {
|
for (int c = 0; c < queueFamilyCount; c++) {
|
||||||
gnBool hasNeededQueue = gnFalse;
|
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 = true;
|
foundGraphicsQueueFamily = GN_TRUE;
|
||||||
hasNeededQueue = gnTrue;
|
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 = true;
|
foundTransferQueueFamily = GN_TRUE;
|
||||||
hasNeededQueue = gnTrue;
|
hasNeededQueue = GN_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasNeededQueue) {
|
if (hasNeededQueue) {
|
||||||
vulkanNeededQueue neededQueue = {
|
vulkanNeededQueue neededQueue = {
|
||||||
.queueIndex = c,
|
.queueIndex = c,
|
||||||
.createFlags = 0,
|
.createFlags = 0,
|
||||||
.usedForPresent = gnFalse
|
.usedForPresent = GN_FALSE
|
||||||
};
|
};
|
||||||
if ((queueFamilies[c].queueFlags & VK_QUEUE_GRAPHICS_BIT)) neededQueue.createFlags |= VK_QUEUE_GRAPHICS_BIT;
|
if ((queueFamilies[c].queueFlags & VK_QUEUE_GRAPHICS_BIT)) neededQueue.createFlags |= VK_QUEUE_GRAPHICS_BIT;
|
||||||
if ((queueFamilies[c].queueFlags & VK_QUEUE_TRANSFER_BIT)) neededQueue.createFlags |= VK_QUEUE_TRANSFER_BIT;
|
if ((queueFamilies[c].queueFlags & VK_QUEUE_TRANSFER_BIT)) neededQueue.createFlags |= VK_QUEUE_TRANSFER_BIT;
|
||||||
@@ -94,7 +94,7 @@ gnPhysicalDevice* getPhysicalDevices(gnInstanceHandle instance, uint32_t* device
|
|||||||
case VK_PHYSICAL_DEVICE_TYPE_MAX_ENUM: outputDevices[i]->properties.deviceType = GN_INTEGRATED_DEVICE;
|
case VK_PHYSICAL_DEVICE_TYPE_MAX_ENUM: outputDevices[i]->properties.deviceType = GN_INTEGRATED_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (instance->enabledExtensions[GN_EXT_QUEUES] == gnFalse)
|
if (instance->enabledExtensions[GN_EXT_QUEUES] == GN_FALSE)
|
||||||
vulkanLoadNeededQueues(physicalDevices[i], outputDevices[i]);
|
vulkanLoadNeededQueues(physicalDevices[i], outputDevices[i]);
|
||||||
|
|
||||||
|
|
||||||
@@ -111,13 +111,13 @@ gnPhysicalDevice* getPhysicalDevices(gnInstanceHandle instance, uint32_t* device
|
|||||||
}
|
}
|
||||||
|
|
||||||
gnBool deviceCanPresentToSurface(gnPhysicalDevice device, gnWindowSurface surface) {
|
gnBool deviceCanPresentToSurface(gnPhysicalDevice device, gnWindowSurface surface) {
|
||||||
gnBool foundQueue = gnFalse;
|
gnBool foundQueue = GN_FALSE;
|
||||||
for (int i = 0; i < device->physicalDevice->neededQueueCount; i++) {
|
for (int 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) {
|
||||||
device->physicalDevice->neededQueues[i].usedForPresent = gnTrue;
|
device->physicalDevice->neededQueues[i].usedForPresent = GN_TRUE;
|
||||||
foundQueue = gnTrue;
|
foundQueue = GN_TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
surface->windowSurface->presentQueueIndex = i;
|
surface->windowSurface->presentQueueIndex = i;
|
||||||
@@ -134,9 +134,9 @@ gnBool deviceCanPresentToSurface(gnPhysicalDevice device, gnWindowSurface surfac
|
|||||||
device->physicalDevice->neededQueues[device->physicalDevice->neededQueueCount] = (vulkanNeededQueue){
|
device->physicalDevice->neededQueues[device->physicalDevice->neededQueueCount] = (vulkanNeededQueue){
|
||||||
.queueIndex = i,
|
.queueIndex = i,
|
||||||
.createFlags = 0,
|
.createFlags = 0,
|
||||||
.usedForPresent = gnTrue
|
.usedForPresent = GN_TRUE
|
||||||
};
|
};
|
||||||
foundQueue = gnTrue;
|
foundQueue = GN_TRUE;
|
||||||
surface->windowSurface->presentQueueIndex = device->physicalDevice->neededQueueCount;
|
surface->windowSurface->presentQueueIndex = device->physicalDevice->neededQueueCount;
|
||||||
device->physicalDevice->neededQueueCount++;
|
device->physicalDevice->neededQueueCount++;
|
||||||
break;
|
break;
|
||||||
@@ -146,11 +146,3 @@ gnBool deviceCanPresentToSurface(gnPhysicalDevice device, gnWindowSurface surfac
|
|||||||
|
|
||||||
return foundQueue;
|
return foundQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// gnBool queueCanPresentToSurface(gnPhysicalDevice device, uint32_t queueIndex, gnWindowSurfaceHandle windowSurface) {
|
|
||||||
// VkBool32 supportsPresent = VK_FALSE;
|
|
||||||
// vkGetPhysicalDeviceSurfaceSupportKHR(device->physicalDevice->device, queueIndex, windowSurface->windowSurface->surface, &supportsPresent);
|
|
||||||
// if (supportsPresent)
|
|
||||||
// return gnTrue;
|
|
||||||
// return gnFalse;
|
|
||||||
// }
|
|
||||||
|
@@ -91,11 +91,11 @@ VkStencilOp vkGryphnStencilOperation(gnStencilOperation operation) {
|
|||||||
|
|
||||||
gnReturnCode createGraphicsPipeline(gnGraphicsPipeline graphicsPipeline, gnDevice device, gnGraphicsPipelineInfo info) {
|
gnReturnCode createGraphicsPipeline(gnGraphicsPipeline graphicsPipeline, gnDevice device, gnGraphicsPipelineInfo info) {
|
||||||
graphicsPipeline->graphicsPipeline = malloc(sizeof(gnPlatformGraphicsPipeline));
|
graphicsPipeline->graphicsPipeline = malloc(sizeof(gnPlatformGraphicsPipeline));
|
||||||
for (int i = 0; i < GN_DYNAMIC_STATE_MAX; i++) graphicsPipeline->graphicsPipeline->isDynamic[i] = gnFalse;
|
for (int i = 0; i < GN_DYNAMIC_STATE_MAX; i++) graphicsPipeline->graphicsPipeline->isDynamic[i] = GN_FALSE;
|
||||||
|
|
||||||
graphicsPipeline->graphicsPipeline->dynamicStates = malloc(sizeof(VkDynamicState) * info.dynamicState.dynamicStateCount);
|
graphicsPipeline->graphicsPipeline->dynamicStates = malloc(sizeof(VkDynamicState) * info.dynamicState.dynamicStateCount);
|
||||||
for (int i = 0; i < info.dynamicState.dynamicStateCount; i++) {
|
for (int i = 0; i < info.dynamicState.dynamicStateCount; i++) {
|
||||||
graphicsPipeline->graphicsPipeline->isDynamic[info.dynamicState.dynamicStates[i]] = gnTrue;
|
graphicsPipeline->graphicsPipeline->isDynamic[info.dynamicState.dynamicStates[i]] = GN_TRUE;
|
||||||
graphicsPipeline->graphicsPipeline->dynamicStates[i] = vkGryphnDynamicStateToVulkanDynamicState(info.dynamicState.dynamicStates[i]);
|
graphicsPipeline->graphicsPipeline->dynamicStates[i] = vkGryphnDynamicStateToVulkanDynamicState(info.dynamicState.dynamicStates[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,7 +184,7 @@ gnReturnCode createGraphicsPipeline(gnGraphicsPipeline graphicsPipeline, gnDevic
|
|||||||
|
|
||||||
graphicsPipeline->graphicsPipeline->colorBlendAttachment = (VkPipelineColorBlendAttachmentState){
|
graphicsPipeline->graphicsPipeline->colorBlendAttachment = (VkPipelineColorBlendAttachmentState){
|
||||||
.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT,
|
.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT,
|
||||||
.blendEnable = ( info.colorBlending.enable == gnTrue ) ? VK_TRUE : VK_FALSE,
|
.blendEnable = ( info.colorBlending.enable == GN_TRUE ) ? VK_TRUE : VK_FALSE,
|
||||||
.srcColorBlendFactor = vkGryphnBlendFactor(info.colorBlending.sourceColorBlendFactor),
|
.srcColorBlendFactor = vkGryphnBlendFactor(info.colorBlending.sourceColorBlendFactor),
|
||||||
.dstColorBlendFactor = vkGryphnBlendFactor(info.colorBlending.destinationColorBlendFactor),
|
.dstColorBlendFactor = vkGryphnBlendFactor(info.colorBlending.destinationColorBlendFactor),
|
||||||
.colorBlendOp = vkGryphnBlendOperation(info.colorBlending.colorBlendOperation),
|
.colorBlendOp = vkGryphnBlendOperation(info.colorBlending.colorBlendOperation),
|
||||||
|
@@ -178,7 +178,7 @@ gnReturnCode createTexture(gnTexture texture, gnDevice device, const gnTextureIn
|
|||||||
VkMemoryRequirements memRequirements;
|
VkMemoryRequirements memRequirements;
|
||||||
vkGetImageMemoryRequirements(device->outputDevice->device, texture->texture->image.image, &memRequirements);
|
vkGetImageMemoryRequirements(device->outputDevice->device, texture->texture->image.image, &memRequirements);
|
||||||
|
|
||||||
gnBool foundMemory = gnFalse;
|
gnBool foundMemory = GN_FALSE;
|
||||||
VkMemoryAllocateInfo allocInfo = {
|
VkMemoryAllocateInfo allocInfo = {
|
||||||
.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
|
||||||
.allocationSize = memRequirements.size,
|
.allocationSize = memRequirements.size,
|
||||||
@@ -191,7 +191,7 @@ gnReturnCode createTexture(gnTexture texture, gnDevice device, const gnTextureIn
|
|||||||
|
|
||||||
vkBindImageMemory(device->outputDevice->device, texture->texture->image.image, texture->texture->image.memory, 0);
|
vkBindImageMemory(device->outputDevice->device, texture->texture->image.image, texture->texture->image.memory, 0);
|
||||||
|
|
||||||
texture->texture->beenWrittenToo = gnFalse;
|
texture->texture->beenWrittenToo = GN_FALSE;
|
||||||
|
|
||||||
VkImageViewCreateInfo viewInfo = {
|
VkImageViewCreateInfo viewInfo = {
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
|
||||||
@@ -255,7 +255,7 @@ void textureData(gnTextureHandle texture, void* pixelData) {
|
|||||||
VkCopyBufferToImage(texture->texture->buffer, texture->texture->image, texture->info.extent, texture->device);
|
VkCopyBufferToImage(texture->texture->buffer, texture->texture->image, texture->info.extent, texture->device);
|
||||||
VkTransitionImageLayout(texture->device, texture->texture->image.image, texture->info.format, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
VkTransitionImageLayout(texture->device, texture->texture->image.image, texture->info.format, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
||||||
|
|
||||||
texture->texture->beenWrittenToo = gnTrue;
|
texture->texture->beenWrittenToo = GN_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gnDestroyVulkanImage(VkGryphnImage* image, VkDevice device) {
|
void gnDestroyVulkanImage(VkGryphnImage* image, VkDevice device) {
|
||||||
|
@@ -12,7 +12,7 @@ gnReturnCode createUniformPool(gnUniformPool pool, gnDeviceHandle device) {
|
|||||||
pool->uniformPool = malloc(sizeof(struct gnPlatformUniformPool_t));
|
pool->uniformPool = malloc(sizeof(struct gnPlatformUniformPool_t));
|
||||||
pool->uniformPool->pools = VkGryphnUniformPoolArrayListCreate();
|
pool->uniformPool->pools = VkGryphnUniformPoolArrayListCreate();
|
||||||
|
|
||||||
if (device->outputDevice->enabledOversizedDescriptorPools == gnTrue) {
|
if (device->outputDevice->enabledOversizedDescriptorPools == GN_TRUE) {
|
||||||
{
|
{
|
||||||
VkGryphnUniformPool firstPool = {
|
VkGryphnUniformPool firstPool = {
|
||||||
.pool = VK_NULL_HANDLE,
|
.pool = VK_NULL_HANDLE,
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceInfo info) {
|
gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceInfo info) {
|
||||||
*instance = malloc(sizeof(struct gnInstance_t));
|
*instance = malloc(sizeof(struct gnInstance_t));
|
||||||
(*instance)->hasDebugger = gnFalse;
|
(*instance)->hasDebugger = GN_FALSE;
|
||||||
|
|
||||||
(*instance)->layers = loaderLayerArrayListCreate();
|
(*instance)->layers = loaderLayerArrayListCreate();
|
||||||
loaderLayerArrayListAdd(&(*instance)->layers, loadLayer((loaderInfo){
|
loaderLayerArrayListAdd(&(*instance)->layers, loadLayer((loaderInfo){
|
||||||
@@ -14,18 +14,18 @@ gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceInfo info) {
|
|||||||
.layerToLoad = api_layer
|
.layerToLoad = api_layer
|
||||||
}));
|
}));
|
||||||
|
|
||||||
for (int c = 0; c < GN_EXT_MAX; c++) (*instance)->enabledExtensions[c] = gnFalse;
|
for (int c = 0; c < GN_EXT_MAX; c++) (*instance)->enabledExtensions[c] = GN_FALSE;
|
||||||
for (int i = 0; i < info.extensionCount; i++) (*instance)->enabledExtensions[info.extensions[i]] = gnTrue;
|
for (int i = 0; i < info.extensionCount; i++) (*instance)->enabledExtensions[info.extensions[i]] = GN_TRUE;
|
||||||
|
|
||||||
if ((*instance)->enabledExtensions[GN_EXT_SYNCHRONIZATION]) (*instance)->layers.data[0].syncFunctions = loadAPISyncFunctions(info.renderingAPI);
|
if ((*instance)->enabledExtensions[GN_EXT_SYNCHRONIZATION]) (*instance)->layers.data[0].syncFunctions = loadAPISyncFunctions(info.renderingAPI);
|
||||||
|
|
||||||
gnBool loaderFunctionChecker = gnFalse;
|
gnBool loaderFunctionChecker = GN_FALSE;
|
||||||
if (info.debugger != NULL) {
|
if (info.debugger != NULL) {
|
||||||
for (int i = 0; i < info.debugger->layerCount; i++) {
|
for (int i = 0; i < info.debugger->layerCount; i++) {
|
||||||
if (info.debugger->layers[i] == GN_DEBUGGER_LAYER_FUNCTIONS) loaderFunctionChecker = gnTrue;
|
if (info.debugger->layers[i] == GN_DEBUGGER_LAYER_FUNCTIONS) loaderFunctionChecker = GN_TRUE;
|
||||||
}
|
}
|
||||||
(*instance)->debugger = *info.debugger;
|
(*instance)->debugger = *info.debugger;
|
||||||
(*instance)->hasDebugger = gnTrue;
|
(*instance)->hasDebugger = GN_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loaderFunctionChecker) {
|
if (loaderFunctionChecker) {
|
||||||
|
@@ -23,10 +23,10 @@ gnBool gnIsSurfaceFormatSupported(
|
|||||||
gnSurfaceFormat* formats = gnGetSupportedSurfaceFormats(windowSurface, device, &formatCount);
|
gnSurfaceFormat* formats = gnGetSupportedSurfaceFormats(windowSurface, device, &formatCount);
|
||||||
for (int i = 0; i < formatCount; i++) {
|
for (int i = 0; i < formatCount; i++) {
|
||||||
if (formats[i].format == format.format && formats[i].colorSpace == format.colorSpace) {
|
if (formats[i].format == format.format && formats[i].colorSpace == format.colorSpace) {
|
||||||
return gnTrue;
|
return GN_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return gnFalse;
|
return GN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gnSurfaceFormat gnGetPreferredSurfaceFormat(
|
gnSurfaceFormat gnGetPreferredSurfaceFormat(
|
||||||
|
@@ -7,18 +7,18 @@
|
|||||||
gnReturnCode gnCreateFence(gnFenceHandle* fence, gnDevice device) {
|
gnReturnCode gnCreateFence(gnFenceHandle* fence, gnDevice device) {
|
||||||
*fence = malloc(sizeof(struct gnFence_t));
|
*fence = malloc(sizeof(struct gnFence_t));
|
||||||
(*fence)->device = device;
|
(*fence)->device = device;
|
||||||
(*fence)->signaled = gnFalse;
|
(*fence)->signaled = GN_FALSE;
|
||||||
return device->instance->callingLayer->syncFunctions._gnCreateFence(*fence, device);
|
return device->instance->callingLayer->syncFunctions._gnCreateFence(*fence, device);
|
||||||
}
|
}
|
||||||
void gnSignalFence(gnFenceHandle fence) {
|
void gnSignalFence(gnFenceHandle fence) {
|
||||||
fence->signaled = gnTrue;
|
fence->signaled = GN_TRUE;
|
||||||
}
|
}
|
||||||
void gnWaitForFence(gnFenceHandle fence, uint64_t timeout) {
|
void gnWaitForFence(gnFenceHandle fence, uint64_t timeout) {
|
||||||
if (fence->signaled == gnTrue) return;
|
if (fence->signaled == GN_TRUE) return;
|
||||||
fence->device->instance->callingLayer->syncFunctions._gnWaitForFence(fence, timeout);
|
fence->device->instance->callingLayer->syncFunctions._gnWaitForFence(fence, timeout);
|
||||||
}
|
}
|
||||||
void gnResetFence(gnFenceHandle fence) {
|
void gnResetFence(gnFenceHandle fence) {
|
||||||
fence->signaled = gnFalse;
|
fence->signaled = GN_FALSE;
|
||||||
fence->device->instance->callingLayer->syncFunctions._gnResetFence(fence);
|
fence->device->instance->callingLayer->syncFunctions._gnResetFence(fence);
|
||||||
}
|
}
|
||||||
void gnDestroyFence(gnFenceHandle fence) {
|
void gnDestroyFence(gnFenceHandle fence) {
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
gnBool gnIsExtensionSuppoted(gnRenderingAPI api, gnExtension extension) {
|
gnBool gnIsExtensionSuppoted(gnRenderingAPI api, gnExtension extension) {
|
||||||
switch (api) {
|
switch (api) {
|
||||||
case GN_RENDERINGAPI_NONE: return gnFalse;
|
case GN_RENDERINGAPI_NONE: return GN_FALSE;
|
||||||
#ifdef GN_API_VULKAN
|
#ifdef GN_API_VULKAN
|
||||||
case GN_RENDERINGAPI_VULKAN: return vulkanIsExtensionSupported(extension);
|
case GN_RENDERINGAPI_VULKAN: return vulkanIsExtensionSupported(extension);
|
||||||
#endif
|
#endif
|
||||||
@@ -31,6 +31,6 @@ gnBool gnIsExtensionSuppoted(gnRenderingAPI api, gnExtension extension) {
|
|||||||
#ifdef GN_API_METAL
|
#ifdef GN_API_METAL
|
||||||
case GN_RENDERINGAPI_METAL: return metalIsExtensionSupported(extension);
|
case GN_RENDERINGAPI_METAL: return metalIsExtensionSupported(extension);
|
||||||
#endif
|
#endif
|
||||||
default: return gnFalse;
|
default: return GN_FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,8 @@ gnRenderingAPI* gnGetSupportedRenderingAPIs(int* count) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gnBool gnSupportsRenderingAPI(gnRenderingAPI api) {
|
gnBool gnSupportsRenderingAPI(gnRenderingAPI api) {
|
||||||
for (int i = 0; i < 3; i++) if (api == renderingAPIs[i]) return gnTrue;
|
for (int i = 0; i < 3; i++) if (api == renderingAPIs[i]) return GN_TRUE;
|
||||||
return gnFalse;
|
return GN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAMetalLayer* gnCreateCAMetalLayer(NSWindow* window) {
|
CAMetalLayer* gnCreateCAMetalLayer(NSWindow* window) {
|
||||||
|
@@ -16,7 +16,7 @@ gnPhysicalDevice* checkGetPhysicalDevices(gnInstanceHandle instance, uint32_t* c
|
|||||||
CHECK_RETURNED_FUNCTION(instance, _gnGetPhysicalDevices, instanceFunctions, NULL, instance, count);
|
CHECK_RETURNED_FUNCTION(instance, _gnGetPhysicalDevices, instanceFunctions, NULL, instance, count);
|
||||||
}
|
}
|
||||||
gnBool checkCanDevicePresent(gnPhysicalDevice device, gnWindowSurfaceHandle windowSurface) {
|
gnBool checkCanDevicePresent(gnPhysicalDevice device, gnWindowSurfaceHandle windowSurface) {
|
||||||
CHECK_RETURNED_FUNCTION(device->instance, _gnPhysicalDeviceCanPresentToSurface, instanceFunctions, gnFalse, device, windowSurface);
|
CHECK_RETURNED_FUNCTION(device->instance, _gnPhysicalDeviceCanPresentToSurface, instanceFunctions, GN_FALSE, device, windowSurface);
|
||||||
}
|
}
|
||||||
|
|
||||||
gnReturnCode checkCreateOutputDevice(gnOutputDeviceHandle device, gnInstanceHandle instance, gnOutputDeviceInfo deviceInfo) {
|
gnReturnCode checkCreateOutputDevice(gnOutputDeviceHandle device, gnInstanceHandle instance, gnOutputDeviceInfo deviceInfo) {
|
||||||
|
Reference in New Issue
Block a user