fixing rendering issue on real PS2
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include "../include/utils/math.hpp"
|
||||
#include "../include/utils/debug.hpp"
|
||||
#include "../include/modules/light.hpp"
|
||||
#include <kernel.h>
|
||||
#include <dma.h>
|
||||
#include <draw.h>
|
||||
#include <stdio.h>
|
||||
@@ -61,6 +62,7 @@ void GifSender::sendTexture(MeshTexture &texture, texbuffer_t *t_texBuffer)
|
||||
q++;
|
||||
q = draw_texture_wrapping(q, 0, texture.getWrapSettings());
|
||||
q = draw_texture_flush(q);
|
||||
FlushCache(0);
|
||||
dma_channel_send_chain(DMA_CHANNEL_GIF, packet->data, q - packet->data, 0, 0);
|
||||
dma_wait_fast();
|
||||
packet_free(packet);
|
||||
@@ -79,6 +81,7 @@ void GifSender::sendClear(zbuffer_t *t_zBuffer)
|
||||
q = draw_enable_tests(q, 0, t_zBuffer);
|
||||
q = draw_finish(q);
|
||||
DMATAG_END(packet->data, q - packet->data - 1, 0, 0, 0);
|
||||
FlushCache(0);
|
||||
dma_channel_send_chain(DMA_CHANNEL_GIF, packet->data, q - packet->data, 0, 0);
|
||||
dma_wait_fast();
|
||||
packet_free(packet);
|
||||
@@ -108,8 +111,9 @@ void GifSender::sendPacket()
|
||||
}
|
||||
q = draw_finish(q);
|
||||
DMATAG_END(dmatag, q - dmatag - 1, 0, 0, 0);
|
||||
dma_wait_fast();
|
||||
FlushCache(0);
|
||||
dma_channel_send_chain(DMA_CHANNEL_GIF, currentPacket->data, q - currentPacket->data, 0, 0);
|
||||
dma_wait_fast();
|
||||
}
|
||||
|
||||
/** Adds clear screen to current packet */
|
||||
|
||||
@@ -222,15 +222,12 @@ void Renderer::draw(Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount)
|
||||
if (t_mesh.shouldBeFrustumCulled && !t_mesh.getMaterial(i).isInFrustum(renderData.frustumPlanes, t_mesh.position))
|
||||
return;
|
||||
u32 vertCount = t_mesh.getMaterial(i).getFacesCount();
|
||||
VECTOR *vertices = new VECTOR[vertCount];
|
||||
VECTOR *normals = new VECTOR[vertCount];
|
||||
VECTOR *coordinates = new VECTOR[vertCount];
|
||||
VECTOR __attribute__((aligned(16))) vertices[vertCount];
|
||||
VECTOR __attribute__((aligned(16))) normals[vertCount];
|
||||
VECTOR __attribute__((aligned(16))) coordinates[vertCount];
|
||||
changeTexture(t_mesh, t_mesh.getMaterial(i).getId());
|
||||
vertCount = t_mesh.getDrawData(i, vertices, normals, coordinates, rotatedCamera);
|
||||
vifSender->drawMesh(&renderData, perspective, vertCount, vertices, normals, coordinates, t_mesh, t_bulbs, t_bulbsCount, &textureBuffer);
|
||||
delete[] vertices;
|
||||
delete[] normals;
|
||||
delete[] coordinates;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ void VifSender::sendMatrices(const RenderData &t_renderData, const Vector3 &t_po
|
||||
vec3ToNative(rotation, t_rotation, 1.0F);
|
||||
create_local_world(localWorld, position, rotation);
|
||||
create_local_screen(localScreen, localWorld, t_renderData.worldView->data, t_renderData.perspective->data);
|
||||
vu1.sendSingleRefList(0, &localScreen, 4);
|
||||
vu1.sendSingleRefList(0, &localScreen, 8);
|
||||
}
|
||||
|
||||
void VifSender::drawMesh(RenderData *t_renderData, Matrix t_perspective, u32 vertCount2, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, const Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount, texbuffer_t *textureBuffer)
|
||||
|
||||
@@ -127,7 +127,7 @@ void VU1::addReferenceList(u32 t_offset, void *t_data, u32 t_size, u8 t_useTops)
|
||||
*((u64 *)currentBuffer)++ = DMA_REF_TAG((u32)t_data, t_size);
|
||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_STCYL, 0, 0x0101);
|
||||
*((u32 *)currentBuffer)++ =
|
||||
AddUnpack(V4_32, t_useTops == 1 ? buildList.dmaSize / 16 : t_offset / 16, t_size, t_useTops);
|
||||
AddUnpack(V4_32, t_useTops == 1 ? buildList.dmaSize >> 4 : t_offset >> 4, t_size, t_useTops);
|
||||
buildList.dmaSize += t_size * 8;
|
||||
buildList.dmaSizeAll += buildList.dmaSize;
|
||||
}
|
||||
@@ -135,7 +135,7 @@ void VU1::addReferenceList(u32 t_offset, void *t_data, u32 t_size, u8 t_useTops)
|
||||
/** Start VU1 program */
|
||||
void VU1::addStartProgram()
|
||||
{
|
||||
*((u64 *)currentBuffer)++ = DMA_CNT_TAG(8 >> 4);
|
||||
*((u64 *)currentBuffer)++ = DMA_CNT_TAG(0);
|
||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_MSCAL, 0, 0);
|
||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_FLUSH, 0, 0);
|
||||
;
|
||||
@@ -144,7 +144,7 @@ void VU1::addStartProgram()
|
||||
/** Continue VU1 program from "--cont" line */
|
||||
void VU1::addContinueProgram()
|
||||
{
|
||||
*((u64 *)currentBuffer)++ = DMA_CNT_TAG(8 >> 4);
|
||||
*((u64 *)currentBuffer)++ = DMA_CNT_TAG(0);
|
||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_MSCAL, 0, 0);
|
||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_FLUSH, 0, 0);
|
||||
;
|
||||
@@ -156,8 +156,9 @@ void VU1::sendList()
|
||||
*((u64 *)currentBuffer)++ = DMA_END_TAG(0);
|
||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_NOP, 0, 0);
|
||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_NOP, 0, 0);
|
||||
dma_channel_wait(DMA_CHANNEL_VIF1, VU1_DMA_CHAN_TIMEOUT);
|
||||
FlushCache(0);
|
||||
dma_channel_send_chain(DMA_CHANNEL_VIF1, buildList.kickBuffer, (u32 *)currentBuffer - (u32 *)buildList.kickBuffer, DMA_FLAG_TRANSFERTAG, 0);
|
||||
dma_channel_wait(DMA_CHANNEL_VIF1, VU1_DMA_CHAN_TIMEOUT);
|
||||
}
|
||||
|
||||
void VU1::addDoubleBufferSetting()
|
||||
|
||||
Reference in New Issue
Block a user