Index: src/gpu/GrProgramDesc.h |
diff --git a/src/gpu/GrProgramDesc.h b/src/gpu/GrProgramDesc.h |
index b17d146a8c2cacfe9613ede7a2a1c2ef6fae40f7..33667f4d77d52e8983e8edba519fba3d11a5f534 100644 |
--- a/src/gpu/GrProgramDesc.h |
+++ b/src/gpu/GrProgramDesc.h |
@@ -13,13 +13,33 @@ |
#include "SkOpts.h" |
#include "SkTArray.h" |
-/** This class describes a program to generate. It also serves as a program cache key. Very little |
- of this is GL-specific. The GL-specific parts could be factored out into a subclass. */ |
+class GrGLSLCaps; |
+class GrPipeline; |
+class GrPrimitiveProcessor; |
+ |
+/** This class describes a program to generate. It also serves as a program cache key */ |
class GrProgramDesc { |
public: |
// Creates an uninitialized key that must be populated by GrGpu::buildProgramDesc() |
GrProgramDesc() {} |
+ /** |
+ * Builds a program descriptor |
bsalomon
2016/09/07 13:41:15
Note that finalize must be called after Build()?
egdaniel
2016/09/07 13:53:38
Done.
|
+ * |
+ * @param GrPrimitiveProcessor The geometry |
+ * @param GrPipeline The optimized drawstate. The descriptor will represent a program |
+ * which this optstate can use to draw with. The optstate contains |
+ * general draw information, as well as the specific color, geometry, |
+ * and coverage stages which will be used to generate the GL Program for |
+ * this optstate. |
+ * @param GrGLSLCaps Capabilities of the GLSL backend. |
+ * @param GrProgramDesc The built and finalized descriptor |
+ **/ |
+ static bool Build(GrProgramDesc*, |
+ const GrPrimitiveProcessor&, |
+ const GrPipeline&, |
+ const GrGLSLCaps&); |
+ |
// Returns this as a uint32_t array to be used as a key in the program cache. |
const uint32_t* asKey() const { |
return reinterpret_cast<const uint32_t*>(fKey.begin()); |
@@ -97,15 +117,6 @@ public: |
// This should really only be used internally, base classes should return their own headers |
const KeyHeader& header() const { return *this->atOffset<KeyHeader, kHeaderOffset>(); } |
-protected: |
- template<typename T, size_t OFFSET> T* atOffset() { |
- return reinterpret_cast<T*>(reinterpret_cast<intptr_t>(fKey.begin()) + OFFSET); |
- } |
- |
- template<typename T, size_t OFFSET> const T* atOffset() const { |
- return reinterpret_cast<const T*>(reinterpret_cast<intptr_t>(fKey.begin()) + OFFSET); |
- } |
- |
void finalize() { |
int keyLength = fKey.count(); |
SkASSERT(0 == (keyLength % 4)); |
@@ -116,10 +127,19 @@ protected: |
*checksum = SkOpts::hash(fKey.begin(), keyLength); |
} |
+protected: |
+ template<typename T, size_t OFFSET> T* atOffset() { |
+ return reinterpret_cast<T*>(reinterpret_cast<intptr_t>(fKey.begin()) + OFFSET); |
+ } |
+ |
+ template<typename T, size_t OFFSET> const T* atOffset() const { |
+ return reinterpret_cast<const T*>(reinterpret_cast<intptr_t>(fKey.begin()) + OFFSET); |
+ } |
+ |
// The key, stored in fKey, is composed of four parts: |
// 1. uint32_t for total key length. |
// 2. uint32_t for a checksum. |
- // 3. Header struct defined above. Also room for extensions to the header |
+ // 3. Header struct defined above. |
// 4. A Backend specific payload. Room is preallocated for this |
bsalomon
2016/09/07 13:41:15
Update this to say part 4 is the per-processor key
egdaniel
2016/09/07 13:53:38
Done.
|
enum KeyOffsets { |
// Part 1. |
@@ -128,7 +148,11 @@ protected: |
kChecksumOffset = kLengthOffset + sizeof(uint32_t), |
// Part 3. |
kHeaderOffset = kChecksumOffset + sizeof(uint32_t), |
- kHeaderSize = SkAlign4(2 * sizeof(KeyHeader)), |
+ kHeaderSize = SkAlign4(sizeof(KeyHeader)), |
+ // Part 4. |
+ // This is the offset into the backenend specific part of the key, which includes |
+ // per-processor keys. |
+ kProcessorKeysOffset = kHeaderOffset + kHeaderSize, |
}; |
enum { |