launching vu1 programs
This commit is contained in:
@@ -40,8 +40,7 @@ class DynPipCore {
|
|||||||
void renderPart(DynPipBag* data, const bool& frustumCull = true);
|
void renderPart(DynPipBag* data, const bool& frustumCull = true);
|
||||||
|
|
||||||
/** Get max vert count of VU1 qbuffer (for optimizations) */
|
/** Get max vert count of VU1 qbuffer (for optimizations) */
|
||||||
u32 getMaxVertCountByParams(const bool& isSingleColor,
|
u32 getMaxVertCountByParams(const bool& isLightingEnabled,
|
||||||
const bool& isLightingEnabled,
|
|
||||||
const bool& isTextureEnabled);
|
const bool& isTextureEnabled);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
# ______ ____ ___
|
|
||||||
# | \/ ____| |___|
|
|
||||||
# | | | \ | |
|
|
||||||
#-----------------------------------------------------------------------
|
|
||||||
# Copyright 2022, tyra - https://github.com/h4570/tyra
|
|
||||||
# Licenced under Apache License 2.0
|
|
||||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "./bag/dynpip_bag.hpp"
|
|
||||||
|
|
||||||
namespace Tyra {
|
|
||||||
|
|
||||||
class DynPipQBuffer {
|
|
||||||
public:
|
|
||||||
DynPipQBuffer();
|
|
||||||
~DynPipQBuffer();
|
|
||||||
|
|
||||||
void setMaxVertCount(const u32& count);
|
|
||||||
|
|
||||||
DynPipBag* bag;
|
|
||||||
|
|
||||||
Vec4* verticesFrom;
|
|
||||||
Vec4* verticesTo;
|
|
||||||
|
|
||||||
Vec4* stsFrom;
|
|
||||||
Vec4* stsTo;
|
|
||||||
|
|
||||||
Vec4* normalsFrom;
|
|
||||||
Vec4* normalsTo;
|
|
||||||
|
|
||||||
/** Size per frame */
|
|
||||||
u32 size;
|
|
||||||
|
|
||||||
void print() const;
|
|
||||||
void print(const char* name) const;
|
|
||||||
void print(const std::string& name) const { print(name.c_str()); }
|
|
||||||
std::string getPrint(const char* name = nullptr) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
u32 maxVertCount;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Tyra
|
|
||||||
@@ -25,16 +25,10 @@ class DynPipRenderer {
|
|||||||
|
|
||||||
void reinitVU1();
|
void reinitVU1();
|
||||||
|
|
||||||
// DynPipQBuffer* getBuffer();
|
|
||||||
|
|
||||||
void sendObjectData(DynPipBag* bag, M4x4* mvp,
|
void sendObjectData(DynPipBag* bag, M4x4* mvp,
|
||||||
RendererCoreTextureBuffers* texBuffers) const;
|
RendererCoreTextureBuffers* texBuffers) const;
|
||||||
|
|
||||||
// void setMaxVertCount(const u32& count);
|
void render(DynPipBag* bag);
|
||||||
|
|
||||||
// void setInfo(PipelineInfoBag* bag);
|
|
||||||
|
|
||||||
// void render(DynPipQBuffer* buffer);
|
|
||||||
|
|
||||||
void clearLastProgramName();
|
void clearLastProgramName();
|
||||||
|
|
||||||
@@ -46,9 +40,8 @@ class DynPipRenderer {
|
|||||||
void uploadPrograms();
|
void uploadPrograms();
|
||||||
void setDoubleBuffer();
|
void setDoubleBuffer();
|
||||||
|
|
||||||
// void addBufferDataToPacket(DynPipVU1Program* program, DynPipQBuffer*
|
void addBufferDataToPacket(DynPipVU1Program* program, DynPipBag* bag);
|
||||||
// buffer); void sendPacket();
|
void sendPacket();
|
||||||
// DynPipQBuffer buffers[2];
|
|
||||||
|
|
||||||
packet2_t* packets[2];
|
packet2_t* packets[2];
|
||||||
packet2_t* programsPacket;
|
packet2_t* programsPacket;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
#include "./dynpip_program_name.hpp"
|
#include "./dynpip_program_name.hpp"
|
||||||
#include "renderer/core/paths/path1/vu1_program.hpp"
|
#include "renderer/core/paths/path1/vu1_program.hpp"
|
||||||
#include "./programs/dynpip_vu1_shared_defines.h"
|
#include "./programs/dynpip_vu1_shared_defines.h"
|
||||||
#include "./dynpip_qbuffer.hpp"
|
#include "./bag/dynpip_bag.hpp"
|
||||||
|
|
||||||
namespace Tyra {
|
namespace Tyra {
|
||||||
|
|
||||||
@@ -28,11 +28,9 @@ class DynPipVU1Program : public VU1Program {
|
|||||||
|
|
||||||
const DynPipProgramName& getName() const;
|
const DynPipProgramName& getName() const;
|
||||||
|
|
||||||
u16 getMaxVertCount(const bool& singleColorEnabled,
|
u16 getMaxVertCount(const u16& vu1DBufferSize) const;
|
||||||
const u16& vu1DBufferSize) const;
|
|
||||||
|
|
||||||
void addBufferDataToPacket(packet2_t* packet, DynPipQBuffer* buffer,
|
void addBufferDataToPacket(packet2_t* packet, DynPipBag* bag, prim_t* prim);
|
||||||
prim_t* prim);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DynPipProgramName name;
|
DynPipProgramName name;
|
||||||
@@ -40,10 +38,10 @@ class DynPipVU1Program : public VU1Program {
|
|||||||
u32 destinationAddress, reglist;
|
u32 destinationAddress, reglist;
|
||||||
|
|
||||||
virtual void addProgramQBufferDataToPacket(packet2_t* packet,
|
virtual void addProgramQBufferDataToPacket(packet2_t* packet,
|
||||||
DynPipQBuffer* qbuffer) const = 0;
|
DynPipBag* bag) const = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addStandardBufferDataToPacket(packet2_t* packet, DynPipQBuffer* buffer,
|
void addStandardBufferDataToPacket(packet2_t* packet, DynPipBag* bag,
|
||||||
prim_t* prim);
|
prim_t* prim);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ class DynPipCVU1Program : public DynPipVU1Program {
|
|||||||
~DynPipCVU1Program();
|
~DynPipCVU1Program();
|
||||||
|
|
||||||
std::string getStringName() const;
|
std::string getStringName() const;
|
||||||
void addProgramQBufferDataToPacket(packet2_t* packet,
|
void addProgramQBufferDataToPacket(packet2_t* packet, DynPipBag* bag) const;
|
||||||
DynPipQBuffer* qbuffer) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ class DynPipDVU1Program : public DynPipVU1Program {
|
|||||||
~DynPipDVU1Program();
|
~DynPipDVU1Program();
|
||||||
|
|
||||||
std::string getStringName() const;
|
std::string getStringName() const;
|
||||||
void addProgramQBufferDataToPacket(packet2_t* packet,
|
void addProgramQBufferDataToPacket(packet2_t* packet, DynPipBag* bag) const;
|
||||||
DynPipQBuffer* qbuffer) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ class DynPipTCVU1Program : public DynPipVU1Program {
|
|||||||
~DynPipTCVU1Program();
|
~DynPipTCVU1Program();
|
||||||
|
|
||||||
std::string getStringName() const;
|
std::string getStringName() const;
|
||||||
void addProgramQBufferDataToPacket(packet2_t* packet,
|
void addProgramQBufferDataToPacket(packet2_t* packet, DynPipBag* bag) const;
|
||||||
DynPipQBuffer* qbuffer) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ class DynPipTDVU1Program : public DynPipVU1Program {
|
|||||||
~DynPipTDVU1Program();
|
~DynPipTDVU1Program();
|
||||||
|
|
||||||
std::string getStringName() const;
|
std::string getStringName() const;
|
||||||
void addProgramQBufferDataToPacket(packet2_t* packet,
|
void addProgramQBufferDataToPacket(packet2_t* packet, DynPipBag* bag) const;
|
||||||
DynPipQBuffer* qbuffer) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
|
|||||||
@@ -14,10 +14,19 @@
|
|||||||
|
|
||||||
namespace Tyra {
|
namespace Tyra {
|
||||||
|
|
||||||
|
enum DynPipFrustumCulling {
|
||||||
|
DynPipFrustumCulling_None = 0,
|
||||||
|
DynPipFrustumCulling_Simple = 1,
|
||||||
|
DynPipFrustumCulling_Precise = 2,
|
||||||
|
};
|
||||||
|
|
||||||
class DynPipOptions : public PipelineOptions {
|
class DynPipOptions : public PipelineOptions {
|
||||||
public:
|
public:
|
||||||
DynPipOptions() {}
|
DynPipOptions() {}
|
||||||
~DynPipOptions() {}
|
~DynPipOptions() {}
|
||||||
|
|
||||||
|
/** Default: Simple */
|
||||||
|
DynPipFrustumCulling frustumCulling;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "renderer/3d/pipeline/dynamic/core/dynpip_core.hpp"
|
#include "renderer/3d/pipeline/dynamic/core/dynpip_core.hpp"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include "thread/threading.hpp"
|
||||||
|
|
||||||
namespace Tyra {
|
namespace Tyra {
|
||||||
|
|
||||||
@@ -25,11 +26,10 @@ void DynPipCore::init(RendererCore* t_core) {
|
|||||||
|
|
||||||
void DynPipCore::reinitVU1Programs() { qbufferRenderer.reinitVU1(); }
|
void DynPipCore::reinitVU1Programs() { qbufferRenderer.reinitVU1(); }
|
||||||
|
|
||||||
u32 DynPipCore::getMaxVertCountByParams(const bool& isSingleColor,
|
u32 DynPipCore::getMaxVertCountByParams(const bool& isLightingEnabled,
|
||||||
const bool& isLightingEnabled,
|
|
||||||
const bool& isTextureEnabled) {
|
const bool& isTextureEnabled) {
|
||||||
return repository.getProgramByParams(isLightingEnabled, isTextureEnabled)
|
return repository.getProgramByParams(isLightingEnabled, isTextureEnabled)
|
||||||
->getMaxVertCount(isSingleColor, qbufferRenderer.getBufferSize());
|
->getMaxVertCount(qbufferRenderer.getBufferSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynPipCore::initParts(DynPipBag* bag) {
|
void DynPipCore::initParts(DynPipBag* bag) {
|
||||||
@@ -49,6 +49,24 @@ void DynPipCore::initParts(DynPipBag* bag) {
|
|||||||
void DynPipCore::renderPart(DynPipBag* bag, const bool& frustumCull) {
|
void DynPipCore::renderPart(DynPipBag* bag, const bool& frustumCull) {
|
||||||
if (bag->count <= 0) return;
|
if (bag->count <= 0) return;
|
||||||
|
|
||||||
|
TYRA_ASSERT(bag->verticesFrom != nullptr && bag->verticesTo != nullptr,
|
||||||
|
"Vertices are required in 3D render bag!");
|
||||||
|
TYRA_ASSERT(bag->info != nullptr, "Info bag is required in 3D render bag!");
|
||||||
|
TYRA_ASSERT(bag->info->model != nullptr,
|
||||||
|
"Info bag's model pointer is empty!");
|
||||||
|
TYRA_ASSERT(bag->color != nullptr, "Color bag is required in 3D render bag!");
|
||||||
|
TYRA_ASSERT(bag->color->single, "Color is required in 3D render bag!");
|
||||||
|
TYRA_ASSERT(
|
||||||
|
!bag->lighting ||
|
||||||
|
(bag->lighting->lightMatrix && bag->lighting->normalsFrom &&
|
||||||
|
bag->lighting->normalsTo && bag->lighting->dirLights),
|
||||||
|
"If you want lighting, please provide light matrix normals and dir "
|
||||||
|
"lights!");
|
||||||
|
TYRA_ASSERT(!bag->texture ||
|
||||||
|
(bag->texture->texture && bag->texture->coordinatesFrom &&
|
||||||
|
bag->texture->coordinatesTo),
|
||||||
|
"If you want texture, please provide texture and coordinates!");
|
||||||
|
|
||||||
if (frustumCull) {
|
if (frustumCull) {
|
||||||
CoreBBox bbox(bag->verticesTo, bag->count);
|
CoreBBox bbox(bag->verticesTo, bag->count);
|
||||||
if (bbox.isInFrustum(rendererCore->renderer3D.frustumPlanes.getAll(),
|
if (bbox.isInFrustum(rendererCore->renderer3D.frustumPlanes.getAll(),
|
||||||
@@ -58,10 +76,7 @@ void DynPipCore::renderPart(DynPipBag* bag, const bool& frustumCull) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Uruchomic odpowiedni program
|
qbufferRenderer.render(bag);
|
||||||
// TODO: Wyslac wierzcholki
|
|
||||||
// TODO: Program VU1 TD
|
|
||||||
// TODO: Reszta programow VU1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
|
|||||||
@@ -16,6 +16,11 @@ DynPipProgramsRepository::DynPipProgramsRepository() {}
|
|||||||
|
|
||||||
DynPipProgramsRepository::~DynPipProgramsRepository() {}
|
DynPipProgramsRepository::~DynPipProgramsRepository() {}
|
||||||
|
|
||||||
|
DynPipVU1Program* DynPipProgramsRepository::getProgramByBag(
|
||||||
|
const DynPipBag* bag) {
|
||||||
|
return getProgramByParams(bag->lighting, bag->texture);
|
||||||
|
}
|
||||||
|
|
||||||
DynPipVU1Program* DynPipProgramsRepository::getProgramByParams(
|
DynPipVU1Program* DynPipProgramsRepository::getProgramByParams(
|
||||||
const bool& isLightingEnabled, const bool& isTextureEnabled) {
|
const bool& isLightingEnabled, const bool& isTextureEnabled) {
|
||||||
if (isLightingEnabled && isTextureEnabled)
|
if (isLightingEnabled && isTextureEnabled)
|
||||||
|
|||||||
@@ -1,81 +0,0 @@
|
|||||||
/*
|
|
||||||
# ______ ____ ___
|
|
||||||
# | \/ ____| |___|
|
|
||||||
# | | | \ | |
|
|
||||||
#-----------------------------------------------------------------------
|
|
||||||
# Copyright 2022, tyra - https://github.com/h4570/tyra
|
|
||||||
# Licenced under Apache License 2.0
|
|
||||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "renderer/3d/pipeline/dynamic/core/dynpip_qbuffer.hpp"
|
|
||||||
#include <sstream>
|
|
||||||
#include <iomanip>
|
|
||||||
|
|
||||||
namespace Tyra {
|
|
||||||
|
|
||||||
DynPipQBuffer::DynPipQBuffer() {}
|
|
||||||
|
|
||||||
DynPipQBuffer::~DynPipQBuffer() {}
|
|
||||||
|
|
||||||
void DynPipQBuffer::setMaxVertCount(const u32& count) { maxVertCount = count; }
|
|
||||||
|
|
||||||
void DynPipQBuffer::print() const {
|
|
||||||
auto text = getPrint(nullptr);
|
|
||||||
printf("%s\n", text.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
void DynPipQBuffer::print(const char* name) const {
|
|
||||||
auto text = getPrint(name);
|
|
||||||
printf("%s\n", text.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string DynPipQBuffer::getPrint(const char* name) const {
|
|
||||||
std::stringstream res;
|
|
||||||
if (name) {
|
|
||||||
res << name << "(";
|
|
||||||
} else {
|
|
||||||
res << "DynPipQBuffer(";
|
|
||||||
}
|
|
||||||
res << std::fixed << std::setprecision(2);
|
|
||||||
res << std::endl;
|
|
||||||
res << "Size: " << static_cast<int>(size) << std::endl;
|
|
||||||
|
|
||||||
res << "Vertices from: " << std::endl;
|
|
||||||
for (u32 i = 0; i < size; i++)
|
|
||||||
res << i << ": " << verticesFrom[i].getPrint() << std::endl;
|
|
||||||
|
|
||||||
res << "Vertices to: " << std::endl;
|
|
||||||
for (u32 i = 0; i < size; i++)
|
|
||||||
res << i << ": " << verticesTo[i].getPrint() << std::endl;
|
|
||||||
|
|
||||||
if (bag->texture != nullptr) {
|
|
||||||
res << "STs from: " << std::endl;
|
|
||||||
for (u32 i = 0; i < size; i++)
|
|
||||||
res << i << ": " << stsFrom[i].getPrint() << std::endl;
|
|
||||||
|
|
||||||
res << "STs to: " << std::endl;
|
|
||||||
for (u32 i = 0; i < size; i++)
|
|
||||||
res << i << ": " << stsTo[i].getPrint() << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bag->lighting != nullptr) {
|
|
||||||
res << "Normals from: " << std::endl;
|
|
||||||
for (u32 i = 0; i < size; i++) {
|
|
||||||
res << i << ": " << normalsFrom[i].getPrint() << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
res << "Normals to: " << std::endl;
|
|
||||||
for (u32 i = 0; i < size; i++) {
|
|
||||||
res << i << ": " << normalsTo[i].getPrint();
|
|
||||||
if (i < size - 1) {
|
|
||||||
res << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
res << ")";
|
|
||||||
return res.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Tyra
|
|
||||||
@@ -16,6 +16,7 @@ namespace Tyra {
|
|||||||
|
|
||||||
DynPipRenderer::DynPipRenderer() {
|
DynPipRenderer::DynPipRenderer() {
|
||||||
context = 0;
|
context = 0;
|
||||||
|
bufferSize = 0;
|
||||||
lastProgramName = DynPipProgramName::DynPipUndefinedProgram;
|
lastProgramName = DynPipProgramName::DynPipUndefinedProgram;
|
||||||
staticDataPacket = packet2_create(3, P2_TYPE_NORMAL, P2_MODE_CHAIN, true);
|
staticDataPacket = packet2_create(3, P2_TYPE_NORMAL, P2_MODE_CHAIN, true);
|
||||||
objectDataPacket = packet2_create(16, P2_TYPE_NORMAL, P2_MODE_CHAIN, true);
|
objectDataPacket = packet2_create(16, P2_TYPE_NORMAL, P2_MODE_CHAIN, true);
|
||||||
@@ -33,32 +34,32 @@ DynPipRenderer::~DynPipRenderer() {
|
|||||||
|
|
||||||
void DynPipRenderer::init(RendererCore* t_core,
|
void DynPipRenderer::init(RendererCore* t_core,
|
||||||
DynPipProgramsRepository* t_programRepo) {
|
DynPipProgramsRepository* t_programRepo) {
|
||||||
// path1 = t_core->getPath1();
|
path1 = t_core->getPath1();
|
||||||
// rendererCore = t_core;
|
rendererCore = t_core;
|
||||||
// programsRepo = t_programRepo;
|
programsRepo = t_programRepo;
|
||||||
|
|
||||||
// dma_channel_initialize(DMA_CHANNEL_VIF1, NULL, 0);
|
dma_channel_initialize(DMA_CHANNEL_VIF1, NULL, 0);
|
||||||
// dma_channel_fast_waits(DMA_CHANNEL_VIF1);
|
dma_channel_fast_waits(DMA_CHANNEL_VIF1);
|
||||||
|
|
||||||
// const u32 VU1_PACKET_SIZE = 16;
|
const u32 VU1_PACKET_SIZE = 16;
|
||||||
|
|
||||||
// packets[0] =
|
packets[0] =
|
||||||
// packet2_create(VU1_PACKET_SIZE, P2_TYPE_NORMAL, P2_MODE_CHAIN, true);
|
packet2_create(VU1_PACKET_SIZE, P2_TYPE_NORMAL, P2_MODE_CHAIN, true);
|
||||||
|
|
||||||
// packets[1] =
|
packets[1] =
|
||||||
// packet2_create(VU1_PACKET_SIZE, P2_TYPE_NORMAL, P2_MODE_CHAIN, true);
|
packet2_create(VU1_PACKET_SIZE, P2_TYPE_NORMAL, P2_MODE_CHAIN, true);
|
||||||
|
|
||||||
// setProgramsCache();
|
setProgramsCache();
|
||||||
|
|
||||||
// reinitVU1();
|
reinitVU1();
|
||||||
|
|
||||||
// TYRA_LOG("Renderer3DQBufferRenderer initialized");
|
TYRA_LOG("DynPipRenderer initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynPipRenderer::reinitVU1() {
|
void DynPipRenderer::reinitVU1() {
|
||||||
// sendStaticData();
|
sendStaticData();
|
||||||
// uploadPrograms();
|
uploadPrograms();
|
||||||
// setDoubleBuffer();
|
setDoubleBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynPipRenderer::setProgramsCache() {
|
void DynPipRenderer::setProgramsCache() {
|
||||||
@@ -136,6 +137,36 @@ void DynPipRenderer::sendObjectData(
|
|||||||
// dma_channel_send_packet2(objectDataPacket, DMA_CHANNEL_VIF1, true);
|
// dma_channel_send_packet2(objectDataPacket, DMA_CHANNEL_VIF1, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DynPipRenderer::render(DynPipBag* bag) {
|
||||||
|
auto* program = programsRepo->getProgramByBag(bag);
|
||||||
|
addBufferDataToPacket(program, bag);
|
||||||
|
sendPacket();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DynPipRenderer::addBufferDataToPacket(DynPipVU1Program* program,
|
||||||
|
DynPipBag* bag) {
|
||||||
|
currentPacket = packets[context];
|
||||||
|
packet2_reset(currentPacket, false);
|
||||||
|
program->addBufferDataToPacket(currentPacket, bag, &rendererCore->gs.prim);
|
||||||
|
|
||||||
|
if (lastProgramName != program->getName()) {
|
||||||
|
packet2_utils_vu_add_start_program(currentPacket,
|
||||||
|
program->getDestinationAddress());
|
||||||
|
lastProgramName = program->getName();
|
||||||
|
} else {
|
||||||
|
packet2_utils_vu_add_continue_program(currentPacket);
|
||||||
|
}
|
||||||
|
packet2_utils_vu_add_end_tag(currentPacket);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DynPipRenderer::sendPacket() {
|
||||||
|
dma_channel_wait(DMA_CHANNEL_VIF1, 0);
|
||||||
|
dma_channel_send_packet2(currentPacket, DMA_CHANNEL_VIF1, true);
|
||||||
|
|
||||||
|
// Switch packet, so we can proceed during DMA transfer
|
||||||
|
context = !context;
|
||||||
|
}
|
||||||
|
|
||||||
void DynPipRenderer::clearLastProgramName() {
|
void DynPipRenderer::clearLastProgramName() {
|
||||||
lastProgramName = DynPipUndefinedProgram;
|
lastProgramName = DynPipUndefinedProgram;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,15 +32,14 @@ const DynPipProgramName& DynPipVU1Program::getName() const { return name; }
|
|||||||
|
|
||||||
u32& DynPipVU1Program::getReglist() { return reglist; }
|
u32& DynPipVU1Program::getReglist() { return reglist; }
|
||||||
|
|
||||||
void DynPipVU1Program::addBufferDataToPacket(packet2_t* packet,
|
void DynPipVU1Program::addBufferDataToPacket(packet2_t* packet, DynPipBag* bag,
|
||||||
DynPipQBuffer* buffer,
|
|
||||||
prim_t* prim) {
|
prim_t* prim) {
|
||||||
addStandardBufferDataToPacket(packet, buffer, prim);
|
addStandardBufferDataToPacket(packet, bag, prim);
|
||||||
addProgramQBufferDataToPacket(packet, buffer);
|
addProgramQBufferDataToPacket(packet, bag);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynPipVU1Program::addStandardBufferDataToPacket(packet2_t* packet,
|
void DynPipVU1Program::addStandardBufferDataToPacket(packet2_t* packet,
|
||||||
DynPipQBuffer* buffer,
|
DynPipBag* bag,
|
||||||
prim_t* prim) {
|
prim_t* prim) {
|
||||||
// if (buffer->bag->texture)
|
// if (buffer->bag->texture)
|
||||||
// prim->mapping = 1;
|
// prim->mapping = 1;
|
||||||
@@ -61,12 +60,9 @@ void DynPipVU1Program::addStandardBufferDataToPacket(packet2_t* packet,
|
|||||||
// packet2_utils_vu_close_unpack(packet);
|
// packet2_utils_vu_close_unpack(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
u16 DynPipVU1Program::getMaxVertCount(const bool& singleColorEnabled,
|
u16 DynPipVU1Program::getMaxVertCount(const u16& bufferSize) const {
|
||||||
const u16& bufferSize) const {
|
|
||||||
u16 res = bufferSize - 4;
|
u16 res = bufferSize - 4;
|
||||||
u8 colorElementsPerVertex =
|
res /= (elementsPerVertex + reglistCount);
|
||||||
singleColorEnabled ? (elementsPerVertex - 1) : elementsPerVertex;
|
|
||||||
res /= (colorElementsPerVertex + reglistCount);
|
|
||||||
|
|
||||||
// Buffer size = VU1 double buffer size (xtop)
|
// Buffer size = VU1 double buffer size (xtop)
|
||||||
// QBufferSize = res (it is placed inside VU1)
|
// QBufferSize = res (it is placed inside VU1)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace Tyra {
|
|||||||
DynPipCVU1Program::DynPipCVU1Program()
|
DynPipCVU1Program::DynPipCVU1Program()
|
||||||
: DynPipVU1Program(
|
: DynPipVU1Program(
|
||||||
DynPipColor, &DynPipVU1_C_CodeStart, &DynPipVU1_C_CodeEnd,
|
DynPipColor, &DynPipVU1_C_CodeStart, &DynPipVU1_C_CodeEnd,
|
||||||
((u64)GIF_REG_RGBAQ) << 0 | ((u64)GIF_REG_XYZ2) << 4, 2, 2) {}
|
((u64)GIF_REG_RGBAQ) << 0 | ((u64)GIF_REG_XYZ2) << 4, 2, 1) {}
|
||||||
|
|
||||||
DynPipCVU1Program::~DynPipCVU1Program() {}
|
DynPipCVU1Program::~DynPipCVU1Program() {}
|
||||||
|
|
||||||
@@ -27,8 +27,8 @@ std::string DynPipCVU1Program::getStringName() const {
|
|||||||
return std::string("DynPip - C");
|
return std::string("DynPip - C");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynPipCVU1Program::addProgramQBufferDataToPacket(
|
void DynPipCVU1Program::addProgramQBufferDataToPacket(packet2_t* packet,
|
||||||
packet2_t* packet, DynPipQBuffer* qbuffer) const {
|
DynPipBag* bag) const {
|
||||||
// u32 addr = VU1_VERT_DATA_ADDR;
|
// u32 addr = VU1_VERT_DATA_ADDR;
|
||||||
|
|
||||||
// // Add vertices
|
// // Add vertices
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace Tyra {
|
|||||||
DynPipDVU1Program::DynPipDVU1Program()
|
DynPipDVU1Program::DynPipDVU1Program()
|
||||||
: DynPipVU1Program(
|
: DynPipVU1Program(
|
||||||
DynPipDirLights, &DynPipVU1_D_CodeStart, &DynPipVU1_D_CodeEnd,
|
DynPipDirLights, &DynPipVU1_D_CodeStart, &DynPipVU1_D_CodeEnd,
|
||||||
((u64)GIF_REG_RGBAQ) << 0 | ((u64)GIF_REG_XYZ2) << 4, 2, 3) {}
|
((u64)GIF_REG_RGBAQ) << 0 | ((u64)GIF_REG_XYZ2) << 4, 2, 2) {}
|
||||||
|
|
||||||
DynPipDVU1Program::~DynPipDVU1Program() {}
|
DynPipDVU1Program::~DynPipDVU1Program() {}
|
||||||
|
|
||||||
@@ -27,8 +27,8 @@ std::string DynPipDVU1Program::getStringName() const {
|
|||||||
return std::string("DynPip - D");
|
return std::string("DynPip - D");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynPipDVU1Program::addProgramQBufferDataToPacket(
|
void DynPipDVU1Program::addProgramQBufferDataToPacket(packet2_t* packet,
|
||||||
packet2_t* packet, DynPipQBuffer* qbuffer) const {
|
DynPipBag* bag) const {
|
||||||
// u32 addr = VU1_VERT_DATA_ADDR;
|
// u32 addr = VU1_VERT_DATA_ADDR;
|
||||||
|
|
||||||
// // Add vertices
|
// // Add vertices
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ DynPipTCVU1Program::DynPipTCVU1Program()
|
|||||||
&DynPipVU1_TC_CodeEnd,
|
&DynPipVU1_TC_CodeEnd,
|
||||||
((u64)GIF_REG_ST) << 0 | ((u64)GIF_REG_RGBAQ) << 4 |
|
((u64)GIF_REG_ST) << 0 | ((u64)GIF_REG_RGBAQ) << 4 |
|
||||||
((u64)GIF_REG_XYZ2) << 8,
|
((u64)GIF_REG_XYZ2) << 8,
|
||||||
3, 3) {}
|
3, 2) {}
|
||||||
|
|
||||||
DynPipTCVU1Program::~DynPipTCVU1Program() {}
|
DynPipTCVU1Program::~DynPipTCVU1Program() {}
|
||||||
|
|
||||||
@@ -29,8 +29,8 @@ std::string DynPipTCVU1Program::getStringName() const {
|
|||||||
return std::string("DynPip - TC");
|
return std::string("DynPip - TC");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynPipTCVU1Program::addProgramQBufferDataToPacket(
|
void DynPipTCVU1Program::addProgramQBufferDataToPacket(packet2_t* packet,
|
||||||
packet2_t* packet, DynPipQBuffer* qbuffer) const {
|
DynPipBag* bag) const {
|
||||||
// u32 addr = VU1_VERT_DATA_ADDR;
|
// u32 addr = VU1_VERT_DATA_ADDR;
|
||||||
|
|
||||||
// // Add vertices
|
// // Add vertices
|
||||||
|
|||||||
@@ -32,7 +32,13 @@
|
|||||||
|
|
||||||
#vuprog DynPipVU1TD
|
#vuprog DynPipVU1TD
|
||||||
|
|
||||||
--cont
|
ResetClipFlags{ }
|
||||||
|
|
||||||
|
begin:
|
||||||
|
xtop buffer
|
||||||
|
|
||||||
|
|
||||||
|
; --cont
|
||||||
|
|
||||||
#endvuprog
|
#endvuprog
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ DynPipTDVU1Program::DynPipTDVU1Program()
|
|||||||
&DynPipVU1_TD_CodeEnd,
|
&DynPipVU1_TD_CodeEnd,
|
||||||
((u64)GIF_REG_ST) << 0 | ((u64)GIF_REG_RGBAQ) << 4 |
|
((u64)GIF_REG_ST) << 0 | ((u64)GIF_REG_RGBAQ) << 4 |
|
||||||
((u64)GIF_REG_XYZ2) << 8,
|
((u64)GIF_REG_XYZ2) << 8,
|
||||||
3, 4) {}
|
3, 3) {}
|
||||||
|
|
||||||
DynPipTDVU1Program::~DynPipTDVU1Program() {}
|
DynPipTDVU1Program::~DynPipTDVU1Program() {}
|
||||||
|
|
||||||
@@ -29,33 +29,37 @@ std::string DynPipTDVU1Program::getStringName() const {
|
|||||||
return std::string("DynPip - TD");
|
return std::string("DynPip - TD");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynPipTDVU1Program::addProgramQBufferDataToPacket(
|
void DynPipTDVU1Program::addProgramQBufferDataToPacket(packet2_t* packet,
|
||||||
packet2_t* packet, DynPipQBuffer* qbuffer) const {
|
DynPipBag* bag) const {
|
||||||
u32 addr = VU1_VERT_DATA_ADDR;
|
u32 addr = VU1_VERT_DATA_ADDR;
|
||||||
|
|
||||||
// Add vertices
|
// Add vertices
|
||||||
packet2_utils_vu_add_unpack_data(packet, addr, qbuffer->verticesFrom,
|
packet2_utils_vu_add_unpack_data(packet, addr, bag->verticesFrom, bag->count,
|
||||||
qbuffer->size, true);
|
|
||||||
addr += qbuffer->size;
|
|
||||||
packet2_utils_vu_add_unpack_data(packet, addr, qbuffer->verticesTo,
|
|
||||||
qbuffer->size, true);
|
|
||||||
addr += qbuffer->size;
|
|
||||||
|
|
||||||
// Add sts
|
|
||||||
packet2_utils_vu_add_unpack_data(packet, addr, qbuffer->stsFrom,
|
|
||||||
qbuffer->size, true);
|
|
||||||
addr += qbuffer->size;
|
|
||||||
packet2_utils_vu_add_unpack_data(packet, addr, qbuffer->stsTo, qbuffer->size,
|
|
||||||
true);
|
true);
|
||||||
addr += qbuffer->size;
|
addr += bag->count;
|
||||||
|
packet2_utils_vu_add_unpack_data(packet, addr, bag->verticesTo, bag->count,
|
||||||
|
true);
|
||||||
|
addr += bag->count;
|
||||||
|
|
||||||
|
if (bag->texture) {
|
||||||
|
// Add sts
|
||||||
|
packet2_utils_vu_add_unpack_data(
|
||||||
|
packet, addr, bag->texture->coordinatesFrom, bag->count, true);
|
||||||
|
addr += bag->count;
|
||||||
|
packet2_utils_vu_add_unpack_data(packet, addr, bag->texture->coordinatesTo,
|
||||||
|
bag->count, true);
|
||||||
|
addr += bag->count;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bag->lighting) {
|
||||||
// Add normal
|
// Add normal
|
||||||
packet2_utils_vu_add_unpack_data(packet, addr, qbuffer->normalsFrom,
|
packet2_utils_vu_add_unpack_data(packet, addr, bag->lighting->normalsFrom,
|
||||||
qbuffer->size, true);
|
bag->count, true);
|
||||||
addr += qbuffer->size;
|
addr += bag->count;
|
||||||
packet2_utils_vu_add_unpack_data(packet, addr, qbuffer->normalsTo,
|
packet2_utils_vu_add_unpack_data(packet, addr, bag->lighting->normalsTo,
|
||||||
qbuffer->size, true);
|
bag->count, true);
|
||||||
addr += qbuffer->size;
|
addr += bag->count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ void DynamicPipeline::init(RendererCore* t_core) {
|
|||||||
core.init(t_core);
|
core.init(t_core);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicPipeline::onUse() {}
|
void DynamicPipeline::onUse() { core.reinitVU1Programs(); }
|
||||||
|
|
||||||
void DynamicPipeline::render(DynamicMesh* mesh, const DynPipOptions* options) {
|
void DynamicPipeline::render(DynamicMesh* mesh, const DynPipOptions* options) {
|
||||||
auto model = mesh->getModelMatrix();
|
auto model = mesh->getModelMatrix();
|
||||||
@@ -29,6 +29,16 @@ void DynamicPipeline::render(DynamicMesh* mesh, const DynPipOptions* options) {
|
|||||||
auto* frameTo = mesh->getFrame(mesh->getNextAnimationFrame());
|
auto* frameTo = mesh->getFrame(mesh->getNextAnimationFrame());
|
||||||
auto* infoBag = getInfoBag(mesh, options, &model);
|
auto* infoBag = getInfoBag(mesh, options, &model);
|
||||||
PipelineDirLightsBag* dirLights = nullptr;
|
PipelineDirLightsBag* dirLights = nullptr;
|
||||||
|
auto frustumCulling =
|
||||||
|
options ? options->frustumCulling : DynPipFrustumCulling_Simple;
|
||||||
|
|
||||||
|
if (frustumCulling == DynPipFrustumCulling_Simple) {
|
||||||
|
if (frameTo->getBBox().isInFrustum(
|
||||||
|
rendererCore->renderer3D.frustumPlanes.getAll(), model) ==
|
||||||
|
CoreBBoxFrustum::OUTSIDE_FRUSTUM) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (options && options->lighting) {
|
if (options && options->lighting) {
|
||||||
setLightingColorsCache(options->lighting);
|
setLightingColorsCache(options->lighting);
|
||||||
@@ -46,8 +56,7 @@ void DynamicPipeline::render(DynamicMesh* mesh, const DynPipOptions* options) {
|
|||||||
for (u32 i = 0; i < mesh->getMaterialsCount(); i++) {
|
for (u32 i = 0; i < mesh->getMaterialsCount(); i++) {
|
||||||
auto* material = mesh->getMaterial(i);
|
auto* material = mesh->getMaterial(i);
|
||||||
auto partSize = core.getMaxVertCountByParams(
|
auto partSize = core.getMaxVertCountByParams(
|
||||||
material->isSingleColorActivated(), options && options->lighting,
|
options && options->lighting, material->getTextureCoordFaces());
|
||||||
material->getTextureCoordFaces());
|
|
||||||
u32 partsCount =
|
u32 partsCount =
|
||||||
ceil(material->getFacesCount() / static_cast<float>(partSize));
|
ceil(material->getFacesCount() / static_cast<float>(partSize));
|
||||||
auto* colorBag = getColorBag(material);
|
auto* colorBag = getColorBag(material);
|
||||||
@@ -76,7 +85,7 @@ void DynamicPipeline::render(DynamicMesh* mesh, const DynPipOptions* options) {
|
|||||||
isPartInitialized = true;
|
isPartInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
core.renderPart(&buffer);
|
core.renderPart(&buffer, frustumCulling == DynPipFrustumCulling_Precise);
|
||||||
|
|
||||||
context = !context;
|
context = !context;
|
||||||
}
|
}
|
||||||
@@ -155,8 +164,9 @@ void DynamicPipeline::addVertices(DynamicMesh* mesh, MeshMaterial* material,
|
|||||||
|
|
||||||
for (u32 i = startIndex; i < startIndex + bag->count; i++) {
|
for (u32 i = startIndex; i < startIndex + bag->count; i++) {
|
||||||
auto& face = material->getVertexFaces()[i];
|
auto& face = material->getVertexFaces()[i];
|
||||||
bag->verticesFrom[i] = frameFrom->getVertices()[face];
|
auto offset = i - startIndex;
|
||||||
bag->verticesTo[i] = frameTo->getVertices()[face];
|
bag->verticesFrom[offset] = frameFrom->getVertices()[face];
|
||||||
|
bag->verticesTo[offset] = frameTo->getVertices()[face];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,8 +192,9 @@ DynPipTextureBag* DynamicPipeline::getTextureBag(
|
|||||||
|
|
||||||
for (u32 i = startIndex; i < startIndex + count; i++) {
|
for (u32 i = startIndex; i < startIndex + count; i++) {
|
||||||
auto& face = material->getTextureCoordFaces()[i];
|
auto& face = material->getTextureCoordFaces()[i];
|
||||||
result->coordinatesFrom[i] = frameFrom->getTextureCoords()[face];
|
auto offset = i - startIndex;
|
||||||
result->coordinatesTo[i] = frameTo->getTextureCoords()[face];
|
result->coordinatesFrom[offset] = frameFrom->getTextureCoords()[face];
|
||||||
|
result->coordinatesTo[offset] = frameTo->getTextureCoords()[face];
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -201,13 +212,15 @@ DynPipLightingBag* DynamicPipeline::getLightingBag(
|
|||||||
auto* result = new DynPipLightingBag();
|
auto* result = new DynPipLightingBag();
|
||||||
|
|
||||||
result->lightMatrix = model;
|
result->lightMatrix = model;
|
||||||
|
result->dirLights = dirLightsBag;
|
||||||
result->normalsFrom = new Vec4[count];
|
result->normalsFrom = new Vec4[count];
|
||||||
result->normalsTo = new Vec4[count];
|
result->normalsTo = new Vec4[count];
|
||||||
|
|
||||||
for (u32 i = startIndex; i < startIndex + count; i++) {
|
for (u32 i = startIndex; i < startIndex + count; i++) {
|
||||||
auto& face = material->getNormalFaces()[i];
|
auto& face = material->getNormalFaces()[i];
|
||||||
result->normalsFrom[i] = frameFrom->getNormals()[face];
|
auto offset = i - startIndex;
|
||||||
result->normalsTo[i] = frameTo->getNormals()[face];
|
result->normalsFrom[offset] = frameFrom->getNormals()[face];
|
||||||
|
result->normalsTo[offset] = frameTo->getNormals()[face];
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -70,8 +70,6 @@ void MinecraftPipeline::render(McpipBlock* blocks, const u32& count,
|
|||||||
if (culled > 0) cull(blocks, cullIndexes, &texBuffers, isMulti);
|
if (culled > 0) cull(blocks, cullIndexes, &texBuffers, isMulti);
|
||||||
if (clipped > 0) clip(blocks, clipIndexes, &texBuffers, isMulti);
|
if (clipped > 0) clip(blocks, clipIndexes, &texBuffers, isMulti);
|
||||||
}
|
}
|
||||||
|
|
||||||
Threading::switchThread();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreBBoxFrustum MinecraftPipeline::isInFrustum(const McpipBlock& block) const {
|
CoreBBoxFrustum MinecraftPipeline::isInFrustum(const McpipBlock& block) const {
|
||||||
|
|||||||
@@ -136,8 +136,6 @@ void StaPipCore::render(StaPipBag* bag, StaPipBagPackagesBBox* bbox) {
|
|||||||
if (!bbox) delete renderBbox;
|
if (!bbox) delete renderBbox;
|
||||||
if (texBuffers) delete texBuffers;
|
if (texBuffers) delete texBuffers;
|
||||||
|
|
||||||
Threading::switchThread();
|
|
||||||
|
|
||||||
Verbose("Render finished");
|
Verbose("Render finished");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ void StaPipQBufferRenderer::init(RendererCore* t_core) {
|
|||||||
|
|
||||||
reinitVU1();
|
reinitVU1();
|
||||||
|
|
||||||
TYRA_LOG("Renderer3DQBufferRenderer initialized");
|
TYRA_LOG("StaPipQBufferRenderer initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
void StaPipQBufferRenderer::reinitVU1() {
|
void StaPipQBufferRenderer::reinitVU1() {
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ void H4570::init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
engine->audio.playSong();
|
engine->audio.playSong();
|
||||||
|
// engine->renderer.setFrameLimit(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 counter = 0;
|
u32 counter = 0;
|
||||||
@@ -142,17 +143,19 @@ void H4570::loop() {
|
|||||||
|
|
||||||
// engine->renderer.renderer3D.usePipeline(&stapip);
|
// engine->renderer.renderer3D.usePipeline(&stapip);
|
||||||
// {
|
// {
|
||||||
// stapip.render(warrior, staOptions);
|
// stapip.render(terrain, staOptions);
|
||||||
// // stapip.render(warrior2, staOptions);
|
|
||||||
// // stapip.render(warrior3, staOptions);
|
|
||||||
// // stapip.render(warrior4, staOptions);
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
engine->renderer.renderer3D.usePipeline(&dynpip);
|
engine->renderer.renderer3D.usePipeline(&dynpip);
|
||||||
{ dynpip.render(warrior, dynOptions); }
|
{
|
||||||
|
dynpip.render(warrior, dynOptions);
|
||||||
|
// dynpip.render(warrior2, dynOptions);
|
||||||
|
// dynpip.render(warrior3, dynOptions);
|
||||||
|
// dynpip.render(warrior4, dynOptions);
|
||||||
|
}
|
||||||
|
|
||||||
engine->renderer.renderer3D.usePipeline(&mcPip);
|
engine->renderer.renderer3D.usePipeline(&mcPip);
|
||||||
{ mcPip.render(blocks, blocksCount, blocksTex, false); }
|
{ mcPip.render(blocks, blocksCount, blocksTex); }
|
||||||
}
|
}
|
||||||
engine->renderer.endFrame();
|
engine->renderer.endFrame();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user