blob: 0ebf6a228ec8906260e431d5ad89629ffcbbbdfb [file] [log] [blame]
bsalomon@google.com31ec7982013-03-27 18:14:57 +00001/*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef GrGLProgramDesc_DEFINED
9#define GrGLProgramDesc_DEFINED
10
joshualitt79f8fae2014-10-28 17:59:26 -070011#include "GrColor.h"
12#include "GrProgramDesc.h"
commit-bot@chromium.org0a6fe712014-04-23 19:26:26 +000013#include "GrGpu.h"
joshualitt79f8fae2014-10-28 17:59:26 -070014#include "GrTypesPriv.h"
bsalomon@google.com31ec7982013-03-27 18:14:57 +000015
bsalomon861e1032014-12-16 07:33:49 -080016class GrGLGpu;
jvanverthd1e72872015-04-20 12:29:37 -070017class GrGLProgramDescBuilder;
18
19class GrGLProgramDesc : public GrProgramDesc {
20 friend class GrGLProgramDescBuilder;
21};
bsalomon@google.com31ec7982013-03-27 18:14:57 +000022
joshualitt79f8fae2014-10-28 17:59:26 -070023/**
24 * This class can be used to build a GrProgramDesc. It also provides helpers for accessing
25 * GL specific info in the header.
26 */
27class GrGLProgramDescBuilder {
bsalomon@google.com31ec7982013-03-27 18:14:57 +000028public:
joshualitt71c92602015-01-14 08:12:47 -080029 typedef GrProgramDesc::KeyHeader KeyHeader;
joshualitt79f8fae2014-10-28 17:59:26 -070030 // The key, stored in fKey, is composed of five parts(first 2 are defined in the key itself):
bsalomon848faf02014-07-11 10:01:02 -070031 // 1. uint32_t for total key length.
32 // 2. uint32_t for a checksum.
33 // 3. Header struct defined above.
egdanielc67870c2014-11-26 08:50:50 -080034 // 4. Backend-specific information including per-processor keys and their key lengths.
35 // Each processor's key is a variable length array of uint32_t.
bsalomon@google.com2db3ded2013-05-22 14:34:04 +000036 enum {
bsalomon929f29a2014-07-17 07:55:11 -070037 // Part 3.
jvanverthd1e72872015-04-20 12:29:37 -070038 kHeaderOffset = GrGLProgramDesc::kHeaderOffset,
joshualitt71c92602015-01-14 08:12:47 -080039 kHeaderSize = SkAlign4(sizeof(KeyHeader)),
bsalomon929f29a2014-07-17 07:55:11 -070040 // Part 4.
egdanielc67870c2014-11-26 08:50:50 -080041 // This is the offset into the backenend specific part of the key, which includes
42 // per-processor keys.
43 kProcessorKeysOffset = kHeaderOffset + kHeaderSize,
bsalomon@google.com2db3ded2013-05-22 14:34:04 +000044 };
45
joshualitt79f8fae2014-10-28 17:59:26 -070046 /**
47 * Builds a GL specific program descriptor
48 *
joshualitt873ad0e2015-01-20 09:08:51 -080049 * @param GrPrimitiveProcessor The geometry
egdaniel8dd688b2015-01-22 10:16:09 -080050 * @param GrPipeline The optimized drawstate. The descriptor will represent a program
joshualitt79f8fae2014-10-28 17:59:26 -070051 * which this optstate can use to draw with. The optstate contains
52 * general draw information, as well as the specific color, geometry,
53 * and coverage stages which will be used to generate the GL Program for
54 * this optstate.
bsalomon7f9b2e42016-01-12 13:29:26 -080055 * @param GrGLSLCaps Capabilities of the GLSL backend.
joshualitt79f8fae2014-10-28 17:59:26 -070056 * @param GrProgramDesc The built and finalized descriptor
57 **/
joshualitt873ad0e2015-01-20 09:08:51 -080058 static bool Build(GrProgramDesc*,
59 const GrPrimitiveProcessor&,
egdaniel8dd688b2015-01-22 10:16:09 -080060 const GrPipeline&,
bsalomon7f9b2e42016-01-12 13:29:26 -080061 const GrGLSLCaps&);
bsalomon@google.com31ec7982013-03-27 18:14:57 +000062};
63
64#endif