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

AccelerationStructure is impossible to build due to a dependency cycle #2304

Closed
atynagano opened this issue Aug 26, 2023 · 4 comments · Fixed by #2307
Closed

AccelerationStructure is impossible to build due to a dependency cycle #2304

atynagano opened this issue Aug 26, 2023 · 4 comments · Fixed by #2307

Comments

@atynagano
Copy link

Template

If you dont understand something just leave it.
If you can provide more detailed information than the template allows for, please ignore the template and present all of your findings.

  • Version of vulkano: a1dca42
  • OS: TODO
  • GPU (the selected PhysicalDevice): TODO
  • GPU Driver: TODO
  • Upload of a reasonably minimal complete main.rs file that demonstrates the issue: TODO

Issue

Is there any acceleration structure example? I cannot find the way to build AS.
To build AS, commonly vkGetAccelerationStructureBuildSizesKHR() is called first with VkAccelerationStructureBuildGeometryInfoKHR.dstAccelerationStructure=scratchData=empty to acquire the size requirements for AS.

	// Get the size requirements for buffers involved in the acceleration structure build process
	VkAccelerationStructureBuildGeometryInfoKHR acceleration_structure_build_geometry_info{};
	acceleration_structure_build_geometry_info.sType         = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_GEOMETRY_INFO_KHR;
	acceleration_structure_build_geometry_info.type          = VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR;
	acceleration_structure_build_geometry_info.flags         = VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR;
	acceleration_structure_build_geometry_info.geometryCount = 1;
	acceleration_structure_build_geometry_info.pGeometries   = &acceleration_structure_geometry;

	const uint32_t primitive_count = 1;

	VkAccelerationStructureBuildSizesInfoKHR acceleration_structure_build_sizes_info{};
	acceleration_structure_build_sizes_info.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_SIZES_INFO_KHR;
	vkGetAccelerationStructureBuildSizesKHR(
	    device->get_handle(),
	    VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR,
	    &acceleration_structure_build_geometry_info,
	    &primitive_count,
	    &acceleration_structure_build_sizes_info);

But current vulkano implementation requires AccelerationStructureBuildGeometryInfo.dst_acceleration_structure and .scratch_data not to be empty. So I think it's almost impossible to create AS without creating AS.

    let build_info = AccelerationStructureBuildGeometryInfo {
        flags: BuildAccelerationStructureFlags::PREFER_FAST_TRACE,
        mode: BuildAccelerationStructureMode::Build,
        ..AccelerationStructureBuildGeometryInfo::new(
            dst_acceleration_structure,
            geometries,
            scratch_data,
        )
    };

    let size = device.acceleration_structure_build_sizes(
        AccelerationStructureBuildType::HostOrDevice,
        &build_info,
        &[1],
    ).unwrap();

#2213

@marc0246
Copy link
Contributor

marc0246 commented Aug 26, 2023

An example is indeed greatly needed.

@marc0246
Copy link
Contributor

The tags I added are not related to the example though, rather what you're saying needs fixing.

@Rua
Copy link
Contributor

Rua commented Aug 26, 2023

I've made a PR to fix the issue, but I think it demonstrates that I really don't know much about how acceleration structures are used in practice. Would you be willing to write an example for Vulkano?

@marc0246 marc0246 changed the title Acceleration structure example AccelerationStructure is impossible to build due to a dependency cycle Aug 26, 2023
@marc0246
Copy link
Contributor

I made an issue to track the state of the example separately: #2308.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants