1 /*---------------------------------------------------------------------------*
2 Project: NintendoWare
3 File: gfx_MemoryUtil.h
4
5 Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc. All rights reserved.
6
7 These coded instructions, statements, and computer programs contain proprietary
8 information of Nintendo and/or its licensed developers and are protected by
9 national and international copyright laws. They may not be disclosed to third
10 parties or copied or duplicated in any form, in whole or in part, without the
11 prior written consent of Nintendo.
12
13 The content herein is highly confidential and should be handled accordingly.
14
15 $Revision: 31311 $
16 *---------------------------------------------------------------------------*/
17 #ifndef NW_GFX_MEMORY_UTIL_H_
18 #define NW_GFX_MEMORY_UTIL_H_
19
20 #include <nw/types.h>
21 #include <nw/ut/ut_RuntimeTypeInfo.h>
22 #include <nw/ut/ut_Inlines.h>
23 #include <nw/math.h>
24 #include <nw/ut/ut_MoveArray.h>
25 #include <nw/ut/ut_RuntimeTypeInfo.h>
26
27 namespace nw {
28 namespace gfx {
29 namespace internal {
30
31 #define DECL_SUB(size) \
32 asm u32* FastWordCopyAsm_##size(u32* /*dst*/, u32* /*src*/);
33
34 DECL_SUB(2)
35 DECL_SUB(4)
36 DECL_SUB(6)
37 DECL_SUB(8)
38 DECL_SUB(10)
39 DECL_SUB(12)
40 DECL_SUB(14)
41 DECL_SUB(16)
42 DECL_SUB(18)
43 DECL_SUB(20)
44 DECL_SUB(22)
45 DECL_SUB(24)
46 DECL_SUB(26)
47 DECL_SUB(28)
48 DECL_SUB(30)
49 DECL_SUB(32)
50 DECL_SUB(34)
51 DECL_SUB(36)
52 DECL_SUB(38)
53 DECL_SUB(78)
54
55 #undef DECL_SUB
56
57 NW_FORCE_INLINE u32*
FastWordCopy(u32 * dst,u32 * src,u32 size)58 FastWordCopy(u32* dst, u32* src, u32 size)
59 {
60 size /= 4;
61 NW_ASSERT(size % 2 == 0);
62
63 #define INVOKE_SUB(count) \
64 if (size == count) \
65 { \
66 return FastWordCopyAsm_##count(dst, src); \
67 }
68
69 INVOKE_SUB(2)
70 INVOKE_SUB(4)
71 INVOKE_SUB(6)
72 INVOKE_SUB(8)
73 INVOKE_SUB(10)
74 INVOKE_SUB(12)
75 INVOKE_SUB(14)
76 INVOKE_SUB(16)
77 INVOKE_SUB(18)
78 INVOKE_SUB(20)
79 INVOKE_SUB(22)
80 INVOKE_SUB(24)
81 INVOKE_SUB(26)
82 INVOKE_SUB(28)
83 INVOKE_SUB(30)
84 INVOKE_SUB(32)
85 INVOKE_SUB(34)
86 INVOKE_SUB(36)
87 INVOKE_SUB(38)
88 INVOKE_SUB(78)
89
90 NW_LOG("Unsupported size : %d\n", size);
91 NW_ASSERT(false);
92 return NULL;
93 #undef INVOKE_SUB
94 }
95
96 } // namespace internal
97 } // namespace gfx
98 } // namespace nw
99
100 #endif // NW_GFX_MEMORY_UTIL_H_
101