std pipeline rename

This commit is contained in:
h4570
2022-07-18 19:46:06 +02:00
parent 632be84ceb
commit bb02a3d9bf
70 changed files with 679 additions and 680 deletions
@@ -0,0 +1,50 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include "../stapip_bag.hpp"
#include "renderer/core/3d/bbox/core_bbox_frustum.hpp"
namespace Tyra {
class StapipBagPackage {
public:
StapipBagPackage();
~StapipBagPackage();
StapipBag* bag;
Vec4* vertices;
Vec4* sts;
Vec4* normals;
Vec4* colors;
/** maxVertCount is max value, because we decided to put max maxVertCount
* verts to single quad buffer in VU1 */
u16 size;
CoreBBoxFrustum isInFrustum;
/**
* We are creating StapipBagPackagesBBox which checks CoreBBoxBBox for every
* maxVertCount / 3. So this variable is index of starting
* StapipBagPackagesBBox's CoreBBoxBBox. If package have <= maxVertCount / 3
* verts, we will need only single (starting) bbox. if package have
* maxVertCount verts, we will calculate CoreBBoxBBox from 3
* StapipBagPackagesBBox's bboxes.
*/
u32 indexOf1By3BBox;
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;
};
} // namespace Tyra
@@ -0,0 +1,52 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include "renderer/core/3d/bbox/core_bbox.hpp"
#include "renderer/core/3d/renderer_3d_frustum_planes.hpp"
#include "renderer/core/paths/path1/clipper/path1_ee_clip_algorithm.hpp"
#include "./stapip_bag_packages_bbox.hpp"
#include "./stapip_bag_package.hpp"
#include "../stapip_bag.hpp"
namespace Tyra {
class StapipBagPackager {
public:
StapipBagPackager();
~StapipBagPackager();
void init(Renderer3DFrustumPlanes* frustumPlanes);
void setRenderBBox(StapipBagPackagesBBox* bbox) { renderBBox = bbox; }
void setMaxVertCount(const u32& count);
/**
* @brief Create render packages from provided render data
*
* @param size Max maxVertCount verts (VU1 buffer size)
*/
StapipBagPackage* create(u16* o_size, StapipBag* data, u16 size);
/**
* @brief Split render package to smaller packages
*
* @param size Max maxVertCount verts (VU1 buffer size)
*/
StapipBagPackage* create(u16* o_size, const StapipBagPackage& pkg, u16 size);
CoreBBoxFrustum checkFrustum(const StapipBagPackage& pkg);
private:
u32 maxVertCount;
Renderer3DFrustumPlanes* frustumPlanes;
StapipBagPackagesBBox* renderBBox;
};
} // namespace Tyra
@@ -0,0 +1,69 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include "renderer/core/3d/bbox/render_bbox.hpp"
namespace Tyra {
/**
* Splits all 3D input vertices into 16vert parts and creates child bboxes for
* it
*/
class StapipBagPackagesBBox {
public:
StapipBagPackagesBBox(Vec4* t_vertices, u32* t_faces, const u32& t_facesCount,
const u32& t_maxVertCount);
StapipBagPackagesBBox(Vec4* t_vertices, const u32& t_counts,
const u32& t_maxVertCount);
~StapipBagPackagesBBox();
void setMaxVertCount(const u32& count);
/**
* @param index Index of part
*/
const RenderBBox& getChildBBox1By3(const u32& index) const;
/** @brief CoreBBox created from all of vertices */
RenderBBox* getMainBBox();
/** @brief Get amount of child Bbox1/3 parts */
const u32& getPartsCount() const;
/** @brief Get amount of vertices */
const u32& getVertexCount() const;
/**
* @brief For example if we want to build a bbox from 96-112 vertices, we
* should input index = 3, partsSize = 1
* @param index Index of part
* @param partsSize How many 1/3 parts
*/
RenderBBox createChildBBox(const u32& index, const u16& partsSize) const;
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;
u32 vertexCount, partsCount;
/** @brief CoreBBox of all vertices */
RenderBBox* mainBBox;
/** @brief Bounding boxes of 1/3 vertices */
std::vector<CoreBBox>* bboxParts;
};
} // namespace Tyra
@@ -0,0 +1,62 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include "math/vec4.hpp"
#include "./stapip_lighting_bag.hpp"
#include "./stapip_info_bag.hpp"
#include "./stapip_color_bag.hpp"
#include "./stapip_texture_bag.hpp"
#include "renderer/core/texture/models/texture.hpp"
#include "./packaging/stapip_bag_packages_bbox.hpp"
namespace Tyra {
/**
* @brief 3D Render data bag.
* Supports frustum culling, clipping, lighting,
* texture and single color / many colors.
*/
class StapipBag {
public:
StapipBag();
~StapipBag();
/** Mandatory. Object info. */
StapipInfoBag* info;
/** Mandatory. Object color(s). */
StapipColorBag* color;
/** Mandatory. Vertex count. */
u32 count;
/** Mandatory. Vertices. */
Vec4* vertices;
/** Optional. Texture coordinates and image. */
StapipTextureBag* texture;
/** Optional. Object lighting. */
StapipLightingBag* lighting;
/**
* @param maxVertCount This parameter is available in renderer API.
*/
StapipBagPackagesBBox calculateBbox(const u32& maxVertCount);
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;
};
} // namespace Tyra
@@ -0,0 +1,32 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include "renderer/models/color.hpp"
namespace Tyra {
/**
* @brief Color data. At least one color data is required (single/many).
*/
class StapipColorBag {
public:
StapipColorBag();
~StapipColorBag();
/** Optional. Single color for all vertices. */
Color* single;
/** Optional. Color per vertex. */
Color* many;
};
} // namespace Tyra
@@ -0,0 +1,34 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include <draw.h>
#include "math/m4x4.hpp"
#include "math/vec4.hpp"
#include "../../stapip_shading_type.hpp"
namespace Tyra {
class StapipInfoBag {
public:
StapipInfoBag();
~StapipInfoBag();
/** Mandatory. Model matrix */
M4x4* model;
StapipShadingType shadingType;
bool blendingEnabled;
bool antiAliasingEnabled;
bool noClipChecks;
};
} // namespace Tyra
@@ -0,0 +1,56 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include "renderer/models/color.hpp"
#include "math/m4x4.hpp"
#include "math/vec4.hpp"
namespace Tyra {
enum StapipLightingBagMode { Auto, Manual };
class StapipLightingBag {
public:
explicit StapipLightingBag(const bool& manual = false);
~StapipLightingBag();
Vec4* normals;
M4x4* lightMatrix;
void setAmbientColor(const Color& color);
void setDirectionalLightColors(Color* colors, const u8& count);
void setDirectionalLightDirections(Vec4* directions, const u8& count);
void setDirectionalLightColor(const Color& color, const u8& index);
void setDirectionalLightDirection(const Vec4& direction, const u8& index);
void setLightsManually(Vec4* colors, Vec4* directions);
void disableManualMode();
Vec4* getLightColors() { return lightColors; }
Vec4* getLightDirections() { return lightDirections; }
void forceDeallocateColors();
void forceDeallocateDirections();
private:
void allocate();
void deallocate();
void forceDeallocate();
u8 isAllocated;
StapipLightingBagMode mode;
Vec4* lightColors;
Vec4* lightDirections;
};
} // namespace Tyra
@@ -0,0 +1,30 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include "math/vec4.hpp"
#include "renderer/core/texture/models/texture.hpp"
namespace Tyra {
class StapipTextureBag {
public:
StapipTextureBag();
~StapipTextureBag();
/** Mandatory. Texture coordinates per vertex. */
Vec4* coordinates;
/** Mandatory. Texture image. */
Texture* texture;
};
} // namespace Tyra
@@ -0,0 +1,30 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include <packet2_utils.h>
#include <string>
#include "../../stapip_vu1_program.hpp"
namespace Tyra {
class StapipAsIsCVU1Program : public StapipVU1Program {
public:
StapipAsIsCVU1Program();
~StapipAsIsCVU1Program();
std::string getStringName() const;
void addProgramQBufferDataToPacket(packet2_t* packet,
StapipQBuffer* qbuffer) const;
};
} // namespace Tyra
@@ -0,0 +1,29 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include <packet2_utils.h>
#include <string>
#include "../../stapip_vu1_program.hpp"
namespace Tyra {
class StapipAsIsDVU1Program : public StapipVU1Program {
public:
StapipAsIsDVU1Program();
~StapipAsIsDVU1Program();
std::string getStringName() const;
void addProgramQBufferDataToPacket(packet2_t* packet,
StapipQBuffer* qbuffer) const;
};
} // namespace Tyra
@@ -0,0 +1,29 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include <packet2_utils.h>
#include <string>
#include "../../stapip_vu1_program.hpp"
namespace Tyra {
class StapipAsIsTCVU1Program : public StapipVU1Program {
public:
StapipAsIsTCVU1Program();
~StapipAsIsTCVU1Program();
std::string getStringName() const;
void addProgramQBufferDataToPacket(packet2_t* packet,
StapipQBuffer* qbuffer) const;
};
} // namespace Tyra
@@ -0,0 +1,29 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include <packet2_utils.h>
#include <string>
#include "../../stapip_vu1_program.hpp"
namespace Tyra {
class StapipAsIsTDVU1Program : public StapipVU1Program {
public:
StapipAsIsTDVU1Program();
~StapipAsIsTDVU1Program();
std::string getStringName() const;
void addProgramQBufferDataToPacket(packet2_t* packet,
StapipQBuffer* qbuffer) const;
};
} // namespace Tyra
@@ -0,0 +1,29 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include <packet2_utils.h>
#include <string>
#include "../../stapip_vu1_program.hpp"
namespace Tyra {
class StapipCullCVU1Program : public StapipVU1Program {
public:
StapipCullCVU1Program();
~StapipCullCVU1Program();
std::string getStringName() const;
void addProgramQBufferDataToPacket(packet2_t* packet,
StapipQBuffer* qbuffer) const;
};
} // namespace Tyra
@@ -0,0 +1,29 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include <packet2_utils.h>
#include <string>
#include "../../stapip_vu1_program.hpp"
namespace Tyra {
class StapipCullDVU1Program : public StapipVU1Program {
public:
StapipCullDVU1Program();
~StapipCullDVU1Program();
std::string getStringName() const;
void addProgramQBufferDataToPacket(packet2_t* packet,
StapipQBuffer* qbuffer) const;
};
} // namespace Tyra
@@ -0,0 +1,29 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include <packet2_utils.h>
#include <string>
#include "../../stapip_vu1_program.hpp"
namespace Tyra {
class StapipCullTCVU1Program : public StapipVU1Program {
public:
StapipCullTCVU1Program();
~StapipCullTCVU1Program();
std::string getStringName() const;
void addProgramQBufferDataToPacket(packet2_t* packet,
StapipQBuffer* qbuffer) const;
};
} // namespace Tyra
@@ -0,0 +1,29 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include <packet2_utils.h>
#include <string>
#include "../../stapip_vu1_program.hpp"
namespace Tyra {
class StapipCullTDVU1Program : public StapipVU1Program {
public:
StapipCullTDVU1Program();
~StapipCullTDVU1Program();
std::string getStringName() const;
void addProgramQBufferDataToPacket(packet2_t* packet,
StapipQBuffer* qbuffer) const;
};
} // namespace Tyra
@@ -0,0 +1,24 @@
//
// ______ ____ ___
// | \/ ____| |___|
// | | | \ | |
//-----------------------------------------------------------------------
// Copyright 2022, tyra - https://github.com/h4570/tyra
// Licenced under Apache License 2.0
// Sandro Sobczyński <sandro.sobczynski@gmail.com>
//
// Updated once per mesh
#define VU1_MVP_MATRIX_ADDR 0
#define VU1_LIGHTS_MATRIX_ADDR 4
#define VU1_SINGLE_COLOR_ADDR 7
#define VU1_OPTIONS_ADDR 8
#define VU1_LOD_ADDR 9
#define VU1_CLUT_ADDR 10
#define VU1_LIGHTS_DIRS_ADDR 11
#define VU1_LIGHTS_COLORS_ADDR 14
#define VU1_SET_GIFTAG_ADDR 18
#define VU1_LAST_ITEM_ADDR 18
// Buffer data (xtop)
#define VU1_VERT_DATA_ADDR 2
@@ -0,0 +1,47 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include <vector>
#include "debug/debug.hpp"
#include "./stapip_qbuffer.hpp"
#include "renderer/renderer_settings.hpp"
#include "renderer/core/paths/path1/clipper/path1_ee_clip_algorithm.hpp"
namespace Tyra {
/**
* @brief This class requires VU1 buffer with max buffsize/3 vertices.
* It will clip triangles and fill the buffer.
*
* To be honest clipping algorithm should be moved to VU1 and "AsIs" VU1 program
* should be renamed to "Clip" - I don't want to do it now, too much time.
*/
class StapipClipper {
public:
StapipClipper();
~StapipClipper();
void clip(StapipQBuffer* buffer);
void init(const RendererSettings& settings);
void setMaxVertCount(const u32& count);
void setMVP(M4x4* mvp);
private:
u32 maxVertCount;
Path1EEClipAlgorithm algorithm;
M4x4* mvp;
void perspectiveDivide(std::vector<Path1ClipVertex>* vertices);
void moveDataToBuffer(const std::vector<Path1ClipVertex>& vertices,
StapipQBuffer* buffer);
};
} // namespace Tyra
@@ -0,0 +1,31 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
namespace Tyra {
enum StapipProgramName {
StdipUndefinedProgram,
StapipCullColor,
StapipAsIsColor,
StapipCullDirLights,
StapipAsIsDirLights,
StapipCullTextureDirLights,
StapipAsIsTextureDirLights,
StapipCullTextureColor,
StapipAsIsTextureColor,
};
} // 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>
*/
#pragma once
namespace Tyra {
enum StapipProgramType {
StapipVU1Color,
StapipVU1DirLights,
StapipVU1TextureDirLights,
StapipVU1TextureColor,
};
} // namespace Tyra
@@ -0,0 +1,49 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include "debug/debug.hpp"
#include "renderer/core/paths/path1/vu1_program.hpp"
#include "./programs/as_is/stapip_as_is_c_vu1_program.hpp"
#include "./programs/as_is/stapip_as_is_d_vu1_program.hpp"
#include "./programs/as_is/stapip_as_is_td_vu1_program.hpp"
#include "./programs/as_is/stapip_as_is_tc_vu1_program.hpp"
#include "./programs/cull/stapip_cull_c_vu1_program.hpp"
#include "./programs/cull/stapip_cull_d_vu1_program.hpp"
#include "./programs/cull/stapip_cull_td_vu1_program.hpp"
#include "./programs/cull/stapip_cull_tc_vu1_program.hpp"
#include "renderer/core/paths/path1/programs/draw_finish/vu1_draw_finish.hpp"
namespace Tyra {
class StapipProgramsRepository {
public:
StapipProgramsRepository();
~StapipProgramsRepository();
StapipVU1Program* getProgram(const StapipProgramName& name);
private:
StapipAsIsCVU1Program asIsColor;
StapipCullCVU1Program cullColor;
StapipAsIsDVU1Program asIsLightingColor;
StapipCullDVU1Program cullLightingColor;
StapipAsIsTDVU1Program asIsLightingTextureColor;
StapipCullTDVU1Program cullLightingTextureColor;
StapipAsIsTCVU1Program asIsTextureColor;
StapipCullTCVU1Program cullTextureColor;
VU1DrawFinish drawFinish;
};
} // namespace Tyra
@@ -0,0 +1,84 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include <math3d.h>
#include <string>
#include <sstream>
#include "debug/debug.hpp"
#include "./bag/packaging/stapip_bag_package.hpp"
#include "./bag/stapip_bag.hpp"
namespace Tyra {
class StapipQBuffer {
public:
StapipQBuffer();
~StapipQBuffer();
void setMaxVertCount(const u32& count);
/**
* @brief Dont allocate any dynamic data in buffer.
* Just copy pointers to input data.
*/
void fillByPointer(const StapipBagPackage& pkg);
/**
* @brief Allocate dynamic data in buffer
* And copy input data to it.
*/
void fillByCopyMax(const StapipBagPackage& pkg1, const StapipBagPackage& pkg2,
const StapipBagPackage& pkg3);
/**
* @brief Allocate dynamic data in buffer
* And copy input data to it.
*/
void fillByCopy1By2(const StapipBagPackage& pkg1,
const StapipBagPackage& pkg2);
/**
* @brief Allocate dynamic data in buffer
* And copy input data to it.
*/
void fillByCopy1By3(const StapipBagPackage& pkg);
/**
* @brief Deallocate dynamic data if it was allocated and allocate new data
* specified by size.
* @param size 48 is max
*/
void reallocateManually(const u16& size);
bool any() const;
StapipBag* bag;
Vec4* vertices;
Vec4* sts;
Vec4* colors;
Vec4* normals;
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;
void deallocateDynamicData();
void allocateDynamicData(u16 size, StapipBag* bag);
u8 _isDynamicallyAllocated, _stAllocated, _colorAllocated, _normalAllocated;
};
} // namespace Tyra
@@ -0,0 +1,98 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include <dma.h>
#include <packet2_utils.h>
#include <vector>
#include "debug/debug.hpp"
#include "math/m4x4.hpp"
#include "renderer/renderer_settings.hpp"
#include "renderer/models/color.hpp"
#include "./stapip_qbuffer.hpp"
#include "./stapip_program_type.hpp"
#include "./stapip_program_name.hpp"
#include "./stapip_programs_repository.hpp"
#include "./stapip_clipper.hpp"
#include "renderer/core/paths/path1/path1.hpp"
#include "renderer/core/renderer_core.hpp"
#include "renderer/core/texture/renderer_core_texture_buffers.hpp"
namespace Tyra {
class StapipQBufferRenderer {
public:
StapipQBufferRenderer();
~StapipQBufferRenderer();
void init(RendererCore* t_core);
void reinitVU1();
void setClipperMVP(M4x4* mvp) { clipper.setMVP(mvp); }
StapipQBuffer* getBuffer();
void sendObjectData(StapipBag* bag, M4x4* mvp,
RendererCoreTextureBuffers* texBuffers) const;
void setMaxVertCount(const u32& count);
void setInfo(StapipInfoBag* bag);
/** Fast render with culling */
void cull(StapipQBuffer* buffer);
/** Slower render with clipping */
void clip(StapipQBuffer* buffer);
void clearLastProgramName();
StapipVU1Program* getCullProgramByBag(const StapipBag* bag);
StapipVU1Program* getCullProgramByParams(const bool& isLightingEnabled,
const bool& isTextureEnabled);
const u16& getBufferSize() { return bufferSize; }
private:
void sendStaticData() const;
void setProgramsCache();
void uploadPrograms();
void setDoubleBuffer();
StapipVU1Program* getProgramByName(const StapipProgramName& name);
void addBufferDataToPacket(StapipVU1Program* program, StapipQBuffer* buffer);
void sendPacket();
StapipVU1Program* getAsIsProgramByBag(const StapipBag* bag);
StapipVU1Program* getCullProgramByType(const StapipProgramType& programType);
StapipProgramType getDrawProgramTypeByBag(const StapipBag* bag) const;
StapipProgramType getDrawProgramTypeByParams(
const bool& isLightingEnabled, const bool& isTextureEnabled) const;
packet2_t* packets[2];
packet2_t* programsPacket;
StapipQBuffer buffers[2];
packet2_t* currentPacket;
packet2_t* staticDataPacket;
packet2_t* objectDataPacket;
RendererCore* rendererCore;
StapipProgramName lastProgramName;
Path1* path1;
StapipClipper clipper;
StapipProgramsRepository repository;
u16 bufferSize;
u8 context;
};
} // namespace Tyra
@@ -0,0 +1,50 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include "./stapip_program_name.hpp"
#include "renderer/core/paths/path1/vu1_program.hpp"
#include "./stapip_qbuffer.hpp"
#include "./programs/stapip_vu1_shared_defines.h"
namespace Tyra {
class StapipVU1Program : public VU1Program {
public:
StapipVU1Program(const StapipProgramName& name, u32* start, u32* end,
const u32& t_reglist, const u8& t_reglistCount,
const u8& t_elementsPerVertex);
~StapipVU1Program();
u32& getReglist();
const StapipProgramName& getName() const;
u16 getMaxVertCount(const bool& singleColorEnabled,
const u16& vu1DBufferSize) const;
void addBufferDataToPacket(packet2_t* packet, StapipQBuffer* buffer,
prim_t* prim);
protected:
StapipProgramName name;
u8 reglistCount, elementsPerVertex;
u32 destinationAddress, reglist;
virtual void addProgramQBufferDataToPacket(packet2_t* packet,
StapipQBuffer* qbuffer) const = 0;
private:
void addStandardBufferDataToPacket(packet2_t* packet, StapipQBuffer* buffer,
prim_t* prim);
};
} // namespace Tyra
@@ -0,0 +1,59 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include <tamtypes.h>
#include "./bag/stapip_bag.hpp"
#include "./bag/packaging/stapip_bag_packages_bbox.hpp"
#include "./bag/packaging/stapip_bag_package.hpp"
#include "./bag/packaging/stapip_bag_packager.hpp"
#include "./stapip_qbuffer_renderer.hpp"
namespace Tyra {
class StapipelineCore {
public:
StapipelineCore();
~StapipelineCore();
void init(RendererCore* t_core);
/** Render 3D data via "bags" */
void render(StapipBag* data, StapipBagPackagesBBox* bbox = nullptr);
/** Get max vert count of VU1 qbuffer (for optimizations) */
u32 getMaxVertCountByParams(const bool& isSingleColor,
const bool& isLightingEnabled,
const bool& isTextureEnabled);
/** Get max vert count of VU1 qbuffer (for optimizations) */
u32 getMaxVertCountByBag(const StapipBag* bag);
/**
* - Uploads standard VU1 programs.
* - Sends static "Tyra Renderer3D" VU1 data.
* - Sets double buffers exactly for "Tyra Renderer3D"
* Should be called if VU1 was used by your non standard programs.
*/
void reinitStandardVU1Programs();
private:
u32 maxVertCount;
RendererCore* rendererCore;
void setMaxVertCount(const u32& count);
StapipBagPackager packager;
StapipQBufferRenderer qbufferRenderer;
void renderPkgs(StapipBagPackage* packages, u16 count);
void renderSubpkgs(StapipBagPackage* packages, u16 count);
};
} // namespace Tyra
@@ -0,0 +1,44 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include "math/vec4.hpp"
#include "renderer/models/color.hpp"
namespace Tyra {
class StapipLightingOptions {
public:
StapipLightingOptions() {}
~StapipLightingOptions() {}
/**
* Mandatory.
* Default 128.0F, 128.0F, 128.0F, 128.0F
*/
Color* ambientColor;
/**
* Mandatory.
* Min/max length - 3.
* Example color value: 64.0F, 0.0F, 0.0F, 1.0F
*/
Color* directionalColors;
/**
* Mandatory.
* Min/max length - 3.
* Example dir value: 1.0F, 0.0F, 0.0F, 1.0F
*/
Vec4* directionalDirections;
};
} // namespace Tyra
@@ -0,0 +1,32 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include "./stapip_shading_type.hpp"
#include "./stapip_lighting_options.hpp"
namespace Tyra {
class StapipOptions {
public:
StapipOptions() {}
~StapipOptions() {}
StapipShadingType shadingType;
bool blendingEnabled;
bool antiAliasingEnabled;
bool noClipChecks;
/** Optional */
StapipLightingOptions* lighting;
};
} // namespace Tyra
@@ -0,0 +1,20 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
namespace Tyra {
enum StapipShadingType {
StapipShadingFlat,
StapipShadingGouraud,
};
} // namespace Tyra
@@ -0,0 +1,59 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include <tamtypes.h>
#include "../renderer_3d_pipeline.hpp"
#include "./stapip_options.hpp"
#include "renderer/core/renderer_core.hpp"
#include "renderer/3d/mesh/mesh.hpp"
#include "./core/static_pipeline_core.hpp"
namespace Tyra {
class Stapipeline : public Renderer3DPipeline {
public:
Stapipeline();
~Stapipeline();
void init(RendererCore* core);
void onUse();
/**
* Render 3D data via "meshes".
* This render() method is a bridge to core.renderer3D.render() method.
*/
void render(Mesh* mesh, const StapipOptions* options = nullptr);
private:
StapipelineCore core;
RendererCore* rendererCore;
Vec4* colorsCache;
void addVertices(Mesh* mesh, MeshMaterial* material, StapipBag* bag,
MeshFrame* frameFrom, MeshFrame* frameTo) const;
StapipInfoBag* getInfoBag(Mesh* mesh, const StapipOptions* options,
M4x4* model) const;
StapipColorBag* getColorBag(Mesh* mesh, MeshMaterial* material,
MeshFrame* frameFrom, MeshFrame* frameTo) const;
StapipTextureBag* getTextureBag(Mesh* mesh, MeshMaterial* material,
MeshFrame* frameFrom, MeshFrame* frameTo);
StapipLightingBag* getLightingBag(Mesh* mesh, MeshMaterial* material,
M4x4* model, MeshFrame* frameFrom,
MeshFrame* frameTo,
const StapipOptions* options) const;
void deallocDrawBags(StapipBag* bag, MeshMaterial* material) const;
void setLightingColorsCache(StapipLightingOptions* lightingOptions);
};
} // namespace Tyra