-
Notifications
You must be signed in to change notification settings - Fork 81
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
Display Helpers #1566
base: master
Are you sure you want to change the base?
Display Helpers #1566
Conversation
4a8be46
to
c6b8a3f
Compare
// aspect ratio is good - add the mode to the list | ||
plDisplayMode plasmaMode; | ||
plasmaMode.ColorDepth = 32; | ||
plasmaMode.Width = int(CGDisplayModeGetWidth(mode)); | ||
plasmaMode.Height = int(CGDisplayModeGetHeight(mode)); | ||
|
||
fDisplayModes.push_back(plasmaMode); |
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.
Should probably use emplace_back()
to construct in place (avoids copying).
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.
Looking at this - we'd need to define a constructor on plDisplayMode. There is an alternative - but I'm not sure it avoids a copy.
// aspect ratio is good - add the mode to the list
fDisplayModes.emplace_back() = {
int(CGDisplayModeGetWidth(mode)),
int(CGDisplayModeGetHeight(mode)),
32
};
FYI - C++20 emplace_back can initialize structs directly without a constructor.
@@ -357,6 +367,9 @@ class plPipeline : public plCreatable | |||
|
|||
float fBackingScale = 1.0f; | |||
void SetBackingScale(float scale) { fBackingScale = scale; }; | |||
|
|||
std::shared_ptr<plDisplayHelper> fDisplayHelper; |
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.
Probably want a better ownership model than shared pointer.
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.
Both the client and the pipeline need access to the display helper. I could roll this back so that the reference is owned by the client.
A few high-level thoughts:
|
c6b8a3f
to
665cde2
Compare
665cde2
to
8421682
Compare
Digging this PR back out - @dpogue I think you are right. One issue is that the client makes a lot of decisions about resolution - but it does it before the pipeline is necessarily available. One possible issue is the divergent views on if resolution selection is part of the graphics API or the platform API. Apple feels that it's platform API, but Microsoft sees it as a graphics API issue at least under D3D9. Other pipelines like OpenGL/Vulkan could cause further chaos, especially if you had one accelerator that supported one set of APIs and another adapter that supported a different set. There are probably Win32 APIs to map a display to resolutions that I'm not aware of. That might be a good solution. But the display helper still includes some graphics API related code to check capabilities. |
There's also overlap going on between this display helper class and DeviceEnumerator. |
I have mostly avoided thinking about this because (as you mentioned) with OpenGL is becomes a complicated nightmare that can't really be done at the driver level. I agree with the idea that the display mode stuff should be at the plClient/windowing level rather than the pipeline level, although I see how we might still want to filter that list of modes based on capabilities of the pipeline render device. The original Direct3D renderer used exclusive fullscreen, which presumably is where it's important to use the driver to enumerate the supported modes. We replaced that with fake-fullscreen though, so it might be less important to use that now vs using standard Win32 APIs to ask for the supported resolutions. I'm imagining something like |
We might need a display handle to go along with that (along with a re-review of where else this concept is already encapsulated in the pipeline.) Resolutions are going to be per display - and it would be good to clean that whole thing up while we're putting in new plumbing. The client will probably need to vend which display the window is currently on, and broadcast any changes. |
plClient does querying of the possible display modes in it’s constructor. For now - using a singleton as a way to set a global display helper before this process starts. Keeping display helpers in the plPipeline family. It’s possible it belongs at a lower level alongside hsG3DDeviceMode in since display helpers are platform and not render specific.
e422ccf
to
d0acae6
Compare
Thinking this through (and the memory lifecycle issues)... I've baked the concept of display helpers into the app as another object needed by the pipeline. But another option is that I push it through as a hsWindowHndl via SetClientDisplay and act as if the display helper type is the display. Downside is that the client itself wouldn't be clear on the meaning of the hsWindowHndl (which so far seems to be mostly just used by Windows.) We wouldn't know what it should be cast to. But things like the Metal pipeline could assume. |
Looking for feedback on this concept. Direct3D is funny in that it directly includes display mode queries as part of its API. For Metal - and OpenGL particularly - things are a bit more interesting. The display mode API is separate from the graphics API.
This PR adds display helpers as a structure to try to bridge a specific renderer to a platform specific implementation.
I'm not sure how this fits with enumerations - it's possible that this integration needs to happen at a deeper level in the code.