Commit c66f0e36 by Nicolas Capens

Implement GL_EXT_draw_buffers.

Bug 19353282 Change-Id: I4a1782c2f1e9ae52b731ef447e97c353cc41044e Reviewed-on: https://swiftshader-review.googlesource.com/5123Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 66747475
...@@ -49,6 +49,7 @@ struct ShBuiltInResources ...@@ -49,6 +49,7 @@ struct ShBuiltInResources
int OES_standard_derivatives; int OES_standard_derivatives;
int OES_fragment_precision_high; int OES_fragment_precision_high;
int OES_EGL_image_external; int OES_EGL_image_external;
int EXT_draw_buffers;
unsigned int MaxCallStackDepth; unsigned int MaxCallStackDepth;
}; };
......
...@@ -481,4 +481,6 @@ void InitExtensionBehavior(const ShBuiltInResources& resources, ...@@ -481,4 +481,6 @@ void InitExtensionBehavior(const ShBuiltInResources& resources,
extBehavior["GL_FRAGMENT_PRECISION_HIGH"] = EBhUndefined; extBehavior["GL_FRAGMENT_PRECISION_HIGH"] = EBhUndefined;
if(resources.OES_EGL_image_external) if(resources.OES_EGL_image_external)
extBehavior["GL_OES_EGL_image_external"] = EBhUndefined; extBehavior["GL_OES_EGL_image_external"] = EBhUndefined;
if(resources.EXT_draw_buffers)
extBehavior["GL_EXT_draw_buffers"] = EBhUndefined;
} }
...@@ -4253,6 +4253,7 @@ const GLubyte* Context::getExtensions(GLuint index, GLuint* numExt) const ...@@ -4253,6 +4253,7 @@ const GLubyte* Context::getExtensions(GLuint index, GLuint* numExt) const
(const GLubyte*)"GL_OES_texture_3D", (const GLubyte*)"GL_OES_texture_3D",
(const GLubyte*)"GL_EXT_blend_minmax", (const GLubyte*)"GL_EXT_blend_minmax",
(const GLubyte*)"GL_EXT_color_buffer_half_float", (const GLubyte*)"GL_EXT_color_buffer_half_float",
(const GLubyte*)"GL_EXT_draw_buffers",
(const GLubyte*)"GL_EXT_occlusion_query_boolean", (const GLubyte*)"GL_EXT_occlusion_query_boolean",
(const GLubyte*)"GL_EXT_read_format_bgra", (const GLubyte*)"GL_EXT_read_format_bgra",
#if (S3TC_SUPPORT) #if (S3TC_SUPPORT)
......
...@@ -176,6 +176,7 @@ TranslatorASM *Shader::createCompiler(GLenum shaderType) ...@@ -176,6 +176,7 @@ TranslatorASM *Shader::createCompiler(GLenum shaderType)
resources.OES_standard_derivatives = 1; resources.OES_standard_derivatives = 1;
resources.OES_fragment_precision_high = 1; resources.OES_fragment_precision_high = 1;
resources.OES_EGL_image_external = 1; resources.OES_EGL_image_external = 1;
resources.EXT_draw_buffers = 1;
resources.MaxCallStackDepth = 16; resources.MaxCallStackDepth = 16;
assembler->Init(resources); assembler->Init(resources);
......
...@@ -182,6 +182,7 @@ global: ...@@ -182,6 +182,7 @@ global:
glFramebufferTexture2DOES; glFramebufferTexture2DOES;
glGetFramebufferAttachmentParameterivOES; glGetFramebufferAttachmentParameterivOES;
glGenerateMipmapOES; glGenerateMipmapOES;
glDrawBuffersEXT;
# GLES 3.0 Functions # GLES 3.0 Functions
glReadBuffer; glReadBuffer;
......
...@@ -1987,6 +1987,7 @@ void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuff ...@@ -1987,6 +1987,7 @@ void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuff
switch(attachment) switch(attachment)
{ {
case GL_COLOR_ATTACHMENT0:
case GL_COLOR_ATTACHMENT1: case GL_COLOR_ATTACHMENT1:
case GL_COLOR_ATTACHMENT2: case GL_COLOR_ATTACHMENT2:
case GL_COLOR_ATTACHMENT3: case GL_COLOR_ATTACHMENT3:
...@@ -2018,12 +2019,6 @@ void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuff ...@@ -2018,12 +2019,6 @@ void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuff
case GL_COLOR_ATTACHMENT29: case GL_COLOR_ATTACHMENT29:
case GL_COLOR_ATTACHMENT30: case GL_COLOR_ATTACHMENT30:
case GL_COLOR_ATTACHMENT31: case GL_COLOR_ATTACHMENT31:
if(clientVersion < 3)
{
return error(GL_INVALID_ENUM);
}
// fall through
case GL_COLOR_ATTACHMENT0:
if((attachment - GL_COLOR_ATTACHMENT0) >= MAX_COLOR_ATTACHMENTS) if((attachment - GL_COLOR_ATTACHMENT0) >= MAX_COLOR_ATTACHMENTS)
{ {
return error(GL_INVALID_ENUM); return error(GL_INVALID_ENUM);
...@@ -2134,10 +2129,9 @@ void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GL ...@@ -2134,10 +2129,9 @@ void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GL
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
GLint clientVersion = context->getClientVersion();
switch(attachment) switch(attachment)
{ {
case GL_COLOR_ATTACHMENT0:
case GL_COLOR_ATTACHMENT1: case GL_COLOR_ATTACHMENT1:
case GL_COLOR_ATTACHMENT2: case GL_COLOR_ATTACHMENT2:
case GL_COLOR_ATTACHMENT3: case GL_COLOR_ATTACHMENT3:
...@@ -2169,12 +2163,6 @@ void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GL ...@@ -2169,12 +2163,6 @@ void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GL
case GL_COLOR_ATTACHMENT29: case GL_COLOR_ATTACHMENT29:
case GL_COLOR_ATTACHMENT30: case GL_COLOR_ATTACHMENT30:
case GL_COLOR_ATTACHMENT31: case GL_COLOR_ATTACHMENT31:
if(clientVersion < 3)
{
return error(GL_INVALID_ENUM);
}
// fall through
case GL_COLOR_ATTACHMENT0:
if((attachment - GL_COLOR_ATTACHMENT0) >= MAX_COLOR_ATTACHMENTS) if((attachment - GL_COLOR_ATTACHMENT0) >= MAX_COLOR_ATTACHMENTS)
{ {
return error(GL_INVALID_ENUM); return error(GL_INVALID_ENUM);
...@@ -2807,6 +2795,7 @@ void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenu ...@@ -2807,6 +2795,7 @@ void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenu
} }
else return error(GL_INVALID_ENUM); else return error(GL_INVALID_ENUM);
break; break;
case GL_COLOR_ATTACHMENT0:
case GL_COLOR_ATTACHMENT1: case GL_COLOR_ATTACHMENT1:
case GL_COLOR_ATTACHMENT2: case GL_COLOR_ATTACHMENT2:
case GL_COLOR_ATTACHMENT3: case GL_COLOR_ATTACHMENT3:
...@@ -2838,12 +2827,6 @@ void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenu ...@@ -2838,12 +2827,6 @@ void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenu
case GL_COLOR_ATTACHMENT29: case GL_COLOR_ATTACHMENT29:
case GL_COLOR_ATTACHMENT30: case GL_COLOR_ATTACHMENT30:
case GL_COLOR_ATTACHMENT31: case GL_COLOR_ATTACHMENT31:
if(clientVersion < 3)
{
return error(GL_INVALID_ENUM);
}
// fall through
case GL_COLOR_ATTACHMENT0:
if((attachment - GL_COLOR_ATTACHMENT0) >= MAX_COLOR_ATTACHMENTS) if((attachment - GL_COLOR_ATTACHMENT0) >= MAX_COLOR_ATTACHMENTS)
{ {
return error(GL_INVALID_ENUM); return error(GL_INVALID_ENUM);
...@@ -6772,6 +6755,82 @@ void GenerateMipmapOES(GLenum target) ...@@ -6772,6 +6755,82 @@ void GenerateMipmapOES(GLenum target)
GenerateMipmap(target); GenerateMipmap(target);
} }
void DrawBuffersEXT(GLsizei n, const GLenum *bufs)
{
TRACE("(GLsizei n = %d, const GLenum *bufs = %p)", n, bufs);
if(n < 0 || n > MAX_DRAW_BUFFERS)
{
return error(GL_INVALID_VALUE);
}
es2::Context *context = es2::getContext();
if(context)
{
GLuint drawFramebufferName = context->getDrawFramebufferName();
if((drawFramebufferName == 0) && (n != 1))
{
return error(GL_INVALID_OPERATION);
}
for(unsigned int i = 0; i < (unsigned)n; i++)
{
switch(bufs[i])
{
case GL_BACK:
if(drawFramebufferName != 0)
{
return error(GL_INVALID_OPERATION);
}
break;
case GL_NONE:
break;
case GL_COLOR_ATTACHMENT0_EXT:
case GL_COLOR_ATTACHMENT1_EXT:
case GL_COLOR_ATTACHMENT2_EXT:
case GL_COLOR_ATTACHMENT3_EXT:
case GL_COLOR_ATTACHMENT4_EXT:
case GL_COLOR_ATTACHMENT5_EXT:
case GL_COLOR_ATTACHMENT6_EXT:
case GL_COLOR_ATTACHMENT7_EXT:
case GL_COLOR_ATTACHMENT8_EXT:
case GL_COLOR_ATTACHMENT9_EXT:
case GL_COLOR_ATTACHMENT10_EXT:
case GL_COLOR_ATTACHMENT11_EXT:
case GL_COLOR_ATTACHMENT12_EXT:
case GL_COLOR_ATTACHMENT13_EXT:
case GL_COLOR_ATTACHMENT14_EXT:
case GL_COLOR_ATTACHMENT15_EXT:
{
GLuint index = (bufs[i] - GL_COLOR_ATTACHMENT0_EXT);
if(index >= MAX_COLOR_ATTACHMENTS)
{
return error(GL_INVALID_OPERATION);
}
if(index != i)
{
return error(GL_INVALID_OPERATION);
}
if(drawFramebufferName == 0)
{
return error(GL_INVALID_OPERATION);
}
}
break;
default:
return error(GL_INVALID_ENUM);
}
}
context->setFramebufferDrawBuffers(n, bufs);
}
}
} }
extern "C" __eglMustCastToProperFunctionPointerType es2GetProcAddress(const char *procname) extern "C" __eglMustCastToProperFunctionPointerType es2GetProcAddress(const char *procname)
...@@ -6831,6 +6890,7 @@ extern "C" __eglMustCastToProperFunctionPointerType es2GetProcAddress(const char ...@@ -6831,6 +6890,7 @@ extern "C" __eglMustCastToProperFunctionPointerType es2GetProcAddress(const char
EXTENSION(glFramebufferTexture2DOES), EXTENSION(glFramebufferTexture2DOES),
EXTENSION(glGetFramebufferAttachmentParameterivOES), EXTENSION(glGetFramebufferAttachmentParameterivOES),
EXTENSION(glGenerateMipmapOES), EXTENSION(glGenerateMipmapOES),
EXTENSION(glDrawBuffersEXT),
#undef EXTENSION #undef EXTENSION
}; };
......
...@@ -182,6 +182,7 @@ EXPORTS ...@@ -182,6 +182,7 @@ EXPORTS
glFramebufferTexture2DOES glFramebufferTexture2DOES
glGetFramebufferAttachmentParameterivOES glGetFramebufferAttachmentParameterivOES
glGenerateMipmapOES glGenerateMipmapOES
glDrawBuffersEXT
; GLES 3.0 Functions ; GLES 3.0 Functions
glReadBuffer @211 glReadBuffer @211
......
...@@ -224,6 +224,7 @@ public: ...@@ -224,6 +224,7 @@ public:
void (*glFramebufferTexture2DOES)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); void (*glFramebufferTexture2DOES)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
void (*glGetFramebufferAttachmentParameterivOES)(GLenum target, GLenum attachment, GLenum pname, GLint* params); void (*glGetFramebufferAttachmentParameterivOES)(GLenum target, GLenum attachment, GLenum pname, GLint* params);
void (*glGenerateMipmapOES)(GLenum target); void (*glGenerateMipmapOES)(GLenum target);
void (*glDrawBuffersEXT)(GLsizei n, const GLenum *bufs);
egl::Context *(*es2CreateContext)(const egl::Config *config, const egl::Context *shareContext, int clientVersion); egl::Context *(*es2CreateContext)(const egl::Config *config, const egl::Context *shareContext, int clientVersion);
__eglMustCastToProperFunctionPointerType (*es2GetProcAddress)(const char *procname); __eglMustCastToProperFunctionPointerType (*es2GetProcAddress)(const char *procname);
......
...@@ -347,6 +347,7 @@ GL_APICALL void FramebufferRenderbufferOES(GLenum target, GLenum attachment, GLe ...@@ -347,6 +347,7 @@ GL_APICALL void FramebufferRenderbufferOES(GLenum target, GLenum attachment, GLe
GL_APICALL void FramebufferTexture2DOES(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); GL_APICALL void FramebufferTexture2DOES(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
GL_APICALL void GetFramebufferAttachmentParameterivOES(GLenum target, GLenum attachment, GLenum pname, GLint* params); GL_APICALL void GetFramebufferAttachmentParameterivOES(GLenum target, GLenum attachment, GLenum pname, GLint* params);
GL_APICALL void GenerateMipmapOES(GLenum target); GL_APICALL void GenerateMipmapOES(GLenum target);
GL_APICALL void DrawBuffersEXT(GLsizei n, const GLenum *bufs);
} }
extern "C" extern "C"
...@@ -1318,6 +1319,11 @@ GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES(GLenum target ...@@ -1318,6 +1319,11 @@ GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES(GLenum target
return es2::EGLImageTargetRenderbufferStorageOES(target, image); return es2::EGLImageTargetRenderbufferStorageOES(target, image);
} }
GL_APICALL void GL_APIENTRY glDrawBuffersEXT(GLsizei n, const GLenum *bufs)
{
return es2::DrawBuffersEXT(n, bufs);
}
void GL_APIENTRY Register(const char *licenseKey) void GL_APIENTRY Register(const char *licenseKey)
{ {
RegisterLicenseKey(licenseKey); RegisterLicenseKey(licenseKey);
...@@ -1524,6 +1530,7 @@ LibGLESv2exports::LibGLESv2exports() ...@@ -1524,6 +1530,7 @@ LibGLESv2exports::LibGLESv2exports()
this->glFramebufferTexture2DOES = es2::FramebufferTexture2DOES; this->glFramebufferTexture2DOES = es2::FramebufferTexture2DOES;
this->glGetFramebufferAttachmentParameterivOES = es2::GetFramebufferAttachmentParameterivOES; this->glGetFramebufferAttachmentParameterivOES = es2::GetFramebufferAttachmentParameterivOES;
this->glGenerateMipmapOES = es2::GenerateMipmapOES; this->glGenerateMipmapOES = es2::GenerateMipmapOES;
this->glDrawBuffersEXT = es2::DrawBuffersEXT;
this->es2CreateContext = ::es2CreateContext; this->es2CreateContext = ::es2CreateContext;
this->es2GetProcAddress = ::es2GetProcAddress; this->es2GetProcAddress = ::es2GetProcAddress;
......
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