[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] WebGL/WebGPU Considerations

On Tue, Feb 21, 2017 at 1:05 PM, Mark Callow <khronos@callow.im> wrote:
On Feb 20, 2017, at 21:04, Florian Bösch <pyalot@gmail.com> wrote:
  1. There needs to be a way to compose programs of many readily available and loaded on the GPU bits&pieces that don't need further massaging (doesn't presently exist at all)
Isn’t this what SSO (separate shader objects) are all about?

There are several mechanisms that attempt to make shaders less monolithic, but none of them are really sufficient.
  1. Separate shader objects allows you to define "incomplete" programs that only define a vertex shader or fragment shader. To render something, you'll just have to make sure that programs containing both stages are bound at the time. This does not solve monolithic shaders, it just breaks programs apart into stage pieces.
  2. Shader subroutines allow you to define/compile snippets of code into subroutines. The shader that wishes to use them needs to predeclare the subroutine signature (which becomes a type) which it can use in a uniform declaration. You can then pass in the subroutine index you obtained from compiling a subroutine as a uniform and the shader can use the passed in uniform subroutine as a function. This isn't available in OpenGL ES, it's not implemented in Direct3D (afaik) and it only made its Debut in the GL 4.0 core profile (though you can get it via an extension from GL 3.2).
Subroutines seem promising, but I haven't tried them and in any case, they'd first need to enjoy broad support.