GxDevice class
#include <nCine/Graphics/RHI/GX/GxDevice.h>
Pipeline-state and draw-call facade of the GX backend (aliased as RHI::Device).
Mirrors the software device's surface, but instead of rasterizing on the CPU each draw decodes the bound program's instance block(s) exactly like SwDevice::Dispatch and emits fixed-function GX quads: the four sprite corners are CPU-transformed to logical screen pixels (the same math as the software FetchVertex), an orthographic projection over the logical resolution maps them onto the full EFB (which is how the logical-resolution scene is upscaled to the display for free), and the effect selected from the program label picks the texture/TEV configuration:
DefaultSpritefamily: textured quad,GX_MODULATEwith the instance colorPaletteRemapfamily: CI8 texture with the TLUT of the instance'spalOffsetrow; RG8 index+alpha textures use a per-row CPU-baked RGBA copy (see GxTexture::EnsureBakedRgba) NoTexturefamily: flat color quad (GX_PASSCLR)TileMapMeshfamily: a whole tile layer arrives as one triangle-list mesh (see DispatchTileMesh) and is submitted as batchedGX_QUADSruns sharing one texture/TEV setupTexturedBackgroundfamily: rendered as a plain textured quad (the per-pixel tunnel warp needs shaders; the flat fallback keeps those layers visible)Combine: intercepted - applies the queued CPU lightmap as a multiply quad plus the water tint bands (the direct-tier lighting contract shared with the software backend) Unknown effects log once and skip their draws.
Render targets are EFB copies: drawing into a bound GxRenderTarget renders to the EFB with the target's dimensions and is copied out (GX_CopyTex) into the attached texture's tiled store when the target is switched away, so the textured-background passes work. Render-target passes must precede the screen pass within a frame (the engine's viewport chain already orders them that way).
Public types
- struct ScissorState
- struct BlendingState
- struct DepthTestState
- struct CullFaceState
Public static functions
-
static auto GetFrameCounter() -> std::
uint32_t - Monotonic count of presented frames, used to detect "still referenced by the in-flight FIFO" resources.
- static auto FindGeneratedEffect(const char* program, const char* variant) -> const FixedFunctionGeneratedEffect*
- Returns the generated fixed-function effect of a (program, variant) key, or
nullptr. - static void SetBlendingEnabled(bool enabled)
-
static void SetBlendingFactors(nCine::
BlendingFactor srcRgb, nCine:: BlendingFactor dstRgb, nCine:: BlendingFactor srcAlpha, nCine:: BlendingFactor dstAlpha) - static auto GetBlendingState() -> BlendingState
- static void SetBlendingState(const BlendingState& state)
- static void SetDepthTestEnabled(bool enabled)
- static void SetDepthMaskEnabled(bool enabled)
- static auto GetDepthTestState() -> DepthTestState
- static void SetDepthTestState(const DepthTestState& state)
- static void SetCullFaceEnabled(bool enabled)
- static auto GetCullFaceState() -> CullFaceState
- static void SetCullFaceState(const CullFaceState& state)
- static auto GetScissorState() -> ScissorState
- static void SetScissorState(const ScissorState& state)
- static void SetScissor(const Recti& rect)
- static void SetScissorTestEnabled(bool enabled)
- static auto GetViewport() -> Recti
- static void SetViewport(const Recti& rect)
-
static void InitViewport(std::
int32_t x, std:: int32_t y, std:: int32_t width, std:: int32_t height) - static auto GetClearColor() -> Colorf
- static void SetClearColor(const Colorf& color)
- static void Clear(ClearFlags flags)
-
static void DrawArrays(PrimitiveType primitive,
std::
int32_t firstVertex, std:: int32_t numVertices) -
static void DrawArraysInstanced(PrimitiveType primitive,
std::
int32_t firstVertex, std:: int32_t numVertices, std:: int32_t numInstances) -
static void DrawElements(PrimitiveType primitive,
std::
uint32_t numIndices, IndexFormat indexFormat, std:: uintptr_t indexOffset, std:: int32_t baseVertex) -
static void DrawElements(PrimitiveType primitive,
std::
uint32_t numIndices, std:: uintptr_t indexOffset, std:: int32_t baseVertex) -
static void DrawElementsInstanced(PrimitiveType primitive,
std::
uint32_t numIndices, IndexFormat indexFormat, std:: uintptr_t indexOffset, std:: int32_t numInstances, std:: int32_t baseVertex) -
static void DrawElementsInstanced(PrimitiveType primitive,
std::
uint32_t numIndices, std:: uintptr_t indexOffset, std:: int32_t numInstances, std:: int32_t baseVertex) - static auto InsertFence() -> FenceHandle
- static void DeleteFence(FenceHandle& fence)
-
static auto ClientWaitFence(FenceHandle fence,
std::
uint64_t timeoutNs) -> bool - static void SetupInitialState()
-
static auto CreateSwapchain(void* windowHandle,
std::
int32_t width, std:: int32_t height, bool vsync) -> bool - No-op (the window backend owns the presentation path).
- static void DestroySwapchain()
- No-op.
-
static void ResizeSwapchain(std::
int32_t width, std:: int32_t height) - No-op (the logical resolution is driven by ResizeScreenFramebuffer() from the render pipeline).
- static void PresentFrame()
- No-op (the window backend calls PresentToXfb() itself).
-
static auto GetMaxTextureDimension() -> std::
int32_t - Returns the maximum supported texture dimension (drives the tileset chunking).
-
static void ResizeScreenFramebuffer(std::
int32_t width, std:: int32_t height) - Sets the logical resolution the scene is rendered at.
- static void InitializeGx(GXRModeObj* rmode)
- Brings up the GX pipe (FIFO, vertex descriptors, TEV baseline) for the given render mode.
- static void ShutdownGx()
- Drains the GX pipe and releases the FIFO, so no GP work is left pending at exit.
- static void PresentToXfb(void* xfb)
- Finishes the frame's draws, copies the EFB to the given external framebuffer and flushes.
- static void BindProgram(GxShaderProgram* program)
- Records the currently bound shader program.
- static auto CurrentProgram() -> GxShaderProgram*
- Returns the currently bound shader program.
-
static void BindTexture(std::
uint32_t unit, const GxTexture* texture) - Records the texture bound to a texture unit.
- static void UnbindTexture(const GxTexture* texture)
- Clears a texture from every unit it is bound to (called from ~GxTexture).
-
static auto GetBoundTexture(std::
uint32_t unit) -> const GxTexture* - Returns the texture bound to a texture unit.
-
static void BindUniformRange(std::
uint32_t index, const std:: uint8_t* data, std:: uint32_t size) - Records the host data range bound to a uniform binding point.
- static void SetRenderTarget(GxRenderTarget* renderTarget)
- Records the current draw render target (draws render to the EFB and are copied out on switch).
- static void UnbindRenderTarget(const GxRenderTarget* renderTarget)
- Clears a render target from the device if it is the current one (called from ~GxRenderTarget).
- static void RegisterPaletteTexture(GxTexture* texture)
- Registers the intercepted shared palette texture (rows become TLUTs).
-
static void NotifyPaletteTextureChanged(GxTexture* texture,
std::
int32_t firstRow, std:: int32_t rowCount) - Invalidates the TLUTs (and RG8 bakes) of the given palette rows after an upload.
-
static void SetPendingSoftwareLighting(const float* lightmap,
std::
int32_t lmW, std:: int32_t lmH, std:: int32_t scale, std:: int32_t vpX, std:: int32_t vpY, std:: int32_t vpW, std:: int32_t vpH, float ambR, float ambG, float ambB, bool waterActive = false, float waterLevelPx = 0.0f, float waterTime = 0.0f, float waterCamY = 0.0f) - Queues the CPU lightmap/water combine for the next
Combinedraw. - static void EndFrame()
- Drops any lighting entries not consumed this frame (called by the window backend at present).
Constructors, destructors, conversion operators
Function documentation
static const FixedFunctionGeneratedEffect* nCine:: RHI:: GX:: GxDevice:: FindGeneratedEffect(const char* program,
const char* variant)
Returns the generated fixed-function effect of a (program, variant) key, or nullptr.
Scans the table transpiled from the shaders' fixed_function blocks (Shaders/Generated/GxGeneratedEffects.h). Called once per program load from GxShaderProgram::SetObjectLabel(), which maps the object label onto the key through its exact-name table - the draw path only ever reads the stored pointer.
static void nCine:: RHI:: GX:: GxDevice:: ResizeScreenFramebuffer(std:: int32_t width,
std:: int32_t height)
Sets the logical resolution the scene is rendered at.
Called by the render pipeline (UpscaleRenderPass) on the direct tier. Draw coordinates arrive in this logical space; the orthographic projection maps it onto the full EFB, whose display copy the video hardware scales to the TV - the logical-to-display upscale costs nothing.
static void nCine:: RHI:: GX:: GxDevice:: SetPendingSoftwareLighting(const float* lightmap,
std:: int32_t lmW,
std:: int32_t lmH,
std:: int32_t scale,
std:: int32_t vpX,
std:: int32_t vpY,
std:: int32_t vpW,
std:: int32_t vpH,
float ambR,
float ambG,
float ambB,
bool waterActive = false,
float waterLevelPx = 0.0f,
float waterTime = 0.0f,
float waterCamY = 0.0f)
Queues the CPU lightmap/water combine for the next Combine draw.
The direct-tier lighting contract shared with the software backend (see CombineRenderer): the GX device consumes each entry by drawing the lightmap as a multiply quad plus the water tint bands.