Implement NV_path_rendering on OpenGL ES
Implement support for NV_path_rendering on OpenGL ES. Use
glProgramPathFragmentInputGenNV function call instead of glPathTexGenNV to
communicate transforms to fragment shader.
The intention is that the NVPR paths will be drawn with the same shader program
as non-NVPR geometry. For NVPR calls, the GPU will skip the vertex shader and
just run the fragment shader.
After program is linked, query the locations of the fragment shader inputs with
glGetResourceLocation. The location will be used to set the transforms with
glProgramPathFragmentInputGenNV.
The functions and their workings are documented in:
glProgramPathFragmentInputGenNV
https://www.opengl.org/registry/specs/NV/path_rendering.txt
(note: addition as of API version 1.3)
glGetResourceLocation
https://www.opengl.org/registry/specs/ARB/program_interface_query.txt
http://www.opengl.org/registry/doc/glspec44.core.pdf
(function is in core Open GL 4.4)
Note: glProgramPathFragmentInputGenNV could be used also for OpenGL. However,
using seems to trigger a bug in the driver. Disable this feature on OpenGL at
least until the driver is fixed and released. The bug manifests in shadertext
test, where the lower-left text pair is missing. Valgrind catches a bad read
for the test and causes the context to OOM reproducibly.
R=bsalomon@google.com, cdalton@nvidia.com, joshualitt@google.com, joshualitt@chromium.org
Author: kkinnunen@nvidia.com
Review URL: https://codereview.chromium.org/367643004
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index 3ab17d4..af28046 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -16,8 +16,8 @@
#include "GrContextFactory.h"
#include "GrDrawEffect.h"
#include "effects/GrConfigConversionEffect.h"
+#include "gl/GrGLPathRendering.h"
#include "gl/GrGpuGL.h"
-
#include "SkChecksum.h"
#include "SkRandom.h"
#include "Test.h"
@@ -42,7 +42,7 @@
bool dstRead = false;
bool fragPos = false;
- bool vertexCode = false;
+ bool vertexShader = false;
for (int s = 0; s < numStages; ++s) {
uint16_t* offsetAndSize = reinterpret_cast<uint16_t*>(fKey.begin() +
kEffectKeyOffsetsAndLengthOffset +
@@ -56,7 +56,7 @@
GrEffectKeyBuilder b(&fKey);
uint16_t effectKeySize;
if (!GetEffectKeyAndUpdateStats(*stages[s], gpu->glCaps(), useLocalCoords, &b,
- &effectKeySize, &dstRead, &fragPos, &vertexCode)) {
+ &effectKeySize, &dstRead, &fragPos, &vertexShader)) {
fKey.reset();
return false;
}
@@ -114,10 +114,10 @@
header->fFragPosKey = 0;
}
- header->fHasVertexCode = vertexCode ||
- useLocalCoords ||
- kAttribute_ColorInput == header->fColorInput ||
- kAttribute_ColorInput == header->fCoverageInput;
+ header->fRequiresVertexShader = vertexShader ||
+ useLocalCoords ||
+ kAttribute_ColorInput == header->fColorInput ||
+ kAttribute_ColorInput == header->fCoverageInput;
CoverageOutput coverageOutput;
bool illegalCoverageOutput;
@@ -178,7 +178,8 @@
SkAutoSTMalloc<8, const GrEffectStage*> stages(numStages);
- bool useFixedFunctionTexturing = this->shouldUseFixedFunctionTexturing();
+ bool useFixedFunctionPathRendering = this->glCaps().pathRenderingSupport() &&
+ this->glPathRendering()->texturingMode() == GrGLPathRendering::FixedFunction_TexturingMode;
for (int s = 0; s < numStages;) {
SkAutoTUnref<const GrEffect> effect(GrEffectTestFactory::CreateStage(
@@ -198,7 +199,7 @@
// If adding this effect would exceed the max texture coord set count then generate a
// new random effect.
- if (useFixedFunctionTexturing && !effect->hasVertexCode()) {
+ if (useFixedFunctionPathRendering && !effect->requiresVertexShader()) {
int numTransforms = effect->numTransforms();
if (currTextureCoordSet + numTransforms > this->glCaps().maxFixedFunctionTextureCoords()) {
continue;
@@ -206,7 +207,7 @@
currTextureCoordSet += numTransforms;
}
- useFixedFunctionTexturing = useFixedFunctionTexturing && !effect->hasVertexCode();
+ useFixedFunctionPathRendering = useFixedFunctionPathRendering && !effect->requiresVertexShader();
for (int i = 0; i < numAttribs; ++i) {
attribIndices[i] = currAttribIndex++;