Jump to content
  • Advertisement
Sign in to follow this  
Shigeo.K

DX12 [D3D12] Barriers are really necessary?

This topic is 583 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

Hi.

I am learning the barrier stuff now.

I got a simple question.

I understood the  theory of the barrier.

But my D3D12 program(and MS sample program too) run fine WITHOUT barrier commands.

It seems like D3D12 driver doesn't care about barriers.

why D3D12 works fine without barriers?

Following code ,of course, works fine.

g_pCommandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(g_pRenderTargets[g_FrameIndex], D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_RENDER_TARGET));

(Draw operations)

g_pCommandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(g_pRenderTargets[g_FrameIndex], D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT));

And bellow works fine TOO (barrier commands are commented out).

//g_pCommandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(g_pRenderTargets[g_FrameIndex], D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_RENDER_TARGET));

(Draw operations)

//g_pCommandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(g_pRenderTargets[g_FrameIndex], D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT));

why?

Edited by Shigeo.K

Share this post


Link to post
Share on other sites
Advertisement

I did not mean I do not want to deal with barriers. Actually, opposite(That's why I post this thread).

You are in the world of undefined behaviors if you do not use proper barriers.

Yes this is what I thought.

, transition from render target to texture and vice versa are super important

Following your advice, I will test some texture transition, and see what happen if I don't put barrier commands.

Thanks.

AAA games, I agree in some ways.

But there is a developer like me who want to get maximum performance for his game. not only enormous budget games.

You might need to know that.

Share this post


Link to post
Share on other sites

But there is a developer like me who want to get maximum performance for his game. not only enormous budget games.

You might need to know that.

 

This is a miss-conception, yes, in some case you can get better performance than DX11, but unless you have a crazy load on your cpu and gpu, the chance you will see a marginal difference are quite low plus you put in balance months of complex development and intense hardcore low level debugging. That has a price !

I do not know your game, but many smaller production can run easily at >100fps if properly done even on moderate hardware with dx11 and DX12 is mostly a CPU improvement API to start with, while modest production usually hit the GPU bottleneck faster. On the GPU, you are looking for the quarter or half millisecond of implicit barriers in dx11 that could be avoid on dx12 on your GPU, or at best 1 or 2ms ( as observe on console renderer ) is you do a great use of async compute. Let me tell you, async compute is not the miraculous things AMD try to sell you,

Share this post


Link to post
Share on other sites

Shigeo.K out of curiosity what video card are you doing this on?

Also is it possible the driver is putting the barrier in for him?  I know its not supposed to for the sake of thinness but I was wondering.

Share this post


Link to post
Share on other sites

what video card are you doing this on?

I am using a very common hardware, GeForce GTX 1070(driver version 21.21.13.7653 2016.12.29) and Core i7 6700K.

I have examined texture transition without putting barriers.

Still D3D12 works fine.

Maybe we will need barriers in the near future. Not now.

Of course, we can't disrespect for the barrier. Barrier is exist because D3D12 want us to use it, obviously.

I just a little surprised that I can do almost everything WITHOUT barriers for now(on my hardware).

is it possible the driver is putting the barrier in for him?

Sorry I can't understand what this means.

This is a miss-conception, yes, in some case

I think I am some kind of peculiar developer.

I am 1 man developer, and I have passed steam greenlight, my game is in the steam store.

a crazy load on your cpu and gpu

My game is the game which has a crazy load on the cpu and the gpu.

 

rare synchronization artifacts that only show up on a particular GPU or driver revision.

Yes, it seems so. That what I was thinking.

Anyway, thanks to you guys, I could get a great confidence.

Thank you.

Share this post


Link to post
Share on other sites

What is that game ?

 

Example of transition that are really necessary :

RTV to SRV : Fast clear elimination and Color ROP cache flush because texture will use L2 cache. Same things if it is to PRESENT state

DSV to SRV : Depth decompression ( too bad, we do not have access to the ZTile data on PC :( )

UAV to SRV : Some cache need to be flushed or you may read outdated incorrect value

UAV to UAV : Not a transition barrier but it is needed to serialize two draw?dispatch or they may overlap. If there is no dependency, it is great and not needed, if there was and the barrier missing, well, it is hazard factory. Some cache flush will happen two for the same reason as uav to srv

To Indirect buffer argument : This one need even more flush than normal or your indirect draws won't see the proper value.

From copy dest to something : Obviously to wait for the copy to be complete.

Aliasing transition : Probably no work, but the barrier has a requirement to issue a clear that imply work.

That are the major chances of real work on transitions. Anyway, because you care, you run with the debug layer and gpu based validation, so even if the barriers where not useful, you do not want thousands of warning a frame to still see the real errors :)

Share this post


Link to post
Share on other sites
What is that game ?

http://store.steampowered.com/app/418050/?snr=1_7_7_151_150_1

I don't come here to advertise my game. So do not buy  from the above link :P

 

Example of transition that are really necessary :

Of course they are.

Needless to say, we need  transitions.

But I don't need  barriers (on my hardware, for now, on my simple examinations).

I just want to make it clear that I do not say I do not need a transition itself.

On my PC, program works fine without barriers, but I know I need barriers for many reasons.

Edited by Shigeo.K

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!