dummy uniform buffers
parent
a92a03a69a
commit
0a7eb1fb2e
|
@ -1031,6 +1031,8 @@ typedef struct VulkanRenderer
|
||||||
|
|
||||||
VkDescriptorSetLayout vertexParamLayout;
|
VkDescriptorSetLayout vertexParamLayout;
|
||||||
VkDescriptorSetLayout fragmentParamLayout;
|
VkDescriptorSetLayout fragmentParamLayout;
|
||||||
|
VulkanBuffer *dummyVertexUniformBuffer;
|
||||||
|
VulkanBuffer *dummyFragmentUniformBuffer;
|
||||||
|
|
||||||
VulkanBuffer *textureStagingBuffer;
|
VulkanBuffer *textureStagingBuffer;
|
||||||
|
|
||||||
|
@ -3528,13 +3530,31 @@ static REFRESH_GraphicsPipeline* VULKAN_CreateGraphicsPipeline(
|
||||||
&graphicsPipeline->fragmentUBODescriptorSet
|
&graphicsPipeline->fragmentUBODescriptorSet
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (graphicsPipeline->vertexUBOBlockSize == 0)
|
||||||
|
{
|
||||||
|
vertexUniformBufferInfo.buffer = renderer->dummyVertexUniformBuffer->subBuffers[0]->buffer;
|
||||||
|
vertexUniformBufferInfo.offset = 0;
|
||||||
|
vertexUniformBufferInfo.range = renderer->dummyVertexUniformBuffer->subBuffers[0]->size;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
vertexUniformBufferInfo.buffer = renderer->vertexUBO->subBuffers[0]->buffer;
|
vertexUniformBufferInfo.buffer = renderer->vertexUBO->subBuffers[0]->buffer;
|
||||||
vertexUniformBufferInfo.offset = 0;
|
vertexUniformBufferInfo.offset = 0;
|
||||||
vertexUniformBufferInfo.range = graphicsPipeline->vertexUBOBlockSize;
|
vertexUniformBufferInfo.range = graphicsPipeline->vertexUBOBlockSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (graphicsPipeline->fragmentUBOBlockSize == 0)
|
||||||
|
{
|
||||||
|
fragmentUniformBufferInfo.buffer = renderer->dummyFragmentUniformBuffer->subBuffers[0]->buffer;
|
||||||
|
fragmentUniformBufferInfo.offset = 0;
|
||||||
|
fragmentUniformBufferInfo.range = renderer->dummyFragmentUniformBuffer->subBuffers[0]->size;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
fragmentUniformBufferInfo.buffer = renderer->fragmentUBO->subBuffers[0]->buffer;
|
fragmentUniformBufferInfo.buffer = renderer->fragmentUBO->subBuffers[0]->buffer;
|
||||||
fragmentUniformBufferInfo.offset = 0;
|
fragmentUniformBufferInfo.offset = 0;
|
||||||
fragmentUniformBufferInfo.range = graphicsPipeline->fragmentUBOBlockSize;
|
fragmentUniformBufferInfo.range = graphicsPipeline->fragmentUBOBlockSize;
|
||||||
|
}
|
||||||
|
|
||||||
uboWriteDescriptorSets[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
uboWriteDescriptorSets[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
||||||
uboWriteDescriptorSets[0].pNext = NULL;
|
uboWriteDescriptorSets[0].pNext = NULL;
|
||||||
|
@ -6667,8 +6687,7 @@ static REFRESH_Device* VULKAN_CreateDevice(
|
||||||
/* Variables: UBO Creation */
|
/* Variables: UBO Creation */
|
||||||
VkDescriptorPoolCreateInfo defaultDescriptorPoolInfo;
|
VkDescriptorPoolCreateInfo defaultDescriptorPoolInfo;
|
||||||
VkDescriptorPoolSize poolSizes[2];
|
VkDescriptorPoolSize poolSizes[2];
|
||||||
VkDescriptorSetAllocateInfo emptyVertexSamplerDescriptorAllocateInfo;
|
VkDescriptorSetAllocateInfo descriptorAllocateInfo;
|
||||||
VkDescriptorSetAllocateInfo emptyFragmentSamplerDescriptorAllocateInfo;
|
|
||||||
|
|
||||||
result = (REFRESH_Device*) SDL_malloc(sizeof(REFRESH_Device));
|
result = (REFRESH_Device*) SDL_malloc(sizeof(REFRESH_Device));
|
||||||
ASSIGN_DRIVER(VULKAN)
|
ASSIGN_DRIVER(VULKAN)
|
||||||
|
@ -7076,27 +7095,23 @@ static REFRESH_Device* VULKAN_CreateDevice(
|
||||||
&renderer->defaultDescriptorPool
|
&renderer->defaultDescriptorPool
|
||||||
);
|
);
|
||||||
|
|
||||||
emptyVertexSamplerDescriptorAllocateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
descriptorAllocateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
||||||
emptyVertexSamplerDescriptorAllocateInfo.pNext = NULL;
|
descriptorAllocateInfo.pNext = NULL;
|
||||||
emptyVertexSamplerDescriptorAllocateInfo.descriptorPool = renderer->defaultDescriptorPool;
|
descriptorAllocateInfo.descriptorPool = renderer->defaultDescriptorPool;
|
||||||
emptyVertexSamplerDescriptorAllocateInfo.descriptorSetCount = 1;
|
descriptorAllocateInfo.descriptorSetCount = 1;
|
||||||
emptyVertexSamplerDescriptorAllocateInfo.pSetLayouts = &renderer->emptyVertexSamplerLayout;
|
descriptorAllocateInfo.pSetLayouts = &renderer->emptyVertexSamplerLayout;
|
||||||
|
|
||||||
renderer->vkAllocateDescriptorSets(
|
renderer->vkAllocateDescriptorSets(
|
||||||
renderer->logicalDevice,
|
renderer->logicalDevice,
|
||||||
&emptyVertexSamplerDescriptorAllocateInfo,
|
&descriptorAllocateInfo,
|
||||||
&renderer->emptyVertexSamplerDescriptorSet
|
&renderer->emptyVertexSamplerDescriptorSet
|
||||||
);
|
);
|
||||||
|
|
||||||
emptyFragmentSamplerDescriptorAllocateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
descriptorAllocateInfo.pSetLayouts = &renderer->emptyFragmentSamplerLayout;
|
||||||
emptyFragmentSamplerDescriptorAllocateInfo.pNext = NULL;
|
|
||||||
emptyFragmentSamplerDescriptorAllocateInfo.descriptorPool = renderer->defaultDescriptorPool;
|
|
||||||
emptyFragmentSamplerDescriptorAllocateInfo.descriptorSetCount = 1;
|
|
||||||
emptyFragmentSamplerDescriptorAllocateInfo.pSetLayouts = &renderer->emptyFragmentSamplerLayout;
|
|
||||||
|
|
||||||
renderer->vkAllocateDescriptorSets(
|
renderer->vkAllocateDescriptorSets(
|
||||||
renderer->logicalDevice,
|
renderer->logicalDevice,
|
||||||
&emptyFragmentSamplerDescriptorAllocateInfo,
|
&descriptorAllocateInfo,
|
||||||
&renderer->emptyFragmentSamplerDescriptorSet
|
&renderer->emptyFragmentSamplerDescriptorSet
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -7130,6 +7145,36 @@ static REFRESH_Device* VULKAN_CreateDevice(
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Dummy Uniform Buffers */
|
||||||
|
|
||||||
|
renderer->dummyVertexUniformBuffer = (VulkanBuffer*) SDL_malloc(sizeof(VulkanBuffer));
|
||||||
|
|
||||||
|
if (!VULKAN_INTERNAL_CreateBuffer(
|
||||||
|
renderer,
|
||||||
|
16,
|
||||||
|
RESOURCE_ACCESS_VERTEX_SHADER_READ_UNIFORM_BUFFER,
|
||||||
|
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
|
||||||
|
1,
|
||||||
|
renderer->dummyVertexUniformBuffer
|
||||||
|
)) {
|
||||||
|
REFRESH_LogError("Failed to create dummy vertex uniform buffer!");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
renderer->dummyFragmentUniformBuffer = (VulkanBuffer*) SDL_malloc(sizeof(VulkanBuffer));
|
||||||
|
|
||||||
|
if (!VULKAN_INTERNAL_CreateBuffer(
|
||||||
|
renderer,
|
||||||
|
16,
|
||||||
|
RESOURCE_ACCESS_FRAGMENT_SHADER_READ_UNIFORM_BUFFER,
|
||||||
|
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
|
||||||
|
1,
|
||||||
|
renderer->dummyFragmentUniformBuffer
|
||||||
|
)) {
|
||||||
|
REFRESH_LogError("Failed to create dummy fragment uniform buffer!");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Initialize caches */
|
/* Initialize caches */
|
||||||
|
|
||||||
for (i = 0; i < NUM_PIPELINE_LAYOUT_BUCKETS; i += 1)
|
for (i = 0; i < NUM_PIPELINE_LAYOUT_BUCKETS; i += 1)
|
||||||
|
|
Loading…
Reference in New Issue