static void vrend_hw_set_color_surface(struct vrend_sub_context *sub_ctx, int index)
{
   struct vrend_surface *surf = sub_ctx->surf[index];

   if (!surf) {
      GLenum attachment = GL_COLOR_ATTACHMENT0 + index;

      glFramebufferTexture2D(GL_FRAMEBUFFER, attachment,
                             GL_TEXTURE_2D, 0, 0);
   } else {
      uint32_t first_layer = sub_ctx->surf[index]->val1 & 0xffff;
      uint32_t last_layer = (sub_ctx->surf[index]->val1 >> 16) & 0xffff;

      vrend_fb_bind_texture_id(surf->texture, surf->id, index, surf->val0,
                               first_layer != last_layer ? 0xffffffff : first_layer,
                               surf->nr_samples);
   }
}
static void vrend_hw_set_color_surface(struct vrend_sub_context *sub_ctx, int index)
{
   struct vrend_surface *surf = sub_ctx->surf[index];

   if (!surf) {
      GLenum attachment = GL_COLOR_ATTACHMENT0 + index;

      glFramebufferTexture2D(GL_FRAMEBUFFER, attachment,
                             GL_TEXTURE_2D, 0, 0);
   } else {
      uint32_t first_layer = sub_ctx->surf[index]->val1 & 0xffff;
      uint32_t last_layer = (sub_ctx->surf[index]->val1 >> 16) & 0xffff;

      vrend_fb_bind_texture_id(surf->texture, surf->id, index, surf->val0,
                               first_layer != last_layer ? 0xffffffff : first_layer,
                               surf->nr_samples);
   }
}