Accelerating 2D Blit i.mx31 MBX Lite

I am trying to determine what would be the fastest method of performing a image buffer blit

  1. glDrawTexi0ES
  2. pbuffer
  3. Textured quad?

Sample code below


GLint cropRect[4] = { 0, 0, 400, 240}; 
int nWidth = 400;
int nHeight = 240;

	void* buffer;
	buffer = malloc (512 * 256 * (32 / 8 ));
	memset (buffer, 128, nWidth * nHeight * (32 / 8 ));

	glGenTextures( 1, &texture);
	glBindTexture( GL_TEXTURE_2D, texture );
	glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA, 512, 256, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
	glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, nWidth, nHeight, GL_BGRA, GL_UNSIGNED_BYTE, buffer);



	// Draws a triangle for 800 frames
	for(int i = 0; i < 800; ++i)
	{
		int color;
		color = rand() % 100 + 1;
		memset (buffer, color, nWidth * nHeight * (32 / 8 ));
		glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, nWidth, nHeight, GL_BGRA, GL_UNSIGNED_BYTE, buffer);

		glViewport(0, 0, nWidth, nHeight);
		glMatrixMode(GL_PROJECTION);
		glPushMatrix();
		glFlush();
		glLoadIdentity();
		glOrthox(0, nWidth, nHeight, 0, 0, 1);
		glMatrixMode(GL_MODELVIEW);
		glPushMatrix();
		glLoadIdentity();
		glEnable(GL_TEXTURE_2D);
		glBindTexture(GL_TEXTURE_2D, texture);
		glTexEnvx( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
		glTexParameterx( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
		glTexParameterx( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
		glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, cropRect);
		glDrawTexiOES(0,0,0,nWidth, nHeight);
		glPopMatrix();
		glMatrixMode(GL_PROJECTION);
		glPopMatrix();
		glFlush();

		eglSwapBuffers(eglDisplay, eglSurface);
		if (!TestEGLError("eglSwapBuffers"))
		{
			goto cleanup;
		}
	}


Thanks

Ryan

glDrawTexiOES is a simplified way to draw a textured quad, thus preferable to 3) when it is available. It isn’t clear to me what you want to do with pbuffers, could you please explain?

A few comments on the sample code:
glTexSubImage2D may be slower than glTexImage2D if you replace a big part of the texture. Thus depending on the size of the image you’re using, it may be faster to round the image buffer dimensions up to the next power of two so you can use glTexImage2D.

glDrawTexiOES takes window coordinates and bypasses the transform pipeline (except for mapping Z to the depth range), so there is no need for any matrix setup/restore code.

glOrthox takes 16.16 fixed point values, so if you want to pass integers you need to shift them 16 bits to the left.

Why are you calling glFlush? And please avoid redundant state changes in a loop.

Regards,
Georg

Dear revans35,
Could you tell me what Hardware and Software tools (board, Linux distro, BSP, etc) do you have?
I bought a MX31LITE from Logicpd and I still couldnt make it work with Opengles :frowning:

Regards,

DrOcta.

What model of the MX31 chip do you have? I believe the i.MX31L does not have the MBX accelerator on it. You can check the freescale website for more details.

Ryan

I have the MX31 with the MBX accelerator, but I’m getting problems with the linux re-build because there is no BSP for the MX31LITE, some ppl is using the BSP from Freescale (MX31ADS board) with some patch.
Do you have MX31LITE or MX31ADS?
My goal with this chip is OpenGLES :!:

hi Xmas,

just to clarify,

Is glDrawTexi0ES faster than glDrawArrays for drawing a textured quad(=2 textured triangles in the case of glDrawArrays).

If so, in what way?

Thanks!

It is simpler to use and it may be (very slightly) faster because it bypasses the transform pipeline and there is only one call instead of possibly multiple ones with some data copies.

On the other hand, glDrawArrays/glDrawElements can be used to draw multiple textured quads in one go (using different regions from the same texture), and in that case it is the preferred way.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.