Forum

SIFT COMPUTE SHADER: Ignore / skip an input vector position in compute shader DX11


#1

Hi duddddes,

How can i IGNORE or SKIP a current vector position in input structuredBuffer in a compute shader? Compute take in a “structureBuffer input” as input check if current input(dtid.x).z is 0 and if it is then it should IGNORE / SKIP or SIFT the current input(dtid.x) and move on top next one. ( should be [ it’s forreadability on forum…

FINAL PRODUCT is a backbuffer SMALLER than the input buffer in slice count.

Is that even possible?

This is the equivalent to do using = and SELECT node, but gpu accelerated in compute shader… I tried “return” to skip but with no luck?

Cheers for the help, code below:

StructuredBuffer<float3> input <string uiname="Input XYZ";>;
RWStructuredBuffer<float3> RWOutputBuffer : BACKBUFFER;

[numthreads(64,1,1)](numthreads(64,1,1))
void CS_siftXYZ(uint3 dtid: SV_DispatchThreadID) 
{
	
if(input[dtid.x](dtid.x).z==0){
return;
}else{
RWOutputBuffer=input[dtid.x](dtid.x);
}	

}

technique11 siftXYZ
{
	pass P0
	{
		SetComputeShader( CompileShader( cs_5_0, CS_siftXYZ() ) );
	}
	
}

#2

use AppendStructuredBuffer instead of RWStructuredBuffer and only append an element when your condition is true.

there are some examples in the dx11 girlpower package where you can see how the buffer renderer has to be set up to work properly with append buffers: https://github.com/mrvux/dx11-vvvv-girlpower/tree/master/girlpower/sm5/directcompute


#3

tmp, thank you so much bro! that is exactly what I was looking for! wicked stuff. Can I be cheeky and ask you if you know how I can get the appendStructuredBuffer appended ELEMENT COUNT SIZE? or is it imposible since it’s the appendStructuresBuffer’s buffer renderer element count that dictate the element count?

I am trying to find out how many element have been appended, and how many have been dropped / ignored / failed condition. Could i do a counter in float and get that somehow in another buffer? or use another compute to count? cheers

I will flag your answer as answer but just thought I would ask a bit more detail. Thank already man


#4

to access the number of appended elements just use the copycounter node. in your code you can access the number of appended elements like this:

ByteAddressBuffer InputCountBuffer;
...
uint cnt = InputCountBuffer.Load(0);

as geometry in you should use the null/index/vertex/dispatchIndirect and connect your buffer to the argument buffer pin.

greetings ;)