aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2017-05-12 11:53:51 +0200
committerSamuel Pitoiset <[email protected]>2017-06-14 10:04:36 +0200
commit6f96bd731819c77d4e899adfc2321eeaace80384 (patch)
treef110e120ecb0ce502f1854dc0c132ae194f96833
parent32b4aa34999c756e82d69472c67dbdd01e1f4fb0 (diff)
st/mesa: add st_convert_image_from_unit() helper
Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
-rw-r--r--src/mesa/state_tracker/st_atom_image.c33
-rw-r--r--src/mesa/state_tracker/st_texture.h5
2 files changed, 27 insertions, 11 deletions
diff --git a/src/mesa/state_tracker/st_atom_image.c b/src/mesa/state_tracker/st_atom_image.c
index 381eca191ac..5b914637a2a 100644
--- a/src/mesa/state_tracker/st_atom_image.c
+++ b/src/mesa/state_tracker/st_atom_image.c
@@ -102,6 +102,27 @@ st_convert_image(const struct st_context *st, const struct gl_image_unit *u,
}
}
+/**
+ * Get a pipe_image_view object from an image unit.
+ */
+void
+st_convert_image_from_unit(const struct st_context *st,
+ struct pipe_image_view *img,
+ GLuint imgUnit)
+{
+ struct gl_image_unit *u = &st->ctx->ImageUnits[imgUnit];
+ struct st_texture_object *stObj = st_texture_object(u->TexObj);
+
+ if (!_mesa_is_image_unit_valid(st->ctx, u) ||
+ !st_finalize_texture(st->ctx, st->pipe, u->TexObj, 0) ||
+ !stObj->pt) {
+ memset(img, 0, sizeof(*img));
+ return;
+ }
+
+ st_convert_image(st, u, img);
+}
+
static void
st_bind_images(struct st_context *st, struct gl_program *prog,
enum pipe_shader_type shader_type)
@@ -116,19 +137,9 @@ st_bind_images(struct st_context *st, struct gl_program *prog,
c = &st->ctx->Const.Program[prog->info.stage];
for (i = 0; i < prog->info.num_images; i++) {
- struct gl_image_unit *u =
- &st->ctx->ImageUnits[prog->sh.ImageUnits[i]];
- struct st_texture_object *stObj = st_texture_object(u->TexObj);
struct pipe_image_view *img = &images[i];
- if (!_mesa_is_image_unit_valid(st->ctx, u) ||
- !st_finalize_texture(st->ctx, st->pipe, u->TexObj, 0) ||
- !stObj->pt) {
- memset(img, 0, sizeof(*img));
- continue;
- }
-
- st_convert_image(st, u, img);
+ st_convert_image_from_unit(st, img, prog->sh.ImageUnits[i]);
}
cso_set_shader_images(st->cso_context, shader_type, 0,
prog->info.num_images, images);
diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h
index cd6a73c7703..4bfec0bed27 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -268,6 +268,11 @@ st_convert_image(const struct st_context *st, const struct gl_image_unit *u,
struct pipe_image_view *img);
void
+st_convert_image_from_unit(const struct st_context *st,
+ struct pipe_image_view *img,
+ GLuint imgUnit);
+
+void
st_convert_sampler(const struct st_context *st,
const struct gl_texture_object *texobj,
const struct gl_sampler_object *msamp,