Render to cubemap face?

I’m trying to render to a cubemap face (actually six faces at once). I’m confused about how to do this, because if I change the baseArrayLayer value in the CreateImageView structure I get errors indicating that baseArrayLayer needs to be 0 and layerCount needs to be 6:

for (int l = 0; l < faces; ++l)
	viewInfo.subresourceRange.baseArrayLayer = l;
	viewInfo.subresourceRange.levelCount = 1;
	viewInfo.subresourceRange.layerCount = faces;
	for (int n = 0; n < mipimageview.size(); ++n)
		viewInfo.subresourceRange.baseMipLevel = n;
		VkAssert(vkCreateImageView(device->device, &viewInfo, NULL, &mipimageview[n]));

How do I set the pColorAttachments array to indicate six different cubemap faces to render to, if the imageview doesn’t have any way to specify a cubemap face without causing a validation error?

VkRenderingAttachmentInfo colorattachment = {};
colorattachment.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
std::array<VkRenderingAttachmentInfo, 6> colorattachments;
for (int n = 0; n < 6; ++n)
	colorattachment.imageView = tex->mipimageview[m];
	colorattachments[n] = colorattachment;
renderinfo.pColorAttachments =;

Here is the answer:

viewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D;

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.