Commit e8fb640d by Jamie Madill Committed by Commit Bot

Update RenderbufferStorage EPs to new style.

This will facilitate changes for WebGL compatibility. BUG=angleproject:747 BUG=angleproject:1708 Change-Id: I62e5d684ca10a843b5e958afe9954c1065bfeb19 Reviewed-on: https://chromium-review.googlesource.com/442093Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 6137ddc5
...@@ -3716,4 +3716,24 @@ void Context::getMultisamplefv(GLenum pname, GLuint index, GLfloat *val) ...@@ -3716,4 +3716,24 @@ void Context::getMultisamplefv(GLenum pname, GLuint index, GLfloat *val)
} }
} }
void Context::renderbufferStorage(GLenum target,
GLenum internalformat,
GLsizei width,
GLsizei height)
{
Renderbuffer *renderbuffer = mGLState.getCurrentRenderbuffer();
handleError(renderbuffer->setStorage(internalformat, width, height));
}
void Context::renderbufferStorageMultisample(GLenum target,
GLsizei samples,
GLenum internalformat,
GLsizei width,
GLsizei height)
{
Renderbuffer *renderbuffer = mGLState.getCurrentRenderbuffer();
handleError(renderbuffer->setStorageMultisample(samples, internalformat, width, height));
}
} // namespace gl } // namespace gl
...@@ -508,6 +508,12 @@ class Context final : public ValidationContext ...@@ -508,6 +508,12 @@ class Context final : public ValidationContext
void popGroupMarker(); void popGroupMarker();
void bindUniformLocation(GLuint program, GLint location, const GLchar *name); void bindUniformLocation(GLuint program, GLint location, const GLchar *name);
void renderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
void renderbufferStorageMultisample(GLenum target,
GLsizei samples,
GLenum internalformat,
GLsizei width,
GLsizei height);
// CHROMIUM_framebuffer_mixed_samples // CHROMIUM_framebuffer_mixed_samples
void setCoverageModulation(GLenum components); void setCoverageModulation(GLenum components);
......
...@@ -1927,7 +1927,7 @@ bool ValidateAttachmentTarget(gl::Context *context, GLenum attachment) ...@@ -1927,7 +1927,7 @@ bool ValidateAttachmentTarget(gl::Context *context, GLenum attachment)
return true; return true;
} }
bool ValidateRenderbufferStorageParametersBase(gl::Context *context, bool ValidateRenderbufferStorageParametersBase(ValidationContext *context,
GLenum target, GLenum target,
GLsizei samples, GLsizei samples,
GLenum internalformat, GLenum internalformat,
...@@ -1982,42 +1982,6 @@ bool ValidateRenderbufferStorageParametersBase(gl::Context *context, ...@@ -1982,42 +1982,6 @@ bool ValidateRenderbufferStorageParametersBase(gl::Context *context,
return true; return true;
} }
bool ValidateRenderbufferStorageParametersANGLE(gl::Context *context,
GLenum target,
GLsizei samples,
GLenum internalformat,
GLsizei width,
GLsizei height)
{
ASSERT(samples == 0 || context->getExtensions().framebufferMultisample);
// ANGLE_framebuffer_multisample states that the value of samples must be less than or equal
// to MAX_SAMPLES_ANGLE (Context::getCaps().maxSamples) otherwise GL_INVALID_VALUE is
// generated.
if (static_cast<GLuint>(samples) > context->getCaps().maxSamples)
{
context->handleError(Error(GL_INVALID_VALUE));
return false;
}
// ANGLE_framebuffer_multisample states GL_OUT_OF_MEMORY is generated on a failure to create
// the specified storage. This is different than ES 3.0 in which a sample number higher
// than the maximum sample number supported by this format generates a GL_INVALID_VALUE.
// The TextureCaps::getMaxSamples method is only guarenteed to be valid when the context is ES3.
if (context->getClientMajorVersion() >= 3)
{
const TextureCaps &formatCaps = context->getTextureCaps().get(internalformat);
if (static_cast<GLuint>(samples) > formatCaps.getMaxSamples())
{
context->handleError(Error(GL_OUT_OF_MEMORY));
return false;
}
}
return ValidateRenderbufferStorageParametersBase(context, target, samples, internalformat,
width, height);
}
bool ValidateFramebufferRenderbufferParameters(gl::Context *context, bool ValidateFramebufferRenderbufferParameters(gl::Context *context,
GLenum target, GLenum target,
GLenum attachment, GLenum attachment,
......
...@@ -76,19 +76,12 @@ Program *GetValidProgram(ValidationContext *context, GLuint id); ...@@ -76,19 +76,12 @@ Program *GetValidProgram(ValidationContext *context, GLuint id);
Shader *GetValidShader(ValidationContext *context, GLuint id); Shader *GetValidShader(ValidationContext *context, GLuint id);
bool ValidateAttachmentTarget(Context *context, GLenum attachment); bool ValidateAttachmentTarget(Context *context, GLenum attachment);
bool ValidateRenderbufferStorageParametersBase(Context *context, bool ValidateRenderbufferStorageParametersBase(ValidationContext *context,
GLenum target, GLenum target,
GLsizei samples, GLsizei samples,
GLenum internalformat, GLenum internalformat,
GLsizei width, GLsizei width,
GLsizei height); GLsizei height);
bool ValidateRenderbufferStorageParametersANGLE(Context *context,
GLenum target,
GLsizei samples,
GLenum internalformat,
GLsizei width,
GLsizei height);
bool ValidateFramebufferRenderbufferParameters(Context *context, bool ValidateFramebufferRenderbufferParameters(Context *context,
GLenum target, GLenum target,
GLenum attachment, GLenum attachment,
......
...@@ -4026,4 +4026,55 @@ bool ValidateDepthRangef(ValidationContext *context, GLclampf zNear, GLclampf zF ...@@ -4026,4 +4026,55 @@ bool ValidateDepthRangef(ValidationContext *context, GLclampf zNear, GLclampf zF
return true; return true;
} }
bool ValidateRenderbufferStorage(ValidationContext *context,
GLenum target,
GLenum internalformat,
GLsizei width,
GLsizei height)
{
return ValidateRenderbufferStorageParametersBase(context, target, 0, internalformat, width,
height);
}
bool ValidateRenderbufferStorageMultisampleANGLE(ValidationContext *context,
GLenum target,
GLsizei samples,
GLenum internalformat,
GLsizei width,
GLsizei height)
{
if (!context->getExtensions().framebufferMultisample)
{
context->handleError(
Error(GL_INVALID_OPERATION, "GL_ANGLE_framebuffer_multisample not available"));
return false;
}
// ANGLE_framebuffer_multisample states that the value of samples must be less than or equal
// to MAX_SAMPLES_ANGLE (Context::getCaps().maxSamples) otherwise GL_INVALID_OPERATION is
// generated.
if (static_cast<GLuint>(samples) > context->getCaps().maxSamples)
{
context->handleError(Error(GL_INVALID_VALUE));
return false;
}
// ANGLE_framebuffer_multisample states GL_OUT_OF_MEMORY is generated on a failure to create
// the specified storage. This is different than ES 3.0 in which a sample number higher
// than the maximum sample number supported by this format generates a GL_INVALID_VALUE.
// The TextureCaps::getMaxSamples method is only guarenteed to be valid when the context is ES3.
if (context->getClientMajorVersion() >= 3)
{
const TextureCaps &formatCaps = context->getTextureCaps().get(internalformat);
if (static_cast<GLuint>(samples) > formatCaps.getMaxSamples())
{
context->handleError(Error(GL_OUT_OF_MEMORY));
return false;
}
}
return ValidateRenderbufferStorageParametersBase(context, target, samples, internalformat,
width, height);
}
} // namespace gl } // namespace gl
...@@ -381,6 +381,17 @@ bool ValidateVertexAttribPointer(ValidationContext *context, ...@@ -381,6 +381,17 @@ bool ValidateVertexAttribPointer(ValidationContext *context,
const GLvoid *ptr); const GLvoid *ptr);
bool ValidateDepthRangef(ValidationContext *context, GLclampf zNear, GLclampf zFar); bool ValidateDepthRangef(ValidationContext *context, GLclampf zNear, GLclampf zFar);
bool ValidateRenderbufferStorage(ValidationContext *context,
GLenum target,
GLenum internalformat,
GLsizei width,
GLsizei height);
bool ValidateRenderbufferStorageMultisampleANGLE(ValidationContext *context,
GLenum target,
GLsizei samples,
GLenum internalformat,
GLsizei width,
GLsizei height);
} // namespace gl } // namespace gl
......
...@@ -990,42 +990,6 @@ bool ValidateFramebufferTextureLayer(Context *context, ...@@ -990,42 +990,6 @@ bool ValidateFramebufferTextureLayer(Context *context,
return true; return true;
} }
bool ValidateES3RenderbufferStorageParameters(gl::Context *context,
GLenum target,
GLsizei samples,
GLenum internalformat,
GLsizei width,
GLsizei height)
{
if (!ValidateRenderbufferStorageParametersBase(context, target, samples, internalformat, width,
height))
{
return false;
}
// The ES3 spec(section 4.4.2) states that the internal format must be sized and not an integer
// format if samples is greater than zero.
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
if ((formatInfo.componentType == GL_UNSIGNED_INT || formatInfo.componentType == GL_INT) &&
samples > 0)
{
context->handleError(Error(GL_INVALID_OPERATION));
return false;
}
// The behavior is different than the ANGLE version, which would generate a GL_OUT_OF_MEMORY.
const TextureCaps &formatCaps = context->getTextureCaps().get(internalformat);
if (static_cast<GLuint>(samples) > formatCaps.getMaxSamples())
{
context->handleError(
Error(GL_INVALID_OPERATION,
"Samples must not be greater than maximum supported value for the format."));
return false;
}
return true;
}
bool ValidateInvalidateFramebuffer(Context *context, bool ValidateInvalidateFramebuffer(Context *context,
GLenum target, GLenum target,
GLsizei numAttachments, GLsizei numAttachments,
...@@ -2106,4 +2070,46 @@ bool ValidateGetStringi(Context *context, GLenum name, GLuint index) ...@@ -2106,4 +2070,46 @@ bool ValidateGetStringi(Context *context, GLenum name, GLuint index)
return true; return true;
} }
bool ValidateRenderbufferStorageMultisample(ValidationContext *context,
GLenum target,
GLsizei samples,
GLenum internalformat,
GLsizei width,
GLsizei height)
{
if (context->getClientMajorVersion() < 3)
{
context->handleError(Error(GL_INVALID_OPERATION));
return false;
}
if (!ValidateRenderbufferStorageParametersBase(context, target, samples, internalformat, width,
height))
{
return false;
}
// The ES3 spec(section 4.4.2) states that the internal format must be sized and not an integer
// format if samples is greater than zero.
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
if ((formatInfo.componentType == GL_UNSIGNED_INT || formatInfo.componentType == GL_INT) &&
samples > 0)
{
context->handleError(Error(GL_INVALID_OPERATION));
return false;
}
// The behavior is different than the ANGLE version, which would generate a GL_OUT_OF_MEMORY.
const TextureCaps &formatCaps = context->getTextureCaps().get(internalformat);
if (static_cast<GLuint>(samples) > formatCaps.getMaxSamples())
{
context->handleError(
Error(GL_INVALID_OPERATION,
"Samples must not be greater than maximum supported value for the format."));
return false;
}
return true;
}
} // namespace gl } // namespace gl
...@@ -156,9 +156,6 @@ bool ValidateGetQueryObjectuiv(Context *context, GLuint id, GLenum pname, GLuint ...@@ -156,9 +156,6 @@ bool ValidateGetQueryObjectuiv(Context *context, GLuint id, GLenum pname, GLuint
bool ValidateFramebufferTextureLayer(Context *context, GLenum target, GLenum attachment, bool ValidateFramebufferTextureLayer(Context *context, GLenum target, GLenum attachment,
GLuint texture, GLint level, GLint layer); GLuint texture, GLint level, GLint layer);
bool ValidateES3RenderbufferStorageParameters(Context *context, GLenum target, GLsizei samples,
GLenum internalformat, GLsizei width, GLsizei height);
bool ValidateInvalidateFramebuffer(Context *context, GLenum target, GLsizei numAttachments, bool ValidateInvalidateFramebuffer(Context *context, GLenum target, GLsizei numAttachments,
const GLenum *attachments); const GLenum *attachments);
...@@ -365,6 +362,12 @@ bool ValidateCopyBufferSubData(ValidationContext *context, ...@@ -365,6 +362,12 @@ bool ValidateCopyBufferSubData(ValidationContext *context,
GLsizeiptr size); GLsizeiptr size);
bool ValidateGetStringi(Context *context, GLenum name, GLuint index); bool ValidateGetStringi(Context *context, GLenum name, GLuint index);
bool ValidateRenderbufferStorageMultisample(ValidationContext *context,
GLenum target,
GLsizei samples,
GLenum internalformat,
GLsizei width,
GLsizei height);
} // namespace gl } // namespace gl
......
...@@ -1966,19 +1966,13 @@ void GL_APIENTRY RenderbufferStorage(GLenum target, GLenum internalformat, GLsiz ...@@ -1966,19 +1966,13 @@ void GL_APIENTRY RenderbufferStorage(GLenum target, GLenum internalformat, GLsiz
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (!ValidateRenderbufferStorageParametersANGLE(context, target, 0, internalformat, if (!context->skipValidation() &&
width, height)) !ValidateRenderbufferStorage(context, target, internalformat, width, height))
{ {
return; return;
} }
Renderbuffer *renderbuffer = context->getGLState().getCurrentRenderbuffer(); context->renderbufferStorage(target, internalformat, width, height);
Error error = renderbuffer->setStorage(internalformat, width, height);
if (error.isError())
{
context->handleError(error);
return;
}
} }
} }
......
...@@ -538,19 +538,14 @@ void GL_APIENTRY RenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samp ...@@ -538,19 +538,14 @@ void GL_APIENTRY RenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samp
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (!ValidateRenderbufferStorageParametersANGLE(context, target, samples, internalformat, if (!context->skipValidation() &&
width, height)) !ValidateRenderbufferStorageMultisampleANGLE(context, target, samples, internalformat,
width, height))
{ {
return; return;
} }
Renderbuffer *renderbuffer = context->getGLState().getCurrentRenderbuffer(); context->renderbufferStorageMultisample(target, samples, internalformat, width, height);
Error error = renderbuffer->setStorageMultisample(samples, internalformat, width, height);
if (error.isError())
{
context->handleError(error);
return;
}
} }
} }
......
...@@ -490,19 +490,14 @@ void GL_APIENTRY RenderbufferStorageMultisample(GLenum target, GLsizei samples, ...@@ -490,19 +490,14 @@ void GL_APIENTRY RenderbufferStorageMultisample(GLenum target, GLsizei samples,
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (context->getClientMajorVersion() < 3) if (!context->skipValidation() &&
{ !ValidateRenderbufferStorageMultisample(context, target, samples, internalformat, width,
context->handleError(Error(GL_INVALID_OPERATION)); height))
return;
}
if (!ValidateES3RenderbufferStorageParameters(context, target, samples, internalformat, width, height))
{ {
return; return;
} }
Renderbuffer *renderbuffer = context->getGLState().getCurrentRenderbuffer(); context->renderbufferStorageMultisample(target, samples, internalformat, width, height);
renderbuffer->setStorageMultisample(samples, internalformat, width, height);
} }
} }
......
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