| 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; |
| bsalomon@google.com | 31ec798 | 2013-03-27 18:14:57 +0000 | [diff] [blame] | 17 | |
| joshualitt | 79f8fae | 2014-10-28 17:59:26 -0700 | [diff] [blame] | 18 | /** |
| 19 | * This class can be used to build a GrProgramDesc. It also provides helpers for accessing |
| 20 | * GL specific info in the header. |
| 21 | */ |
| 22 | class GrGLProgramDescBuilder { |
| bsalomon@google.com | 31ec798 | 2013-03-27 18:14:57 +0000 | [diff] [blame] | 23 | public: |
| joshualitt | 71c9260 | 2015-01-14 08:12:47 -0800 | [diff] [blame] | 24 | typedef GrProgramDesc::KeyHeader KeyHeader; |
| joshualitt | 79f8fae | 2014-10-28 17:59:26 -0700 | [diff] [blame] | 25 | // 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] | 26 | // 1. uint32_t for total key length. |
| 27 | // 2. uint32_t for a checksum. |
| 28 | // 3. Header struct defined above. |
| egdaniel | c67870c | 2014-11-26 08:50:50 -0800 | [diff] [blame] | 29 | // 4. Backend-specific information including per-processor keys and their key lengths. |
| 30 | // 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] | 31 | enum { |
| bsalomon | 929f29a | 2014-07-17 07:55:11 -0700 | [diff] [blame] | 32 | // Part 3. |
| joshualitt | 79f8fae | 2014-10-28 17:59:26 -0700 | [diff] [blame] | 33 | kHeaderOffset = GrProgramDesc::kHeaderOffset, |
| joshualitt | 71c9260 | 2015-01-14 08:12:47 -0800 | [diff] [blame] | 34 | kHeaderSize = SkAlign4(sizeof(KeyHeader)), |
| bsalomon | 929f29a | 2014-07-17 07:55:11 -0700 | [diff] [blame] | 35 | // Part 4. |
| egdaniel | c67870c | 2014-11-26 08:50:50 -0800 | [diff] [blame] | 36 | // This is the offset into the backenend specific part of the key, which includes |
| 37 | // per-processor keys. |
| 38 | kProcessorKeysOffset = kHeaderOffset + kHeaderSize, |
| bsalomon@google.com | 2db3ded | 2013-05-22 14:34:04 +0000 | [diff] [blame] | 39 | }; |
| 40 | |
| joshualitt | 79f8fae | 2014-10-28 17:59:26 -0700 | [diff] [blame] | 41 | /** |
| 42 | * Builds a GL specific program descriptor |
| 43 | * |
| joshualitt | 873ad0e | 2015-01-20 09:08:51 -0800 | [diff] [blame] | 44 | * @param GrPrimitiveProcessor The geometry |
| egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame^] | 45 | * @param GrPipeline The optimized drawstate. The descriptor will represent a program |
| joshualitt | 79f8fae | 2014-10-28 17:59:26 -0700 | [diff] [blame] | 46 | * which this optstate can use to draw with. The optstate contains |
| 47 | * general draw information, as well as the specific color, geometry, |
| 48 | * and coverage stages which will be used to generate the GL Program for |
| 49 | * this optstate. |
| 50 | * @param DescInfo A descriptor info struct, generated by the optstate, which contains a number |
| 51 | * of important facts about the program the built descriptor will represent |
| bsalomon | 861e103 | 2014-12-16 07:33:49 -0800 | [diff] [blame] | 52 | * @param GrGLGpu A GL Gpu, the caps and Gpu object are used to output processor specific |
| joshualitt | 79f8fae | 2014-10-28 17:59:26 -0700 | [diff] [blame] | 53 | * parts of the descriptor. |
| 54 | * @param GrDeviceCoordTexture A dstCopy texture, which may be null if frame buffer fetch is |
| 55 | * supported |
| 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&, |
| joshualitt | 79f8fae | 2014-10-28 17:59:26 -0700 | [diff] [blame] | 61 | const GrProgramDesc::DescInfo&, |
| joshualitt | 873ad0e | 2015-01-20 09:08:51 -0800 | [diff] [blame] | 62 | const GrGLGpu*, |
| 63 | const GrBatchTracker&); |
| bsalomon@google.com | 31ec798 | 2013-03-27 18:14:57 +0000 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | #endif |