intel: properly constify isl_format_layouts
Putting a const char * in the struct means it's a pointer that has to be resolved at rtld time, which means it can be in .data.rel.ro but not .rodata like you'd hope. Fix this with the usual string table trick. Cuts about 20k (-80k read-write +60k read-only) and ~280 relocations from the gallium driver. Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11168>
This commit is contained in:
parent
8fb1300333
commit
ed6e586562
|
@ -61,12 +61,23 @@ TEMPLATE = template.Template(future_imports=['division'],
|
||||||
|
|
||||||
#include "isl/isl.h"
|
#include "isl/isl.h"
|
||||||
|
|
||||||
|
const uint16_t isl_format_name_offsets[] = { <% offset = 0 %>
|
||||||
|
% for format in formats:
|
||||||
|
${offset}, <% offset += 11 + len(format.name) + 1 %>
|
||||||
|
% endfor
|
||||||
|
};
|
||||||
|
|
||||||
|
const char isl_format_names[] = {
|
||||||
|
% for format in formats:
|
||||||
|
"ISL_FORMAT_${format.name}\\0"
|
||||||
|
% endfor
|
||||||
|
};
|
||||||
|
|
||||||
const struct isl_format_layout
|
const struct isl_format_layout
|
||||||
isl_format_layouts[] = {
|
isl_format_layouts[] = {
|
||||||
% for format in formats:
|
% for format in formats:
|
||||||
[ISL_FORMAT_${format.name}] = {
|
[ISL_FORMAT_${format.name}] = {
|
||||||
.format = ISL_FORMAT_${format.name},
|
.format = ISL_FORMAT_${format.name},
|
||||||
.name = "ISL_FORMAT_${format.name}",
|
|
||||||
.bpb = ${format.bpb},
|
.bpb = ${format.bpb},
|
||||||
.bw = ${format.bw},
|
.bw = ${format.bw},
|
||||||
.bh = ${format.bh},
|
.bh = ${format.bh},
|
||||||
|
@ -94,7 +105,7 @@ isl_format_is_valid(enum isl_format format)
|
||||||
{
|
{
|
||||||
if (format >= sizeof(isl_format_layouts) / sizeof(isl_format_layouts[0]))
|
if (format >= sizeof(isl_format_layouts) / sizeof(isl_format_layouts[0]))
|
||||||
return false;
|
return false;
|
||||||
return isl_format_layouts[format].name;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum isl_format
|
enum isl_format
|
||||||
|
|
|
@ -1116,7 +1116,6 @@ struct isl_channel_layout {
|
||||||
*/
|
*/
|
||||||
struct isl_format_layout {
|
struct isl_format_layout {
|
||||||
enum isl_format format;
|
enum isl_format format;
|
||||||
const char *name;
|
|
||||||
|
|
||||||
uint16_t bpb; /**< Bits per block */
|
uint16_t bpb; /**< Bits per block */
|
||||||
uint8_t bw; /**< Block width, in pixels */
|
uint8_t bw; /**< Block width, in pixels */
|
||||||
|
@ -1522,6 +1521,8 @@ struct isl_depth_stencil_hiz_emit_info {
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const struct isl_format_layout isl_format_layouts[];
|
extern const struct isl_format_layout isl_format_layouts[];
|
||||||
|
extern const char isl_format_names[];
|
||||||
|
extern const uint16_t isl_format_name_offsets[];
|
||||||
|
|
||||||
void
|
void
|
||||||
isl_device_init(struct isl_device *dev,
|
isl_device_init(struct isl_device *dev,
|
||||||
|
@ -1544,7 +1545,9 @@ bool isl_format_is_valid(enum isl_format);
|
||||||
static inline const char * ATTRIBUTE_CONST
|
static inline const char * ATTRIBUTE_CONST
|
||||||
isl_format_get_name(enum isl_format fmt)
|
isl_format_get_name(enum isl_format fmt)
|
||||||
{
|
{
|
||||||
return isl_format_get_layout(fmt)->name;
|
assert(fmt != ISL_FORMAT_UNSUPPORTED);
|
||||||
|
assert(fmt < ISL_NUM_FORMATS);
|
||||||
|
return isl_format_names + isl_format_name_offsets[fmt];
|
||||||
}
|
}
|
||||||
|
|
||||||
enum isl_format isl_format_for_pipe_format(enum pipe_format pf);
|
enum isl_format isl_format_for_pipe_format(enum pipe_format pf);
|
||||||
|
|
|
@ -1896,7 +1896,7 @@ can_texture_with_ccs(struct brw_context *brw,
|
||||||
if (!format_ccs_e_compat_with_miptree(&brw->screen->devinfo,
|
if (!format_ccs_e_compat_with_miptree(&brw->screen->devinfo,
|
||||||
mt, view_format)) {
|
mt, view_format)) {
|
||||||
perf_debug("Incompatible sampling format (%s) for rbc (%s)\n",
|
perf_debug("Incompatible sampling format (%s) for rbc (%s)\n",
|
||||||
isl_format_get_layout(view_format)->name,
|
isl_format_get_name(view_format),
|
||||||
_mesa_get_format_name(mt->format));
|
_mesa_get_format_name(mt->format));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue