some uniform buffer fixes
continuous-integration/drone/push Build is passing Details

pull/1/head
cosmonaut 2022-01-12 13:25:42 -08:00
parent 5c47f98160
commit 4ad948aba4
1 changed files with 56 additions and 46 deletions

View File

@ -3326,6 +3326,7 @@ static void VULKAN_INTERNAL_CreateUniformBuffer(
}
VulkanUniformBuffer *buffer = SDL_malloc(sizeof(VulkanUniformBuffer));
buffer->pool = bufferPool;
buffer->vulkanBuffer = VULKAN_INTERNAL_CreateBuffer(
renderer,
@ -4456,8 +4457,9 @@ static void VULKAN_INTERNAL_EndCommandBuffer(
VkResult result;
/* Compute pipelines are not explicitly unbound so we have to clean up here */
if (commandBuffer->computeUniformBuffer != NULL)
{
if ( commandBuffer->computeUniformBuffer != renderer->dummyComputeUniformBuffer &&
commandBuffer->computeUniformBuffer != NULL
) {
VULKAN_INTERNAL_BindUniformBuffer(commandBuffer->computeUniformBuffer);
}
commandBuffer->computeUniformBuffer = NULL;
@ -7803,14 +7805,16 @@ static void VULKAN_EndRenderPass(
vulkanCommandBuffer->commandBuffer
);
if (vulkanCommandBuffer->vertexUniformBuffer != NULL)
{
if ( vulkanCommandBuffer->vertexUniformBuffer != renderer->dummyVertexUniformBuffer &&
vulkanCommandBuffer->vertexUniformBuffer != NULL
) {
VULKAN_INTERNAL_BindUniformBuffer(vulkanCommandBuffer->vertexUniformBuffer);
}
vulkanCommandBuffer->vertexUniformBuffer = NULL;
if (vulkanCommandBuffer->fragmentUniformBuffer != NULL)
{
if ( vulkanCommandBuffer->fragmentUniformBuffer != renderer->dummyFragmentUniformBuffer &&
vulkanCommandBuffer->fragmentUniformBuffer != NULL
) {
VULKAN_INTERNAL_BindUniformBuffer(vulkanCommandBuffer->fragmentUniformBuffer);
}
vulkanCommandBuffer->fragmentUniformBuffer = NULL;
@ -7880,8 +7884,9 @@ static void VULKAN_BindGraphicsPipeline(
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
VulkanGraphicsPipeline* pipeline = (VulkanGraphicsPipeline*) graphicsPipeline;
if (vulkanCommandBuffer->vertexUniformBuffer != renderer->dummyVertexUniformBuffer)
{
if ( vulkanCommandBuffer->vertexUniformBuffer != renderer->dummyVertexUniformBuffer &&
vulkanCommandBuffer->vertexUniformBuffer != NULL
) {
VULKAN_INTERNAL_BindUniformBuffer(vulkanCommandBuffer->vertexUniformBuffer);
}
@ -7898,8 +7903,9 @@ static void VULKAN_BindGraphicsPipeline(
);
}
if (vulkanCommandBuffer->fragmentUniformBuffer != renderer->dummyFragmentUniformBuffer)
{
if ( vulkanCommandBuffer->fragmentUniformBuffer != renderer->dummyFragmentUniformBuffer &&
vulkanCommandBuffer->fragmentUniformBuffer != NULL
) {
VULKAN_INTERNAL_BindUniformBuffer(vulkanCommandBuffer->fragmentUniformBuffer);
}
@ -8036,8 +8042,9 @@ static void VULKAN_BindComputePipeline(
vulkanCommandBuffer->imageDescriptorSet = renderer->emptyComputeImageDescriptorSet;
}
if (vulkanCommandBuffer->computeUniformBuffer != NULL)
{
if ( vulkanCommandBuffer->computeUniformBuffer != renderer->dummyComputeUniformBuffer &&
vulkanCommandBuffer->computeUniformBuffer != NULL
) {
VULKAN_INTERNAL_BindUniformBuffer(vulkanCommandBuffer->computeUniformBuffer);
}
vulkanCommandBuffer->computeUniformBuffer = NULL;
@ -9301,7 +9308,7 @@ static Refresh_Device* VULKAN_INTERNAL_CreateDevice(
/* Variables: UBO Creation */
VkDescriptorPoolCreateInfo defaultDescriptorPoolInfo;
VkDescriptorPoolSize poolSizes[3];
VkDescriptorPoolSize poolSizes[4];
VkDescriptorSetAllocateInfo descriptorAllocateInfo;
result = (Refresh_Device*) SDL_malloc(sizeof(Refresh_Device));
@ -9560,11 +9567,14 @@ static Refresh_Device* VULKAN_INTERNAL_CreateDevice(
poolSizes[2].descriptorCount = 1;
poolSizes[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
poolSizes[3].descriptorCount = 3;
poolSizes[3].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC;
defaultDescriptorPoolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
defaultDescriptorPoolInfo.pNext = NULL;
defaultDescriptorPoolInfo.flags = 0;
defaultDescriptorPoolInfo.maxSets = 2 + 1 + 1;
defaultDescriptorPoolInfo.poolSizeCount = 3;
defaultDescriptorPoolInfo.maxSets = 2 + 1 + 1 + 3;
defaultDescriptorPoolInfo.poolSizeCount = 4;
defaultDescriptorPoolInfo.pPoolSizes = poolSizes;
renderer->vkCreateDescriptorPool(
@ -9610,37 +9620,6 @@ static Refresh_Device* VULKAN_INTERNAL_CreateDevice(
&renderer->emptyComputeImageDescriptorSet
);
/* Initialize uniform buffer pools */
renderer->vertexUniformBufferPool = VULKAN_INTERNAL_CreateUniformBufferPool(
renderer,
UNIFORM_BUFFER_VERTEX
);
renderer->fragmentUniformBufferPool = VULKAN_INTERNAL_CreateUniformBufferPool(
renderer,
UNIFORM_BUFFER_FRAGMENT
);
renderer->computeUniformBufferPool = VULKAN_INTERNAL_CreateUniformBufferPool(
renderer,
UNIFORM_BUFFER_COMPUTE
);
/* Initialize buffer space */
renderer->buffersInUseCapacity = 32;
renderer->buffersInUseCount = 0;
renderer->buffersInUse = (VulkanBuffer**)SDL_malloc(
sizeof(VulkanBuffer*) * renderer->buffersInUseCapacity
);
renderer->submittedBufferCapacity = 32;
renderer->submittedBufferCount = 0;
renderer->submittedBuffers = (VulkanBuffer**)SDL_malloc(
sizeof(VulkanBuffer*) * renderer->submittedBufferCapacity
);
/* Dummy Uniform Buffers */
renderer->dummyVertexUniformBuffer = VULKAN_INTERNAL_CreateDummyUniformBuffer(
@ -9676,6 +9655,37 @@ static Refresh_Device* VULKAN_INTERNAL_CreateDevice(
return NULL;
}
/* Initialize uniform buffer pools */
renderer->vertexUniformBufferPool = VULKAN_INTERNAL_CreateUniformBufferPool(
renderer,
UNIFORM_BUFFER_VERTEX
);
renderer->fragmentUniformBufferPool = VULKAN_INTERNAL_CreateUniformBufferPool(
renderer,
UNIFORM_BUFFER_FRAGMENT
);
renderer->computeUniformBufferPool = VULKAN_INTERNAL_CreateUniformBufferPool(
renderer,
UNIFORM_BUFFER_COMPUTE
);
/* Initialize buffer space */
renderer->buffersInUseCapacity = 32;
renderer->buffersInUseCount = 0;
renderer->buffersInUse = (VulkanBuffer**)SDL_malloc(
sizeof(VulkanBuffer*) * renderer->buffersInUseCapacity
);
renderer->submittedBufferCapacity = 32;
renderer->submittedBufferCount = 0;
renderer->submittedBuffers = (VulkanBuffer**)SDL_malloc(
sizeof(VulkanBuffer*) * renderer->submittedBufferCapacity
);
/* Initialize caches */
for (i = 0; i < NUM_COMMAND_POOL_BUCKETS; i += 1)