Unravel Engine C++ Reference
Loading...
Searching...
No Matches
gfx::program Struct Reference

#include <program.h>

Inheritance diagram for gfx::program:
gfx::handle_impl< program, program_handle > gfx::ievictable

Public Types

using uniform_ptr = std::shared_ptr<uniform>
 
- Public Types inherited from gfx::handle_impl< program, program_handle >
using ptr
 
using uptr
 
using weak_ptr
 
using handle_type_t
 
using base_type
 

Public Member Functions

 program ()=default
 
 program (const shader &compute_shader)
 
 program (const shader &vertex_shader, const shader &fragment_shader)
 
void set_texture (uint8_t _stage, const hpp::string_view &_sampler, const gfx::frame_buffer *_handle, uint8_t _attachment=0, uint32_t _flags=std::numeric_limits< uint32_t >::max())
 
void set_texture (uint8_t _stage, const hpp::string_view &_sampler, const gfx::texture *_texture, uint32_t _flags=std::numeric_limits< uint32_t >::max())
 
void set_uniform (const hpp::string_view &_name, const void *_value, uint16_t _num=1)
 
auto get_uniform (const hpp::string_view &_name, uint8_t stage=uint8_t(-1)) -> uniform_ptr
 
- Public Member Functions inherited from gfx::handle_impl< program, program_handle >
 handle_impl ()=default
 
 handle_impl (const handle_impl &)=delete
 
 handle_impl (handle_impl &&)=delete
 
auto operator= (const handle_impl &) -> handle_impl &=delete
 
auto operator= (handle_impl &&) -> handle_impl &=delete
 
 ~handle_impl () override
 
void dispose ()
 
auto is_valid () const -> bool
 
auto native_handle () const -> program_handle
 
void set_name (const hpp::string_view &_name)
 
auto on_evict () -> std::uint64_t override
 Release the GPU handle. Returns the number of GPU bytes freed. Must be idempotent.
 
auto on_restore () -> bool override
 Recreate the GPU handle from the CPU backing. Returns true on success.
 
auto gpu_size () const -> std::uint64_t override
 Approximate GPU footprint of the resource in bytes.
 
- Public Member Functions inherited from gfx::ievictable
 ievictable ()=default
 
 ievictable (const ievictable &)=delete
 
auto operator= (const ievictable &) -> ievictable &=delete
 
 ievictable (ievictable &&)=delete
 
auto operator= (ievictable &&) -> ievictable &=delete
 
virtual ~ievictable ()=default
 
auto get_evict_class () const -> evict_class
 
auto get_evict_state () const -> evict_state
 
auto get_last_use_frame () const -> std::uint64_t
 
auto get_use_count () const -> std::uint64_t
 
void touch () const noexcept
 

Public Attributes

std::map< std::string, uniform_ptr, std::less<> > uniforms
 All uniforms for this program.
 
std::array< uniform_ptr, 64 > textures_uniforms
 

Additional Inherited Members

- Static Public Member Functions inherited from gfx::handle_impl< program, program_handle >
static auto invalid_handle () -> program_handle
 
- Protected Member Functions inherited from gfx::handle_impl< program, program_handle >
auto fallback_handle () const -> program_handle
 
auto get_fallback_handle () const -> program_handle
 
void make_evictable (std::uint64_t gpu_bytes, std::function< bool(program &)> restore_fn, evict_class cls=evict_class::evictable)
 
void make_evictable_deferred (std::uint64_t gpu_bytes, std::function< bool(program &)> restore_fn, evict_class cls=evict_class::evictable)
 
- Protected Attributes inherited from gfx::handle_impl< program, program_handle >
program_handle handle_
 
std::function< bool(program &)> restore_fn_
 
std::uint64_t gpu_size_
 
- Protected Attributes inherited from gfx::ievictable
std::uint64_t last_use_frame_ {0}
 Frame the resource was last used on (heuristic, written from touch).
 
std::uint64_t use_count_ {0}
 Number of times the resource was used (heuristic, written from touch).
 
evict_state evict_state_ {evict_state::resident}
 Current residency state. Written by the owning resource during evict/restore.
 
evict_class evict_class_ {evict_class::non_evictable}
 Eligibility class. Set once when the resource opts into eviction.
 

Detailed Description

Definition at line 17 of file program.h.

Member Typedef Documentation

◆ uniform_ptr

using gfx::program::uniform_ptr = std::shared_ptr<uniform>

Definition at line 19 of file program.h.

Constructor & Destructor Documentation

◆ program() [1/3]

gfx::program::program ( )
default

◆ program() [2/3]

gfx::program::program ( const shader & compute_shader)

Definition at line 9 of file program.cpp.

◆ program() [3/3]

gfx::program::program ( const shader & vertex_shader,
const shader & fragment_shader )

Definition at line 25 of file program.cpp.

Member Function Documentation

◆ get_uniform()

auto gfx::program::get_uniform ( const hpp::string_view & _name,
uint8_t stage = uint8_t(-1) ) -> uniform_ptr

Definition at line 97 of file program.cpp.

◆ set_texture() [1/2]

void gfx::program::set_texture ( uint8_t _stage,
const hpp::string_view & _sampler,
const gfx::frame_buffer * _handle,
uint8_t _attachment = 0,
uint32_t _flags = std::numeric_limits<uint32_t>::max() )

Definition at line 46 of file program.cpp.

◆ set_texture() [2/2]

void gfx::program::set_texture ( uint8_t _stage,
const hpp::string_view & _sampler,
const gfx::texture * _texture,
uint32_t _flags = std::numeric_limits<uint32_t>::max() )

Definition at line 67 of file program.cpp.

◆ set_uniform()

void gfx::program::set_uniform ( const hpp::string_view & _name,
const void * _value,
uint16_t _num = 1 )

Definition at line 87 of file program.cpp.

Member Data Documentation

◆ textures_uniforms

std::array<uniform_ptr, 64> gfx::program::textures_uniforms

Definition at line 99 of file program.h.

◆ uniforms

std::map<std::string, uniform_ptr, std::less<> > gfx::program::uniforms

All uniforms for this program.

Definition at line 98 of file program.h.


The documentation for this struct was generated from the following files: