1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     ut_CmdCache.h
4 
5   Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Revision: 24805 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NW_UT_CMDCACHE_H_
17 #define NW_UT_CMDCACHE_H_
18 
19 #include <GLES2/gl2.h>
20 #include <nn/gx.h>
21 
22 namespace nw {
23 namespace ut {
24 namespace internal {
25 
26 //! :private
27 //! @brief コマンドキャッシュクラスです。
28 class CmdCache
29 {
30 public:
31                         CmdCache();
32 
33     void                Init(
34                             void*   buffer,
35                             u32     size,
36                             bool    isCopy  = true);
37 
38     void                Use() const;
39 
40     void                Add(
41                             const u32*  command,
42                             u32         size);
43 
44     void                RoundUp(u8 align);
45 
Clear()46     void                Clear() { m_CmdBufferSize = 0; }
47 
GetAddr()48     void*               GetAddr() const     { return m_CmdBuffer; }
49 
GetSize()50     GLsizei             GetSize() const     { return m_CmdBufferSize; }
51 
52     void                Dump(
53                             bool    asF32           = false,
54                             bool    showMnemonic    = false
55                         ) const
56 #if defined(NW_RELEASE)
57     {
58         (void)asF32;
59         (void)showMnemonic;
60     }
61 #else
62     ;
63 #endif
64 
65     static void         Dump(
66                             const void* from,
67                             const void* to,
68                             bool    asF32           = false,
69                             bool    showMnemonic    = false
70                         )
71 #if defined(NW_RELEASE)
72     {
73         (void)from;
74         (void)to;
75         (void)asF32;
76         (void)showMnemonic;
77     }
78 #else
79     ;
80 #endif
81 
82 private:
83     static void         DumpCommon(
84                             const void* from,
85                             const void* to,
86                             bool asF32,
87                             bool showMnemonic
88                         );
89 
90     u8*                 m_CmdBuffer;
91     GLsizei             m_CmdBufferSize;
92     GLsizei             m_CmdMaxBufferSize;
93 
94     bool                m_IsCopy;
95 };
96 
97 }   // namespace internal
98 }   // namespace ut
99 }   // namespace nw
100 
101 #endif  // NW_UT_CMDCACHE_H_
102