mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Vulkan: Avoid desc set error in tests.
This requires quite a few DrawActiveTextures, but some pspautotests were triggering it.
This commit is contained in:
parent
5907897c36
commit
75d2188a92
2 changed files with 34 additions and 11 deletions
|
@ -92,18 +92,9 @@ void Vulkan2D::InitDeviceObjects() {
|
|||
res = vkCreateDescriptorSetLayout(device, &dsl, nullptr, &descriptorSetLayout_);
|
||||
_assert_(VK_SUCCESS == res);
|
||||
|
||||
VkDescriptorPoolSize dpTypes[1];
|
||||
dpTypes[0].descriptorCount = 3000;
|
||||
dpTypes[0].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||
|
||||
VkDescriptorPoolCreateInfo dp = { VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO };
|
||||
dp.flags = 0; // Don't want to mess around with individually freeing these, let's go fixed each frame and zap the whole array. Might try the dynamic approach later.
|
||||
dp.maxSets = 3000;
|
||||
dp.pPoolSizes = dpTypes;
|
||||
dp.poolSizeCount = ARRAY_SIZE(dpTypes);
|
||||
for (int i = 0; i < vulkan_->GetInflightFrames(); i++) {
|
||||
VkResult res = vkCreateDescriptorPool(vulkan_->GetDevice(), &dp, nullptr, &frameData_[i].descPool);
|
||||
_assert_(VK_SUCCESS == res);
|
||||
bool success = RecreateDescriptorPool(frameData_[i], 3000);
|
||||
_assert_(success);
|
||||
}
|
||||
|
||||
VkPushConstantRange push = {};
|
||||
|
@ -121,6 +112,28 @@ void Vulkan2D::InitDeviceObjects() {
|
|||
_assert_(VK_SUCCESS == res);
|
||||
}
|
||||
|
||||
bool Vulkan2D::RecreateDescriptorPool(FrameData &frame, int newSize) {
|
||||
if (frame.descPoolSize != 0) {
|
||||
DEBUG_LOG(G3D, "Reallocating desc pool from %d to %d", frame.descPoolSize, newSize);
|
||||
vulkan_->Delete().QueueDeleteDescriptorPool(frame.descPool);
|
||||
frame.descSets.clear();
|
||||
}
|
||||
frame.descPoolSize = newSize;
|
||||
|
||||
VkDescriptorPoolSize dpTypes[1];
|
||||
dpTypes[0].descriptorCount = frame.descPoolSize;
|
||||
dpTypes[0].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||
|
||||
VkDescriptorPoolCreateInfo dp = { VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO };
|
||||
dp.flags = 0; // Don't want to mess around with individually freeing these, let's go fixed each frame and zap the whole array. Might try the dynamic approach later.
|
||||
dp.maxSets = frame.descPoolSize;
|
||||
dp.pPoolSizes = dpTypes;
|
||||
dp.poolSizeCount = ARRAY_SIZE(dpTypes);
|
||||
|
||||
VkResult res = vkCreateDescriptorPool(vulkan_->GetDevice(), &dp, nullptr, &frame.descPool);
|
||||
return res == VK_SUCCESS;
|
||||
}
|
||||
|
||||
void Vulkan2D::DeviceLost() {
|
||||
DestroyDeviceObjects();
|
||||
}
|
||||
|
@ -193,6 +206,13 @@ VkDescriptorSet Vulkan2D::GetDescriptorSet(VkImageView tex1, VkSampler sampler1,
|
|||
descAlloc.descriptorPool = frame->descPool;
|
||||
descAlloc.descriptorSetCount = 1;
|
||||
VkResult result = vkAllocateDescriptorSets(vulkan_->GetDevice(), &descAlloc, &desc);
|
||||
if (result == VK_ERROR_FRAGMENTED_POOL || result < 0) {
|
||||
bool res = RecreateDescriptorPool(*frame, frame->descPoolSize * 2);
|
||||
_assert_msg_(res, "Ran out of descriptor space (frag?) and failed to recreate a descriptor pool. sz=%d res=%d", (int)frame->descSets.size());
|
||||
descAlloc.descriptorPool = frame->descPool;
|
||||
result = vkAllocateDescriptorSets(vulkan_->GetDevice(), &descAlloc, &desc);
|
||||
_assert_msg_(result == VK_SUCCESS, "Ran out of descriptor space (frag?) and failed to allocate after recreating a descriptor pool. res=%d", (int)result);
|
||||
}
|
||||
_assert_(result == VK_SUCCESS);
|
||||
|
||||
// We just don't write to the slots we don't care about.
|
||||
|
|
|
@ -127,11 +127,14 @@ private:
|
|||
|
||||
struct FrameData {
|
||||
VkDescriptorPool descPool;
|
||||
int descPoolSize = 0;
|
||||
std::map<DescriptorSetKey, VkDescriptorSet> descSets;
|
||||
};
|
||||
|
||||
FrameData frameData_[VulkanContext::MAX_INFLIGHT_FRAMES];
|
||||
|
||||
bool RecreateDescriptorPool(FrameData &frame, int newSize);
|
||||
|
||||
std::map<PipelineKey, VkPipeline> pipelines_;
|
||||
std::vector<VkPipeline> keptPipelines_;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue