86#ifndef NNGN_GRAPHICS_GRAPHICS_H
87#define NNGN_GRAPHICS_GRAPHICS_H
125 std::array<vec4, NNGN_MAX_LIGHTS>
dir = {};
127 std::array<mat4, NNGN_MAX_LIGHTS>
mat = {};
130 std::array<vec4, NNGN_MAX_LIGHTS>
dir = {};
131 std::array<vec4, NNGN_MAX_LIGHTS>
color_spec = {};
132 std::array<vec4, NNGN_MAX_LIGHTS>
pos = {};
176 std::array<char, name_max_len>
name = {};
180 std::array<char, 256>
name = {};
189 std::array<char, 256>
name = {};
242 std::span<const std::pair<u32, u32>>
buffers = {};
244 std::span<const Stage>
268 static constexpr float
272 static constexpr std::size_t
277 static std::unique_ptr<Graphics>
create(
Backend b,
const void *params);
304 virtual std::size_t
n_heaps(std::size_t
i)
const = 0;
316 std::size_t
i, std::size_t ih,
MemoryType *p)
const = 0;
324 virtual void get_keys(
size_t n, int32_t *keys)
const = 0;
370 void *
data,
auto &&vgen,
auto &&egen);
374 std::uint32_t
i, std::uint32_t
n,
const std::byte *
v) = 0;
378 unsigned char c, std::uint32_t
n,
396 b, offset,
n, size, &
f,
397 [](
void *p,
auto ...args) { (*
static_cast<F*
>(p))(args...); });
403 void *
data,
auto &&vgen,
auto &&egen
414template<Graphics::Backend>
static constexpr T mip_levels(T extent)
Definition math.h:236
precision highp int
Definition common.h:14
#define NNGN_TEXTURE_EXTENT
Definition const.h:4
#define NNGN_SHADOWS_ENABLED_BIT
Definition const.h:7
#define NNGN_TEXTURE_SIZE
Definition const.h:5
for i
Definition font.lua:5
local n
Definition dump_lights.lua:5
local c
Definition gamma.lua:11
local data
Definition house0.lua:10
pos
Definition lua_audio.cpp:17
local l
Definition light.lua:23
vec2_base< double > dvec2
Definition vec2.h:30
vec2_base< std::uint32_t > uvec2
Definition vec2.h:27
std::unique_ptr< Graphics > graphics_create_backend(const void *params)
std::uint32_t u32
Definition def.h:14
std::uint8_t u8
Definition def.h:12
std::uint64_t u64
Definition def.h:15
v[1]
Definition math.lua:22
#define NNGN_VIRTUAL(x)
Definition utils.h:27
local w
Definition strict.lua:12
Definition graphics.h:113
mat4 proj
Definition graphics.h:113
mat4 view
Definition graphics.h:113
Wrapper for a small unsigned integral representing flags.
Definition flags.h:18
Definition graphics.h:233
const char * name
Definition graphics.h:235
Type type
Definition graphics.h:236
Type
Definition graphics.h:234
u64 size
Definition graphics.h:237
Definition graphics.h:250
const mat4 * view
Definition graphics.h:253
const mat4 * screen_proj
Definition graphics.h:253
const mat4 * proj
Definition graphics.h:253
uint8_t * flags
Definition graphics.h:251
const uvec2 * screen
Definition graphics.h:252
Definition graphics.h:185
Type
Definition graphics.h:186
u32 driver_version
Definition graphics.h:191
std::array< char, 256 > name
Definition graphics.h:189
Type type
Definition graphics.h:192
u32 vendor_id
Definition graphics.h:191
std::array< char, 15 > version
Definition graphics.h:190
u32 device_id
Definition graphics.h:191
Definition graphics.h:174
u32 version
Definition graphics.h:177
std::array< char, name_max_len > name
Definition graphics.h:176
static constexpr std::size_t name_max_len
Definition graphics.h:175
Definition graphics.h:179
u32 version
Definition graphics.h:183
std::array< char, 256 > name
Definition graphics.h:180
std::array< char, 256 > description
Definition graphics.h:181
std::array< char, 15 > spec_version
Definition graphics.h:182
Definition graphics.h:255
const mat4 * dir_views
Definition graphics.h:259
const LightsUBO * ubo
Definition graphics.h:256
const mat4 * dir_proj
Definition graphics.h:258
const mat4 * point_views
Definition graphics.h:259
const mat4 * point_proj
Definition graphics.h:258
Definition graphics.h:202
u64 size
Definition graphics.h:204
Flag
Definition graphics.h:203
@ DEVICE_LOCAL
Definition graphics.h:203
Flag flags
Definition graphics.h:205
Definition graphics.h:207
Flag
Definition graphics.h:208
@ HOST_VISIBLE
Definition graphics.h:209
@ LAZILY_ALLOCATED
Definition graphics.h:211
@ HOST_CACHED
Definition graphics.h:210
@ DEVICE_LOCAL
Definition graphics.h:209
@ HOST_COHERENT
Definition graphics.h:210
Flag flags
Definition graphics.h:213
Definition graphics.h:169
int maj
Definition graphics.h:169
int min
Definition graphics.h:169
Definition graphics.h:149
Flags< Flag > flags
Definition graphics.h:153
Flag
Definition graphics.h:150
@ HIDDEN
Definition graphics.h:151
@ DEBUG
Definition graphics.h:151
Definition graphics.h:219
Type
Definition graphics.h:226
Flag
Definition graphics.h:220
@ CULL_BACK_FACES
Definition graphics.h:223
@ LINE
Definition graphics.h:224
@ DEPTH_WRITE
Definition graphics.h:222
@ DEPTH_TEST
Definition graphics.h:221
Type type
Definition graphics.h:230
const char * name
Definition graphics.h:229
Flag flags
Definition graphics.h:231
Definition graphics.h:194
Flag flags
Definition graphics.h:200
Flag
Definition graphics.h:195
@ GRAPHICS
Definition graphics.h:196
@ COMPUTE
Definition graphics.h:196
@ TRANSFER
Definition graphics.h:196
@ PRESENT
Definition graphics.h:197
u32 count
Definition graphics.h:199
Definition graphics.h:240
std::span< const std::pair< u32, u32 > > buffers
Definition graphics.h:242
u32 pipeline
Definition graphics.h:241
Definition graphics.h:239
std::span< const Stage > map_persp
Definition graphics.h:245
std::span< const Stage > normal
Definition graphics.h:246
std::span< const Stage > overlay
Definition graphics.h:246
std::span< const Stage > shadow_maps
Definition graphics.h:247
std::span< const Stage > map_ortho
Definition graphics.h:245
std::span< const Stage > shadow_cubes
Definition graphics.h:247
std::span< const Stage > no_light
Definition graphics.h:246
std::span< const Stage > depth
Definition graphics.h:245
std::span< const Stage > screen
Definition graphics.h:246
Definition graphics.h:215
u32 max_images
Definition graphics.h:216
uvec2 min_extent
Definition graphics.h:217
uvec2 cur_extent
Definition graphics.h:217
u32 min_images
Definition graphics.h:216
uvec2 max_extent
Definition graphics.h:217
Definition graphics.h:164
TerminalMode mode
Definition graphics.h:167
TerminalFlag flags
Definition graphics.h:166
Definition graphics.h:155
u32 minor
Definition graphics.h:155
const char * name
Definition graphics.h:155
u32 major
Definition graphics.h:155
u32 patch
Definition graphics.h:155
Definition graphics.h:170
Version version
Definition graphics.h:171
LogLevel log_level
Definition graphics.h:172
Definition graphics.h:138
virtual void set_bloom_downscale(std::size_t d)=0
virtual bool load_font(unsigned char c, std::uint32_t n, const nngn::uvec2 *size, const std::byte *v)=0
virtual void set_exposure(float e)=0
Backend
Definition graphics.h:143
virtual std::size_t n_memory_types(std::size_t i, std::size_t ih) const =0
static constexpr u32 TEXTURE_SIZE
Definition graphics.h:264
virtual int swap_interval() const =0
virtual std::size_t n_present_modes() const =0
void(*)(void *, int, int, int, int) key_callback_f
Definition graphics.h:140
virtual void set_blur_passes(std::size_t n)=0
virtual bool init_instance()=0
virtual void set_blur_size(float n)=0
virtual void set_bloom_blur_size(float n)=0
static constexpr u32 TEXTURE_EXTENT_LOG2
Definition graphics.h:263
virtual bool init_device()=0
virtual void set_cursor_mode(CursorMode m)=0
virtual GraphicsStats stats()=0
virtual void set_bloom_threshold(float t)=0
virtual bool resize_textures(std::uint32_t s)=0
static constexpr u32 SHADOW_MAP_INITIAL_SIZE
Definition graphics.h:266
void(*)(void *, dvec2) mouse_move_callback_f
Definition graphics.h:142
virtual u32 create_buffer(const BufferConfiguration &conf)=0
static constexpr std::size_t DEFAULT_BLOOM_DOWNSCALE
Definition graphics.h:273
TerminalMode
Definition graphics.h:163
virtual bool init_device(std::size_t i)=0
CursorMode
Definition graphics.h:249
static std::string flags_str(QueueFamily::Flag f)
Definition graphics.cpp:50
virtual void set_mouse_move_callback(void *data, mouse_move_callback_f f)=0
virtual void set_mouse_button_callback(void *data, mouse_button_callback_f f)=0
virtual bool init()
Fully initialize the back end.
Definition graphics.h:387
static std::unique_ptr< Graphics > create(Backend b, const void *params)
Definition graphics.cpp:7
virtual void set_bloom_blur_passes(std::size_t n)=0
virtual u32 create_pipeline(const PipelineConfiguration &conf)=0
virtual std::size_t n_device_extensions(std::size_t i) const =0
static constexpr float DEFAULT_BLOOM_THRESHOLD
Definition graphics.h:270
virtual ivec2 mouse_pos(void) const =0
LogLevel
Definition graphics.h:147
void(*)(void *, uvec2) size_callback_f
Definition graphics.h:139
static constexpr float DEFAULT_BLOOM_BLUR_SIZE
Definition graphics.h:271
virtual uvec2 window_size() const =0
virtual bool resize_font(std::uint32_t s)=0
virtual void present_modes(PresentMode *p) const =0
virtual bool set_render_list(const RenderList &l)=0
virtual void set_blur_downscale(std::size_t d)=0
virtual void set_automatic_exposure(bool b)=0
virtual void set_key_callback(void *data, key_callback_f f)=0
void(*)(void *, int, int, int) mouse_button_callback_f
Definition graphics.h:141
virtual void set_camera(const Camera &c)=0
virtual void device_infos(DeviceInfo *p) const =0
virtual void set_lighting(const Lighting &l)=0
virtual void set_window_title(const char *t)=0
virtual void heaps(std::size_t i, MemoryHeap *p) const =0
virtual bool set_buffer_size(u32 b, std::uint64_t size)=0
static constexpr float DEFAULT_EXPOSURE
Definition graphics.h:269
virtual void memory_types(std::size_t i, std::size_t ih, MemoryType *p) const =0
virtual void set_HDR_mix(float m)=0
virtual bool load_textures(std::uint32_t i, std::uint32_t n, const std::byte *v)=0
virtual void queue_families(std::size_t i, QueueFamily *p) const =0
virtual void poll_events() const =0
virtual void layers(Layer *p) const =0
virtual bool window_closed() const =0
virtual void set_swap_interval(int i)=0
virtual Version version() const =0
virtual void device_extensions(std::size_t i, Extension *p) const =0
static constexpr std::size_t DEFAULT_BLOOM_BLUR_PASSES
Definition graphics.h:275
virtual bool set_shadow_cube_size(uint32_t s)=0
static constexpr u32 TEXTURE_EXTENT
Definition graphics.h:262
TerminalFlag
Definition graphics.h:156
static const char * enum_str(DeviceInfo::Type t)
Definition graphics.cpp:25
static constexpr u32 SHADOW_CUBE_INITIAL_SIZE
Definition graphics.h:267
bool update_buffers(u32 vbo, u32 ebo, u64 voff, u64 eoff, u64 vn, u64 vsize, u64 en, u64 esize, void *data, auto &&vgen, auto &&egen)
Definition graphics.h:400
virtual bool write_to_buffer(u32 b, u64 offset, u64 n, u64 size, void *data, void f(void *, void *, u64, u64))=0
virtual std::size_t n_extensions() const =0
virtual void extensions(Extension *p) const =0
virtual void resize(int w, int h)=0
virtual void set_camera_updated()=0
virtual std::size_t n_heaps(std::size_t i) const =0
virtual void get_keys(size_t n, int32_t *keys) const =0
virtual bool init_backend()=0
virtual SurfaceInfo surface_info() const =0
virtual void set_bloom_amount(float a)=0
virtual void set_lighting_updated()=0
virtual std::size_t selected_device() const =0
virtual std::size_t n_queue_families(std::size_t i) const =0
virtual std::size_t n_layers() const =0
PresentMode
Definition graphics.h:148
virtual std::size_t n_devices() const =0
virtual bool set_n_swap_chain_images(std::size_t n)=0
virtual bool set_shadow_map_size(uint32_t s)=0
virtual bool set_n_frames(std::size_t n)=0
static constexpr std::size_t DEFAULT_BLUR_DOWNSCALE
Definition graphics.h:274
virtual bool set_buffer_capacity(u32 b, u64 size)=0
virtual void set_size_callback(void *data, size_callback_f f)=0
static constexpr u32 TEXTURE_MIP_LEVELS
Definition graphics.h:265
Definition graphics.h:114
std::array< vec4, NNGN_MAX_LIGHTS > dir
Definition graphics.h:125
struct nngn::LightsUBO::@8 point
vec3 view_pos
Definition graphics.h:120
u32 n_dir
Definition graphics.h:121
u32 flags
Definition graphics.h:118
Flag
Definition graphics.h:115
@ SHADOWS_ENABLED
Definition graphics.h:116
vec3 ambient
Definition graphics.h:122
std::array< vec4, NNGN_MAX_LIGHTS > att_cutoff
Definition graphics.h:133
u32 n_point
Definition graphics.h:123
std::array< vec4, NNGN_MAX_LIGHTS > color_spec
Definition graphics.h:126
float depth_transform1
Definition graphics.h:119
float depth_transform0
Definition graphics.h:119
Definition graphics.h:136
vec3 color
Definition graphics.h:136
vec3 norm
Definition graphics.h:136
vec3 pos
Definition graphics.h:136
local e
Definition math.lua:4
std::chrono::seconds s
Definition timing.cpp:6
std::chrono::duration< float, typename T::period > fd
Definition timing.cpp:8