Changeset 473
- Timestamp:
- 10/09/15 14:06:56 (10 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/base/rtti_support.hh
r436 r473 17 17 18 18 #define NV_RTTI_DECLARE(T) \ 19 namespace nv { \ 20 template<> struct rtti_type_hash< T > { \ 19 template<> struct ::nv::rtti_type_hash< T > { \ 20 NV_MSVC_SUPRESS( 4307 )\ 21 static const nv::uint64 value = nv::rtti_const_hash(#T); \ 21 22 static const char* name() { return #T; } \ 22 23 static nv::uint64 hash() { \ 23 NV_MSVC_SUPRESS( 4307 )\24 static const nv::uint64 value = nv::rtti_const_hash(#T); \25 24 return value; \ 26 25 } \ 27 }; }\26 }; \ 28 27 29 28 #define NV_RTTI_DECLARE_NAME(T,NAME) \ 30 namespace nv { \ 31 template<> struct rtti_type_hash< T > { \ 29 template<> struct ::nv::rtti_type_hash< T > { \ 30 NV_MSVC_SUPRESS( 4307 )\ 31 static const nv::uint64 value = nv::rtti_const_hash(#T); \ 32 32 static const char* name() { return NAME; } \ 33 33 static nv::uint64 hash() { \ 34 NV_MSVC_SUPRESS( 4307 )\35 static const nv::uint64 value = nv::rtti_const_hash(#T); \36 34 return value; \ 37 35 } \ 38 }; }\36 }; \ 39 37 40 38 namespace nv -
trunk/nv/core/arcball.hh
r454 r473 50 50 vec3 vb = get_arcball_vector( nposition ); 51 51 52 m_angle = math::acos( math::min( 1.0f, math::dot( va, vb ) ) );52 m_angle = nv::acos( math::min( 1.0f, math::dot( va, vb ) ) ); 53 53 m_axis = math::cross( va, vb ); 54 54 m_last = nposition; -
trunk/nv/gl/gl_context.hh
r463 r473 48 48 virtual void bind( framebuffer f, framebuffer_slot ft = FRAMEBUFFER ); 49 49 virtual void bind( texture t, texture_slot slot ); 50 virtual void bind( buffer b, uint32 index, size_t offset = 0, size_t size = 0 ); 50 51 51 52 virtual void update( texture t, const void* data ); 52 53 virtual void update( buffer b, const void* data, size_t offset, size_t size ); 54 virtual void update( buffer b, uint32 index, const void* data, size_t offset, size_t size ); 53 55 54 56 virtual void clear( const clear_state& cs ); 55 57 // temporary 56 virtual void draw( primitive prim, const render_state& rs, program p, vertex_array va, size_t count );58 virtual void draw( primitive prim, const render_state& rs, program p, vertex_array va, size_t count, size_t first = 0 ); 57 59 virtual const ivec4& get_viewport(); 58 60 virtual void set_viewport( const ivec4& viewport ); -
trunk/nv/gl/gl_device.hh
r463 r473 56 56 57 57 virtual int get_attribute_location( program p, const string_view& name, bool fatal = true ) const; 58 virtual int get_block_location( program p, const string_view& name, bool fatal = true ) const; 58 59 virtual void prepare_program( program p ); 59 60 virtual string_view get_shader_header() const { return m_shader_header; } -
trunk/nv/interface/context.hh
r469 r473 102 102 virtual void bind( framebuffer f, framebuffer_slot slot = FRAMEBUFFER ) = 0; 103 103 virtual void bind( texture, texture_slot ) = 0; 104 virtual void bind( buffer, uint32 /*index*/, size_t /*offset*/ = 0, size_t /*size */= 0 ) = 0; 105 104 106 virtual void update( texture, const void* ) = 0; 105 107 virtual void update( buffer, const void*, size_t /*offset*/, size_t /*size*/ ) = 0; 108 virtual void update( buffer, uint32 /*index*/, const void* , size_t /*offset*/, size_t /*size*/ ) = 0; 106 109 107 110 virtual void clear( const clear_state& cs ) = 0; 108 111 // temporary 109 virtual void draw( primitive prim, const render_state& rs, program p, vertex_array va, size_t count ) = 0;110 111 void draw( primitive prim, const render_state& rs, const scene_state& s, program p, vertex_array va, size_t count )112 virtual void draw( primitive prim, const render_state& rs, program p, vertex_array va, size_t count, size_t first = 0 ) = 0; 113 114 void draw( primitive prim, const render_state& rs, const scene_state& s, program p, vertex_array va, size_t count, size_t first = 0 ) 112 115 { 113 116 apply_engine_uniforms(p,s); 114 draw( prim, rs, p, va, count );117 draw( prim, rs, p, va, count, first ); 115 118 } 116 119 virtual void apply_engine_uniforms( program p, const scene_state& s ) = 0; -
trunk/nv/interface/device.hh
r472 r473 82 82 struct buffer_tag {}; 83 83 struct program_tag {}; 84 84 85 typedef handle< uint32, 16, 16, buffer_tag > buffer; 85 86 typedef handle< uint32, 16, 16, texture_tag > texture; 86 87 typedef handle< uint32, 16, 16, program_tag > program; 88 89 NV_RTTI_DECLARE_NAME( buffer, "buffer" ) 90 NV_RTTI_DECLARE_NAME( texture, "texture" ) 91 NV_RTTI_DECLARE_NAME( program, "program" ) 87 92 88 93 struct sampler … … 129 134 VERTEX_BUFFER, 130 135 INDEX_BUFFER, 136 UNIFORM_BUFFER, 131 137 }; 132 138 … … 198 204 } 199 205 206 int try_get_block_location( program p, const string_view& name ) const 207 { 208 return get_block_location( p, name, false ); 209 } 210 200 211 virtual int get_attribute_location( program p, const string_view& name, bool fatal = true ) const = 0; 212 virtual int get_block_location( program p, const string_view& name, bool fatal = true ) const = 0; 213 201 214 202 215 template < typename T > -
trunk/nv/stl/string/short_string.hh
r472 r473 145 145 { 146 146 Storage::reserve( new_size + 1 ); 147 Storage::resize( min( new_size, capacity() - 1 ) );147 Storage::resize( min( new_size, this->capacity() - 1 ) ); 148 148 this->data()[this->size()] = 0; 149 149 } … … 172 172 else 173 173 { 174 result = capacity() - this->size() - 1;175 Storage::try_resize( capacity() - 1, true, 1 );174 result = this->capacity() - this->size() - 1; 175 Storage::try_resize( this->capacity() - 1, true, 1 ); 176 176 } 177 177 this->data()[this->size()] = 0; -
trunk/src/gl/gl_context.cc
r469 r473 205 205 { 206 206 glBindFramebuffer( framebuffer_slot_to_enum(ft), 0 ); 207 } 208 } 209 210 void nv::gl_context::bind( buffer b, uint32 index, size_t offset /*= 0*/, size_t size /*= 0 */ ) 211 { 212 const gl_buffer_info* info = static_cast< const gl_buffer_info* >( m_device->get_buffer_info( b ) ); 213 if ( info ) 214 { 215 if ( size == 0 ) 216 glBindBufferBase( buffer_type_to_enum( info->type ), index, info->glid ); 217 else 218 glBindBufferRange( buffer_type_to_enum( info->type ), index, info->glid, offset, size ); 207 219 } 208 220 } … … 339 351 else 340 352 glTexImage2D( gl_type, 0, static_cast<GLint>( nv::image_format_to_internal_enum(format.format) ), size.x, size.y, 0, nv::image_format_to_enum(format.format), nv::datatype_to_gl_enum(format.type), data ); 353 } 354 } 355 356 void nv::gl_context::update( buffer b, uint32 index, const void* data, size_t offset, size_t size ) 357 { 358 const gl_buffer_info* info = static_cast<const gl_buffer_info*>( m_device->get_buffer_info( b ) ); 359 if ( info ) 360 { 361 GLenum glenum = buffer_type_to_enum( info->type ); 362 if ( size == 0 ) 363 glBindBufferBase( glenum, index, info->glid ); 364 else 365 glBindBufferRange( glenum, index, info->glid, offset, size ); 366 glBufferSubData( glenum, GLintptr( offset ), GLsizeiptr( size ), data ); 341 367 } 342 368 } … … 750 776 } 751 777 752 void gl_context::draw( primitive prim, const render_state& rs, program p, vertex_array va, nv::size_t count )778 void gl_context::draw( primitive prim, const render_state& rs, program p, vertex_array va, nv::size_t count, nv::size_t first ) 753 779 { 754 780 apply_render_state( rs ); … … 760 786 if ( info->index.is_valid() ) 761 787 { 762 glDrawElements( primitive_to_enum(prim), static_cast<GLsizei>( count ), datatype_to_gl_enum( info->index_type ), 0);788 glDrawElements( primitive_to_enum(prim), static_cast<GLsizei>( count ), datatype_to_gl_enum( info->index_type ), reinterpret_cast< const void* >( get_datatype_info( info->index_type ).size * first ) ); 763 789 } 764 790 else 765 791 { 766 glDrawArrays( primitive_to_enum(prim), 0, static_cast<GLsizei>( count ) );792 glDrawArrays( primitive_to_enum(prim), first, static_cast<GLsizei>( count ) ); 767 793 } 768 794 unbind( va ); -
trunk/src/gl/gl_device.cc
r471 r473 337 337 } 338 338 } 339 return -1; 340 } 341 342 int nv::gl_device::get_block_location( program p, const string_view& name, bool fatal /*= true */ ) const 343 { 339 344 return -1; 340 345 } … … 450 455 { 451 456 int params; 457 int bparams; 452 458 glGetProgramiv( p->glid, GL_ACTIVE_UNIFORMS, ¶ms ); 459 glGetProgramiv( p->glid, GL_ACTIVE_UNIFORM_BLOCKS, &bparams ); 453 460 454 461 for ( unsigned i = 0; i < unsigned( params ); ++i ) … … 479 486 NV_ASSERT( u, "Unknown uniform type!" ); 480 487 (*p->m_uniform_map)[ name ] = u; 488 } 489 490 for ( unsigned i = 0; i < unsigned( bparams ); ++i ) 491 { 492 int uni_len; 493 char name_buffer[128]; 494 495 glGetActiveUniformBlockName( p->glid, i, 128, &uni_len, name_buffer ); 496 NV_LOG_INFO( string_view( name_buffer, size_t( uni_len ) ) ); 481 497 } 482 498 } -
trunk/src/gl/gl_enum.cc
r472 r473 168 168 switch( type ) 169 169 { 170 case VERTEX_BUFFER : return GL_ARRAY_BUFFER; 171 case INDEX_BUFFER : return GL_ELEMENT_ARRAY_BUFFER; 170 case VERTEX_BUFFER : return GL_ARRAY_BUFFER; 171 case INDEX_BUFFER : return GL_ELEMENT_ARRAY_BUFFER; 172 case UNIFORM_BUFFER : return GL_UNIFORM_BUFFER; 172 173 NV_RETURN_COVERED_DEFAULT( 0 ); 173 174 }
Note: See TracChangeset
for help on using the changeset viewer.