fix some warnings and add vulkan headers

pull/8/head
cosmonaut 2020-12-17 16:39:25 -08:00
parent 22c5248ef3
commit 501a9d61a2
4 changed files with 51 additions and 15 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "Vulkan-Headers"]
path = Vulkan-Headers
url = git@github.com:KhronosGroup/Vulkan-Headers.git

1
Vulkan-Headers Submodule

@ -0,0 +1 @@
Subproject commit 85470b32ad5d0d7d67fdf411b6e7b502c09c9c52

View File

@ -367,10 +367,10 @@ typedef struct REFRESH_Vec4
typedef struct REFRESH_Viewport typedef struct REFRESH_Viewport
{ {
int32_t x; float x;
int32_t y; float y;
int32_t w; float w;
int32_t h; float h;
float minDepth; float minDepth;
float maxDepth; float maxDepth;
} REFRESH_Viewport; } REFRESH_Viewport;

View File

@ -754,14 +754,14 @@ static REFRESH_GraphicsPipeline* VULKAN_CreateGraphicsPipeline(
VkPipelineShaderStageCreateInfo shaderStageCreateInfos[2]; VkPipelineShaderStageCreateInfo shaderStageCreateInfos[2];
VkPipelineVertexInputStateCreateInfo vertexInputStateCreateInfo; VkPipelineVertexInputStateCreateInfo vertexInputStateCreateInfo;
VkVertexInputBindingDescription vertexInputBindingDescriptions[pipelineCreateInfo->vertexInputState.vertexBindingCount]; VkVertexInputBindingDescription *vertexInputBindingDescriptions = SDL_stack_alloc(VkVertexInputBindingDescription, pipelineCreateInfo->vertexInputState.vertexBindingCount);
VkVertexInputAttributeDescription vertexInputAttributeDescriptions[pipelineCreateInfo->vertexInputState.vertexAttributeCount]; VkVertexInputAttributeDescription *vertexInputAttributeDescriptions = SDL_stack_alloc(VkVertexInputAttributeDescription, pipelineCreateInfo->vertexInputState.vertexAttributeCount);
VkPipelineInputAssemblyStateCreateInfo inputAssemblyStateCreateInfo; VkPipelineInputAssemblyStateCreateInfo inputAssemblyStateCreateInfo;
VkPipelineViewportStateCreateInfo viewportStateCreateInfo; VkPipelineViewportStateCreateInfo viewportStateCreateInfo;
VkViewport viewports[pipelineCreateInfo->viewportState.viewportCount]; VkViewport *viewports = SDL_stack_alloc(VkViewport, pipelineCreateInfo->viewportState.viewportCount);
VkRect2D scissors[pipelineCreateInfo->viewportState.scissorCount]; VkRect2D *scissors = SDL_stack_alloc(VkRect2D, pipelineCreateInfo->viewportState.scissorCount);
VkPipelineRasterizationStateCreateInfo rasterizationStateCreateInfo; VkPipelineRasterizationStateCreateInfo rasterizationStateCreateInfo;
@ -772,21 +772,24 @@ static REFRESH_GraphicsPipeline* VULKAN_CreateGraphicsPipeline(
VkStencilOpState backStencilState; VkStencilOpState backStencilState;
VkPipelineColorBlendStateCreateInfo colorBlendStateCreateInfo; VkPipelineColorBlendStateCreateInfo colorBlendStateCreateInfo;
VkPipelineColorBlendAttachmentState colorBlendAttachmentStates[ VkPipelineColorBlendAttachmentState *colorBlendAttachmentStates = SDL_stack_alloc(
VkPipelineColorBlendAttachmentState,
pipelineCreateInfo->colorBlendState.blendStateCount pipelineCreateInfo->colorBlendState.blendStateCount
]; );
VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo; VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo;
VkPipelineLayout pipelineLayout; VkPipelineLayout pipelineLayout;
VkDescriptorSetLayout setLayouts[4]; VkDescriptorSetLayout setLayouts[4];
VkDescriptorSetLayoutCreateInfo setLayoutCreateInfo; VkDescriptorSetLayoutCreateInfo setLayoutCreateInfo;
VkDescriptorSetLayoutBinding vertexSamplerLayoutBindings[ VkDescriptorSetLayoutBinding *vertexSamplerLayoutBindings = SDL_stack_alloc(
VkDescriptorSetLayoutBinding,
pipelineCreateInfo->pipelineLayoutCreateInfo.vertexSamplerBindingCount pipelineCreateInfo->pipelineLayoutCreateInfo.vertexSamplerBindingCount
]; );
VkDescriptorSetLayoutBinding fragmentSamplerLayoutBindings[ VkDescriptorSetLayoutBinding *fragmentSamplerLayoutBindings = SDL_stack_alloc(
VkDescriptorSetLayoutBinding,
pipelineCreateInfo->pipelineLayoutCreateInfo.fragmentSamplerBindingCount pipelineCreateInfo->pipelineLayoutCreateInfo.fragmentSamplerBindingCount
]; );
VulkanRenderer *renderer = (VulkanRenderer*) driverData; VulkanRenderer *renderer = (VulkanRenderer*) driverData;
@ -1059,6 +1062,14 @@ static REFRESH_GraphicsPipeline* VULKAN_CreateGraphicsPipeline(
if (vulkanResult != VK_SUCCESS) if (vulkanResult != VK_SUCCESS)
{ {
REFRESH_LogError("Failed to create vertex sampler layout!"); 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; return NULL;
} }
@ -1087,6 +1098,13 @@ static REFRESH_GraphicsPipeline* VULKAN_CreateGraphicsPipeline(
if (vulkanResult != VK_SUCCESS) if (vulkanResult != VK_SUCCESS)
{ {
REFRESH_LogError("Failed to create fragment sampler layout!"); 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; return NULL;
} }
@ -1140,9 +1158,23 @@ static REFRESH_GraphicsPipeline* VULKAN_CreateGraphicsPipeline(
if (vulkanResult != VK_SUCCESS) if (vulkanResult != VK_SUCCESS)
{ {
REFRESH_LogError("Failed to create graphics pipeline!"); 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; 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; return (REFRESH_GraphicsPipeline*) pipeline;
} }
@ -1966,7 +1998,7 @@ static uint8_t VULKAN_INTERNAL_CheckValidationLayers(
uint32_t layerCount; uint32_t layerCount;
VkLayerProperties *availableLayers; VkLayerProperties *availableLayers;
uint32_t i, j; uint32_t i, j;
uint8_t layerFound; uint8_t layerFound = 0;
vkEnumerateInstanceLayerProperties(&layerCount, NULL); vkEnumerateInstanceLayerProperties(&layerCount, NULL);
availableLayers = SDL_stack_alloc(VkLayerProperties, layerCount); availableLayers = SDL_stack_alloc(VkLayerProperties, layerCount);