bsalomon@google.com | 31ec798 | 2013-03-27 18:14:57 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
joshualitt | 79f8fae | 2014-10-28 17:59:26 -0700 | [diff] [blame] | 11 | #include "GrColor.h" |
| 12 | #include "GrProgramDesc.h" |
commit-bot@chromium.org | 0a6fe71 | 2014-04-23 19:26:26 +0000 | [diff] [blame] | 13 | #include "GrGpu.h" |
joshualitt | 79f8fae | 2014-10-28 17:59:26 -0700 | [diff] [blame] | 14 | #include "GrTypesPriv.h" |
bsalomon@google.com | 31ec798 | 2013-03-27 18:14:57 +0000 | [diff] [blame] | 15 | |
bsalomon | 861e103 | 2014-12-16 07:33:49 -0800 | [diff] [blame] | 16 | class GrGLGpu; |
jvanverth | d1e7287 | 2015-04-20 12:29:37 -0700 | [diff] [blame] | 17 | class GrGLProgramDescBuilder; |
| 18 | |
| 19 | class GrGLProgramDesc : public GrProgramDesc { |
| 20 | friend class GrGLProgramDescBuilder; |
| 21 | }; |
bsalomon@google.com | 31ec798 | 2013-03-27 18:14:57 +0000 | [diff] [blame] | 22 | |
joshualitt | 79f8fae | 2014-10-28 17:59:26 -0700 | [diff] [blame] | 23 | /** |
| 24 | * This class can be used to build a GrProgramDesc. It also provides helpers for accessing |
| 25 | * GL specific info in the header. |
| 26 | */ |
| 27 | class GrGLProgramDescBuilder { |
bsalomon@google.com | 31ec798 | 2013-03-27 18:14:57 +0000 | [diff] [blame] | 28 | public: |
joshualitt | 71c9260 | 2015-01-14 08:12:47 -0800 | [diff] [blame] | 29 | typedef GrProgramDesc::KeyHeader KeyHeader; |
joshualitt | 79f8fae | 2014-10-28 17:59:26 -0700 | [diff] [blame] | 30 | // The key, stored in fKey, is composed of five parts(first 2 are defined in the key itself): |
bsalomon | 848faf0 | 2014-07-11 10:01:02 -0700 | [diff] [blame] | 31 | // 1. uint32_t for total key length. |
| 32 | // 2. uint32_t for a checksum. |
| 33 | // 3. Header struct defined above. |
egdaniel | c67870c | 2014-11-26 08:50:50 -0800 | [diff] [blame] | 34 | // 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.com | 2db3ded | 2013-05-22 14:34:04 +0000 | [diff] [blame] | 36 | enum { |
bsalomon | 929f29a | 2014-07-17 07:55:11 -0700 | [diff] [blame] | 37 | // Part 3. |
jvanverth | d1e7287 | 2015-04-20 12:29:37 -0700 | [diff] [blame] | 38 | kHeaderOffset = GrGLProgramDesc::kHeaderOffset, |
joshualitt | 71c9260 | 2015-01-14 08:12:47 -0800 | [diff] [blame] | 39 | kHeaderSize = SkAlign4(sizeof(KeyHeader)), |
bsalomon | 929f29a | 2014-07-17 07:55:11 -0700 | [diff] [blame] | 40 | // Part 4. |
egdaniel | c67870c | 2014-11-26 08:50:50 -0800 | [diff] [blame] | 41 | // This is the offset into the backenend specific part of the key, which includes |
| 42 | // per-processor keys. |
| 43 | kProcessorKeysOffset = kHeaderOffset + kHeaderSize, |
bsalomon@google.com | 2db3ded | 2013-05-22 14:34:04 +0000 | [diff] [blame] | 44 | }; |
| 45 | |
joshualitt | 79f8fae | 2014-10-28 17:59:26 -0700 | [diff] [blame] | 46 | /** |
| 47 | * Builds a GL specific program descriptor |
| 48 | * |
joshualitt | 873ad0e | 2015-01-20 09:08:51 -0800 | [diff] [blame] | 49 | * @param GrPrimitiveProcessor The geometry |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 50 | * @param GrPipeline The optimized drawstate. The descriptor will represent a program |
joshualitt | 79f8fae | 2014-10-28 17:59:26 -0700 | [diff] [blame] | 51 | * 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. |
bsalomon | 7f9b2e4 | 2016-01-12 13:29:26 -0800 | [diff] [blame] | 55 | * @param GrGLSLCaps Capabilities of the GLSL backend. |
joshualitt | 79f8fae | 2014-10-28 17:59:26 -0700 | [diff] [blame] | 56 | * @param GrProgramDesc The built and finalized descriptor |
| 57 | **/ |
joshualitt | 873ad0e | 2015-01-20 09:08:51 -0800 | [diff] [blame] | 58 | static bool Build(GrProgramDesc*, |
| 59 | const GrPrimitiveProcessor&, |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 60 | const GrPipeline&, |
bsalomon | 7f9b2e4 | 2016-01-12 13:29:26 -0800 | [diff] [blame] | 61 | const GrGLSLCaps&); |
bsalomon@google.com | 31ec798 | 2013-03-27 18:14:57 +0000 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | #endif |