migrated vu1 upload_prog into spacket

This commit is contained in:
h4570
2020-11-17 12:58:13 +01:00
parent 00c171d6b9
commit d2ce2eb7b2
5 changed files with 26 additions and 38 deletions
+8 -8
View File
@@ -64,18 +64,18 @@ void GifSender::sendTexture(MeshTexture &texture, texbuffer_t *t_texBuffer)
texture.getHeight(), GS_PSM_24,
t_texBuffer->address,
t_texBuffer->width));
spacket_chain_open_cnt(spacket, 0, 0, 0);
spacket_chain_open_cnt(spacket, 0, 0, 0, false);
spacket_update(spacket, draw_texture_wrapping(spacket->next, 0, texture.getWrapSettings()));
spacket_chain_close_tag(spacket);
spacket_update(spacket, draw_texture_flush(spacket->next));
spacket_send_chain(spacket, DMA_CHANNEL_GIF, true, true);
spacket_send_chain(spacket, DMA_CHANNEL_GIF, true, true, false);
spacket_free(spacket);
}
void GifSender::sendClear(zbuffer_t *t_zBuffer)
{
spacket_t *spacket = spacket_create(36, SPACKET_NORMAL);
spacket_chain_open_end(spacket, 0, 0);
spacket_chain_open_end(spacket, 0, 0, false);
spacket_update(spacket, draw_disable_tests(spacket->next, 0, t_zBuffer));
spacket_update(spacket, draw_clear(spacket->next, 0,
2048.0F - (screen->width / 2), 2048.0F - (screen->height / 2),
@@ -84,7 +84,7 @@ void GifSender::sendClear(zbuffer_t *t_zBuffer)
spacket_update(spacket, draw_enable_tests(spacket->next, 0, t_zBuffer));
spacket_update(spacket, draw_finish(spacket->next));
spacket_chain_close_tag(spacket);
spacket_send_chain(spacket, DMA_CHANNEL_GIF, true, true);
spacket_send_chain(spacket, DMA_CHANNEL_GIF, true, true, false);
spacket_free(spacket);
}
@@ -103,17 +103,17 @@ void GifSender::sendPacket()
{
if (isAnyObjectAdded)
{
spacket_chain_open_end(currentPacket, 0, 0);
spacket_chain_open_end(currentPacket, 0, 0, false);
spacket_update(currentPacket, draw_finish(currentPacket->next));
spacket_chain_close_tag(currentPacket);
}
spacket_send_chain(currentPacket, DMA_CHANNEL_GIF, true, true);
spacket_send_chain(currentPacket, DMA_CHANNEL_GIF, true, true, false);
}
/** Adds clear screen to current packet */
void GifSender::addClear(zbuffer_t *t_zBuffer)
{
spacket_chain_open_cnt(currentPacket, 0, 0, 0);
spacket_chain_open_cnt(currentPacket, 0, 0, 0, false);
spacket_update(currentPacket, draw_disable_tests(currentPacket->next, 0, t_zBuffer));
spacket_update(currentPacket, draw_clear(currentPacket->next, 0,
2048.0F - (screen->width / 2), 2048.0F - (screen->height / 2),
@@ -131,7 +131,7 @@ void GifSender::addClear(zbuffer_t *t_zBuffer)
*/
void GifSender::addObject(RenderData *t_renderData, Mesh &t_mesh, u32 vertexCount, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, LightBulb *t_bulbs, u16 t_bulbsCount, texbuffer_t *textureBuffer)
{
spacket_chain_open_cnt(currentPacket, 0, 0, 0);
spacket_chain_open_cnt(currentPacket, 0, 0, 0, false);
spacket_update(currentPacket, draw_texture_sampling(currentPacket->next, 0, &t_mesh.lod));
spacket_update(currentPacket, draw_texturebuffer(currentPacket->next, 0, textureBuffer, &t_mesh.clut));
spacket_update(currentPacket, draw_prim_start(currentPacket->next, 0, t_renderData->prim, &t_mesh.color));
+3
View File
@@ -29,6 +29,9 @@ VifSender::VifSender()
{
PRINT_LOG("Initializing VifSender");
PRINT_LOG("VifSender initialized!");
dma_channel_initialize(DMA_CHANNEL_VIF1, NULL, 0);
dma_channel_fast_waits(DMA_CHANNEL_VIF1);
}
VifSender::~VifSender() {}
+13 -29
View File
@@ -163,7 +163,7 @@ void VU1::sendList()
void VU1::addDoubleBufferSetting()
{
*((u64 *)currentBuffer)++ = DMA_CNT_TAG(8 >> 4);
*((u64 *)currentBuffer)++ = DMA_CNT_TAG(0);
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_BASE, 0, 8);
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_OFFSET, 0, 496);
isDoubleBufferSet = 1;
@@ -171,7 +171,7 @@ void VU1::addDoubleBufferSetting()
void VU1::addFlush()
{
*((u64 *)currentBuffer)++ = DMA_CNT_TAG(8 >> 4);
*((u64 *)currentBuffer)++ = DMA_CNT_TAG(0);
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_NOP, 0, 0);
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_FLUSH, 0, 0);
}
@@ -227,44 +227,28 @@ void VU1::checkList()
// Static
// ----
u8 IS_DMA_VIF1_INITIALIZED = 0;
/** TODO */
void VU1::uploadProgram(int t_dest, u32 *t_start, u32 *t_end)
{
if (!IS_DMA_VIF1_INITIALIZED)
{
IS_DMA_VIF1_INITIALIZED = 1;
dma_channel_initialize(DMA_CHANNEL_VIF1, NULL, 0);
dma_channel_fast_waits(DMA_CHANNEL_VIF1);
}
int count = 0;
u8 tempBuffer[512] __attribute__((aligned(16)));
void *chain = (u64 *)&tempBuffer; // uncached
// get the size of the code as we can only send 256 instructions in each MPGtag
count = VU1::countProgramSize(t_start, t_end);
int count = VU1::countProgramSize(t_start, t_end);
spacket_t *spacket = spacket_create(20, SPACKET_NORMAL);
while (count > 0)
{
u32 currentCount = count > 256 ? 256 : count;
*((u64 *)chain)++ = DMA_REF_TAG((u32)t_start, currentCount / 2);
*((u32 *)chain)++ = VIF_CODE(VIF_NOP, 0, 0);
*((u32 *)chain)++ = VIF_CODE(VIF_MPG, currentCount & 0xFF, t_dest);
spacket_ref(spacket, t_start, currentCount / 2, 0, 0, 0, 1);
spacket_vif_nop(spacket, 0);
spacket_vif_mpg(spacket, currentCount & 0xFF, t_dest, 0);
t_start += currentCount * 2;
count -= currentCount;
t_dest += currentCount;
}
*((u64 *)chain)++ = DMA_END_TAG(0);
*((u32 *)chain)++ = VIF_CODE(VIF_NOP, 0, 0);
*((u32 *)chain)++ = VIF_CODE(VIF_NOP, 0, 0);
// Send it to vif1
FlushCache(0);
dma_channel_send_chain(DMA_CHANNEL_VIF1, tempBuffer, 0, DMA_FLAG_TRANSFERTAG, 0);
dma_channel_wait(DMA_CHANNEL_VIF1, VU1_DMA_CHAN_TIMEOUT); // synchronize immediately.
spacket_chain_open_end(spacket, 0, 0, true);
spacket_vif_nop(spacket, 0);
spacket_vif_nop(spacket, 0);
spacket_chain_close_tag(spacket);
spacket_send_chain(spacket, DMA_CHANNEL_VIF1, true, true, true);
}
u32 VU1::countProgramSize(u32 *t_start, u32 *t_end)