use 32 bit block sizes

pull/50/head
cosmonaut 2024-02-16 18:29:05 -08:00
parent 695ad15b75
commit f5e25979f4
1 changed files with 15 additions and 8 deletions

View File

@ -872,8 +872,8 @@ typedef struct VulkanGraphicsPipeline
VkPipeline pipeline; VkPipeline pipeline;
VulkanGraphicsPipelineLayout *pipelineLayout; VulkanGraphicsPipelineLayout *pipelineLayout;
Refresh_PrimitiveType primitiveType; Refresh_PrimitiveType primitiveType;
VkDeviceSize vertexUniformBlockSize; uint32_t vertexUniformBlockSize;
VkDeviceSize fragmentUniformBlockSize; uint32_t fragmentUniformBlockSize;
VulkanShaderModule *vertexShaderModule; VulkanShaderModule *vertexShaderModule;
VulkanShaderModule *fragmentShaderModule; VulkanShaderModule *fragmentShaderModule;
@ -892,7 +892,7 @@ typedef struct VulkanComputePipeline
{ {
VkPipeline pipeline; VkPipeline pipeline;
VulkanComputePipelineLayout *pipelineLayout; VulkanComputePipelineLayout *pipelineLayout;
VkDeviceSize uniformBlockSize; /* permanently set in Create function */ uint32_t uniformBlockSize; /* permanently set in Create function */
VulkanShaderModule *computeShaderModule; VulkanShaderModule *computeShaderModule;
SDL_atomic_t referenceCount; SDL_atomic_t referenceCount;
@ -1754,7 +1754,7 @@ typedef struct VulkanRenderer
VkDescriptorSetLayout fragmentUniformDescriptorSetLayout; VkDescriptorSetLayout fragmentUniformDescriptorSetLayout;
VkDescriptorSetLayout computeUniformDescriptorSetLayout; VkDescriptorSetLayout computeUniformDescriptorSetLayout;
VkDeviceSize minUBOAlignment; uint32_t minUBOAlignment;
/* Some drivers don't support D16 for some reason. Fun! */ /* Some drivers don't support D16 for some reason. Fun! */
VkFormat D16Format; VkFormat D16Format;
@ -2078,6 +2078,13 @@ static inline VkDeviceSize VULKAN_INTERNAL_NextHighestAlignment(
return align * ((n + align - 1) / align); 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( static void VULKAN_INTERNAL_MakeMemoryUnavailable(
VulkanRenderer* renderer, VulkanRenderer* renderer,
VulkanMemoryAllocation *allocation VulkanMemoryAllocation *allocation
@ -6086,7 +6093,7 @@ static Refresh_GraphicsPipeline* VULKAN_CreateGraphicsPipeline(
shaderStageCreateInfos[0].pSpecializationInfo = NULL; shaderStageCreateInfos[0].pSpecializationInfo = NULL;
graphicsPipeline->vertexUniformBlockSize = graphicsPipeline->vertexUniformBlockSize =
VULKAN_INTERNAL_NextHighestAlignment( VULKAN_INTERNAL_NextHighestAlignment32(
pipelineCreateInfo->vertexShaderInfo.uniformBufferSize, pipelineCreateInfo->vertexShaderInfo.uniformBufferSize,
renderer->minUBOAlignment renderer->minUBOAlignment
); );
@ -6103,7 +6110,7 @@ static Refresh_GraphicsPipeline* VULKAN_CreateGraphicsPipeline(
shaderStageCreateInfos[1].pSpecializationInfo = NULL; shaderStageCreateInfos[1].pSpecializationInfo = NULL;
graphicsPipeline->fragmentUniformBlockSize = graphicsPipeline->fragmentUniformBlockSize =
VULKAN_INTERNAL_NextHighestAlignment( VULKAN_INTERNAL_NextHighestAlignment32(
pipelineCreateInfo->fragmentShaderInfo.uniformBufferSize, pipelineCreateInfo->fragmentShaderInfo.uniformBufferSize,
renderer->minUBOAlignment renderer->minUBOAlignment
); );
@ -6529,7 +6536,7 @@ static Refresh_ComputePipeline* VULKAN_CreateComputePipeline(
); );
vulkanComputePipeline->uniformBlockSize = vulkanComputePipeline->uniformBlockSize =
VULKAN_INTERNAL_NextHighestAlignment( VULKAN_INTERNAL_NextHighestAlignment32(
computeShaderInfo->uniformBufferSize, computeShaderInfo->uniformBufferSize,
renderer->minUBOAlignment renderer->minUBOAlignment
); );
@ -11334,7 +11341,7 @@ static Refresh_Device* VULKAN_CreateDevice(
/* Set up UBO layouts */ /* Set up UBO layouts */
renderer->minUBOAlignment = renderer->physicalDeviceProperties.properties.limits.minUniformBufferOffsetAlignment; renderer->minUBOAlignment = (uint32_t) renderer->physicalDeviceProperties.properties.limits.minUniformBufferOffsetAlignment;
emptyVertexSamplerLayoutBinding.binding = 0; emptyVertexSamplerLayoutBinding.binding = 0;
emptyVertexSamplerLayoutBinding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; emptyVertexSamplerLayoutBinding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;