All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] drm/amdgpu: Add macros and documentation for format modifiers.
@ 2018-09-04  1:00 Bas Nieuwenhuizen
       [not found] ` <20180904010033.67611-1-bas-dldO88ZXqoXqqjsSq9zF6IRWq/SkRNHw@public.gmane.org>
  0 siblings, 1 reply; 32+ messages in thread
From: Bas Nieuwenhuizen @ 2018-09-04  1:00 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Nicolai Hähnle, Daniel Vetter, Chad Versace,
	Bas Nieuwenhuizen, Alex Deucher, Dave Airlie,
	Marek Olšák

This is an initial proposal for format modifiers for AMD hardware.

It uses 48 bits including a chip generation, leaving 8 bits for
a format version number.

On gfx6-gfx8 we have all the fields influencing sample locations
in memory.

Tile split bytes are optional for single sample buffers as no
hardware reaches the split size with 1 sample and hence the actual
size does not matter.

The macrotile fields are duplicated for images with multiple planes.
If the planes have different bitdepth they need different macro
tile fields and different tile split bytes if multisample.

I could not fit multiple copies in for tile split bytes, but
multisample & multiplane images are very rare. Overall, I think
we should punt on multisample for a later format version since
they are generally not shared on any modifier aware windowing
system, and we have more issues like fmask & cmask.

We need these copies because the drm modifier of all planes in an
image needs to be equal, so we need to fit these together.

This adds fields for compression support, using metadata that is
compatible with AMDVLK and for which radv and radeonsi can
reasonably be extended.

The big open question for compression is between which generations
the format changed to see if we can share more.

This explicitly does not try to solve the linear stride alignment
issue, thoguh we could internally just use the tiling modes for
the linear modes to indicate linear images with the stride for the
given chip.

Signed-off-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
CC: Chad Versace <chadversary@chromium.org>
CC: Dave Airlie <airlied@redhat.com>
CC: Marek Olšák <marek.olsak@amd.com>
CC: Nicolai Hähnle <nicolai.haehnle@amd.com>
CC: Alex Deucher <alexander.deucher@amd.com>
CC: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 include/uapi/drm/amdgpu_drm.h | 130 ++++++++++++++++++++++++++++++++++
 1 file changed, 130 insertions(+)

diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h
index 94444eeba55b..4e1452161dbf 100644
--- a/include/uapi/drm/amdgpu_drm.h
+++ b/include/uapi/drm/amdgpu_drm.h
@@ -990,6 +990,136 @@ struct drm_amdgpu_info_vce_clock_table {
 #define AMDGPU_FAMILY_AI			141 /* Vega10 */
 #define AMDGPU_FAMILY_RV			142 /* Raven */
 
+#define AMDGPU_CHIP_TAHITI	0
+#define AMDGPU_CHIP_PITCAIRN	1
+#define AMDGPU_CHIP_VERDE	2
+#define AMDGPU_CHIP_OLAND	3
+#define AMDGPU_CHIP_HAINAN	4
+#define AMDGPU_CHIP_BONAIRE	5
+#define AMDGPU_CHIP_KAVERI	6
+#define AMDGPU_CHIP_KABINI	7
+#define AMDGPU_CHIP_HAWAII	8
+#define AMDGPU_CHIP_MULLINS	9
+#define AMDGPU_CHIP_TOPAZ	10
+#define AMDGPU_CHIP_TONGA	11
+#define AMDGPU_CHIP_FIJI	12
+#define AMDGPU_CHIP_CARRIZO	13
+#define AMDGPU_CHIP_STONEY	14
+#define AMDGPU_CHIP_POLARIS10	15
+#define AMDGPU_CHIP_POLARIS11	16
+#define AMDGPU_CHIP_POLARIS12	17
+#define AMDGPU_CHIP_VEGAM	18
+#define AMDGPU_CHIP_VEGA10	19
+#define AMDGPU_CHIP_VEGA12	20
+#define AMDGPU_CHIP_VEGA20	21
+#define AMDGPU_CHIP_RAVEN	22
+
+/* Format for GFX6-GFX8 DRM format modifiers. These are intentionally the same
+ * as AMDGPU_TILING_*. However, the the rules as to when to set them are
+ * different.
+ *
+ * Do not use linear ARRAY_MODEs or SWIZZLE_MODEs. Use DRM_FORMAT_MOD_LINEAR
+ * instead.
+ *
+ * If ARRAY_MODE is 1D, only the micro tile mode and the pipe config should be
+ * set.
+ *
+ * For other ARRAY_MODEs:
+ *  - Only set TILE_SPLIT if the image is multisample.
+ *
+ * We have 1 extra bit for the micro tile mode, as GFX6 and GFX7+ have 1
+ * different value there. The values are
+ *   - depth           : 0
+ *   - displayable     : 1
+ *   - thin            : 2
+ *   - thick (GFX6)    : 3
+ *   - rotated (GFX7+) : 4
+ *
+ * TODO: What to do with multisample multi plane images? More tile split
+ * fields don't fit if we want to keep a few bits for a format version.
+ */
+#define AMDGPU_MODIFIER_GFX8_ARRAY_MODE_SHIFT		0
+#define AMDGPU_MODIFIER_GFX8_ARRAY_MODE_MASK		0xf
+#define AMDGPU_MODIFIER_GFX8_PIPE_CONFIG_SHIFT		4
+#define AMDGPU_MODIFIER_GFX8_PIPE_CONFIG_MASK		0x1f
+#define AMDGPU_MODIFIER_GFX8_TILE_SPLIT_SHIFT		9
+#define AMDGPU_MODIFIER_GFX8_TILE_SPLIT_MASK		0x7
+#define AMDGPU_MODIFIER_GFX8_MICRO_TILE_MODE_SHIFT	12
+#define AMDGPU_MODIFIER_GFX8_MICRO_TILE_MODE_MASK	0x7
+#define AMDGPU_MODIFIER_GFX8_BANK_WIDTH_SHIFT		15
+#define AMDGPU_MODIFIER_GFX8_BANK_WIDTH_MASK		0x3
+#define AMDGPU_MODIFIER_GFX8_BANK_HEIGHT_SHIFT		17
+#define AMDGPU_MODIFIER_GFX8_BANK_HEIGHT_MASK		0x3
+#define AMDGPU_MODIFIER_GFX8_MACRO_TILE_ASPECT_SHIFT	19
+#define AMDGPU_MODIFIER_GFX8_MACRO_TILE_ASPECT_MASK	0x3
+#define AMDGPU_MODIFIER_GFX8_NUM_BANKS_SHIFT		21
+#define AMDGPU_MODIFIER_GFX8_NUM_BANKS_MASK		0x3
+
+/* Macrotile parameters for a second plane if existing */
+#define AMDGPU_MODIFIER_GFX8_BANK_WIDTH_1_SHIFT		23
+#define AMDGPU_MODIFIER_GFX8_BANK_WIDTH_1_MASK		0x3
+#define AMDGPU_MODIFIER_GFX8_BANK_HEIGHT_1_SHIFT	25
+#define AMDGPU_MODIFIER_GFX8_BANK_HEIGHT_1_MASK		0x3
+#define AMDGPU_MODIFIER_GFX8_MACRO_TILE_ASPECT_1_SHIFT	27
+#define AMDGPU_MODIFIER_GFX8_MACRO_TILE_ASPECT_1_MASK	0x3
+#define AMDGPU_MODIFIER_GFX8_NUM_BANKS_1_SHIFT		29
+#define AMDGPU_MODIFIER_GFX8_NUM_BANKS_1_MASK		0x3
+
+/* Macrotile parameters for a third plane if existing */
+#define AMDGPU_MODIFIER_GFX8_BANK_WIDTH_2_SHIFT		31
+#define AMDGPU_MODIFIER_GFX8_BANK_WIDTH_2_MASK		0x3
+#define AMDGPU_MODIFIER_GFX8_BANK_HEIGHT_2_SHIFT	33
+#define AMDGPU_MODIFIER_GFX8_BANK_HEIGHT_2_MASK		0x3
+#define AMDGPU_MODIFIER_GFX8_MACRO_TILE_ASPECT_2_SHIFT	35
+#define AMDGPU_MODIFIER_GFX8_MACRO_TILE_ASPECT_2_MASK	0x3
+#define AMDGPU_MODIFIER_GFX8_NUM_BANKS_2_SHIFT		37
+#define AMDGPU_MODIFIER_GFX8_NUM_BANKS_2_MASK		0x3
+
+#define AMDGPU_MODIFIER_GFX9_SWIZZLE_MODE_SHIFT		0
+#define AMDGPU_MODIFIER_GFX9_SWIZZLE_MODE_MASK		0x1f
+
+/* Whether to enable DCC compression.
+ *
+ * If enabled, exporting the surface results in three
+ * planes:
+ *   - color data
+ *   - DCC data
+ *   - a 64-byte block with
+ *     - a 16 byte 0/1 bool as to whether the surface is currently DCC compressed.
+ *     - a 16-byte 0/1 bool as to whether the surface has fastclear data
+ *     - a 8-byte chunk with the current fastclear colors
+ *
+ * To ensure we do not keep compressing and decompressing the surface, once it
+ * has been decompressed no party may recompress again.
+ *
+ * Applications should not hand over images with fastclear data as not
+ * all users can support it, however, to help both Vulkan implementations
+ * with the allocation we keep it in the 64-byte block.
+ *
+ * TODO: Can scanout really not support fastclear data?
+ * TODO: What to do with multiplane images?
+ */
+#define AMDGPU_MODIFIER_COMPRESSION_SHIFT		39
+#define AMDGPU_MODIFIER_COMPRESSION_MASK		0x1
+
+/* The chip this is compatible with.
+ *
+ * If compression is disabled, use
+ *   - AMDGPU_CHIP_TAHITI for GFX6-GFX8
+ *   - AMDGPU_CHIP_VEGA10 for GFX9+
+ *
+ * With compression enabled please use the exact chip.
+ *
+ * TODO: Do some generations share DCC format?
+ */
+#define AMDGPU_MODIFIER_CHIP_GEN_SHIFT			40
+#define AMDGPU_MODIFIER_CHIP_GEN_MASK			0xff
+
+#define AMDGPU_MODIFIER_SET(field, value) \
+	(((__u64)(value) & AMDGPU_MODIFIER_##field##_MASK) << AMDGPU_MODIFIER_##field##_SHIFT)
+#define AMDGPU_MODIFIER_GET(value, field) \
+	(((__u64)(value) >> AMDGPU_MODIFIER_##field##_SHIFT) & AMDGPU_MODIFIER_##field##_MASK)
+
 /*
  * Definition of free sync enter and exit signals
  * We may have more options in the future
-- 
2.18.0

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2018-09-07 22:33 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-04  1:00 [RFC] drm/amdgpu: Add macros and documentation for format modifiers Bas Nieuwenhuizen
     [not found] ` <20180904010033.67611-1-bas-dldO88ZXqoXqqjsSq9zF6IRWq/SkRNHw@public.gmane.org>
