LukasBanana / LLGL

Low Level Graphics Library (LLGL) is a thin abstraction layer for the modern graphics APIs OpenGL, Direct3D, Vulkan, and Metal
BSD 3-Clause "New" or "Revised" License
2.05k stars 139 forks source link

Remove "ShaderProgram" interface #45

Closed LukasBanana closed 1 year ago

LukasBanana commented 5 years ago

Replace the ShaderProgram interface and use Shader instances individually in various combinations for a GraphicsPipeline:

Before:

LLGL::ShaderProgramDescriptor myProgramDesc;
myProgramDesc.vertexShader = myVertShader;
myProgramDesc.fragmentShader = myFragShader;
LLGL::ShaderProgram* myShaderProgram = myRenderer->CreateShaderProgram(myProgramDesc);

LLGL::GraphicsPipelineDescriptor myPipelineDesc;
myPipelineDesc.shaderProgram = myShaderProgram;
/* ... */

After:

LLGL::GraphicsPipelineDescriptor myPipelineDesc;
myPipelineDesc.vertexShader = myVertShader;
myPipelineDesc.fragmentShader = myFragShader;
/* ... */

For OpenGL there need to be two paths implemented:

  1. Using GL_ARB_separate_shader_objects extension.
  2. Using an internal pool to look up existing shader programs that already exist for a combination of the specified shaders, i.e. the GLShaderProgram implementation will remain as internal class as fallback when the extension (see 1.) is not available.

All the shader reflection will move into Shader interface, which might be a bit chellenging for the 2nd case for OpenGL, because all shader related glGet* function need a shader program, i.e. a dummy shader program needs to be created, e.g. with a dummy vertex or fragment shader.

LukasBanana commented 1 year ago

Fixed with f481e1d