Browse Source

Updated to newer specification of header file. Tracked down clang/graphene incompatibility that prevented building

master
dirkson 4 months ago
parent
commit
6687ea68bb
3 changed files with 42 additions and 41 deletions
  1. 1
    0
      meson.build
  2. 40
    40
      src/voxen_vulkan.c
  3. 1
    1
      src/voxen_vulkan_pick_gpu.c

+ 1
- 0
meson.build View File

@@ -1,4 +1,5 @@
project('voxen', 'c', default_options : ['default_library=static', 'c_std=c99'])
add_project_arguments(['-Werror', '-Wall', '-Wpedantic', '-D_XOPEN_SOURCE=600', '-D_GNU_SOURCE'], language : 'c')
incdir = include_directories(['include', 'src'])

if get_option('buildtype').startswith('debug')

+ 40
- 40
src/voxen_vulkan.c View File

@@ -5,7 +5,7 @@
#include "graphene.h"
//#include "vtl.h"

#include "vulkan/vk_enum_string_helper.h"
#include "vk_enum_string_helper.h"

//***Constants***

@@ -98,7 +98,7 @@ inline voxen_bool voxen_vulkan_draw(VoxenVulkanInfo *initInfo)
voxen_debug(VOXEN_WARN, "Failed to aquire swapchain image");
//voxen_debug(VOXEN_INFO, "vkAcquireNextImageKHR: %i", voxen_time_diff(time)/2000);

VkSubmitInfo submitInfo = {};
VkSubmitInfo submitInfo = {0};
submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;

VkSemaphore waitSemaphores[] = {initInfo->ImageAvailableSemaphore[initInfo->CurrentFrame]};
@@ -120,7 +120,7 @@ inline voxen_bool voxen_vulkan_draw(VoxenVulkanInfo *initInfo)
voxen_debug(VOXEN_WARN, "Failed to submit vulkan queue");
//voxen_debug(VOXEN_INFO, "vkQueueSubmit: %i", voxen_time_diff(time)/2000);

VkPresentInfoKHR presentInfo = {};
VkPresentInfoKHR presentInfo = {0};
presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;

