-
-
Notifications
You must be signed in to change notification settings - Fork 21.9k
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
Expose a function to create textures from a native handle in the compatibility renderer #96928
Expose a function to create textures from a native handle in the compatibility renderer #96928
Conversation
a3fe3a4
to
290570a
Compare
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.
LGTM, as discussed already on rocketchat, this is a much better name to prevent confusion with Android external textures.
@@ -1108,6 +1108,195 @@ void TextureStorage::texture_proxy_initialize(RID p_texture, RID p_base) { | |||
tex->proxies.push_back(p_texture); | |||
} | |||
|
|||
// Note: We make some big assumptions about format and usage. If developers need more control, | |||
// they should use RD::texture_create_from_extension() instead. |
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.
Is it correct this comment refers to texture_create_from_extension
?
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.
Yep! This PR adds RenderingServer::texture_create_from_native_handle()
which is implemented by both OpenGL and the rendering device renderers, but if you're using rendering device you can get more control by using the pre-existing RenderingDevice::texture_create_from_extension()
which has more options. I put a similar note in the docs.
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.
I think the rename you chose to go with is suitable. Code LGTM!
…atibility renderer
290570a
to
7d56b09
Compare
Thanks! |
There is already a function in the compatibility renderer to create a texture from a native handle, however, it is unexposed and badly named, which is
GLES3::TextureStorage::texture_create_external()
.We need to expose it in order to implement some OpenXR extensions via GDExtension in the 'godot_openxr_vendor' repo.
But it is badly named, because there is an effort to add support for
GL_TEXTURE_EXTERNAL_OES
(see PR #96705 and #83519), and since that is from official GLES extensions, it would be better to call that an "external texture", and rename the existing function to something else.We discussed a number of names for this over here, but I ended up going with something else in this PR:
RenderingServer::texture_create_from_native_handle()
(which I picked because it pairs withRenderingServer::texture_get_native_handle()
).I'm happy to continue discussing names for this if folks don't like it!
NOTE: There is already function for doing this when using rendering device,
RenderingDevice::texture_create_from_extension()
(also not named very well :-)), which allows configuring many RD-specific options. Since this PR adds a function toRenderingServer
, we also need to implement it for the RD renderer, but it just callsRenderingDevice::texture_create_from_extension()
while making a bunch of assumptions for the RD-specific options. Most folks using the RD render would probably be better off using the RD-specific function, rather than the generic one onRenderingServer
, which I've noted in the docs.