tutorial 1 and 2
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
#include "renderer/3d/pipeline/dynamic/core/dynpip_renderer.hpp"
|
||||
#include "renderer/3d/pipeline/dynamic/core/programs/dynpip_vu1_shared_defines.h"
|
||||
#include <dma.h>
|
||||
#include <utility>
|
||||
#include "packet2/packet2_tyra_utils.hpp"
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
@@ -114,8 +116,8 @@ void DynPipRenderer::sendObjectData(
|
||||
|
||||
if (singleColorEnabled) // Color is placed in 4th slot of
|
||||
// VU1_LIGHTS_MATRIX_ADDR
|
||||
packet2_utils_vu_add_unpack_data(objectDataPacket, VU1_SINGLE_COLOR_ADDR,
|
||||
bag->color->single->rgba, 1, false);
|
||||
Packet2TyraUtils::addUnpackData(objectDataPacket, VU1_SINGLE_COLOR_ADDR,
|
||||
bag->color->single->rgba, 1, false);
|
||||
|
||||
packet2_utils_vu_open_unpack(objectDataPacket, VU1_OPTIONS_ADDR, false);
|
||||
{
|
||||
|
||||
@@ -51,7 +51,13 @@ void DynamicPipeline::onUseEnd() {
|
||||
core.deallocateOnUse();
|
||||
}
|
||||
|
||||
void DynamicPipeline::render(DynamicMesh* mesh, const DynPipOptions* options) {
|
||||
void DynamicPipeline::render(const DynamicMesh& mesh,
|
||||
const DynPipOptions* options) {
|
||||
render(&mesh, options);
|
||||
}
|
||||
|
||||
void DynamicPipeline::render(const DynamicMesh* mesh,
|
||||
const DynPipOptions* options) {
|
||||
bool optionsManuallyAllocated = false;
|
||||
|
||||
if (!options) {
|
||||
@@ -185,7 +191,7 @@ void DynamicPipeline::sendRestOfBuffers(DynPipBag* buffers, u16* bufferIndex) {
|
||||
}
|
||||
|
||||
void DynamicPipeline::setBuffersDefaultVars(DynPipBag* buffers,
|
||||
DynamicMesh* mesh,
|
||||
const DynamicMesh* mesh,
|
||||
DynPipInfoBag* infoBag) {
|
||||
for (u32 i = 0; i < buffersCount; i++) {
|
||||
buffers[i].info = infoBag;
|
||||
@@ -210,7 +216,7 @@ void DynamicPipeline::freeBuffer(DynPipBag* bag) {
|
||||
}
|
||||
}
|
||||
|
||||
DynPipInfoBag* DynamicPipeline::getInfoBag(DynamicMesh* mesh,
|
||||
DynPipInfoBag* DynamicPipeline::getInfoBag(const DynamicMesh* mesh,
|
||||
const DynPipOptions* options,
|
||||
M4x4* model) const {
|
||||
auto* result = new DynPipInfoBag();
|
||||
@@ -230,22 +236,23 @@ DynPipInfoBag* DynamicPipeline::getInfoBag(DynamicMesh* mesh,
|
||||
return result;
|
||||
}
|
||||
|
||||
void DynamicPipeline::addVertices(MeshMaterialFrame* materialFrameFrom,
|
||||
MeshMaterialFrame* materialFrameTo,
|
||||
void DynamicPipeline::addVertices(const MeshMaterialFrame* materialFrameFrom,
|
||||
const MeshMaterialFrame* materialFrameTo,
|
||||
DynPipBag* bag, const u32& startIndex) const {
|
||||
bag->verticesFrom = &materialFrameFrom->vertices[startIndex];
|
||||
bag->verticesTo = &materialFrameTo->vertices[startIndex];
|
||||
}
|
||||
|
||||
DynPipColorBag* DynamicPipeline::getColorBag(MeshMaterial* material) const {
|
||||
DynPipColorBag* DynamicPipeline::getColorBag(
|
||||
const MeshMaterial* material) const {
|
||||
auto* result = new DynPipColorBag();
|
||||
result->single = &material->ambient;
|
||||
return result;
|
||||
}
|
||||
|
||||
DynPipTextureBag* DynamicPipeline::getTextureBag(
|
||||
Texture* texture, MeshMaterialFrame* materialFrameFrom,
|
||||
MeshMaterialFrame* materialFrameTo, const u32& startIndex) {
|
||||
Texture* texture, const MeshMaterialFrame* materialFrameFrom,
|
||||
const MeshMaterialFrame* materialFrameTo, const u32& startIndex) {
|
||||
if (!materialFrameFrom->textureCoords) return nullptr;
|
||||
|
||||
auto* result = new DynPipTextureBag();
|
||||
@@ -259,9 +266,10 @@ DynPipTextureBag* DynamicPipeline::getTextureBag(
|
||||
}
|
||||
|
||||
DynPipLightingBag* DynamicPipeline::getLightingBag(
|
||||
MeshMaterialFrame* materialFrameFrom, MeshMaterialFrame* materialFrameTo,
|
||||
M4x4* model, const DynPipOptions* options,
|
||||
PipelineDirLightsBag* dirLightsBag, const u32& startIndex) const {
|
||||
const MeshMaterialFrame* materialFrameFrom,
|
||||
const MeshMaterialFrame* materialFrameTo, M4x4* model,
|
||||
const DynPipOptions* options, PipelineDirLightsBag* dirLightsBag,
|
||||
const u32& startIndex) const {
|
||||
if (!materialFrameFrom->normals || options == nullptr ||
|
||||
options->lighting == nullptr)
|
||||
return nullptr;
|
||||
|
||||
@@ -43,7 +43,8 @@ StaPipBagPackage* StaPipBagPackager::create(u16* o_size, StaPipBag* data,
|
||||
if (data->texture) result[i].sts = &data->texture->coordinates[i * size];
|
||||
|
||||
if (data->color->many)
|
||||
result[i].colors = reinterpret_cast<Vec4*>(&data->color->many[i * size]);
|
||||
result[i].colors =
|
||||
reinterpret_cast<const Vec4*>(&data->color->many[i * size]);
|
||||
|
||||
if (data->lighting) result[i].normals = &data->lighting->normals[i * size];
|
||||
|
||||
|
||||
@@ -37,10 +37,12 @@ void StaPipQBuffer::fillByPointer(const StaPipBagPackage& pkg) {
|
||||
|
||||
deallocateDynamicData();
|
||||
|
||||
vertices = pkg.vertices;
|
||||
sts = pkg.sts;
|
||||
colors = pkg.colors;
|
||||
normals = pkg.normals;
|
||||
// Too bad, but in reality const is not violated.
|
||||
// This class needs refactor
|
||||
vertices = const_cast<Vec4*>(pkg.vertices);
|
||||
sts = const_cast<Vec4*>(pkg.sts);
|
||||
colors = const_cast<Vec4*>(pkg.colors);
|
||||
normals = const_cast<Vec4*>(pkg.normals);
|
||||
size = pkg.size;
|
||||
bag = pkg.bag;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "renderer/3d/pipeline/static/core/stapip_qbuffer_renderer.hpp"
|
||||
#include "renderer/3d/pipeline/static/core/programs/stapip_vu1_shared_defines.h"
|
||||
#include "packet2/packet2_tyra_utils.hpp"
|
||||
|
||||
// #define TYRA_QBUFF_RENDERER_VERBOSE_LOG 1
|
||||
|
||||
@@ -135,8 +136,8 @@ void StaPipQBufferRenderer::sendObjectData(
|
||||
|
||||
if (singleColorEnabled) // Color is placed in 4th slot of
|
||||
// VU1_LIGHTS_MATRIX_ADDR
|
||||
packet2_utils_vu_add_unpack_data(objectDataPacket, VU1_SINGLE_COLOR_ADDR,
|
||||
bag->color->single->rgba, 1, false);
|
||||
Packet2TyraUtils::addUnpackData(objectDataPacket, VU1_SINGLE_COLOR_ADDR,
|
||||
bag->color->single->rgba, 1, false);
|
||||
|
||||
packet2_utils_vu_open_unpack(objectDataPacket, VU1_OPTIONS_ADDR, false);
|
||||
{
|
||||
|
||||
@@ -39,7 +39,13 @@ void StaticPipeline::onUseEnd() {
|
||||
core.deallocateOnUse();
|
||||
}
|
||||
|
||||
void StaticPipeline::render(StaticMesh* mesh, const StaPipOptions* options) {
|
||||
void StaticPipeline::render(const StaticMesh& mesh,
|
||||
const StaPipOptions* options) {
|
||||
render(&mesh, options);
|
||||
}
|
||||
|
||||
void StaticPipeline::render(const StaticMesh* mesh,
|
||||
const StaPipOptions* options) {
|
||||
bool optionsManuallyAllocated = false;
|
||||
|
||||
if (!options) {
|
||||
@@ -89,13 +95,13 @@ void StaticPipeline::render(StaticMesh* mesh, const StaPipOptions* options) {
|
||||
if (optionsManuallyAllocated) delete options;
|
||||
}
|
||||
|
||||
void StaticPipeline::addVertices(MeshMaterialFrame* materialFrame,
|
||||
void StaticPipeline::addVertices(const MeshMaterialFrame* materialFrame,
|
||||
StaPipBag* bag) const {
|
||||
bag->count = materialFrame->count;
|
||||
bag->vertices = materialFrame->vertices;
|
||||
}
|
||||
|
||||
StaPipInfoBag* StaticPipeline::getInfoBag(StaticMesh* mesh,
|
||||
StaPipInfoBag* StaticPipeline::getInfoBag(const StaticMesh* mesh,
|
||||
const StaPipOptions* options,
|
||||
M4x4* model) const {
|
||||
auto* result = new StaPipInfoBag();
|
||||
@@ -117,7 +123,8 @@ StaPipInfoBag* StaticPipeline::getInfoBag(StaticMesh* mesh,
|
||||
}
|
||||
|
||||
StaPipColorBag* StaticPipeline::getColorBag(
|
||||
MeshMaterial* material, MeshMaterialFrame* materialFrame) const {
|
||||
const MeshMaterial* material,
|
||||
const MeshMaterialFrame* materialFrame) const {
|
||||
auto* result = new StaPipColorBag();
|
||||
|
||||
if (material->lightmapFlag) {
|
||||
@@ -130,7 +137,7 @@ StaPipColorBag* StaticPipeline::getColorBag(
|
||||
}
|
||||
|
||||
StaPipTextureBag* StaticPipeline::getTextureBag(
|
||||
MeshMaterial* material, MeshMaterialFrame* materialFrame) {
|
||||
const MeshMaterial* material, const MeshMaterialFrame* materialFrame) {
|
||||
if (!materialFrame->textureCoords) return nullptr;
|
||||
|
||||
auto* result = new StaPipTextureBag();
|
||||
@@ -149,7 +156,7 @@ StaPipTextureBag* StaticPipeline::getTextureBag(
|
||||
}
|
||||
|
||||
StaPipLightingBag* StaticPipeline::getLightingBag(
|
||||
MeshMaterialFrame* materialFrame, M4x4* model,
|
||||
const MeshMaterialFrame* materialFrame, M4x4* model,
|
||||
const StaPipOptions* options) const {
|
||||
if (!materialFrame->normals || options == nullptr ||
|
||||
options->lighting == nullptr)
|
||||
@@ -181,7 +188,7 @@ void StaticPipeline::setLightingColorsCache(
|
||||
}
|
||||
|
||||
void StaticPipeline::deallocDrawBags(StaPipBag* bag,
|
||||
MeshMaterial* material) const {
|
||||
const MeshMaterial* material) const {
|
||||
if (bag->texture) {
|
||||
delete bag->texture;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user