'<(skia_src_path)/gpu/GrPipelineBuilder.h',
'<(skia_src_path)/gpu/GrPrimitiveProcessor.cpp',
'<(skia_src_path)/gpu/GrPrimitiveProcessor.h',
+ '<(skia_src_path)/gpu/GrProgramDesc.cpp',
'<(skia_src_path)/gpu/GrProgramDesc.h',
'<(skia_src_path)/gpu/GrProgramElement.cpp',
'<(skia_src_path)/gpu/GrProcessor.cpp',
'<(skia_src_path)/gpu/glsl/GrGLSLProgramBuilder.h',
'<(skia_src_path)/gpu/glsl/GrGLSLProgramDataManager.cpp',
'<(skia_src_path)/gpu/glsl/GrGLSLProgramDataManager.h',
- '<(skia_src_path)/gpu/glsl/GrGLSLProgramDesc.cpp',
- '<(skia_src_path)/gpu/glsl/GrGLSLProgramDesc.h',
'<(skia_src_path)/gpu/glsl/GrGLSLSampler.h',
'<(skia_src_path)/gpu/glsl/GrGLSLShaderBuilder.cpp',
'<(skia_src_path)/gpu/glsl/GrGLSLShaderBuilder.h',
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "GrGLSLProgramDesc.h"
+#include "GrProgramDesc.h"
#include "GrProcessor.h"
#include "GrPipeline.h"
fp.numTransformsExclChildren()), b);
}
-bool GrGLSLProgramDescBuilder::Build(GrProgramDesc* desc,
- const GrPrimitiveProcessor& primProc,
- const GrPipeline& pipeline,
- const GrGLSLCaps& glslCaps) {
+bool GrProgramDesc::Build(GrProgramDesc* desc,
+ const GrPrimitiveProcessor& primProc,
+ const GrPipeline& pipeline,
+ const GrGLSLCaps& glslCaps) {
// The descriptor is used as a cache key. Thus when a field of the
// descriptor will not affect program generation (because of the attribute
// bindings in use or other descriptor field settings) it should be set
// to a canonical value to avoid duplicate programs with different keys.
- GrGLSLProgramDesc* glDesc = (GrGLSLProgramDesc*)desc;
-
GR_STATIC_ASSERT(0 == kProcessorKeysOffset % sizeof(uint32_t));
// Make room for everything up to the effect keys.
- glDesc->key().reset();
- glDesc->key().push_back_n(kProcessorKeysOffset);
+ desc->key().reset();
+ desc->key().push_back_n(kProcessorKeysOffset);
- GrProcessorKeyBuilder b(&glDesc->key());
+ GrProcessorKeyBuilder b(&desc->key());
primProc.getGLSLProcessorKey(glslCaps, &b);
if (!gen_meta_key(primProc, glslCaps, 0, &b)) {
- glDesc->key().reset();
+ desc->key().reset();
return false;
}
GrProcessor::RequiredFeatures requiredFeatures = primProc.requiredFeatures();
for (int i = 0; i < pipeline.numFragmentProcessors(); ++i) {
const GrFragmentProcessor& fp = pipeline.getFragmentProcessor(i);
if (!gen_frag_proc_and_meta_keys(primProc, fp, glslCaps, &b)) {
- glDesc->key().reset();
+ desc->key().reset();
return false;
}
requiredFeatures |= fp.requiredFeatures();
const GrXferProcessor& xp = pipeline.getXferProcessor();
xp.getGLSLProcessorKey(glslCaps, &b);
if (!gen_meta_key(xp, glslCaps, 0, &b)) {
- glDesc->key().reset();
+ desc->key().reset();
return false;
}
requiredFeatures |= xp.requiredFeatures();
// --------DO NOT MOVE HEADER ABOVE THIS LINE--------------------------------------------------
// Because header is a pointer into the dynamic array, we can't push any new data into the key
// below here.
- KeyHeader* header = glDesc->atOffset<KeyHeader, kHeaderOffset>();
+ KeyHeader* header = desc->atOffset<KeyHeader, kHeaderOffset>();
// make sure any padding in the header is zeroed.
memset(header, 0, kHeaderSize);
header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters();
header->fColorEffectCnt = pipeline.numColorFragmentProcessors();
header->fCoverageEffectCnt = pipeline.numCoverageFragmentProcessors();
- glDesc->finalize();
return true;
}
#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. Before the descriptor can be used, the client must call finalize
+ * on the returned GrProgramDesc.
+ *
+ * @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());
// 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));
*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
- // 4. A Backend specific payload. Room is preallocated for this
+ // 3. Header struct defined above.
+ // 4. A Backend specific payload which includes the per-processor keys.
enum KeyOffsets {
// Part 1.
kLengthOffset = 0,
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 {
#include "builders/GrGLProgramBuilder.h"
#include "GrProcessor.h"
+#include "GrProgramDesc.h"
#include "GrGLPathRendering.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLProgramDataManager.h"
-#include "glsl/GrGLSLProgramDesc.h"
#include "SkTSearch.h"
#ifdef PROGRAM_CACHE_STATS
#endif
// Get GrGLProgramDesc
- GrGLSLProgramDesc desc;
- if (!GrGLSLProgramDescBuilder::Build(&desc, primProc, pipeline, *gpu->glCaps().glslCaps())) {
+ GrProgramDesc desc;
+ if (!GrProgramDesc::Build(&desc, primProc, pipeline, *gpu->glCaps().glslCaps())) {
GrCapsDebugf(gpu->caps(), "Failed to gl program descriptor!\n");
return nullptr;
}
+ desc.finalize();
Entry* entry = nullptr;
#define GrGLProgram_DEFINED
#include "GrGLContext.h"
+#include "GrProgramDesc.h"
#include "GrGLTexture.h"
#include "GrGLProgramDataManager.h"
#include "glsl/GrGLSLProgramDataManager.h"
-#include "glsl/GrGLSLProgramDesc.h"
#include "glsl/GrGLSLUniformHandler.h"
#include "SkString.h"
#include "GrAutoLocaleSetter.h"
#include "GrCoordTransform.h"
#include "GrGLProgramBuilder.h"
+#include "GrProgramDesc.h"
#include "GrSwizzle.h"
#include "GrTexture.h"
#include "SkTraceEvent.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLGeometryProcessor.h"
#include "glsl/GrGLSLProgramDataManager.h"
-#include "glsl/GrGLSLProgramDesc.h"
#include "glsl/GrGLSLSampler.h"
#include "glsl/GrGLSLXferProcessor.h"
GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrPipeline& pipeline,
const GrPrimitiveProcessor& primProc,
- const GrGLSLProgramDesc& desc,
+ const GrProgramDesc& desc,
GrGLGpu* gpu) {
GrAutoLocaleSetter als("C");
GrGLProgramBuilder::GrGLProgramBuilder(GrGLGpu* gpu,
const GrPipeline& pipeline,
const GrPrimitiveProcessor& primProc,
- const GrGLSLProgramDesc& desc)
+ const GrProgramDesc& desc)
: INHERITED(pipeline, primProc, desc)
, fGpu(gpu)
, fVaryingHandler(this)
class GrFragmentProcessor;
class GrGLContextInfo;
-class GrGLSLProgramDesc;
+class GrProgramDesc;
class GrGLSLShaderBuilder;
class GrGLSLCaps;
*/
static GrGLProgram* CreateProgram(const GrPipeline&,
const GrPrimitiveProcessor&,
- const GrGLSLProgramDesc&,
+ const GrProgramDesc&,
GrGLGpu*);
const GrCaps* caps() const override;
private:
GrGLProgramBuilder(GrGLGpu*, const GrPipeline&, const GrPrimitiveProcessor&,
- const GrGLSLProgramDesc&);
+ const GrProgramDesc&);
bool compileAndAttachShaders(GrGLSLShaderBuilder& shader,
GrGLuint programId,
+++ /dev/null
-/*
-* Copyright 2016 Google Inc.
-*
-* Use of this source code is governed by a BSD-style license that can be
-* found in the LICENSE file.
-*/
-
-#ifndef GrGLSLProgramDesc_DEFINED
-#define GrGLSLProgramDesc_DEFINED
-
-#include "GrColor.h"
-#include "GrProgramDesc.h"
-#include "GrGpu.h"
-#include "GrTypesPriv.h"
-
-class GrGLSLProgramDescBuilder;
-
-class GrGLSLProgramDesc : public GrProgramDesc {
- friend class GrGLSLProgramDescBuilder;
-};
-
-/**
-* This class can be used to build a GrProgramDesc. It also provides helpers for accessing
-* GL specific info in the header.
-*/
-class GrGLSLProgramDescBuilder {
-public:
- typedef GrProgramDesc::KeyHeader KeyHeader;
- // The key, stored in fKey, is composed of five parts(first 2 are defined in the key itself):
- // 1. uint32_t for total key length.
- // 2. uint32_t for a checksum.
- // 3. Header struct defined above.
- // 4. Backend-specific information including per-processor keys and their key lengths.
- // Each processor's key is a variable length array of uint32_t.
- enum {
- // Part 3.
- kHeaderOffset = GrGLSLProgramDesc::kHeaderOffset,
- 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,
- };
-
- /**
- * Builds a GLSL specific program descriptor
- *
- * @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&);
-};
-
-#endif
#ifndef GrVkPipelineState_DEFINED
#define GrVkPipelineState_DEFINED
+#include "GrProgramDesc.h"
#include "GrStencilSettings.h"
#include "GrVkDescriptorSetManager.h"
#include "GrVkImage.h"
#include "GrVkPipelineStateDataManager.h"
#include "glsl/GrGLSLProgramBuilder.h"
-#include "glsl/GrGLSLProgramDesc.h"
#include "vk/GrVkDefines.h"
*/
struct Desc {
uint32_t fChecksum;
- GrGLSLProgramDesc fProgramDesc;
+ GrProgramDesc fProgramDesc;
enum {
kRenderPassKeyAlloc = 12, // This is typical color attachment with no stencil or msaa
GrVkPipelineStateBuilder::GrVkPipelineStateBuilder(GrVkGpu* gpu,
const GrPipeline& pipeline,
const GrPrimitiveProcessor& primProc,
- const GrGLSLProgramDesc& desc)
+ const GrProgramDesc& desc)
: INHERITED(pipeline, primProc, desc)
, fGpu(gpu)
, fVaryingHandler(this)
#include "vk/GrVkDefines.h"
+class GrProgramDesc;
class GrVkGpu;
class GrVkRenderPass;
-class GrGLSLProgramDesc;
class GrVkPipelineStateBuilder : public GrGLSLProgramBuilder {
public:
GrVkPipelineStateBuilder(GrVkGpu*,
const GrPipeline&,
const GrPrimitiveProcessor&,
- const GrGLSLProgramDesc&);
+ const GrProgramDesc&);
GrVkPipelineState* finalize(GrPrimitiveType primitiveType,
const GrVkRenderPass& renderPass,
#endif
// Get GrVkProgramDesc
GrVkPipelineState::Desc desc;
- if (!GrGLSLProgramDescBuilder::Build(&desc.fProgramDesc,
- primProc,
- pipeline,
- *fGpu->vkCaps().glslCaps())) {
+ if (!GrProgramDesc::Build(&desc.fProgramDesc, primProc, pipeline, *fGpu->vkCaps().glslCaps())) {
GrCapsDebugf(fGpu->caps(), "Failed to build vk program descriptor!\n");
return nullptr;
}
+ desc.fProgramDesc.finalize();
// Get vulkan specific descriptor key
GrVkPipelineState::BuildStateKey(pipeline, primitiveType, &desc.fStateKey);