Changeset 493 for trunk


Ignore:
Timestamp:
05/06/16 19:25:05 (9 years ago)
Author:
epyon
Message:
  • program validation moved to first use - fixes validation errors on Intel and AMD cards
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/gl/gl_context.hh

    r492 r493  
    9797                void enable( unsigned int what, bool value );
    9898                void set_active_texture( texture_slot slot );
     99
     100                bool validate_program( program p );
    99101        private:
    100102                texture_slot m_active_slot;
  • trunk/nv/gl/gl_device.hh

    r491 r493  
    3333                unsigned glidv;
    3434                unsigned glidf;
     35                bool validated;
    3536        };
    3637
     
    6061                virtual bool bind_block( program p, const string_view& name, uint32 index );
    6162                virtual int get_block_location( program p, const string_view& name, bool fatal = true ) const;
    62                 virtual void prepare_program( program p );
    6363                virtual string_view get_shader_header() const { return m_shader_header; }
    6464                virtual ~gl_device();
    6565        protected:
     66                void prepare_program( program p );
    6667                uniform_base* get_uniform( program p, const string_view& name, bool fatal = true ) const;
    6768
  • trunk/src/gl/gl_context.cc

    r492 r493  
    317317                glUseProgram( info->glid );
    318318                gdevice->update_uniforms( info );
    319         }
    320 }
     319                if ( !info->validated )
     320                {
     321                        validate_program( p );
     322                }
     323        }
     324}
     325
     326bool nv::gl_context::validate_program( program p )
     327{
     328        gl_device* gdevice = static_cast<gl_device*>( m_device );
     329        gl_program_info* info = gdevice->m_programs.get( p );
     330        if ( info )
     331        {
     332                info->validated = true;
     333                const uint32 buffer_size = 1024;
     334                char buffer[buffer_size] = { 0 };
     335                int length;
     336                int status;
     337                glValidateProgram( info->glid );
     338                glGetProgramiv( info->glid, GL_VALIDATE_STATUS, &status );
     339
     340                if ( status == GL_FALSE )
     341                {
     342                        glGetProgramInfoLog( info->glid, buffer_size, &length, buffer );
     343                        NV_LOG_ERROR( "Program #", info->glid, " validation error : ", buffer );
     344                        return false;
     345                }
     346                return true;
     347        }
     348        return false;
     349}
     350
    321351
    322352// void nv::gl_context::bind( buffer b )
  • trunk/src/gl/gl_device.cc

    r492 r493  
    3434
    3535        info->glid = glCreateProgram();
     36        info->validated = false;
    3637        compile( info, vs_source, fs_source );
    3738        prepare_program( result );
     
    452453        }
    453454
    454         glValidateProgram( p->glid );
    455         glGetProgramiv( p->glid, GL_VALIDATE_STATUS, &status );
    456 
    457         if ( status == GL_FALSE )
    458         {
    459                 glGetProgramInfoLog( p->glid, buffer_size, &length, buffer );
    460                 NV_LOG_ERROR( "Program #", p->glid, " validation error : ", buffer );
    461                 //return false;
    462         }
    463455        load_attributes( p );
    464456        load_uniforms( p );
Note: See TracChangeset for help on using the changeset viewer.