[Mesa-dev] [PATCH 11/41] intel: Kill intel_mipmap_level::nr_images [v2]
Chad Versace
chad.versace at linux.intel.com
Fri Nov 18 16:17:35 PST 2011
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 11/18/2011 03:55 PM, Kenneth Graunke wrote:
> On 11/18/2011 01:52 PM, Chad Versace wrote:
> [snip]
>> @@ -335,23 +338,18 @@ intel_miptree_get_image_offset(struct intel_mipmap_tree *mt,
>> GLuint level, GLuint face, GLuint depth,
>> GLuint *x, GLuint *y)
>> {
>> - switch (mt->target) {
>> - case GL_TEXTURE_CUBE_MAP_ARB:
>> - *x = mt->level[level].slice[face].x_offset;
>> - *y = mt->level[level].slice[face].y_offset;
>> - break;
>> - case GL_TEXTURE_3D:
>> - case GL_TEXTURE_2D_ARRAY_EXT:
>> - case GL_TEXTURE_1D_ARRAY_EXT:
>> - assert(depth < mt->level[level].nr_images);
>> - *x = mt->level[level].slice[depth].x_offset;
>> - *y = mt->level[level].slice[depth].y_offset;
>> - break;
>> - default:
>> - *x = mt->level[level].slice[0].x_offset;
>> - *y = mt->level[level].slice[0].y_offset;
>> - break;
>> + int slice;
>> +
>> + if (face > 0) {
>> + assert(face < 6);
>> + assert(depth == 0);
>> + slice = face;
>> + } else {
>> + slice = depth;
>> }
>
> I find the face > 0 check confusing. For cube face 0, you're falling
> through to the array case and relying the fact that depth == 0 for
> cubemaps. Yes, it works, but...bizarre.
>
> You're also relying on depth == 0 for non-cube/non-array cases, but that
> seems entirely reasonable to me.
>
> Perhaps just change the (face > 0) check to (mt->target ==
> GL_TEXTURE_CUBE_MAP)? That seems clear enough.
If it looks bizarre to you, it will likely look bizarre to others too. I dislike
bizarre code, so I'll change this with your (mt->target = GL_TEXTURE_CUBE_MAP)
suggestion.
>
> Technically you could just drop the changes in this function (they're
> not necessary), but I do like the cleanup.
True that it's not really needed. I cleaned it up because it seemed that
the old code did a lot of special-casing for no good reason.
- ----
Chad Versace
chad.versace at linux.intel.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQIcBAEBAgAGBQJOxvWdAAoJEAIvNt057x8iq5YP/REghGtNAaYC7hKdnfeuCYU7
LGHF728d57q0wzntZT+h0bOdXZh4hhRXXFaxYHniLovBLufUOLnLG2BUrz2aFqzq
QcRWqRx6KKoe/9Fy7iq4fAS5+DEoNNidLnLkBsIKcOuEgUtXYLXRIkhtxV3ZkKyA
9ahk30aA+jbaTK7allTMX52+JLs3pkdClALOykkWhKocAPskWa4a/fW44KKq4ASq
0bYcQeb5Behu0GGCKF8hfNtblxsNYUBWMLgAgPKN8MSaMZocLbw+VZOuv7ENz3zh
CcN4BIIMXoFrwrvaSaNFmLJVwbuFK0qtTpIeNFbrVmIQh+tEgEuXhPkkXmpAYhym
0akN/eV8yNVwClhM4XGEw0firvdm6cTJKImOX+nvgJUVMP+Ll2clpYjNDPnfKPp6
+v/e6PWOjxjht/go07ED+vWuk46mr/eEQ4ZIzlkN2RF1mgd6Yc/hGpM38M3yOEet
6zNvrtfKzi0mMgvm5ZAxPpAvDUpvbzrKP/3UaNJN3NrWlVpBt/q3eb/jpd8HFEq6
w2fYSrX4g+X+PLT/k+14XXeEQxhLD9E5pv5AQyus0jlBhatbAGm7RbMmqgsiOdE/
bAFIhE4T7Ra6VQG4LUzOfl2xhewojz0g5FDQT6LDr1FkKWs/hpZx286AzCS2vDki
mGbS0DPxKXLdTD8IGKuo
=bkdP
-----END PGP SIGNATURE-----
More information about the mesa-dev
mailing list