Expose RenderingServer methods to get rendering driver and method name#85430
Conversation
7d43035 to
91cb11d
Compare
91cb11d to
7ae69b7
Compare
|
Exposing this makes sense to me, but I wonder why we put it in Wouldn't it be more appropriate in We could still move the C++ |
c006e7f to
c8c72e9
Compare
I've moved the exposed method to Engine in a separate commit (should be squashed before merging). It still works after testing. I chose to keep the internal method in OS to avoid any risk of regressions and preserve compatibility. The rendering driver has OS-specific interactions in particular, with ANGLE, Direct3D, etc. |
|
Should |
c8c72e9 to
eeebd19
Compare
Done (I also added a mention of |
|
Should this be removed? |
This enum is useless for now, there is nothing using this. |
huwpascoe
left a comment
There was a problem hiding this comment.
Probably this enum should be deleted
https://docs.godotengine.org/en/stable/classes/class_os.html#enum-os-renderingdriver
And then it's good
The problem with that is that we now have a discrepancy between the core C++ API (method in So if it can't be moved from |
Is this the only merge blocker? Testing games is getting harder, now that the RD renderers support multiple drivers. For example, a common problem is that some GPUs come with bad Vulkan drivers, but good D3D12 drivers. Being able to know the currently used rendering driver is important for end-users to know how best to play our games. |
These are the changes needed to keep things consistent: akien-mga@3a1117c WDYT @clayjohn? Alternatively, we can keep it in OS and expose it in OS to scripting. |
|
We discussed in the rendering meeting. We think that we should investigate exposing it through the RenderingServer as that is the most natural place for these methods to exist. While the indirection is awkward, it should be much nicer from a user point of view |
Done. While I'm thinking about it, I wonder if I should name the exposed methods as such:
Right now, we have the following which is inconsistent:
We don't have exposed enums for the rendering drivers and methods (an unexposed enum for the rendering driver already exists). We should probably add one for the rendering method and expose both enums. This would allow creating and exposing the following enum-based methods:
This would allow users to make comparisons that are not string-based, therefore not being prone to typos (while also allowing for autocompletion to work). We should probably decide on this before merging the PR, as changing method names later on would break compatibility. What do you think? |
This is useful for troubleshooting purposes and debug menus.
eeebd19 to
4a70ac2
Compare
|
TIWAGOS and I'd let the rendering team decide, but yes I feel exposing an enum version of those methods might make sense. And our internal code should likely also be refactored to use the enums, the string comparisons we have throughout the rendering code are a bit awkward. |
|
Is it worth to make it enum? |
|
Regardless of the outcome, there's an existing enum that despite being exposed, doesn't seem to be referenced anywhere: |
Ah, that's what I meant actually. The enum is exposed, it's just not usable anywhere in the scripting API since no methods return it. |
|
We discussed using enums for a very long time during the initial 4.0 rewrite. I was in favour of them at the time. But the consensus was that we wanted to eventually allow people to add new rendering methods and rendering drivers through GDextensions. Having a closed enum would make that very challenging. |
|
I agree, that using Strings allows for future expansion and adding additional renderers at runtime using GDExtensions. However, it would be great to have a way to validate the string values. An option would be to have a and Dictionary RenderingServer::get_supported_rendering_methods() In these dictionaries the keys would be the valid settings of the get_current_rendering_*() methods, while the values could be an additional Dictionaries with information specific to the driver / rendering methods (could even be reserved for future use). That said, I think that this should be implemented in a separate PR. |
|
I'd like to chime in if I may: I was researching whether or not it was possible to check the rendering method idiomatically, because I wanna use a feature unavailable in the |
This can be achieved in 4.3 with the following code: if ProjectSettings.get_setting_with_override("rendering/renderer/rendering_method") == "gl_compatibility":
print("Using Compatibility")
else:
print("Using Forward+/Mobile")The The downside of this approach is that it doesn't take CLI argument overrides into account, nor automatic fallbacks that may happen on unsupported GPUs (but this isn't implemented in 4.3 anyway, only 4.4). |
| String RenderingServer::get_current_rendering_driver_name() const { | ||
| // Needs to remain in OS, since it's actually OS that interacts with it, but it's better exposed here. | ||
| return ::OS::get_singleton()->get_current_rendering_driver_name(); | ||
| } |
There was a problem hiding this comment.
I would still challenge this comment. In what way does OS interact with this? It just seems like the value was parked there for ease of access, but it could as well be in RenderingServer a priori. It's mostly set from DisplayServer implementations which should have access to both singletons.
I'll have a look to confirm.
There was a problem hiding this comment.
I've confirmed these can be moved to RenderingServer without problems with akien-mga@3a94368.
So I think we should do it properly (amending in my commit should do the trick).
And also moved OS::_is_gles_over_gl that similarly doesn't need to be in OS, and removed the getter for _display_driver_id, was never used since it was added in 2020.
There was a problem hiding this comment.
Actually some CI tests are failing with my branch. I'll look into it further. Seems like the editor crashes on start.
akien-mga
left a comment
There was a problem hiding this comment.
I still insist we do this properly by moving the C++ members to RenderingServer too.
| String RenderingServer::get_current_rendering_driver_name() const { | ||
| // Needs to remain in OS, since it's actually OS that interacts with it, but it's better exposed here. | ||
| return ::OS::get_singleton()->get_current_rendering_driver_name(); | ||
| } |
There was a problem hiding this comment.
I've confirmed these can be moved to RenderingServer without problems with akien-mga@3a94368.
So I think we should do it properly (amending in my commit should do the trick).
And also moved OS::_is_gles_over_gl that similarly doesn't need to be in OS, and removed the getter for _display_driver_id, was never used since it was added in 2020.
akien-mga
left a comment
There was a problem hiding this comment.
I admit defeat for now, would need to look a bit more into why the editor crashes if the C++ getter is moved to RenderingServer. I still think this could be done, but requires more work, which could be done later.
|
Thanks! |
This is useful for troubleshooting purposes and debug menus, as it obeys automatic fallbacks and CLI arguments unlike when reading the project settings.
This also improves related documentation in ProjectSettings.
PS:
--headlessdoesn't use thedummydriver that is listed in the list of valid rendering drivers when using--rendering-driver list. Is that expected? For this reason, I didn't list it in the documentation.