gpu_program - ryzom/ryzomcore GitHub Wiki


title: GPU Program description: published: true date: 2023-03-01T05:19:27.721Z tags: editor: markdown dateCreated: 2022-03-08T22:40:40.118Z

One generic class: IProgram.

Three stages: CVertexProgram, CPixelProgram, CGeometryProgram.

IProgram

  • A container of program code for a single stage targeting multiple program model profiles.
  • A local state of uniforms (cfr. gl Program Object).

Will contain setUniform functions in the future, using DSA functions provided by ARB_separate_shader_objects.

This class follows the creation methods conform other classes in the NL3D drivers such as CVertexBuffer.

The user simply creates this class using "new IProgram()", and adds the necessary profiles. The program is compiled (and linked) using IDriver::compileVertexProgram etc, after which the setUniform and getUniformIndex functions of the IProgram become valid for use. Using IDriver::activeVertexProgram will also compile an IProgram if it has not yet been.

IDriver::setUniform

  • Currently implementation-dependent in driver. Old drivers set Env parameters, new drivers set program Local state.
  • Setting Local state requires the program to be set active.

Local state will be set through IProgram in the future, and the IDriver::setUniform functions will only work on profiles that support Env state using programs that use Env state. When Env state is not supported, these functions must crash the program with an error message, as using these would indicate a serious bug in the rendering code. If the overhead is neglible for modifying the old drivers to emulate Local state, these may be removed altogether. D3D does not natively support it, OpenGL's ARB programs do in fact support this functionality.

The nelvp vertex program profile (this is a strict subset of arbvp1 that can be converted to d3d asm) only supports Env state and does not support Local state. This may be reversed if the functionality can be switched with minimal overhead.

IProgram::setUniform

Currently not in IProgram yet because of necessary structural changes in existing NL3D code.

Must crash with error on program profiles that do not support local uniform state.

See IDriver::setUniform for the current transitional interface.

IDriver::activeVertexProgram, ...

  • Activates a program on the driver.
  • The activated program always has preference over any programs that can be generated from the CMaterial used for rendering or fixed pipeline functionality.
  • The activated program always has preference over any programs contained in the CMaterial dynamic passes (in case this features is implemented) or surface shaders.
  • (IProgram contained in CMaterial dynamic passes always have preference over any programs that can be generated from the CMaterial.)

CProgramFeatures

  • Describes a number of options when an IProgram is used in conjunction with a CMaterial (for example, whether or not the CProgram expects the texture stages (and samplers) of the Cmaterial as it's input uniforms.
⚠️ **GitHub.com Fallback** ⚠️