Re: [Mesa-dev] [PATCH 1/4] st/dri: move image extension into the common file

2017-06-28 Thread Emil Velikov
On 9 June 2017 at 01:26, gurchetansi...@chromium.org
 wrote:
> From: Gurchetan Singh 
>
> This image extension is is needed by the Android studio emulator
> when using the host's GLES implementation.
>
> This patch moves the extension code from dri2.c to dri_extensions.c.
> Since some functions in this extension are initialized at runtime by
> dri2.c, we need to expose them in dri_extensions.h.
> ---
>  src/gallium/state_trackers/dri/dri2.c   | 756 ---
>  src/gallium/state_trackers/dri/dri_extensions.c | 770 
> +++-
>  src/gallium/state_trackers/dri/dri_extensions.h |  17 +
>  3 files changed, 784 insertions(+), 759 deletions(-)
>
> diff --git a/src/gallium/state_trackers/dri/dri2.c 
> b/src/gallium/state_trackers/dri/dri2.c

> +/* The extension is modified during runtime if DRI_PRIME is detected */
> +__DRIimageExtension dri2ImageExtension = {
> +.base = { __DRI_IMAGE, 12 },
> +
> +.createImageFromName  = dri2_create_image_from_name,
> +.createImageFromRenderbuffer  = dri2_create_image_from_renderbuffer,
> +.destroyImage = dri2_destroy_image,
> +.createImage  = dri2_create_image,
> +.queryImage   = dri2_query_image,
> +.dupImage = dri2_dup_image,
> +.validateUsage= dri2_validate_usage,
> +.createImageFromNames = dri2_from_names,
> +.fromPlanar   = dri2_from_planar,
> +.createImageFromTexture   = dri2_create_from_texture,
> +.createImageFromFds   = NULL,
> +.createImageFromDmaBufs   = NULL,
> +.blitImage= dri2_blit_image,
> +.getCapabilities  = dri2_get_capabilities,
> +.mapImage = dri2_map_image,
> +.unmapImage   = dri2_unmap_image,
> +};
> +
From the above only .createImageFromNames,
.createImageFromRenderbuffer and .destroyImage are needed for
EGL_KHR_gl_image.

Although a bit strange to keep separate, we don't want to bring
drm_driver.h, drm.h, xf86drm.h and alike when building drisw. I.e. I'd
move only those - be that to dri_extensions.c or other file.

-Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/4] st/dri: move image extension into the common file

2017-06-08 Thread gurchetansi...@chromium.org
From: Gurchetan Singh 

This image extension is is needed by the Android studio emulator
when using the host's GLES implementation.

This patch moves the extension code from dri2.c to dri_extensions.c.
Since some functions in this extension are initialized at runtime by
dri2.c, we need to expose them in dri_extensions.h.
---
 src/gallium/state_trackers/dri/dri2.c   | 756 ---
 src/gallium/state_trackers/dri/dri_extensions.c | 770 +++-
 src/gallium/state_trackers/dri/dri_extensions.h |  17 +
 3 files changed, 784 insertions(+), 759 deletions(-)

diff --git a/src/gallium/state_trackers/dri/dri2.c 
b/src/gallium/state_trackers/dri/dri2.c
index 625678f257..b68d93bdaa 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -35,7 +35,6 @@
 #include "util/u_inlines.h"
 #include "util/u_format.h"
 #include "util/u_debug.h"
-#include "state_tracker/drm_driver.h"
 #include "state_tracker/st_cb_bufferobjects.h"
 #include "state_tracker/st_cb_fbo.h"
 #include "state_tracker/st_cb_texture.h"
@@ -52,126 +51,6 @@
 #include "dri_query_renderer.h"
 #include "dri2_buffer.h"
 
-static int convert_fourcc(int format, int *dri_components_p)
-{
-   int dri_components;
-   switch(format) {
-   case __DRI_IMAGE_FOURCC_RGB565:
-  format = __DRI_IMAGE_FORMAT_RGB565;
-  dri_components = __DRI_IMAGE_COMPONENTS_RGB;
-  break;
-   case __DRI_IMAGE_FOURCC_ARGB:
-  format = __DRI_IMAGE_FORMAT_ARGB;
-  dri_components = __DRI_IMAGE_COMPONENTS_RGBA;
-  break;
-   case __DRI_IMAGE_FOURCC_XRGB:
-  format = __DRI_IMAGE_FORMAT_XRGB;
-  dri_components = __DRI_IMAGE_COMPONENTS_RGB;
-  break;
-   case __DRI_IMAGE_FOURCC_ABGR:
-  format = __DRI_IMAGE_FORMAT_ABGR;
-  dri_components = __DRI_IMAGE_COMPONENTS_RGBA;
-  break;
-   case __DRI_IMAGE_FOURCC_XBGR:
-  format = __DRI_IMAGE_FORMAT_XBGR;
-  dri_components = __DRI_IMAGE_COMPONENTS_RGB;
-  break;
-   case __DRI_IMAGE_FOURCC_R8:
-  format = __DRI_IMAGE_FORMAT_R8;
-  dri_components = __DRI_IMAGE_COMPONENTS_R;
-  break;
-   case __DRI_IMAGE_FOURCC_GR88:
-  format = __DRI_IMAGE_FORMAT_GR88;
-  dri_components = __DRI_IMAGE_COMPONENTS_RG;
-  break;
-   /*
-* For multi-planar YUV formats, we return the format of the first
-* plane only.  Since there is only one caller which supports multi-
-* planar YUV it gets to figure out the remaining planes on it's
-* own.
-*/
-   case __DRI_IMAGE_FOURCC_YUV420:
-   case __DRI_IMAGE_FOURCC_YVU420:
-  format = __DRI_IMAGE_FORMAT_R8;
-  dri_components = __DRI_IMAGE_COMPONENTS_Y_U_V;
-  break;
-   case __DRI_IMAGE_FOURCC_NV12:
-  format = __DRI_IMAGE_FORMAT_R8;
-  dri_components = __DRI_IMAGE_COMPONENTS_Y_UV;
-  break;
-   default:
-  return -1;
-   }
-   *dri_components_p = dri_components;
-   return format;
-}
-
-/* NOTE this probably isn't going to do the right thing for YUV images
- * (but I think the same can be said for intel_query_image()).  I think
- * only needed for exporting dmabuf's, so I think I won't loose much
- * sleep over it.
- */
-static int convert_to_fourcc(int format)
-{
-   switch(format) {
-   case __DRI_IMAGE_FORMAT_RGB565:
-  format = __DRI_IMAGE_FOURCC_RGB565;
-  break;
-   case __DRI_IMAGE_FORMAT_ARGB:
-  format = __DRI_IMAGE_FOURCC_ARGB;
-  break;
-   case __DRI_IMAGE_FORMAT_XRGB:
-  format = __DRI_IMAGE_FOURCC_XRGB;
-  break;
-   case __DRI_IMAGE_FORMAT_ABGR:
-  format = __DRI_IMAGE_FOURCC_ABGR;
-  break;
-   case __DRI_IMAGE_FORMAT_XBGR:
-  format = __DRI_IMAGE_FOURCC_XBGR;
-  break;
-   case __DRI_IMAGE_FORMAT_R8:
-  format = __DRI_IMAGE_FOURCC_R8;
-  break;
-   case __DRI_IMAGE_FORMAT_GR88:
-  format = __DRI_IMAGE_FOURCC_GR88;
-  break;
-   default:
-  return -1;
-   }
-   return format;
-}
-
-static enum pipe_format dri2_format_to_pipe_format (int format)
-{
-   enum pipe_format pf;
-
-   switch (format) {
-   case __DRI_IMAGE_FORMAT_RGB565:
-  pf = PIPE_FORMAT_B5G6R5_UNORM;
-  break;
-   case __DRI_IMAGE_FORMAT_XRGB:
-  pf = PIPE_FORMAT_BGRX_UNORM;
-  break;
-   case __DRI_IMAGE_FORMAT_ARGB:
-  pf = PIPE_FORMAT_BGRA_UNORM;
-  break;
-   case __DRI_IMAGE_FORMAT_ABGR:
-  pf = PIPE_FORMAT_RGBA_UNORM;
-  break;
-   case __DRI_IMAGE_FORMAT_R8:
-  pf = PIPE_FORMAT_R8_UNORM;
-  break;
-   case __DRI_IMAGE_FORMAT_GR88:
-  pf = PIPE_FORMAT_RG88_UNORM;
-  break;
-   default:
-  pf = PIPE_FORMAT_NONE;
-  break;
-   }
-
-   return pf;
-}
-
 /**
  * DRI2 flush extension.
  */
@@ -780,641 +659,6 @@ dri2_lookup_egl_image(struct dri_screen *screen, void 
*handle)
return img;
 }
 
-static __DRIimage *
-dri2_create_image_from_winsys(__DRIscreen *_screen,
-  int width, int