-
Notifications
You must be signed in to change notification settings - Fork 433
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
WIP: Implementing Acceleration Structures #1967
base: main
Are you sure you want to change the base?
WIP: Implementing Acceleration Structures #1967
Conversation
Just setup for acceleration structures by adding the definitions of the extension where it is needed. I also added the physical device features and properties that are needed.
This commit adds a few items which are: * A list of functions that are needed to be implemented * An implementation of the vkGetAccelerationStructureBuildSizesKHR function * Fixed the parameters for the create and destroy acceleration structure in MVKDevice * Added the current functions in vulkan.mm
Acceleration Structure and Raytracing in general does not seem to be supported before MacOS 11, so Xcode 11.7 will always fail. |
Then the parts of MoltenVK that deal with Acceleration Structures need to be inside |
Agreed. But before forcing that, we should discuss whether that makes sense at this point. Xcode 11 is now 4 years old, and at some point, we must give up support for it, from a practicality perspective (like this one). Retaining support for Xcode 11 was added a couple of years ago because some devs required it for their internal processes. A few months ago, I reached out to the community about this exact question, and received no responses. Unless we can determine a good reason for maintaining Xcode 11, maybe now is the time to drop support for it. |
@billhollings MacOS 11 seems to have support from devices as old as 2013 and newer. So it's a matter of dropping support of these pre-2013 devices, as well as that, some people stay on MacOS 10 for support of 32 bit applications and other reasons. This is just something to take into consideration. |
I have added a ping post to that feedback request thread. @AntarticCoder Hold off wrapping your code in any |
@billhollings Alright, I'll hold off on the |
The |
@billhollings Ah, yes my mistake. Also, just a thought but only about 120 people actually watch this repository, so I'm not sure how many people will see your message. |
898e09d
to
5e5c4a7
Compare
This commit adds: * A .h and .mm file for Acceleration Structure commands * An acceleration structure command encoder into `MVKCommandBuffer` * An actual acceleration structure handle * And some other items that are not complete, or need to removed
5e5c4a7
to
a1b0961
Compare
Fixed the missing symbol for getPoolType in MVKCmdBuildAccelerationStructure by including it in MVKCommandPool.h. I also added the Build Acceleration structure command into definitions file.
Finished up what was needed for the MVKCmdBuildAccelerationStructure. The only 2 issues at the moment are the scratch buffer and the scratch buffer offset, to which a solution has been proposed. I plan to discuss this in the PR thread before trying out anything.
@billhollings @cdavis5e An issue I've run into during this PR, is accessing the provided scratch buffer, via the provided device address. To solve this, I got a reply from @K0bin in issue #1956, which is as followed.
Basically create a map from scratch that is fast, and thread safe, and when you call |
This commit adds the copy acceleration structure, but does not add the commands that copy memory to and from an acceleration structure. As well as that I've added 2 files for a map that will store the device address along with the buffer. This map will also come in handy when getting the device address for the acceleration structure
It's probably better to do that at buffer creation time and keep vkGetBufferDeviceAddress fast. |
@K0bin But not every created buffer will be used via the device address. So if you pushed it on |
Base it off of VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT. |
Okay then, I'll get started on the implementation. Thanks @K0bin |
A half done implementation of MVKMap. MVKMap aims to use the same API as std::unordered_map, and I used MVKSmallVector as an example of how to write MVKMap. I hope there aren't any bugs however, I'll probably do some tests off of the repository once I'm done
Search for |
@billhollings That seems like a good idea, I'll go ahead and use that for now, and we can change it in the future if it's not getting the job done. |
This commit finished off the build acceleration structure command. This is because in MVKDevice, we are now using a std::unordered_map instead of a custom map implementation.
542c3f8
to
9aae084
Compare
6/12 commands have been implemented, so I'm halfway there. 🎉 |
Is there any news regarding this PR? I now own an M3 Max Macbook and could test if this is of interest. |
c688f5e
to
3937822
Compare
Our game studio is interested in cross-platform ray tracing with Vulkan, wondering whether there's been any progress here. |
Still not finished, just quickly saving my work on get build sizes
How do you intend to work around the fact that Metal needs a list of all bottom level acceleration structures to build the TLAS while Vulkan only needs a GPU buffer address that contains that data? You'll probably have to maintain a list that has every single BLAS and use that when creating the Metal TLAS. |
This commit is pretty small and just adds AABBs to be allowed to be pushed to the acceleration structure.
MVKTraceVulkanCallStart(); | ||
MVKDevice* mvkDev = (MVKDevice*)device; | ||
VkAccelerationStructureBuildSizesInfoKHR buildSizes = MVKAccelerationStructure::getBuildSizes(mvkDev, buildType, pBuildInfo); | ||
pSizeInfo = &buildSizes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pSizeInfo should be dereferenced
This commit adds the device command 'kCmdWriteAccelerationStructuresPropertiesKHR'.
…es' into address-map
Implement new address map for buffers
Would this work in something like RTX Remix? which uses a modified dxvk to translate DirectX to Vulkan RT. It would be interesting to see something like Portal RTX converted over for Mac |
Given that MoltenVK targets Apple family of devices, and RTX Remix is not. I will say though, that Remix does cover some strategies such as the Remix acceleration manager to provide a generic BLAS tracker which folks here may find useful to reference while implementing similar code. Anyways, this discussion isn't really relevant to the PR, so I will refrain from discussing further. |
Never say "never"... |
heh, I work on the RTX remix codebase a lot, this isn't on the roadmap. But sure, maybe one day ... :) |
Well I wasn't implying the RTX Remix devs would integrate it, given RTX Remix is open sourced, I was interested if it could be ported over for personal purposes |
And I am here to tell you that it is unlikely, considering that it would require RTX remix to be ported to apple. Maybe one day. Remix also only supports D3D9. An API which does not exist on Apple hardware, or is supported in any capacity through translation currently. I'm not following. Anyways, this is derailing the PR convo. |
This PR provides an implementation of the
VK_KHR_acceleration_structure
extension which provides a gateway to ray queries and ray tracing pipelines. This PR is still very WIP due to not being anywhere close to done. The reason for opening this PR so early on is to allow for more concrete discussion of the implementation of acceleration structures, and also keeps people up to date on the implementation.This PR is related to:
#427
#1953 - Not directly related but may have some slight discussion on Acceleration Structures
#1956