sokol icon indicating copy to clipboard operation
sokol copied to clipboard

sokol_gfx.h: Pipeline desc without attributes should be valid

Open agorgl opened this issue 4 years ago • 7 comments

Hello there,

It is perfectly valid to be able to call the draw functions without any vertex or index buffer bound. For example this vertex shader is a neat trick to draw a fullscreen pass without any vertex buffer:

#version 330 core
out vec2 uv;

void main()
{
    uv = vec2((gl_VertexID << 1) & 2, gl_VertexID & 2);
    gl_Position = vec4(uv * 2.0f + -1.0f, 0.0f, 1.0f);
}

Sokol pipeline validation though does not permit this, using the following validation: https://github.com/floooh/sokol/blob/master/sokol_gfx.h#L10440

This is not valid, and we should allow pipelines without any layout attributes to be created.

agorgl avatar Apr 01 '20 21:04 agorgl

Hi, the reason why attribute-less rendering isn't allow in sokol_gfx.h is that this isn't supported by GLES2 and WebGL (gl_VertexID was only added to GLES3 and WebGL2).

It might make sense to declare this as an optional feature though, I'll think about it.

Thanks for writing the issue!

floooh avatar Apr 02 '20 22:04 floooh

Just ran into the same issue, support for this would be great.

SanderMertens avatar Oct 10 '20 02:10 SanderMertens

@floooh Why keep GLES2 and WebGL around? Can't they be replaced by GLES3 and WebGL2 across the board?

aganm avatar Oct 10 '20 16:10 aganm

It's also required with WebGL2 and angle backend (d3d9)

Maeiky avatar Oct 10 '20 20:10 Maeiky

@floooh Why keep GLES2 and WebGL around? Can't they be replaced by GLES3 and WebGL2 across the board?

Believe it or not, Apple has never moved beyond a mostly un-implemented webgl2 support on its devices. We'll have to wait until they bother with WebGPU, most likely, as that uses Metal underneath. I think that there should be a WebGL 1 extension for hacking-in some things optionally.

KTRosenberg avatar Oct 11 '20 03:10 KTRosenberg

Apple has never moved beyond a mostly un-implemented webgl2 support

Safari Technology Review on macOS now actually has a working WebGL2 implementation based on ANGLE (it was just enabled by default a couple of days ago), I don't know how far along the iOS version is. But once this lands in the stable version I might indeed start plotting to remove the GLES2/WebGL1 support.

floooh avatar Oct 11 '20 12:10 floooh

Upvoting this. Something like a feature flag would be greatly appreciated.

iOrange avatar Nov 27 '21 14:11 iOrange

Closing this ticket in favour of: https://github.com/floooh/sokol/issues/922

(now that GLES2/WebGL1 has been dropped it's time to look into that topic again)

floooh avatar Oct 23 '23 11:10 floooh

("closed as not planned" actually means "closed as duplicate"!)

floooh avatar Oct 23 '23 11:10 floooh