# DX12 ID3D12GraphicsCommandList::ResourceBarrier validation

## Recommended Posts

I've had a D3D12 implementaiton sitting in the background for a long time, but I only periodically check on it to see if it's still working (after windows/driver/etc updates). Today I checked it for the first time in many months, and ID3D12GraphicsCommandList::ResourceBarrier is causing validation errors:

D3D12 ERROR: ID3D12CommandList::ResourceBarrier: Before state (0x10: D3D12_RESOURCE_STATE_DEPTH_WRITE) of resource (0x00000279584EFB40:'depth') (subresource: 0) specified by transition barrier does not match with the state (0x80: D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE) specified in the previous call to ResourceBarrier [ RESOURCE_MANIPULATION ERROR #527: RESOURCE_BARRIER_BEFORE_AFTER_MISMATCH]

Six months ago my code was working fine without any errors, and now I get these errors (and if I ignore them, I get corrupt rendering that looks like cache invalidation/flush issues -- bad transitions)... This is probably due to windows/d3d validation getting better and catching bugs in my code that it wasn't before... but...

What I'm wondering is how is that particular function able to know the previous state of a resource during command recording?

For example, let's say I have one resource that starts in state "A", and I:
Record command list #1: Swap from "B" to "C".
Record command list #2: Swap from "C" to "A".
Record command list #3: Swap from "A" to "B".
Then let's say I execute list #3, then list #1, then list #2

This will correctly transition from "A"->"B"->"C"->"A"... but during recording, it looked like we were going to incorrectly do B->C (from A), C->A (from C), A->B (from A)...

It seems like I should get RESOURCE_BARRIER_BEFORE_AFTER_MISMATCH errors only when I execute a command list, not when I record one... Am I wrong??

##### Share on other sites

To answer my own question: Within a single command list, I'm performing an "A->B" followed by "A->C" transition. So, it makes perfect sense for the validation layer to flag the second transition as never-possibly-valid and the first as possibly-valid-depending-on-when-the-list-is-executed...

##### Share on other sites

Hi Hodgman,

If you are using NVIDIA Gfx card then it might be the latest driver from them that is doing this.

I had similar experience where code used to work and then suddenly started to crash on one of my machines. I spent a lot of time wondering why it was working on one machine and not the other. And why it had stopped working on a machine that used to execute the code without any problems.

After going one step back on NVIDIA driver on the machine causing headaches it worked again.

/Kim

##### Share on other sites

In this specific case it looks like you've called ResourceBarrier twice in the same command list. Going based off of:

does not match with the state (0x80: D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE) specified in the previous call to ResourceBarrier

It's possible that validation got better, but as far as I'm aware, it should've always been able to catch this particular case.

## Create an account

Register a new account

1. 1
2. 2
3. 3
Rutin
19
4. 4
5. 5

• 10
• 21
• 9
• 31
• 16
• ### Forum Statistics

• Total Topics
632618
• Total Posts
3007464
• ### Who's Online (See full list)

There are no registered users currently online

×