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

Tests cleanup: Remove old AccelerationStructureKHR in favor of RT helper classes defined in rt::as #5456

Merged
merged 3 commits into from
Mar 19, 2023

Conversation

arno-lunarg
Copy link
Contributor

@arno-lunarg arno-lunarg commented Mar 17, 2023

Bulk of the additions (~500 for a total of ~730) are in tests\framework\ray_tracing_objects.h/.cpp. They mostly consist in new methods to handle top level acceleration structures, and host acceleration structure operations.

The 1st commit fixes for safe_VkAccelerationStructureGeometryKHR, a memcpy was incorrect. The way array_size is computed is dubious, I created an issue to investigate that: KhronosGroup/Vulkan-Utility-Libraries#205

The 2nd removes AccelerationStructureKHR defined in tests\framework\binding.h in favor of classes from the rt::as namespace. It also adds the positive test RayTracingAccelerationStructureReference: it creates a bottom level acceleration structure on the device, then a top level acceleration structure that references the bottom level one.

The 3rd one removes old AccelerationStructureKHR

@arno-lunarg arno-lunarg requested a review from a team as a code owner March 17, 2023 09:00
@ci-tester-lunarg
Copy link
Collaborator

CI Vulkan-ValidationLayers build queued with queue ID 39663.

@ci-tester-lunarg
Copy link
Collaborator

CI Vulkan-ValidationLayers build # 11203 running.

@ci-tester-lunarg
Copy link
Collaborator

CI Vulkan-ValidationLayers build # 11203 failed.

@ci-tester-lunarg
Copy link
Collaborator

CI Vulkan-ValidationLayers build queued with queue ID 39686.

@ci-tester-lunarg
Copy link
Collaborator

CI Vulkan-ValidationLayers build # 11204 running.

@ci-tester-lunarg
Copy link
Collaborator

CI Vulkan-ValidationLayers build # 11204 failed.

@ci-tester-lunarg
Copy link
Collaborator

CI Vulkan-ValidationLayers build queued with queue ID 39716.

@ci-tester-lunarg
Copy link
Collaborator

CI Vulkan-ValidationLayers build # 11205 running.

@@ -60098,7 +60098,8 @@ safe_VkAccelerationStructureGeometryKHR::safe_VkAccelerationStructureGeometryKHR
} else {
size_t array_size = build_range_info->primitiveOffset + build_range_info->primitiveCount * sizeof(VkAccelerationStructureInstanceKHR);
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be enough to allocate memory just for build_range_info->primitiveCount structures? Do we need part of allocation of the size build_range_info->primitiveOffset bytes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think so too, but I need to explore how safe_VkAccelerationStructureGeometryKHR are used to make sure it will not break anything. For this PR, I am just going to fix the memcpy that is just wrong. I plan to have a deeper look at safe_VkAccelerationStructureGeometryKHR next

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You make me realise that to keep the current weird logic, I also need to offset the destination address in the memcpy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I created an issue for the dubious array_size computation: https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/5458

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks! yes, it would be nice to figure out if some code relies on that, especially if other computations need to be adjusted to match current logic.

@ci-tester-lunarg
Copy link
Collaborator

CI Vulkan-ValidationLayers build # 11205 passed.

@ci-tester-lunarg
Copy link
Collaborator

CI Vulkan-ValidationLayers build queued with queue ID 39749.

@ci-tester-lunarg
Copy link
Collaborator

CI Vulkan-ValidationLayers build # 11207 running.

Fix source address and copy size in the memcpy needed to initialize
a safe_VkAccelerationStructureGeometryKHR when the copied acceleration
structure is on the host

Will also need to have a look at array_size
@ci-tester-lunarg
Copy link
Collaborator

CI Vulkan-ValidationLayers build queued with queue ID 39766.

@ci-tester-lunarg
Copy link
Collaborator

CI Vulkan-ValidationLayers build # 11208 running.

@ci-tester-lunarg
Copy link
Collaborator

CI Vulkan-ValidationLayers build # 11208 failed.

@ci-tester-lunarg
Copy link
Collaborator

CI Vulkan-ValidationLayers build queued with queue ID 39781.

@ci-tester-lunarg
Copy link
Collaborator

CI Vulkan-ValidationLayers build # 11209 running.

@ci-tester-lunarg
Copy link
Collaborator

CI Vulkan-ValidationLayers build # 11209 passed.

AccelerationStructureKHR& SetBufferMemoryPropertyFlags(VkMemoryAllocateFlags memory_property_flags_);
AccelerationStructureKHR& SetDeviceBuffer(vk_testing::Buffer&& buffer);
AccelerationStructureKHR& SetDeviceBufferMemoryAllocateFlags(VkMemoryAllocateFlags memory_allocate_flags);
AccelerationStructureKHR& SetDeviceBufferMemoryPropertyFlags(VkMemoryAllocateFlags memory_property_flags_);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: last underscore

vk_obj_.geometry.aabbs.stride = stride;
return *this;
}

GeometryKHR &GeometryKHR::SetAABBsHostBuffer(std::unique_ptr<VkAabbPositionsKHR[]> &&buffer,
Copy link
Contributor

@artem-lunarg artem-lunarg Mar 17, 2023

Choose a reason for hiding this comment

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

I have impression that it's more common to pass std::unique_ptr by value. That can also be true for other move-only types where we need to call std::move anyway, but at least for std::unique_ptr that's what I saw more often. There is also this remark in c++ guidelines:

Exception. Unique owner types that are move-only and cheap-to-move, such as unique_ptr, can also be passed by value which is simpler to write and achieves the same effect. Passing by value does generate one extra (cheap) move operation, but prefer simplicity and clarity first.

p.s. that's not request for a change since it's more about style and it's up to the author if he likes this or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking that only an rvalue reference was possible here, thank you for showing me this. Clarity is the priority in those classes, so I am going to make this change!

Copy link
Contributor

@artem-lunarg artem-lunarg left a comment

Choose a reason for hiding this comment

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

LGTM. Nice simplification of test code.

Simplify tests by using objects from the rt::as namespace,
replacing usage of AccelerationStructureKHR

Rename RayTracingAccelerationStructureReference to
RayTracingHostAccelerationStructureReference, because it tests host
acceleration structure creation

Add RayTracingHostAccelerationStructureReference to test on device
acceleration structure creation
Remove vk_testing::AccelerationStructureKHR in favor of new helper
classes from the rt::as namespace
@ci-tester-lunarg
Copy link
Collaborator

CI Vulkan-ValidationLayers build queued with queue ID 40768.

@ci-tester-lunarg
Copy link
Collaborator

CI Vulkan-ValidationLayers build # 11227 running.

@ci-tester-lunarg
Copy link
Collaborator

CI Vulkan-ValidationLayers build # 11227 passed.

@arno-lunarg arno-lunarg merged commit 9139876 into KhronosGroup:main Mar 19, 2023
@arno-lunarg arno-lunarg deleted the clean-rt-tests branch March 19, 2023 19:07
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.

4 participants