aconstlink / motor

Software Framework for Audio/Visual/Interactive Real-Time Applications
MIT License
1 stars 0 forks source link

Graphics backend variable storage optimization #84

Closed aconstlink closed 2 months ago

aconstlink commented 2 months ago

There are many vector in vector variable storage containers.

Since the refactoring of the managed pointer model, there are placehoders for every variable set ...

motor::vector< motor::graphics::variable_set_mtr_t > var_sets ;

... but variable sets are still stored additionally for variables.

// user provided variable set
motor::vector< std::pair<
    motor::graphics::variable_set_ptr_t,
    motor::vector< uniform_variable_link > > > var_sets_data ;

This could be changed so that the variable set index var_set_idx is stored with the uniform link

struct uniform_variable_link
{
    size_t var_set_idx ;

    // the index into the shader_config::uniforms array
    size_t uniform_id ;
    // the user variable holding the data.
    motor::graphics::ivariable_ptr_t var ;

    // pointing into the mem_block
    void_ptr_t mem = nullptr ;
};

Because the multiple variable sets feature is rarely used, this could be simply faster because less memory indirection is done.

This could be done for GL4 and D3D11.