sokol_gfx.h : resizing render targets (sg_image)

Created on 6 Jun 2019  Â·  6Comments  Â·  Source: floooh/sokol

Hello! I was wondering how would one scale down render targets? (for effects like bloom)

All 6 comments

To resize render targets with window size changes, you need to destroy and recreate them, along with their pass. Here's an example which recreates offscreen render targets when the sokol_app.h RESIZED event is sent:

https://github.com/floooh/sokol-samples/blob/7df270a9ed402af95f3560fecc74fef55174ddd1/sapp/mrt-sapp.c#L52-L100

The actual downscaling must be done with a pixel shader by rendering a fullscreen quad, there's no "fixed function" blitting operation in sokol-gfx.

Thank you!

On Thu, Jun 6, 2019 at 5:54 PM Andre Weissflog notifications@github.com
wrote:

To resize render targets with window size changes, you need to destroy and
recreate them, along with their pass. Here's an example which recreates
offscreen render targets when the sokol_app.h RESIZED event is sent:

https://github.com/floooh/sokol-samples/blob/7df270a9ed402af95f3560fecc74fef55174ddd1/sapp/mrt-sapp.c#L52-L100

The actual downscaling must be done by rendering via pixel shader by
rendering a fullscreen quad, there's no "fixed function" blitting operation
in sokol-gfx.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/floooh/sokol/issues/167?email_source=notifications&email_token=AAIGT2SSM6LEJWSGLL57433PZEFXJA5CNFSM4HVA4K5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXC2I2I#issuecomment-499491945,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAIGT2UVL2X6BI4FEGTDU63PZEFXJANCNFSM4HVA4K5A
.

Forgot to ask, is it a webgl/opengles limitation?

No, WebGL is fine since it has a scaling glBlitFramebuffer function (I'm using this - without the scaling - to resolve MSAA render targets to textures in sg_end_pass().

The problem are the other APIs, both D3D11 and Metal only offer fairly limited copying between texture resources without scaling, so a full render pass is needed for this anyway (and it's also more flexible since you have better control over the scaling via the pixel shader).

...oops correction, WebGL doesn't have glBlitFramebuffer() that's a WebGL2 feature (that's why sokol_gfx.h doesn't support MSAA render target in WebGL(1).

So yeah, in addition to D3D11 and Metal, WebGL/GLES2 also wouldn't work :)

I wasn't aware that limitation applies to D3D11 and Metal as well. Thanks again :)

Was this page helpful?
0 / 5 - 0 ratings