@ -3033,14 +3033,9 @@ static void vrend_draw_bind_samplers(struct vrend_context *ctx)
ctx - > sub - > sampler_state_dirty = false ;
ctx - > sub - > sampler_state_dirty = false ;
}
}
static void vrend_draw_bind_ubo ( struct vrend_context * ctx )
static void vrend_draw_bind_ubo_shader ( struct vrend_context * ctx ,
int shader_type , int * ubo_id )
{
{
int i ;
int ubo_id ;
int shader_type ;
ubo_id = 0 ;
for ( shader_type = PIPE_SHADER_VERTEX ; shader_type < = ctx - > sub - > last_shader_idx ; shader_type + + ) {
uint32_t mask ;
uint32_t mask ;
int shader_ubo_idx ;
int shader_ubo_idx ;
struct pipe_constant_buffer * cb ;
struct pipe_constant_buffer * cb ;
@ -3048,17 +3043,17 @@ static void vrend_draw_bind_ubo(struct vrend_context *ctx)
struct vrend_shader_info * sinfo ;
struct vrend_shader_info * sinfo ;
if ( ! ctx - > sub - > const_bufs_used_mask [ shader_type ] )
if ( ! ctx - > sub - > const_bufs_used_mask [ shader_type ] )
continue ;
return ;
if ( ! ctx - > sub - > prog - > ubo_locs [ shader_type ] )
if ( ! ctx - > sub - > prog - > ubo_locs [ shader_type ] )
continue ;
return ;
sinfo = & ctx - > sub - > prog - > ss [ shader_type ] - > sel - > sinfo ;
sinfo = & ctx - > sub - > prog - > ss [ shader_type ] - > sel - > sinfo ;
mask = ctx - > sub - > const_bufs_used_mask [ shader_type ] ;
mask = ctx - > sub - > const_bufs_used_mask [ shader_type ] ;
while ( mask ) {
while ( mask ) {
/* The const_bufs_used_mask stores the gallium uniform buffer indices */
/* The const_bufs_used_mask stores the gallium uniform buffer indices */
i = u_bit_scan ( & mask ) ;
int i = u_bit_scan ( & mask ) ;
/* The cbs array is indexed using the gallium uniform buffer index */
/* The cbs array is indexed using the gallium uniform buffer index */
cb = & ctx - > sub - > cbs [ shader_type ] [ i ] ;
cb = & ctx - > sub - > cbs [ shader_type ] [ i ] ;
@ -3072,12 +3067,22 @@ static void vrend_draw_bind_ubo(struct vrend_context *ctx)
if ( shader_ubo_idx = = sinfo - > num_ubos )
if ( shader_ubo_idx = = sinfo - > num_ubos )
continue ;
continue ;
glBindBufferRange ( GL_UNIFORM_BUFFER , ubo_id , res - > id ,
glBindBufferRange ( GL_UNIFORM_BUFFER , * ubo_id , res - > id ,
cb - > buffer_offset , cb - > buffer_size ) ;
cb - > buffer_offset , cb - > buffer_size ) ;
/* The ubo_locs array is indexed using the shader ubo index */
/* The ubo_locs array is indexed using the shader ubo index */
glUniformBlockBinding ( ctx - > sub - > prog - > id , ctx - > sub - > prog - > ubo_locs [ shader_type ] [ shader_ubo_idx ] , ubo_id ) ;
glUniformBlockBinding ( ctx - > sub - > prog - > id , ctx - > sub - > prog - > ubo_locs [ shader_type ] [ shader_ubo_idx ] , * ubo_id ) ;
ubo_id + + ;
( * ubo_id ) + + ;
}
}
}
static void vrend_draw_bind_ubo ( struct vrend_context * ctx )
{
int ubo_id ;
int shader_type ;
ubo_id = 0 ;
for ( shader_type = PIPE_SHADER_VERTEX ; shader_type < = ctx - > sub - > last_shader_idx ; shader_type + + ) {
vrend_draw_bind_ubo_shader ( ctx , shader_type , & ubo_id ) ;
}
}
}
}