mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 04:38:03 +02:00
additional error checking for GL_EXT_packed_depth_stencil
This commit is contained in:
parent
cef88397a6
commit
0899afae33
1 changed files with 50 additions and 13 deletions
|
|
@ -1687,8 +1687,9 @@ copytexture_error_check( GLcontext *ctx, GLuint dimensions,
|
||||||
GLenum target, GLint level, GLint internalFormat,
|
GLenum target, GLint level, GLint internalFormat,
|
||||||
GLint width, GLint height, GLint border )
|
GLint width, GLint height, GLint border )
|
||||||
{
|
{
|
||||||
GLenum format, type;
|
GLenum type;
|
||||||
GLboolean sizeOK;
|
GLboolean sizeOK;
|
||||||
|
GLint format;
|
||||||
|
|
||||||
/* Basic level check (more checking in ctx->Driver.TestProxyTexImage) */
|
/* Basic level check (more checking in ctx->Driver.TestProxyTexImage) */
|
||||||
if (level < 0 || level >= MAX_TEXTURE_LEVELS) {
|
if (level < 0 || level >= MAX_TEXTURE_LEVELS) {
|
||||||
|
|
@ -1704,10 +1705,16 @@ copytexture_error_check( GLcontext *ctx, GLuint dimensions,
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The format and type aren't really significant here, but we need to pass
|
|
||||||
* something to TestProxyTexImage().
|
|
||||||
*/
|
|
||||||
format = _mesa_base_tex_format(ctx, internalFormat);
|
format = _mesa_base_tex_format(ctx, internalFormat);
|
||||||
|
if (format < 0) {
|
||||||
|
_mesa_error(ctx, GL_INVALID_VALUE,
|
||||||
|
"glCopyTexImage%dD(internalFormat)", dimensions);
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* NOTE: the format and type aren't really significant for
|
||||||
|
* TestProxyTexImage(). Only the internalformat really matters.
|
||||||
|
*/
|
||||||
type = GL_FLOAT;
|
type = GL_FLOAT;
|
||||||
|
|
||||||
/* Check target and call ctx->Driver.TestProxyTexImage() to check the
|
/* Check target and call ctx->Driver.TestProxyTexImage() to check the
|
||||||
|
|
@ -1777,12 +1784,6 @@ copytexture_error_check( GLcontext *ctx, GLuint dimensions,
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_mesa_base_tex_format(ctx, internalFormat) < 0) {
|
|
||||||
_mesa_error(ctx, GL_INVALID_VALUE,
|
|
||||||
"glCopyTexImage%dD(internalFormat)", dimensions);
|
|
||||||
return GL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_compressed_format(ctx, internalFormat)) {
|
if (is_compressed_format(ctx, internalFormat)) {
|
||||||
if (target != GL_TEXTURE_2D) {
|
if (target != GL_TEXTURE_2D) {
|
||||||
_mesa_error(ctx, GL_INVALID_ENUM,
|
_mesa_error(ctx, GL_INVALID_ENUM,
|
||||||
|
|
@ -1795,6 +1796,23 @@ copytexture_error_check( GLcontext *ctx, GLuint dimensions,
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (is_depth_format(internalFormat)) {
|
||||||
|
/* make sure we have depth/stencil buffers */
|
||||||
|
if (!ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer) {
|
||||||
|
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||||
|
"glCopyTexImage%D(no depth)", dimensions);
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (is_depthstencil_format(internalFormat)) {
|
||||||
|
/* make sure we have depth/stencil buffers */
|
||||||
|
if (!ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer ||
|
||||||
|
!ctx->ReadBuffer->Attachment[BUFFER_STENCIL].Renderbuffer) {
|
||||||
|
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||||
|
"glCopyTexImage%D(no depth/stencil buffer)", dimensions);
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* if we get here, the parameters are OK */
|
/* if we get here, the parameters are OK */
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
@ -1956,6 +1974,24 @@ copytexsubimage_error_check( GLcontext *ctx, GLuint dimensions,
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (teximage->Format == GL_DEPTH_COMPONENT) {
|
||||||
|
if (!ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer) {
|
||||||
|
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||||
|
"glCopyTexSubImage%D(no depth buffer)",
|
||||||
|
dimensions);
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (teximage->Format == GL_DEPTH_STENCIL_EXT) {
|
||||||
|
if (!ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer ||
|
||||||
|
!ctx->ReadBuffer->Attachment[BUFFER_STENCIL].Renderbuffer) {
|
||||||
|
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||||
|
"glCopyTexSubImage%D(no depth/stencil buffer)",
|
||||||
|
dimensions);
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* if we get here, the parameters are OK */
|
/* if we get here, the parameters are OK */
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
@ -2035,8 +2071,8 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure the requested image format is compatible with the
|
/* Make sure the requested image format is compatible with the
|
||||||
* texture's format. We let the colorformat-indexformat go through,
|
* texture's format. Note that a color index texture can be converted
|
||||||
* because the texelfetcher will dequantize to full rgba.
|
* to RGBA so that combo is allowed.
|
||||||
*/
|
*/
|
||||||
if (is_color_format(format)
|
if (is_color_format(format)
|
||||||
&& !is_color_format(texImage->TexFormat->BaseFormat)
|
&& !is_color_format(texImage->TexFormat->BaseFormat)
|
||||||
|
|
@ -2050,7 +2086,8 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (is_depth_format(format)
|
else if (is_depth_format(format)
|
||||||
&& !is_depth_format(texImage->TexFormat->BaseFormat)) {
|
&& !is_depth_format(texImage->TexFormat->BaseFormat)
|
||||||
|
&& !is_depthstencil_format(texImage->TexFormat->BaseFormat)) {
|
||||||
_mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)");
|
_mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue