|
InternalGrGLProgram
Pieces of the Ganesh GPU Shader Model
This documentation describes the state of an internal component as of r2494. IntroductionGPU vertex/fragment shaders are generated and managed as GrGLProgram objects. They are identified at runtime by a hash computed off of the ProgramDesc, a private struct of packed descriptors. The basic model of a shader hearkens back to the fixed function pipeline: a series of stages, each of which receives an input color and texture coordinates, reads a single texture n times, and writes a single output that as the input to the next stage. Currently, each stage modulates the incoming color by its computed color. The input to the first stage will be one of:
Some transfer (blend) modes require computing fractional coverage separately from alpha. The program descriptor contains a stage index that divides the stages been color- and coverage-computing. The coverage stages are linked series in the same manner as the color stages. The initial input to the first coverage stage is either:
The frag shader color output (gl_FragColor) is color x coverage. A secondary frag shader output may be computed from the color and coverage. It is used as a dst coefficient to the GL blend operation (see GL_ARB_blend_func_extended). The program descriptor enum DualSrcOutput indicates whether this additional output is necessary and how it is computed. These stages are augmented with several special-purpose elements:
Shaders are generated as groups of strings of text by GrGLProgram::genProgram(), then compiled, with their setup information stored in a GrGLProgram::CachedData struct. The parameters to genProgram() are set up by GrGpuGLShaders::buildProgram(), which is called by GrGpuGLShaders::ProgramCache::getProgramData(), which is in turn called by GrGpuGLShaders::flushGraphicsState(). The CachedData object is stored in GrGpuGLShaders::fProgramData and used heavily throughout GrGpuGLShaders. Future Work
|