Commit 510b6424 authored by Erik Faye-Lund 's avatar Erik Faye-Lund

mesa/main: do not allow rg-textures enums before gles3

EXT_packed_float isn't supported on OpenGL ES, we shouldn't allow
these enums there, before OpenGL ES 3.0 which also introduce support
for these enums.

Since this check is repeated a lot, let's make a helper for this.
Signed-off-by: Erik Faye-Lund 's avatarErik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: 's avatarMarek Olšák <marek.olsak@amd.com>
parent 59690bf0
......@@ -361,6 +361,12 @@ _mesa_has_packed_float(const struct gl_context *ctx)
return _mesa_has_EXT_packed_float(ctx) || _mesa_is_gles3(ctx);
}
static inline bool
_mesa_has_rg_textures(const struct gl_context *ctx)
{
return _mesa_has_ARB_texture_rg(ctx) || _mesa_is_gles3(ctx);
}
/**
* Checks if the context supports geometry shaders.
*/
......
......@@ -1876,7 +1876,7 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx,
return GL_NO_ERROR;
case GL_RG:
case GL_RED:
if (_mesa_is_gles3(ctx) || ctx->Extensions.ARB_texture_rg)
if (_mesa_has_rg_textures(ctx))
return GL_NO_ERROR;
default:
return GL_INVALID_OPERATION;
......@@ -1930,8 +1930,8 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx,
}
case GL_RG:
if (!ctx->Extensions.ARB_texture_rg)
return GL_INVALID_ENUM;
if (!_mesa_has_rg_textures(ctx))
return GL_INVALID_ENUM;
switch (type) {
case GL_BYTE:
case GL_UNSIGNED_BYTE:
......@@ -2170,7 +2170,7 @@ _mesa_es_error_check_format_and_type(const struct gl_context *ctx,
switch (format) {
case GL_RED:
case GL_RG:
if (ctx->API == API_OPENGLES || !ctx->Extensions.ARB_texture_rg)
if (!_mesa_has_rg_textures(ctx))
return GL_INVALID_VALUE;
/* fallthrough */
case GL_ALPHA:
......@@ -2543,7 +2543,7 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint internalFormat)
}
}
if (ctx->Extensions.ARB_texture_rg) {
if (_mesa_has_rg_textures(ctx)) {
switch (internalFormat) {
case GL_R16F:
case GL_R32F:
......@@ -3105,7 +3105,7 @@ _mesa_gles_error_check_format_and_type(const struct gl_context *ctx,
break;
case GL_RG:
if (!ctx->Extensions.ARB_texture_rg)
if (!_mesa_has_rg_textures(ctx))
return GL_INVALID_OPERATION;
switch (type) {
case GL_UNSIGNED_BYTE:
......@@ -3137,7 +3137,7 @@ _mesa_gles_error_check_format_and_type(const struct gl_context *ctx,
return GL_INVALID_OPERATION;
break;
case GL_RG:
if (ctx->Extensions.ARB_texture_rg &&
if (_mesa_has_rg_textures(ctx) &&
ctx->Extensions.OES_texture_half_float)
break;
/* fallthrough */
......@@ -3152,7 +3152,7 @@ _mesa_gles_error_check_format_and_type(const struct gl_context *ctx,
case GL_RG32F:
break;
case GL_RG:
if (ctx->Extensions.ARB_texture_rg &&
if (_mesa_has_rg_textures(ctx) &&
ctx->Extensions.OES_texture_float)
break;
/* fallthrough */
......@@ -3206,7 +3206,7 @@ _mesa_gles_error_check_format_and_type(const struct gl_context *ctx,
break;
case GL_RED:
if (!ctx->Extensions.ARB_texture_rg)
if (!_mesa_has_rg_textures(ctx))
return GL_INVALID_OPERATION;
switch (type) {
case GL_UNSIGNED_BYTE:
......@@ -3241,7 +3241,7 @@ _mesa_gles_error_check_format_and_type(const struct gl_context *ctx,
break;
case GL_RG:
case GL_RED:
if (ctx->Extensions.ARB_texture_rg &&
if (_mesa_has_rg_textures(ctx) &&
ctx->Extensions.OES_texture_half_float)
break;
/* fallthrough */
......@@ -3256,7 +3256,7 @@ _mesa_gles_error_check_format_and_type(const struct gl_context *ctx,
case GL_R32F:
break;
case GL_RED:
if (ctx->Extensions.ARB_texture_rg &&
if (_mesa_has_rg_textures(ctx) &&
ctx->Extensions.OES_texture_float)
break;
/* fallthrough */
......
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