Changeset 469
- Timestamp:
- 09/17/15 17:17:20 (10 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/gfx/debug_draw.hh
r395 r469 41 41 program m_program; 42 42 vertex_array m_va; 43 buffer m_vb; 44 uint32 m_buffer_size; 43 45 vector< debug_vtx > m_data; 44 46 }; -
trunk/nv/interface/context.hh
r463 r469 125 125 126 126 template < typename VTX, slot SLOT > 127 void add_vertex_buffer_impl( vertex_array, buffer, const false_type& )127 void add_vertex_buffer_impl( vertex_array, buffer, bool, const false_type& ) 128 128 { 129 129 } 130 130 131 131 template < typename VTX, slot SLOT > 132 void add_vertex_buffer_impl( vertex_array va, buffer vb, const true_type& )132 void add_vertex_buffer_impl( vertex_array va, buffer vb, bool owned, const true_type& ) 133 133 { 134 134 typedef slot_info< VTX, SLOT > vinfo; 135 135 typedef datatype_traits< typename vinfo::value_type > dt_traits; 136 add_vertex_buffer( va, SLOT, vb, type_to_enum< typename dt_traits::base_type >::type, dt_traits::size, vinfo::offset, sizeof( VTX ), false);136 add_vertex_buffer( va, SLOT, vb, type_to_enum< typename dt_traits::base_type >::type, dt_traits::size, vinfo::offset, sizeof( VTX ), owned ); 137 137 } 138 138 139 139 template < typename VTX, slot SLOT > 140 void add_vertex_buffer( vertex_array va, buffer vb )141 { 142 add_vertex_buffer_impl< VTX, SLOT >( va, vb, has_slot< VTX, SLOT >() );140 void add_vertex_buffer( vertex_array va, buffer vb, bool owned ) 141 { 142 add_vertex_buffer_impl< VTX, SLOT >( va, vb, owned, has_slot< VTX, SLOT >() ); 143 143 } 144 144 145 145 template < typename VTX > 146 void add_vertex_buffers( vertex_array va, buffer vb )147 { 148 add_vertex_buffer< VTX, slot::POSITION > ( va, vb );149 add_vertex_buffer< VTX, slot::TEXCOORD > ( va, vb );150 add_vertex_buffer< VTX, slot::NORMAL > ( va, vb );151 add_vertex_buffer< VTX, slot::TANGENT > ( va, vb );152 add_vertex_buffer< VTX, slot::BONEINDEX > ( va, vb );153 add_vertex_buffer< VTX, slot::BONEWEIGHT >( va, vb );154 add_vertex_buffer< VTX, slot::COLOR > ( va, vb );146 void add_vertex_buffers( vertex_array va, buffer vb, bool owned ) 147 { 148 add_vertex_buffer< VTX, slot::POSITION > ( va, vb, owned ); 149 add_vertex_buffer< VTX, slot::TEXCOORD > ( va, vb, owned ); 150 add_vertex_buffer< VTX, slot::NORMAL > ( va, vb, owned ); 151 add_vertex_buffer< VTX, slot::TANGENT > ( va, vb, owned ); 152 add_vertex_buffer< VTX, slot::BONEINDEX > ( va, vb, owned ); 153 add_vertex_buffer< VTX, slot::BONEWEIGHT >( va, vb, owned ); 154 add_vertex_buffer< VTX, slot::COLOR > ( va, vb, owned ); 155 155 } 156 156 … … 182 182 vertex_array create_vertex_array( const VTX* v, size_t count, buffer_hint hint ) 183 183 { 184 // TODO: vb will not be owned or freed!185 184 vertex_array va = create_vertex_array(); 186 185 buffer vb = m_device->create_buffer( VERTEX_BUFFER, hint, count * sizeof( VTX ), v ); 187 add_vertex_buffers< VTX >( va, vb );186 add_vertex_buffers< VTX >( va, vb, true ); 188 187 return va; 189 188 } -
trunk/nv/stl/math/geometric.hh
r454 r469 70 70 { 71 71 return sqrt( dot( v, v ) ); 72 } 73 74 template < typename T, typename enable_if< is_fp_vec<T>::value >::type* = nullptr > 75 inline value_type_t<T> length_sq( const T& v ) 76 { 77 return dot( v, v ); 72 78 } 73 79 -
trunk/nv/stl/string/short_string.hh
r442 r469 95 95 char buffer[8]; 96 96 size_t result = sint32_to_buffer( array_ref< char >( buffer ), s ); 97 return ( result > 0 ? append( buffer .data(), result ) : 0 );97 return ( result > 0 ? append( buffer, result ) : 0 ); 98 98 } 99 99 -
trunk/nv/stl/utility/common.hh
r395 r469 34 34 35 35 template < typename T > 36 inline const T& max( const T& a, const T& b, const T& c ) 37 { 38 return a < b ? (c < b ? b : c) : a; 39 } 40 41 template < typename T > 36 42 inline const T& min( const T& a, const T& b ) 37 43 { 38 44 return a > b ? b : a; 39 45 } 46 47 template < typename T > 48 inline const T& min( const T& a, const T& b, const T& c ) 49 { 50 return a > b ? ( c > b ? b : c ) : a; 51 } 52 40 53 } 41 54 -
trunk/src/gfx/debug_draw.cc
r395 r469 8 8 9 9 #include "nv/interface/device.hh" 10 #include "nv/core/logging.hh" 10 11 11 12 static const char *nv_debug_draw_vertex_shader = R"( … … 34 35 { 35 36 m_program = m_context->get_device()->create_program( nv_debug_draw_vertex_shader, nv_debug_draw_fragment_shader ); 37 m_buffer_size = 0; 36 38 } 37 39 38 40 void nv::debug_data::update() 39 41 { 40 m_context->release( m_va ); 41 m_va = m_context->create_vertex_array( m_data, nv::STATIC_DRAW ); 42 if ( !m_va.is_valid() || m_data.size() > m_buffer_size ) 43 { 44 if ( m_va.is_valid() ) m_context->release( m_va ); 45 m_buffer_size = nv::max( m_data.size(), 4096U, m_buffer_size ); 46 m_va = m_context->create_vertex_array(); 47 m_vb = m_context->get_device()->create_buffer( VERTEX_BUFFER, nv::STREAM_DRAW, m_buffer_size * sizeof( debug_vtx ), m_data.data() ); 48 m_context->add_vertex_buffers< debug_vtx >( m_va, m_vb, true ); 49 } 50 else 51 { 52 m_context->update( m_vb, m_data.data(), 0, m_data.size()* sizeof( debug_vtx ) ); 53 } 42 54 } 43 55 -
trunk/src/gl/gl_context.cc
r466 r469 48 48 for ( uint32 i = 0; i < info->count; ++i ) 49 49 { 50 if ( info->attr[i].owner ) m_device->release( info->attr[i].vbuffer ); 50 if ( info->attr[i].owner ) 51 m_device->release( info->attr[i].vbuffer ); 51 52 } 52 53 if ( info->index.is_valid() && info->index_owner) m_device->release( info->index ); -
trunk/src/gui/gui_gfx_renderer.cc
r456 r469 160 160 sr->varray = m_window->get_context()->create_vertex_array(); 161 161 buffer vb = sr->buffer.get_buffer(); 162 m_window->get_context()->add_vertex_buffers< vertex >( sr->varray, vb );162 m_window->get_context()->add_vertex_buffers< vertex >( sr->varray, vb, false ); 163 163 164 164 nv::sampler sampler( nv::sampler::LINEAR, nv::sampler::CLAMP_TO_EDGE );
Note: See TracChangeset
for help on using the changeset viewer.