Remove final usage of GrProgramDesc's header
This demotes GrProgramDesc to just being the program key while promoting GrProgramInfo as the exclusive source for live information about the program.
The GrProgramDesc is still a bit more than a simple program key though bc Vulkan shears off the non-Vulkan-specific portion to cache the SPIRV code.
Bug: skia:9455
Change-Id: Ica11e3df91b8c97794deebff3f5208d16aaf75c7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/254184
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrProgramDesc.h b/src/gpu/GrProgramDesc.h
index ce9b0e3..9d9ea00 100644
--- a/src/gpu/GrProgramDesc.h
+++ b/src/gpu/GrProgramDesc.h
@@ -18,17 +18,18 @@
class GrProgramInfo;
class GrShaderCaps;
-/** This class describes a program to generate. It also serves as a program cache key */
+/** This class is used to generate a generic program cache key. The Dawn, Metal and Vulkan
+ * backends derive backend-specific versions which add additional information.
+ */
class GrProgramDesc {
public:
- // Creates an uninitialized key that must be populated by GrGpu::buildProgramDesc()
+ // Creates an uninitialized key that must be populated by Build
GrProgramDesc() {}
/**
- * Builds a program descriptor. Before the descriptor can be used, the client must call finalize
- * on the filled in GrProgramDesc.
+ * Builds a program descriptor.
*
- * @param desc The built and finalized descriptor
+ * @param desc The built descriptor
* @param renderTarget The target of the draw
* @param programInfo Program information need to build the key
* @param caps the caps
@@ -85,10 +86,8 @@
return !(*this == other);
}
- // TODO: remove this use of the header
- bool hasPointSize() const { return this->header().fHasPointSize; }
-
protected:
+ // TODO: this should be removed and converted to just data added to the key
struct KeyHeader {
// Set to uniquely identify any swizzling of the shader's output color(s).
uint16_t fOutputSwizzle;
@@ -103,23 +102,16 @@
};
GR_STATIC_ASSERT(sizeof(KeyHeader) == 6);
- const KeyHeader& header() const { return *this->atOffset<KeyHeader, kHeaderOffset>(); }
-
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 two parts:
// 1. Header struct defined above.
// 2. A Backend specific payload which includes the per-processor keys.
enum KeyOffsets {
kHeaderOffset = 0,
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,
@@ -133,7 +125,6 @@
};
SkSTArray<kPreAllocSize, uint8_t, true>& key() { return fKey; }
- const SkSTArray<kPreAllocSize, uint8_t, true>& key() const { return fKey; }
private:
SkSTArray<kPreAllocSize, uint8_t, true> fKey;