PDA

View Full Version : GL_LUMINANCE and pbo : slow !



qnext
11-06-2012, 09:50 AM
I am trying to play a movie in yuv 420 ... so I have Three texture (one for lumi, one for u, one for V) with only one channel. When I use pbo it seems that it's slower than playing the same yuv files in 422 ! is GL_Luminance double pbo accelerated ( on both nvidia and amd card ?)

aqnuep
11-06-2012, 10:11 AM
Considering that neither luminance, nor double precision pixels are directly supported by hardware, I'm not wondering.

If you want to get the most performance, use core OpenGL instead of legacy stuff. That means, don't use luminance or intensity formats and don't use types that don't have a corresponding texture internal format, i.e. double.

Alfonse Reinheart
11-06-2012, 10:49 AM
Considering that neither luminance, nor double precision pixels are directly supported by hardware, I'm not wondering.

Luminance is directly supported by the hardware (http://www.opengl.org/wiki/Texture#Swizzle_mask). Double is very much not though.

Cab
11-06-2012, 11:48 AM
I made something similar yesterday (3 pbo to draw a yuv420 video frame). I'm not using double but normal UBYTE pbo's/textures. And I'm using GL_RED textures. And it is working fine.
Here is the relevant code:



void CU1VideoPlayer::U1Video_RTInitialize()
{
///--- Crea las texturas que va a usar para renderizar el vĚdeo
TESTRENDERTHREAD();
...

///---
GFXSelectTextureUnit(0);
m_oFrameTexture_Y.Initialize(GFX_TEXTURE_LINEAR, GFX_TEXTURE_LINEAR, GFX_TEXTURE_CLAMP_TO_EDGE, GFX_TEXTURE_CLAMP_TO_EDGE,
GFX_TEXTURE_2D, GFX_TEXTURE_STATIC);
m_oFrameTexture_Y.m_uWidth=1280;
m_oFrameTexture_Y.m_uHeight=720;
m_oFrameTexture_Y.BindTexture(0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, 1280, 720, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);


///////
m_oFrameTexture_U.Initialize(GFX_TEXTURE_LINEAR, GFX_TEXTURE_LINEAR, GFX_TEXTURE_CLAMP_TO_EDGE, GFX_TEXTURE_CLAMP_TO_EDGE,
GFX_TEXTURE_2D, GFX_TEXTURE_STATIC);
m_oFrameTexture_U.m_uWidth=1280>>1;
m_oFrameTexture_U.m_uHeight=720>>1;
m_oFrameTexture_U.BindTexture(0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, 1280>>1, 720>>1, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);


///////
m_oFrameTexture_V.Initialize(GFX_TEXTURE_LINEAR, GFX_TEXTURE_LINEAR, GFX_TEXTURE_CLAMP_TO_EDGE, GFX_TEXTURE_CLAMP_TO_EDGE,
GFX_TEXTURE_2D, GFX_TEXTURE_STATIC);
m_oFrameTexture_V.m_uWidth=1280>>1;
m_oFrameTexture_V.m_uHeight=720>>1;
m_oFrameTexture_V.BindTexture(0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, 1280>>1, 720>>1, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);




//////////////////////////////////////////////////////////////////////////
///--- Crea el PBO para las texturas
glGenBuffers(1, &m_uiGLPBOID_Y);
glGenBuffers(1, &m_uiGLPBOID_U);
glGenBuffers(1, &m_uiGLPBOID_V);

...
}


bool CU1VideoPlayer::RTPrivUpdateTexture()
{
bool bRet=false;
...


if(...){
if(g_bSup_ARB_pixel_buffer_object){
const int iWidth=1280;
const int iHeight=720;
const int iWidth2=1280>>1;
const int iHeight2=720>>1;


///--- Bind
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, m_uiGLPBOID_Y);
glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, iWidth*iHeight, NULL, GL_STREAM_DRAW_ARB);
uint8_t *pboMemory;
pboMemory=(uint8_t*)glMapBuffer(GL_PIXEL_UNPACK_BU FFER_ARB, GL_WRITE_ONLY);
XXXXTrapIf(pboMemory==NULL);
if(pboMemory){
m_pVDecoder->TransferBitmap(pboMemory, iWidth, iHeight, 0);
if(!glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB)) {
///--- Handle error case
...
}
m_oFrameTexture_Y.BindTexture(0);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, iWidth, iHeight, GL_RED, GL_UNSIGNED_BYTE, NULL);
}


//////////////////////////////////////////////////////////////////////////
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, m_uiGLPBOID_U);
glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, iWidth2*iHeight2, NULL, GL_STREAM_DRAW_ARB);
pboMemory=(uint8_t*)glMapBuffer(GL_PIXEL_UNPACK_BU FFER_ARB, GL_WRITE_ONLY);
XXXXTrapIf(pboMemory==NULL);
if(pboMemory){
m_pVDecoder->TransferBitmap(pboMemory, iWidth2, iHeight2, 1);
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB);
m_oFrameTexture_U.BindTexture(0);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, iWidth2, iHeight2, GL_RED, GL_UNSIGNED_BYTE, NULL);
}


//////////////////////////////////////////////////////////////////////////
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, m_uiGLPBOID_V);
glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, iWidth2*iHeight2, NULL, GL_STREAM_DRAW_ARB);
pboMemory=(uint8_t*)glMapBuffer(GL_PIXEL_UNPACK_BU FFER_ARB, GL_WRITE_ONLY);
XXXXTrapIf(pboMemory==NULL);
if(pboMemory){
m_pVDecoder->TransferBitmap(pboMemory, iWidth2, iHeight2, 2);
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB);
m_oFrameTexture_V.BindTexture(0);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, iWidth2, iHeight2, GL_RED, GL_UNSIGNED_BYTE, NULL);
}


///--- unbind
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0);

bRet=true;
}
else
{
...
}
}
return bRet;
}




Hope this helps.

--- Carlos Abril
--- www.zackzero.com (http://www.zackzero.com)

aqnuep
11-06-2012, 12:58 PM
Luminance is directly supported by the hardware (http://www.opengl.org/wiki/Texture#Swizzle_mask). Double is very much not though.
No, texture swizzling is directly supported by hardware. Luminance formats are just emulated using swizzling.

qnext
11-06-2012, 01:14 PM
regardings double ... i was talking about double pbo (not double format)...
I am certain that GL_BGRA is accelerated on nvidia and amd card, but I am not sure that GL_Luminance is as fast as GL_BGRA : it's working but I try to work with very large movie (4K). ... But how I can use any other accelerated format .. I have only one channel .. not 4 !

Alfonse Reinheart
11-06-2012, 01:56 PM
No, texture swizzling is directly supported by hardware. Luminance formats are just emulated using swizzling.

Remember the "as if" rule: if it gets the same results (with no loss of performance), then it is no different from using luminance. For all useful definitions of the term "supported", it is supported in hardware.


double pbo

What does that mean? Do you mean "double buffered pbo"?


I am certain that GL_BGRA is accelerated on nvidia and amd card, but I am not sure that GL_Luminance is as fast as GL_BGRA

You can't use GL_BGRA on a single-channel texture. More importantly... if you're not sure that LUMINANCE is faster or slower than something else, how do you know that your program is slow? Are you profiling?

More importantly, why don't you actually show us your code, instead of making us guess at what you're doing.