Getting the GPU offscreen rendering texture

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Getting the GPU offscreen rendering texture

Postby BenjiSBRK » Thu Jan 23, 2014 8:40 am

Is there a way to retrieve directly the id of the texture used on the GPU for offscreen rendering, instead of having to copy a buffer to another texture like I do ?
BenjiSBRK
Techie
 
Posts: 35
Joined: Tue Jan 21, 2014 9:59 am

Re: Getting the GPU offscreen rendering texture

Postby magreenblatt » Thu Jan 23, 2014 9:17 am

OSR does not support hardware acceleration and textures only exist in the GPU process.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Getting the GPU offscreen rendering texture

Postby BenjiSBRK » Thu Jan 23, 2014 10:58 am

Ok. Another question : the buffer passed to OnPaint is in BGRA, and I need it in RGBA. Making the conversion each frame has a huge impact on performance. Is there a way to get the buffer in RGBA ?
BenjiSBRK
Techie
 
Posts: 35
Joined: Tue Jan 21, 2014 9:59 am

Re: Getting the GPU offscreen rendering texture

Postby Czarek » Thu Jan 23, 2014 11:57 am

Why is it a huge impact to convert from bgra to rgba? Did you make any performance tests?

In CEF Python I wrote this function to swap the channels, you might find it useful:

Code: Select all
void SwapBufferFromBgraToRgba(void* _dest, const void* _src, int width, \
        int height) {
  int32_t* dest = (int32_t*)_dest;
  int32_t* src = (int32_t*)_src;
  int32_t rgba;
  int32_t bgra;
  int length = width*height;
  for (int i = 0; i < length; i++) {
    bgra = src[i];
    // BGRA in hex = 0xAARRGGBB.
    rgba = (bgra & 0x00ff0000) >> 16 // Red >> Blue.
           | (bgra & 0xff00ff00) // Green Alpha.
           | (bgra & 0x000000ff) << 16; // Blue >> Red.
    dest[i] = rgba;
  }
}
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: Getting the GPU offscreen rendering texture

Postby BenjiSBRK » Thu Jan 23, 2014 12:03 pm

Czarek wrote:Why is it a huge impact to convert from bgra to rgba? Did you make any performance tests?

In CEF Python I wrote this function to swap the channels, you might find it useful:

I'm doing it in C++, but bacisally I'm using the same method as your code. It's got an impact because on 2048*2048 image, doing it each frame (if, say, you're displaying a gif) means you do 4 million iterations each frame, so it's a no-no.
I can use a shader for doing this anyway (but still it would be nice if there was a way to get the rgba buffer from CEF).
BenjiSBRK
Techie
 
Posts: 35
Joined: Tue Jan 21, 2014 9:59 am

Re: Getting the GPU offscreen rendering texture

Postby magreenblatt » Thu Jan 23, 2014 1:08 pm

BenjiSBRK wrote:Ok. Another question : the buffer passed to OnPaint is in BGRA, and I need it in RGBA. Making the conversion each frame has a huge impact on performance. Is there a way to get the buffer in RGBA ?

How are you rendering the buffer? Both OpenGL and Direct3D support BGRA.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Getting the GPU offscreen rendering texture

Postby BenjiSBRK » Thu Jan 23, 2014 2:06 pm

magreenblatt wrote:
BenjiSBRK wrote:Ok. Another question : the buffer passed to OnPaint is in BGRA, and I need it in RGBA. Making the conversion each frame has a huge impact on performance. Is there a way to get the buffer in RGBA ?

How are you rendering the buffer? Both OpenGL and Direct3D support BGRA.

I'm working on a 3D engine, and our textures are in RGBA
BenjiSBRK
Techie
 
Posts: 35
Joined: Tue Jan 21, 2014 9:59 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 222 guests