rendervulkan: Prepare for multiple descriptor sets.
This commit is contained in:
parent
56fb91ea72
commit
7f3aebbcc0
1 changed files with 22 additions and 12 deletions
|
@ -33,8 +33,6 @@ const VkApplicationInfo appInfo = {
|
||||||
|
|
||||||
VkInstance instance;
|
VkInstance instance;
|
||||||
|
|
||||||
#define k_nMaxSets 8 // should only need one or two per output tops
|
|
||||||
|
|
||||||
struct VulkanOutput_t
|
struct VulkanOutput_t
|
||||||
{
|
{
|
||||||
VkSurfaceKHR surface;
|
VkSurfaceKHR surface;
|
||||||
|
@ -79,7 +77,12 @@ static int g_drmRenderFd = -1;
|
||||||
|
|
||||||
VkDescriptorSetLayout descriptorSetLayout;
|
VkDescriptorSetLayout descriptorSetLayout;
|
||||||
VkPipelineLayout pipelineLayout;
|
VkPipelineLayout pipelineLayout;
|
||||||
VkDescriptorSet descriptorSet;
|
|
||||||
|
// currently just one set, no need to double buffer because we
|
||||||
|
// vkQueueWaitIdle after each submit.
|
||||||
|
// should be moved to the output if we are going to support multiple outputs
|
||||||
|
std::array<VkDescriptorSet, 1> descriptorSets;
|
||||||
|
size_t nCurrentDescriptorSet = 0;
|
||||||
|
|
||||||
std::array<std::array<VkPipeline, k_nMaxYcbcrMask>, k_nMaxLayers> pipelines = {};
|
std::array<std::array<VkPipeline, k_nMaxYcbcrMask>, k_nMaxLayers> pipelines = {};
|
||||||
std::mutex pipelineMutex;
|
std::mutex pipelineMutex;
|
||||||
|
@ -1318,11 +1321,11 @@ retry:
|
||||||
VkDescriptorPoolSize descriptorPoolSize[] = {
|
VkDescriptorPoolSize descriptorPoolSize[] = {
|
||||||
{
|
{
|
||||||
VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
||||||
k_nMaxSets * 1,
|
descriptorSets.size() * 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||||
2 * k_nMaxSets * k_nMaxLayers,
|
2 * descriptorSets.size() * k_nMaxLayers,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1330,7 +1333,7 @@ retry:
|
||||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
|
||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
.maxSets = k_nMaxSets,
|
.maxSets = descriptorSets.size(),
|
||||||
.poolSizeCount = sizeof(descriptorPoolSize) / sizeof(descriptorPoolSize[0]),
|
.poolSizeCount = sizeof(descriptorPoolSize) / sizeof(descriptorPoolSize[0]),
|
||||||
.pPoolSizes = descriptorPoolSize
|
.pPoolSizes = descriptorPoolSize
|
||||||
};
|
};
|
||||||
|
@ -1454,16 +1457,18 @@ retry:
|
||||||
std::thread piplelineThread(compile_all_pipelines);
|
std::thread piplelineThread(compile_all_pipelines);
|
||||||
piplelineThread.detach();
|
piplelineThread.detach();
|
||||||
|
|
||||||
|
std::vector<VkDescriptorSetLayout> descriptorSetLayouts(descriptorSets.size(), descriptorSetLayout);
|
||||||
|
|
||||||
VkDescriptorSetAllocateInfo descriptorSetAllocateInfo = {
|
VkDescriptorSetAllocateInfo descriptorSetAllocateInfo = {
|
||||||
VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
|
VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
|
||||||
nullptr,
|
nullptr,
|
||||||
descriptorPool,
|
descriptorPool,
|
||||||
1,
|
(uint32_t)descriptorSetLayouts.size(),
|
||||||
&descriptorSetLayout
|
descriptorSetLayouts.data(),
|
||||||
};
|
};
|
||||||
|
|
||||||
res = vkAllocateDescriptorSets(device, &descriptorSetAllocateInfo, &descriptorSet);
|
res = vkAllocateDescriptorSets(device, &descriptorSetAllocateInfo, descriptorSets.data());
|
||||||
if ( res != VK_SUCCESS || descriptorSet == VK_NULL_HANDLE )
|
if ( res != VK_SUCCESS )
|
||||||
{
|
{
|
||||||
vk_log.errorf( "vkAllocateDescriptorSets failed" );
|
vk_log.errorf( "vkAllocateDescriptorSets failed" );
|
||||||
return false;
|
return false;
|
||||||
|
@ -2085,8 +2090,11 @@ bool float_is_integer(float x)
|
||||||
|
|
||||||
static uint32_t s_frameId = 0;
|
static uint32_t s_frameId = 0;
|
||||||
|
|
||||||
void vulkan_update_descriptor( struct Composite_t *pComposite, struct VulkanPipeline_t *pPipeline, int nYCBCRMask )
|
VkDescriptorSet vulkan_update_descriptor( struct Composite_t *pComposite, struct VulkanPipeline_t *pPipeline, int nYCBCRMask )
|
||||||
{
|
{
|
||||||
|
VkDescriptorSet descriptorSet = descriptorSets[nCurrentDescriptorSet];
|
||||||
|
nCurrentDescriptorSet = (nCurrentDescriptorSet + 1) % descriptorSets.size();
|
||||||
|
|
||||||
{
|
{
|
||||||
VkImageView targetImageView;
|
VkImageView targetImageView;
|
||||||
|
|
||||||
|
@ -2195,6 +2203,8 @@ void vulkan_update_descriptor( struct Composite_t *pComposite, struct VulkanPipe
|
||||||
};
|
};
|
||||||
|
|
||||||
vkUpdateDescriptorSets(device, writeDescriptorSets.size(), writeDescriptorSets.data(), 0, nullptr);
|
vkUpdateDescriptorSets(device, writeDescriptorSets.size(), writeDescriptorSets.data(), 0, nullptr);
|
||||||
|
|
||||||
|
return descriptorSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool vulkan_composite( struct Composite_t *pComposite, struct VulkanPipeline_t *pPipeline, std::shared_ptr<CVulkanTexture> *pScreenshotTexture )
|
bool vulkan_composite( struct Composite_t *pComposite, struct VulkanPipeline_t *pPipeline, std::shared_ptr<CVulkanTexture> *pScreenshotTexture )
|
||||||
|
@ -2221,7 +2231,7 @@ bool vulkan_composite( struct Composite_t *pComposite, struct VulkanPipeline_t *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vulkan_update_descriptor( pComposite, pPipeline, pComposite->nYCBCRMask );
|
VkDescriptorSet descriptorSet = vulkan_update_descriptor( pComposite, pPipeline, pComposite->nYCBCRMask );
|
||||||
|
|
||||||
for ( int i = 0; i < pComposite->nLayerCount; i++ )
|
for ( int i = 0; i < pComposite->nLayerCount; i++ )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue