Skip to content

Texture2DRD Global RenderingDevice Documentation #104489

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Akeal
Copy link

@Akeal Akeal commented Mar 22, 2025

Updated documentation to specify that Texture2DRD is only supported by the global rendering device.

Example:

In ...
texture_rd.cpp
_set_texture_rd_rid()

ERR_FAIL_COND(!RD::get_singleton()->texture_is_valid(p_texture_rd_rid));

This fail condition ensures that the rendering device global singleton owns the RID that is being assigned to the Texture2DRD, and errors if it is owned by another rendering device (is designated as not valid).

There are many other instances in texture_rd.cpp that call RD::get_singleton() as well.

@Akeal Akeal requested a review from a team as a code owner March 22, 2025 16:41
@Mickeon Mickeon requested a review from a team March 22, 2025 17:16
@Mickeon Mickeon added this to the 4.x milestone Mar 22, 2025
@Calinou
Copy link
Member

Calinou commented Jun 9, 2025

Is this intended behavior of Texture2DRD? If it's a bug, it should be reported in its own issue.

Also, does this apply to other *RD classes?

cc @clayjohn @BastiaanOlij

@AThousandShips AThousandShips changed the title Texture2DRD Global Renderingdevice Documentation Texture2DRD Global RenderingDevice Documentation Jun 9, 2025
@BastiaanOlij
Copy link
Contributor

@Calinou that's actually a really good question.

Yes in theory you could create TextureRD textures for a texture id created on a local rendering device instance BUT you wouldn't be able to actually use it.

TextureRD was added so we can wrap custom texture objects in a Texture object that can be used on materials. Those don't work across rendering devices (at this point in time), so there would never be a valid use case where TextureRD can be used outside of the global rendering device, hence the code assuming we're only dealing with texture id's created on the global rendering device and erroring out if you give it any other texture id.

That said, there have often been requests to make it possible to populate texture data on a local rendering device in a separate thread, where the end result is then used by the main renderer. However that would likely require either a transfer of the end result between contexts, or creating a shared texture object on the global rendering device and the TextureRD being related to the global rendering device texture id of this shared texture. Hard to say though until we actually have support for this (if we ever get there).

So my gut feeling is that at this point in time, the ERR_FAIL_COND should be in place on all these functions, and specifically naming the global rendering device in the documentation is probably a good idea.

@Mickeon
Copy link
Member

Mickeon commented Jun 17, 2025

So what should be done in this PR? Do you think it's a good idea as is?

I would recommend changing the commit and the title of this PR to be somewhat more descriptive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants