[Mesa-dev] ARB_copy_image support in Gallium
Ilia Mirkin
imirkin at alum.mit.edu
Mon Jul 20 12:19:53 PDT 2015
On Mon, Jul 20, 2015 at 2:44 PM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> Hi Brian,
>
> You marked off ARB_copy_image (and ARB_clear_texture) as in-progress
> by VMware some months ago -- has there been any movement on that? It
> appears that Bioshock Infinite requires ARB_copy_image so might be
> nice to get that added in.
>
> The complication in implementing ARB_copy_image was that st/mesa will
> pick potentially different PIPE_FORMAT enums for the same internal
> format, depending on the parameters to the glTexImage call. A
> developer (irc handle Leftmost, I forget his real name, sorry) tried
> to wrestle with the issues this presents, but as I recall ended up
> coming up short.
>
> The final implementation probably needs some combination of
> resource_copy_region and blit. I think resource_copy_region currently
> is spec'd to require identical formats in src and dst, but that could
> be relaxed.
>
> Anyways, would be interested in hearing whether you guys have made any
> progress, or if you had thoughts on proper implementation.
>
> Cheers,
>
> -ilia
As an aside, here's a very naive implementation of the ext, which
fails for lots of reasons not the least of which is that we default to
BGRA instead of RGBA. Perhaps we could create a resource_copy_region
version that also takes (or knows about) swizzles... that should also
cover many (all?) of the situations I think.
-ilia
diff --git a/src/mesa/state_tracker/st_cb_texture.c
b/src/mesa/state_tracker/st_cb_texture.c
index 7ea3846..b6b0081 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -1864,6 +1864,28 @@ st_TextureView(struct gl_context *ctx,
return GL_TRUE;
}
+static void
+st_CopyImageSubData(struct gl_context *ctx,
+ struct gl_texture_image *src_image,
+ int src_x, int src_y, int src_z,
+ struct gl_texture_image *dst_image,
+ int dst_x, int dst_y, int dst_z,
+ int src_width, int src_height)
+{
+ struct st_context *st = st_context(ctx);
+ struct pipe_context *pipe = st->pipe;
+ struct st_texture_image *src = st_texture_image(src_image);
+ struct st_texture_image *dst = st_texture_image(dst_image);
+
+ struct pipe_box box;
+
+ u_box_2d_zslice(src_x, src_y, src_z, src_width, src_height, &box);
+ pipe->resource_copy_region(pipe, dst->pt, dst_image->Level,
+ dst_x, dst_y, dst_z,
+ src->pt, src_image->Level,
+ &box);
+}
+
void
st_init_texture_functions(struct dd_function_table *functions)
@@ -1896,4 +1918,6 @@ st_init_texture_functions(struct
dd_function_table *functions)
functions->AllocTextureStorage = st_AllocTextureStorage;
functions->TextureView = st_TextureView;
+
+ functions->CopyImageSubData = st_CopyImageSubData;
}
diff --git a/src/mesa/state_tracker/st_extensions.c
b/src/mesa/state_tracker/st_extensions.c
index b1057f3..9bff7b4 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -589,6 +589,7 @@ void st_init_extensions(struct pipe_screen *screen,
* Extensions that are supported by all Gallium drivers:
*/
extensions->ARB_ES2_compatibility = GL_TRUE;
+ extensions->ARB_copy_image = GL_TRUE;
extensions->ARB_draw_elements_base_vertex = GL_TRUE;
extensions->ARB_explicit_attrib_location = GL_TRUE;
extensions->ARB_explicit_uniform_location = GL_TRUE;
More information about the mesa-dev
mailing list