Skip to content

[FIXED] array texture mipmaps#877

Merged
robertosfield merged 3 commits intovsg-dev:masterfrom
siystar:mipmap_array
Jul 20, 2023
Merged

[FIXED] array texture mipmaps#877
robertosfield merged 3 commits intovsg-dev:masterfrom
siystar:mipmap_array

Conversation

@siystar
Copy link
Copy Markdown

@siystar siystar commented Jul 18, 2023

Pull Request Template

Description

Fixed invalid baseArrayLayer and layerCount parameters passed to VkImageBlit when generating array texture mipmaps.

The Vulkan specification states: "The srcSubresource.baseArrayLayer + srcSubresource.layerCount of each element of pRegions must be less than or equal to the arrayLayers specified in VkImageCreateInfo when srcImage was created." (VUID-vkCmdBlitImage-srcSubresource-01707)

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Tested that array texture mipmaps no longer contain artifacts

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@robertosfield
Copy link
Copy Markdown
Collaborator

I have just done a quick review, I will need to investigate the issue further before merging so I understand the issue at hand. Do you have a means for recreating the problem that I could use to test things before/after?

There is also similar code in TransferTask.cpp that will need updating as well. Or, we refactor both so they use the same code to avoid divergence.

siystar added 2 commits July 18, 2023 20:42
Invalid layerCount was passed to vkCmdBlitImage when generating mipmaps for an array texture. In the code that loops over arrayLayers and blits each layer, layerCount should have been set to 1, not arrayLayers.

Fixed by removing the loop. Let Vulkan loop over the image layers using a single blit of baseArrayLayer=0, layerCount=arrayLayers.

Test case:

auto imageData = vsg::ubvec4Array3D::create(256, 256, 32, vsg::ubvec4(), vsg::Data::Properties(VK_FORMAT_R8G8B8A8_UNORM));
imageData->properties.imageViewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY;
sampler->maxLod = 4; // Generate mipmaps
…sferTask

Tested dynamic image updates

Tested array texture mipmaps
@robertosfield robertosfield merged commit 26a0138 into vsg-dev:master Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants