[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mesa3d-users
Subject:    [Mesa-users] Trying to put pixmap support in Native_fbdev.c
From:       Vivek Singh <vivek.siwan () gmail ! com>
Date:       2011-09-23 10:29:21
Message-ID: CAJrcCc0UFEzKZY_f5oNU=RyyvwYy52bdPeR-T30e8KRWDCZK+Q () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hello All

   I am using Mesa-7.10.2 stack.

I am trying to run EGL with egl_gallium state trackers
(GLES=>EGL=>egl_gallium=>fbdev) over fbdev with following

configuration


./configure --prefix=/opt/mesa-arm-genoa-new --host=arm-linux
--build=i686-linux --enable-gles2 --with-x=no

--with-egl-platforms=fbdev  --with-egl-displays=fbdev --with-driver=no
--disable-glu --disable-glw --disable-glut

--disable-gl-osmesa --disable-opengl --enable-debug --enable-gles-overlay

I am able to run applications which can draw directly on scanout
surfaces/pbuffer (es2gears).

I want to run application which uses eglCreateImageKHR (with user defined
pixmap structures) to make textures
and eglCreatePixmapSurface (with user defined pixmap structures) to create a
Pixmap surfaces. Since Native_fbdev.c doesnot

support pixmap surfaces both calls fail.
       I tried to put pixmap support in native_fbdev.c with following steps
1)putting a function in
 fbdpy->base.destroy = fbdev_display_destroy;
 fbdpy->base.get_param = fbdev_display_get_param;
 fbdpy->base.get_configs = fbdev_display_get_configs;

 /*Adding function to create PIXMAP surface*/
 fbdpy->base.is_pixmap_supported = fbdev_display_is_pixmap_supported;
 fbdpy->base.create_pixmap_surface = fbdev_display_create_pixmap_surface;

2)Added support flag true in native_config
  pixmap_bit=true;

I am able to get finctions  eglCreateImageKHR/eglCreatePixmapSurface run
successfully able to get user defined pixmap
to native_fbdev by typecasting it ot EGLNativePixmaptype. But I am not able
to draw any texture on EGLImage. I suspect
glEGLImageTargetTexture2DOES is not working properly with EGLImage returned
from eglCreateImageKHR.

I dont know how I can make it visible to GLES by calling function like
glEGLImageTargetTexture2DOES.

I am very new to GLES and EGL . Please provide me suggestions so that I can
proceed further.

For convenient i am putting my code which I have inserted to native_fbdev.c

static struct native_surface *
fbdev_display_create_pixmap_surface(struct native_display *ndpy,
                                     EGLNativePixmapType pix,
                                     const struct native_config *nconf)
{
   printf("START %s    %s\n", __FUNCTION__, __FILE__);
   fbdev_pixmap  *pixmap = (fbdev_pixmap *)pix;
   /*Trying To print pixmap detail*/

   printf("pixmap->height                 ::%d\n", pixmap->height);
   printf("pixmap->width                  ::%d\n",  pixmap->width);
   printf("pixmap->bytes_per_pixel        ::%d\n", pixmap->bytes_per_pixel);
   printf("pixmap->buffer_size            ::%d\n",  pixmap->buffer_size);
   printf("pixmap->red_size               ::%d\n", pixmap->red_size);
   printf("pixmap->green_size             ::%d\n",  pixmap->green_size);
   printf("pixmap->red_size               ::%d\n", pixmap->blue_size);
   printf("pixmap->alpha_size             ::%d\n",  pixmap->alpha_size);
   printf("pixmap->luminance_size         ::%d\n", pixmap->luminance_size);
   printf("pixmap->flags                  ::%d\n",  pixmap->flags);
   printf("pixmap->data              ::%p\n",   pixmap->data);

   struct fbdev_display *fbdpy = fbdev_display(ndpy);
   struct fbdev_surface *fbsurf;
   fbsurf = CALLOC_STRUCT(fbdev_surface);
   if (!fbsurf)
      return NULL;
   fbsurf->fbdpy = fbdpy;
   fbsurf->width = pixmap->width;
   fbsurf->height =  pixmap->height;
   fbsurf->type = FBDEV_SURFACE_TYPE_PIXMAP;
   fbsurf->pixmap = pix;
   fbsurf->rsurf = resource_surface_create(fbdpy->base.screen,
         nconf->color_format,
         PIPE_BIND_RENDER_TARGET |
         PIPE_BIND_DISPLAY_TARGET |  PIPE_BIND_SCANOUT );

   if (!fbsurf->rsurf) {
      FREE(fbsurf);
      return NULL;
   }

   resource_surface_set_size(fbsurf->rsurf, fbsurf->width, fbsurf->height);

   fbsurf->base.destroy = fbdev_surface_destroy;
   fbsurf->base.present = fbdev_surface_present;
   fbsurf->base.validate = fbdev_surface_validate;
   fbsurf->base.wait = fbdev_surface_wait;

   printf("END %s    %s\n", __FUNCTION__, __FILE__);
   return &fbsurf->base;

}

static struct native_display *
fbdev_display_create(int fd, struct native_event_handler *event_handler,
                     void *user_data)
{
   struct fbdev_display *fbdpy;

   fbdpy = CALLOC_STRUCT(fbdev_display);
   if (!fbdpy)
      return NULL;

   fbdpy->fd = fd;
   fbdpy->event_handler = event_handler;
   fbdpy->base.user_data = user_data;

   if (!fbdev_display_init(&fbdpy->base)) {
      FREE(fbdpy);
      return NULL;
   }

   fbdpy->base.destroy = fbdev_display_destroy;
   fbdpy->base.get_param = fbdev_display_get_param;
   fbdpy->base.get_configs = fbdev_display_get_configs;

   /*Vivek:: Adding function to create PIXMAP surface*/
    fbdpy->base.is_pixmap_supported = fbdev_display_is_pixmap_supported;
    fbdpy->base.create_pixmap_surface = fbdev_display_create_pixmap_surface;

    fbdpy->base.modeset = &fbdev_display_modeset;

   return &fbdpy->base;
}

static boolean
fbdev_display_is_pixmap_supported(struct native_display *ndpy,
                                   EGLNativePixmapType pix,
                                   const struct native_config *nconf)
{
   printf("START   %s     %s\n", __FUNCTION__, __FILE__);
   struct fbdev_display *fdpy = fbdev_display(ndpy);
   enum pipe_format fmt;
   uint depth;
   depth =  32; //hard coded for 4bpp
   switch (depth) {
   case 32:
      fmt = PIPE_FORMAT_B8G8R8A8_UNORM;
      break;
   case 24:
      fmt = PIPE_FORMAT_B8G8R8X8_UNORM;
      break;
   case 16:
      fmt = PIPE_FORMAT_B5G6R5_UNORM;
      break;
   default:
      fmt = PIPE_FORMAT_NONE;
      break;
   }

   return (fmt == nconf->color_format);
}

static boolean
fbdev_surface_flush_frontbuffer(struct native_surface *nsurf)
{
  printf("%s    %s\n", __FUNCTION__, __FILE__);
  struct fbdev_surface *fbsurf = fbdev_surface(nsurf);

   if (!fbsurf->is_current)
      return TRUE;

   if(fbsurf->type == FBDEV_SURFACE_TYPE_PIXMAP)   //Vivek
        {

           return resource_surface_present(fbsurf->rsurf,
NATIVE_ATTACHMENT_FRONT_LEFT, fbsurf->pixmap);
        }
   else
        {
           return resource_surface_present(fbsurf->rsurf,
NATIVE_ATTACHMENT_FRONT_LEFT, NULL);
        }

}


Regards
Vivek

