diff --git a/engine/inc/renderer/3d/pipeline/static/core/bag/packaging/stapip_bag_packages_bbox.hpp b/engine/inc/renderer/3d/pipeline/static/core/bag/packaging/stapip_bag_packages_bbox.hpp index 94ddd1f..78af0db 100644 --- a/engine/inc/renderer/3d/pipeline/static/core/bag/packaging/stapip_bag_packages_bbox.hpp +++ b/engine/inc/renderer/3d/pipeline/static/core/bag/packaging/stapip_bag_packages_bbox.hpp @@ -42,6 +42,8 @@ class StaPipBagPackagesBBox { /** @brief Get amount of vertices */ const u32& getVertexCount() const; + const std::vector& getParts() const { return *bboxParts; } + /** * @brief For example if we want to build a bbox from 96-112 vertices, we * should input index = 3, partsSize = 1 diff --git a/engine/inc/renderer/3d/pipeline/static/core/stapip_qbuffer_renderer.hpp b/engine/inc/renderer/3d/pipeline/static/core/stapip_qbuffer_renderer.hpp index 9f4a911..2409076 100644 --- a/engine/inc/renderer/3d/pipeline/static/core/stapip_qbuffer_renderer.hpp +++ b/engine/inc/renderer/3d/pipeline/static/core/stapip_qbuffer_renderer.hpp @@ -97,7 +97,6 @@ class StaPipQBufferRenderer { packet2_t** packets; StaPipVU1Program** dBufferPrograms; StaPipQBuffer** buffers; - packet2_t* currentPacket; packet2_t* staticDataPacket; packet2_t* objectDataPacket; diff --git a/engine/inc/renderer/core/3d/bbox/core_bbox.hpp b/engine/inc/renderer/core/3d/bbox/core_bbox.hpp index 0d2f4a5..db4db85 100644 --- a/engine/inc/renderer/core/3d/bbox/core_bbox.hpp +++ b/engine/inc/renderer/core/3d/bbox/core_bbox.hpp @@ -31,6 +31,7 @@ class CoreBBox { const u32& startIndex, const u32& stopIndex); const Vec4& operator[](const u8& i) { return _vertices[i]; } + const u8 getVertexCount() { return 8; } const Vec4& getVertex(const u8& i) { return _vertices[i]; } Vec4* getVertices() { return _vertices; } diff --git a/engine/src/renderer/3d/pipeline/shared/vcl_sml.i b/engine/src/renderer/3d/pipeline/shared/vcl_sml.i index d1bb727..92e1123 100644 --- a/engine/src/renderer/3d/pipeline/shared/vcl_sml.i +++ b/engine/src/renderer/3d/pipeline/shared/vcl_sml.i @@ -1381,8 +1381,6 @@ QSL3@: ;//--------------------------------------------------------- ;// PerformClipCheck - checks if the vertex is outside the viewing frustum. ;// If it is, then the appropriate clipping flags are set. -;// Not using sqi instruction, because VCL cannot optimize it. -;// Primtag contains information about how many polys we will send ;// 2 - Bitwise AND the clipping flags with 0x3FFFF, this makes sure that ;// we get the clipping judgement for the last three verts ;// (i.e. that make up the triangle we are about to draw) diff --git a/engine/src/renderer/3d/pipeline/static/core/bag/packaging/stapip_bag_packager.cpp b/engine/src/renderer/3d/pipeline/static/core/bag/packaging/stapip_bag_packager.cpp index 649e4a8..39091d0 100644 --- a/engine/src/renderer/3d/pipeline/static/core/bag/packaging/stapip_bag_packager.cpp +++ b/engine/src/renderer/3d/pipeline/static/core/bag/packaging/stapip_bag_packager.cpp @@ -106,10 +106,9 @@ CoreBBoxFrustum StaPipBagPackager::checkFrustum(const StaPipBagPackage& pkg) { auto& bbox = renderBBox->getChildBBox1By3(pkg.indexOf1By3BBox); return bbox.clipIsInFrustum(frustumPlanes->getAll(), *pkg.bag->info->model); } else { // Is package - auto bbox = renderBBox->createChildBBox( - pkg.indexOf1By3BBox, - ceil(pkg.size / static_cast(maxVertCount / 3))); - + const auto& indexOfPart = pkg.indexOf1By3BBox; + auto partSize = ceil(pkg.size / static_cast(maxVertCount / 3)); + auto bbox = renderBBox->createChildBBox(indexOfPart, partSize); return bbox.clipIsInFrustum(frustumPlanes->getAll(), *pkg.bag->info->model); } } diff --git a/engine/src/renderer/3d/pipeline/static/core/bag/packaging/stapip_bag_packages_bbox.cpp b/engine/src/renderer/3d/pipeline/static/core/bag/packaging/stapip_bag_packages_bbox.cpp index d17c85c..b6eb72d 100644 --- a/engine/src/renderer/3d/pipeline/static/core/bag/packaging/stapip_bag_packages_bbox.cpp +++ b/engine/src/renderer/3d/pipeline/static/core/bag/packaging/stapip_bag_packages_bbox.cpp @@ -72,7 +72,7 @@ const u32& StaPipBagPackagesBBox::getVertexCount() const { return vertexCount; } RenderBBox StaPipBagPackagesBBox::createChildBBox(const u32& index, const u16& partsSize) const { - return RenderBBox(*bboxParts, index, partsSize); + return RenderBBox(*bboxParts, index, index + partsSize); } void StaPipBagPackagesBBox::print() const { diff --git a/engine/src/renderer/3d/pipeline/static/core/programs/as_is/stapip_as_is_c_vu1.vclpp b/engine/src/renderer/3d/pipeline/static/core/programs/as_is/stapip_as_is_c_vu1.vclpp index 1c63352..055dc5d 100644 --- a/engine/src/renderer/3d/pipeline/static/core/programs/as_is/stapip_as_is_c_vu1.vclpp +++ b/engine/src/renderer/3d/pipeline/static/core/programs/as_is/stapip_as_is_c_vu1.vclpp @@ -90,6 +90,11 @@ processing: ScaleVertexToGSFormat{ scale, vertex3 } FixColor{ color3 } + iaddiu adcBit, VI00, 0x0 + isw.w adcBit, XYZ2_STORE_OFFSET(destAddress) + isw.w adcBit, XYZ2_STORE_OFFSET+2(destAddress) + isw.w adcBit, XYZ2_STORE_OFFSET+4(destAddress) + ;--- Store vertex1 sq color1, RGBA_STORE_OFFSET(destAddress) sq.xyz vertex1, XYZ2_STORE_OFFSET(destAddress) diff --git a/engine/src/renderer/3d/pipeline/static/core/programs/as_is/stapip_as_is_d_vu1.vclpp b/engine/src/renderer/3d/pipeline/static/core/programs/as_is/stapip_as_is_d_vu1.vclpp index d9071fa..1341dd9 100644 --- a/engine/src/renderer/3d/pipeline/static/core/programs/as_is/stapip_as_is_d_vu1.vclpp +++ b/engine/src/renderer/3d/pipeline/static/core/programs/as_is/stapip_as_is_d_vu1.vclpp @@ -76,6 +76,11 @@ vertexLoop: CalculateTyraDirectionalLights{ outputColor3, normal3, lightDirections, lightColors, lightMatrix, ambientColor } FixColor{ outputColor3 } + iaddiu adcBit, VI00, 0x0 + isw.w adcBit, XYZ2_STORE_OFFSET(destAddress) + isw.w adcBit, XYZ2_STORE_OFFSET+2(destAddress) + isw.w adcBit, XYZ2_STORE_OFFSET+4(destAddress) + ;--- Store vertex1 sq outputColor1, RGBA_STORE_OFFSET(destAddress) sq.xyz vertex1, XYZ2_STORE_OFFSET(destAddress) diff --git a/engine/src/renderer/3d/pipeline/static/core/programs/as_is/stapip_as_is_tc_vu1.vclpp b/engine/src/renderer/3d/pipeline/static/core/programs/as_is/stapip_as_is_tc_vu1.vclpp index 90775ab..5a5c4d5 100644 --- a/engine/src/renderer/3d/pipeline/static/core/programs/as_is/stapip_as_is_tc_vu1.vclpp +++ b/engine/src/renderer/3d/pipeline/static/core/programs/as_is/stapip_as_is_tc_vu1.vclpp @@ -101,6 +101,11 @@ processing: PerformTexturePerspectiveCorrection{ outputStq3, stq3 } FixColor{ color3 } + iaddiu adcBit, VI00, 0x0 + isw.w adcBit, XYZ2_STORE_OFFSET(destAddress) + isw.w adcBit, XYZ2_STORE_OFFSET+3(destAddress) + isw.w adcBit, XYZ2_STORE_OFFSET+6(destAddress) + ;--- Store vertex1 sq outputStq1, STQ_STORE_OFFSET(destAddress) sq color1, RGBA_STORE_OFFSET(destAddress) diff --git a/engine/src/renderer/3d/pipeline/static/core/programs/as_is/stapip_as_is_td_vu1.vclpp b/engine/src/renderer/3d/pipeline/static/core/programs/as_is/stapip_as_is_td_vu1.vclpp index b072c83..39e7574 100644 --- a/engine/src/renderer/3d/pipeline/static/core/programs/as_is/stapip_as_is_td_vu1.vclpp +++ b/engine/src/renderer/3d/pipeline/static/core/programs/as_is/stapip_as_is_td_vu1.vclpp @@ -87,6 +87,11 @@ vertexLoop: CalculateTyraDirectionalLights{ outputColor3, normal3, lightDirections, lightColors, lightMatrix, ambientColor } FixColor{ outputColor3 } + iaddiu adcBit, VI00, 0x0 + isw.w adcBit, XYZ2_STORE_OFFSET(destAddress) + isw.w adcBit, XYZ2_STORE_OFFSET+3(destAddress) + isw.w adcBit, XYZ2_STORE_OFFSET+6(destAddress) + ;--- Store vertex1 sq outputStq1, STQ_STORE_OFFSET(destAddress) sq outputColor1, RGBA_STORE_OFFSET(destAddress) diff --git a/engine/src/renderer/3d/pipeline/static/core/stapip_qbuffer_renderer.cpp b/engine/src/renderer/3d/pipeline/static/core/stapip_qbuffer_renderer.cpp index a8837d5..43e3283 100644 --- a/engine/src/renderer/3d/pipeline/static/core/stapip_qbuffer_renderer.cpp +++ b/engine/src/renderer/3d/pipeline/static/core/stapip_qbuffer_renderer.cpp @@ -11,7 +11,7 @@ #include "renderer/3d/pipeline/static/core/stapip_qbuffer_renderer.hpp" #include "renderer/3d/pipeline/static/core/programs/stapip_vu1_shared_defines.h" -#define TYRA_QBUFF_RENDERER_VERBOSE_LOG 1 +// #define TYRA_QBUFF_RENDERER_VERBOSE_LOG 1 #ifdef TYRA_QBUFF_RENDERER_VERBOSE_LOG #define Verbose(...) Debug::writeLines("VRB: ", ##__VA_ARGS__, "\n") @@ -272,11 +272,11 @@ void StaPipQBufferRenderer::cull(StaPipQBuffer* buffer) { dBufferPrograms[getQBufferIndex(buffer)] = getCullProgramByBag(buffer->bag); + Verbose("Add cull[", getQBufferIndex(buffer), "]: ", buffer->size); + auto is1stDBuffer = is1stDBufferFlushTime(); auto is2ndDBuffer = is2ndDBufferFlushTime(); - Verbose("Add cull[", getQBufferIndex(buffer), "]: ", buffer->size); - if (is1stDBuffer || is2ndDBuffer) { auto from = is1stDBuffer ? 0 : buffersCount / 2; auto to = from + buffersCount / 2; @@ -321,7 +321,7 @@ void StaPipQBufferRenderer::clearLastProgramName() { void StaPipQBufferRenderer::addBuffersDataToPacket(const u32& from, const u32& to) { - currentPacket = packets[context]; + auto* currentPacket = packets[context]; packet2_reset(currentPacket, false); for (u32 i = from; i < to; i++) { @@ -346,6 +346,7 @@ void StaPipQBufferRenderer::addBuffersDataToPacket(const u32& from, } void StaPipQBufferRenderer::sendPacket() { + auto* currentPacket = packets[context]; dma_channel_wait(DMA_CHANNEL_VIF1, 0); dma_channel_send_packet2(currentPacket, DMA_CHANNEL_VIF1, true); diff --git a/engine/src/renderer/core/3d/bbox/render_bbox.cpp b/engine/src/renderer/core/3d/bbox/render_bbox.cpp index e09435c..c7ef19a 100644 --- a/engine/src/renderer/core/3d/bbox/render_bbox.cpp +++ b/engine/src/renderer/core/3d/bbox/render_bbox.cpp @@ -46,6 +46,7 @@ CoreBBoxFrustum RenderBBox::clipIsInFrustum(const Plane* frustumPlanes, // Oh no, it probably needs clipping + // This is crappy guard band, but it works xd float guardBand[6]; // This probably needs more calibration guardBand[0] = -15.0F; // Top