nCine::RHI::PVR::PvrDevice class

Pipeline-state and draw-call facade of the PVR backend (aliased as RHI::Device).

The Dreamcast twin of the GX device: each draw decodes the bound program's instance block(s) exactly like SwDevice::Dispatch, CPU-transforms the four sprite corners to logical pixels and submits them as PowerVR translucent-list quads in display coordinates (the logical-to-640x480 scale is folded into the vertex positions). The TA renders one scene per frame, so the device runs a small scene state machine: the first draw of a frame opens the scene (pvr_scene_begin / pvr_scene_begin_txr for a render target) and its translucent list; switching targets or presenting finishes it. Autosort is disabled at init, so the translucent list preserves submission order - the engine's painter's-order queue maps 1:1.

Per-effect texture selection mirrors the GX device: CI8-style draws pick one of the four hardware palette banks from the instance's palOffset (LRU), RG8 index+alpha textures use the per-row ARGB4444 bake, NoTexture draws submit untextured colored quads, and the Combine draw applies the queued CPU lightmap as a dst * src multiply quad plus the water tint bands.

Public types

struct ScissorState
struct BlendingState
struct DepthTestState
struct CullFaceState

Public static functions

static auto GetSceneCounter() -> std::uint32_t
Monotonic count of finished scenes, used to detect "still referenced by the current scene" 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()
Finishes the frame's TA scene (called by the Dc window backend once per frame).
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 (scaled to 640x480 at submit).
static void InitializePvr()
Brings up the PVR (pvr_init with autosort disabled, background color, palette format).
static void BindProgram(PvrShaderProgram* program)
Records the currently bound shader program.
static auto CurrentProgram() -> PvrShaderProgram*
Returns the currently bound shader program.
static void BindTexture(std::uint32_t unit, const PvrTexture* texture)
Records the texture bound to a texture unit.
static void UnbindTexture(const PvrTexture* texture)
Clears a texture from every unit it is bound to (called from ~PvrTexture).
static auto GetBoundTexture(std::uint32_t unit) -> const PvrTexture*
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(PvrRenderTarget* renderTarget)
Records the current draw render target (draws open a render-to-texture scene).
static void UnbindRenderTarget(const PvrRenderTarget* renderTarget)
Clears a render target from the device if it is the current one (called from ~PvrRenderTarget).
static void RegisterPaletteTexture(PvrTexture* texture)
Registers the intercepted shared palette texture (rows become palette banks).
static void NotifyPaletteTextureChanged(PvrTexture* texture, std::int32_t firstRow, std::int32_t rowCount)
Invalidates the palette banks (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 Combine draw (the direct-tier lighting contract).
static void EndFrame()
Drops any lighting entries not consumed this frame (called by the window backend at present).

Constructors, destructors, conversion operators

PvrDevice() deleted
~PvrDevice() deleted

Function documentation

static const FixedFunctionGeneratedEffect* nCine::RHI::PVR::PvrDevice::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/PvrGeneratedEffects.h). Called once per program load from PvrShaderProgram::SetObjectLabel(), which maps the object label onto the key through its exact-name table - the draw path only ever reads the stored pointer.