asahi: Use PIPE_FORMATs for driver-compiler ABI
This avoids exposing the ISA-internal agx_format to the driver, instead hiding it behind a real PIPE_FORMAT. This lets us use real pipe formats in formatted intrinsics in NIR, which is convenient; it will allow us to simplify the compiler/driver ABI; and it lets us use common format helpers (e.g. util_format_get_blocksize) for the internal formats in driver lowering. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19871>
This commit is contained in:

committed by
Marge Bot

parent
940b871dba
commit
6ee6cfec41
30
src/asahi/compiler/agx_internal_formats.h
Normal file
30
src/asahi/compiler/agx_internal_formats.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2022 Alyssa Rosenzweig
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef AGX_INTERNAL_FORMATS_H
|
||||
#define AGX_INTERNAL_FORMATS_H
|
||||
|
||||
#include "util/format/u_formats.h"
|
||||
|
||||
/* Define aliases for the subset formats that are accessible in the ISA. These
|
||||
* subsets disregard component mapping and number of components. This
|
||||
* constitutes ABI with the compiler.
|
||||
*/
|
||||
enum agx_internal_formats {
|
||||
AGX_INTERNAL_FORMAT_I8 = PIPE_FORMAT_R8_UINT,
|
||||
AGX_INTERNAL_FORMAT_I16 = PIPE_FORMAT_R16_UINT,
|
||||
AGX_INTERNAL_FORMAT_I32 = PIPE_FORMAT_R32_UINT,
|
||||
AGX_INTERNAL_FORMAT_F16 = PIPE_FORMAT_R16_FLOAT,
|
||||
AGX_INTERNAL_FORMAT_U8NORM = PIPE_FORMAT_R8_UNORM,
|
||||
AGX_INTERNAL_FORMAT_S8NORM = PIPE_FORMAT_R8_SNORM,
|
||||
AGX_INTERNAL_FORMAT_U16NORM = PIPE_FORMAT_R16_UNORM,
|
||||
AGX_INTERNAL_FORMAT_S16NORM = PIPE_FORMAT_R16_SNORM,
|
||||
AGX_INTERNAL_FORMAT_RGB10A2 = PIPE_FORMAT_R10G10B10A2_UNORM,
|
||||
AGX_INTERNAL_FORMAT_SRGBA8 = PIPE_FORMAT_R8G8B8A8_SRGB,
|
||||
AGX_INTERNAL_FORMAT_RG11B10F = PIPE_FORMAT_R11G11B10_FLOAT,
|
||||
AGX_INTERNAL_FORMAT_RGB9E5 = PIPE_FORMAT_R9G9B9E5_FLOAT
|
||||
};
|
||||
|
||||
#endif
|
@@ -23,17 +23,18 @@
|
||||
|
||||
#include "agx_pack.h"
|
||||
#include "agx_formats.h"
|
||||
#include "agx_internal_formats.h"
|
||||
|
||||
#define T true
|
||||
#define F false
|
||||
#define AGX_FORMAT__ 0
|
||||
#define AGX_INTERNAL_FORMAT__ PIPE_FORMAT_NONE
|
||||
|
||||
#define AGX_FMT(pipe, channels_, type_, is_renderable, internal_fmt) \
|
||||
[PIPE_FORMAT_ ## pipe] = { \
|
||||
.channels = AGX_CHANNELS_ ## channels_, \
|
||||
.type = AGX_TEXTURE_TYPE_ ## type_, \
|
||||
.renderable = is_renderable, \
|
||||
.internal = AGX_FORMAT_ ## internal_fmt,\
|
||||
.internal = (enum pipe_format) AGX_INTERNAL_FORMAT_ ## internal_fmt,\
|
||||
}
|
||||
|
||||
const struct agx_pixel_format_entry agx_pixel_format[PIPE_FORMAT_COUNT] = {
|
||||
|
@@ -32,7 +32,7 @@ struct agx_pixel_format_entry {
|
||||
uint8_t channels;
|
||||
uint8_t type;
|
||||
bool renderable : 1;
|
||||
enum agx_format internal : 4;
|
||||
enum pipe_format internal;
|
||||
};
|
||||
|
||||
extern const struct agx_pixel_format_entry agx_pixel_format[PIPE_FORMAT_COUNT];
|
||||
|
@@ -746,8 +746,7 @@ agx_flush_batch(struct agx_context *ctx, struct agx_batch *batch)
|
||||
agx_pool_upload(&batch->pool, clear_colour, sizeof(clear_colour)));
|
||||
|
||||
if (batch->key.cbufs[0]) {
|
||||
enum pipe_format fmt = batch->key.cbufs[0]->format;
|
||||
enum agx_format internal = agx_pixel_format[fmt].internal;
|
||||
enum agx_format internal = AGX_FORMAT_U8NORM /* other formats broken */;
|
||||
uint32_t shader = dev->reload.format[internal];
|
||||
|
||||
pipeline_reload = agx_build_reload_pipeline(batch, shader,
|
||||
|
@@ -1240,7 +1240,7 @@ agx_update_fs(struct agx_batch *batch)
|
||||
if (surf) {
|
||||
enum pipe_format fmt = surf->format;
|
||||
key.rt_formats[i] = fmt;
|
||||
key.base.fs.tib_formats[i] = agx_pixel_format[fmt].internal;
|
||||
key.base.fs.tib_formats[i] = AGX_FORMAT_U8NORM /* other formats broken */;
|
||||
} else {
|
||||
key.rt_formats[i] = PIPE_FORMAT_NONE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user