mesa: error-check GL_TEXTURE_TILING_EXT params
This just seems like the right thing to do. We shouldn't allow unexpected params just like that. Reviewed-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32349>
This commit is contained in:
committed by
Marge Bot
parent
7b0d401265
commit
284952b864
@@ -248,6 +248,19 @@ _mesa_target_allows_setting_sampler_parameters(GLenum target)
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
is_valid_texture_tiling(struct gl_context *ctx, GLenum tiling)
|
||||
{
|
||||
switch (tiling) {
|
||||
case GL_OPTIMAL_TILING_EXT:
|
||||
case GL_LINEAR_TILING_EXT:
|
||||
return true;
|
||||
case GL_CONST_BW_TILING_MESA:
|
||||
return _mesa_has_MESA_texture_const_bandwidth(ctx);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an integer-valued texture parameter
|
||||
@@ -656,8 +669,10 @@ set_tex_parameteri(struct gl_context *ctx,
|
||||
|
||||
case GL_TEXTURE_TILING_EXT:
|
||||
if (_mesa_has_EXT_memory_object(ctx) && !texObj->Immutable) {
|
||||
texObj->TextureTiling = params[0];
|
||||
if (!is_valid_texture_tiling(ctx, params[0]))
|
||||
goto invalid_param;
|
||||
|
||||
texObj->TextureTiling = params[0];
|
||||
return GL_TRUE;
|
||||
}
|
||||
goto invalid_pname;
|
||||
@@ -876,6 +891,12 @@ set_tex_parameterf(struct gl_context *ctx,
|
||||
|
||||
case GL_TEXTURE_TILING_EXT:
|
||||
if (_mesa_has_EXT_memory_object(ctx)) {
|
||||
if (!is_valid_texture_tiling(ctx, (GLenum)params[0])) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glTex%sParameter(param)",
|
||||
suffix);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
texObj->TextureTiling = params[0];
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user