Some tweaks in renderbuffer handling

This commit is contained in:
fincs 2015-09-20 14:04:50 +02:00
parent 447c5b05bb
commit 6c4836397b
5 changed files with 36 additions and 26 deletions

View File

@ -126,12 +126,6 @@ void C3Di_UpdateContext(void)
int i; int i;
C3D_Context* ctx = C3Di_GetContext(); C3D_Context* ctx = C3Di_GetContext();
if (ctx->flags & C3DiF_NeedFinishDrawing)
{
ctx->flags &= ~C3DiF_NeedFinishDrawing;
//GPU_FinishDrawing();
}
if (ctx->flags & C3DiF_Program) if (ctx->flags & C3DiF_Program)
{ {
ctx->flags &= ~C3DiF_Program; ctx->flags &= ~C3DiF_Program;
@ -141,6 +135,11 @@ void C3Di_UpdateContext(void)
if (ctx->flags & C3DiF_RenderBuf) if (ctx->flags & C3DiF_RenderBuf)
{ {
ctx->flags &= ~C3DiF_RenderBuf; ctx->flags &= ~C3DiF_RenderBuf;
if (ctx->flags & C3DiF_DrawUsed)
{
ctx->flags &= ~C3DiF_DrawUsed;
GPUCMD_AddWrite(GPUREG_FRAMEBUFFER_FLUSH, 1);
}
C3Di_RenderBufBind(ctx->rb); C3Di_RenderBufBind(ctx->rb);
} }
@ -238,12 +237,12 @@ void C3D_FlushAsync(void)
if (!(ctx->flags & C3DiF_Active)) if (!(ctx->flags & C3DiF_Active))
return; return;
if (ctx->flags & C3DiF_NeedFinishDrawing) if (ctx->flags & C3DiF_DrawUsed)
{ {
ctx->flags &= ~C3DiF_NeedFinishDrawing; ctx->flags &= ~C3DiF_DrawUsed;
GPUCMD_AddWrite(GPUREG_FRAMEBUFFER_FLUSH, 0x00000001); GPUCMD_AddWrite(GPUREG_FRAMEBUFFER_FLUSH, 1);
GPUCMD_AddWrite(GPUREG_FRAMEBUFFER_INVALIDATE, 0x00000001); GPUCMD_AddWrite(GPUREG_FRAMEBUFFER_INVALIDATE, 1);
GPUCMD_AddWrite(GPUREG_0063, 0x00000001); GPUCMD_AddWrite(GPUREG_0063, 1); // Does this even do anything at all?
} }
GPUCMD_Finalize(); GPUCMD_Finalize();

View File

@ -49,7 +49,7 @@ typedef struct
enum enum
{ {
C3DiF_Active = BIT(0), C3DiF_Active = BIT(0),
C3DiF_NeedFinishDrawing = BIT(1), C3DiF_DrawUsed = BIT(1),
C3DiF_AttrInfo = BIT(2), C3DiF_AttrInfo = BIT(2),
C3DiF_BufInfo = BIT(3), C3DiF_BufInfo = BIT(3),
C3DiF_Effect = BIT(4), C3DiF_Effect = BIT(4),

View File

@ -22,5 +22,5 @@ void C3D_DrawArrays(GPU_Primitive_t primitive, int first, int size)
GPUCMD_AddMaskedWrite(GPUREG_0245, 1, 0x00000001); GPUCMD_AddMaskedWrite(GPUREG_0245, 1, 0x00000001);
GPUCMD_AddWrite(GPUREG_0231, 0x00000001); GPUCMD_AddWrite(GPUREG_0231, 0x00000001);
C3Di_GetContext()->flags |= C3DiF_NeedFinishDrawing; C3Di_GetContext()->flags |= C3DiF_DrawUsed;
} }

View File

@ -28,5 +28,5 @@ void C3D_DrawElements(GPU_Primitive_t primitive, int count, int type, const void
GPUCMD_AddMaskedWrite(GPUREG_0245, 1, 0x00000001); GPUCMD_AddMaskedWrite(GPUREG_0245, 1, 0x00000001);
GPUCMD_AddWrite(GPUREG_0231, 0x00000001); GPUCMD_AddWrite(GPUREG_0231, 0x00000001);
C3Di_GetContext()->flags |= C3DiF_NeedFinishDrawing; C3Di_GetContext()->flags |= C3DiF_DrawUsed;
} }

View File

@ -23,16 +23,25 @@ bool C3D_RenderBufInit(C3D_RenderBuf* rb, int width, int height, int colorFmt, i
rb->height = height; rb->height = height;
rb->clearColor = rb->clearDepth = 0; rb->clearColor = rb->clearDepth = 0;
if (colorFmt >= 0)
{
rb->colorBuf = vramAlloc(calcColorBufSize(width, height, colorFmt)); rb->colorBuf = vramAlloc(calcColorBufSize(width, height, colorFmt));
if (!rb->colorBuf) return false; if (!rb->colorBuf) return false;
} else
rb->colorFmt = GPU_RB_RGBA8;
if (depthFmt >= 0)
{
rb->depthBuf = vramAlloc(calcDepthBufSize(width, height, depthFmt)); rb->depthBuf = vramAlloc(calcDepthBufSize(width, height, depthFmt));
if (!rb->depthBuf) if (!rb->depthBuf)
{ {
if (rb->colorBuf)
vramFree(rb->colorBuf); vramFree(rb->colorBuf);
rb->colorBuf = NULL; rb->colorBuf = NULL;
return false; return false;
} }
} else
rb->depthFmt = GPU_RB_DEPTH16;
return true; return true;
} }
@ -62,7 +71,7 @@ void C3D_RenderBufBind(C3D_RenderBuf* rb)
void C3Di_RenderBufBind(C3D_RenderBuf* rb) void C3Di_RenderBufBind(C3D_RenderBuf* rb)
{ {
u32 param[4]; u32 param[4] = { 0, 0, 0, 0 };
GPUCMD_AddWrite(GPUREG_FRAMEBUFFER_INVALIDATE, 1); GPUCMD_AddWrite(GPUREG_FRAMEBUFFER_INVALIDATE, 1);
@ -77,7 +86,9 @@ void C3Di_RenderBufBind(C3D_RenderBuf* rb)
GPUCMD_AddWrite(GPUREG_FRAMEBUFFER_BLOCK32, 0x00000000); //? GPUCMD_AddWrite(GPUREG_FRAMEBUFFER_BLOCK32, 0x00000000); //?
// "Enable depth buffer" (?) // "Enable depth buffer" (?)
if (rb->colorBuf)
param[0] = param[1] = 0xF; param[0] = param[1] = 0xF;
if (rb->depthBuf)
param[2] = param[3] = 0x2; param[2] = param[3] = 0x2;
GPUCMD_AddIncrementalWrites(GPUREG_COLORBUFFER_READ, param, 4); GPUCMD_AddIncrementalWrites(GPUREG_COLORBUFFER_READ, param, 4);
} }