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
Vulkan .pNext #843
Comments
Hey @tlf30, The typed physicalDeviceRayTracingPipelineProperties = VkPhysicalDeviceRayTracingPipelinePropertiesKHR.calloc()
.sType$Default();
physicalDeviceAccelerationStructureProperties = VkPhysicalDeviceAccelerationStructurePropertiesKHR.calloc()
.sType$Default();
physicalDeviceIDProperties = VkPhysicalDeviceIDProperties.calloc()
.sType$Default();
physicalDeviceProperties2 = VkPhysicalDeviceProperties2.calloc()
.sType$Default()
.pNext(physicalDeviceRayTracingPipelineProperties)
.pNext(physicalDeviceAccelerationStructureProperties)
.pNext(physicalDeviceIDProperties); Note that the typed overloads only exist on the "parent" struct. The siblings do not (need to) know each other. If this is inconvenient, you should probably use the untyped/pointer |
Thank you for the clarification @Spasi. Since those overloads provide additional functionality, perhaps it would be best if there was something in the name to indicate that, similar to |
It's a bit late for breaking API changes and I'm afraid a new name won't be less confusing. I'm more inclined to remove such helpers in LWJGL 4. It seems that whenever LWJGL tries to be clever, there are always users that stumble on unexpected/non-intuitive behavior. |
Hmm, maybe LWJGL should check that the input struct's |
Unfortunately, it is a trade off. While having additional functionality is great, having it hidden also makes it hard to know if it is there. In v4 perhaps all additional functionality is denoted some way as to clue in the developer that there may be more going on behind the scenes to investigate.
Would it be possible to do this: Basically, append what is given to what is already there?
If nothing else, this would be great. |
I agree with @tlf30. One of the powers of LWJGL is that it tries to mirror the original API as much as possible, but it's also great that LWJGL does include helpers for some minor functionality. This particular helper functionality has surprised me as well. I suggest renaming it in LWJGL 4 like above, or turning them into static helper methods. I don't really see any reason in removing them, when renaming them is all that's necessary to remove confusion. In fact, I actually wrote a method to replicate that exact behaviour before I noticed what these methods do, so this functionality is needed. |
Just implemented this as an experiment. Chain order does not matter, so I figured this would be a compatible change and... it isn't. This example from lwjgl3-demos: VkPhysicalDeviceAccelerationStructureFeaturesKHR accelerationStructureFeatures = VkPhysicalDeviceAccelerationStructureFeaturesKHR
.malloc(stack)
.sType$Default();
VkPhysicalDeviceRayTracingPipelineFeaturesKHR rayTracingPipelineFeatures = VkPhysicalDeviceRayTracingPipelineFeaturesKHR
.malloc(stack)
.sType$Default();
VkPhysicalDeviceBufferDeviceAddressFeaturesKHR bufferDeviceAddressFeatures = VkPhysicalDeviceBufferDeviceAddressFeaturesKHR
.malloc(stack)
.sType$Default();
vkGetPhysicalDeviceFeatures2(dev, VkPhysicalDeviceFeatures2
.calloc(stack)
.sType$Default()
.pNext(bufferDeviceAddressFeatures)
.pNext(rayTracingPipelineFeatures)
.pNext(accelerationStructureFeatures)); crashes with the new implementation. Turns out if we change prepending to appending all structs must initialize their |
@Spasi I believe you should just leave this functionality as-is without further modifications, until LWJGL 4. |
The identifiers with |
@rongcuid That’s an issue you should report to JetBrains, not LWJGL. IntelliSense/IntelliJ should be able to handle that. |
Well, the autocomplete problem surely belongs to JetBrains. But the dollar sign still makes it awkward to use in Kotlin:
|
@Spasi I think there is no action to take on this issue unless you would like to implemented the pointer chaining that you proposed. Eitherway, would you like me to close it? |
Hey @tlf30, Yes, closing this. I realized that my suggestion above about adding a The good news is that the existing javadoc already documents the prepend behavior. Everyone reads javadoc, right? 😅
My recommendation would be to just not use these methods. It's very likely that I won't implement them in LWJGL 4, might as well be ready for that. |
Haha, no, I don’t think we read all the JavaDoc. :P We expect all the methods to not do anything special, as long as they’re named the same as the VK struct members, which are documented at the class level JavaDoc. Occassionally we read the JavaDoc for the member functions (struct fields) too, but we don’t expect side-effects there.
You forgot that’s also the letter used when the native struct has a member named the same as an existing member of the generated Java class, or one of its superclasses. There’s a lot of them in the FT structs. |
Question
Hello,
on VkPhysicalDeviceProperties2 and VkPhysicalDeviceFeatures2 I recently ran into a scenario where I was using the pNext to set a pointer, but because in the code both VkPhysicalDeviceProperties2 and VkPhysicalDeviceFeatures2 overwrite the pNext of the structure being passed into them if the structure is one of the overridden types, it did not work as initially intended. After digging in the code I found where this was happening, and changed my code to pass the address of the struct to the pNext.
Example:
In this example, only the VkPhysicalDeviceIDProperties struct is actually passes to VkPhysicalDeviceProperties2 because in VkPhysicalDeviceProperties2 the function is overloaded as:
Which overwrites the pNext of the VkPhysicalDeviceIDProperties struct.
IIRC the vulkan C++ API does not do this (although I could be wrong).
Perhaps if this is additional functionality that is intended, the function could be renamed to
pNext$Append
Thank you,
Trevor
The text was updated successfully, but these errors were encountered: