webgl2-compute: Can we use SSBO in vertex shader?

1,484 views
Skip to first unread message

Kentaro Kawakatsu

unread,
Apr 21, 2019, 9:50:18 PM4/21/19
to WebGL Dev List
I’m not sure it was when, but I saw below info as the difference between WebGL 2.0 compute and OpenGL ES 3.1 in Proposal spec:

SSBO is limited to be used only in fragment shader and compute shader because SSBO is implemented using RWStructuredBuffer on D3D.

But I can’t find the sentence corresponding to it in current Draft spec.
And currently, SSBO seems to be implemented using RWByteAddressBuffer on D3D.
So has the limitation been removed and we can use SSBO in vertex shader with random access(read/write) right?

-Kentaro

Qin, Jiajia

unread,
Apr 21, 2019, 10:25:35 PM4/21/19
to webgl-d...@googlegroups.com

Hi Kentaro,

That limitation is not needed anymore. Currently, we are using RWByteAddressBuffer instead of RWStructuredBuffer to implement SSBO. Whether you can use SSBO in vertex shader depends on the value of MAX_VERTEX_SHADER_STORAGE_BLOCKS. If your hardware at most supports d3d feature level 11.0, MAX_VERTEX_SHADER_STORAGE_BLOCKS will be 0 when you query. It means that you can’t use it in vertex shader. Otherwise, you can use it.

 

However, currently, SSBO is only supported in compute shader on d3d backend.  If you want to test it in vertex/fragment shader, you have to try it on gl backend.

 

Regards,

Jiajia

--
You received this message because you are subscribed to the Google Groups "WebGL Dev List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webgl-dev-lis...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kentaro Kawakatsu

unread,
Apr 23, 2019, 1:53:49 AM4/23/19
to WebGL Dev List
Thank you Jiajia.
I understood I should check if executing hardware supports SSBO to be used in vertex shader because minimum d3d environment which supports webgl2-compute does not ensure it.

And is SSBO in compute shader also so?
Is there theoretically possibly any environment which returns 0 as MAX_COMPUTE_SHADER_STORAGE_BLOCKS though supports webgl2-compute?
Or only speaking about compute(and fragment) shader, is there minimum requirement (e.g. at least 1) to support webgl2-compute?

-Kentaro

To unsubscribe from this group and stop receiving emails from it, send an email to webgl-d...@googlegroups.com.

Qin, Jiajia

unread,
Apr 23, 2019, 2:20:15 AM4/23/19
to webgl-d...@googlegroups.com

The webgl2-compute spec is based on OpenGL ES 31 spec with extra limitations. So you can check opengl es 31 spec, table 20.45, the minimum value of MAX_COMPUTE_SHADER_STORAGE_BLOCKS is 4. So you can use at least 4 blocks in compute shader in any device. But the minimum value of MAX_VERTEX_SHADER_STORAGE_BLOCKS  and MAX_FRAGMENT_SHADER_STORAGE_BLOCKS are 0 which means they may be not supported in vertex/fragment shader in some devices.

To unsubscribe from this group and stop receiving emails from it, send an email to webgl-dev-lis...@googlegroups.com.

Kentaro Kawakatsu

unread,
Apr 23, 2019, 2:47:00 AM4/23/19
to WebGL Dev List
Thank you, I'm relieved to hear that!
Sorry, I've searched this document before but overlooked this table.

-Kentaro
Reply all
Reply to author
Forward
0 new messages