static void vrend_draw_bind_objects(struct vrend_sub_context *sub_ctx, bool new_program)
{
   int next_ubo_id = 0, next_sampler_id = 0;
   for (int shader_type = PIPE_SHADER_VERTEX; shader_type <= sub_ctx->last_shader_idx; shader_type++) {
      next_ubo_id = vrend_draw_bind_ubo_shader(sub_ctx, shader_type, next_ubo_id);
      vrend_draw_bind_const_shader(sub_ctx, shader_type, new_program);
      next_sampler_id = vrend_draw_bind_samplers_shader(sub_ctx, shader_type,
                                                        next_sampler_id);

      vrend_draw_bind_images_shader(sub_ctx, shader_type);
      vrend_draw_bind_ssbo_shader(sub_ctx, shader_type);

      if (vrend_state.use_gles) {
         if (sub_ctx->prog->tex_levels_uniform_id[shader_type] != -1) {
            glUniform1iv(sub_ctx->prog->tex_levels_uniform_id[shader_type],
                         sub_ctx->n_samplers[shader_type],
                         sub_ctx->texture_levels[shader_type]);
         }
      }
   }

   vrend_draw_bind_abo_shader(sub_ctx);

   if (vrend_state.use_core_profile && sub_ctx->prog->fs_stipple_loc != -1) {
      glActiveTexture(GL_TEXTURE0 + next_sampler_id);
      glBindTexture(GL_TEXTURE_2D, sub_ctx->parent->pstipple_tex_id);
      glUniform1i(sub_ctx->prog->fs_stipple_loc, next_sampler_id);
   }

   if (sub_ctx->prog->fs_alpha_ref_val_loc != -1) {
      assert(sub_ctx->prog->fs_alpha_func_loc != -1);

      /* If it's an integer format surface, alpha test shouldn't do anything. */
      if (sub_ctx->dsa_state.alpha.enabled && sub_ctx->surf[0] &&
          !util_format_is_pure_integer(sub_ctx->surf[0]->format))
          glUniform1i(sub_ctx->prog->fs_alpha_func_loc, sub_ctx->dsa_state.alpha.func);
      else
          glUniform1i(sub_ctx->prog->fs_alpha_func_loc, PIPE_FUNC_ALWAYS);

      glUniform1f(sub_ctx->prog->fs_alpha_ref_val_loc, sub_ctx->dsa_state.alpha.ref_value);
   }
}
static void vrend_draw_bind_objects(struct vrend_sub_context *sub_ctx, bool new_program)
{
   int next_ubo_id = 0, next_sampler_id = 0;
   for (int shader_type = PIPE_SHADER_VERTEX; shader_type <= sub_ctx->last_shader_idx; shader_type++) {
      next_ubo_id = vrend_draw_bind_ubo_shader(sub_ctx, shader_type, next_ubo_id);
      vrend_draw_bind_const_shader(sub_ctx, shader_type, new_program);
      next_sampler_id = vrend_draw_bind_samplers_shader(sub_ctx, shader_type,
                                                        next_sampler_id);

      vrend_draw_bind_images_shader(sub_ctx, shader_type);
      vrend_draw_bind_ssbo_shader(sub_ctx, shader_type);

      if (vrend_state.use_gles) {
         if (sub_ctx->prog->tex_levels_uniform_id[shader_type] != -1) {
            glUniform1iv(sub_ctx->prog->tex_levels_uniform_id[shader_type],
                         sub_ctx->n_samplers[shader_type],
                         sub_ctx->texture_levels[shader_type]);
         }
      }
   }

   vrend_draw_bind_abo_shader(sub_ctx);

   if (vrend_state.use_core_profile && sub_ctx->prog->fs_stipple_loc != -1) {
      glActiveTexture(GL_TEXTURE0 + next_sampler_id);
      glBindTexture(GL_TEXTURE_2D, sub_ctx->parent->pstipple_tex_id);
      glUniform1i(sub_ctx->prog->fs_stipple_loc, next_sampler_id);
   }

   if (sub_ctx->prog->fs_alpha_ref_val_loc != -1) {
      assert(sub_ctx->prog->fs_alpha_func_loc != -1);

       
      if (sub_ctx->dsa_state.alpha.enabled && sub_ctx->surf[0] &&
          !util_format_is_pure_integer(sub_ctx->surf[0]->format))
          glUniform1i(sub_ctx->prog->fs_alpha_func_loc, sub_ctx->dsa_state.alpha.func);
      else
          glUniform1i(sub_ctx->prog->fs_alpha_func_loc, PIPE_FUNC_ALWAYS);

      glUniform1f(sub_ctx->prog->fs_alpha_ref_val_loc, sub_ctx->dsa_state.alpha.ref_value);
   }
}