Commit b3801744 by Shannon Woods

Adds support for OES_mapbuffer

BUG=angle:581 Change-Id: I05824051789a77c8169ec5830731e6155c507fc4 Reviewed-on: https://chromium-review.googlesource.com/191650Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarShannon Woods <shannonwoods@chromium.org>
parent 8776b258
...@@ -369,6 +369,7 @@ void Context::makeCurrent(egl::Surface *surface) ...@@ -369,6 +369,7 @@ void Context::makeCurrent(egl::Surface *surface)
mSupportsDepthTextures = mRenderer->getDepthTextureSupport(); mSupportsDepthTextures = mRenderer->getDepthTextureSupport();
mSupportsTextureFilterAnisotropy = mRenderer->getTextureFilterAnisotropySupport(); mSupportsTextureFilterAnisotropy = mRenderer->getTextureFilterAnisotropySupport();
mSupports32bitIndices = mRenderer->get32BitIndexSupport(); mSupports32bitIndices = mRenderer->get32BitIndexSupport();
mSupportsPBOs = mRenderer->getPBOSupport();
mNumCompressedTextureFormats = 0; mNumCompressedTextureFormats = 0;
if (supportsDXT1Textures()) if (supportsDXT1Textures())
...@@ -3381,6 +3382,11 @@ bool Context::supportsTextureFilterAnisotropy() const ...@@ -3381,6 +3382,11 @@ bool Context::supportsTextureFilterAnisotropy() const
return mSupportsTextureFilterAnisotropy; return mSupportsTextureFilterAnisotropy;
} }
bool Context::supportsPBOs() const
{
return mSupportsPBOs;
}
float Context::getTextureMaxAnisotropy() const float Context::getTextureMaxAnisotropy() const
{ {
return mMaxTextureAnisotropy; return mMaxTextureAnisotropy;
...@@ -3761,6 +3767,11 @@ void Context::initExtensionString() ...@@ -3761,6 +3767,11 @@ void Context::initExtensionString()
mExtensionStringList.push_back("GL_OES_packed_depth_stencil"); mExtensionStringList.push_back("GL_OES_packed_depth_stencil");
mExtensionStringList.push_back("GL_OES_get_program_binary"); mExtensionStringList.push_back("GL_OES_get_program_binary");
mExtensionStringList.push_back("GL_OES_rgb8_rgba8"); mExtensionStringList.push_back("GL_OES_rgb8_rgba8");
if (supportsPBOs())
{
mExtensionStringList.push_back("GL_OES_mapbuffer");
}
if (mRenderer->getDerivativeInstructionSupport()) if (mRenderer->getDerivativeInstructionSupport())
{ {
mExtensionStringList.push_back("GL_OES_standard_derivatives"); mExtensionStringList.push_back("GL_OES_standard_derivatives");
......
...@@ -443,6 +443,7 @@ class Context ...@@ -443,6 +443,7 @@ class Context
bool supportsNonPower2Texture() const; bool supportsNonPower2Texture() const;
bool supportsInstancing() const; bool supportsInstancing() const;
bool supportsTextureFilterAnisotropy() const; bool supportsTextureFilterAnisotropy() const;
bool supportsPBOs() const;
bool getCurrentReadFormatType(GLenum *internalFormat, GLenum *format, GLenum *type); bool getCurrentReadFormatType(GLenum *internalFormat, GLenum *format, GLenum *type);
...@@ -581,6 +582,7 @@ class Context ...@@ -581,6 +582,7 @@ class Context
bool mSupportsDepthTextures; bool mSupportsDepthTextures;
bool mSupports32bitIndices; bool mSupports32bitIndices;
bool mSupportsTextureFilterAnisotropy; bool mSupportsTextureFilterAnisotropy;
bool mSupportsPBOs;
int mNumCompressedTextureFormats; int mNumCompressedTextureFormats;
ResourceManager *mResourceManager; ResourceManager *mResourceManager;
......
...@@ -6624,23 +6624,7 @@ GLboolean __stdcall glUnmapBuffer(GLenum target) ...@@ -6624,23 +6624,7 @@ GLboolean __stdcall glUnmapBuffer(GLenum target)
return gl::error(GL_INVALID_OPERATION, GL_FALSE); return gl::error(GL_INVALID_OPERATION, GL_FALSE);
} }
if (!gl::ValidBufferTarget(context, target)) return glUnmapBufferOES(target);
{
return gl::error(GL_INVALID_ENUM, GL_FALSE);
}
gl::Buffer *buffer = context->getTargetBuffer(target);
if (buffer == NULL || !buffer->mapped())
{
return gl::error(GL_INVALID_OPERATION, GL_FALSE);
}
// TODO: detect if we had corruption. if so, throw an error and return false.
buffer->unmap();
return GL_TRUE;
} }
} }
catch(std::bad_alloc&) catch(std::bad_alloc&)
...@@ -6666,24 +6650,7 @@ void __stdcall glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) ...@@ -6666,24 +6650,7 @@ void __stdcall glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
return gl::error(GL_INVALID_OPERATION); return gl::error(GL_INVALID_OPERATION);
} }
if (!gl::ValidBufferTarget(context, target)) glGetBufferPointervOES(target, pname, params);
{
return gl::error(GL_INVALID_ENUM);
}
if (pname != GL_BUFFER_MAP_POINTER)
{
return gl::error(GL_INVALID_ENUM);
}
gl::Buffer *buffer = context->getTargetBuffer(target);
if (!buffer || !buffer->mapped())
{
*params = NULL;
}
*params = buffer->mapPointer();
} }
} }
catch(std::bad_alloc&) catch(std::bad_alloc&)
...@@ -10319,6 +10286,127 @@ void __stdcall glDrawBuffersEXT(GLsizei n, const GLenum *bufs) ...@@ -10319,6 +10286,127 @@ void __stdcall glDrawBuffersEXT(GLsizei n, const GLenum *bufs)
} }
} }
void __stdcall glGetBufferPointervOES(GLenum target, GLenum pname, void** params)
{
EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
try
{
gl::Context *context = gl::getNonLostContext();
if (context)
{
if (!context->supportsPBOs())
{
return gl::error(GL_INVALID_OPERATION);
}
if (!gl::ValidBufferTarget(context, target))
{
return gl::error(GL_INVALID_ENUM);
}
if (pname != GL_BUFFER_MAP_POINTER)
{
return gl::error(GL_INVALID_ENUM);
}
gl::Buffer *buffer = context->getTargetBuffer(target);
if (!buffer || !buffer->mapped())
{
*params = NULL;
}
*params = buffer->mapPointer();
}
}
catch (std::bad_alloc&)
{
return gl::error(GL_OUT_OF_MEMORY);
}
}
void * __stdcall glMapBufferOES(GLenum target, GLenum access)
{
EVENT("(GLenum target = 0x%X, GLbitfield access = 0x%X)", target, access);
try
{
gl::Context *context = gl::getNonLostContext();
if (context)
{
if (!gl::ValidBufferTarget(context, target))
{
return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLvoid*>(NULL));
}
gl::Buffer *buffer = context->getTargetBuffer(target);
if (buffer == NULL)
{
return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL));
}
if (access != GL_WRITE_ONLY_OES)
{
return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLvoid*>(NULL));
}
if (buffer->mapped())
{
return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL));
}
return buffer->mapRange(0, buffer->size(), GL_MAP_WRITE_BIT);
}
}
catch(std::bad_alloc&)
{
return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLvoid*>(NULL));
}
return NULL;
}
GLboolean __stdcall glUnmapBufferOES(GLenum target)
{
EVENT("(GLenum target = 0x%X)", target);
try
{
gl::Context *context = gl::getNonLostContext();
if (context)
{
if (!gl::ValidBufferTarget(context, target))
{
return gl::error(GL_INVALID_ENUM, GL_FALSE);
}
gl::Buffer *buffer = context->getTargetBuffer(target);
if (buffer == NULL || !buffer->mapped())
{
return gl::error(GL_INVALID_OPERATION, GL_FALSE);
}
// TODO: detect if we had corruption. if so, throw an error and return false.
buffer->unmap();
return GL_TRUE;
}
}
catch(std::bad_alloc&)
{
return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
}
return GL_FALSE;
}
__eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname) __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname)
{ {
struct Extension struct Extension
...@@ -10357,7 +10445,10 @@ __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char * ...@@ -10357,7 +10445,10 @@ __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *
{"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE}, {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE},
{"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE}, {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE},
{"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES}, {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES},
{"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES}, }; {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES},
{"glGetBufferPointervOES", (__eglMustCastToProperFunctionPointerType)glGetBufferPointervOES},
{"glMapBufferOES", (__eglMustCastToProperFunctionPointerType)glMapBufferOES},
{"glUnmapBufferOES", (__eglMustCastToProperFunctionPointerType)glUnmapBufferOES}, };
for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++) for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++)
{ {
......
...@@ -173,6 +173,9 @@ EXPORTS ...@@ -173,6 +173,9 @@ EXPORTS
glProgramBinaryOES @175 glProgramBinaryOES @175
glGetProgramBinaryOES @176 glGetProgramBinaryOES @176
glDrawBuffersEXT @179 glDrawBuffersEXT @179
glMapBufferOES @285
glUnmapBufferOES @286
glGetBufferPointervOES @287
; GLES 3.0 Functions ; GLES 3.0 Functions
glReadBuffer @180 glReadBuffer @180
......
...@@ -189,6 +189,7 @@ class Renderer ...@@ -189,6 +189,7 @@ class Renderer
virtual bool getOcclusionQuerySupport() const = 0; virtual bool getOcclusionQuerySupport() const = 0;
virtual bool getInstancingSupport() const = 0; virtual bool getInstancingSupport() const = 0;
virtual bool getTextureFilterAnisotropySupport() const = 0; virtual bool getTextureFilterAnisotropySupport() const = 0;
virtual bool getPBOSupport() const = 0;
virtual float getTextureMaxAnisotropy() const = 0; virtual float getTextureMaxAnisotropy() const = 0;
virtual bool getShareHandleSupport() const = 0; virtual bool getShareHandleSupport() const = 0;
virtual bool getDerivativeInstructionSupport() const = 0; virtual bool getDerivativeInstructionSupport() const = 0;
......
...@@ -2013,6 +2013,11 @@ bool Renderer11::getTextureFilterAnisotropySupport() const ...@@ -2013,6 +2013,11 @@ bool Renderer11::getTextureFilterAnisotropySupport() const
return true; return true;
} }
bool Renderer11::getPBOSupport() const
{
return true;
}
float Renderer11::getTextureMaxAnisotropy() const float Renderer11::getTextureMaxAnisotropy() const
{ {
switch (mFeatureLevel) switch (mFeatureLevel)
......
...@@ -137,6 +137,7 @@ class Renderer11 : public Renderer ...@@ -137,6 +137,7 @@ class Renderer11 : public Renderer
virtual bool getOcclusionQuerySupport() const; virtual bool getOcclusionQuerySupport() const;
virtual bool getInstancingSupport() const; virtual bool getInstancingSupport() const;
virtual bool getTextureFilterAnisotropySupport() const; virtual bool getTextureFilterAnisotropySupport() const;
virtual bool getPBOSupport() const;
virtual float getTextureMaxAnisotropy() const; virtual float getTextureMaxAnisotropy() const;
virtual bool getShareHandleSupport() const; virtual bool getShareHandleSupport() const;
virtual bool getDerivativeInstructionSupport() const; virtual bool getDerivativeInstructionSupport() const;
......
...@@ -2458,6 +2458,12 @@ bool Renderer9::getTextureFilterAnisotropySupport() const ...@@ -2458,6 +2458,12 @@ bool Renderer9::getTextureFilterAnisotropySupport() const
return mSupportsTextureFilterAnisotropy; return mSupportsTextureFilterAnisotropy;
} }
bool Renderer9::getPBOSupport() const
{
// D3D9 cannot support PBOs
return false;
}
float Renderer9::getTextureMaxAnisotropy() const float Renderer9::getTextureMaxAnisotropy() const
{ {
if (mSupportsTextureFilterAnisotropy) if (mSupportsTextureFilterAnisotropy)
......
...@@ -139,6 +139,7 @@ class Renderer9 : public Renderer ...@@ -139,6 +139,7 @@ class Renderer9 : public Renderer
virtual bool getOcclusionQuerySupport() const; virtual bool getOcclusionQuerySupport() const;
virtual bool getInstancingSupport() const; virtual bool getInstancingSupport() const;
virtual bool getTextureFilterAnisotropySupport() const; virtual bool getTextureFilterAnisotropySupport() const;
virtual bool getPBOSupport() const;
virtual float getTextureMaxAnisotropy() const; virtual float getTextureMaxAnisotropy() const;
virtual bool getShareHandleSupport() const; virtual bool getShareHandleSupport() const;
virtual bool getDerivativeInstructionSupport() const; virtual bool getDerivativeInstructionSupport() const;
......
...@@ -106,10 +106,10 @@ bool ValidBufferTarget(const Context *context, GLenum target) ...@@ -106,10 +106,10 @@ bool ValidBufferTarget(const Context *context, GLenum target)
case GL_ELEMENT_ARRAY_BUFFER: case GL_ELEMENT_ARRAY_BUFFER:
return true; return true;
case GL_COPY_READ_BUFFER:
case GL_COPY_WRITE_BUFFER:
case GL_PIXEL_PACK_BUFFER: case GL_PIXEL_PACK_BUFFER:
case GL_PIXEL_UNPACK_BUFFER: case GL_PIXEL_UNPACK_BUFFER:
case GL_COPY_READ_BUFFER:
case GL_COPY_WRITE_BUFFER:
case GL_TRANSFORM_FEEDBACK_BUFFER: case GL_TRANSFORM_FEEDBACK_BUFFER:
case GL_UNIFORM_BUFFER: case GL_UNIFORM_BUFFER:
return (context->getClientVersion() >= 3); return (context->getClientVersion() >= 3);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment