+ * Create a texture handle from a texture unit.
+ */
+static GLuint64
+st_create_texture_handle_from_unit(struct st_context *st,
+ struct gl_program *prog, GLuint texUnit)
+{
+ struct pipe_context *pipe = st->pipe;
+ struct pipe_sampler_view *view;
+ struct pipe_sampler_state sampler = {0};
+
+ /* TODO: Clarify the interaction of ARB_bindless_texture and EXT_texture_sRGB_decode */
+ st_update_single_texture(st, &view, texUnit, prog->sh.data->Version >= 130, true);
+ if (!view)
+ return 0;
+
+ if (view->target != PIPE_BUFFER)
+ st_convert_sampler_from_unit(st, &sampler, texUnit);
+
+ assert(st->ctx->Texture.Unit[texUnit]._Current);
+
+ return pipe->create_texture_handle(pipe, view, &sampler);
+}
+
+
+/**
+ * Create an image handle from an image unit.
+ */
+static GLuint64
+st_create_image_handle_from_unit(struct st_context *st,
+ struct gl_program *prog, GLuint imgUnit)
+{
+ struct pipe_context *pipe = st->pipe;
+ struct pipe_image_view img;
+
+ st_convert_image_from_unit(st, &img, imgUnit, GL_READ_WRITE);
+
+ return pipe->create_image_handle(pipe, &img);
+}
+
+
+/**
+ * Make all bindless samplers bound to texture units resident in the context.