tyrav2 init

This commit is contained in:
h4570
2022-07-17 10:21:35 +02:00
parent 44c1ee4fe8
commit c8b22ff331
249 changed files with 18187 additions and 0 deletions
@@ -0,0 +1,28 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# 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 "debug/debug.hpp"
#include "renderer/3d/pipeline/minecraft/programs/mcpip_program.hpp"
namespace Tyra {
class McpipAsIsVU1Program : public McpipProgram {
public:
McpipAsIsVU1Program();
~McpipAsIsVU1Program();
std::string getStringName() const;
};
} // namespace Tyra
@@ -0,0 +1,70 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# 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 "debug/debug.hpp"
#include "renderer/renderer.hpp"
#include "packet2/packet2_tyra_utils.hpp"
#include "../mcpip_programs_repository.hpp"
#include "../../mcpip_block.hpp"
#include "../../data/mcpip_block_data.hpp"
#include "./mcpip_vu1_as_is_shared_defines.h"
#include "renderer/core/paths/path1/clipper/path1_ee_clip_algorithm.hpp"
namespace Tyra {
class McpipClip {
public:
McpipClip();
~McpipClip();
Path1EEClipAlgorithm algorithm;
Path1EEClipAlgorithmSettings algoSettings;
void init(RendererCore* core, McpipBlockData* t_singleBlockData,
McpipBlockData* t_multiBlockData);
u32 uploadVU1Program(McpipProgramsRepository* repo, const u32& addr);
void configureVU1AndSendStaticData();
void addData(McpipBlock* block, const bool& isMulti,
RendererCoreTextureBuffers* texBuffers, packet2_t* packet,
const u8& context);
private:
RendererCore* rendererCore;
McpipBlockData* singleBlockData;
McpipBlockData* multiBlockData;
packet2_t* staticPacket;
u16 vu1DBufferSize;
std::vector<Path1ClipVertex> clippedTriangle;
std::vector<Path1ClipVertex> inputTriangle;
Vec4 vertexBuffers[2][108];
Vec4 texCoordBuffers[2][108];
void addCorrections(std::vector<Path1ClipVertex>* vertices,
McpipBlock* block);
void moveDataToBuffer(std::vector<Path1ClipVertex>* vertices,
const u8& context);
void addDataToPacket(packet2_t* packet, const u8& context, McpipBlock* block,
const int& count,
RendererCoreTextureBuffers* texBuffers);
void initStaticPacket();
void sendVU1StaticData();
void setDBufferSize();
};
} // 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>
//
// Static data for blockizer program
#define VU1_MCPIP_AS_IS_STATIC_LOD 0
#define VU1_MCPIP_AS_IS_STATIC_SET_TAG 1
#define VU1_MCPIP_AS_IS_STATIC_LAST_DATA_ADDR 1
// Dynamic data (unpack per VU1 call)
#define VU1_MCPIP_AS_IS_DYNAMIC_SCALE 0
#define VU1_MCPIP_AS_IS_DYNAMIC_PRIM 1
#define VU1_MCPIP_AS_IS_DYNAMIC_CLUT 2
#define VU1_MCPIP_AS_IS_DYNAMIC_COLOR 3
#define VU1_MCPIP_AS_IS_DYNAMIC_VERTEX_DATA_ADDR 4
@@ -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 <packet2_utils.h>
#include "debug/debug.hpp"
#include "renderer/renderer.hpp"
#include "packet2/packet2_tyra_utils.hpp"
#include "../mcpip_programs_repository.hpp"
#include "../../mcpip_block.hpp"
#include "../../data/mcpip_block_data.hpp"
#include "./mcpip_vu1_cull_shared_defines.h"
namespace Tyra {
class McpipCull {
public:
McpipCull();
~McpipCull();
void init(RendererCore* core, McpipBlockData* t_blockData);
u32 uploadVU1Program(McpipProgramsRepository* repo, const u32& addr);
void configureVU1AndSendStaticData();
u32 getMaxBlocksCountPerQBuffer() const;
void addData(packet2_t* packet, McpipBlock** blockPointerArray,
u32 blockPointerArrayCount,
RendererCoreTextureBuffers* texBuffers, bool isMulti);
private:
RendererCore* rendererCore;
u16 vu1DBufferSize;
McpipBlockData* blockData;
packet2_t* staticPacket;
void initStaticPacket();
void sendVU1StaticData();
void setDBufferSize();
};
} // namespace Tyra
@@ -0,0 +1,28 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# 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 "debug/debug.hpp"
#include "renderer/3d/pipeline/minecraft/programs/mcpip_program.hpp"
namespace Tyra {
class McpipCullVU1Program : public McpipProgram {
public:
McpipCullVU1Program();
~McpipCullVU1Program();
std::string getStringName() const;
};
} // namespace Tyra
@@ -0,0 +1,33 @@
//
// ______ ____ ___
// | \/ ____| |___|
// | | | \ | |
//-----------------------------------------------------------------------
// Copyright 2022, tyra - https://github.com/h4570/tyra
// Licenced under Apache License 2.0
// Sandro Sobczyński <sandro.sobczynski@gmail.com>
//
// Static data for blockizer program
#define VU1_MCPIP_CULL_VERTEX_COUNT 36
#define VU1_MCPIP_CULL_QWORDS_PER_BLOCK 6
#define VU1_MCPIP_CULL_STATIC_LOD 0
#define VU1_MCPIP_CULL_STATIC_PRIM 1
#define VU1_MCPIP_CULL_STATIC_SET_TAG 2
#define VU1_MCPIP_CULL_STATIC_VU1_OPTIONS 3
#define VU1_MCPIP_CULL_STATIC_VERTEX_DATA 4
#define VU1_MCPIP_CULL_STATIC_TEX_COORD_DATA 4 + 36
#define VU1_MCPIP_CULL_STATIC_LAST_DATA_ADDR \
VU1_MCPIP_CULL_STATIC_TEX_COORD_DATA + 36
// Dynamic data (unpack per VU1 call)
#define VU1_MCPIP_CULL_DYNAMIC_SCALE_AND_BLOCKS_COUNT_ADDR 0
#define VU1_MCPIP_CULL_DYNAMIC_CLUT_TEX 1
#define VU1_MCPIP_CULL_DYNAMIC_VIEW_PROJ_MATRIX_ADDR 2
#define VU1_MCPIP_CULL_DYNAMIC_BLOCKS_DATA 6
// Output mini double buffer inside VU1 mem
#define VU1_MCPIP_CULL_DYNAMIC_OUTPUT_DOUBLE_BUFF1_ADDR 774
#define VU1_MCPIP_CULL_DYNAMIC_OUTPUT_DOUBLE_BUFF2_ADDR 887
@@ -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 "./mcpip_program_name.hpp"
#include "renderer/core/paths/path1/vu1_program.hpp"
namespace Tyra {
class McpipProgram : public VU1Program {
public:
McpipProgram(const McpipProgramName& name, u32* start, u32* end);
~McpipProgram();
const McpipProgramName& getName() const;
protected:
McpipProgramName name;
};
} // namespace Tyra
@@ -0,0 +1,21 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# 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 McpipProgramName {
UndefinedMcpipProgram,
McPipCull,
McPipAsIs,
};
} // namespace Tyra
@@ -0,0 +1,75 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# 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 "debug/debug.hpp"
#include "renderer/renderer.hpp"
#include "./cull/mcpip_cull.hpp"
#include "./as_is/mcpip_clip.hpp"
#include "./mcpip_programs_repository.hpp"
#include "../data/mcpip_single_tex_block_data.hpp"
#include "../data/mcpip_multi_tex_block_data.hpp"
#include "../mcpip_block.hpp"
namespace Tyra {
enum McpipStaticBlockData {
BlockNotUploaded,
BlockMultiUploaded,
BlockSingleUploaded
};
class BlockizerProgramsManager {
public:
BlockizerProgramsManager();
~BlockizerProgramsManager();
McpipCull culler;
McpipClip clipper;
void init(RendererCore* core);
void uploadVU1Programs();
void clearLastProgram() { lastProgramName = UndefinedMcpipProgram; }
void cull(McpipBlock** blockPointerArray, u32 blockPointerArrayCount,
RendererCoreTextureBuffers* texBuffers, const bool& isMulti);
void clip(McpipBlock* block, RendererCoreTextureBuffers* texBuffers,
const bool& isMulti);
inline const float& getTextureOffset() const {
return singleTexBlockData.offset;
}
const McpipBlockData& getBlockData() const { return singleTexBlockData; }
private:
McpipProgramsRepository repo;
Renderer* renderer;
McpipSingleTexBlockData singleTexBlockData;
McpipMultiTexBlockData multiTexBlockData;
McpipProgramName lastProgramName;
packet2_t* programsPacket;
packet2_t* staticPacket;
packet2_t* dynamicPackets[2];
u8 context;
McpipStaticBlockData vu1BlockData;
void setProgramsCache();
void uploadBlock(bool isMulti);
void sendPacket(McpipProgram* program);
};
} // 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 "debug/debug.hpp"
#include "./mcpip_program.hpp"
#include "cull/mcpip_cull_vu1_program.hpp"
#include "as_is/mcpip_as_is_vu1_program.hpp"
namespace Tyra {
class McpipProgramsRepository {
public:
McpipProgramsRepository();
~McpipProgramsRepository();
McpipProgram* getProgram(const McpipProgramName& name);
private:
McpipCullVU1Program cull;
McpipAsIsVU1Program asIs;
};
} // namespace Tyra