Unravel Engine C++ Reference
Loading...
Searching...
No Matches
index_buffer.cpp
Go to the documentation of this file.
1#include "index_buffer.h"
2
3namespace gfx
4{
5
6index_buffer::index_buffer(const memory_view* _mem, std::uint16_t _flags /*= BGFX_BUFFER_NONE*/)
7{
8 if(_mem == nullptr)
9 {
10 return;
11 }
13 {
14 handle_ = create_index_buffer(_mem, _flags);
15 return;
16 }
17 eviction::backing_buffer backing = eviction::make_backing(_mem->data, _mem->size);
18 handle_ = create_index_buffer(_mem, _flags);
19 if(is_valid())
20 {
21 make_evictable(backing->size(),
22 [backing, flags = _flags](index_buffer& self) -> bool
23 {
24 const memory_view* mem = eviction::make_backing_ref(backing);
25 self.handle_ = create_index_buffer(mem, flags);
26 return self.is_valid();
27 });
28 }
29}
30} // namespace gfx
void make_evictable(std::uint64_t gpu_bytes, std::function< bool(index_buffer &)> restore_fn, evict_class cls=evict_class::evictable)
auto is_supported() -> bool
Definition eviction.cpp:650
std::shared_ptr< std::vector< std::uint8_t > > backing_buffer
Definition eviction.h:18
auto make_backing(const void *data, std::uint32_t size) -> backing_buffer
Definition eviction.h:20
index_buffer_handle create_index_buffer(const memory_view *_mem, uint16_t _flags)
Definition graphics.cpp:495
bgfx::Memory memory_view
Definition graphics.h:23
index_buffer()=default