[Attachment #5 (text/html)]

<div><br></div><div>Hello All</div><div>   </div><div>   I am using Mesa-7.10.2 \
stack. </div><div><br></div><div>I am trying to run EGL with egl_gallium state \
trackers (GLES=&gt;EGL=&gt;egl_gallium=&gt;fbdev) over fbdev with following </div> \
<div><br></div><div>configuration</div><div><br></div><div><br></div><div>./configure \
--prefix=/opt/mesa-arm-genoa-new --host=arm-linux --build=i686-linux --enable-gles2 \
--with-x=no </div><div><br></div><div>--with-egl-platforms=fbdev  \
--with-egl-displays=fbdev --with-driver=no   --disable-glu --disable-glw \
--disable-glut </div> <div><br></div><div>--disable-gl-osmesa --disable-opengl \
--enable-debug --enable-gles-overlay</div><div><br></div><div>I am able to run \
applications which can draw directly on scanout surfaces/pbuffer \
(es2gears).</div><div> <br></div><div>I want to run application which uses \
eglCreateImageKHR (with user defined pixmap structures) to make \
textures</div><div>and eglCreatePixmapSurface (with user defined pixmap structures) \
to create a Pixmap surfaces. Since Native_fbdev.c doesnot </div> \
<div><br></div><div>support pixmap surfaces both calls fail.</div><div>       I tried \
to put pixmap support in native_fbdev.c with following steps</div><div>1)putting a \
function in  </div><div> fbdpy-&gt;base.destroy = fbdev_display_destroy;</div> <div> \
fbdpy-&gt;base.get_param = fbdev_display_get_param;</div><div> \
fbdpy-&gt;base.get_configs = fbdev_display_get_configs;</div><div><br></div><div> \
/*Adding function to create PIXMAP surface*/</div><div> \
fbdpy-&gt;base.is_pixmap_supported = fbdev_display_is_pixmap_supported;</div> <div> \
fbdpy-&gt;base.create_pixmap_surface = \
fbdev_display_create_pixmap_surface;</div><div><br></div><div>2)Added support flag \
true in native_config</div><div>  pixmap_bit=true;</div><div><br></div><div>I am able \
to get finctions  eglCreateImageKHR/eglCreatePixmapSurface run successfully able to \
get user defined pixmap </div> <div>to native_fbdev by typecasting it ot \
EGLNativePixmaptype. But I am not able to draw any texture on EGLImage. I suspect     \
</div><div>glEGLImageTargetTexture2DOES is not working properly with EGLImage \
returned from eglCreateImageKHR.</div> <div><br></div><div>I dont know how I can make \
it visible to GLES by calling function like \
glEGLImageTargetTexture2DOES.</div><div><br></div><div>I am very new to GLES and EGL \
. Please provide me suggestions so that I can proceed further.</div> \
<div><br></div><div>For convenient i am putting my code which I have inserted to \
native_fbdev.c</div><div><br></div><div>static struct native_surface \
*</div><div>fbdev_display_create_pixmap_surface(struct native_display *ndpy,</div> \
<div>                                     EGLNativePixmapType pix,</div><div>         \
const struct native_config *nconf)</div><div>{</div><div>   printf(&quot;START %s    \
%s\n&quot;, __FUNCTION__, __FILE__);</div> <div>   fbdev_pixmap  *pixmap = \
(fbdev_pixmap *)pix;</div><div>   /*Trying To print pixmap \
detail*/</div><div><br></div><div>   printf(&quot;pixmap-&gt;height                 \
::%d\n&quot;, pixmap-&gt;height);</div><div>   printf(&quot;pixmap-&gt;width          \
::%d\n&quot;,  pixmap-&gt;width);</div> <div>   \
printf(&quot;pixmap-&gt;bytes_per_pixel        ::%d\n&quot;, \
pixmap-&gt;bytes_per_pixel);</div><div>   printf(&quot;pixmap-&gt;buffer_size         \
::%d\n&quot;,  pixmap-&gt;buffer_size);</div><div>   printf(&quot;pixmap-&gt;red_size \
::%d\n&quot;, pixmap-&gt;red_size);</div> <div>   printf(&quot;pixmap-&gt;green_size  \
::%d\n&quot;,  pixmap-&gt;green_size);</div><div>   printf(&quot;pixmap-&gt;red_size  \
::%d\n&quot;, pixmap-&gt;blue_size);</div><div>   printf(&quot;pixmap-&gt;alpha_size  \
::%d\n&quot;,  pixmap-&gt;alpha_size);</div> <div>   \
printf(&quot;pixmap-&gt;luminance_size         ::%d\n&quot;, \
pixmap-&gt;luminance_size);</div><div>   printf(&quot;pixmap-&gt;flags                \
::%d\n&quot;,  pixmap-&gt;flags);</div><div>   printf(&quot;pixmap-&gt;data           \
::%p\n&quot;,   pixmap-&gt;data);</div> <div><br></div><div>   struct fbdev_display \
*fbdpy = fbdev_display(ndpy);</div><div>   struct fbdev_surface *fbsurf;</div><div>   \
fbsurf = CALLOC_STRUCT(fbdev_surface);</div><div>   if (!fbsurf)</div><div>      \
return NULL;</div> <div>   fbsurf-&gt;fbdpy = fbdpy;</div><div>   fbsurf-&gt;width = \
pixmap-&gt;width;</div><div>   fbsurf-&gt;height =  pixmap-&gt;height;</div><div>   \
fbsurf-&gt;type = FBDEV_SURFACE_TYPE_PIXMAP;</div><div>   fbsurf-&gt;pixmap = \
pix;</div> <div>   fbsurf-&gt;rsurf = \
resource_surface_create(fbdpy-&gt;base.screen,</div><div>         \
nconf-&gt;color_format,</div><div>         PIPE_BIND_RENDER_TARGET |</div><div>       \
PIPE_BIND_DISPLAY_TARGET |  PIPE_BIND_SCANOUT );</div> <div><br></div><div>   if \
(!fbsurf-&gt;rsurf) {</div><div>      FREE(fbsurf);</div><div>      return \
NULL;</div><div>   }</div><div><br></div><div>   \
resource_surface_set_size(fbsurf-&gt;rsurf, fbsurf-&gt;width, \
fbsurf-&gt;height);</div> <div><br></div><div>   fbsurf-&gt;base.destroy = \
fbdev_surface_destroy;</div><div>   fbsurf-&gt;base.present = \
fbdev_surface_present;</div><div>   fbsurf-&gt;base.validate = \
fbdev_surface_validate;</div><div>   fbsurf-&gt;base.wait = fbdev_surface_wait;</div> \
<div><br></div><div>   printf(&quot;END %s    %s\n&quot;, __FUNCTION__, \
__FILE__);</div><div>   return \
&amp;fbsurf-&gt;base;</div><div><br></div><div>}</div><div><br></div><div>static \
struct native_display *</div><div>fbdev_display_create(int fd, struct \
native_event_handler *event_handler,</div> <div>                     void \
*user_data)</div><div>{</div><div>   struct fbdev_display \
*fbdpy;</div><div><br></div><div>   fbdpy = CALLOC_STRUCT(fbdev_display);</div><div>  \
if (!fbdpy)</div><div>      return NULL;</div> <div><br></div><div>   fbdpy-&gt;fd = \
fd;</div><div>   fbdpy-&gt;event_handler = event_handler;</div><div>   \
fbdpy-&gt;base.user_data = user_data;</div><div><br></div><div>   if \
(!fbdev_display_init(&amp;fbdpy-&gt;base)) {</div> <div>      FREE(fbdpy);</div><div> \
return NULL;</div><div>   }</div><div><br></div><div>   fbdpy-&gt;base.destroy = \
fbdev_display_destroy;</div><div>   fbdpy-&gt;base.get_param = \
fbdev_display_get_param;</div><div>   fbdpy-&gt;base.get_configs = \
fbdev_display_get_configs;</div> <div><br></div><div>   /*Vivek:: Adding function to \
create PIXMAP surface*/</div><div>    fbdpy-&gt;base.is_pixmap_supported = \
fbdev_display_is_pixmap_supported;</div><div>    fbdpy-&gt;base.create_pixmap_surface \
= fbdev_display_create_pixmap_surface;</div> <div><br></div><div>    \
fbdpy-&gt;base.modeset = &amp;fbdev_display_modeset;</div><div><br></div><div>   \
return &amp;fbdpy-&gt;base;</div><div>}</div><div><br></div><div>static \
boolean</div><div>fbdev_display_is_pixmap_supported(struct native_display \
*ndpy,</div> <div>                                   EGLNativePixmapType \
pix,</div><div>                                   const struct native_config \
*nconf)</div><div>{</div><div>   printf(&quot;START   %s     %s\n&quot;, \
__FUNCTION__, __FILE__);</div> <div>   struct fbdev_display *fdpy = \
fbdev_display(ndpy);</div><div>   enum pipe_format fmt;</div><div>   uint \
depth;</div><div>   depth =  32; //hard coded for 4bpp</div><div>   switch (depth) \
{</div><div>   case 32:</div> <div>      fmt = PIPE_FORMAT_B8G8R8A8_UNORM;</div><div> \
break;</div><div>   case 24:</div><div>      fmt = \
PIPE_FORMAT_B8G8R8X8_UNORM;</div><div>      break;</div><div>   case 16:</div><div>   \
fmt = PIPE_FORMAT_B5G6R5_UNORM;</div> <div>      break;</div><div>   \
default:</div><div>      fmt = PIPE_FORMAT_NONE;</div><div>      break;</div><div>   \
}</div><div><br></div><div>   return (fmt == \
nconf-&gt;color_format);</div><div>}</div><div><br></div><div> static \
boolean</div><div>fbdev_surface_flush_frontbuffer(struct native_surface \
*nsurf)</div><div>{</div><div>  printf(&quot;%s    %s\n&quot;, __FUNCTION__, \
__FILE__);</div><div>  struct fbdev_surface *fbsurf = fbdev_surface(nsurf);</div> \
<div><br></div><div>   if (!fbsurf-&gt;is_current)</div><div>      return \
TRUE;</div><div><br></div><div>   if(fbsurf-&gt;type == FBDEV_SURFACE_TYPE_PIXMAP)   \
//Vivek</div><div>        {</div><div>           </div><div>           return \
resource_surface_present(fbsurf-&gt;rsurf, NATIVE_ATTACHMENT_FRONT_LEFT, \
fbsurf-&gt;pixmap);</div> <div>        }</div><div>   else</div><div>        \
{</div><div>           return resource_surface_present(fbsurf-&gt;rsurf, \
NATIVE_ATTACHMENT_FRONT_LEFT, NULL);</div><div>        \
}</div><div><br></div><div>}</div><div><br> \
</div><div><br></div><div>Regards</div><div>Vivek</div><div><br></div><div>   \
</div><div><br></div>



_______________________________________________
mesa-users mailing list
mesa-users@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-users


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic