libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
WutVideoDriver Class Reference

Wii U VideoDriver: GX2 + libwhb's WHBGfx* helpers. More...

#include <WutVideoDriver.h>

Inheritance diagram for WutVideoDriver:
[legend]

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).
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ WutVideoDriver()

WutVideoDriver::WutVideoDriver ( )

Definition at line 122 of file WutVideoDriver.cpp.

◆ ~WutVideoDriver()

WutVideoDriver::~WutVideoDriver ( )
override

Definition at line 128 of file WutVideoDriver.cpp.

Member Function Documentation

◆ clearScreen()

void WutVideoDriver::clearScreen ( const PixelColor & color)
overridevirtual

Clears the current frame buffer.

Implements VideoDriver.

Definition at line 585 of file WutVideoDriver.cpp.

◆ flushDrawQueue()

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.

◆ getDeltaTime()

float WutVideoDriver::getDeltaTime ( ) const
overridevirtual
Returns
the nominal frame period in seconds (1/getRefreshRate()); not a measured time

Implements VideoDriver.

Definition at line 595 of file WutVideoDriver.cpp.

◆ getFrameTimer()

uint32_t WutVideoDriver::getFrameTimer ( )
overridevirtual
Returns
the number of frames rendered so far (incremented once per render())

Implements VideoDriver.

Definition at line 580 of file WutVideoDriver.cpp.

◆ getGlyphRenderer()

GlyphRenderer * WutVideoDriver::getGlyphRenderer ( )
inlineoverridevirtual
Returns
the renderer GuiTextRenderer draws glyphs through

Implements VideoDriver.

Definition at line 100 of file WutVideoDriver.h.

◆ getImageRenderer()

ImageRenderer * WutVideoDriver::getImageRenderer ( )
inlineoverridevirtual
Returns
the renderer GuiImage/GuiImageData draw through

Implements VideoDriver.

Definition at line 99 of file WutVideoDriver.h.

◆ getRefreshRate()

int WutVideoDriver::getRefreshRate ( ) const
overridevirtual
Returns
the display refresh rate in Hz (50 for PAL/576i output, otherwise 60)

Implements VideoDriver.

Definition at line 590 of file WutVideoDriver.cpp.

◆ getScreenHeight()

int WutVideoDriver::getScreenHeight ( ) const
inlineoverridevirtual
Returns
the design canvas height in pixels (as passed to init())

Implements VideoDriver.

Definition at line 85 of file WutVideoDriver.h.

◆ getScreenWidth()

int WutVideoDriver::getScreenWidth ( ) const
inlineoverridevirtual
Returns
the design canvas width in pixels (as passed to init())

Implements VideoDriver.

Definition at line 84 of file WutVideoDriver.h.

◆ getTargetHeight()

int WutVideoDriver::getTargetHeight ( OutputTarget target) const
inline

Definition at line 97 of file WutVideoDriver.h.

◆ getTargetWidth()

int WutVideoDriver::getTargetWidth ( OutputTarget target) const
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.

◆ getUIScale()

float WutVideoDriver::getUIScale ( ) const
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.

◆ init()

void WutVideoDriver::init ( int width,
int height )
overridevirtual
Parameters
widthDesign canvas width in pixels
heightDesign canvas height in pixels

Implements VideoDriver.

Definition at line 142 of file WutVideoDriver.cpp.

◆ isForeground()

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.

◆ isPresentPending()

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.

◆ prepareFrame()

void WutVideoDriver::prepareFrame ( unsigned targets = kAllTargets)

Definition at line 229 of file WutVideoDriver.cpp.

◆ presentBuffer()

void WutVideoDriver::presentBuffer ( )

Definition at line 556 of file WutVideoDriver.cpp.

◆ queueDraw()

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.

◆ queueMesh()

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().

Parameters
verticesTriangle list in design-canvas pixels
countNumber of vertices

Definition at line 317 of file WutVideoDriver.cpp.

◆ queueMeshInstance()

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().

Parameters
meshMesh to draw
xWhere the mesh's (0,0) lands, design-canvas pixels
yWhere the mesh's (0,0) lands, design-canvas pixels
scaleXHorizontal stretch about (x,y)
scaleYVertical stretch about (x,y)

Definition at line 352 of file WutVideoDriver.cpp.

◆ render()

void WutVideoDriver::render ( )
overridevirtual

Flushes the current frame to the screen and swaps buffers.

Implements VideoDriver.

Definition at line 303 of file WutVideoDriver.cpp.

◆ retireMesh()

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.

◆ setUiTargets()

void WutVideoDriver::setUiTargets ( unsigned mask)
inline

Definition at line 154 of file WutVideoDriver.h.

◆ shutdown()

void WutVideoDriver::shutdown ( )
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.

◆ waitForIdle()

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.

Member Data Documentation

◆ kAllTargets

const unsigned WutVideoDriver::kAllTargets = 3
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.


The documentation for this class was generated from the following files: