Skip to content

Conversation

@skarthik0196
Copy link
Contributor

@skarthik0196 skarthik0196 commented Oct 15, 2025

Description

Issues:

  1. Some of the ray tracing samples violate the spec requirement that scratch buffers must be aligned to VkPhysicalDeviceAccelerationStructureProperties::minAccelerationStructureScratchOffsetAlignment. This can cause crashes if the default alignment reported by vkGetBufferMemoryRequirements does not match minAccelerationStructureScratchOffsetAlignment.
  2. The Shader Binding Table must also respect shaderGroupBaseAlignment.

This PR adds a way to specify the required alignment for a buffer. Internally, it updates the buffer creation code to use vmaCreateBufferWithAlignment instead of vmaCreateBuffer if an alignment is specified. I only updated the BufferBuilder to allow a way to specify an alignment since the comments says the other Buffer constructor is now deprecated.

The following samples have been updated to be alignment aware for scratch buffers and Shader

  1. ray_tracing_extended
  2. ray_tracing_reflection
  3. ray_queries
  4. ray_tracing_position_fetch
  5. mobile_nerf_rayquery

Testing
I did a full batch run on an AMD Radeon RX 9070XT and a Nvidia Geforce RTX 5090 on Windows. I currently don't have a setup to test other platforms.

General Checklist:

Please ensure the following points are checked:

  • My code follows the coding style
  • I have reviewed file licenses
  • I have commented any added functions (in line with Doxygen)
  • I have commented any code that could be hard to understand
  • My changes do not add any new compiler warnings
  • My changes do not add any new validation layer errors or warnings
  • I have used existing framework/helper functions where possible
  • My changes do not add any regressions
  • I have tested every sample to ensure everything runs correctly
  • This PR describes the scope and expected impact of the changes I am making

Note: The Samples CI runs a number of checks including:

  • I have updated the header Copyright to reflect the current year (CI build will fail if Copyright is out of date)
  • My changes build on Windows, Linux, macOS and Android. Otherwise I have documented any exceptions

If this PR contains framework changes:

  • I did a full batch run using the batch command line argument to make sure all samples still work properly

Sample Checklist

If your PR contains a new or modified sample, these further checks must be carried out in addition to the General Checklist:

  • I have tested the sample on at least one compliant Vulkan implementation
  • If the sample is vendor-specific, I have tagged it appropriately
  • I have stated on what implementation the sample has been tested so that others can test on different implementations and platforms
  • Any dependent assets have been merged and published in downstream modules
  • For new samples, I have added a paragraph with a summary to the appropriate chapter in the readme of the folder that the sample belongs to e.g. api samples readme
  • For new samples, I have added a tutorial README.md file to guide users through what they need to know to implement code using this feature. For example, see conditional_rendering
  • For new samples, I have added a link to the Antora navigation so that the sample will be listed at the Vulkan documentation site

@CLAassistant
Copy link

CLAassistant commented Oct 15, 2025

CLA assistant check
All committers have signed the CLA.

SaschaWillems
SaschaWillems previously approved these changes Oct 18, 2025
Copy link
Collaborator

@SaschaWillems SaschaWillems left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for fixing this 👍🏻

@skarthik0196
Copy link
Contributor Author

The clang format check failed for one of the files, I've fixed it now. Is there a command I can use to trigger the builds?

@SaschaWillems
Copy link
Collaborator

Due to security concerns, first time contributors can't trigger builds. I just did that.

SaschaWillems
SaschaWillems previously approved these changes Oct 20, 2025
@JoseEmilio-ARM JoseEmilio-ARM self-requested a review November 3, 2025 16:27
Copy link
Collaborator

@JoseEmilio-ARM JoseEmilio-ARM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on Android (Xiaomi 15S Pro). I get a DEVICE_LOST for Mobile NeRF, but I checked that this already happens in main too, so need to track that separately.

Thank you for the PR!

@marty-johnson59
Copy link
Contributor

3 approvals - merging

@marty-johnson59 marty-johnson59 merged commit b279952 into KhronosGroup:main Nov 13, 2025
19 checks passed
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.

6 participants