Voxel
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Macros Pages
synchronized_texture_heap_host.h
1 #pragma once
2 
3 #ifndef SYNCHRONIZED_TEXTURE_HEAP_HOST_H
4 #define SYNCHRONIZED_TEXTURE_HEAP_HOST_H
5 
6 
7 
8 
9 #include "synchronized_texture_heap_base.h"
10 #include "platform.h"
11 #include "color.h"
12 
13 #include <boost/shared_ptr.hpp>
14 #include <boost/shared_array.hpp>
15 
16 #include <array>
17 
18 
19 
20 
21 namespace Synchronized {
22 
23 
24 
25 
26 /*==============================================================================
27  TextureHeap< PLATFORM_HOST > specialization
28 ==============================================================================*/
29 
30 
31 template< int t_ColorFormat >
32 struct TextureHeap< t_ColorFormat, PLATFORM_HOST > {
33 
34  struct Pointer;
35 
36 
37  inline TextureHeap();
38 
39 
40  inline Pointer Allocate( unsigned int const logSize ) const;
41 
42 
43  inline void Synchronize() const;
44 
45 
46  struct Pointer : public boost::shared_array< Color< t_ColorFormat > const > { // **TODO: in boost 1.53+, shared_ptr< Color< t_ColorFormat >[] > can substitute for shared_array< Color< t_ColorFormat > >
47 
48  typedef typename boost::shared_ptr< Color< t_ColorFormat > const >::element_type element_type;
49 
50 
51  inline Pointer();
52  inline Pointer( Pointer const& other );
53 
54 
55  inline void Assign( size_t const index, element_type const& data ) const;
56 
57 
58  private:
59 
60  inline Pointer( Color< t_ColorFormat >* array );
61 
62 
63  friend struct TextureHeap;
64  };
65 };
66 
67 
68 
69 
70 /*==============================================================================
71  TextureHeap< PLATFORM_HOST >::Pointer methods
72 ==============================================================================*/
73 
74 
75 template< int t_ColorFormat >
76 TextureHeap< t_ColorFormat, PLATFORM_HOST >::Pointer::Pointer() {
77 }
78 
79 
80 template< int t_ColorFormat >
81 TextureHeap< t_ColorFormat, PLATFORM_HOST >::Pointer::Pointer( Pointer const& other ) : boost::shared_array< Color< t_ColorFormat > const >( other ) {
82 }
83 
84 
85 template< int t_ColorFormat >
86 void TextureHeap< t_ColorFormat, PLATFORM_HOST >::Pointer::Assign( size_t const index, element_type const& data ) const {
87 
88  *const_cast< Color< t_ColorFormat >* >( boost::shared_array< Color< t_ColorFormat > const >::get() + index ) = data;
89 }
90 
91 
92 template< int t_ColorFormat >
93 TextureHeap< t_ColorFormat, PLATFORM_HOST >::Pointer::Pointer( Color< t_ColorFormat >* array ) : boost::shared_array< Color< t_ColorFormat > const >( array ) {
94 }
95 
96 
97 
98 
99 /*==============================================================================
100  TextureHeap< PLATFORM_HOST > methods
101 ==============================================================================*/
102 
103 
104 template< int t_ColorFormat >
105 TextureHeap< t_ColorFormat, PLATFORM_HOST >::TextureHeap() {
106 }
107 
108 
109 template< int t_ColorFormat >
110 typename TextureHeap< t_ColorFormat, PLATFORM_HOST >::Pointer TextureHeap< t_ColorFormat, PLATFORM_HOST >::Allocate( unsigned int const logSize ) const {
111 
112  return Pointer( new Color< t_ColorFormat >[ 1 << ( 3 * logSize ) ] );
113 }
114 
115 
116 template< int t_ColorFormat >
117 void TextureHeap< t_ColorFormat, PLATFORM_HOST >::Synchronize() const {
118 }
119 
120 
121 
122 
123 } // namespace Synchronized
124 
125 
126 
127 
128 #endif // SYNCHRONIZED_TEXTURE_HEAP_HOST_H