2018-09-04  7:10   ` Christian König
2018-09-04 10:04   ` Daniel Vetter
     [not found]     ` <CAKMK7uGceX3ueO9+m8ZAi6UZMsx47X57L4NzzeivFFdquqMGXA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-09-04 10:15       ` Daniel Stone
     [not found]         ` <CAPj87rNRAa0PkSOp3crK2YsifCeO6ucPhUM4Kg2kOfXk3MDOWg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-09-04 10:44           ` Christian König
     [not found]             ` <72744df1-001b-bcd4-dcba-b6966a62c4ce-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-09-04 12:22               ` Daniel Stone
     [not found]                 ` <CAP+8YyG3ALnJJH_04-10t2EOy9wk4SVB1jz8kw8MoX-w+J8sng@mail.gmail.com>
     [not found]                   ` <CAP+8YyG3ALnJJH_04-10t2EOy9wk4SVB1jz8kw8MoX-w+J8sng-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-09-04 12:40                     ` Bas Nieuwenhuizen
     [not found]                 ` <CAPj87rMPtu_O5jGxFPgc02QeXofrmzzP7kiVbL7xD9-rpa9akw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-09-04 12:59                   ` Christian König
2018-09-04 12:26             ` Daniel Vetter
     [not found]               ` <20180904122604.GO21634-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2018-09-04 12:33                 ` Bas Nieuwenhuizen
