-
Notifications
You must be signed in to change notification settings - Fork 298
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
Use legacy texture creation for mac and linux #1009
Conversation
Thanks for the pull request @nithinp7!
Reviewers, don't forget to make sure that:
|
The next texture creation stuff seems to be working fine on my Android phone, even before this PR. I foolishly merged ue5-main into this branch, though. So I'll merge it there and then merge the one commit into ue4-main. |
This is strange though isn't it, that Vulkan on Android is working fine, but Vulkan on Linux is not? Any idea why the difference? |
c2d4899
to
f539803
Compare
I force-pushed to switch this back to ue4-main instead. |
There's a comment: "Legacy texture creation code path. Only for testing, no safety checks are done." After this PR, we're not using it only for testing anymore. Do we need to add some safety checks? |
@kring I just looked over the code again, nothing looks particularly unsafe even though I hadn't originally intended to use it beyond testing. I think we can assume the MipPositions from Cesium Native are valid, beyond that I can't think of any other issue with it - I can remove that comment. |
I can't seem to get the Vulkan preview rendering to work in UE5.1 to test this theory, but this seems odd... At the end of
But then in |
@kring I probably did not arrive at the most sensible structure for this, I tried to abstract the image source concept but it probably made things more confusing. I think maybe the answer to what you asked about is in this overload of
The image index is a temporary replacement for an image pointer, so that the actual pointer can be re-resolved as needed during the game thread part of the loading. So before the actual game thread loading commences, this function is called which substitutes the image index for an image pointer again, using the model. I did it this way so the other loadTextureInGameThread didn't require a "model" since the texture could be from anywhere (e.g., raster overlay). |
Also I'll repeat what I mentioned offline that I tried Vulkan on Windows (with main), this time in UE5.1 and did not have any issues. So I wonder if there is something platform-specific in the Linux case. Regarding mac, there may be a more obvious RHI level issue that we can solve - since I never really tested the new-ish texture code with Metal. |
@nithinp7 I finally was able to package the plugin for UE 5.1 and run the samples on my Linux system, and can confirm it worked fine even before this PR. With Vulkan:
|
I spoke too soon. A release build installed as an engine plugin works fine. A debug build embedded in the project crashes with an error like this:
I also saw this one time, which might be a red herring or it might be a clue:
|
The crash happens while trying to create a raster overlay texture. The image isn't null, but it points to memory that is corrupt (most likely a use-after-free). I think that there's a race condition here, and it just happens to only show up consistently with certain configurations on certain platforms. Here's my best understanding of the sequence of events:
I'm not certain that step (4) is happening, though. Or why. It seems a little surprising to be freeing a raster so early. This should be easy to verify, but debugging UE on Linux is an extraordinarily slow process for some reason (like, it takes 10 minutes to start up). So I'm just reporting what I know for now. But assuming the above is close to right, I'm not completely sure what to do about it. It will be tricky to completely avoid this sort of race condition. |
Thanks for looking into this @kring! I think I was finally able to reproduce this on Windows with Vulkan, probably the same underlying issue. I set the raster tile cache size to 0 and spammed the "Refresh Tileset" button and it seems to be a good way to catch that race condition, where the raster tile is freed before the render thread creation task is complete. One option is we could create a new fence around the render thread texture creation and check that during |
@kring I can move this idea to a different issue once I work it out but: The main motivation for the rambling below is that it would be nice to be able to do something like e.g., pass around I was thinking recently about how both The advantage of decoupling those is that we can provide a lot more implementation-specific features in the new image class. Some of these features would feel very awkward in
|
@kring I think Vulkan (and almost certainly Metal as well) should be working fine now. The old texture creation path is used for any device where When all the shaders were compiling for Vulkan, I ran into an error message and debug assertion "Array resized during ranged-for iteration". I couldn't see how that was related to this last change (or anything in this PR for that matter). Now that the shaders are done compiling I can't seem to run into that assertion failure at all. I tried making dummy changes to the material to retrigger shader compiling, but it doesn't seem to cause the assertion failure anymore. Please keep an eye out for that one, but I'll keep trying to reproduce it on my end. |
Thanks @nithinp7! |
Hopefully this is a workaround for #1007, although it would be slightly better to get the current texture creation path to work for mac and linux. Both the Vulkan and Metal RHI implementations in Unreal do not have async texture creation implemented, so the current texture creation path on these platforms does the next best thing by avoiding a texture memcpy on the game thread (by wrapping the source texture memory into an Unreal-specific interface for direct GPU upload). But it won't be a huge loss to go back to the legacy texture creation code paths on these platforms.
TODO: