Add caps and GL API for buffer texture
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1784063003
Review URL: https://codereview.chromium.org/1784063003
diff --git a/src/gpu/gl/GrGLAssembleInterface.cpp b/src/gpu/gl/GrGLAssembleInterface.cpp
index 27597b2..6672d22 100644
--- a/src/gpu/gl/GrGLAssembleInterface.cpp
+++ b/src/gpu/gl/GrGLAssembleInterface.cpp
@@ -205,6 +205,9 @@
GET_PROC(StencilMaskSeparate);
GET_PROC(StencilOp);
GET_PROC(StencilOpSeparate);
+ if (glVer >= GR_GL_VER(3,1)) {
+ GET_PROC(TexBuffer);
+ }
GET_PROC(TexImage2D);
GET_PROC(TexParameteri);
GET_PROC(TexParameteriv);
@@ -491,6 +494,9 @@
GET_PROC_SUFFIX(MapNamedBufferRange, EXT);
GET_PROC_SUFFIX(FlushMappedNamedBufferRange, EXT);
}
+ if (glVer >= GR_GL_VER(3,1)) {
+ GET_PROC_SUFFIX(TextureBuffer, EXT);
+ }
}
if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_KHR_debug")) {
@@ -643,6 +649,15 @@
GET_PROC(StencilMaskSeparate);
GET_PROC(StencilOp);
GET_PROC(StencilOpSeparate);
+
+ if (version >= GR_GL_VER(3,2)) {
+ GET_PROC(TexBuffer);
+ } else if (extensions.has("GL_OES_texture_buffer")) {
+ GET_PROC_SUFFIX(TexBuffer, OES);
+ } else if (extensions.has("GL_EXT_texture_buffer")) {
+ GET_PROC_SUFFIX(TexBuffer, EXT);
+ }
+
GET_PROC(TexImage2D);
GET_PROC(TexParameteri);
GET_PROC(TexParameteriv);
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 96a75b2..dfcde60 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -717,6 +717,22 @@
}
}
+ if (kGL_GrGLStandard == standard) {
+ glslCaps->fBufferTextureSupport = ctxInfo.version() > GR_GL_VER(3, 1) &&
+ ctxInfo.glslGeneration() >= k330_GrGLSLGeneration;
+ } else {
+ if (ctxInfo.version() > GR_GL_VER(3, 2) &&
+ ctxInfo.glslGeneration() >= k320es_GrGLSLGeneration) {
+ glslCaps->fBufferTextureSupport = true;
+ } else if (ctxInfo.hasExtension("GL_OES_texture_buffer")) {
+ glslCaps->fBufferTextureSupport = true;
+ glslCaps->fBufferTextureExtensionString = "GL_OES_texture_buffer";
+ } else if (ctxInfo.hasExtension("GL_EXT_texture_buffer")) {
+ glslCaps->fBufferTextureSupport = true;
+ glslCaps->fBufferTextureExtensionString = "GL_EXT_texture_buffer";
+ }
+ }
+
// The Tegra3 compiler will sometimes never return if we have min(abs(x), 1.0), so we must do
// the abs first in a separate expression.
if (kTegra3_GrGLRenderer == ctxInfo.renderer()) {
diff --git a/src/gpu/gl/GrGLCreateNullInterface.cpp b/src/gpu/gl/GrGLCreateNullInterface.cpp
index 17f305b..dd48bd8 100644
--- a/src/gpu/gl/GrGLCreateNullInterface.cpp
+++ b/src/gpu/gl/GrGLCreateNullInterface.cpp
@@ -435,6 +435,7 @@
functions->fStencilMaskSeparate = noOpGLStencilMaskSeparate;
functions->fStencilOp = noOpGLStencilOp;
functions->fStencilOpSeparate = noOpGLStencilOpSeparate;
+ functions->fTexBuffer = noOpGLTexBuffer;
functions->fTexImage2D = noOpGLTexImage2D;
functions->fTexParameteri = noOpGLTexParameteri;
functions->fTexParameteriv = noOpGLTexParameteriv;
diff --git a/src/gpu/gl/GrGLDefines.h b/src/gpu/gl/GrGLDefines.h
index 2553002..cd73be4 100644
--- a/src/gpu/gl/GrGLDefines.h
+++ b/src/gpu/gl/GrGLDefines.h
@@ -109,6 +109,7 @@
#define GR_GL_ARRAY_BUFFER 0x8892
#define GR_GL_ELEMENT_ARRAY_BUFFER 0x8893
#define GR_GL_DRAW_INDIRECT_BUFFER 0x8F3F
+#define GR_GL_TEXTURE_BUFFER 0x8C2A
#define GR_GL_ARRAY_BUFFER_BINDING 0x8894
#define GR_GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
#define GR_GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43
@@ -236,6 +237,7 @@
#define GR_GL_RENDERBUFFER_COLOR_SAMPLES 0x8E10
#define GR_GL_MAX_MULTISAMPLE_COVERAGE_MODES 0x8E11
#define GR_GL_MULTISAMPLE_COVERAGE_MODES 0x8E12
+#define GR_GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B
/* GetTextureParameter */
/* GL_TEXTURE_MAG_FILTER */
diff --git a/src/gpu/gl/GrGLInterface.cpp b/src/gpu/gl/GrGLInterface.cpp
index 84c51fb..728fb3f 100644
--- a/src/gpu/gl/GrGLInterface.cpp
+++ b/src/gpu/gl/GrGLInterface.cpp
@@ -424,6 +424,21 @@
}
if (kGL_GrGLStandard == fStandard) {
+ if (glVer >= GR_GL_VER(3,1)) {
+ if (nullptr == fFunctions.fTexBuffer) {
+ RETURN_FALSE_INTERFACE;
+ }
+ }
+ } else {
+ if (glVer >= GR_GL_VER(3,2) || fExtensions.has("GL_OES_texture_buffer") ||
+ fExtensions.has("GL_EXT_texture_buffer")) {
+ if (nullptr == fFunctions.fTexBuffer) {
+ RETURN_FALSE_INTERFACE;
+ }
+ }
+ }
+
+ if (kGL_GrGLStandard == fStandard) {
if (glVer >= GR_GL_VER(3, 0) || fExtensions.has("GL_ARB_vertex_array_object")) {
if (nullptr == fFunctions.fBindVertexArray ||
nullptr == fFunctions.fDeleteVertexArrays ||
@@ -746,6 +761,11 @@
RETURN_FALSE_INTERFACE
}
}
+ if (glVer >= GR_GL_VER(3,1)) {
+ if (nullptr == fFunctions.fTextureBuffer) {
+ RETURN_FALSE_INTERFACE;
+ }
+ }
}
if ((kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,3)) ||
diff --git a/src/gpu/gl/GrGLNoOpInterface.cpp b/src/gpu/gl/GrGLNoOpInterface.cpp
index 5d094e0..16a4fc6 100644
--- a/src/gpu/gl/GrGLNoOpInterface.cpp
+++ b/src/gpu/gl/GrGLNoOpInterface.cpp
@@ -242,6 +242,11 @@
GrGLenum zpass) {
}
+GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexBuffer(GrGLenum target,
+ GrGLint internalformat,
+ GrGLuint buffer) {
+}
+
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexImage2D(GrGLenum target,
GrGLint level,
GrGLint internalformat,
diff --git a/src/gpu/gl/GrGLNoOpInterface.h b/src/gpu/gl/GrGLNoOpInterface.h
index 23168e2..f81003b 100644
--- a/src/gpu/gl/GrGLNoOpInterface.h
+++ b/src/gpu/gl/GrGLNoOpInterface.h
@@ -164,6 +164,10 @@
GrGLenum zfail,
GrGLenum zpass);
+GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexBuffer(GrGLenum target,
+ GrGLint internalformat,
+ GrGLuint buffer);
+
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexImage2D(GrGLenum target,
GrGLint level,
GrGLint internalformat,
diff --git a/src/gpu/gl/SkNullGLContext.cpp b/src/gpu/gl/SkNullGLContext.cpp
index 33f9a0a..c6e01c3 100644
--- a/src/gpu/gl/SkNullGLContext.cpp
+++ b/src/gpu/gl/SkNullGLContext.cpp
@@ -484,6 +484,7 @@
functions->fStencilMaskSeparate = noOpGLStencilMaskSeparate;
functions->fStencilOp = noOpGLStencilOp;
functions->fStencilOpSeparate = noOpGLStencilOpSeparate;
+ functions->fTexBuffer = noOpGLTexBuffer;
functions->fTexImage2D = noOpGLTexImage2D;
functions->fTexParameteri = noOpGLTexParameteri;
functions->fTexParameteriv = noOpGLTexParameteriv;
diff --git a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
index 23e0d7e..d8418fd 100644
--- a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
+++ b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
@@ -926,6 +926,7 @@
functions->fStencilMaskSeparate = noOpGLStencilMaskSeparate;
functions->fStencilOp = noOpGLStencilOp;
functions->fStencilOpSeparate = noOpGLStencilOpSeparate;
+ functions->fTexBuffer = noOpGLTexBuffer;
functions->fTexImage2D = noOpGLTexImage2D;
functions->fTexParameteri = noOpGLTexParameteri;
functions->fTexParameteriv = noOpGLTexParameteriv;
diff --git a/src/gpu/glsl/GrGLSLCaps.cpp b/src/gpu/glsl/GrGLSLCaps.cpp
index 189b766..f142741 100755
--- a/src/gpu/glsl/GrGLSLCaps.cpp
+++ b/src/gpu/glsl/GrGLSLCaps.cpp
@@ -29,11 +29,13 @@
fSampleVariablesSupport = false;
fSampleMaskOverrideCoverageSupport = false;
fExternalTextureSupport = false;
+ fBufferTextureSupport = false;
fVersionDeclString = nullptr;
fShaderDerivativeExtensionString = nullptr;
fFragCoordConventionsExtensionString = nullptr;
fSecondaryOutputExtensionString = nullptr;
fExternalTextureExtensionString = nullptr;
+ fBufferTextureExtensionString = nullptr;
fNoPerspectiveInterpolationExtensionString = nullptr;
fMultisampleInterpolationExtensionString = nullptr;
fSampleVariablesExtensionString = nullptr;
@@ -80,6 +82,7 @@
r.appendf("Sample mask override coverage support: %s\n", (fSampleMaskOverrideCoverageSupport ?
"YES" : "NO"));
r.appendf("External texture support: %s\n", (fExternalTextureSupport ? "YES" : "NO"));
+ r.appendf("Buffer texture support: %s\n", (fBufferTextureSupport ? "YES" : "NO"));
r.appendf("Max VS Samplers: %d\n", fMaxVertexSamplers);
r.appendf("Max GS Samplers: %d\n", fMaxGeometrySamplers);
r.appendf("Max FS Samplers: %d\n", fMaxFragmentSamplers);
diff --git a/src/gpu/glsl/GrGLSLCaps.h b/src/gpu/glsl/GrGLSLCaps.h
index f907be2..f54c61d 100755
--- a/src/gpu/glsl/GrGLSLCaps.h
+++ b/src/gpu/glsl/GrGLSLCaps.h
@@ -66,6 +66,8 @@
bool externalTextureSupport() const { return fExternalTextureSupport; }
+ bool bufferTextureSupport() const { return fBufferTextureSupport; }
+
AdvBlendEqInteraction advBlendEqInteraction() const { return fAdvBlendEqInteraction; }
bool mustEnableAdvBlendEqs() const {
@@ -118,6 +120,11 @@
return fExternalTextureExtensionString;
}
+ const char* bufferTextureExtensionString() const {
+ SkASSERT(this->bufferTextureSupport());
+ return fBufferTextureExtensionString;
+ }
+
const char* noperspectiveInterpolationExtensionString() const {
SkASSERT(this->noperspectiveInterpolationSupport());
return fNoPerspectiveInterpolationExtensionString;
@@ -179,6 +186,7 @@
bool fSampleVariablesSupport : 1;
bool fSampleMaskOverrideCoverageSupport : 1;
bool fExternalTextureSupport : 1;
+ bool fBufferTextureSupport : 1;
// Used for specific driver bug work arounds
bool fCanUseMinAndAbsTogether : 1;
@@ -190,6 +198,7 @@
const char* fFragCoordConventionsExtensionString;
const char* fSecondaryOutputExtensionString;
const char* fExternalTextureExtensionString;
+ const char* fBufferTextureExtensionString;
const char* fNoPerspectiveInterpolationExtensionString;
const char* fMultisampleInterpolationExtensionString;
const char* fSampleVariablesExtensionString;