<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:'times new roman', 'new york', times, serif;font-size:12pt"><div style="color: black; font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">Hi Jerome,</div><div style="color: black; font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><span class="Apple-tab-span" style="white-space:pre">        </span>i understand your point,i agree i have registered the pointer for function "<b>dri2_get_buffers_flip</b>" during initialization, and it is called from eglMakeCurrent( ) just after the eglCreateWindowSurface(), as you said. the implementation of get_buffers is as below.</div><div style="color: black; font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br></div><div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">static __DRIbuffer
*</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><b>dri2_get_buffers_flip</b>(__DRIdrawable * driDrawable,i</font><span class="Apple-style-span" style="font-family: 'times new roman', 'new york', times, serif; ">nt *width, int *height,u</span><span class="Apple-style-span" style="font-family: 'times new roman', 'new york', times, serif; ">nsigned int *attachments, int count,</span></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">                </span>int *out_count, void *loaderPrivate)</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">{</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>struct dri2_egl_surface *dri2_surf = loaderPrivate;</font></div><div><font
class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>struct dri2_egl_display *dri2_dpy =</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>dri2_egl_display(dri2_surf->base.Resource.Display);</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>/*T_DispMan_Surface*/T_LP_DispMan_Surface *flipSurf = NULL; // private windowing system.</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>int cdi_surface_width, cdi_surface_height,i,ret,fd = -1;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span
class="Apple-tab-span" style="white-space:pre">        </span>struct drm_i915_gem_create create;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>struct drm_gem_flink flink;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>struct drm_gem_open open;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>_eglLog(_EGL_INFO, "This is not the right way of implementing, hack is </font><span class="Apple-style-span" style="font-family: 'times new roman', 'new york', times, serif; ">done by looking out X11
values.\n");</span></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>flipSurf = DispMan_Surface_FromId(2);</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>if (NULL == flipSurf){</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">                </span>printf("~~~~~~~~~~~~ Getting Surface from Dispman Error </font><span class="Apple-style-span" style="font-family: 'times new roman', 'new york', times, serif; ">~~~~~~~~~~~~\n");</span></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span
class="Apple-tab-span" style="white-space:pre">                </span>return NULL;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>}</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>DispMan_Surface_GetDimension(dri2_dpy->flip_info.flipSurf, </font><span class="Apple-style-span" style="font-family: 'times new roman', 'new york', times, serif; ">&cdi_surface_width, &cdi_surface_height); // Private API</span></div><div><span class="Apple-style-span" style="font-family: 'times new roman', 'new york', times, serif; "><span class="Apple-tab-span" style="white-space:pre">        </span></span><span class="Apple-style-span" style="font-family: 'times new roman', 'new york', times, serif; ">dri2_surf->base.Width = *width =
cdi_surface_width;</span></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>dri2_surf->base.Height = *height = cdi_surface_height;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>dri2_surf->buffer_count = 1;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>dri2_surf->have_fake_front = 1;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>memset(&create , 0 , sizeof(create));</font></div><div><font
class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>create.size = 2*1024 *1024; </font><span class="Apple-style-span" style="font-family: 'times new roman', 'new york', times, serif; ">// this values are hard coded aftre looking out the X11 Flow.</span></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>ret = ioctl(dri2_dpy->fd,DRM_IOCTL_I915_GEM_CREATE,&create);</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>assert(ret == 0);</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span
class="Apple-tab-span" style="white-space:pre">        </span>flink.handle = create.handle;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>ret = ioctl(dri2_dpy->fd, DRM_IOCTL_GEM_FLINK,&flink);</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>assert(ret == 0);</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>open.name = flink.name;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>ret =
ioctl(dri2_dpy->fd,DRM_IOCTL_GEM_OPEN,&open);</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>assert(ret == 0);</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>assert(open.handle != 0);</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><span class="Apple-style-span" style="font-family: 'times new roman', 'new york', times, serif; "><span class="Apple-tab-span" style="white-space:pre">        </span></span><span class="Apple-style-span" style="font-family: 'times new roman', 'new york', times, serif; ">dri2_surf->buffers[0].attachment = 7; // this values are hard coded aftre looking out the X11 Flow.</span></div><div><font class="Apple-style-span"
face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>dri2_surf->buffers[0].name = open.name;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>dri2_surf->buffers[0].pitch = 3072; </font><span class="Apple-style-span" style="font-family: 'times new roman', 'new york', times, serif; ">// this values are hard coded aftre looking out the X11 Flow.</span></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>dri2_surf->buffers[0].cpp = 4; </font><span class="Apple-style-span" style="font-family: 'times new roman', 'new york', times, serif; ">// this values are hard coded aftre looking out the X11 Flow.</span></div><div><font class="Apple-style-span" face="'times new roman',
'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>dri2_surf->buffers[0].flags = 0; </font><span class="Apple-style-span" style="font-family: 'times new roman', 'new york', times, serif; ">// this values are hard coded aftre looking out the X11 Flow.</span></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>*out_count = 1;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>return dri2_surf->buffers;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">}</font></div></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">here i am not getting what is the handle to drm buffer you are recommending. may be you mean after
this call, the call to "<b>intel_bo_gem_create_from_name</b>" from the function "<b>intel_region_alloc_for_handle</b>" in the file <b>intel_region.c</b> returns the buffer of type "<b>struct _drm_intel_bo</b>". i compared this structure with X11 there is no discrepancy between both.</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">Another thing is, I can query pointer to onscreen window. To my windowing system using the call "<b>DispMan_Surface_GetPixmapAdr( )</b>" My idea is to do memcpy to this retrieved pointer from the pointer to FAKE_FRONT_LEFT</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">like this </font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">memcpy(
*</font><span class="Apple-style-span" style="font-family: 'times new roman', 'new york', times, serif; "><b>DispMan_Surface_GetPixmapAdr(), * FAKE_FRONT_LEFT, size</b></span><span class="Apple-style-span" style="font-family: 'times new roman', 'new york', times, serif; ">) ;</span></div><div><span class="Apple-style-span" style="font-family: 'times new roman', 'new york', times, serif; "><br></span></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">for this obviously i need to derive some how the pointer, from the drm handle as you suggested.</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">i am not clear that i conveyed you properly, please write me for more details.</font></div><div><font class="Apple-style-span" face="'times new roman',
'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">Thank you very much.</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">Regards,</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">Srini.</font></div><div></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; color: black; "><div style="font-family:arial, helvetica, sans-serif;font-size:13px"><font size="2" face="Tahoma"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Jerome Glisse <j.glisse@gmail.com><br><b><span style="font-weight: bold;">To:</span></b> Srini
<srini_rajini@yahoo.com><br><b><span style="font-weight: bold;">Cc:</span></b> mesa-dev@lists.freedesktop.org<br><b><span style="font-weight: bold;">Sent:</span></b> Wed, 30 March, 2011 7:18:28 PM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [Mesa-dev] decoupling XCB from Mesa<br></font><br>On Wed, Mar 30, 2011 at 2:30 AM, Srini <<a ymailto="mailto:srini_rajini@yahoo.com" href="mailto:srini_rajini@yahoo.com">srini_rajini@yahoo.com</a>> wrote:<br>> Hi Jerome,<br>><br>> Thanks for Reply, what you said is right for my attempt on software<br>> acceleration. I added a folder called "flip" in<br>> mesa/src/gallium/state_tracker/egl/ and created the egl software driver<br>> called "egl_flip_swrast.so" its working fine.<br>><br>> My current attempt is to enable the hardware acceleration, I choose<br>> Mesa-7.9,and the configuration i used is<br>><br>> "./configure --enable-gles2
--enable-egl --with-egl-platforms=x11<br>> --with-dri-drivers=i965 --with-state-trackers=egl,dri --disable-gallium<br>> --disable-glw"<br>><br>> This configuration totally disable the gallium driver this means I am using<br>> Classic mesa driver, I used the small GLES application to read the flow of<br>> the Hardware rendering path, accordingly I mocked the entire flow for my<br>> windowing system by faking the egl_dri2.c file, where actually the<br>> initialization for x11 and drm are happening, I added the new API<br>> "dri2_initialize_flip".<br>><br>> The difference between dri2_initialize_flip and dri2_initialize_x11 is, all<br>> the calls to XCB are removed, and rather I am using my local library by this<br>> way, whole initialization is successful, I have touch few thing in<br>> libdrm_intel.so to fake the xcb connection.<br>><br>> How I am telling the initialization is successful is because, my
gles<br>> application returns success in creating shader and vertex program.the final<br>> call to glDrawaArray is also success. after glDrawaArray application calls<br>> eglSwapBuffers. If I see the eglSwapBuffers implementation it boils to<br>> "dri2_copy_region" where they directly delegates to libXCb.<br>><br>> From dri2_copy_region the call to "xcb_dri2_copy_region_unchecked" has the<br>> source and destination as XCB_DRI2_ATTACHMENT_BUFFER_FAKE_FRONT_LEFT and<br>> XCB_DRI2_ATTACHMENT_BUFFER_FRONT_LEFT respectively.<br>><br>> What I believe is, final GLES created scene is available in<br>> "FAKE_FRONT_LEFT" if by any chance I happen to get the pointer to<br>> FAKE_FRONT_LEFT, I can copy the content to my window surface and validate<br>> the scene.<br>><br>> Sorry for the big mail, i want to put in detail.<br>><br>> Happy to hear back.<br>><br>> Regards,<br>><br>>
Srini.<br>><br><br>Easiest solution is to record in egl the drm handle of the buffer when<br>GetBuffer is call (after egl surface creation) and in the elg swap<br>buffer call back you call your window system to blit from this handle<br>to your front buffer and do nothing else. That means that the dri<br>driver will keep rendering to the same buffer.<br><br>Cheers,<br>Jerome<br></div></div><div style="position: fixed; color: black; font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "></div>
</div></body></html>