[SOLVED] Post Processing BackBuffer using Effects 11

Started by
12 comments, last by Crosire 11 years ago

I thought the shader view interface only stores a pointer to the screen texture, so it will retrieve the updated data, when I change the texture object it was initalized with.

Nope, the view is tightly bound to the resource, you can't change that after creation.

The code now fails at "context->CopyResource(g_pScreenTexture11, m_pBackBuffer);" though. The texture is just empty.

If you look at the docs of this function you will have to check the compatibility of source and target resource. I already suspected some format problem: Is your backbuffer e.g. really 32F ?

I tried this one too:
*snip*
But it crashes the application at the second line already, I have no idea why.

BMP can't cope with float formats, use DDS instead.

I'm going to try and put together a quick testing program as I cannot bind PIX to any other software with my project applied. PIX tries to hook the DirectX Exported Functions which was already done by my hook, so it just crashes.

That leaves bare logging, hopefully. Dump the description of the resources and views in question using GetResource and GetDesc and compare them.
Advertisement

If you look at the docs of this function you will have to check the compatibility of source and target resource. I already suspected some format problem: Is your backbuffer e.g. really 32F ?

And that is the problem. DirectX 9 had the "StretchRect" function, which did the job. DirectX 11 is missing any real replacement. I don't see how I can copy the resource of the backbuffer to my texture, which has a different format?!

"CopyResource" and "ResolveSubresource" both require compatible formats. If I set up my texture with the same format as the backbuffer, those work of course, but the Shader View is not created properly again (see below).

Whatever I'm trying, either one or the other thing work, but not both together ...

BMP can't cope with float formats, use DDS instead.

It's not the save texture line that makes it crash, it's the "GetResource" and that's because the shader resource view object is NULL (got my testing application working and can successfully debug it with the VS 11 graphics debugger) even though it was created earlier.

Tried to create it every frame too:


SAFE_RELEASE(g_pScreenSurface11);
device->CreateShaderResourceView(g_pScreenTexture11, NULL, &g_pScreenSurface11);
ID3D11Resource *tex;
g_pScreenSurface11->GetResource(&tex);

Crashes, it is still NULL. It works when I create the texture from a file instead of using the backbuffer, so I asume either the format is the issue or the backbuffer is missing the "D3D11_BIND_SHADER_RESOURCE" flag (which is probably the case).

The solution would be to create a texture with that flag set and copy the backbuffer contents onto it. But all my tries failed there yet, as shown above.

I hope I'm not too annoying here smile.png

Yeah, you need the copy resource, and you need D3D11_BIND_SHADER_RESOURCE on your target texture to then be able to sample from. Don't see where you fail, so I just reiterate:

- Your backbuffer is given, so D3D11_BIND_SHADER_RESOURCE is not available
- create a compatible texture, same format (and MS type!), same dimension, this time with D3D11_BIND_SHADER_RESOURCE
- create the view thereof
- use it as source for your postprocess

Forgive me, I was just stupid. Everything is working now!

BIG thanks to you smile.png

This topic is closed to new replies.

Advertisement