cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

MichaelChampigny
Journeyman III

Computer Shader model limited to global buffer?

global buffer, compute shader

From what little I can find in the documentation about the global buffer, is it true there is only one available (i.e., g[])?

 

Also, it appears that I can't use o0-o7 output registers in a computer shader. Instead, if I want to output from a kernel I need to scatter writes to the global buffer. I would like the flexibility of outputing to multiple o# registers. I know I can emulate this behavior with a scatter but it's a bit messy.

 

What is the best practice for handling multiple output buffers in that case? Is seems I am limited to outputing to just the single global buffer in the kernel when using the compute shader model.

0 Likes
3 Replies
rick_weber
Adept II

There is only one g register.

When writing to o#, you can only write to the current location in the domain of execution. You can't index into them arbitrarily (you can't index into them at all, actually). For example, if vWinCoord0.x = 20.5 and y = 70.5, this means I'm at row 70 column 20 in a 2d matrix. To write to that location, call "mov o0, r2" (or any other operation with o# as a destination register).

If you're going to use the global buffer as your output, you map it to a resource by passing a flag when you call ResAllocLocal1D(). You can probably still additionally map o0-o7 to resources as well and use them for output.

0 Likes

Thanks.

 

I don't think you can use the o# registers for compute shaders (i.e., IL_CS). Those are for pixel shaders (i.e., IL_PS) only. At least that's my understanding.

 

The compute shaders must use the g[] register for output with linear addressing. The issue is that it's a bit limiting. I may want to have multiple outputs for my kernel without resorting to hacks like offsets passed in through the constant buffer.

 

0 Likes

Originally posted by: MichaelChampigny Thanks.

 

 

 

I don't think you can use the o# registers for compute shaders (i.e., IL_CS). Those are for pixel shaders (i.e., IL_PS) only. At least that's my understanding.

 

 

 

Yes you are correct. You cannot use o# is IL_CS kernels.

0 Likes