diff options
author | Samuel Pitoiset <[email protected]> | 2017-05-12 14:15:29 +0200 |
---|---|---|
committer | Samuel Pitoiset <[email protected]> | 2017-06-14 10:04:36 +0200 |
commit | 66a2589d00e38f0d25530ec70274cf42c35e1f9d (patch) | |
tree | 1ec97cf95bce8c3e94948234bc034878b3fd55b1 /src/mesa/state_tracker/st_texture.c | |
parent | b6b915afa45da8e0da3ad315f523051ae1b5d836 (diff) |
st/mesa: add infrastructure for storing bound texture/image handles
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 | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index 7da111f39f3..0f72eb778ad 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -421,6 +421,85 @@ st_create_color_map_texture(struct gl_context *ctx) return pt; } +/** + * Destroy bound texture handles for the given stage. + */ +static void +st_destroy_bound_texture_handles_per_stage(struct st_context *st, + enum pipe_shader_type shader) +{ + struct st_bound_handles *bound_handles = &st->bound_texture_handles[shader]; + struct pipe_context *pipe = st->pipe; + unsigned i; + + if (likely(!bound_handles->num_handles)) + return; + + for (i = 0; i < bound_handles->num_handles; i++) { + uint64_t handle = bound_handles->handles[i]; + + pipe->make_texture_handle_resident(pipe, handle, false); + pipe->delete_texture_handle(pipe, handle); + } + free(bound_handles->handles); + bound_handles->handles = NULL; + bound_handles->num_handles = 0; +} + + +/** + * Destroy all bound texture handles in the context. + */ +void +st_destroy_bound_texture_handles(struct st_context *st) +{ + unsigned i; + + for (i = 0; i < PIPE_SHADER_TYPES; i++) { + st_destroy_bound_texture_handles_per_stage(st, i); + } +} + + +/** + * Destroy bound image handles for the given stage. + */ +static void +st_destroy_bound_image_handles_per_stage(struct st_context *st, + enum pipe_shader_type shader) +{ + struct st_bound_handles *bound_handles = &st->bound_image_handles[shader]; + struct pipe_context *pipe = st->pipe; + unsigned i; + + if (likely(!bound_handles->num_handles)) + return; + + for (i = 0; i < bound_handles->num_handles; i++) { + uint64_t handle = bound_handles->handles[i]; + + pipe->make_image_handle_resident(pipe, handle, GL_READ_WRITE, false); + pipe->delete_image_handle(pipe, handle); + } + free(bound_handles->handles); + bound_handles->handles = NULL; + bound_handles->num_handles = 0; +} + + +/** + * Destroy all bound image handles in the context. + */ +void +st_destroy_bound_image_handles(struct st_context *st) +{ + unsigned i; + + for (i = 0; i < PIPE_SHADER_TYPES; i++) { + st_destroy_bound_image_handles_per_stage(st, i); + } +} + /** * Create a texture handle from a texture unit. |