Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using MVKImage's getLayerCount() to initialize layerCount of an MVKImageView's subresourceRange breaks down for 3D images with 3D image views. #64

Closed
hideyhole opened this issue Feb 26, 2018 · 1 comment
Labels
Bug Completed Issue has been fixed, or enhancement implemented.

Comments

@hideyhole
Copy link
Collaborator

MVKImage's getLayerCount() function effectively treats a 3D texture as a 2D texture array and returns a count > 1 for such textures. This is useful in certain scenarios, such as calculating the total size occupied by a buffer that would hold the raw bytes of a 3D texture (such as in MVKImage's constructor) or an offset into such a buffer (such as in MVKImage::initSubresourceLayout()).

During construction of an MVKImageView, the layerCount member of its subresourceRange object is initialized in part using a call to this function, if the subresourceRange.layerCount of the incoming VkImageViewCreateInfo is VK_REMAINING_ARRAY_LAYERS. This breaks down for 3D images with 3D image views because the layerCount will be > 1 for such image views, which is invalid, and causes an assertion failure in the call to MTLTexture's newTextureViewWithPixelFormat in MVKImageView::newMTLTexture().

The same should be true for MVKImage::applyImageMemoryBarrier, if the vkCmdPipelineBarrier that triggers it is passed a VkImageMemoryBarrier that has VK_REMAINING_ARRAY_LAYERS for its subresourceRange.levelCount. I believe that would cause a validation failure in BlitCommandEncoder's synchronizeTexture.

@billhollings
Copy link
Contributor

@hideyhole This is now fixed in PR #127. Please retest and close this issue.

@billhollings billhollings added the Completed Issue has been fixed, or enhancement implemented. label Apr 9, 2018
billhollings added a commit that referenced this issue Apr 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Completed Issue has been fixed, or enhancement implemented.
Projects
None yet
Development

No branches or pull requests

2 participants