amd: update gfx10_format_table.py for gfx11
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16328>
This commit is contained in:
parent
931098d44d
commit
9480ad2b1c
|
@ -28,6 +28,7 @@
|
|||
#define GFX10_FORMAT_TABLE_H
|
||||
|
||||
#include "pipe/p_format.h"
|
||||
#include "ac_gpu_info.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
|
@ -41,5 +42,15 @@ struct gfx10_format {
|
|||
};
|
||||
|
||||
extern const struct gfx10_format gfx10_format_table[PIPE_FORMAT_COUNT];
|
||||
extern const struct gfx10_format gfx11_format_table[PIPE_FORMAT_COUNT];
|
||||
|
||||
static inline
|
||||
const struct gfx10_format* ac_get_gfx10_format_table(struct radeon_info *info)
|
||||
{
|
||||
if (info->chip_class >= GFX11)
|
||||
return gfx11_format_table;
|
||||
else
|
||||
return gfx10_format_table;
|
||||
}
|
||||
|
||||
#endif /* GFX10_FORMAT_TABLE_H */
|
||||
|
|
|
@ -103,16 +103,19 @@ HARDCODED = {
|
|||
# Main script
|
||||
|
||||
header_template = mako.template.Template("""\
|
||||
% if header:
|
||||
// DO NOT EDIT -- AUTOMATICALLY GENERATED
|
||||
|
||||
#include "gfx10_format_table.h"
|
||||
#include "amdgfxregs.h"
|
||||
|
||||
% endif
|
||||
|
||||
#define FMT(_img_format, ...) \
|
||||
{ .img_format = V_008F0C_GFX10_FORMAT_##_img_format, \
|
||||
{ .img_format = V_008F0C_${gfx.upper()}_FORMAT_##_img_format, \
|
||||
##__VA_ARGS__ }
|
||||
|
||||
const struct gfx10_format gfx10_format_table[PIPE_FORMAT_COUNT] = {
|
||||
const struct gfx10_format ${gfx}_format_table[PIPE_FORMAT_COUNT] = {
|
||||
% for pipe_format, args in formats:
|
||||
% if args is not None:
|
||||
[${pipe_format}] = FMT(${args}),
|
||||
|
@ -120,6 +123,8 @@ const struct gfx10_format gfx10_format_table[PIPE_FORMAT_COUNT] = {
|
|||
/* ${pipe_format} is not supported */
|
||||
% endif
|
||||
% endfor
|
||||
|
||||
#undef FMT
|
||||
};
|
||||
""")
|
||||
|
||||
|
@ -250,17 +255,7 @@ class Gfx10FormatMapping(object):
|
|||
|
||||
return None
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
pipe_formats = parse(sys.argv[1])
|
||||
|
||||
with open(sys.argv[2], 'r') as filp:
|
||||
db = RegisterDatabase.from_json(json.load(filp))
|
||||
|
||||
gfx10_formats = [Gfx10Format(entry) for entry in db.enum('GFX10_FORMAT').entries]
|
||||
|
||||
mapping = Gfx10FormatMapping(pipe_formats, gfx10_formats)
|
||||
|
||||
def pipe_formats_to_formats(pipe_formats, mapping):
|
||||
formats = []
|
||||
for fmt in pipe_formats:
|
||||
if fmt.name in HARDCODED:
|
||||
|
@ -276,4 +271,25 @@ if __name__ == '__main__':
|
|||
args = None
|
||||
formats.append((fmt.name, args))
|
||||
|
||||
print(header_template.render(formats=formats))
|
||||
return formats
|
||||
|
||||
if __name__ == '__main__':
|
||||
pipe_formats = parse(sys.argv[1])
|
||||
|
||||
# gfx10
|
||||
with open(sys.argv[2], 'r') as filp:
|
||||
db = RegisterDatabase.from_json(json.load(filp))
|
||||
|
||||
gfx10_formats = [Gfx10Format(entry) for entry in db.enum('GFX10_FORMAT').entries]
|
||||
mapping = Gfx10FormatMapping(pipe_formats, gfx10_formats)
|
||||
formats = pipe_formats_to_formats(pipe_formats, mapping)
|
||||
print(header_template.render(header=True, gfx='gfx10', formats=formats))
|
||||
|
||||
# gfx11
|
||||
with open(sys.argv[3], 'r') as filp:
|
||||
db = RegisterDatabase.from_json(json.load(filp))
|
||||
|
||||
gfx11_formats = [Gfx10Format(entry) for entry in db.enum('GFX11_FORMAT').entries]
|
||||
mapping = Gfx10FormatMapping(pipe_formats, gfx11_formats)
|
||||
formats = pipe_formats_to_formats(pipe_formats, mapping)
|
||||
print(header_template.render(header=False, gfx='gfx11', formats=formats))
|
||||
|
|
|
@ -56,7 +56,7 @@ gfx10_format_table_c = custom_target(
|
|||
'gfx10_format_table.c',
|
||||
input : files(
|
||||
'gfx10_format_table.py',
|
||||
'../../util/format/u_format.csv', '../registers/gfx10-rsrc.json'
|
||||
'../../util/format/u_format.csv', '../registers/gfx10-rsrc.json', '../registers/gfx11-rsrc.json'
|
||||
),
|
||||
output : 'gfx10_format_table.c',
|
||||
command : [prog_python, '@INPUT@'],
|
||||
|
|
|
@ -2125,7 +2125,7 @@ static bool si_is_sampler_format_supported(struct pipe_screen *screen, enum pipe
|
|||
return false;
|
||||
|
||||
if (sscreen->info.chip_class >= GFX10) {
|
||||
const struct gfx10_format *fmt = &gfx10_format_table[format];
|
||||
const struct gfx10_format *fmt = &ac_get_gfx10_format_table(&sscreen->info)[format];
|
||||
if (!fmt->img_format || fmt->buffers_only)
|
||||
return false;
|
||||
return true;
|
||||
|
@ -2281,7 +2281,7 @@ static unsigned si_is_vertex_format_supported(struct pipe_screen *screen, enum p
|
|||
}
|
||||
|
||||
if (sscreen->info.chip_class >= GFX10) {
|
||||
const struct gfx10_format *fmt = &gfx10_format_table[format];
|
||||
const struct gfx10_format *fmt = &ac_get_gfx10_format_table(&sscreen->info)[format];
|
||||
if (!fmt->img_format || fmt->img_format >= 128)
|
||||
return 0;
|
||||
return usage;
|
||||
|
@ -3806,7 +3806,7 @@ void si_make_buffer_descriptor(struct si_screen *screen, struct si_resource *buf
|
|||
S_008F0C_DST_SEL_W(si_map_swizzle(desc->swizzle[3]));
|
||||
|
||||
if (screen->info.chip_class >= GFX10) {
|
||||
const struct gfx10_format *fmt = &gfx10_format_table[format];
|
||||
const struct gfx10_format *fmt = &ac_get_gfx10_format_table(&screen->info)[format];
|
||||
|
||||
/* OOB_SELECT chooses the out-of-bounds check:
|
||||
* - 0: (index >= NUM_RECORDS) || (offset >= STRIDE)
|
||||
|
@ -3876,7 +3876,7 @@ static void gfx10_make_texture_descriptor(
|
|||
uint64_t va;
|
||||
|
||||
desc = util_format_description(pipe_format);
|
||||
img_format = gfx10_format_table[pipe_format].img_format;
|
||||
img_format = ac_get_gfx10_format_table(&screen->info)[pipe_format].img_format;
|
||||
|
||||
if (desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) {
|
||||
const unsigned char swizzle_xxxx[4] = {0, 0, 0, 0};
|
||||
|
@ -4898,7 +4898,7 @@ static void *si_create_vertex_elements(struct pipe_context *ctx, unsigned count,
|
|||
S_008F0C_DST_SEL_W(si_map_swizzle(desc->swizzle[3]));
|
||||
|
||||
if (sscreen->info.chip_class >= GFX10) {
|
||||
const struct gfx10_format *fmt = &gfx10_format_table[elements[i].src_format];
|
||||
const struct gfx10_format *fmt = &ac_get_gfx10_format_table(&sscreen->info)[elements[i].src_format];
|
||||
assert(fmt->img_format != 0 && fmt->img_format < 128);
|
||||
v->rsrc_word3[i] |= S_008F0C_FORMAT(fmt->img_format) | S_008F0C_RESOURCE_LEVEL(1);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue