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
apply
functions added in 3.2.3 break existing Kotlin code
#554
Comments
apply
functions added in 3.2.3 breaks tons of existing Vulkan Kotlin codeapply
functions added in 3.2.3 break existing Vulkan Kotlin code
apply
functions added in 3.2.3 break existing Vulkan Kotlin codeapply
functions added in 3.2.3 break existing Kotlin code
(I don't know about tons, it's just mine afaik. But |
I don't think this does the same job -- here I do think that it may be slightly misleading for them to have the same name and similar signatures, but do very different things. |
So can it build with the latest version of kotlin? |
Your question is weirdly phrased. This has nothing to do with changes on the Kotlin side, the latest version of LWJGL just breaks my code in plenty of places. I do very liberal amounts of stackAlloc(1) to get singleton array of structs to pass into Vulkan in plenty of places where the API expects an array, since LWJGL doesn't offer overloads for the non-buffer variants. Using Kotlin's |
Oh. I see. |
Hey @Hugobros3, thanks for opening this issue. Adding these methods to However, I would like to point out that there's a ton of flexibility in Kotlin and there are trivial workarounds that don't sacrifice readability. As an example, I refactored some of the code in the posted screenshot and this is how I would have written it: val colorAttachmentReference = VkAttachmentReference.callocStack(outputsDeclaration.outputs.size)
colorAttachmentReference.forEachIndexed { index, ref -> ref
.attachment(index)
.layout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)
}
val subpassDescription = VkSubpassDescription.callocStack(1)
.pipelineBindPoint(VK_PIPELINE_BIND_POINT_GRAPHICS)
.pColorAttachments(colorAttachmentReference)
.colorAttachmentCount(colorAttachmentReference.capacity())
.pDepthStencilAttachment(if (!depth.enabled) null else VkAttachmentReference.callocStack()
.attachment(attachmentDescription.capacity() - 1)
.layout(
if (depth.write)
VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
else
VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
)
) This is shorter and I would argue cleaner than the original code. |
Well it was reported a year ago, it looks like the issue slipped under the cracks. It doesn't really matter too much, as you say, it's too late now, and personally I have moved in other directions. |
Release 3.2.3 brought a new
apply
method inStructBuffer
and thus clashes with the built-inapply
extension function available in Kotlin code. That apply function appears to do the same job but has a different calling convention from the Kotlin one (Kotlinapply
takes a lambda withthis
renamed to the object it's called on, whileStructBuffer
's takes a SAM ).The result of this is large portions of Kotlin code that use
StructBuffer
s are now broken (example here) and need tedious manual working around the issue. I have to say it's a very unfortunate oversight to have implemented any functionality that clashes with basic Kotlin stdlib functionality, especially given LWJGL itself uses Kotlin for various things internally.I'm not sure how to fix this, I admit it's been a while since I worked on my Kotlin game engine project. I'd say roll back the changes, but this already shipped so it's a matter of choosing whose code you'll break now. The middle ground might just be to rename the function ?
The text was updated successfully, but these errors were encountered: