Browse Source

inital structure for linear asset memory allocation

render_group_fix
cinnaboot 5 years ago
parent
commit
41c37773a4
  1. 50
      include/renderer.h

50
include/renderer.h

@ -41,6 +41,56 @@ struct SDL_Handles
SDL_DisplayMode currentDisplayMode;
};
// --------------------------
// Memory allocation WIP
#define MAX_PATH_SIZE 256
struct render_asset
{
// header
size_t size;
uint name_len;
uint num_vertices;
uint num_indices;
render_asset* next;
// data
char* filepath;
glm::vec3* vertices;
uint* indices;
glm::vec3* texture_coords;
glm::mat4* model_transform;
// FIXME: also need to flatten diffuse_texture->pixels and track size of
// util_image structure, ie) another heaader + pixels
util_image* diffuse_texture;
// FIXME: node_animation has a pointer to a render_object. need to decouple
// that somehow
//node_animation* node_anim;
};
// NOTE: This is a linearly allocated block to contain all used mesh assets
// Assets are loaded once, and then copied to video memory as needed.
struct asset_memory_block
{
uint asset_count;
size_t max_size;
render_asset* first;
render_asset* next_free;
};
#define INITIAL_ASSET_BLOCK_SIZE 256 * 1024 * 1024 // 256MB
asset_memory_block*
memInitBlock(size_t initial_size = INITIAL_ASSET_BLOCK_SIZE);
render_asset*
memAddAsset(const char* filepath);
void
memFreeBlock(asset_memory_block* block);
// Memory allocation WIP
// --------------------------
struct render_state
{
glm::vec2 viewport_dims;

Loading…
Cancel
Save