Mixing GX and direct framebuffer writing

Post Reply
Lin
Posts: 18
Joined: Sat Feb 20, 2010 5:20 pm
Location: Salt Lake City

Mixing GX and direct framebuffer writing

Post by Lin » Wed Jul 28, 2010 2:52 am

I started programming the Wii by just writing pixels directly to the framebuffer. I've sinced learned how to use GX to draw textured polygons, which makes blending run much faster than it does on the CPU. Now I want to combine the two methods.

I want to draw a scene using GX and then draw some "overlays," by which I mean some text or a cursor that will overwrite parts of the image produced by GX. Is this sensible? I tried simply writing to the framebuffer after I called GX_DrawDone, but this produces a weird effect where my "overlay" pixels flickered erratically, as if my direct framebuffer write was occurring simultaneously with the GX framebuffer copy. I tried to use VIDEO_ClearFrameBuffer as I had done before with direct writing, and while this fixed the overlay flickering, it made half of the screen black.

It seems like GX is running as I'm doing my framebuffer writes, even though I tried to do them afterward. If this is the case, how do I synchronize the two processes?

techhnik
Posts: 15
Joined: Sun Jun 20, 2010 9:21 pm

Re: Mixing GX and direct framebuffer writing

Post by techhnik » Sat Aug 07, 2010 8:09 pm

GX_DrawDone doesn't mean it has finished drawing 3D, it means you have finished sending commands to GPU, but GPU keeps working.
You can either wait for syncro and write your overlays just before copying the frameBuffer or you can draw your overlays as a texture to a polygon in front of the camera (using an orthogonal projection matrix).

Lin
Posts: 18
Joined: Sat Feb 20, 2010 5:20 pm
Location: Salt Lake City

Re: Mixing GX and direct framebuffer writing

Post by Lin » Wed Aug 18, 2010 9:22 pm

techhnik wrote:You can either wait for syncro and write your overlays just before copying the frameBuffer...
How do you wait for synchro? Synchro with what? Do I actually want to draw my overlays before calling GX_CopyDisp?

My code is as follows:

Code: Select all

GX_Begin(GX_QUADS, GX_VTXFMT0, 56);
    // some textured quadrilaterals
GX_End();

GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
GX_SetAlphaUpdate(GX_TRUE);
GX_SetColorUpdate(GX_TRUE);
GX_CopyDisp(frameBuffer[fb],GX_TRUE);

GX_SetDrawSync(0);
GX_DrawDone();

/*** this draws the overlay pixels directly on the framebuffer ***/
drawBorderTest(frameBuffer[fb]);

VIDEO_SetNextFramebuffer(frameBuffer[fb]);

VIDEO_Flush();
VIDEO_WaitVSync();

fb ^= 1;
Sorry for the lack of activity, because I really appreciate the response; this issue really bugs me for some reason. The reason I've been afk is I just moved and don't have an internet connection, so I'm operating out of a library.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests