<div dir="ltr"><div>Reviewed-by: Marek Olšák <<a href="mailto:marek.olsak@amd.com">marek.olsak@amd.com</a>><br><br></div>Marek<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 19, 2018 at 2:26 PM, Francisco Jerez <span dir="ltr"><<a href="mailto:currojerez@riseup.net" target="_blank">currojerez@riseup.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This reverts commit c0ed52f6146c7e24e1275451773bd4<wbr>7c1eda3145. It was<br>
preventing the image format validation from being done on buffer<br>
textures, which is required to ensure that the application doesn't<br>
attempt to create a buffer texture with an internal format<br>
incompatible with the image unit format (e.g. of different texel<br>
size), which is not allowed by the spec (it's not allowed for *any*<br>
texture target, whether or not there is spec wording restricting this<br>
behavior specifically for buffer textures) and will cause the driver<br>
to calculate texel bounds incorrectly and potentially crash instead of<br>
the expected behavior.<br>
<br>
Cc: <a href="mailto:mesa-stable@lists.freedesktop.org">mesa-stable@lists.freedesktop.<wbr>org</a><br>
---<br>
src/mesa/main/shaderimage.c | 25 ++++++++++++-------------<br>
1 file changed, 12 insertions(+), 13 deletions(-)<br>
<br>
diff --git a/src/mesa/main/shaderimage.c b/src/mesa/main/shaderimage.c<br>
index 596eadd4f85..054ab1d95e4 100644<br>
--- a/src/mesa/main/shaderimage.c<br>
+++ b/src/mesa/main/shaderimage.c<br>
@@ -479,13 +479,6 @@ _mesa_is_image_unit_valid(<wbr>struct gl_context *ctx, struct gl_image_unit *u)<br>
if (!t)<br>
return GL_FALSE;<br>
<br>
- /* The GL 4.5 Core spec doesn't say anything about buffers. In practice,<br>
- * the image buffer format is always compatible with the underlying<br>
- * buffer storage.<br>
- */<br>
- if (t->Target == GL_TEXTURE_BUFFER)<br>
- return GL_TRUE;<br>
-<br>
if (!t->_BaseComplete && !t->_MipmapComplete)<br>
_mesa_test_texobj_<wbr>completeness(ctx, t);<br>
<br>
@@ -499,14 +492,20 @@ _mesa_is_image_unit_valid(<wbr>struct gl_context *ctx, struct gl_image_unit *u)<br>
u->_Layer >= _mesa_get_texture_layers(t, u->Level))<br>
return GL_FALSE;<br>
<br>
- struct gl_texture_image *img = (t->Target == GL_TEXTURE_CUBE_MAP ?<br>
- t->Image[u->_Layer][u->Level] :<br>
- t->Image[0][u->Level]);<br>
+ if (t->Target == GL_TEXTURE_BUFFER) {<br>
+ tex_format = _mesa_get_shader_image_format(<wbr>t->BufferObjectFormat);<br>
<br>
- if (!img || img->Border || img->NumSamples > ctx->Const.MaxImageSamples)<br>
- return GL_FALSE;<br>
+ } else {<br>
+ struct gl_texture_image *img = (t->Target == GL_TEXTURE_CUBE_MAP ?<br>
+ t->Image[u->_Layer][u->Level] :<br>
+ t->Image[0][u->Level]);<br>
+<br>
+ if (!img || img->Border || img->NumSamples > ctx->Const.MaxImageSamples)<br>
+ return GL_FALSE;<br>
+<br>
+ tex_format = _mesa_get_shader_image_format(<wbr>img->InternalFormat);<br>
+ }<br>
<br>
- tex_format = _mesa_get_shader_image_format(<wbr>img->InternalFormat);<br>
if (!tex_format)<br>
return GL_FALSE;<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.16.1<br>
<br>
______________________________<wbr>_________________<br>
mesa-stable mailing list<br>
<a href="mailto:mesa-stable@lists.freedesktop.org">mesa-stable@lists.freedesktop.<wbr>org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-stable" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-stable</a><br>
</font></span></blockquote></div><br></div>