Remove MaxImageAttachments on RP/FB, dynamically size. Closes #1033

* Render passes and framebuffers can have as many attachments as desired, and
  just use a small subset in each subpass. We shouldn't add an artificial limit
  without good reason.
This commit is contained in:
baldurk
2018-07-09 16:26:03 +01:00
parent 650a80db47
commit b00f62b976
3 changed files with 12 additions and 15 deletions
-2
View File
@@ -1110,8 +1110,6 @@ public:
VkResourceRecord *bakedCommands;
static const int MaxImageAttachments = 17; // 8 Input, 8 Colour and 1 Depth
// pointer to either the pool this item is allocated from, or the children allocated
// from this pool. Protected by the chunk lock
VkResourceRecord *pool;
@@ -1148,7 +1148,7 @@ void WrappedVulkan::vkCmdBeginRenderPass(VkCommandBuffer commandBuffer,
VkResourceRecord *fb = GetRecord(pRenderPassBegin->framebuffer);
record->MarkResourceFrameReferenced(fb->GetResourceID(), eFrameRef_Read);
for(size_t i = 0; i < VkResourceRecord::MaxImageAttachments; i++)
for(size_t i = 0; fb->imageAttachments[i].barrier.sType; i++)
{
VkResourceRecord *att = fb->imageAttachments[i].record;
if(att == NULL)
@@ -1334,7 +1334,7 @@ void WrappedVulkan::vkCmdEndRenderPass(VkCommandBuffer commandBuffer)
std::vector<VkImageMemoryBarrier> barriers;
for(size_t i = 0; i < VkResourceRecord::MaxImageAttachments; i++)
for(size_t i = 0; fb->imageAttachments[i].barrier.sType; i++)
{
if(fb->imageAttachments[i].barrier.oldLayout == fb->imageAttachments[i].barrier.newLayout)
continue;
@@ -639,16 +639,14 @@ VkResult WrappedVulkan::vkCreateFramebuffer(VkDevice device,
VkResourceRecord *record = GetResourceManager()->AddResourceRecord(*pFramebuffer);
record->AddChunk(chunk);
record->imageAttachments = new AttachmentInfo[VkResourceRecord::MaxImageAttachments];
RDCASSERT(pCreateInfo->attachmentCount <= VkResourceRecord::MaxImageAttachments);
RDCEraseMem(record->imageAttachments,
sizeof(AttachmentInfo) * VkResourceRecord::MaxImageAttachments);
VkResourceRecord *rpRecord = GetRecord(pCreateInfo->renderPass);
record->AddParent(rpRecord);
uint32_t arrayCount = pCreateInfo->attachmentCount + 1;
record->imageAttachments = new AttachmentInfo[arrayCount];
RDCEraseMem(record->imageAttachments, sizeof(AttachmentInfo) * arrayCount);
for(uint32_t i = 0; i < pCreateInfo->attachmentCount; i++)
{
VkResourceRecord *attRecord = GetRecord(pCreateInfo->pAttachments[i]);
@@ -847,11 +845,12 @@ VkResult WrappedVulkan::vkCreateRenderPass(VkDevice device, const VkRenderPassCr
VkResourceRecord *record = GetResourceManager()->AddResourceRecord(*pRenderPass);
record->AddChunk(chunk);
record->imageAttachments = new AttachmentInfo[VkResourceRecord::MaxImageAttachments];
RDCASSERT(pCreateInfo->attachmentCount <= VkResourceRecord::MaxImageAttachments);
// +1 for the terminal value
uint32_t arrayCount = pCreateInfo->attachmentCount + 1;
RDCEraseMem(record->imageAttachments,
sizeof(AttachmentInfo) * VkResourceRecord::MaxImageAttachments);
record->imageAttachments = new AttachmentInfo[arrayCount];
RDCEraseMem(record->imageAttachments, sizeof(AttachmentInfo) * arrayCount);
for(uint32_t i = 0; i < pCreateInfo->attachmentCount; i++)
{