Index: /trunk/nv/gl/gl_context.hh
===================================================================
--- /trunk/nv/gl/gl_context.hh	(revision 492)
+++ /trunk/nv/gl/gl_context.hh	(revision 493)
@@ -97,4 +97,6 @@
 		void enable( unsigned int what, bool value );
 		void set_active_texture( texture_slot slot );
+
+		bool validate_program( program p );
 	private:
 		texture_slot m_active_slot;
Index: /trunk/nv/gl/gl_device.hh
===================================================================
--- /trunk/nv/gl/gl_device.hh	(revision 492)
+++ /trunk/nv/gl/gl_device.hh	(revision 493)
@@ -33,4 +33,5 @@
 		unsigned glidv;
 		unsigned glidf;
+		bool validated;
 	};
 
@@ -60,8 +61,8 @@
 		virtual bool bind_block( program p, const string_view& name, uint32 index );
 		virtual int get_block_location( program p, const string_view& name, bool fatal = true ) const;
-		virtual void prepare_program( program p );
 		virtual string_view get_shader_header() const { return m_shader_header; }
 		virtual ~gl_device();
 	protected:
+		void prepare_program( program p );
 		uniform_base* get_uniform( program p, const string_view& name, bool fatal = true ) const;
 
Index: /trunk/src/gl/gl_context.cc
===================================================================
--- /trunk/src/gl/gl_context.cc	(revision 492)
+++ /trunk/src/gl/gl_context.cc	(revision 493)
@@ -317,6 +317,36 @@
 		glUseProgram( info->glid );
 		gdevice->update_uniforms( info );
-	}
-}
+		if ( !info->validated )
+		{
+			validate_program( p );
+		}
+	}
+}
+
+bool nv::gl_context::validate_program( program p )
+{
+	gl_device* gdevice = static_cast<gl_device*>( m_device );
+	gl_program_info* info = gdevice->m_programs.get( p );
+	if ( info )
+	{
+		info->validated = true;
+		const uint32 buffer_size = 1024;
+		char buffer[buffer_size] = { 0 };
+		int length;
+		int status;
+		glValidateProgram( info->glid );
+		glGetProgramiv( info->glid, GL_VALIDATE_STATUS, &status );
+
+		if ( status == GL_FALSE )
+		{
+			glGetProgramInfoLog( info->glid, buffer_size, &length, buffer );
+			NV_LOG_ERROR( "Program #", info->glid, " validation error : ", buffer );
+			return false;
+		}
+		return true;
+	}
+	return false;
+}
+
 
 // void nv::gl_context::bind( buffer b )
Index: /trunk/src/gl/gl_device.cc
===================================================================
--- /trunk/src/gl/gl_device.cc	(revision 492)
+++ /trunk/src/gl/gl_device.cc	(revision 493)
@@ -34,4 +34,5 @@
 
 	info->glid = glCreateProgram();
+	info->validated = false;
 	compile( info, vs_source, fs_source );
 	prepare_program( result );
@@ -452,13 +453,4 @@
 	}
 
-	glValidateProgram( p->glid );
-	glGetProgramiv( p->glid, GL_VALIDATE_STATUS, &status );
-
-	if ( status == GL_FALSE )
-	{
-		glGetProgramInfoLog( p->glid, buffer_size, &length, buffer );
-		NV_LOG_ERROR( "Program #", p->glid, " validation error : ", buffer );
-		//return false;
-	}
 	load_attributes( p );
 	load_uniforms( p );