2018-09-04 13:03                   ` Daniel Vetter
2018-09-04 13:12                     ` Christian König
     [not found]                       ` <164b70a7-8a7d-60ca-480b-04453ca95b90-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-09-04 13:17                         ` Daniel Vetter
2018-09-04 13:23                           ` Christian König
     [not found]                     ` <20180904130353.GQ21634-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2018-09-04 13:33                       ` Bas Nieuwenhuizen
2018-09-04 14:43                         ` Daniel Vetter
2018-09-04 15:52                           ` Bas Nieuwenhuizen
     [not found]                             ` <CAP+8YyH_5oNKcWgapuC+vRQOAcBEDPLqxvBqUvhqYdT_FjMe7A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-09-04 16:37                               ` Daniel Vetter
     [not found]                                 ` <CAKMK7uEYNkvTV19Svz0LQS5SgiWbTXmQcmVZCWMihrjNE6Rx3g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-09-04 17:48                                   ` Christian König
     [not found]                                     ` <b3276cd4-8ff2-36d6-35ef-83da75099b96-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-09-04 17:57                                       ` Bas Nieuwenhuizen
     [not found]                                         ` <CAP+8YyFC6z=aNT=RR7zV44i4y6tURfadazDX0VaPnzBhG-6gfg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-09-04 18:00                                           ` Bas Nieuwenhuizen
     [not found]                                             ` <CAP+8YyEH7i-zkoaMyT=jhgc_O_uyq6cdU2PjNkAvE6o_7AthaA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-09-04 18:06                                               ` Christian König
2018-09-04 18:27                                         ` Daniel Vetter
2018-09-04 18:31                                           ` Bas Nieuwenhuizen
2018-09-04 19:28                                             ` Daniel Vetter
     [not found]                                               ` <CAKMK7uH+O5bhSUY6srEGEu2NcqCOR0vEw+mfoPm8q_yCzzNUHg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-09-04 19:36                                                 ` Bas Nieuwenhuizen
     [not found]                                                   ` <CAP+8YyF6NyFbjiVrR4jvfgE7gZTtbM3GuxMqqkoDPRADV+4EYA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-09-04 21:39                                                     ` Daniel Vetter
2018-09-04 13:03                 ` Christian König
2018-09-04 12:21     ` Bas Nieuwenhuizen
2018-09-07  4:50   ` Marek Olšák
     [not found]     ` <CAAxE2A4eO4pevcHQKhbRbZXFTUVbFuBzOrFf8dgfVR4n5fvX1g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-09-07  9:55       ` Bas Nieuwenhuizen
     [not found]         ` <CAP+8YyEQKu7xACK3O=tp=MqvvumcjYouwate3_+uhTCDho-v5w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-09-07 22:33           ` Marek Olšák

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.