17 typedef size_t size_type;
20 typedef gli::swizzles swizzles_type;
21 typedef storage_linear storage_type;
22 typedef storage_type::data_type data_type;
23 typedef storage_type::extent_type extent_type;
39 extent_type
const& Extent,
43 swizzles_type
const& Swizzles = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
54 size_type BaseLayer, size_type MaxLayer,
55 size_type BaseFace, size_type MaxFace,
56 size_type BaseLevel, size_type MaxLevel,
57 swizzles_type
const& Swizzles = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
66 swizzles_type
const& Swizzles = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
74 target_type
target()
const{
return this->Target;}
77 format_type
format()
const;
79 swizzles_type swizzles()
const;
97 size_type
faces()
const;
109 extent_type
extent(size_type Level = 0)
const;
112 size_type
size()
const;
116 template <
typename genType>
117 size_type
size()
const;
120 size_type
size(size_type Level)
const;
124 template <
typename gen_type>
125 size_type
size(size_type Level)
const;
131 template <
typename gen_type>
135 void const*
data()
const;
138 template <
typename gen_type>
139 gen_type
const*
data()
const;
142 void*
data(size_type Layer, size_type Face, size_type Level);
145 void const*
const data(size_type Layer, size_type Face, size_type Level)
const;
148 template <
typename gen_type>
149 gen_type*
data(size_type Layer, size_type Face, size_type Level);
152 template <
typename gen_type>
153 gen_type
const*
const data(size_type Layer, size_type Face, size_type Level)
const;
160 template <
typename gen_type>
161 void clear(gen_type
const& Texel);
164 template <
typename gen_type>
165 void clear(size_type Layer, size_type Face, size_type Level, gen_type
const& BlockData);
168 template <
typename gen_type>
169 void clear(size_type Layer, size_type Face, size_type Level, extent_type
const& TexelOffset, extent_type
const& TexelExtent, gen_type
const& BlockData);
174 size_t LayerSrc,
size_t FaceSrc,
size_t LevelSrc,
175 size_t LayerDst,
size_t FaceDst,
size_t LevelDst);
180 size_t LayerSrc,
size_t FaceSrc,
size_t LevelSrc, extent_type
const& OffsetSrc,
181 size_t LayerDst,
size_t FaceDst,
size_t LevelDst, extent_type
const& OffsetDst,
182 extent_type
const& Extent);
185 template <
typename gen_type>
186 void swizzle(gli::swizzles
const& Swizzles);
189 template <
typename gen_type>
190 gen_type
load(extent_type
const & TexelCoord, size_type Layer, size_type Face, size_type Level)
const;
193 template <
typename gen_type>
194 void store(extent_type
const& TexelCoord, size_type Layer, size_type Face, size_type Level, gen_type
const& Texel);
197 std::shared_ptr<storage_type> Storage;
206 swizzles_type Swizzles;
222 storage_type& Storage,
224 size_type BaseLayer, size_type Layers,
225 size_type BaseFace, size_type MaxFace,
226 size_type BaseLevel, size_type MaxLevel
228 : Faces(MaxFace - BaseFace + 1)
229 , Levels(MaxLevel - BaseLevel + 1)
231 GLI_ASSERT(static_cast<size_t>(
gli::levels(Storage.extent(0))) < this->ImageMemorySize.size());
233 this->BaseAddresses.resize(Layers * this->Faces * this->Levels);
235 for(size_type Layer = 0; Layer < Layers; ++Layer)
236 for(size_type Face = 0; Face < this->Faces; ++Face)
237 for(size_type Level = 0; Level < this->Levels; ++Level)
239 size_type
const Index = index_cache(Layer, Face, Level);
240 this->BaseAddresses[Index] = Storage.data() + Storage.base_offset(
241 BaseLayer + Layer, BaseFace + Face, BaseLevel + Level);
244 for(size_type Level = 0; Level < this->Levels; ++Level)
246 extent_type
const& SrcExtent = Storage.extent(BaseLevel + Level);
247 extent_type
const& DstExtent = SrcExtent *
block_extent(Format) / Storage.block_extent();
249 this->ImageExtent[Level] = glm::max(DstExtent, extent_type(1));
250 this->ImageMemorySize[Level] = Storage.level_size(BaseLevel + Level);
253 this->GlobalMemorySize = Storage.layer_size(BaseFace, MaxFace, BaseLevel, MaxLevel) * Layers;
257 data_type* get_base_address(size_type Layer, size_type Face, size_type Level)
const
259 return this->BaseAddresses[index_cache(Layer, Face, Level)];
263 extent_type get_extent(size_type Level)
const
265 return this->ImageExtent[Level];
269 size_type get_memory_size(size_type Level)
const
271 return this->ImageMemorySize[Level];
275 size_type get_memory_size()
const
277 return this->GlobalMemorySize;
281 size_type index_cache(size_type Layer, size_type Face, size_type Level)
const
283 return ((Layer * this->Faces) + Face) * this->Levels + Level;
288 std::vector<data_type*> BaseAddresses;
289 std::array<extent_type, 16> ImageExtent;
290 std::array<size_type, 16> ImageMemorySize;
291 size_type GlobalMemorySize;
296 #include "./core/texture.inl"
ivec3 block_extent(format Format)
Return the dimensions in texels of the block for a format.
void swizzle(gli::swizzles const &Swizzles)
Reorder the component in texture memory.
target_type target() const
Return the target of a texture instance.
size_type levels() const
Return max_level() - base_level() + 1.
gen_type load(extent_type const &TexelCoord, size_type Layer, size_type Face, size_type Level) const
Fetch a texel from a texture. The texture format must be uncompressed.
format
Texture data format.
void store(extent_type const &TexelCoord, size_type Layer, size_type Face, size_type Level, gen_type const &Texel)
Write a texel to a texture. The texture format must be uncompressed.
size_type base_layer() const
Return the base layer of the texture instance, effectively a memory offset in the actual texture stor...
size_type max_layer() const
Return the max layer of the texture instance, effectively a memory offset to the beginning of the las...
bool empty() const
Return whether the texture instance is empty, no storage_type or description have been assigned to th...
texture()
Create an empty texture instance.
Include to compute the number of mipmaps levels necessary to create a mipmap complete texture...
Include to use the target enum and query properties of targets.
size_type max_face() const
Return the max face of the texture instance, effectively a memory offset to the beginning of the last...
format_type format() const
Return the texture instance format.
Genetic texture class. It can support any target.
void * data()
Return a pointer to the beginning of the texture instance data.
size_type max_level() const
Return the max level of the texture instance, effectively a memory offset to the beginning of the las...
Include to use images, a representation of a single texture level.
size_type size() const
Return the memory size of a texture instance storage_type in bytes.
target
Texture target: type/shape of the texture storage_linear.
size_type layers() const
Return max_layer() - base_layer() + 1.
size_type faces() const
Return max_face() - base_face() + 1.
Namespace where all the classes and functions provided by GLI are exposed.
void copy(texture const &TextureSrc, size_t LayerSrc, size_t FaceSrc, size_t LevelSrc, size_t LayerDst, size_t FaceDst, size_t LevelDst)
Copy a specific image of a texture.
extent_type extent(size_type Level=0) const
Return the size of a texture instance: width, height and depth.
size_type base_face() const
Return the base face of the texture instance, effectively a memory offset in the actual texture stora...
size_type base_level() const
Return the base level of the texture instance, effectively a memory offset in the actual texture stor...
void clear()
Clear the entire texture storage_linear with zeros.
T levels(vecType< T, P > const &Extent)
Compute the number of mipmaps levels necessary to create a mipmap complete texture.