Commit 8227d9c3 authored by Adam Jackson's avatar Adam Jackson 🎧
Browse files

mesa/texstore: Don't declare StoreTexImageFunc tables static

Doing so forces the compiler to actually emit storage for them in bss.
If we build the table as a local the compiler is allowed to optimize it
down to constants. Trades about 500 bytes of text for -6000 bytes of
bss:

   text	   data	    bss	    dec	    hex	filename
  16496	      0	   6146	  22642	   5872	build/src/mesa/bbe4a73@@mesa_common@sta/main_texstore.c.o
  17026	      0	      0	  17026	   4282	build/src/mesa/bbe4a73@@mesa_common@sta/main_texstore.c.o
parent 9522eb7b
Pipeline #196033 waiting for manual action with stages
......@@ -582,24 +582,17 @@ _mesa_texstore_z32f_x24s8(TEXSTORE_PARAMS)
static GLboolean
texstore_depth_stencil(TEXSTORE_PARAMS)
{
static StoreTexImageFunc table[MESA_FORMAT_COUNT];
static GLboolean initialized = GL_FALSE;
if (!initialized) {
memset(table, 0, sizeof table);
table[MESA_FORMAT_S8_UINT_Z24_UNORM] = _mesa_texstore_z24_s8;
table[MESA_FORMAT_Z24_UNORM_S8_UINT] = _mesa_texstore_s8_z24;
table[MESA_FORMAT_Z_UNORM16] = _mesa_texstore_z16;
table[MESA_FORMAT_Z24_UNORM_X8_UINT] = _mesa_texstore_x8_z24;
table[MESA_FORMAT_X8_UINT_Z24_UNORM] = _mesa_texstore_z24_x8;
table[MESA_FORMAT_Z_UNORM32] = _mesa_texstore_z32;
table[MESA_FORMAT_S_UINT8] = _mesa_texstore_s8;
table[MESA_FORMAT_Z_FLOAT32] = _mesa_texstore_z32;
table[MESA_FORMAT_Z32_FLOAT_S8X24_UINT] = _mesa_texstore_z32f_x24s8;
initialized = GL_TRUE;
}
StoreTexImageFunc table[MESA_FORMAT_COUNT] = { 0, };
table[MESA_FORMAT_S8_UINT_Z24_UNORM] = _mesa_texstore_z24_s8;
table[MESA_FORMAT_Z24_UNORM_S8_UINT] = _mesa_texstore_s8_z24;
table[MESA_FORMAT_Z_UNORM16] = _mesa_texstore_z16;
table[MESA_FORMAT_Z24_UNORM_X8_UINT] = _mesa_texstore_x8_z24;
table[MESA_FORMAT_X8_UINT_Z24_UNORM] = _mesa_texstore_z24_x8;
table[MESA_FORMAT_Z_UNORM32] = _mesa_texstore_z32;
table[MESA_FORMAT_S_UINT8] = _mesa_texstore_s8;
table[MESA_FORMAT_Z_FLOAT32] = _mesa_texstore_z32;
table[MESA_FORMAT_Z32_FLOAT_S8X24_UINT] = _mesa_texstore_z32f_x24s8;
assert(table[dstFormat]);
return table[dstFormat](ctx, dims, baseInternalFormat,
......@@ -611,55 +604,42 @@ texstore_depth_stencil(TEXSTORE_PARAMS)
static GLboolean
texstore_compressed(TEXSTORE_PARAMS)
{
static StoreTexImageFunc table[MESA_FORMAT_COUNT];
static GLboolean initialized = GL_FALSE;
if (!initialized) {
memset(table, 0, sizeof table);
table[MESA_FORMAT_SRGB_DXT1] = _mesa_texstore_rgb_dxt1;
table[MESA_FORMAT_SRGBA_DXT1] = _mesa_texstore_rgba_dxt1;
table[MESA_FORMAT_SRGBA_DXT3] = _mesa_texstore_rgba_dxt3;
table[MESA_FORMAT_SRGBA_DXT5] = _mesa_texstore_rgba_dxt5;
table[MESA_FORMAT_RGB_FXT1] = _mesa_texstore_rgb_fxt1;
table[MESA_FORMAT_RGBA_FXT1] = _mesa_texstore_rgba_fxt1;
table[MESA_FORMAT_RGB_DXT1] = _mesa_texstore_rgb_dxt1;
table[MESA_FORMAT_RGBA_DXT1] = _mesa_texstore_rgba_dxt1;
table[MESA_FORMAT_RGBA_DXT3] = _mesa_texstore_rgba_dxt3;
table[MESA_FORMAT_RGBA_DXT5] = _mesa_texstore_rgba_dxt5;
table[MESA_FORMAT_R_RGTC1_UNORM] = _mesa_texstore_red_rgtc1;
table[MESA_FORMAT_R_RGTC1_SNORM] = _mesa_texstore_signed_red_rgtc1;
table[MESA_FORMAT_RG_RGTC2_UNORM] = _mesa_texstore_rg_rgtc2;
table[MESA_FORMAT_RG_RGTC2_SNORM] = _mesa_texstore_signed_rg_rgtc2;
table[MESA_FORMAT_L_LATC1_UNORM] = _mesa_texstore_red_rgtc1;
table[MESA_FORMAT_L_LATC1_SNORM] = _mesa_texstore_signed_red_rgtc1;
table[MESA_FORMAT_LA_LATC2_UNORM] = _mesa_texstore_rg_rgtc2;
table[MESA_FORMAT_LA_LATC2_SNORM] = _mesa_texstore_signed_rg_rgtc2;
table[MESA_FORMAT_ETC1_RGB8] = _mesa_texstore_etc1_rgb8;
table[MESA_FORMAT_ETC2_RGB8] = _mesa_texstore_etc2_rgb8;
table[MESA_FORMAT_ETC2_SRGB8] = _mesa_texstore_etc2_srgb8;
table[MESA_FORMAT_ETC2_RGBA8_EAC] = _mesa_texstore_etc2_rgba8_eac;
table[MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC] = _mesa_texstore_etc2_srgb8_alpha8_eac;
table[MESA_FORMAT_ETC2_R11_EAC] = _mesa_texstore_etc2_r11_eac;
table[MESA_FORMAT_ETC2_RG11_EAC] = _mesa_texstore_etc2_rg11_eac;
table[MESA_FORMAT_ETC2_SIGNED_R11_EAC] = _mesa_texstore_etc2_signed_r11_eac;
table[MESA_FORMAT_ETC2_SIGNED_RG11_EAC] = _mesa_texstore_etc2_signed_rg11_eac;
table[MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1] =
_mesa_texstore_etc2_rgb8_punchthrough_alpha1;
table[MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1] =
_mesa_texstore_etc2_srgb8_punchthrough_alpha1;
table[MESA_FORMAT_BPTC_RGBA_UNORM] =
_mesa_texstore_bptc_rgba_unorm;
table[MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM] =
_mesa_texstore_bptc_rgba_unorm;
table[MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT] =
_mesa_texstore_bptc_rgb_signed_float;
table[MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT] =
_mesa_texstore_bptc_rgb_unsigned_float;
initialized = GL_TRUE;
}
StoreTexImageFunc table[MESA_FORMAT_COUNT] = { 0, };
table[MESA_FORMAT_SRGB_DXT1] = _mesa_texstore_rgb_dxt1;
table[MESA_FORMAT_SRGBA_DXT1] = _mesa_texstore_rgba_dxt1;
table[MESA_FORMAT_SRGBA_DXT3] = _mesa_texstore_rgba_dxt3;
table[MESA_FORMAT_SRGBA_DXT5] = _mesa_texstore_rgba_dxt5;
table[MESA_FORMAT_RGB_FXT1] = _mesa_texstore_rgb_fxt1;
table[MESA_FORMAT_RGBA_FXT1] = _mesa_texstore_rgba_fxt1;
table[MESA_FORMAT_RGB_DXT1] = _mesa_texstore_rgb_dxt1;
table[MESA_FORMAT_RGBA_DXT1] = _mesa_texstore_rgba_dxt1;
table[MESA_FORMAT_RGBA_DXT3] = _mesa_texstore_rgba_dxt3;
table[MESA_FORMAT_RGBA_DXT5] = _mesa_texstore_rgba_dxt5;
table[MESA_FORMAT_R_RGTC1_UNORM] = _mesa_texstore_red_rgtc1;
table[MESA_FORMAT_R_RGTC1_SNORM] = _mesa_texstore_signed_red_rgtc1;
table[MESA_FORMAT_RG_RGTC2_UNORM] = _mesa_texstore_rg_rgtc2;
table[MESA_FORMAT_RG_RGTC2_SNORM] = _mesa_texstore_signed_rg_rgtc2;
table[MESA_FORMAT_L_LATC1_UNORM] = _mesa_texstore_red_rgtc1;
table[MESA_FORMAT_L_LATC1_SNORM] = _mesa_texstore_signed_red_rgtc1;
table[MESA_FORMAT_LA_LATC2_UNORM] = _mesa_texstore_rg_rgtc2;
table[MESA_FORMAT_LA_LATC2_SNORM] = _mesa_texstore_signed_rg_rgtc2;
table[MESA_FORMAT_ETC1_RGB8] = _mesa_texstore_etc1_rgb8;
table[MESA_FORMAT_ETC2_RGB8] = _mesa_texstore_etc2_rgb8;
table[MESA_FORMAT_ETC2_SRGB8] = _mesa_texstore_etc2_srgb8;
table[MESA_FORMAT_ETC2_RGBA8_EAC] = _mesa_texstore_etc2_rgba8_eac;
table[MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC] = _mesa_texstore_etc2_srgb8_alpha8_eac;
table[MESA_FORMAT_ETC2_R11_EAC] = _mesa_texstore_etc2_r11_eac;
table[MESA_FORMAT_ETC2_RG11_EAC] = _mesa_texstore_etc2_rg11_eac;
table[MESA_FORMAT_ETC2_SIGNED_R11_EAC] = _mesa_texstore_etc2_signed_r11_eac;
table[MESA_FORMAT_ETC2_SIGNED_RG11_EAC] = _mesa_texstore_etc2_signed_rg11_eac;
table[MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1] = _mesa_texstore_etc2_rgb8_punchthrough_alpha1;
table[MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1] = _mesa_texstore_etc2_srgb8_punchthrough_alpha1;
table[MESA_FORMAT_BPTC_RGBA_UNORM] = _mesa_texstore_bptc_rgba_unorm;
table[MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM] = _mesa_texstore_bptc_rgba_unorm;
table[MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT] = _mesa_texstore_bptc_rgb_signed_float;
table[MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT] = _mesa_texstore_bptc_rgb_unsigned_float;
assert(table[dstFormat]);
return table[dstFormat](ctx, dims, baseInternalFormat,
......
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