agx: Add agx_format_shift routine
Required to calculate alignments for vertex buffers correctly. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12053>
This commit is contained in:
@@ -118,6 +118,39 @@ enum agx_format {
|
||||
AGX_NUM_FORMATS,
|
||||
};
|
||||
|
||||
/* Returns the number of bits at the bottom of the address required to be zero.
|
||||
* That is, returns the base-2 logarithm of the minimum alignment for an
|
||||
* agx_format, where the minimum alignment is 2^n where n is the result of this
|
||||
* function. The offset argument to device_load is left-shifted by this amount
|
||||
* in the hardware */
|
||||
|
||||
static inline unsigned
|
||||
agx_format_shift(enum agx_format format)
|
||||
{
|
||||
switch (format) {
|
||||
case AGX_FORMAT_I8:
|
||||
case AGX_FORMAT_U8NORM:
|
||||
case AGX_FORMAT_S8NORM:
|
||||
case AGX_FORMAT_SRGBA8:
|
||||
return 0;
|
||||
|
||||
case AGX_FORMAT_I16:
|
||||
case AGX_FORMAT_F16:
|
||||
case AGX_FORMAT_U16NORM:
|
||||
case AGX_FORMAT_S16NORM:
|
||||
return 1;
|
||||
|
||||
case AGX_FORMAT_I32:
|
||||
case AGX_FORMAT_RGB10A2:
|
||||
case AGX_FORMAT_RG11B10F:
|
||||
case AGX_FORMAT_RGB9E5:
|
||||
return 2;
|
||||
|
||||
default:
|
||||
unreachable("invalid format");
|
||||
}
|
||||
}
|
||||
|
||||
struct agx_attribute {
|
||||
uint32_t divisor;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user