diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..bf57598 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "Vulkan-Headers"] + path = Vulkan-Headers + url = git@github.com:KhronosGroup/Vulkan-Headers.git diff --git a/Vulkan-Headers b/Vulkan-Headers new file mode 160000 index 0000000..85470b3 --- /dev/null +++ b/Vulkan-Headers @@ -0,0 +1 @@ +Subproject commit 85470b32ad5d0d7d67fdf411b6e7b502c09c9c52 diff --git a/include/Refresh.h b/include/Refresh.h index a151233..4821394 100644 --- a/include/Refresh.h +++ b/include/Refresh.h @@ -367,10 +367,10 @@ typedef struct REFRESH_Vec4 typedef struct REFRESH_Viewport { - int32_t x; - int32_t y; - int32_t w; - int32_t h; + float x; + float y; + float w; + float h; float minDepth; float maxDepth; } REFRESH_Viewport; diff --git a/src/Refresh_Driver_Vulkan.c b/src/Refresh_Driver_Vulkan.c index fed01a2..c524cb2 100644 --- a/src/Refresh_Driver_Vulkan.c +++ b/src/Refresh_Driver_Vulkan.c @@ -754,14 +754,14 @@ static REFRESH_GraphicsPipeline* VULKAN_CreateGraphicsPipeline( VkPipelineShaderStageCreateInfo shaderStageCreateInfos[2]; VkPipelineVertexInputStateCreateInfo vertexInputStateCreateInfo; - VkVertexInputBindingDescription vertexInputBindingDescriptions[pipelineCreateInfo->vertexInputState.vertexBindingCount]; - VkVertexInputAttributeDescription vertexInputAttributeDescriptions[pipelineCreateInfo->vertexInputState.vertexAttributeCount]; + VkVertexInputBindingDescription *vertexInputBindingDescriptions = SDL_stack_alloc(VkVertexInputBindingDescription, pipelineCreateInfo->vertexInputState.vertexBindingCount); + VkVertexInputAttributeDescription *vertexInputAttributeDescriptions = SDL_stack_alloc(VkVertexInputAttributeDescription, pipelineCreateInfo->vertexInputState.vertexAttributeCount); VkPipelineInputAssemblyStateCreateInfo inputAssemblyStateCreateInfo; VkPipelineViewportStateCreateInfo viewportStateCreateInfo; - VkViewport viewports[pipelineCreateInfo->viewportState.viewportCount]; - VkRect2D scissors[pipelineCreateInfo->viewportState.scissorCount]; + VkViewport *viewports = SDL_stack_alloc(VkViewport, pipelineCreateInfo->viewportState.viewportCount); + VkRect2D *scissors = SDL_stack_alloc(VkRect2D, pipelineCreateInfo->viewportState.scissorCount); VkPipelineRasterizationStateCreateInfo rasterizationStateCreateInfo; @@ -772,21 +772,24 @@ static REFRESH_GraphicsPipeline* VULKAN_CreateGraphicsPipeline( VkStencilOpState backStencilState; VkPipelineColorBlendStateCreateInfo colorBlendStateCreateInfo; - VkPipelineColorBlendAttachmentState colorBlendAttachmentStates[ + VkPipelineColorBlendAttachmentState *colorBlendAttachmentStates = SDL_stack_alloc( + VkPipelineColorBlendAttachmentState, pipelineCreateInfo->colorBlendState.blendStateCount - ]; + ); VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo; VkPipelineLayout pipelineLayout; VkDescriptorSetLayout setLayouts[4]; VkDescriptorSetLayoutCreateInfo setLayoutCreateInfo; - VkDescriptorSetLayoutBinding vertexSamplerLayoutBindings[ + VkDescriptorSetLayoutBinding *vertexSamplerLayoutBindings = SDL_stack_alloc( + VkDescriptorSetLayoutBinding, pipelineCreateInfo->pipelineLayoutCreateInfo.vertexSamplerBindingCount - ]; - VkDescriptorSetLayoutBinding fragmentSamplerLayoutBindings[ + ); + VkDescriptorSetLayoutBinding *fragmentSamplerLayoutBindings = SDL_stack_alloc( + VkDescriptorSetLayoutBinding, pipelineCreateInfo->pipelineLayoutCreateInfo.fragmentSamplerBindingCount - ]; + ); VulkanRenderer *renderer = (VulkanRenderer*) driverData; @@ -1059,6 +1062,14 @@ static REFRESH_GraphicsPipeline* VULKAN_CreateGraphicsPipeline( if (vulkanResult != VK_SUCCESS) { REFRESH_LogError("Failed to create vertex sampler layout!"); + + SDL_stack_free(vertexInputBindingDescriptions); + SDL_stack_free(vertexInputAttributeDescriptions); + SDL_stack_free(viewports); + SDL_stack_free(scissors); + SDL_stack_free(colorBlendAttachmentStates); + SDL_stack_free(vertexSamplerLayoutBindings); + SDL_stack_free(fragmentSamplerLayoutBindings); return NULL; } @@ -1087,6 +1098,13 @@ static REFRESH_GraphicsPipeline* VULKAN_CreateGraphicsPipeline( if (vulkanResult != VK_SUCCESS) { REFRESH_LogError("Failed to create fragment sampler layout!"); + SDL_stack_free(vertexInputBindingDescriptions); + SDL_stack_free(vertexInputAttributeDescriptions); + SDL_stack_free(viewports); + SDL_stack_free(scissors); + SDL_stack_free(colorBlendAttachmentStates); + SDL_stack_free(vertexSamplerLayoutBindings); + SDL_stack_free(fragmentSamplerLayoutBindings); return NULL; } @@ -1140,9 +1158,23 @@ static REFRESH_GraphicsPipeline* VULKAN_CreateGraphicsPipeline( if (vulkanResult != VK_SUCCESS) { REFRESH_LogError("Failed to create graphics pipeline!"); + SDL_stack_free(vertexInputBindingDescriptions); + SDL_stack_free(vertexInputAttributeDescriptions); + SDL_stack_free(viewports); + SDL_stack_free(scissors); + SDL_stack_free(colorBlendAttachmentStates); + SDL_stack_free(vertexSamplerLayoutBindings); + SDL_stack_free(fragmentSamplerLayoutBindings); return NULL; } + SDL_stack_free(vertexInputBindingDescriptions); + SDL_stack_free(vertexInputAttributeDescriptions); + SDL_stack_free(viewports); + SDL_stack_free(scissors); + SDL_stack_free(colorBlendAttachmentStates); + SDL_stack_free(vertexSamplerLayoutBindings); + SDL_stack_free(fragmentSamplerLayoutBindings); return (REFRESH_GraphicsPipeline*) pipeline; } @@ -1966,7 +1998,7 @@ static uint8_t VULKAN_INTERNAL_CheckValidationLayers( uint32_t layerCount; VkLayerProperties *availableLayers; uint32_t i, j; - uint8_t layerFound; + uint8_t layerFound = 0; vkEnumerateInstanceLayerProperties(&layerCount, NULL); availableLayers = SDL_stack_alloc(VkLayerProperties, layerCount);