gongminmin/KlayGE

how to share counted structured buffer uav between cs and ps?

Closed this issue · 4 comments

I'm creating my demo with KlayGE. Some problem arises.

I have a vertex buffer and a uav based on it. The uav is counted structured buffer uav.
Then I pass the same uav as parameter to a pixel shader and a compute shader.
In pixel shader, some data format float4 is appended to the buffer uav.
When I try to fetch data from the uav in my compute shader, nothing got.

I struggled with it days, don't know what can be wrong.
If more info is needed, I can paste some code for further investigation.
Thanks in advance.

The UAV itself shouldn't be different between shader stages. It could be a bug in bindings. I'll write a test for it. Thanks.

New tests are added to test/UavOutput branch for writing from PS and read from CS. The content is correct, it doesn't repro what you descried.

However, the counter itself is cleared to 0 when setting to CS. Is this what you meant?

I compared your test code with my code, and found that I was using the following code to bind uav to ps.
'*(effect_->ParameterByName("xxx")) = uav;

I modified my code and finally got uav working. Thanks.

In DX11, there's an option whether to clear the counter when binding the uav. But I didn't find any place to do the same thing with KlayGE. I don't need such mechanism right now. Maybe the interface can be optimized in proper time.

There is an function to set the initial count. But the value is not used when setting a uav to CS. I'm fixing it.