Skip to content

CmdClearAttachments no effect when no pipelines in renderpass #81

@publicrepo

Description

@publicrepo

When no pipelines are used in a pass, CmdClearAttachments has no effect.
This is because RenderPassCache::CreateRenderPass will flag color attachment as VK_ATTACHMENT_UNUSED when no pipelines are used.

One possible solution (may not be the best)

  1. Add code to CmdClearAttachments, to signal use of output attachments
	StreamEncoder::CmdClearAttachments

		// Add input attachment index to current subpass.
		auto& subpass = m_renderPasses.back().subpasses.back();
		for(auto index = 0U; index < attachmentCount; ++index)
			{ subpass.outputAttachments.emplace(pAttachments[index].colorAttachment); }
  1. This somewhat works, but because render passes are cached and hashed, empty passes and empty passes with clear get the same hash.
    So we'd need to update the hash
	static RenderPassHash GetHash(const RenderPassDesc* pDesc)
	
        struct SubpassDescriptionBitField
        {
            uint8_t pipelineCount : 8;
            uint8_t outputAttachments : 8; // fix for CmdClearAttachments
        };

		// SubpassDescriptionBitField
		subpassDescriptions[i].pipelineCount = static_cast<uint8_t>(pDesc->subpasses[i].pipelineBindings.size());
		subpassDescriptions[i].outputAttachments = static_cast<uint8_t>(pDesc->subpasses[i].outputAttachments.size()); // fix for CmdClearAttachments

It is undesirable to increase the size and complexity of the hash, so any better solution is welcome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions