aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/GrGLCaps.cpp
diff options
context:
space:
mode:
authorGravatar cdalton <cdalton@nvidia.com>2016-03-11 10:07:37 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-11 10:07:37 -0800
commit9c3f14327a38e79ab7d0cf30dfd9bf89676fde06 (patch)
treef4695cc85cf19bf471ed8c956083f2234f18d4e1 /src/gpu/gl/GrGLCaps.cpp
parent6b563156eb7ce05b51997695ec9ab2aedcc2e6b1 (diff)
Add support for vertex and geometry shader textures
Adds a visibility bitfield to GrTextureAccess that controls in which shaders the texture should be accessible. Also adds caps and validation to ensure we don't exceed texture limits. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1782583002 Review URL: https://codereview.chromium.org/1782583002
Diffstat (limited to 'src/gpu/gl/GrGLCaps.cpp')
-rw-r--r--src/gpu/gl/GrGLCaps.cpp41
1 files changed, 25 insertions, 16 deletions
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 5baed59f14..96a75b24d8 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -27,7 +27,6 @@ GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions,
fTransferBufferType = kNone_TransferBufferType;
fMaxFragmentUniformVectors = 0;
fMaxVertexAttributes = 0;
- fMaxFragmentTextureUnits = 0;
fUnpackRowLengthSupport = false;
fUnpackFlipYSupport = false;
fPackRowLengthSupport = false;
@@ -46,7 +45,6 @@ GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions,
fUseNonVBOVertexAndIndexDynamicData = false;
fIsCoreProfile = false;
fBindFragDataLocationSupport = false;
- fExternalTextureSupport = false;
fRectangleTextureSupport = false;
fTextureSwizzleSupport = false;
fSRGBWriteControl = false;
@@ -86,7 +84,6 @@ void GrGLCaps::init(const GrContextOptions& contextOptions,
}
}
GR_GL_GetIntegerv(gli, GR_GL_MAX_VERTEX_ATTRIBS, &fMaxVertexAttributes);
- GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_IMAGE_UNITS, &fMaxFragmentTextureUnits);
if (kGL_GrGLStandard == standard) {
fUnpackRowLengthSupport = true;
@@ -213,16 +210,6 @@ void GrGLCaps::init(const GrContextOptions& contextOptions,
fBindUniformLocationSupport = false;
#endif
- if (ctxInfo.hasExtension("GL_OES_EGL_image_external")) {
- if (ctxInfo.glslGeneration() == k110_GrGLSLGeneration) {
- fExternalTextureSupport = true;
- } else if (ctxInfo.hasExtension("GL_OES_EGL_image_external_essl3") ||
- ctxInfo.hasExtension("OES_EGL_image_external_essl3")) {
- // At least one driver has been found that has this extension without the "GL_" prefix.
- fExternalTextureSupport = true;
- }
- }
-
if (kGL_GrGLStandard == standard) {
if (version >= GR_GL_VER(3, 1) || ctxInfo.hasExtension("GL_ARB_texture_rectangle")) {
// We also require textureSize() support for rectangle 2D samplers which was added in
@@ -313,6 +300,20 @@ void GrGLCaps::init(const GrContextOptions& contextOptions,
glslCaps->fPLSPathRenderingSupport = false;
}
+ // Protect ourselves against tracking huge amounts of texture state.
+ static const uint8_t kMaxSaneSamplers = 32;
+ GrGLint maxSamplers;
+ GR_GL_GetIntegerv(gli, GR_GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &maxSamplers);
+ glslCaps->fMaxVertexSamplers = SkTMin<GrGLint>(kMaxSaneSamplers, maxSamplers);
+ if (glslCaps->fGeometryShaderSupport) {
+ GR_GL_GetIntegerv(gli, GR_GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS, &maxSamplers);
+ glslCaps->fMaxGeometrySamplers = SkTMin<GrGLint>(kMaxSaneSamplers, maxSamplers);
+ }
+ GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_IMAGE_UNITS, &maxSamplers);
+ glslCaps->fMaxFragmentSamplers = SkTMin<GrGLint>(kMaxSaneSamplers, maxSamplers);
+ GR_GL_GetIntegerv(gli, GR_GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxSamplers);
+ glslCaps->fMaxCombinedSamplers = SkTMin<GrGLint>(kMaxSaneSamplers, maxSamplers);
+
/**************************************************************************
* GrCaps fields
**************************************************************************/
@@ -698,7 +699,17 @@ void GrGLCaps::initGLSL(const GrGLContextInfo& ctxInfo) {
glslCaps->fSecondaryOutputExtensionString = "GL_EXT_blend_func_extended";
}
- if (fExternalTextureSupport) {
+ if (ctxInfo.hasExtension("GL_OES_EGL_image_external")) {
+ if (ctxInfo.glslGeneration() == k110_GrGLSLGeneration) {
+ glslCaps->fExternalTextureSupport = true;
+ } else if (ctxInfo.hasExtension("GL_OES_EGL_image_external_essl3") ||
+ ctxInfo.hasExtension("OES_EGL_image_external_essl3")) {
+ // At least one driver has been found that has this extension without the "GL_" prefix.
+ glslCaps->fExternalTextureSupport = true;
+ }
+ }
+
+ if (glslCaps->fExternalTextureSupport) {
if (ctxInfo.glslGeneration() == k110_GrGLSLGeneration) {
glslCaps->fExternalTextureExtensionString = "GL_OES_EGL_image_external";
} else {
@@ -1026,7 +1037,6 @@ SkString GrGLCaps::dump() const {
r.appendf("Invalidate FB Type: %s\n", kInvalidateFBTypeStr[fInvalidateFBType]);
r.appendf("Map Buffer Type: %s\n", kMapBufferTypeStr[fMapBufferType]);
r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors);
- r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits);
r.appendf("Max Vertex Attributes: %d\n", fMaxVertexAttributes);
r.appendf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES": "NO"));
r.appendf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO"));
@@ -1049,7 +1059,6 @@ SkString GrGLCaps::dump() const {
r.appendf("RGBA 8888 pixel ops are slow: %s\n", (fRGBA8888PixelsOpsAreSlow ? "YES" : "NO"));
r.appendf("Partial FBO read is slow: %s\n", (fPartialFBOReadIsSlow ? "YES" : "NO"));
r.appendf("Bind uniform location support: %s\n", (fBindUniformLocationSupport ? "YES" : "NO"));
- r.appendf("External texture support: %s\n", (fExternalTextureSupport ? "YES" : "NO"));
r.appendf("Rectangle texture support: %s\n", (fRectangleTextureSupport? "YES" : "NO"));
r.appendf("Texture swizzle support: %s\n", (fTextureSwizzleSupport ? "YES" : "NO"));