View Full Version : Is this possible - Draw & resize BB to RT

04-27-2010, 10:53 AM

Say for example I have a Back-Buffer the size of 2000x1000.

In addition I have a render target (FBO) the size of 2000x1000.

And say the Back-Buffer is multi-sampled (16).

I want to blit the pixels from the back-buffer to the final render target, BUT - I want to copy the entire back-buffer frame to the upper-left quarter of the final render target.

Meaning - I want to copy from the BB and shrink it by 4 when it's copied to the final render target.

The problem is - this doesn't work and gives me an 'Invalid Operation' error.

So what I did to bypass the error is -

I've rendered to the 2000x1000 Back-buffer.

Then I copied the pixels as they are to a TEMP render target 2000x1000 size.

Then I copied & shrunk from the TEMP render target to the FINAL render target, and this works.

Maybe you can't copy & shrink from the Multi-Sampled Back-Buffer to a non-multi-sampled final render target ?

Is this true ?

If not - I'd be happy to hear so ...

Because this extra copy through the TEMP render target causes me some performance issues I cannot afford ...

Thank you all in advance !

04-27-2010, 12:05 PM
It is possible according to the blit command. You might have some kind of mismatch in types and targets.


If the source and destination rectangle dimensions do not match,
the source image is stretched to fit the destination
rectangle. <filter> must be LINEAR or NEAREST and specifies the
method of interpolation to be applied if the image is
stretched. LINEAR filtering is allowed only for the color buffer;
if <mask> includes DEPTH_BUFFER_BIT or STENCIL_BUFFER_BIT, and
filter is not NEAREST, no copy is performed and an
INVALID_OPERATION error is generated. If the source and
destination dimensions are identical, no filtering is applied. If
either the source or destination rectangle specifies a negative
dimension, the image is reversed in the corresponding direction.
If both the source and destination rectangles specify a negative
dimension for the same direction, no reversal is performed.

04-27-2010, 07:39 PM
There is no mention to the fact that the Back-Buffer is MULTI-SAMPLED, and the render target to which I want to copy is NOT MULTI-SAMPLED.

Could that be what causes me the INVALID OPERATION ?

04-29-2010, 03:49 PM
No, blitting should take care of that. Here's a working example I use as reference. You can always try swapping in his values.