OROCHI
 
Loading...
Searching...
No Matches
GxPrimitiveManager.h
Go to the documentation of this file.
1//===========================================================================
11//===========================================================================
12#pragma once
13
14GX_CORE_NAMESPACE_BEGIN()
15
17class GxPrimitiveModel;
18//===========================================================================
21//===========================================================================
23{
24 //-------------------------------------------------------------
26 //-------------------------------------------------------------
28public:
29 // RTTI定義
30 GX_RTTI_CLASS(GxPrimitiveManager, GxClassBase)
31 // GxClassBaseReference継承クラス用禁止宣言
33 // new, delete定義
34 GX_OPERATOR_NEW_DELETE(GxAllocatorList::ALLOCATOR_TYPE::RENDER)
35
36 friend class GxPrimitiveContext;
37
51
53 enum class RENDER_TYPE
54 {
55 _2D,
56 _3D,
57 _2D_VIRTUAL,
58 };
59
61 static constexpr u32 DRAW_LIST_MAX_VERTEX_NUM = GxMath::VALUE_1K;
62
63protected:
65 enum class COMMAND_TYPE
66 {
67 NOP,
68 SET_SCREEN_SIZE,
69 SET_SCISSOR_RECT,
70 SET_RENDER_TARGET,
71 COPY_RENDER_TARGET_TO_TEXTURE,
72 CLEAR,
73 LINELIST_2D,
74 LINESTRIP_2D,
75 TRIANGLELIST_2D,
76 TRIANGLESTRIP_2D,
77 TRIANGLEFAN_2D,
78 QUADLIST_2D,
79 LINELIST_3D,
80 LINESTRIP_3D,
81 TRIANGLELIST_3D,
82 TRIANGLESTRIP_3D,
83 TRIANGLEFAN_3D,
84 QUADLIST_3D,
85 CUSTOM_2D,
86 CUSTOM_3D,
87 MAX,
88 };
89
98
100 GX_ALIGN16_BEGIN struct GxCommandSetScreenSize
101 {
103 } GX_ALIGN16_END;
104
106 GX_ALIGN16_BEGIN struct GxCommandSetScissor
107 {
109 } GX_ALIGN16_END;
110
112 GX_ALIGN16_BEGIN struct GxCommandSetRenderTarget
113 {
115 } GX_ALIGN16_END;
116
127
129 GX_ALIGN16_BEGIN struct GxCommandClear
130 {
132 } GX_ALIGN16_END;
133
135 GX_ALIGN16_BEGIN struct GxPacket
136 {
140 void* _pCommand;
141 } GX_ALIGN16_END;
142
143private:
145 static constexpr u32 PACKET_BLOCK_SIZE = sizeof(GxPacket) * GxMath::VALUE_256;
147 static constexpr u32 COMMAND_BLOCK_SIZE = sizeof(GxCommandDraw) * GxMath::VALUE_256;
149 static constexpr u32 VERTEX_BLOCK_SIZE = sizeof(GxPrimitiveVertex) * DRAW_LIST_MAX_VERTEX_NUM;
151 static constexpr u32 BUFFER_COUNT = RENDER_BUFFER_COUNT_MAX;
153 static const GxMatrix44Gpu REMAP_MATRIX_INSTANCE[14];
155 static const GxMatrix44Gpu* REMAP_MATRIX_TABLE[static_cast<s32>(PRIMITIVE_TEXTURE_REMAP_ALPHA::MAX)][static_cast<s32>(PRIMITIVE_TEXTURE_REMAP_COLOR::MAX)];
157 static const GxVector4 REMAP_VECTOR_INSTANCE[6];
159 static const GxVector4* REMAP_VECTOR_TABLE[static_cast<s32>(PRIMITIVE_TEXTURE_REMAP_ALPHA::MAX)][static_cast<s32>(PRIMITIVE_TEXTURE_REMAP_COLOR::MAX)];
160
162 //-------------------------------------------------------------
164 //-------------------------------------------------------------
166public:
168 GxPrimitiveManager(void);
169
171 virtual b32 initialize(GxAllocator* pAllocator, u32 commandBufferSize, u32 vertexBufferSize, u32 indexBufferSize, RENDER_TYPE type, u32 maxProjection2DId, b32 use32bitIndex = false);
172
174 void terminate(void);
175
177 //-------------------------------------------------------------
179 //-------------------------------------------------------------
181
182#if GX_DEVELOP
184 static GxGuiBase* createGui(GxProperty& property, GxTypedObject* pOwner, const GxRtti& rtti, u32 index);
185#endif //GX_DEVELOP
186
187public:
189 void begin(void);
190
192 constexpr void end(void) {}
193
195 void beginRender(b32 isSort);
196
198 void render(GxRect* pRect = nullptr);
199
201 void endRender(void);
202
203private:
205 u32 buildCommand(b32 isSort, GxPacket** ppPacket);
206
208 void setMaterial(const GxPrimitiveMaterial& material);
209
211 void resetPrimitiveRenderState(GxRenderContext* pRenderContext, const GxRect& rect, s32 stateMask = 0xffffffff);
212
213private:
215 GX_FORCE_INLINE GxPacket* allocatePacketBlock(void);
217 GX_FORCE_INLINE void* allocateCommandBlock(void);
219 GX_FORCE_INLINE GxPrimitiveVertex* allocateVertexBlock(void);
220
222 //-----------------------------------------------------------
224 //-----------------------------------------------------------
226public:
228 GxPrimitiveContext* getContext(u32 index);
229
231 static void setCustomShaderCallback(const GxCallback::GxHandlerBase& handler);
232
234 GX_FORCE_INLINE b32 isRenderType(RENDER_TYPE type) const { return _renderType == type; }
235
237 // projId は 1 以上
238 void setProjectionMatrix2D(u32 projectionId, const GxMatrix44& matrix);
240 // projId は 0 (スクリーンスペース) も指定可能
241 const GxMatrix44& getProjectionMatrix2D(u32 projectionId) const;
243 u32 allocateProjectionMatrix2DId(void);
245 void freeProjectionMatrix2DId(u32 projectionId);
247 GX_FORCE_INLINE const GxPoint2& getOutputOffset2D(void) const { return _outputOffset2D; }
249 GX_FORCE_INLINE void setOutputOffset2D(const GxPoint2& offset) { _outputOffset2D = offset; }
252 constexpr void setDefaultRenderTarget(GxRenderTexture* pRenderTarget, GxRenderTexture* pDepth) { _pDefaultRenderTarget = pRenderTarget; _pDefaultDepthStencil = pDepth; }
253
254#if GX_DEVELOP
256 constexpr u32 getMaxCommandBufferSize(void) const { return _maxCommandBufferSize; }
258 constexpr u32 getUsedCommandBufferSize(void) const { return _usedCommandBufferSize; }
260 constexpr u32 getMaxVertexBufferSize(void) const { return _maxVertexBufferSize; }
262 constexpr u32 getUsedVertexBufferSize(void) const { return _usedVertexBufferSize; }
264 constexpr u32 getMaxIndexBufferSize(void) const { return _maxIndexBufferSize; }
266 constexpr u32 getUsedIndexBufferSize(void) const { return _usedIndexBufferSize; }
267#endif //GX_DEVELOP
268
270 //-------------------------------------------------------------
272 //-------------------------------------------------------------
274private:
275 RENDER_TYPE _renderType;
276 GxPrimitiveContext* _pContext;
277
278 GxAllocatorFrame* _pAllocatorCommand;
279 GxAllocatorFrame* _pAllocatorVertex;
280
281 GxRenderTexture* _pDefaultRenderTarget;
282 GxRenderTexture* _pDefaultDepthStencil;
283
284 GxRenderVertexDeclaration* _pRenderDeclaration;
285 GxRenderVertexBuffer* _pRenderVertexBuffer[BUFFER_COUNT];
286 GxRenderIndexBuffer* _pRenderIndexBuffer[BUFFER_COUNT];
287
288 GxResShaderVertex* _pResVertexShader2D;
289 GxResShaderVertex* _pResVertexShader3D;
290 GxResShaderPixel* _pResPixelShader;
291 GxResShaderPixel* _pResPixelShaderTexture;
292 GxResShaderPixel* _pResPixelShaderAlphatest;
293 GxResShaderPixel* _pResPixelShaderTexRefAlphatest;
294 GxRenderVertexShader* _pVertexShader2D;
295 GxRenderVertexShader* _pVertexShader3D;
296 GxRenderPixelShader* _pPixelShader;
297 GxRenderPixelShader* _pPixelShaderTexture;
298 GxRenderPixelShader* _pPixelShaderAlphatest;
299 GxRenderPixelShader* _pPixelShaderTexRefAlphatest;
300 GxMatrix44* _pProjectionMatrix2DBuffer;
301 u8* _pProjectionMatrix2DIdBuffer;
302 GxCriticalSection _csProjectionMatrix2DIdBuffer;
303
304 GX_HANDLE _hProjectionMatrix2D;
305 GX_HANDLE _hProjectionMatrix3D;
306
307 GX_HANDLE _hRemapMatrix;
308 GX_HANDLE _hRemapVector;
309 GX_HANDLE _hTexture;
310 GX_HANDLE _hAlphaRefValue;
311 GX_HANDLE _hPrimitiveModelColor;
312 GX_HANDLE _hPrimitiveModelMatrix2D;
313 GX_HANDLE _hPrimitiveModelUVOffset;
314 GX_HANDLE _hPrimitiveModelModifier;
315#if defined(_PS4) || defined(_PS5)
316 GX_HANDLE _hScissorRect;
317#endif // _PS4 || _PS5
318
319#if GX_DEVELOP
320 GxResShaderPixel* _pResPixelShaderTextureGradation;
321 GxRenderPixelShader* _pPixelShaderTextureGradation;
322 GX_HANDLE _hGradationParam;
323#endif //GX_DEVELOP
324
325 void* _pCommandBuffer;
326
327 GxVector3 _lightVector;
328
329 u32 _currentBuffer;
330
331 u32 _commandBufferSize;
332 u32 _vertexBufferSize;
333 u32 _indexBufferSize;
334
335 u32 _maxCommandBufferSize;
336 u32 _maxVertexBufferSize;
337 u32 _maxIndexBufferSize;
338 u32 _usedCommandBufferSize;
339 u32 _usedVertexBufferSize;
340 u32 _usedIndexBufferSize;
341 u32 _maxProjectionMatrix2DIdCount;
342 GxPoint2 _outputOffset2D;
343 f32 _texcelOffset;
344 static GxCallback::GxHandlerBase _customShaderCallback;
345
346 void* _currentIndexBufferRaw;
347 GxPacket* _pPacket;
348 u32 _packetCount;
349
351};
352
353GX_CORE_NAMESPACE_END()
354
355#include "GxPrimitiveManager.inl"
#define GX_PROHIBIT_CLASS_BASE(__CLASS__)
GxClassBase継承の禁止宣言
Definition GxBase.h:240
@ MAX
定義数
void GxTypedObject
その他
Definition GxDefine.h:213
u32 GX_HANDLE
ハンドル
Definition GxDefine.h:214
@ RENDER_BUFFER_COUNT_MAX
トリプルバッファリング
Definition GxRender.h:20
フレームアロケータ
Definition GxAllocatorFrame.h:19
メモリアロケータ基底クラス
Definition GxAllocator.h:82
@ RENDER
レンダリング
ハンドラ基本クラス
Definition GxCallback.h:27
オブジェクト基底クラス
Definition GxBase.h:88
クリティカルセクションクラス
Definition GxThread.h:20
static constexpr u32 VALUE_1K
1K
Definition GxMath.h:129
static constexpr u32 VALUE_256
256
Definition GxMath.h:127
プリミティブの並列発行を管理します。
Definition GxPrimitiveContext.h:22
プリミティブの描画発行単位を管理します。
Definition GxPrimitiveManager.h:23
GX_FORCE_INLINE void setOutputOffset2D(const GxPoint2 &offset)
2Dプリミティブ全体の位置オフセットを設定
Definition GxPrimitiveManager.h:249
COMMAND_TYPE
コマンドタイプ
Definition GxPrimitiveManager.h:66
GX_FORCE_INLINE b32 isRenderType(RENDER_TYPE type) const
描画タイプを判定
Definition GxPrimitiveManager.h:234
constexpr void end(void)
パケット収集完了
Definition GxPrimitiveManager.h:192
constexpr void setDefaultRenderTarget(GxRenderTexture *pRenderTarget, GxRenderTexture *pDepth)
Definition GxPrimitiveManager.h:252
RENDER_TYPE
描画タイプ
Definition GxPrimitiveManager.h:54
GX_FORCE_INLINE const GxPoint2 & getOutputOffset2D(void) const
2Dプリミティブ全体の位置オフセットを取得
Definition GxPrimitiveManager.h:247
プロパティクラス
Definition GxProperty.h:48
描画コマンドの並列発行を管理します。
Definition GxRenderContext.h:28
インデックスバッファを管理する
Definition GxRenderIndexBuffer.h:20
ピクセルシェーダを管理する
Definition GxRenderPixelShader.h:20
テクスチャクラス
Definition GxRenderTexture.h:19
頂点バッファを管理する
Definition GxRenderVertexBuffer.h:20
頂点シェーダに渡す頂点の宣言を管理する
Definition GxRenderVertexDeclaration.h:22
頂点シェーダを管理する
Definition GxRenderVertexShader.h:22
ピクセルシェーダリソース
Definition GxResShader.h:247
頂点シェーダリソース
Definition GxResShader.h:164
実行時型情報クラス
Definition GxRtti.h:154
Definition GxColor.h:21
4×4行列(GPU用)
Definition GxMatrix.h:915
4×4行列(行優先)
Definition GxMatrix.h:607
座標
Definition GxStruct.h:867
画面クリアコマンド
Definition GxPrimitiveManager.h:130
GxColor _color
クリアカラー
Definition GxPrimitiveManager.h:131
レンダーターゲットをテクスチャにコピーするコマンド
Definition GxPrimitiveManager.h:119
const GxRect * _pSrcRect
描画元矩形ポインタ
Definition GxPrimitiveManager.h:123
u16 _dstMipLevel
ミップレベル
Definition GxPrimitiveManager.h:121
u16 _index
インデックス
Definition GxPrimitiveManager.h:120
GxRect _srcRect
描画元矩形
Definition GxPrimitiveManager.h:124
GxRenderTexture * _pTexture
テクスチャ
Definition GxPrimitiveManager.h:122
GxPoint2 _dstPoint
描画先座標
Definition GxPrimitiveManager.h:125
描画コマンド(アライメントの関係で、サイズは16の倍数である必要がある!)
Definition GxPrimitiveManager.h:92
GxVector3 _priorityPoint
優先度判定用の座標(3Dのみ)
Definition GxPrimitiveManager.h:94
u32 _vertexCount
頂点数
Definition GxPrimitiveManager.h:95
GxPrimitiveVertex * _pVertex
頂点バッファに渡すための頂点情報
Definition GxPrimitiveManager.h:96
GxPrimitiveMaterial _material
マテリアル
Definition GxPrimitiveManager.h:93
レンダーターゲット設定コマンド
Definition GxPrimitiveManager.h:113
GxRenderTexture * _pRenderTarget
レンダーターゲット
Definition GxPrimitiveManager.h:114
シザリング矩形設定コマンド
Definition GxPrimitiveManager.h:107
GxRect _rect
矩形
Definition GxPrimitiveManager.h:108
スクリーンサイズ設定コマンド
Definition GxPrimitiveManager.h:101
GxSize _size
サイズ
Definition GxPrimitiveManager.h:102
カスタムシェーダコールバックパラメータ
Definition GxPrimitiveManager.h:40
GxRenderPixelShader * _pPixelShaderTexRefAlphatest
テクスチャ付きテクスチャ参照アルファテスト付きピクセルシェーダ
Definition GxPrimitiveManager.h:46
GxRenderVertexShader * _pVertexShader3D
3D描画用頂点シェーダ
Definition GxPrimitiveManager.h:42
GxRenderPixelShader * _pPixelShaderTexture
テクスチャ付きピクセルシェーダ
Definition GxPrimitiveManager.h:44
GxRenderPixelShader * _pPixelShader
ピクセルシェーダ
Definition GxPrimitiveManager.h:43
GxRenderVertexShader * _pVertexShader2D
2D描画用頂点シェーダ
Definition GxPrimitiveManager.h:41
GxRenderPixelShader * _pPixelShaderAlphatest
テクスチャ付きアルファテスト付きピクセルシェーダ
Definition GxPrimitiveManager.h:45
描画パケット
Definition GxPrimitiveManager.h:136
GxPrimitiveManager::COMMAND_TYPE _type
コマンドタイプ
Definition GxPrimitiveManager.h:137
void * _pCommand
コマンドのポインタ
Definition GxPrimitiveManager.h:140
u32 _priority
優先度
Definition GxPrimitiveManager.h:138
u32 _viewFlag
ビューフラグ
Definition GxPrimitiveManager.h:139
プリミティブマテリアル
Definition GxPrimitive.h:103
プリミティブ頂点
Definition GxPrimitive.h:20
矩形
Definition GxStruct.h:951
サイズ
Definition GxStruct.h:730
3次元ベクトル
Definition GxVector.h:245
4次元ベクトル
Definition GxVector.h:582
32bitブーリアン
Definition GxDefine.h:173