<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-&gt;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&nbsp;</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&nbsp;</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-&gt;flip_info.flipSurf,&nbsp;</font><span class="Apple-style-span" style="font-family: 'times new roman', 'new york', times, serif; ">&amp;cdi_surface_width, &amp;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-&gt;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-&gt;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-&gt;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-&gt;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(&amp;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; &nbsp;</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-&gt;fd,DRM_IOCTL_I915_GEM_CREATE,&amp;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-&gt;fd, DRM_IOCTL_GEM_FLINK,&amp;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-&gt;fd,DRM_IOCTL_GEM_OPEN,&amp;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-&gt;buffers[0].attachment = 7; &nbsp;// 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-&gt;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-&gt;buffers[0].pitch = 3072;&nbsp;</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-&gt;buffers[0].cpp = 4;&nbsp;</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-&gt;buffers[0].flags = 0;&nbsp;</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-&gt;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 &nbsp;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&nbsp;compared&nbsp;this structure with X11 there is no&nbsp;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&nbsp;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&nbsp;</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&nbsp;obviously i need to derive some how&nbsp;&nbsp;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&nbsp;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 &lt;j.glisse@gmail.com&gt;<br><b><span style="font-weight: bold;">To:</span></b> Srini
 &lt;srini_rajini@yahoo.com&gt;<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 &lt;<a ymailto="mailto:srini_rajini@yahoo.com" href="mailto:srini_rajini@yahoo.com">srini_rajini@yahoo.com</a>&gt; wrote:<br>&gt; Hi Jerome,<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp; Thanks for Reply, what you said is right for my attempt on software<br>&gt; acceleration. I added a folder called "flip" in<br>&gt; mesa/src/gallium/state_tracker/egl/ and created the egl software driver<br>&gt; called "egl_flip_swrast.so" its working fine.<br>&gt;<br>&gt; My current attempt is to enable the hardware acceleration, I choose<br>&gt; Mesa-7.9,and the configuration i used is<br>&gt;<br>&gt; "./configure --enable-gles2
 --enable-egl --with-egl-platforms=x11<br>&gt; --with-dri-drivers=i965 --with-state-trackers=egl,dri --disable-gallium<br>&gt; --disable-glw"<br>&gt;<br>&gt; This configuration totally disable the gallium driver this means I am using<br>&gt; Classic mesa driver, I used the small GLES application to read the flow of<br>&gt; the Hardware rendering path, accordingly I mocked the entire flow for my<br>&gt; windowing system by faking the egl_dri2.c file, where actually the<br>&gt; initialization for x11 and drm are happening, I added the new API<br>&gt; "dri2_initialize_flip".<br>&gt;<br>&gt; The difference between dri2_initialize_flip and dri2_initialize_x11 is, all<br>&gt; the calls to XCB are removed, and rather I am using my local library by this<br>&gt; way, whole initialization is successful, I have touch few thing in<br>&gt; libdrm_intel.so to fake the xcb connection.<br>&gt;<br>&gt; How I am telling the initialization is successful is because, my
 gles<br>&gt; application returns success in creating shader and vertex program.the final<br>&gt; call to glDrawaArray is also success. after glDrawaArray application calls<br>&gt; eglSwapBuffers. If I see the eglSwapBuffers implementation it boils to<br>&gt; "dri2_copy_region" where they directly delegates to libXCb.<br>&gt;<br>&gt; From dri2_copy_region the call to "xcb_dri2_copy_region_unchecked" has the<br>&gt; source and destination as XCB_DRI2_ATTACHMENT_BUFFER_FAKE_FRONT_LEFT and<br>&gt; XCB_DRI2_ATTACHMENT_BUFFER_FRONT_LEFT respectively.<br>&gt;<br>&gt; What I believe is, final GLES created scene is available in<br>&gt; "FAKE_FRONT_LEFT" if by any chance I happen to get the pointer to<br>&gt; FAKE_FRONT_LEFT, I can copy the content &nbsp;to my window surface and validate<br>&gt; the scene.<br>&gt;<br>&gt; Sorry for the big mail, i want to put in detail.<br>&gt;<br>&gt; Happy to hear back.<br>&gt;<br>&gt; Regards,<br>&gt;<br>&gt;
 Srini.<br>&gt;<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>