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
Fix discrete GPU preference symbols being exported from the wrong place #1406
Conversation
I'm not sure if the top of Window.hpp is the right place to define this stuff. Maybe it would deserve its own header?
I don't know if it works with macros too, but you can use |
d60ea66
to
0f6660a
Compare
@LaurentGomila @MarioLiebisch I moved the definition into its own file and added a paragraph with a reference to it in Window.hpp. |
Shouldn't header be included in the top-level Window.hpp as well, so you don't specifically have to include the header and define the macro? |
I was thinking of providing this as a "convenience header" much like what |
I mean, it doesn't really do any harm in directly including it and potentially reduces one extra step when explaining how to use it. |
0f6660a
to
f3e1eec
Compare
@eXpl0it3r Done. |
include/SFML/GpuPreference.hpp
Outdated
/// the final executable. Typically it is best to place it | ||
/// where the main function is also defined. | ||
/// | ||
/// |
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.
Because I found nothing else to say: there's one empty line that should be removed here 😁
f3e1eec
to
f7c4e22
Compare
@LaurentGomila Fixed. |
Shouldn't it be part of current Window module? ie in SFML/Window/GpuPreference.hpp |
Theoretically you can use this macro even in a console application in which you only make use of sfml-network even though it wouldn't make much sense. I wouldn't go so far as to say it changes any behaviour we should handle differently. This also expresses a preference, not a demand, we can't and shouldn't rely on it having any effect. When choosing a spot to place it, I figured this has a similar purpose as |
I didn't notice that before, and yes I admit that it looks confusing. Either make it part of the window module and include it in SFML/Window.hpp, or leave it as a standalone functionality and don't include it in any module by default. Which solution to choose, I'm not sure 😬 |
Well... until now, the user could always assume that using something from an include file would imply having to link against that module as well. This works out for |
Ok, so let's keep it separate from the Window module. |
I didn't realize that it wasn't "part" of a module when I suggested to add it to |
Cna you revert it again, @binary1248? 😄 |
What do you mean with revert it again? |
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.
Maybe it's just me, but I'd consider it useful to rename this from GpuPreference
to GpuSelection
as it feels more intuitive. In addition, I'd also provide a second set of macros to prefer the on-board GPU even though they wouldn't do anything in your everyday app. It would still provide confirmation "yes, indeed use the on-board one!" though.
Remove it from the general Window.hpp as to keep it separate from the Window module. |
@MarioLiebisch Selection is misleading, because we don't select anything. We express a preference/hint. It is still up to the driver to pick a GPU for us. If the user chooses to do so, they can still override which GPU will be used. The opposite is also true, there is no way to express a preference for the iGPU. The hints only have an effect when they are exported and their values set to 1. Setting their values to 0 would be the same as not exporting them at all meaning "no preference". In that case it is up to the driver to guess which GPU to use. |
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.
Yeah, true.
How reliable would it be to try detect on-board cards and spit out a warning on context creation for debug builds in case the macro isn't used (e.g. due to not knowing about it)?
Not reliable at all? An iGPU in a hybrid graphics setup could be the only available GPU in another system. OpenGL also doesn't provide any reliable way of enumerating adapters like D3D or Vulkan does, so that is also sort of out of the question. |
f7c4e22
to
9a453ed
Compare
@eXpl0it3r Done. |
…t of sfml-main and into a macro the user can place in their own translation unit when they need it. Fixes #1192
9a453ed
to
cd13874
Compare
Moved NvOptimusEnablement and AmdPowerXpressRequestHighPerformance out of sfml-main and into a macro the user can place in their own translation unit when they need it.
The current implementation suffers from a bunch of problems:
__declspec(dllexport)
from a static library is just weird in itself anywayWith this change, the user will have full control over when they want this preference to be made, and the symbols will always be exported from the right place: the final executable. And there is the added bonus that this will actually show up in the documentation as well (might still be hard to find though).