Wii U VideoDriver: GX2 + libwhb's WHBGfx* helpers. More...
#include <WutVideoDriver.h>
Public Member Functions | |
| void | init (int width, int height) override |
| void | shutdown () override |
| Releases the video backend. Call after every other user of the renderers has finished. | |
| void | render () override |
| Flushes the current frame to the screen and swaps buffers. | |
| void | clearScreen (const PixelColor &color) override |
| Clears the current frame buffer. | |
| int | getScreenWidth () const override |
| int | getScreenHeight () const override |
| uint32_t | getFrameTimer () override |
| int | getRefreshRate () const override |
| float | getDeltaTime () const override |
| float | getUIScale () const override |
| Ratio of physical render-target pixels to design-canvas pixels (the width/height passed to init()). | |
| int | getTargetWidth (OutputTarget target) const |
| Physical pixel size of a render target (the TV follows the console's output setting, the GamePad is always 854x480). | |
| int | getTargetHeight (OutputTarget target) const |
| ImageRenderer * | getImageRenderer () override |
| GlyphRenderer * | getGlyphRenderer () override |
| bool | isForeground () const |
| False once the OS has taken away the foreground (HOME menu overlay, forced exit, etc.) - GX2 is off-limits at that point, so every draw/render entry point below checks this first and no-ops rather than issuing a GX2 call into a context we no longer own. | |
| void | presentBuffer () |
| void | queueDraw (const WutDrawCmd &cmd) |
| Records a UI draw for the next flushDrawQueue(). | |
| void | queueMesh (const MeshVertex *vertices, size_t count) |
| Copies a triangle list into this frame's vertex arena (converting positions to NDC) and records a Mesh draw. | |
| void | queueMeshInstance (const WutMesh *mesh, float x, float y, float scaleX, float scaleY) |
| Records a draw of a mesh made by WutImageRenderer::createMesh(). | |
| void | retireMesh (WutMesh *mesh) |
| Sets a mesh aside to be freed once the GPU is done with every frame that might draw it. | |
| void | flushDrawQueue () |
| Replays every recorded UI draw into the TV context, then the same list into the GamePad context, and empties the list. | |
| void | setUiTargets (unsigned mask) |
| void | waitForIdle () |
| Waits until the GPU has retired the last submitted frame. | |
| void | prepareFrame (unsigned targets=kAllTargets) |
| bool | isPresentPending () const |
| True while the last presented frame has not finished: not yet on screen (the swap is waiting for the next vsync) or the GPU is still drawing it. | |
Static Public Attributes | |
| static const unsigned | kAllTargets = 3 |
| Which outputs flushDrawQueue() replays into (bit per OutputTarget: 1 << TV, 1 << DRC). | |
Wii U VideoDriver: GX2 + libwhb's WHBGfx* helpers.
Every frame's draws are submitted twice - once for the TV, once for the GamePad - so the same UI always reaches both screens; there's no separate dual-display mode. UI draws are recorded into a list and replayed per target (one context switch each) rather than switching targets around every single draw.
Definition at line 73 of file WutVideoDriver.h.
| WutVideoDriver::WutVideoDriver | ( | ) |
Definition at line 122 of file WutVideoDriver.cpp.
|
override |
Definition at line 128 of file WutVideoDriver.cpp.
|
overridevirtual |
Clears the current frame buffer.
Implements VideoDriver.
Definition at line 585 of file WutVideoDriver.cpp.
| void WutVideoDriver::flushDrawQueue | ( | ) |
Replays every recorded UI draw into the TV context, then the same list into the GamePad context, and empties the list.
Does nothing when the list is empty. presentBuffer() calls this; direct GX2 drawing that must land on top of (or under) queued UI draws, and anything that frees a texture a queued draw may reference, must call it first to keep ordering. Leaves the GamePad context bound.
Definition at line 523 of file WutVideoDriver.cpp.
|
overridevirtual |
Implements VideoDriver.
Definition at line 595 of file WutVideoDriver.cpp.
|
overridevirtual |
Implements VideoDriver.
Definition at line 580 of file WutVideoDriver.cpp.
|
inlineoverridevirtual |
Implements VideoDriver.
Definition at line 100 of file WutVideoDriver.h.
|
inlineoverridevirtual |
Implements VideoDriver.
Definition at line 99 of file WutVideoDriver.h.
|
overridevirtual |
Implements VideoDriver.
Definition at line 590 of file WutVideoDriver.cpp.
|
inlineoverridevirtual |
Implements VideoDriver.
Definition at line 85 of file WutVideoDriver.h.
|
inlineoverridevirtual |
Implements VideoDriver.
Definition at line 84 of file WutVideoDriver.h.
|
inline |
Definition at line 97 of file WutVideoDriver.h.
|
inline |
Physical pixel size of a render target (the TV follows the console's output setting, the GamePad is always 854x480).
Unrelated to the design canvas returned by getScreenWidth()/getScreenHeight(), which is stretched onto each target independently per axis.
Definition at line 96 of file WutVideoDriver.h.
|
inlineoverridevirtual |
Ratio of physical render-target pixels to design-canvas pixels (the width/height passed to init()).
Greater than 1.0 wherever the driver upscales the design canvas to fill a higher-resolution.
Reimplemented from VideoDriver.
Definition at line 90 of file WutVideoDriver.h.
|
overridevirtual |
| width | Design canvas width in pixels |
| height | Design canvas height in pixels |
Implements VideoDriver.
Definition at line 142 of file WutVideoDriver.cpp.
| bool WutVideoDriver::isForeground | ( | ) | const |
False once the OS has taken away the foreground (HOME menu overlay, forced exit, etc.) - GX2 is off-limits at that point, so every draw/render entry point below checks this first and no-ops rather than issuing a GX2 call into a context we no longer own.
Definition at line 224 of file WutVideoDriver.cpp.
| bool WutVideoDriver::isPresentPending | ( | ) | const |
True while the last presented frame has not finished: not yet on screen (the swap is waiting for the next vsync) or the GPU is still drawing it.
Presenting now would make prepareFrame()/presentBuffer() wait for it. A caller that must not block checks this first.
Definition at line 275 of file WutVideoDriver.cpp.
| void WutVideoDriver::prepareFrame | ( | unsigned | targets = kAllTargets | ) |
Definition at line 229 of file WutVideoDriver.cpp.
| void WutVideoDriver::presentBuffer | ( | ) |
Definition at line 556 of file WutVideoDriver.cpp.
| void WutVideoDriver::queueDraw | ( | const WutDrawCmd & | cmd | ) |
Records a UI draw for the next flushDrawQueue().
Called by the renderers below; must be called from the thread that draws.
Definition at line 309 of file WutVideoDriver.cpp.
| void WutVideoDriver::queueMesh | ( | const MeshVertex * | vertices, |
| size_t | count ) |
Copies a triangle list into this frame's vertex arena (converting positions to NDC) and records a Mesh draw.
A mesh that does not fit in what is left of the arena this frame is dropped. Same threading rule as queueDraw().
| vertices | Triangle list in design-canvas pixels |
| count | Number of vertices |
Definition at line 317 of file WutVideoDriver.cpp.
| void WutVideoDriver::queueMeshInstance | ( | const WutMesh * | mesh, |
| float | x, | ||
| float | y, | ||
| float | scaleX, | ||
| float | scaleY ) |
Records a draw of a mesh made by WutImageRenderer::createMesh().
Nothing is copied: the mesh must stay alive until the draw has run, which destroyMesh() guarantees by handing it to retireMesh().
| mesh | Mesh to draw |
| x | Where the mesh's (0,0) lands, design-canvas pixels |
| y | Where the mesh's (0,0) lands, design-canvas pixels |
| scaleX | Horizontal stretch about (x,y) |
| scaleY | Vertical stretch about (x,y) |
Definition at line 352 of file WutVideoDriver.cpp.
|
overridevirtual |
Flushes the current frame to the screen and swaps buffers.
Implements VideoDriver.
Definition at line 303 of file WutVideoDriver.cpp.
| void WutVideoDriver::retireMesh | ( | WutMesh * | mesh | ) |
Sets a mesh aside to be freed once the GPU is done with every frame that might draw it.
Safe from any thread.
Definition at line 381 of file WutVideoDriver.cpp.
|
inline |
Definition at line 154 of file WutVideoDriver.h.
|
overridevirtual |
Releases the video backend. Call after every other user of the renderers has finished.
Implements VideoDriver.
Definition at line 218 of file WutVideoDriver.cpp.
| void WutVideoDriver::waitForIdle | ( | ) |
Waits until the GPU has retired the last submitted frame.
Nothing happens if no frame is in flight or the foreground is gone. Anything about to write to (or free) memory a submitted frame may still be sampling must call this first. prepareFrame() does.
Definition at line 287 of file WutVideoDriver.cpp.
|
static |
Which outputs flushDrawQueue() replays into (bit per OutputTarget: 1 << TV, 1 << DRC).
Default is both. A UI overlay for one output sets it around its draws, so even a queue overflow part way through cannot put them on the other. Always restore it to kAllTargets.
Definition at line 153 of file WutVideoDriver.h.