mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-11 16:45:48 -04:00
PS2: Ensure that empty DMA buffer can't be sent
This commit is contained in:
parent
82b494203d
commit
f7e54f4394
@ -115,7 +115,7 @@ FUNC DrawTexturedQuad
|
|||||||
BeginClip POS_1
|
BeginClip POS_1
|
||||||
|
|
||||||
### VERTEX 2 ###
|
### VERTEX 2 ###
|
||||||
# LOAD VERTEX 2
|
# LOAD VERTEX 2 (todo rearrange vertices for efficient loading)
|
||||||
ld $t0,0x18(SRC) # t0 = src[1].x,y
|
ld $t0,0x18(SRC) # t0 = src[1].x,y
|
||||||
sd $t0,0x00(TMP) # tmp.x,y = t0
|
sd $t0,0x00(TMP) # tmp.x,y = t0
|
||||||
lw $t0,0x20(SRC) # t0 = src[1].z
|
lw $t0,0x20(SRC) # t0 = src[1].z
|
||||||
|
@ -37,7 +37,7 @@ extern void LoadViewportScale(VU0_VECTOR* scale);
|
|||||||
static packet_t* packets[2];
|
static packet_t* packets[2];
|
||||||
static packet_t* current;
|
static packet_t* current;
|
||||||
static int context;
|
static int context;
|
||||||
static qword_t* dma_tag;
|
static qword_t* dma_beg;
|
||||||
static qword_t* q;
|
static qword_t* q;
|
||||||
|
|
||||||
static GfxResourceID white_square;
|
static GfxResourceID white_square;
|
||||||
@ -71,9 +71,9 @@ static void UpdateContext(void) {
|
|||||||
|
|
||||||
current = packets[context];
|
current = packets[context];
|
||||||
|
|
||||||
dma_tag = current->data;
|
dma_beg = current->data;
|
||||||
// increment past the dmatag itself
|
// increment past the dmatag itself
|
||||||
q = dma_tag + 1;
|
q = dma_beg + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ static void InitDrawingEnv(void) {
|
|||||||
|
|
||||||
dma_channel_send_normal(DMA_CHANNEL_GIF, beg, q - beg, 0, 0);
|
dma_channel_send_normal(DMA_CHANNEL_GIF, beg, q - beg, 0, 0);
|
||||||
dma_wait_fast();
|
dma_wait_fast();
|
||||||
q = dma_tag + 1;
|
q = dma_beg + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tex_offset;
|
static int tex_offset;
|
||||||
@ -155,6 +155,13 @@ void Gfx_Free(void) {
|
|||||||
Gfx_FreeState();
|
Gfx_FreeState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static CC_INLINE void DMAFlushBuffer(void) {
|
||||||
|
if (q == dma_beg) return;
|
||||||
|
|
||||||
|
DMATAG_END(dma_beg, (q - dma_beg) - 1, 0, 0, 0);
|
||||||
|
dma_channel_send_chain(DMA_CHANNEL_GIF, dma_beg, q - dma_beg, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*---------------------------------------------------------Textures--------------------------------------------------------*
|
*---------------------------------------------------------Textures--------------------------------------------------------*
|
||||||
@ -200,8 +207,7 @@ void Gfx_BindTexture(GfxResourceID texId) {
|
|||||||
unsigned dst_stride = max(64, tex->width);
|
unsigned dst_stride = max(64, tex->width);
|
||||||
|
|
||||||
// TODO terrible perf
|
// TODO terrible perf
|
||||||
DMATAG_END(dma_tag, (q - current->data) - 1, 0, 0, 0);
|
DMAFlushBuffer();
|
||||||
dma_channel_send_chain(DMA_CHANNEL_GIF, current->data, q - current->data, 0, 0);
|
|
||||||
dma_wait_fast();
|
dma_wait_fast();
|
||||||
|
|
||||||
packet_t *packet = packet_init(200, PACKET_NORMAL);
|
packet_t *packet = packet_init(200, PACKET_NORMAL);
|
||||||
@ -217,7 +223,7 @@ void Gfx_BindTexture(GfxResourceID texId) {
|
|||||||
packet_free(packet);
|
packet_free(packet);
|
||||||
|
|
||||||
// TODO terrible perf
|
// TODO terrible perf
|
||||||
q = dma_tag + 1;
|
q = dma_beg + 1;
|
||||||
UpdateTextureBuffer(0, tex, dst_addr, dst_stride);
|
UpdateTextureBuffer(0, tex, dst_addr, dst_stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -638,11 +644,10 @@ static void DrawTriangles(int verticesCount, int startVertex) {
|
|||||||
if (formatDirty) UpdateFormat(0);
|
if (formatDirty) UpdateFormat(0);
|
||||||
|
|
||||||
if ((q - current->data) > 45000) {
|
if ((q - current->data) > 45000) {
|
||||||
DMATAG_END(dma_tag, (q - current->data) - 1, 0, 0, 0);
|
DMAFlushBuffer();
|
||||||
dma_channel_send_chain(DMA_CHANNEL_GIF, current->data, q - current->data, 0, 0);
|
|
||||||
dma_wait_fast();
|
dma_wait_fast();
|
||||||
q = dma_tag + 1;
|
q = dma_beg + 1;
|
||||||
Platform_LogConst("Too much geometry!!!");
|
Platform_LogConst("Too much geometry!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
while (verticesCount)
|
while (verticesCount)
|
||||||
@ -712,10 +717,8 @@ void Gfx_EndFrame(void) {
|
|||||||
|
|
||||||
q = draw_finish(q);
|
q = draw_finish(q);
|
||||||
|
|
||||||
// Fill out and then send DMA chain
|
|
||||||
DMATAG_END(dma_tag, (q - current->data) - 1, 0, 0, 0);
|
|
||||||
dma_wait_fast();
|
dma_wait_fast();
|
||||||
dma_channel_send_chain(DMA_CHANNEL_GIF, current->data, q - current->data, 0, 0);
|
DMAFlushBuffer();
|
||||||
//Platform_LogConst("--- EF2 ---");
|
//Platform_LogConst("--- EF2 ---");
|
||||||
|
|
||||||
draw_wait_finish();
|
draw_wait_finish();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user