Unravel Engine C++ Reference
Loading...
Searching...
No Matches
texture.h
Go to the documentation of this file.
1#pragma once
2
3#include "handle_impl.h"
4#include <base/basetypes.hpp>
5#include <memory>
6
7namespace gfx
8{
9struct texture : public handle_impl<texture, texture_handle>
10{
11 //-----------------------------------------------------------------------------
12 // Name : Texture ()
18 //-----------------------------------------------------------------------------
19 texture() = default;
20
21 texture(const char* _path,
22 std::uint64_t _flags = BGFX_TEXTURE_NONE | BGFX_SAMPLER_NONE,
23 std::uint8_t _skip = 0,
24 texture_info* _info = nullptr);
25
26 texture(const void* _data,
27 std::uint32_t _size,
28 std::uint64_t _flags = BGFX_TEXTURE_NONE | BGFX_SAMPLER_NONE,
29 std::uint8_t _skip = 0,
30 texture_info* _info = nullptr,
31 const char* _name = nullptr);
32
33 //-----------------------------------------------------------------------------
34 // Name : Texture ()
40 //-----------------------------------------------------------------------------
41 texture(std::uint16_t _width,
42 std::uint16_t _height,
43 bool _hasMips,
44 std::uint16_t _numLayers,
45 texture_format _format,
46 std::uint64_t _flags = BGFX_TEXTURE_NONE | BGFX_SAMPLER_NONE,
47 const memory_view* _mem = nullptr);
48
49
50 //-----------------------------------------------------------------------------
51 // Name : Texture ()
57 //-----------------------------------------------------------------------------
58 texture(std::uint16_t _width,
59 std::uint16_t _height,
60 std::uint16_t _depth,
61 bool _hasMips,
62 texture_format _format,
63 std::uint64_t _flags = BGFX_TEXTURE_NONE | BGFX_SAMPLER_NONE,
64 const memory_view* _mem = nullptr);
65
66 //-----------------------------------------------------------------------------
67 // Name : Texture ()
73 //-----------------------------------------------------------------------------
74 texture(std::uint16_t _size,
75 bool _hasMips,
76 std::uint16_t _numLayers,
77 texture_format _format,
78 std::uint64_t _flags = BGFX_TEXTURE_NONE | BGFX_SAMPLER_NONE,
79 const memory_view* _mem = nullptr);
80
81 //-----------------------------------------------------------------------------
82 // Name : get_size ()
88 //-----------------------------------------------------------------------------
89 auto get_size() const -> usize32_t;
90
91 //-----------------------------------------------------------------------------
92 // Name : is_render_target ()
98 //-----------------------------------------------------------------------------
99 auto is_render_target() const -> bool;
100
101 //-----------------------------------------------------------------------------
102 // Name : is_gpu_generated ()
108 //-----------------------------------------------------------------------------
109 auto is_gpu_generated() const -> bool;
110
111 //-----------------------------------------------------------------------------
112 // Name : fallback_handle ()
118 //-----------------------------------------------------------------------------
119 auto fallback_handle() const -> texture_handle;
120
121
122 auto get_estimated_gpu_size() const -> std::uint64_t;
123
127 std::uint64_t flags = BGFX_TEXTURE_NONE;
128
129private:
130 void adopt_loaded_eviction(eviction::backing_buffer backing,
131 std::uint64_t estimated_size,
132 std::uint64_t load_flags,
133 std::uint8_t skip,
134 const char* label);
135};
136
137
138inline auto needs_recreate(const gfx::texture::ptr& tex, const usize32_t& size) -> bool
139{
140 return !tex || (tex && tex->get_size() != size);
141}
142
143inline auto needs_recreate(const gfx::texture::ptr& tex, const usize32_t& size, const texture_format& format) -> bool
144{
145 return !tex || (tex && tex->get_size() != size) || (tex && tex->info.format != format);
146}
147} // namespace gfx
gfx::texture_format format
std::shared_ptr< std::vector< std::uint8_t > > backing_buffer
Definition eviction.h:18
bgfx::TextureFormat::Enum texture_format
Definition format.h:10
auto needs_recreate(const gfx::frame_buffer::ptr &fbo, const usize32_t &size) -> bool
bgfx::TextureHandle texture_handle
Definition graphics.h:51
bgfx::TextureInfo texture_info
Definition graphics.h:24
bgfx::Memory memory_view
Definition graphics.h:23
Hash specialization for batch_key to enable use in std::unordered_map.
auto is_render_target() const -> bool
Definition texture.cpp:344
auto fallback_handle() const -> texture_handle
Definition texture.cpp:354
texture()=default
auto is_gpu_generated() const -> bool
Whether the texture's contents are produced on the GPU (render target or compute-write) rather than u...
Definition texture.cpp:349
std::uint64_t flags
Creation flags.
Definition texture.h:127
auto get_size() const -> usize32_t
Definition texture.cpp:339
texture_info info
Texture detail info.
Definition texture.h:125
auto get_estimated_gpu_size() const -> std::uint64_t
Definition texture.cpp:359