presentInfo.waitSemaphoreCount = 1;
@@ -286,7 +286,7 @@ voxen_bool voxen_vulkan_create_logical_device(VoxenVulkanInfo *initInfo, VoxenVu


VkDeviceCreateInfo createInfo = {};
VkDeviceCreateInfo createInfo = {0};
createInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
createInfo.pQueueCreateInfos = queueCreateInfos;
// voxen_debug(VOXEN_WARN, "%i %i", queueCreateInfos.pQueueCreateInfos[0].sType, queueCreateInfos.pQueueCreateInfos[1].sType);
@@ -348,7 +348,7 @@ voxen_bool voxen_vulkan_create_swapchain(VoxenVulkanPhysicalInfo *physicalDevice
if (physicalDevice->Capabilities.maxImageCount > 0 && imageCount > physicalDevice->Capabilities.maxImageCount)
imageCount = physicalDevice->Capabilities.maxImageCount;

VkSwapchainCreateInfoKHR createInfo = {};
VkSwapchainCreateInfoKHR createInfo = {0};
createInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
createInfo.surface = surface;
createInfo.minImageCount = imageCount;
@@ -421,7 +421,7 @@ voxen_bool voxen_vulkan_create_swapchain(VoxenVulkanPhysicalInfo *physicalDevice
if (NULL == initInfo->SwapChainImageViews)
return voxen_debug(VOXEN_ERROR, "Failed to allocate swap chain image views");

VkImageViewCreateInfo createInfoViews = {};
VkImageViewCreateInfo createInfoViews = {0};
size_t i;
for (i = 0; i < initInfo->SwapChainImagesCount; i++)
{
@@ -449,7 +449,7 @@ voxen_bool voxen_vulkan_create_swapchain(VoxenVulkanPhysicalInfo *physicalDevice

voxen_bool voxen_vulkan_create_shader_module(const VkDevice device, const uint32_t * const shader, const size_t shaderSize, VkShaderModule *shaderModule)
{
VkShaderModuleCreateInfo createInfo = {};
VkShaderModuleCreateInfo createInfo = {0};
createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
createInfo.codeSize = shaderSize;
createInfo.pCode = shader;
@@ -463,7 +463,7 @@ voxen_bool voxen_vulkan_create_shader_module(const VkDevice device, const uint32
voxen_bool voxen_vulkan_create_render_pass(VoxenVulkanInfo *initInfo, VkDevice device)
{

VkAttachmentDescription colorAttachment = {};
VkAttachmentDescription colorAttachment = {0};
colorAttachment.format = initInfo->Format.format;
colorAttachment.samples = VK_SAMPLE_COUNT_1_BIT;
colorAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
@@ -473,11 +473,11 @@ voxen_bool voxen_vulkan_create_render_pass(VoxenVulkanInfo *initInfo, VkDevice d
colorAttachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
colorAttachment.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;

VkAttachmentReference colorAttachmentRef = {};
VkAttachmentReference colorAttachmentRef = {0};
colorAttachmentRef.attachment = 0;
colorAttachmentRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
VkSubpassDependency dependency = {};
VkSubpassDependency dependency = {0};
dependency.srcSubpass = VK_SUBPASS_EXTERNAL;
dependency.dstSubpass = 0;
dependency.srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
@@ -485,12 +485,12 @@ voxen_bool voxen_vulkan_create_render_pass(VoxenVulkanInfo *initInfo, VkDevice d
dependency.dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
dependency.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
VkSubpassDescription subpass = {};
VkSubpassDescription subpass = {0};
subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
subpass.colorAttachmentCount = 1;
subpass.pColorAttachments = &colorAttachmentRef;

VkRenderPassCreateInfo renderPassInfo = {};
VkRenderPassCreateInfo renderPassInfo = {0};
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
renderPassInfo.attachmentCount = 1;
renderPassInfo.pAttachments = &colorAttachment;
@@ -531,13 +531,13 @@ voxen_bool voxen_vulkan_create_graphics_pipeline(VoxenVulkanInfo *initInfo, VkDe
return voxen_debug(VOXEN_ERROR, "Failed to create fragment shader module");

//Shader Info
VkPipelineShaderStageCreateInfo vertShaderStageInfo = {};
VkPipelineShaderStageCreateInfo vertShaderStageInfo = {0};
vertShaderStageInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
vertShaderStageInfo.stage = VK_SHADER_STAGE_VERTEX_BIT;
vertShaderStageInfo.module = vertShaderModule;
vertShaderStageInfo.pName = "main";

VkPipelineShaderStageCreateInfo fragShaderStageInfo = {};
VkPipelineShaderStageCreateInfo fragShaderStageInfo = {0};
fragShaderStageInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
fragShaderStageInfo.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
fragShaderStageInfo.module = fragShaderModule;
@@ -546,13 +546,13 @@ voxen_bool voxen_vulkan_create_graphics_pipeline(VoxenVulkanInfo *initInfo, VkDe
VkPipelineShaderStageCreateInfo shaderStages[] = {vertShaderStageInfo, fragShaderStageInfo};

//Vertex setup
VkVertexInputBindingDescription bindingDescription = {};
VkVertexInputBindingDescription bindingDescription = {0};
bindingDescription.binding = 0;
bindingDescription.stride = sizeof(VoxenVertex);
bindingDescription.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
//VK_VERTEX_INPUT_RATE_INSTANCE
VkVertexInputAttributeDescription attributeDescriptions[2] = {};
VkVertexInputAttributeDescription attributeDescriptions[2] = {{0}, {0}};

attributeDescriptions[0].binding = 0;
attributeDescriptions[0].location = 0;
@@ -565,7 +565,7 @@ voxen_bool voxen_vulkan_create_graphics_pipeline(VoxenVulkanInfo *initInfo, VkDe
attributeDescriptions[1].offset = offsetof(VoxenVertex, col);

//Vertex Input
VkPipelineVertexInputStateCreateInfo vertexInputInfo = {};
VkPipelineVertexInputStateCreateInfo vertexInputInfo = {0};
vertexInputInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
vertexInputInfo.vertexBindingDescriptionCount = 1;
vertexInputInfo.pVertexBindingDescriptions = &bindingDescription; // Optional
@@ -575,13 +575,13 @@ voxen_bool voxen_vulkan_create_graphics_pipeline(VoxenVulkanInfo *initInfo, VkDe
vertexInputInfo.pVertexAttributeDescriptions = attributeDescriptions; // Optional

//Input Assembly
VkPipelineInputAssemblyStateCreateInfo inputAssembly = {};
VkPipelineInputAssemblyStateCreateInfo inputAssembly = {0};
inputAssembly.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
inputAssembly.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
inputAssembly.primitiveRestartEnable = VK_FALSE;
//Viewport
VkViewport viewport = {};
VkViewport viewport = {0};
viewport.x = 0.0f;
viewport.y = 0.0f;
viewport.width = (float) initInfo->Extent.width;
@@ -589,12 +589,12 @@ voxen_bool voxen_vulkan_create_graphics_pipeline(VoxenVulkanInfo *initInfo, VkDe
viewport.minDepth = 0.0f;
viewport.maxDepth = 1.0f;

VkRect2D scissor = {};
VkRect2D scissor = {0};
scissor.offset.x = 0;
scissor.offset.y = 0;
scissor.extent = initInfo->Extent;

VkPipelineViewportStateCreateInfo viewportState = {};
VkPipelineViewportStateCreateInfo viewportState = {0};
viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
viewportState.viewportCount = 1;
viewportState.pViewports = &viewport;
@@ -602,7 +602,7 @@ voxen_bool voxen_vulkan_create_graphics_pipeline(VoxenVulkanInfo *initInfo, VkDe
viewportState.pScissors = &scissor;
//Rasterizer
VkPipelineRasterizationStateCreateInfo rasterizer = {};
VkPipelineRasterizationStateCreateInfo rasterizer = {0};
rasterizer.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
rasterizer.depthClampEnable = VK_FALSE;
rasterizer.rasterizerDiscardEnable = VK_FALSE;
@@ -616,7 +616,7 @@ voxen_bool voxen_vulkan_create_graphics_pipeline(VoxenVulkanInfo *initInfo, VkDe
rasterizer.depthBiasSlopeFactor = 0.0f; // Optional

//Multisampling
VkPipelineMultisampleStateCreateInfo multisampling = {};
VkPipelineMultisampleStateCreateInfo multisampling = {0};
multisampling.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
multisampling.sampleShadingEnable = VK_FALSE;
multisampling.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
@@ -630,7 +630,7 @@ voxen_bool voxen_vulkan_create_graphics_pipeline(VoxenVulkanInfo *initInfo, VkDe
//VkPipelineDepthStencilStateCreateInfo

//Color blending
VkPipelineColorBlendAttachmentState colorBlendAttachment = {};
VkPipelineColorBlendAttachmentState colorBlendAttachment = {0};
colorBlendAttachment.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
colorBlendAttachment.blendEnable = VK_FALSE;
colorBlendAttachment.srcColorBlendFactor = VK_BLEND_FACTOR_ONE; // Optional
@@ -650,7 +650,7 @@ voxen_bool voxen_vulkan_create_graphics_pipeline(VoxenVulkanInfo *initInfo, VkDe
colorBlendAttachment.alphaBlendOp = VK_BLEND_OP_ADD;
*/

VkPipelineColorBlendStateCreateInfo colorBlending = {};
VkPipelineColorBlendStateCreateInfo colorBlending = {0};
colorBlending.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
colorBlending.logicOpEnable = VK_FALSE;
colorBlending.logicOp = VK_LOGIC_OP_COPY; // Optional
@@ -667,13 +667,13 @@ voxen_bool voxen_vulkan_create_graphics_pipeline(VoxenVulkanInfo *initInfo, VkDe
// VK_DYNAMIC_STATE_LINE_WIDTH
// };

// VkPipelineDynamicStateCreateInfo dynamicState = {};
// VkPipelineDynamicStateCreateInfo dynamicState = {0};
// dynamicState.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
// dynamicState.dynamicStateCount = 2;
// dynamicState.pDynamicStates = dynamicStates;

//Pipeline Layout
VkPipelineLayoutCreateInfo pipelineLayoutInfo = {};
VkPipelineLayoutCreateInfo pipelineLayoutInfo = {0};
pipelineLayoutInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
pipelineLayoutInfo.setLayoutCount = 0; // Optional
pipelineLayoutInfo.pSetLayouts = NULL; // Optional
@@ -684,7 +684,7 @@ voxen_bool voxen_vulkan_create_graphics_pipeline(VoxenVulkanInfo *initInfo, VkDe
voxen_debug(VOXEN_ERROR, "Failed to create vulkan pipeline layout");

//ACTUALLY MAKE THE PIPELINE
VkGraphicsPipelineCreateInfo pipelineInfo = {};
VkGraphicsPipelineCreateInfo pipelineInfo = {0};
pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
pipelineInfo.stageCount = 2;
pipelineInfo.pStages = shaderStages;
@@ -728,7 +728,7 @@ voxen_bool voxen_vulkan_create_framebuffers(VoxenVulkanInfo *initInfo, VkDevice
if (NULL == initInfo->SwapChainFramebuffers)
return voxen_debug(VOXEN_ERROR, "Failed to allocate framebuffers");
VkFramebufferCreateInfo framebufferInfo = {};
VkFramebufferCreateInfo framebufferInfo = {0};
framebufferInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
framebufferInfo.renderPass = initInfo->RenderPass;
framebufferInfo.attachmentCount = 1;
@@ -752,7 +752,7 @@ voxen_bool voxen_vulkan_create_framebuffers(VoxenVulkanInfo *initInfo, VkDevice

voxen_bool voxen_vulkan_create_command_pools(VoxenVulkanPhysicalInfo *physicalDevice, VoxenVulkanInfo *initInfo)
{
VkCommandPoolCreateInfo poolInfo = {};
VkCommandPoolCreateInfo poolInfo = {0};
poolInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
poolInfo.queueFamilyIndex = physicalDevice->GraphicsQueueFamily;
poolInfo.flags = 0; // Optional
@@ -771,7 +771,7 @@ voxen_bool voxen_vulkan_create_command_pools(VoxenVulkanPhysicalInfo *physicalDe
voxen_bool voxen_vulkan_create_command_buffers(VoxenVulkanInfo *initInfo)
{
//Bufferpool
VkCommandBufferAllocateInfo allocInfo = {};
VkCommandBufferAllocateInfo allocInfo = {0};
allocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
allocInfo.commandPool = initInfo->CommandPool;
allocInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
@@ -853,10 +853,10 @@ voxen_bool voxen_vulkan_create_command_buffers(VoxenVulkanInfo *initInfo)

voxen_bool voxen_vulkan_create_semaphores(VoxenVulkanInfo *initInfo)
{
VkSemaphoreCreateInfo semaphoreInfo = {};
VkSemaphoreCreateInfo semaphoreInfo = {0};
semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
VkFenceCreateInfo fenceInfo = {};
VkFenceCreateInfo fenceInfo = {0};
fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT;

@@ -897,7 +897,7 @@ voxen_bool voxen_vulkan_find_memory_type(VoxenVulkanPhysicalInfo *physInfo, uint
voxen_bool voxen_vulkan_create_buffer(VoxenVulkanInfo *initInfo, VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer *buffer, VkDeviceMemory *bufferMemory)
{
VkBufferCreateInfo bufferInfo = {};
VkBufferCreateInfo bufferInfo = {0};
bufferInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
bufferInfo.size = size;
bufferInfo.usage = usage;
@@ -919,7 +919,7 @@ voxen_bool voxen_vulkan_create_buffer(VoxenVulkanInfo *initInfo, VkDeviceSize si
return voxen_debug(VOXEN_ERROR,"Failed to find memory type suitable for buffer");
//Allocate
VkMemoryAllocateInfo allocInfo = {};
VkMemoryAllocateInfo allocInfo = {0};
allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
allocInfo.allocationSize = memRequirements.size;
allocInfo.memoryTypeIndex = memType;
@@ -1032,7 +1032,7 @@ voxen_bool voxen_vulkan_init(VoxenVulkanInfo *initInfo, const char *programName,

VkResult vkresult;

VkApplicationInfo appinfo = {};
VkApplicationInfo appinfo = {0};
appinfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
appinfo.pApplicationName = programName;
appinfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
@@ -1040,7 +1040,7 @@ voxen_bool voxen_vulkan_init(VoxenVulkanInfo *initInfo, const char *programName,
appinfo.engineVersion = VK_MAKE_VERSION(1, 0, 0);
appinfo.apiVersion = VK_API_VERSION_1_0;

VkInstanceCreateInfo vulkanInstanceCreateInfo = {};
VkInstanceCreateInfo vulkanInstanceCreateInfo = {0};
vulkanInstanceCreateInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
vulkanInstanceCreateInfo.pApplicationInfo = &appinfo;

@@ -1069,7 +1069,7 @@ voxen_bool voxen_vulkan_init(VoxenVulkanInfo *initInfo, const char *programName,
vulkanInstanceCreateInfo.ppEnabledLayerNames = &validationlayers[0];
vulkanInstanceCreateInfo.enabledLayerCount = 1;

VkDebugReportCallbackCreateInfoEXT vulkanDebugCallbackCreateInfo = {};
VkDebugReportCallbackCreateInfoEXT vulkanDebugCallbackCreateInfo = {0};
vulkanDebugCallbackCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
vulkanDebugCallbackCreateInfo.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT
| VK_DEBUG_REPORT_WARNING_BIT_EXT

+ 1
- 1
src/voxen_vulkan_pick_gpu.c View File

@@ -5,7 +5,7 @@
#include <string.h> //for memcmp. Because memory is a string!

//#include "vtl.h"
#include "vulkan/vk_enum_string_helper.h"
#include "vk_enum_string_helper.h"

void voxen_vulkan_free_physical_devices(VoxenVulkanPhysicalInfo **devices, int32_t deviceCount, int32_t skip)
{

Loading…
Cancel
Save