init dynpip bag
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# 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/bag/dynpip_bag.hpp"
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
DynPipBag::DynPipBag() {
|
||||
info = nullptr;
|
||||
color = nullptr;
|
||||
texture = nullptr;
|
||||
lighting = nullptr;
|
||||
}
|
||||
|
||||
DynPipBag::~DynPipBag() {}
|
||||
|
||||
void DynPipBag::print() const {
|
||||
auto text = getPrint(nullptr);
|
||||
printf("%s\n", text.c_str());
|
||||
}
|
||||
|
||||
void DynPipBag::print(const char* name) const {
|
||||
auto text = getPrint(name);
|
||||
printf("%s\n", text.c_str());
|
||||
}
|
||||
|
||||
std::string DynPipBag::getPrint(const char* name) const {
|
||||
std::stringstream res;
|
||||
if (name) {
|
||||
res << name << "(";
|
||||
} else {
|
||||
res << "DynPipBag(";
|
||||
}
|
||||
res << std::fixed << std::setprecision(4);
|
||||
res << std::endl;
|
||||
res << "Count: " << count << ", " << std::endl;
|
||||
res << "Vertices present: " << (vertices != nullptr ? "Yes" : "No") << ", "
|
||||
<< std::endl;
|
||||
res << "Info present: " << (info != nullptr ? "Yes" : "No") << ", "
|
||||
<< std::endl;
|
||||
res << "Color present: " << (color != nullptr ? "Yes" : "No") << ", "
|
||||
<< std::endl;
|
||||
res << "Texture present: " << (texture != nullptr ? "Yes" : "No") << ", "
|
||||
<< std::endl;
|
||||
res << "Lighting present: " << (lighting != nullptr ? "Yes" : "No") << ", "
|
||||
<< std::endl;
|
||||
res << "Model matrix: " << info->model->getPrint() << ", " << std::endl;
|
||||
if (color->single) {
|
||||
res << "Color single: " << color->single->getPrint() << ", " << std::endl;
|
||||
} else {
|
||||
res << "Color many: " << color->many->getPrint() << ", " << std::endl;
|
||||
}
|
||||
if (texture) {
|
||||
res << "Texture coords present: "
|
||||
<< (texture->coordinates != nullptr ? "Yes" : "No") << ", "
|
||||
<< std::endl;
|
||||
res << "Texture: " << texture->texture->getPrint() << ", " << std::endl;
|
||||
}
|
||||
if (lighting) {
|
||||
res << "Lighting normals present: " << (lighting->normals ? "Yes" : "No")
|
||||
<< ", " << std::endl;
|
||||
res << "Lighting matrix: " << lighting->lightMatrix->getPrint() << ", "
|
||||
<< std::endl;
|
||||
}
|
||||
res << ")";
|
||||
|
||||
return res.str();
|
||||
}
|
||||
|
||||
} // namespace Tyra
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# 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/bag/dynpip_color_bag.hpp"
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
DynPipColorBag::DynPipColorBag() {
|
||||
single = nullptr;
|
||||
many = nullptr;
|
||||
}
|
||||
|
||||
DynPipColorBag::~DynPipColorBag() {}
|
||||
|
||||
} // namespace Tyra
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# 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/bag/dynpip_texture_bag.hpp"
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
DynPipTextureBag::DynPipTextureBag() {
|
||||
coordinates = nullptr;
|
||||
texture = nullptr;
|
||||
}
|
||||
|
||||
DynPipTextureBag::~DynPipTextureBag() {}
|
||||
|
||||
} // namespace Tyra
|
||||
@@ -19,8 +19,8 @@
|
||||
.init_vf_all
|
||||
.init_vi_all
|
||||
|
||||
#include "src/renderer/3d/pipeline/shared_macros/vcl_sml.i"
|
||||
#include "src/renderer/3d/pipeline/shared_macros/tyra_macros.i"
|
||||
#include "src/renderer/3d/pipeline/shared/vcl_sml.i"
|
||||
#include "src/renderer/3d/pipeline/shared/tyra_macros.i"
|
||||
#include "inc/renderer/3d/pipeline/dynamic/programs/dynpip_vu1_shared_defines.h"
|
||||
|
||||
#define RGBA_STORE_OFFSET 0
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
.init_vf_all
|
||||
.init_vi_all
|
||||
|
||||
#include "src/renderer/3d/pipeline/shared_macros/vcl_sml.i"
|
||||
#include "src/renderer/3d/pipeline/shared_macros/tyra_macros.i"
|
||||
#include "src/renderer/3d/pipeline/shared/vcl_sml.i"
|
||||
#include "src/renderer/3d/pipeline/shared/tyra_macros.i"
|
||||
#include "inc/renderer/3d/pipeline/dynamic/programs/dynpip_vu1_shared_defines.h"
|
||||
|
||||
#define RGBA_STORE_OFFSET 0
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
.init_vf_all
|
||||
.init_vi_all
|
||||
|
||||
#include "src/renderer/3d/pipeline/shared_macros/vcl_sml.i"
|
||||
#include "src/renderer/3d/pipeline/shared_macros/tyra_macros.i"
|
||||
#include "src/renderer/3d/pipeline/shared/vcl_sml.i"
|
||||
#include "src/renderer/3d/pipeline/shared/tyra_macros.i"
|
||||
#include "inc/renderer/3d/pipeline/dynamic/programs/dynpip_vu1_shared_defines.h"
|
||||
|
||||
#define STQ_STORE_OFFSET 0
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
.init_vf_all
|
||||
.init_vi_all
|
||||
|
||||
#include "src/renderer/3d/pipeline/shared_macros/vcl_sml.i"
|
||||
#include "src/renderer/3d/pipeline/shared_macros/tyra_macros.i"
|
||||
#include "src/renderer/3d/pipeline/shared/vcl_sml.i"
|
||||
#include "src/renderer/3d/pipeline/shared/tyra_macros.i"
|
||||
#include "inc/renderer/3d/pipeline/dynamic/programs/dynpip_vu1_shared_defines.h"
|
||||
|
||||
#define STQ_STORE_OFFSET 0
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
.init_vf_all
|
||||
.init_vi_all
|
||||
|
||||
#include "src/renderer/3d/pipeline/shared_macros/vcl_sml.i"
|
||||
#include "src/renderer/3d/pipeline/shared/vcl_sml.i"
|
||||
#include "inc/renderer/3d/pipeline/minecraft/programs/as_is/mcpip_vu1_as_is_shared_defines.h"
|
||||
#include "src/renderer/3d/pipeline/minecraft/programs/as_is/macros.i"
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
.init_vf_all
|
||||
.init_vi_all
|
||||
|
||||
#include "src/renderer/3d/pipeline/shared_macros/vcl_sml.i"
|
||||
#include "src/renderer/3d/pipeline/shared/vcl_sml.i"
|
||||
#include "inc/renderer/3d/pipeline/minecraft/programs/cull/mcpip_vu1_cull_shared_defines.h"
|
||||
#include "src/renderer/3d/pipeline/minecraft/programs/cull/macros.i"
|
||||
|
||||
|
||||
+3
-3
@@ -8,17 +8,17 @@
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#include "renderer/3d/pipeline/static/core/bag/stapip_info_bag.hpp"
|
||||
#include "renderer/3d/pipeline/shared/bag/pipeline_info_bag.hpp"
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
StaPipInfoBag::StaPipInfoBag() {
|
||||
PipelineInfoBag::PipelineInfoBag() {
|
||||
shadingType = StaPipShadingFlat;
|
||||
blendingEnabled = true;
|
||||
antiAliasingEnabled = false;
|
||||
model = nullptr;
|
||||
}
|
||||
|
||||
StaPipInfoBag::~StaPipInfoBag() {}
|
||||
PipelineInfoBag::~PipelineInfoBag() {}
|
||||
|
||||
} // namespace Tyra
|
||||
+19
-19
@@ -9,11 +9,11 @@
|
||||
*/
|
||||
|
||||
#include "debug/debug.hpp"
|
||||
#include "renderer/3d/pipeline/static/core/bag/stapip_lighting_bag.hpp"
|
||||
#include "renderer/3d/pipeline/shared/bag/pipeline_lighting_bag.hpp"
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
StaPipLightingBag::StaPipLightingBag(const bool& manual) {
|
||||
PipelineLightingBag::PipelineLightingBag(const bool& manual) {
|
||||
isAllocated = false;
|
||||
mode = Auto;
|
||||
normals = nullptr;
|
||||
@@ -27,33 +27,33 @@ StaPipLightingBag::StaPipLightingBag(const bool& manual) {
|
||||
}
|
||||
}
|
||||
|
||||
StaPipLightingBag::~StaPipLightingBag() { deallocate(); }
|
||||
PipelineLightingBag::~PipelineLightingBag() { deallocate(); }
|
||||
|
||||
void StaPipLightingBag::setAmbientColor(const Color& color) {
|
||||
void PipelineLightingBag::setAmbientColor(const Color& color) {
|
||||
TYRA_ASSERT(mode != Manual, "Ambient color cannot be set in manual mode");
|
||||
lightColors[3].set(reinterpret_cast<const Vec4&>(color));
|
||||
}
|
||||
|
||||
void StaPipLightingBag::setDirectionalLightColors(Color* colors,
|
||||
const u8& count) {
|
||||
void PipelineLightingBag::setDirectionalLightColors(Color* colors,
|
||||
const u8& count) {
|
||||
for (u8 i = 0; i < count; i++) setDirectionalLightColor(colors[i], i);
|
||||
}
|
||||
|
||||
void StaPipLightingBag::setDirectionalLightDirections(Vec4* directions,
|
||||
const u8& count) {
|
||||
void PipelineLightingBag::setDirectionalLightDirections(Vec4* directions,
|
||||
const u8& count) {
|
||||
for (u8 i = 0; i < count; i++) setDirectionalLightDirection(directions[i], i);
|
||||
}
|
||||
|
||||
void StaPipLightingBag::setDirectionalLightColor(const Color& color,
|
||||
const u8& index) {
|
||||
void PipelineLightingBag::setDirectionalLightColor(const Color& color,
|
||||
const u8& index) {
|
||||
TYRA_ASSERT(mode != Manual,
|
||||
"Directional lights cannot be set in manual mode");
|
||||
TYRA_ASSERT(index < 3, "There are max 3 directional lights");
|
||||
lightColors[index].set(reinterpret_cast<const Vec4&>(color));
|
||||
}
|
||||
|
||||
void StaPipLightingBag::setDirectionalLightDirection(const Vec4& direction,
|
||||
const u8& index) {
|
||||
void PipelineLightingBag::setDirectionalLightDirection(const Vec4& direction,
|
||||
const u8& index) {
|
||||
TYRA_ASSERT(mode != Manual,
|
||||
"Directional lights cannot be set in manual mode");
|
||||
TYRA_ASSERT(index < 3, "There are max 3 directional lights");
|
||||
@@ -61,19 +61,19 @@ void StaPipLightingBag::setDirectionalLightDirection(const Vec4& direction,
|
||||
lightDirections[index].set(direction);
|
||||
}
|
||||
|
||||
void StaPipLightingBag::setLightsManually(Vec4* colors, Vec4* directions) {
|
||||
void PipelineLightingBag::setLightsManually(Vec4* colors, Vec4* directions) {
|
||||
deallocate();
|
||||
lightColors = colors;
|
||||
lightDirections = directions;
|
||||
mode = Manual;
|
||||
}
|
||||
|
||||
void StaPipLightingBag::disableManualMode() {
|
||||
void PipelineLightingBag::disableManualMode() {
|
||||
allocate();
|
||||
mode = Auto;
|
||||
}
|
||||
|
||||
void StaPipLightingBag::allocate() {
|
||||
void PipelineLightingBag::allocate() {
|
||||
if (isAllocated) return;
|
||||
|
||||
lightColors = new Vec4[4];
|
||||
@@ -92,27 +92,27 @@ void StaPipLightingBag::allocate() {
|
||||
isAllocated = true;
|
||||
}
|
||||
|
||||
void StaPipLightingBag::deallocate() {
|
||||
void PipelineLightingBag::deallocate() {
|
||||
if (!isAllocated) return;
|
||||
|
||||
forceDeallocate();
|
||||
}
|
||||
|
||||
void StaPipLightingBag::forceDeallocate() {
|
||||
void PipelineLightingBag::forceDeallocate() {
|
||||
forceDeallocateColors();
|
||||
forceDeallocateDirections();
|
||||
|
||||
isAllocated = false;
|
||||
}
|
||||
|
||||
void StaPipLightingBag::forceDeallocateColors() {
|
||||
void PipelineLightingBag::forceDeallocateColors() {
|
||||
if (lightColors != nullptr) {
|
||||
delete[] lightColors;
|
||||
lightColors = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void StaPipLightingBag::forceDeallocateDirections() {
|
||||
void PipelineLightingBag::forceDeallocateDirections() {
|
||||
if (lightDirections != nullptr) {
|
||||
delete[] lightDirections;
|
||||
lightDirections = nullptr;
|
||||
@@ -18,8 +18,8 @@
|
||||
.init_vf_all
|
||||
.init_vi_all
|
||||
|
||||
#include "src/renderer/3d/pipeline/shared_macros/vcl_sml.i"
|
||||
#include "src/renderer/3d/pipeline/shared_macros/tyra_macros.i"
|
||||
#include "src/renderer/3d/pipeline/shared/vcl_sml.i"
|
||||
#include "src/renderer/3d/pipeline/shared/tyra_macros.i"
|
||||
#include "inc/renderer/3d/pipeline/static/core/programs/stapip_vu1_shared_defines.h"
|
||||
|
||||
#define RGBA_STORE_OFFSET 0
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
.init_vf_all
|
||||
.init_vi_all
|
||||
|
||||
#include "src/renderer/3d/pipeline/shared_macros/vcl_sml.i"
|
||||
#include "src/renderer/3d/pipeline/shared_macros/tyra_macros.i"
|
||||
#include "src/renderer/3d/pipeline/shared/vcl_sml.i"
|
||||
#include "src/renderer/3d/pipeline/shared/tyra_macros.i"
|
||||
#include "inc/renderer/3d/pipeline/static/core/programs/stapip_vu1_shared_defines.h"
|
||||
|
||||
#define RGBA_STORE_OFFSET 0
|
||||
|
||||
+2
-2
@@ -18,8 +18,8 @@
|
||||
.init_vf_all
|
||||
.init_vi_all
|
||||
|
||||
#include "src/renderer/3d/pipeline/shared_macros/vcl_sml.i"
|
||||
#include "src/renderer/3d/pipeline/shared_macros/tyra_macros.i"
|
||||
#include "src/renderer/3d/pipeline/shared/vcl_sml.i"
|
||||
#include "src/renderer/3d/pipeline/shared/tyra_macros.i"
|
||||
#include "inc/renderer/3d/pipeline/static/core/programs/stapip_vu1_shared_defines.h"
|
||||
|
||||
#define STQ_STORE_OFFSET 0
|
||||
|
||||
+2
-2
@@ -18,8 +18,8 @@
|
||||
.init_vf_all
|
||||
.init_vi_all
|
||||
|
||||
#include "src/renderer/3d/pipeline/shared_macros/vcl_sml.i"
|
||||
#include "src/renderer/3d/pipeline/shared_macros/tyra_macros.i"
|
||||
#include "src/renderer/3d/pipeline/shared/vcl_sml.i"
|
||||
#include "src/renderer/3d/pipeline/shared/tyra_macros.i"
|
||||
#include "inc/renderer/3d/pipeline/static/core/programs/stapip_vu1_shared_defines.h"
|
||||
|
||||
#define STQ_STORE_OFFSET 0
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
.init_vf_all
|
||||
.init_vi_all
|
||||
|
||||
#include "src/renderer/3d/pipeline/shared_macros/vcl_sml.i"
|
||||
#include "src/renderer/3d/pipeline/shared_macros/tyra_macros.i"
|
||||
#include "src/renderer/3d/pipeline/shared/vcl_sml.i"
|
||||
#include "src/renderer/3d/pipeline/shared/tyra_macros.i"
|
||||
#include "inc/renderer/3d/pipeline/static/core/programs/stapip_vu1_shared_defines.h"
|
||||
|
||||
#define RGBA_STORE_OFFSET 0
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
.init_vf_all
|
||||
.init_vi_all
|
||||
|
||||
#include "src/renderer/3d/pipeline/shared_macros/vcl_sml.i"
|
||||
#include "src/renderer/3d/pipeline/shared_macros/tyra_macros.i"
|
||||
#include "src/renderer/3d/pipeline/shared/vcl_sml.i"
|
||||
#include "src/renderer/3d/pipeline/shared/tyra_macros.i"
|
||||
#include "inc/renderer/3d/pipeline/static/core/programs/stapip_vu1_shared_defines.h"
|
||||
|
||||
#define RGBA_STORE_OFFSET 0
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
.init_vf_all
|
||||
.init_vi_all
|
||||
|
||||
#include "src/renderer/3d/pipeline/shared_macros/vcl_sml.i"
|
||||
#include "src/renderer/3d/pipeline/shared_macros/tyra_macros.i"
|
||||
#include "src/renderer/3d/pipeline/shared/vcl_sml.i"
|
||||
#include "src/renderer/3d/pipeline/shared/tyra_macros.i"
|
||||
#include "inc/renderer/3d/pipeline/static/core/programs/stapip_vu1_shared_defines.h"
|
||||
|
||||
#define STQ_STORE_OFFSET 0
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
.init_vf_all
|
||||
.init_vi_all
|
||||
|
||||
#include "src/renderer/3d/pipeline/shared_macros/vcl_sml.i"
|
||||
#include "src/renderer/3d/pipeline/shared_macros/tyra_macros.i"
|
||||
#include "src/renderer/3d/pipeline/shared/vcl_sml.i"
|
||||
#include "src/renderer/3d/pipeline/shared/tyra_macros.i"
|
||||
#include "inc/renderer/3d/pipeline/static/core/programs/stapip_vu1_shared_defines.h"
|
||||
|
||||
#define STQ_STORE_OFFSET 0
|
||||
|
||||
@@ -130,7 +130,7 @@ void StaPipQBufferRenderer::sendObjectData(
|
||||
dma_channel_send_packet2(objectDataPacket, DMA_CHANNEL_VIF1, true);
|
||||
}
|
||||
|
||||
void StaPipQBufferRenderer::setInfo(StaPipInfoBag* bag) {
|
||||
void StaPipQBufferRenderer::setInfo(PipelineInfoBag* bag) {
|
||||
rendererCore->gs.prim.antialiasing = bag->antiAliasingEnabled;
|
||||
rendererCore->gs.prim.blending = bag->blendingEnabled;
|
||||
rendererCore->gs.prim.shading = bag->shadingType;
|
||||
|
||||
@@ -83,10 +83,10 @@ void StaticPipeline::addVertices(DynamicMesh* mesh, MeshMaterial* material,
|
||||
}
|
||||
}
|
||||
|
||||
StaPipInfoBag* StaticPipeline::getInfoBag(DynamicMesh* mesh,
|
||||
const StaPipOptions* options,
|
||||
M4x4* model) const {
|
||||
auto* result = new StaPipInfoBag();
|
||||
PipelineInfoBag* StaticPipeline::getInfoBag(DynamicMesh* mesh,
|
||||
const StaPipOptions* options,
|
||||
M4x4* model) const {
|
||||
auto* result = new PipelineInfoBag();
|
||||
|
||||
if (options) {
|
||||
result->antiAliasingEnabled = options->antiAliasingEnabled;
|
||||
@@ -163,7 +163,7 @@ StaPipTextureBag* StaticPipeline::getTextureBag(DynamicMesh* mesh,
|
||||
return result;
|
||||
}
|
||||
|
||||
StaPipLightingBag* StaticPipeline::getLightingBag(
|
||||
PipelineLightingBag* StaticPipeline::getLightingBag(
|
||||
DynamicMesh* mesh, MeshMaterial* material, M4x4* model,
|
||||
MeshFrame* frameFrom, MeshFrame* frameTo,
|
||||
const StaPipOptions* options) const {
|
||||
@@ -171,7 +171,7 @@ StaPipLightingBag* StaticPipeline::getLightingBag(
|
||||
options->lighting == nullptr)
|
||||
return nullptr;
|
||||
|
||||
auto* result = new StaPipLightingBag(true);
|
||||
auto* result = new PipelineLightingBag(true);
|
||||
result->lightMatrix = model;
|
||||
|
||||
result->setLightsManually(colorsCache,
|
||||
|
||||
Reference in New Issue
Block a user