diff options
author | Samuel Pitoiset <[email protected]> | 2017-05-09 14:32:06 +0200 |
---|---|---|
committer | Samuel Pitoiset <[email protected]> | 2017-06-14 10:04:36 +0200 |
commit | b6b915afa45da8e0da3ad315f523051ae1b5d836 (patch) | |
tree | 72e33196509f26f55da816c4d9ea6be66f998f61 /src/mesa/state_tracker/st_texture.c | |
parent | 6f96bd731819c77d4e899adfc2321eeaace80384 (diff) |
st/mesa: add st_create_{texture,image}_handle_from_unit() helper
Signed-off-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Nicolai Hähnle <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker/st_texture.c')
-rw-r--r-- | src/mesa/state_tracker/st_texture.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index 2e9856dcdfd..7da111f39f3 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -420,3 +420,44 @@ st_create_color_map_texture(struct gl_context *ctx) texSize, texSize, 1, 1, 0, PIPE_BIND_SAMPLER_VIEW); return pt; } + + +/** + * 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 gl_context *ctx = st->ctx; + struct gl_texture_object *texObj; + struct pipe_context *pipe = st->pipe; + struct pipe_sampler_view *view; + struct pipe_sampler_state sampler; + + if (!st_update_single_texture(st, &view, texUnit, prog->sh.data->Version)) + return 0; + + st_convert_sampler_from_unit(st, &sampler, texUnit); + + texObj = ctx->Texture.Unit[texUnit]._Current; + assert(texObj); + + 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); + + return pipe->create_image_handle(pipe, &img); +} |