aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar cdalton <cdalton@nvidia.com>2016-03-11 14:07:38 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-11 14:07:38 -0800
commitc04ce676d4516a8c64e29e1f60bb72cd2c6c0a59 (patch)
tree5c432eac89ac2915f8ef22f4f2701516e0a85de2
parent5f2d8e28c4f8ec0ead92eb613254063ace4e90b4 (diff)
Add caps and GL API for buffer texture
-rw-r--r--include/gpu/gl/GrGLFunctions.h3
-rw-r--r--include/gpu/gl/GrGLInterface.h3
-rw-r--r--src/gpu/gl/GrGLAssembleInterface.cpp15
-rw-r--r--src/gpu/gl/GrGLCaps.cpp16
-rw-r--r--src/gpu/gl/GrGLCreateNullInterface.cpp1
-rw-r--r--src/gpu/gl/GrGLDefines.h2
-rw-r--r--src/gpu/gl/GrGLInterface.cpp20
-rw-r--r--src/gpu/gl/GrGLNoOpInterface.cpp5
-rw-r--r--src/gpu/gl/GrGLNoOpInterface.h4
-rw-r--r--src/gpu/gl/SkNullGLContext.cpp1
-rw-r--r--src/gpu/gl/debug/GrGLCreateDebugInterface.cpp1
-rwxr-xr-xsrc/gpu/glsl/GrGLSLCaps.cpp3
-rwxr-xr-xsrc/gpu/glsl/GrGLSLCaps.h9
13 files changed, 83 insertions, 0 deletions
diff --git a/include/gpu/gl/GrGLFunctions.h b/include/gpu/gl/GrGLFunctions.h
index a6b9b9a623..fcd89e1406 100644
--- a/include/gpu/gl/GrGLFunctions.h
+++ b/include/gpu/gl/GrGLFunctions.h
@@ -144,6 +144,7 @@ typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLStencilMaskProc)(GrGLuint mask);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLStencilMaskSeparateProc)(GrGLenum face, GrGLuint mask);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLStencilOpProc)(GrGLenum fail, GrGLenum zfail, GrGLenum zpass);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLStencilOpSeparateProc)(GrGLenum face, GrGLenum fail, GrGLenum zfail, GrGLenum zpass);
+typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLTexBufferProc)(GrGLenum target, GrGLenum internalformat, GrGLuint buffer);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLTexImage2DProc)(GrGLenum target, GrGLint level, GrGLint internalformat, GrGLsizei width, GrGLsizei height, GrGLint border, GrGLenum format, GrGLenum type, const GrGLvoid* pixels);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLTexParameteriProc)(GrGLenum target, GrGLenum pname, GrGLint param);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLTexParameterivProc)(GrGLenum target, GrGLenum pname, const GrGLint* params);
@@ -338,6 +339,8 @@ typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLGetVertexArrayIntegeri_vProc)(GrGLuin
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLGetVertexArrayPointeri_vProc)(GrGLuint vaobj, GrGLuint index, GrGLenum pname, GrGLvoid **param);
typedef GrGLvoid* (GR_GL_FUNCTION_TYPE* GrGLMapNamedBufferRangeProc)(GrGLuint buffer, GrGLintptr offset, GrGLsizeiptr length, GrGLbitfield access);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLFlushMappedNamedBufferRangeProc)(GrGLuint buffer, GrGLintptr offset, GrGLsizeiptr length);
+// OpenGL 3.1
+typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLTextureBufferProc)(GrGLuint texture, GrGLenum target, GrGLenum internalformat, GrGLuint buffer);
/* KHR_debug */
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDebugMessageControlProc)(GrGLenum source, GrGLenum type, GrGLenum severity, GrGLsizei count, const GrGLuint* ids, GrGLboolean enabled);
diff --git a/include/gpu/gl/GrGLInterface.h b/include/gpu/gl/GrGLInterface.h
index 150a2bf943..545a66de77 100644
--- a/include/gpu/gl/GrGLInterface.h
+++ b/include/gpu/gl/GrGLInterface.h
@@ -276,6 +276,7 @@ public:
GrGLFunction<GrGLStencilMaskSeparateProc> fStencilMaskSeparate;
GrGLFunction<GrGLStencilOpProc> fStencilOp;
GrGLFunction<GrGLStencilOpSeparateProc> fStencilOpSeparate;
+ GrGLFunction<GrGLTexBufferProc> fTexBuffer;
GrGLFunction<GrGLTexImage2DProc> fTexImage2D;
GrGLFunction<GrGLTexParameteriProc> fTexParameteri;
GrGLFunction<GrGLTexParameterivProc> fTexParameteriv;
@@ -471,6 +472,8 @@ public:
GrGLFunction<GrGLGetVertexArrayPointeri_vProc> fGetVertexArrayPointeri_v;
GrGLFunction<GrGLMapNamedBufferRangeProc> fMapNamedBufferRange;
GrGLFunction<GrGLFlushMappedNamedBufferRangeProc> fFlushMappedNamedBufferRange;
+ // OpenGL 3.1
+ GrGLFunction<GrGLTextureBufferProc> fTextureBuffer;
/* KHR_debug */
GrGLFunction<GrGLDebugMessageControlProc> fDebugMessageControl;
diff --git a/src/gpu/gl/GrGLAssembleInterface.cpp b/src/gpu/gl/GrGLAssembleInterface.cpp
index 27597b20bd..6672d224fd 100644
--- a/src/gpu/gl/GrGLAssembleInterface.cpp
+++ b/src/gpu/gl/GrGLAssembleInterface.cpp
@@ -205,6 +205,9 @@ const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) {
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 @@ const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) {
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 @@ const GrGLInterface* GrGLAssembleGLESInterface(void* ctx, GrGLGetProc get) {
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 96a75b24d8..dfcde60d45 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -717,6 +717,22 @@ void GrGLCaps::initGLSL(const GrGLContextInfo& ctxInfo) {
}
}
+ 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 17f305b6e3..dd48bd8f0f 100644
--- a/src/gpu/gl/GrGLCreateNullInterface.cpp
+++ b/src/gpu/gl/GrGLCreateNullInterface.cpp
@@ -435,6 +435,7 @@ const GrGLInterface* GrGLCreateNullInterface() {
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 2553002309..cd73be401b 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 84c51fb252..728fb3f9e5 100644
--- a/src/gpu/gl/GrGLInterface.cpp
+++ b/src/gpu/gl/GrGLInterface.cpp
@@ -424,6 +424,21 @@ bool GrGLInterface::validate() const {
}
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 @@ bool GrGLInterface::validate() const {
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 5d094e09a4..16a4fc6781 100644
--- a/src/gpu/gl/GrGLNoOpInterface.cpp
+++ b/src/gpu/gl/GrGLNoOpInterface.cpp
@@ -242,6 +242,11 @@ GrGLvoid GR_GL_FUNCTION_TYPE noOpGLStencilOpSeparate(GrGLenum face,
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 23168e28a3..f81003b75c 100644
--- a/src/gpu/gl/GrGLNoOpInterface.h
+++ b/src/gpu/gl/GrGLNoOpInterface.h
@@ -164,6 +164,10 @@ GrGLvoid GR_GL_FUNCTION_TYPE noOpGLStencilOpSeparate(GrGLenum face,
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 33f9a0a0a0..c6e01c341c 100644
--- a/src/gpu/gl/SkNullGLContext.cpp
+++ b/src/gpu/gl/SkNullGLContext.cpp
@@ -484,6 +484,7 @@ static GrGLInterface* create_null_interface(State* state) {
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 23e0d7e919..d8418fd9f0 100644
--- a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
+++ b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
@@ -926,6 +926,7 @@ const GrGLInterface* GrGLCreateDebugInterface() {
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 189b766752..f14274143b 100755
--- a/src/gpu/glsl/GrGLSLCaps.cpp
+++ b/src/gpu/glsl/GrGLSLCaps.cpp
@@ -29,11 +29,13 @@ GrGLSLCaps::GrGLSLCaps(const GrContextOptions& options) {
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 @@ SkString GrGLSLCaps::dump() const {
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 f907be2b8d..f54c61d933 100755
--- a/src/gpu/glsl/GrGLSLCaps.h
+++ b/src/gpu/glsl/GrGLSLCaps.h
@@ -66,6 +66,8 @@ public:
bool externalTextureSupport() const { return fExternalTextureSupport; }
+ bool bufferTextureSupport() const { return fBufferTextureSupport; }
+
AdvBlendEqInteraction advBlendEqInteraction() const { return fAdvBlendEqInteraction; }
bool mustEnableAdvBlendEqs() const {
@@ -118,6 +120,11 @@ public:
return fExternalTextureExtensionString;
}
+ const char* bufferTextureExtensionString() const {
+ SkASSERT(this->bufferTextureSupport());
+ return fBufferTextureExtensionString;
+ }
+
const char* noperspectiveInterpolationExtensionString() const {
SkASSERT(this->noperspectiveInterpolationSupport());
return fNoPerspectiveInterpolationExtensionString;
@@ -179,6 +186,7 @@ private:
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 @@ private:
const char* fFragCoordConventionsExtensionString;
const char* fSecondaryOutputExtensionString;
const char* fExternalTextureExtensionString;
+ const char* fBufferTextureExtensionString;
const char* fNoPerspectiveInterpolationExtensionString;
const char* fMultisampleInterpolationExtensionString;
const char* fSampleVariablesExtensionString;