Sign in to follow this  

DXGI format question.

This topic is 662 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

One of textures in my GBuffer has format  DXGI_FORMAT_R8G8B8A8_UNORM.

GBuffer uses only first 3 bytes of it.

 

For my SSAO buffer I created a separate texture, SRV, and RTV with format DXGI_FORMAT_R8_UNORM

In separate SSAO pass I write to the SSAO RTV.

 

I would like to save 2MB of VRAM.

 

Is it possible to reuse last byte of a texture DXGI_FORMAT_R8G8B8A8_UNORM to render SSAO data and to read data from it?

It would make sense only if writes from SSAO pass to the last byte would not rewrite first 3 bytes that are already written by GBuffer pass.

 

If it is possible, what formats should I use for:

1. GBuffer's SRV and RTV

2. RTV and SRV for SSAO pass?

 

I was looking in to dxgiformat.h and could not find neither DXGI_FORMAT_R8G8B8_UNORM_X8_TYPELESS nor DXGI_FORMAT_X24_TYPELESS_G8_UNORM.

 

Thanks in advance.

Edited by Happy SDE

Share this post


Link to post
Share on other sites

Depending on whether performance or saving memory is your primary concern, this may not be a wise idea.

 

If saving as much memory as possible is your aim, then what you've done is probably fine.

 

If saving GPU time is the goal, then I think you'll only make things worse (YMMV). The SSAO pass may only write 1 byte out of the 4, but the GPU can only write at the granularity of one cache line (~64 bytes), so it's going to have to Read-Modify-Write the memory to insert your 'alpha' bytes. Instead of writing "Width * Height * 1" bytes of data, it probably now has to read "Width * Height * 4" bytes, modify and write "Width * Height * 4" bytes, an 8-fold increase in bandwidth over just writing R8_UNORM.

 

Then, when you come to read this hybrid GBuffer/SSAO data, do you read them in separate passes or both at the same time? If they're read at different times, the SSAO-reading pass has to read Width * Height * 4 bytes again (since it can't read just 1 byte ouf ot the 4), rather than just 1 byte per pixel in the R8_UNORM case.

Share this post


Link to post
Share on other sites
Adam Miles, on 17 Feb 2016 - 7:05 PM, said:Adam Miles, on 17 Feb 2016 - 7:05 PM, said:Adam Miles, on 17 Feb 2016 - 7:05 PM, said:

Depending on whether performance or saving memory is your primary concern, this may not be a wise idea.

 

If saving as much memory as possible is your aim, then what you've done is probably fine.

 

If saving GPU time is the goal, then I think you'll only make things worse (YMMV). The SSAO pass may only write 1 byte out of the 4, but the GPU can only write at the granularity of one cache line (~64 bytes), so it's going to have to Read-Modify-Write the memory to insert your 'alpha' bytes. Instead of writing "Width * Height * 1" bytes of data, it probably now has to read "Width * Height * 4" bytes, modify and write "Width * Height * 4" bytes, an 8-fold increase in bandwidth over just writing R8_UNORM.

 

Then, when you come to read this hybrid GBuffer/SSAO data, do you read them in separate passes or both at the same time? If they're read at different times, the SSAO-reading pass has to read Width * Height * 4 bytes again (since it can't read just 1 byte ouf ot the 4), rather than just 1 byte per pixel in the R8_UNORM case.

Thank you Adam for the note.

 

My current SSAO implementation consist of 3 passes:

1. Compute SSAO: data is written into A-channel of 32-bit texture.

2. Horizontal bilateral edge preserving blur: data is read from the texture and written to R8_UNORM.

3. Vertical blur pass: read from R8_UNORM and write to A-channel of 32-bit texture.

 

Final lighting pass reads 32-bit texture.

 

I do not measure performance right now.

I am just learning DX =)

 

But I can see FPS drop (below 60) in 2 cases:

1. 20.000 objects, 6.000.000 triangles + about 65 light sources

2. 2.500 objects, 1.300.000 triangles, most of them are transparent + 14 light sources.

 

I am definitely planning to measure performance at some point in the future when I will break in the industry.

I presume it's much faster to learn this topic from face-to-face communication, than trying to learn it from scratch by myself.

 

If there will be a bottle neck in SSAO effect, I will for sure try to use your suggestion and will create second texture for SSAO effect only.

And may be will do SSAO at half resolution =)

Edited by Happy SDE

Share this post


Link to post
Share on other sites

This topic is 662 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this