ztest option
This commit is contained in:
@@ -73,7 +73,7 @@ u32 StaPipCore::getMaxVertCountByParams(const bool& isSingleColor,
|
||||
}
|
||||
|
||||
void StaPipCore::render(StaPipBag* bag, const bool& frustumCull,
|
||||
StaPipBagPackagesBBox* bbox) {
|
||||
const StaPipZTest& zTest, StaPipBagPackagesBBox* bbox) {
|
||||
if (bag->count <= 0) return;
|
||||
|
||||
TYRA_ASSERT(bag->vertices != nullptr,
|
||||
@@ -128,6 +128,10 @@ void StaPipCore::render(StaPipBag* bag, const bool& frustumCull,
|
||||
}
|
||||
}
|
||||
|
||||
if (zTest == StaPipZTest_AllPass) {
|
||||
rendererCore->gs.setAllPassZTest();
|
||||
}
|
||||
|
||||
packager.setRenderBBox(renderBbox);
|
||||
|
||||
M4x4 mvp;
|
||||
@@ -204,6 +208,10 @@ void StaPipCore::render(StaPipBag* bag, const bool& frustumCull,
|
||||
|
||||
qbufferRenderer.flushBuffers();
|
||||
|
||||
if (zTest == StaPipZTest_AllPass) {
|
||||
rendererCore->gs.setStandardZTest();
|
||||
}
|
||||
|
||||
Verbose("Render finished");
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ void StaticPipeline::render(StaticMesh* mesh, const StaPipOptions* options) {
|
||||
auto model = mesh->getModelMatrix();
|
||||
auto* infoBag = getInfoBag(mesh, options, &model);
|
||||
|
||||
auto zTesting = options ? options->zTestType : StaPipZTest_Standard;
|
||||
auto frustumCulling =
|
||||
options ? options->frustumCulling : PipelineFrustumCulling_Simple;
|
||||
|
||||
@@ -75,7 +76,8 @@ void StaticPipeline::render(StaticMesh* mesh, const StaPipOptions* options) {
|
||||
bag.texture = getTextureBag(material, materialFrame);
|
||||
bag.lighting = getLightingBag(materialFrame, &model, options);
|
||||
|
||||
core.render(&bag, frustumCulling == PipelineFrustumCulling_Precise);
|
||||
core.render(&bag, frustumCulling == PipelineFrustumCulling_Precise,
|
||||
zTesting);
|
||||
|
||||
deallocDrawBags(&bag, material);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,9 @@ RendererCoreGS::~RendererCoreGS() {
|
||||
if (flipPacket) {
|
||||
packet2_free(flipPacket);
|
||||
}
|
||||
if (zTestPacket) {
|
||||
packet2_free(zTestPacket);
|
||||
}
|
||||
}
|
||||
|
||||
void RendererCoreGS::init(RendererSettings* t_settings) {
|
||||
@@ -39,6 +42,7 @@ void RendererCoreGS::init(RendererSettings* t_settings) {
|
||||
|
||||
initChannels();
|
||||
flipPacket = packet2_create(4, P2_TYPE_UNCACHED_ACCL, P2_MODE_NORMAL, 0);
|
||||
zTestPacket = packet2_create(3, P2_TYPE_NORMAL, P2_MODE_NORMAL, 0);
|
||||
allocateBuffers();
|
||||
initDrawingEnvironment();
|
||||
|
||||
@@ -49,6 +53,21 @@ void RendererCoreGS::initChannels() {
|
||||
dma_channel_initialize(DMA_CHANNEL_GIF, NULL, 0);
|
||||
}
|
||||
|
||||
void RendererCoreGS::setStandardZTest() {
|
||||
packet2_reset(zTestPacket, false);
|
||||
packet2_update(zTestPacket,
|
||||
draw_enable_tests(zTestPacket->base, 0, &zBuffer));
|
||||
dma_channel_wait(DMA_CHANNEL_GIF, 0);
|
||||
dma_channel_send_packet2(zTestPacket, DMA_CHANNEL_GIF, true);
|
||||
}
|
||||
|
||||
void RendererCoreGS::setAllPassZTest() {
|
||||
packet2_reset(zTestPacket, false);
|
||||
packet2_update(zTestPacket, addAllPassZTest(zTestPacket->base, 0, &zBuffer));
|
||||
dma_channel_wait(DMA_CHANNEL_GIF, 0);
|
||||
dma_channel_send_packet2(zTestPacket, DMA_CHANNEL_GIF, true);
|
||||
}
|
||||
|
||||
void RendererCoreGS::allocateBuffers() {
|
||||
frameBuffers[0].width = static_cast<unsigned int>(settings->getWidth());
|
||||
frameBuffers[0].height = static_cast<unsigned int>(settings->getHeight());
|
||||
@@ -119,6 +138,20 @@ qword_t* RendererCoreGS::setXYOffset(qword_t* q, const int& drawContext,
|
||||
return q;
|
||||
}
|
||||
|
||||
qword_t* RendererCoreGS::addAllPassZTest(qword_t* q, int context,
|
||||
zbuffer_t* z) {
|
||||
(void)z;
|
||||
|
||||
PACK_GIFTAG(q, GIF_SET_TAG(1, 0, 0, 0, GIF_FLG_PACKED, 1), GIF_REG_AD);
|
||||
q++;
|
||||
|
||||
PACK_GIFTAG(q, GS_SET_TEST(0, 0, 0, 0, 0, 0, 0, ZTEST_METHOD_ALLPASS),
|
||||
GS_REG_TEST + context);
|
||||
q++;
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
void RendererCoreGS::flipBuffers() {
|
||||
graph_set_framebuffer_filtered(frameBuffers[context].address,
|
||||
frameBuffers[context].width,
|
||||
|
||||
Reference in New Issue
Block a user