Support ARB extensions for indirect drawing

Adds support for the ARB extensions and fixes incorrect logic that was
being used on the GL version for indirect drawing.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2038743002

Review-Url: https://codereview.chromium.org/2038743002
This commit is contained in:
csmartdalton 2016-06-03 08:28:47 -07:00 committed by Commit bot
parent 2cee902847
commit 5cebf8c82d
4 changed files with 25 additions and 23 deletions

View File

@ -206,6 +206,8 @@ public:
GrGLFunction<GrGLMapBufferRangeProc> fMapBufferRange;
GrGLFunction<GrGLMapBufferSubDataProc> fMapBufferSubData;
GrGLFunction<GrGLMapTexSubImage2DProc> fMapTexSubImage2D;
GrGLFunction<GrGLMultiDrawArraysIndirectProc> fMultiDrawArraysIndirect;
GrGLFunction<GrGLMultiDrawElementsIndirectProc> fMultiDrawElementsIndirect;
GrGLFunction<GrGLPixelStoreiProc> fPixelStorei;
GrGLFunction<GrGLPopGroupMarkerProc> fPopGroupMarker;
GrGLFunction<GrGLPushGroupMarkerProc> fPushGroupMarker;
@ -323,10 +325,6 @@ public:
/* NV_framebuffer_mixed_samples */
GrGLFunction<GrGLCoverageModulationProc> fCoverageModulation;
/* EXT_multi_draw_indirect */
GrGLFunction<GrGLMultiDrawArraysIndirectProc> fMultiDrawArraysIndirect;
GrGLFunction<GrGLMultiDrawElementsIndirectProc> fMultiDrawElementsIndirect;
/* NV_bindless_texture */
// We use the NVIDIA verson for now because it does not require dynamically uniform handles.
// We may switch the the ARB version and/or omit methods in the future.

View File

@ -144,8 +144,7 @@ const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) {
GET_PROC(DrawElementsInstanced);
}
if (glVer >= GR_GL_VER(4,0)) {
// We don't use ARB_draw_indirect because it does not support a base instance.
if (glVer >= GR_GL_VER(4,0) || extensions.has("GL_ARB_draw_indirect")) {
GET_PROC(DrawArraysIndirect);
GET_PROC(DrawElementsIndirect);
}
@ -190,6 +189,12 @@ const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) {
GET_PROC(LineWidth);
GET_PROC(LinkProgram);
GET_PROC(MapBuffer);
if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_ARB_multi_draw_indirect")) {
GET_PROC(MultiDrawArraysIndirect);
GET_PROC(MultiDrawElementsIndirect);
}
GET_PROC(PixelStorei);
if (extensions.has("GL_EXT_raster_multisample")) {
GET_PROC_SUFFIX(RasterSamples, EXT);
@ -368,12 +373,6 @@ const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) {
GET_PROC(GetProgramResourceLocation);
}
if (glVer >= GR_GL_VER(4,3)) {
// We don't use ARB_multi_draw_indirect because it does not support GL_DRAW_INDIRECT_BUFFER.
GET_PROC(MultiDrawArraysIndirect);
GET_PROC(MultiDrawElementsIndirect);
}
if (extensions.has("GL_NV_bindless_texture")) {
GET_PROC_SUFFIX(GetTextureHandle, NV);
GET_PROC_SUFFIX(GetTextureSamplerHandle, NV);
@ -640,6 +639,12 @@ const GrGLInterface* GrGLAssembleGLESInterface(void* ctx, GrGLGetProc get) {
GET_PROC(IsTexture);
GET_PROC(LineWidth);
GET_PROC(LinkProgram);
if (extensions.has("GL_EXT_multi_draw_indirect")) {
GET_PROC_SUFFIX(MultiDrawArraysIndirect, EXT);
GET_PROC_SUFFIX(MultiDrawElementsIndirect, EXT);
}
GET_PROC(PixelStorei);
if (extensions.has("GL_EXT_raster_multisample")) {
@ -854,11 +859,6 @@ const GrGLInterface* GrGLAssembleGLESInterface(void* ctx, GrGLGetProc get) {
GET_PROC_SUFFIX(CoverageModulation, CHROMIUM);
}
if (extensions.has("GL_EXT_multi_draw_indirect")) {
GET_PROC_SUFFIX(MultiDrawArraysIndirect, EXT);
GET_PROC_SUFFIX(MultiDrawElementsIndirect, EXT);
}
if (extensions.has("GL_NV_bindless_texture")) {
GET_PROC_SUFFIX(GetTextureHandle, NV);
GET_PROC_SUFFIX(GetTextureSamplerHandle, NV);

View File

@ -519,10 +519,12 @@ void GrGLCaps::init(const GrContextOptions& contextOptions,
}
if (kGL_GrGLStandard == standard) {
// We don't use ARB_draw_indirect because it does not support a base instance.
// We don't use ARB_multi_draw_indirect because it does not support GL_DRAW_INDIRECT_BUFFER.
fDrawIndirectSupport =
fMultiDrawIndirectSupport = fBaseInstanceSupport = version >= GR_GL_VER(4,3);
fDrawIndirectSupport = version >= GR_GL_VER(4,0) ||
ctxInfo.hasExtension("GL_ARB_draw_indirect");
fBaseInstanceSupport = version >= GR_GL_VER(4,2);
fMultiDrawIndirectSupport = version >= GR_GL_VER(4,3) ||
(!fBaseInstanceSupport && // The ARB extension has no base inst.
ctxInfo.hasExtension("GL_ARB_multi_draw_indirect"));
} else {
fDrawIndirectSupport = version >= GR_GL_VER(3,1);
fMultiDrawIndirectSupport = ctxInfo.hasExtension("GL_EXT_multi_draw_indirect");

View File

@ -600,7 +600,8 @@ bool GrGLInterface::validate() const {
}
}
if ((kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,3)) ||
if ((kGL_GrGLStandard == fStandard &&
(glVer >= GR_GL_VER(4,0) || fExtensions.has("GL_ARB_draw_indirect"))) ||
(kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,1))) {
if (NULL == fFunctions.fDrawArraysIndirect ||
NULL == fFunctions.fDrawElementsIndirect) {
@ -608,7 +609,8 @@ bool GrGLInterface::validate() const {
}
}
if ((kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,3)) ||
if ((kGL_GrGLStandard == fStandard &&
(glVer >= GR_GL_VER(4,3) || fExtensions.has("GL_ARB_multi_draw_indirect"))) ||
(kGLES_GrGLStandard == fStandard && fExtensions.has("GL_EXT_multi_draw_indirect"))) {
if (NULL == fFunctions.fMultiDrawArraysIndirect ||
NULL == fFunctions.fMultiDrawElementsIndirect) {