2016-01-05 17:30:05 +01:00
|
|
|
#pragma once
|
2017-02-14 18:34:14 +01:00
|
|
|
#include "framebuffer.h"
|
|
|
|
|
2016-01-05 17:30:05 +01:00
|
|
|
typedef struct C3D_RenderTarget_tag C3D_RenderTarget;
|
|
|
|
|
|
|
|
struct C3D_RenderTarget_tag
|
|
|
|
{
|
2017-03-26 20:15:01 +02:00
|
|
|
C3D_RenderTarget *next, *prev;
|
2017-02-14 18:34:14 +01:00
|
|
|
C3D_FrameBuf frameBuf;
|
|
|
|
|
2017-03-26 20:15:01 +02:00
|
|
|
bool used;
|
2017-02-14 18:34:14 +01:00
|
|
|
bool ownsColor, ownsDepth;
|
2016-01-05 17:30:05 +01:00
|
|
|
|
|
|
|
bool linked;
|
|
|
|
gfxScreen_t screen;
|
|
|
|
gfx3dSide_t side;
|
2017-03-26 20:15:01 +02:00
|
|
|
u32 transferFlags;
|
2016-01-05 17:30:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// Flags for C3D_FrameBegin
|
|
|
|
enum
|
|
|
|
{
|
2017-03-26 20:15:01 +02:00
|
|
|
C3D_FRAME_SYNCDRAW = BIT(0), // Perform C3D_FrameSync before checking the GPU status
|
|
|
|
C3D_FRAME_NONBLOCK = BIT(1), // Return false instead of waiting if the GPU is busy
|
2016-01-05 17:30:05 +01:00
|
|
|
};
|
|
|
|
|
2017-02-09 19:57:02 +01:00
|
|
|
float C3D_FrameRate(float fps);
|
2017-03-26 20:15:01 +02:00
|
|
|
void C3D_FrameSync(void);
|
2017-05-14 23:09:56 +02:00
|
|
|
u32 C3D_FrameCounter(int id);
|
2017-03-26 20:15:01 +02:00
|
|
|
|
2016-01-05 17:30:05 +01:00
|
|
|
bool C3D_FrameBegin(u8 flags);
|
|
|
|
bool C3D_FrameDrawOn(C3D_RenderTarget* target);
|
2017-03-26 20:15:01 +02:00
|
|
|
void C3D_FrameSplit(u8 flags);
|
2016-01-05 17:30:05 +01:00
|
|
|
void C3D_FrameEnd(u8 flags);
|
|
|
|
|
2017-10-30 21:06:23 +01:00
|
|
|
void C3D_FrameEndHook(void (* hook)(void*), void* param);
|
|
|
|
|
2017-02-16 14:39:48 +01:00
|
|
|
float C3D_GetDrawingTime(void);
|
|
|
|
float C3D_GetProcessingTime(void);
|
|
|
|
|
2017-02-14 18:34:14 +01:00
|
|
|
#if defined(__GNUC__) && !defined(__cplusplus)
|
|
|
|
typedef union __attribute__((__transparent_union__))
|
2016-01-05 17:30:05 +01:00
|
|
|
{
|
2017-02-14 18:34:14 +01:00
|
|
|
int __i;
|
|
|
|
GPU_DEPTHBUF __e;
|
|
|
|
} C3D_DEPTHTYPE;
|
|
|
|
#else
|
2017-04-09 20:22:24 +02:00
|
|
|
union C3D_DEPTHTYPE
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
int __i;
|
|
|
|
GPU_DEPTHBUF __e;
|
|
|
|
public:
|
|
|
|
C3D_DEPTHTYPE(GPU_DEPTHBUF e) : __e(e) {}
|
|
|
|
C3D_DEPTHTYPE(int i) : __i(-1) { (void)i; }
|
|
|
|
};
|
2017-02-14 18:34:14 +01:00
|
|
|
#endif
|
2016-01-05 17:30:05 +01:00
|
|
|
|
2017-04-09 20:22:24 +02:00
|
|
|
#define C3D_DEPTHTYPE_OK(_x) ((_x).__i >= 0)
|
|
|
|
#define C3D_DEPTHTYPE_VAL(_x) ((_x).__e)
|
|
|
|
|
2017-02-14 18:34:14 +01:00
|
|
|
C3D_RenderTarget* C3D_RenderTargetCreate(int width, int height, GPU_COLORBUF colorFmt, C3D_DEPTHTYPE depthFmt);
|
|
|
|
C3D_RenderTarget* C3D_RenderTargetCreateFromTex(C3D_Tex* tex, GPU_TEXFACE face, int level, C3D_DEPTHTYPE depthFmt);
|
2016-01-05 17:30:05 +01:00
|
|
|
void C3D_RenderTargetDelete(C3D_RenderTarget* target);
|
|
|
|
void C3D_RenderTargetSetOutput(C3D_RenderTarget* target, gfxScreen_t screen, gfx3dSide_t side, u32 transferFlags);
|
2016-03-26 00:30:43 +01:00
|
|
|
|
2020-09-28 23:33:02 +02:00
|
|
|
static inline void C3D_RenderTargetDetachOutput(C3D_RenderTarget* target)
|
|
|
|
{
|
|
|
|
C3D_RenderTargetSetOutput(NULL, target->screen, target->side, 0);
|
|
|
|
}
|
|
|
|
|
2017-11-12 14:24:04 +01:00
|
|
|
static inline void C3D_RenderTargetClear(C3D_RenderTarget* target, C3D_ClearBits clearBits, u32 clearColor, u32 clearDepth)
|
|
|
|
{
|
|
|
|
C3D_FrameBufClear(&target->frameBuf, clearBits, clearColor, clearDepth);
|
|
|
|
}
|
|
|
|
|
2017-11-12 14:25:03 +01:00
|
|
|
void C3D_SyncDisplayTransfer(u32* inadr, u32 indim, u32* outadr, u32 outdim, u32 flags);
|
|
|
|
void C3D_SyncTextureCopy(u32* inadr, u32 indim, u32* outadr, u32 outdim, u32 size, u32 flags);
|
|
|
|
void C3D_SyncMemoryFill(u32* buf0a, u32 buf0v, u32* buf0e, u16 control0, u32* buf1a, u32 buf1v, u32* buf1e, u16 control1);
|