From f5e25979f409bb2cfd87bec8bdab8b0a010a300b Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Fri, 16 Feb 2024 18:29:05 -0800 Subject: [PATCH] use 32 bit block sizes --- src/Refresh_Driver_Vulkan.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Refresh_Driver_Vulkan.c b/src/Refresh_Driver_Vulkan.c index 7307e71..94c4351 100644 --- a/src/Refresh_Driver_Vulkan.c +++ b/src/Refresh_Driver_Vulkan.c @@ -872,8 +872,8 @@ typedef struct VulkanGraphicsPipeline VkPipeline pipeline; VulkanGraphicsPipelineLayout *pipelineLayout; Refresh_PrimitiveType primitiveType; - VkDeviceSize vertexUniformBlockSize; - VkDeviceSize fragmentUniformBlockSize; + uint32_t vertexUniformBlockSize; + uint32_t fragmentUniformBlockSize; VulkanShaderModule *vertexShaderModule; VulkanShaderModule *fragmentShaderModule; @@ -892,7 +892,7 @@ typedef struct VulkanComputePipeline { VkPipeline pipeline; VulkanComputePipelineLayout *pipelineLayout; - VkDeviceSize uniformBlockSize; /* permanently set in Create function */ + uint32_t uniformBlockSize; /* permanently set in Create function */ VulkanShaderModule *computeShaderModule; SDL_atomic_t referenceCount; @@ -1754,7 +1754,7 @@ typedef struct VulkanRenderer VkDescriptorSetLayout fragmentUniformDescriptorSetLayout; VkDescriptorSetLayout computeUniformDescriptorSetLayout; - VkDeviceSize minUBOAlignment; + uint32_t minUBOAlignment; /* Some drivers don't support D16 for some reason. Fun! */ VkFormat D16Format; @@ -2078,6 +2078,13 @@ static inline VkDeviceSize VULKAN_INTERNAL_NextHighestAlignment( return align * ((n + align - 1) / align); } +static inline uint32_t VULKAN_INTERNAL_NextHighestAlignment32( + uint32_t n, + uint32_t align +) { + return align * ((n + align - 1) / align); +} + static void VULKAN_INTERNAL_MakeMemoryUnavailable( VulkanRenderer* renderer, VulkanMemoryAllocation *allocation @@ -6086,7 +6093,7 @@ static Refresh_GraphicsPipeline* VULKAN_CreateGraphicsPipeline( shaderStageCreateInfos[0].pSpecializationInfo = NULL; graphicsPipeline->vertexUniformBlockSize = - VULKAN_INTERNAL_NextHighestAlignment( + VULKAN_INTERNAL_NextHighestAlignment32( pipelineCreateInfo->vertexShaderInfo.uniformBufferSize, renderer->minUBOAlignment ); @@ -6103,7 +6110,7 @@ static Refresh_GraphicsPipeline* VULKAN_CreateGraphicsPipeline( shaderStageCreateInfos[1].pSpecializationInfo = NULL; graphicsPipeline->fragmentUniformBlockSize = - VULKAN_INTERNAL_NextHighestAlignment( + VULKAN_INTERNAL_NextHighestAlignment32( pipelineCreateInfo->fragmentShaderInfo.uniformBufferSize, renderer->minUBOAlignment ); @@ -6529,7 +6536,7 @@ static Refresh_ComputePipeline* VULKAN_CreateComputePipeline( ); vulkanComputePipeline->uniformBlockSize = - VULKAN_INTERNAL_NextHighestAlignment( + VULKAN_INTERNAL_NextHighestAlignment32( computeShaderInfo->uniformBufferSize, renderer->minUBOAlignment ); @@ -11334,7 +11341,7 @@ static Refresh_Device* VULKAN_CreateDevice( /* Set up UBO layouts */ - renderer->minUBOAlignment = renderer->physicalDeviceProperties.properties.limits.minUniformBufferOffsetAlignment; + renderer->minUBOAlignment = (uint32_t) renderer->physicalDeviceProperties.properties.limits.minUniformBufferOffsetAlignment; emptyVertexSamplerLayoutBinding.binding = 0; emptyVertexSamplerLayoutBinding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;