migrated renderer to libspacket
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
#include <draw_buffers.h>
|
#include <draw_buffers.h>
|
||||||
#include <draw_primitives.h>
|
#include <draw_primitives.h>
|
||||||
#include <packet.h>
|
#include <packet.h>
|
||||||
|
#include <spacket.h>
|
||||||
#include "gif_sender.hpp"
|
#include "gif_sender.hpp"
|
||||||
#include "vif_sender.hpp"
|
#include "vif_sender.hpp"
|
||||||
#include "../models/math/plane.hpp"
|
#include "../models/math/plane.hpp"
|
||||||
@@ -118,7 +119,7 @@ private:
|
|||||||
TextureRepository textureRepo;
|
TextureRepository textureRepo;
|
||||||
GifSender *gifSender;
|
GifSender *gifSender;
|
||||||
VifSender *vifSender;
|
VifSender *vifSender;
|
||||||
packet_t *flipPacket;
|
spacket_t *flipPacket;
|
||||||
void allocateBuffers(float t_screenW, float t_screenH);
|
void allocateBuffers(float t_screenW, float t_screenH);
|
||||||
void initDrawingEnv(float t_screenW, float t_screenH);
|
void initDrawingEnv(float t_screenW, float t_screenH);
|
||||||
void setPrim();
|
void setPrim();
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ Renderer::Renderer(u32 t_packetSize, ScreenSettings *t_screen)
|
|||||||
isVSyncEnabled = true;
|
isVSyncEnabled = true;
|
||||||
isFrameEmpty = false;
|
isFrameEmpty = false;
|
||||||
lastTextureId = 0;
|
lastTextureId = 0;
|
||||||
flipPacket = packet_init(3, PACKET_UCAB); // Uncached accelerated
|
flipPacket = spacket_create(4, SPACKET_UNCACHED_ACCL);
|
||||||
allocateBuffers(t_screen->width, t_screen->height);
|
allocateBuffers(t_screen->width, t_screen->height);
|
||||||
initDrawingEnv(t_screen->width, t_screen->height);
|
initDrawingEnv(t_screen->width, t_screen->height);
|
||||||
setPrim();
|
setPrim();
|
||||||
@@ -104,17 +104,14 @@ void Renderer::changeTexture(const Mesh &t_mesh, u32 t_materialId)
|
|||||||
void Renderer::initDrawingEnv(float t_screenW, float t_screenH)
|
void Renderer::initDrawingEnv(float t_screenW, float t_screenH)
|
||||||
{
|
{
|
||||||
PRINT_LOG("Initializing drawing environment");
|
PRINT_LOG("Initializing drawing environment");
|
||||||
packet_t *packet = packet_init(20, PACKET_NORMAL);
|
|
||||||
u16 halfW = (u16)t_screenW / 2;
|
u16 halfW = (u16)t_screenW / 2;
|
||||||
u16 halfH = (u16)t_screenH / 2;
|
u16 halfH = (u16)t_screenH / 2;
|
||||||
qword_t *q = packet->data; // Generic qword pointer.
|
spacket_t *spacket = spacket_create(20, SPACKET_NORMAL);
|
||||||
q = draw_setup_environment(q, 0, frameBuffers, &(zBuffer));
|
spacket_update(spacket, draw_setup_environment(spacket->base, 0, frameBuffers, &(zBuffer)));
|
||||||
q = draw_primitive_xyoffset(q, 0, (2048 - halfW), (2048 - halfH));
|
spacket_update(spacket, draw_primitive_xyoffset(spacket->next, 0, (2048 - halfW), (2048 - halfH)));
|
||||||
q = draw_finish(q);
|
spacket_update(spacket, draw_finish(spacket->next));
|
||||||
// Now send the packet, no need to wait since it's the first.
|
spacket_send(spacket, DMA_CHANNEL_GIF, true);
|
||||||
dma_channel_send_normal(DMA_CHANNEL_GIF, packet->data, q - packet->data, 0, 0);
|
spacket_free(spacket);
|
||||||
dma_wait_fast();
|
|
||||||
packet_free(packet);
|
|
||||||
PRINT_LOG("Drawing environment initialized!");
|
PRINT_LOG("Drawing environment initialized!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,10 +274,8 @@ void Renderer::flipBuffers()
|
|||||||
0);
|
0);
|
||||||
context ^= 1;
|
context ^= 1;
|
||||||
isFrameEmpty = 1;
|
isFrameEmpty = 1;
|
||||||
qword_t *q = flipPacket->data;
|
spacket_update(flipPacket, draw_framebuffer(flipPacket->base, 0, &frameBuffers[context]));
|
||||||
q = draw_framebuffer(q, 0, &frameBuffers[context]);
|
spacket_update(flipPacket, draw_finish(flipPacket->next));
|
||||||
q = draw_finish(q);
|
spacket_send(flipPacket, DMA_CHANNEL_GIF, false);
|
||||||
dma_wait_fast();
|
|
||||||
dma_channel_send_normal_ucab(DMA_CHANNEL_GIF, flipPacket->data, q - flipPacket->data, 0);
|
|
||||||
draw_wait_finish();
|
draw_wait_finish();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user