migrated vu1 upload_prog into spacket
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
#include <tamtypes.h>
|
#include <tamtypes.h>
|
||||||
#include <draw_primitives.h>
|
#include <draw_primitives.h>
|
||||||
#include <packet.h>
|
#include <packet.h>
|
||||||
|
#include <spacket.h>
|
||||||
#include <math3d.h>
|
#include <math3d.h>
|
||||||
|
|
||||||
const u32 VIF_BUFFER_SIZE = 48 * 1024;
|
const u32 VIF_BUFFER_SIZE = 48 * 1024;
|
||||||
|
|||||||
@@ -64,18 +64,18 @@ void GifSender::sendTexture(MeshTexture &texture, texbuffer_t *t_texBuffer)
|
|||||||
texture.getHeight(), GS_PSM_24,
|
texture.getHeight(), GS_PSM_24,
|
||||||
t_texBuffer->address,
|
t_texBuffer->address,
|
||||||
t_texBuffer->width));
|
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_update(spacket, draw_texture_wrapping(spacket->next, 0, texture.getWrapSettings()));
|
||||||
spacket_chain_close_tag(spacket);
|
spacket_chain_close_tag(spacket);
|
||||||
spacket_update(spacket, draw_texture_flush(spacket->next));
|
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);
|
spacket_free(spacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GifSender::sendClear(zbuffer_t *t_zBuffer)
|
void GifSender::sendClear(zbuffer_t *t_zBuffer)
|
||||||
{
|
{
|
||||||
spacket_t *spacket = spacket_create(36, SPACKET_NORMAL);
|
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_disable_tests(spacket->next, 0, t_zBuffer));
|
||||||
spacket_update(spacket, draw_clear(spacket->next, 0,
|
spacket_update(spacket, draw_clear(spacket->next, 0,
|
||||||
2048.0F - (screen->width / 2), 2048.0F - (screen->height / 2),
|
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_enable_tests(spacket->next, 0, t_zBuffer));
|
||||||
spacket_update(spacket, draw_finish(spacket->next));
|
spacket_update(spacket, draw_finish(spacket->next));
|
||||||
spacket_chain_close_tag(spacket);
|
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);
|
spacket_free(spacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,17 +103,17 @@ void GifSender::sendPacket()
|
|||||||
{
|
{
|
||||||
if (isAnyObjectAdded)
|
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_update(currentPacket, draw_finish(currentPacket->next));
|
||||||
spacket_chain_close_tag(currentPacket);
|
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 */
|
/** Adds clear screen to current packet */
|
||||||
void GifSender::addClear(zbuffer_t *t_zBuffer)
|
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_disable_tests(currentPacket->next, 0, t_zBuffer));
|
||||||
spacket_update(currentPacket, draw_clear(currentPacket->next, 0,
|
spacket_update(currentPacket, draw_clear(currentPacket->next, 0,
|
||||||
2048.0F - (screen->width / 2), 2048.0F - (screen->height / 2),
|
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)
|
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_texture_sampling(currentPacket->next, 0, &t_mesh.lod));
|
||||||
spacket_update(currentPacket, draw_texturebuffer(currentPacket->next, 0, textureBuffer, &t_mesh.clut));
|
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));
|
spacket_update(currentPacket, draw_prim_start(currentPacket->next, 0, t_renderData->prim, &t_mesh.color));
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ VifSender::VifSender()
|
|||||||
{
|
{
|
||||||
PRINT_LOG("Initializing VifSender");
|
PRINT_LOG("Initializing VifSender");
|
||||||
PRINT_LOG("VifSender initialized!");
|
PRINT_LOG("VifSender initialized!");
|
||||||
|
|
||||||
|
dma_channel_initialize(DMA_CHANNEL_VIF1, NULL, 0);
|
||||||
|
dma_channel_fast_waits(DMA_CHANNEL_VIF1);
|
||||||
}
|
}
|
||||||
|
|
||||||
VifSender::~VifSender() {}
|
VifSender::~VifSender() {}
|
||||||
|
|||||||
+13
-29
@@ -163,7 +163,7 @@ void VU1::sendList()
|
|||||||
|
|
||||||
void VU1::addDoubleBufferSetting()
|
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_BASE, 0, 8);
|
||||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_OFFSET, 0, 496);
|
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_OFFSET, 0, 496);
|
||||||
isDoubleBufferSet = 1;
|
isDoubleBufferSet = 1;
|
||||||
@@ -171,7 +171,7 @@ void VU1::addDoubleBufferSetting()
|
|||||||
|
|
||||||
void VU1::addFlush()
|
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_NOP, 0, 0);
|
||||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_FLUSH, 0, 0);
|
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_FLUSH, 0, 0);
|
||||||
}
|
}
|
||||||
@@ -227,44 +227,28 @@ void VU1::checkList()
|
|||||||
// Static
|
// Static
|
||||||
// ----
|
// ----
|
||||||
|
|
||||||
u8 IS_DMA_VIF1_INITIALIZED = 0;
|
|
||||||
/** TODO */
|
/** TODO */
|
||||||
void VU1::uploadProgram(int t_dest, u32 *t_start, u32 *t_end)
|
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
|
// 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)
|
while (count > 0)
|
||||||
{
|
{
|
||||||
u32 currentCount = count > 256 ? 256 : count;
|
u32 currentCount = count > 256 ? 256 : count;
|
||||||
|
spacket_ref(spacket, t_start, currentCount / 2, 0, 0, 0, 1);
|
||||||
*((u64 *)chain)++ = DMA_REF_TAG((u32)t_start, currentCount / 2);
|
spacket_vif_nop(spacket, 0);
|
||||||
*((u32 *)chain)++ = VIF_CODE(VIF_NOP, 0, 0);
|
spacket_vif_mpg(spacket, currentCount & 0xFF, t_dest, 0);
|
||||||
*((u32 *)chain)++ = VIF_CODE(VIF_MPG, currentCount & 0xFF, t_dest);
|
|
||||||
|
|
||||||
t_start += currentCount * 2;
|
t_start += currentCount * 2;
|
||||||
count -= currentCount;
|
count -= currentCount;
|
||||||
t_dest += currentCount;
|
t_dest += currentCount;
|
||||||
}
|
}
|
||||||
|
spacket_chain_open_end(spacket, 0, 0, true);
|
||||||
*((u64 *)chain)++ = DMA_END_TAG(0);
|
spacket_vif_nop(spacket, 0);
|
||||||
*((u32 *)chain)++ = VIF_CODE(VIF_NOP, 0, 0);
|
spacket_vif_nop(spacket, 0);
|
||||||
*((u32 *)chain)++ = VIF_CODE(VIF_NOP, 0, 0);
|
spacket_chain_close_tag(spacket);
|
||||||
|
spacket_send_chain(spacket, DMA_CHANNEL_VIF1, true, true, true);
|
||||||
// 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.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 VU1::countProgramSize(u32 *t_start, u32 *t_end)
|
u32 VU1::countProgramSize(u32 *t_start, u32 *t_end)
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ void Ari::onInit()
|
|||||||
|
|
||||||
// texRepo->addByMesh("ari/", player.mesh);
|
// texRepo->addByMesh("ari/", player.mesh);
|
||||||
|
|
||||||
engine->audio.playSong();
|
// engine->audio.playSong();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ari::initBulb()
|
void Ari::initBulb()
|
||||||
|
|||||||
Reference in New Issue
Block a user