aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/GrGLProgram.h
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-06-08 18:05:20 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-08 22:32:02 +0000
commit802cb318f695d5c3ade20b6424c97ea548a929b2 (patch)
tree964cb86d42d1d3e0e2ffb970364622b902733a44 /src/gpu/gl/GrGLProgram.h
parent65b7bfcf61c5d925bf0066a2b40dd6ef7cf82595 (diff)
Stop passing GrPrimitiveProcessor to GrMesh::sendToGpu.
It is currently used in GrGLGpu::setupGeometry. Instead: 1) Make GrMesh track whether primitive restart should be enabled. 2) Make GrGLProgram track program attributes. Change-Id: Ice411a495961fcbc3cedc81e8ae0583537f42153 Reviewed-on: https://skia-review.googlesource.com/132267 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'src/gpu/gl/GrGLProgram.h')
-rw-r--r--src/gpu/gl/GrGLProgram.h40
1 files changed, 31 insertions, 9 deletions
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index a43e4f4294..6ea1f2cbf9 100644
--- a/src/gpu/gl/GrGLProgram.h
+++ b/src/gpu/gl/GrGLProgram.h
@@ -10,6 +10,7 @@
#define GrGLProgram_DEFINED
#include "GrGLProgramDataManager.h"
+#include "GrPrimitiveProcessor.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "glsl/GrGLSLUniformHandler.h"
@@ -22,16 +23,23 @@ class GrRenderTargetProxy;
class GrResourceIOProcessor;
/**
- * This class manages a GPU program and records per-program information.
- * We can specify the attribute locations so that they are constant
- * across our shaders. But the driver determines the uniform locations
- * at link time. We don't need to remember the sampler uniform location
- * because we will bind a texture slot to it and never change it
- * Uniforms are program-local so we can't rely on fHWState to hold the
- * previous uniform state after a program change.
+ * This class manages a GPU program and records per-program information. It also records the vertex
+ * and instance attribute layouts that are to be used with the program.
*/
class GrGLProgram : public SkRefCnt {
public:
+ /**
+ * This class has its own Attribute representation as it does not need the name and we don't
+ * want to worry about copying the name string to memory with life time of GrGLProgram.
+ * Additionally, these store the attribute location.
+ */
+ struct Attribute {
+ GrVertexAttribType fType;
+ int fOffset;
+ GrGLint fLocation;
+ GrPrimitiveProcessor::Attribute::InputRate fInputRate;
+ };
+
using UniformHandle = GrGLSLProgramDataManager::UniformHandle;
using UniformInfoArray = GrGLProgramDataManager::UniformInfoArray;
using VaryingInfoArray = GrGLProgramDataManager::VaryingInfoArray;
@@ -46,7 +54,11 @@ public:
std::unique_ptr<GrGLSLPrimitiveProcessor> geometryProcessor,
std::unique_ptr<GrGLSLXferProcessor> xferProcessor,
std::unique_ptr<std::unique_ptr<GrGLSLFragmentProcessor>[]> fragmentProcessors,
- int fragmentProcessorCnt);
+ int fragmentProcessorCnt,
+ std::unique_ptr<Attribute[]>,
+ int attributeCnt,
+ int vertexStride,
+ int instanceStride);
~GrGLProgram();
@@ -109,6 +121,11 @@ public:
* ensures that any textures requiring mipmaps have their mipmaps correctly built.
*/
void generateMipmaps(const GrPrimitiveProcessor&, const GrPipeline&);
+ int vertexStride() const { return fVertexStride; }
+ int instanceStride() const { return fInstanceStride; }
+
+ int numAttributes() const { return fAttributeCnt; }
+ const Attribute& attribute(int i) const { return fAttributes[i]; }
private:
// A helper to loop over effects, set the transforms (via subclass) and bind textures
@@ -130,11 +147,16 @@ private:
GrGLuint fProgramID;
// the installed effects
- std::unique_ptr<GrGLSLPrimitiveProcessor> fGeometryProcessor;
+ std::unique_ptr<GrGLSLPrimitiveProcessor> fPrimitiveProcessor;
std::unique_ptr<GrGLSLXferProcessor> fXferProcessor;
std::unique_ptr<std::unique_ptr<GrGLSLFragmentProcessor>[]> fFragmentProcessors;
int fFragmentProcessorCnt;
+ std::unique_ptr<Attribute[]> fAttributes;
+ int fAttributeCnt;
+ int fVertexStride;
+ int fInstanceStride;
+
GrGLGpu* fGpu;
GrGLProgramDataManager fProgramDataManager;