Created
June 5, 2026 16:13
-
-
Save ilsubyeega/8390fe8b07cfb65d88ac7cf30e2c51d2 to your computer and use it in GitHub Desktop.
GeForce Now with NixOS+RX470. (upstream linux does not support vulkan video encoding so it must hack the kernels instead)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| kernel driver, and the last ones that didn't support | |
| DRM format modifiers until now. | |
| On GFX6-8, the GFX block can only use pre-determined tiling | |
| modes which are programmed by the kernel according to the | |
| tiling mode table. GFX6 uses the GB_TILE_MODE0...31 registers, | |
| and GFX7-8 also has GB_MACROTILE_MODE0...15 registers. | |
| DCC is also supported on GFX8, albeit not displayable. | |
| Note that the tiling table is uAPI and userspace relies on | |
| specific modes being present at specific indices. | |
| How the tiling works is primarily determined by the | |
| so-called array mode. | |
| Use the TILE field to specify the array mode. | |
| Pixel data is organized into micro tiles. | |
| Each micro tile may be 8x8 / 8x8x4 / 8x8x8 pixels, | |
| depending on the array mode. | |
| Add the MICROTILE field to specify microtile mode. | |
| Microtiles may be further organized into macro tiles, | |
| which have many configurable parameters. Macro tile mode | |
| selection depends on how many bits per pixel an image has. | |
| Add the PIPE_CONFIG, TILE_SPLIT, BANK_WIDTH, BANK_HEIGHT, | |
| MACRO_TILE_ASPECT, NUM_BANKS fields to specify parameters | |
| of macro tiled modes. | |
| Furthermore, tiling is also influenced by memory | |
| configuration: GB_ADDR_CONFIG.ROW_SIZE needs to be | |
| considered when calculating TILE_SPLIT, but does not | |
| need to be included in the modifiers, and also | |
| PIPE_INTERLEAVE matters, but it's hardcoded to the | |
| same value on all GFX6-8 GPUs and changing it would | |
| break userspace, so it also doesn't need to be included. | |
| As a side note, tiling works similarly on GFX4-5 but | |
| that will need some additional PIPE_CONFIG enum values | |
| as well as some extra fields to represent some factors | |
| which don't matter on GFX6-8, such as NUM_RANKS | |
| among other things. | |
| Initially, let's only expose the tiling modes that are | |
| most relevant to sharing buffers between different | |
| processes: | |
| Exposed tiling modes: | |
| - 1D_TILED_THIN1: micro tiled only | |
| - 2D_TILED_THIN1: macro tiled | |
| Exposed micro tile modes: | |
| - DISPLAY: supported by DCE (the display engine) | |
| - THIN: more efficient but not displayable | |
| Exposed macro tile modes: | |
| All possible parameters (25088 permutations). | |
| More modes may be exposed in the future as needed. | |
| Technically, the amount of possible combinations | |
| of all possible tiling parameters is in the range | |
| of hundreds of thousands, but in practice, there are | |
| just a handful of possible modifiers for a surface. | |
| For example on GFX8, a surface would have these | |
| modifiers, from best to worst performance: | |
| - 2D_TILED_THIN1 + THIN + DCC (macro tiled) | |
| - 2D_TILED_THIN1 + THIN (macro tiled) | |
| - 2D_TILED_THIN1 + DISPLAY (macro tiled) | |
| - THIN (micro tiled only) | |
| - DISPLAY (micro tiled only) | |
| - LINEAR | |
| The macro tiling parameters depend on the bits per pixel | |
| of the specific surface. | |
| When sharing buffers between different GFX6-8 GPUs, | |
| it is possible but not likely that they support the exact | |
| same macrotiling configuration, so they will likely need | |
| to fall back to using micro tiled modes, which are still | |
| much better than using linear buffers. | |
| Suggested-by: Bas Nieuwenhuizen <<A HREF="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">bas at basnieuwenhuizen.nl</A>> | |
| Signed-off-by: Timur Kristóf <<A HREF="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">timur.kristof at gmail.com</A>> | |
| Reviewed-by: Marek Olšák <<A HREF="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">maraeo at gmail.com</A>> | |
| --- | |
| include/uapi/drm/drm_fourcc.h | 207 +++++++++++++++++++++++++++++++--- | |
| 1 file changed, 189 insertions(+), 18 deletions(-) | |
| diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h | |
| index e527b24bd824..4a150c48f348 100644 | |
| --- a/include/uapi/drm/drm_fourcc.h | |
| +++ b/include/uapi/drm/drm_fourcc.h | |
| @@ -1620,36 +1620,67 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier) | |
| * For multi-plane formats the above surfaces get merged into one plane for | |
| * each format plane, based on the required alignment only. | |
| * | |
| - * Bits Parameter Notes | |
| - * ----- ------------------------ --------------------------------------------- | |
| + * Bits Parameter Notes | |
| + * ------- ------------------------ --------------------------------------------- | |
| + * | |
| + * General fields: | |
| + * 7:0 TILE_VERSION Values are AMD_FMT_MOD_TILE_VER_* | |
| + * 12:8 TILE Values are AMD_FMT_MOD_TILE_<version>_* | |
| + * 13 DCC | |
| + * | |
| + * Fields for GFX9 and newer: | |
| + * 14 DCC_RETILE | |
| + * 15 DCC_PIPE_ALIGN | |
| + * 16 DCC_INDEPENDENT_64B | |
| + * 17 DCC_INDEPENDENT_128B | |
| + * 19:18 DCC_MAX_COMPRESSED_BLOCK Values are AMD_FMT_MOD_DCC_BLOCK_* | |
| + * 20 DCC_CONSTANT_ENCODE | |
| + * 23:21 PIPE_XOR_BITS Only for some chips | |
| + * 26:24 BANK_XOR_BITS Only for some chips | |
| + * 29:27 PACKERS Only for some chips | |
| + * 32:30 RB Only for some chips | |
| + * 35:33 PIPE Only for some chips | |
| + * 55:36 - Reserved for future use, must be zero | |
| + * | |
| + * Fields for GFX6-8: | |
| + * 16:14 MICROTILE Micro tile format | |
| + * 21:17 PIPE_CONFIG Number of pipes and how pipes are interleaved | |
| + * 24:22 TILE_SPLIT Tile split size | |
| + * 26:25 BANK_WIDTH Number of tiles in the X direction in the same bank | |
| + * 28:27 BANK_HEIGHT Number of tiles in the Y direction in the same bank | |
| + * 30:29 MACRO_TILE_ASPECT Macro tile aspect ratio | |
| + * 32:31 NUM_BANKS Number of banks | |
| + * 55:33 - Reserved for future use, must be zero | |
| * | |
| - * 7:0 TILE_VERSION Values are AMD_FMT_MOD_TILE_VER_* | |
| - * 12:8 TILE Values are AMD_FMT_MOD_TILE_<version>_* | |
| - * 13 DCC | |
| - * 14 DCC_RETILE | |
| - * 15 DCC_PIPE_ALIGN | |
| - * 16 DCC_INDEPENDENT_64B | |
| - * 17 DCC_INDEPENDENT_128B | |
| - * 19:18 DCC_MAX_COMPRESSED_BLOCK Values are AMD_FMT_MOD_DCC_BLOCK_* | |
| - * 20 DCC_CONSTANT_ENCODE | |
| - * 23:21 PIPE_XOR_BITS Only for some chips | |
| - * 26:24 BANK_XOR_BITS Only for some chips | |
| - * 29:27 PACKERS Only for some chips | |
| - * 32:30 RB Only for some chips | |
| - * 35:33 PIPE Only for some chips | |
| - * 55:36 - Reserved for future use, must be zero | |
| */ | |
| #define AMD_FMT_MOD fourcc_mod_code(AMD, 0) | |
| #define IS_AMD_FMT_MOD(val) (((val) >> 56) == DRM_FORMAT_MOD_VENDOR_AMD) | |
| -/* Reserve 0 for GFX8 and older */ | |
| +#define AMD_FMT_MOD_TILE_VER_GFX6 0 | |
| #define AMD_FMT_MOD_TILE_VER_GFX9 1 | |
| #define AMD_FMT_MOD_TILE_VER_GFX10 2 | |
| #define AMD_FMT_MOD_TILE_VER_GFX10_RBPLUS 3 | |
| #define AMD_FMT_MOD_TILE_VER_GFX11 4 | |
| #define AMD_FMT_MOD_TILE_VER_GFX12 5 | |
| +/* | |
| + * Gfx6-8 tiling modes. | |
| + * A complete reference implementation is found in addrlib in the Mesa code base. | |
| + * | |
| + * - Microtiled modes (1D): | |
| + * Pixel data is organized into micro tiles of 8x8 pixels. | |
| + * | |
| + * - Macrotiled modes (2D): | |
| + * Micro tiles are further organized into macro tiles. | |
| + * These are optimized for even load distribution among memory channels. | |
| + * | |
| + * Note that only THIN1 modes are exposed here. | |
| + * THICK and XTHICK are for 3D images and not relevant to DRM format modifiers. | |
| + */ | |
| +#define AMD_FMT_MOD_TILE_GFX6_1D_TILED_THIN1 0x2 | |
| +#define AMD_FMT_MOD_TILE_GFX6_2D_TILED_THIN1 0x4 | |
| + | |
| /* | |
| * 64K_S is the same for GFX9/GFX10/GFX10_RBPLUS and hence has GFX9 as canonical | |
| * version. | |
| @@ -1748,6 +1779,146 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier) | |
| #define AMD_FMT_MOD_PIPE_SHIFT 33 | |
| #define AMD_FMT_MOD_PIPE_MASK 0x7 | |
| +/* | |
| + * MICRO_TILE_MODE, 3 bits. Determines the micro tile format. | |
| + * Only relevant to Gfx6-8. | |
| + * | |
| + * DISPLAY - Displayable tiling | |
| + * THIN - Non-displayable tiling, a.k.a thin micro tiling | |
| + * DEPTH, THICK - not exposed, not relevant to DRM format modifier use cases | |
| + * ROTATED - not exposed, not implemented in Linux or Mesa | |
| + */ | |
| +#define AMD_FMT_MOD_MICROTILE_SHIFT 14ULL | |
| +#define AMD_FMT_MOD_MICROTILE_MASK 0x7 | |
| + | |
| +#define AMD_FMT_MOD_MICROTILE_DISPLAY 0x0 | |
| +#define AMD_FMT_MOD_MICROTILE_THIN 0x1 | |
| + | |
| +/* | |
| + * PIPE_CONFIG, 5 bits. Number of pipes and how pipes are interleaved on the surface, | |
| + * which means the shader engine tile size and packer tile size. | |
| + * Typically matches the number of memory channels, or number of RBs. | |
| + * Only relevant to Gfx6-8 macro tiled modes. | |
| + * | |
| + * P<n>_<a>x<b>_<c>x<d> | |
| + * where: | |
| + * <n> - number of pipes | |
| + * <a>x<b> - shader engine tile size | |
| + * <c>x<d> - packer tile size | |
| + */ | |
| +#define AMD_FMT_MOD_PIPE_CONFIG_SHIFT 19ULL | |
| +#define AMD_FMT_MOD_PIPE_CONFIG_MASK 0x1f | |
| + | |
| +#define AMD_FMT_MOD_PIPE_CONFIG_P2 0x0 | |
| +#define AMD_FMT_MOD_PIPE_CONFIG_P4_8x16 0x4 | |
| +#define AMD_FMT_MOD_PIPE_CONFIG_P4_16x16 0x5 | |
| +#define AMD_FMT_MOD_PIPE_CONFIG_P4_16x32 0x6 | |
| +#define AMD_FMT_MOD_PIPE_CONFIG_P4_32x32 0x7 | |
| +#define AMD_FMT_MOD_PIPE_CONFIG_P8_16x16_8x16 0x8 | |
| +#define AMD_FMT_MOD_PIPE_CONFIG_P8_16x32_8x16 0x9 | |
| +#define AMD_FMT_MOD_PIPE_CONFIG_P8_32x32_8x16 0xa | |
| +#define AMD_FMT_MOD_PIPE_CONFIG_P8_16x32_16x16 0xb | |
| +#define AMD_FMT_MOD_PIPE_CONFIG_P8_32x32_16x16 0xc | |
| +#define AMD_FMT_MOD_PIPE_CONFIG_P8_32x32_16x32 0xd | |
| +#define AMD_FMT_MOD_PIPE_CONFIG_P8_32x64_32x32 0xe | |
| +#define AMD_FMT_MOD_PIPE_CONFIG_P16_32x32_8x16 0x10 | |
| +#define AMD_FMT_MOD_PIPE_CONFIG_P16_32x32_16x16 0x11 | |
| + | |
| +/* | |
| + * TILE_SPLIT, 3 bits. | |
| + * Only relevant to Gfx6-8 macro tiled modes. | |
| + * | |
| + * On GFX6 (or with depth tiling modes on GFX7 and newer), | |
| + * the GFX block uses the GB_TILE_MODE.TILE_SPLIT field directly. | |
| + * | |
| + * On GFX7 and newer with non-depth tiling modes, the GFX block uses a | |
| + * split factor which is stored in the GB_TILE_MODE.SAMPLE_SPLIT field. | |
| + * SAMPLE_SPLIT may be: 0 - 1 byte; 1 - 2 bytes; 2 - 4 bytes; 3 - 8 bytes. | |
| + * The actual tile size and tile split bytes are calculated as follows: | |
| + * | |
| + * bpp = ... <- bits per pixel in the current image | |
| + * thickness = ... <- depends on array mode; may be: 1, 4, 8 | |
| + * num_samples = ... <- number of samples in the current image | |
| + * tile_size_pixels = 8 * 8 | |
| + * tile_bytes_1x = thickness * tile_size_pixels * bpp / 8 | |
| + * sample_split_factor = 1 << SAMPLE_SPLIT | |
| + * tile_split_bytes = clamp(tile_bytes_1x * sample_split_factor, 256, dram_row_size_bytes) | |
| + * tile_bytes = clamp(tile_bytes_1x * num_samples, 64, tile_split_bytes) | |
| + * | |
| + * In both cases, the display block (DCE) has no SAMPLE_SPLIT | |
| + * and just needs the tile split bytes in the GRPH_CONTROL.GRPH_TILE_SPLIT field. | |
| + * To maximize compatibility between GFX6-7, we don't include the SAMPLE_SPLIT | |
| + * in the format modifiers. | |
| + * | |
| + * The actual tile split in bytes is: 64 << field value | |
| + * Possible values of this field: | |
| + * | |
| + * 0 - Tile split is 64 bytes | |
| + * 1 - Tile split is 128 bytes | |
| + * 2 - Tile split is 256 bytes | |
| + * 3 - Tile split is 512 bytes | |
| + * 4 - Tile split is 1 KiB | |
| + * 5 - Tile split is 2 KiB | |
| + * 6 - Tile split is 4 KiB | |
| + */ | |
| +#define AMD_FMT_MOD_TILE_SPLIT_SHIFT 24ULL | |
| +#define AMD_FMT_MOD_TILE_SPLIT_MASK 0x7 | |
| + | |
| +/* | |
| + * BANK_WIDTH, 2 bits. Number of tiles in the X direction in the same bank. | |
| + * Only relevant to Gfx6-8 macro tiled modes. | |
| + * The actual bank width is: 1 << field value | |
| + * Possible values: | |
| + * | |
| + * 0 - bank width is 1 | |
| + * 1 - bank width is 2 | |
| + * 2 - bank width is 4 | |
| + * 3 - bank width is 8 | |
| + */ | |
| +#define AMD_FMT_MOD_BANK_WIDTH_SHIFT 27ULL | |
| +#define AMD_FMT_MOD_BANK_WIDTH_MASK 0x3 | |
| + | |
| +/* | |
| + * BANK_HEIGHT, 2 bits. Number of tiles in the Y direction in the same bank. | |
| + * Only relevant to Gfx6-8 macro tiled modes. | |
| + * The actual bank height is: 1 << field value | |
| + * Possible values: | |
| + * | |
| + * 0 - bank height is 1 | |
| + * 1 - bank height is 2 | |
| + * 2 - bank height is 4 | |
| + * 3 - bank height is 8 | |
| + */ | |
| +#define AMD_FMT_MOD_BANK_HEIGHT_SHIFT 29ULL | |
| +#define AMD_FMT_MOD_BANK_HEIGHT_MASK 0x3 | |
| + | |
| +/* | |
| + * MACRO_TILE_ASPECT, 2 bits. Macro tile aspect ratio. | |
| + * Only relevant to Gfx6-8 macro tiled modes. | |
| + * Possible values: | |
| + * | |
| + * 0 - aspect ratio is 1:1 | |
| + * 1 - aspect ratio is 4:1 | |
| + * 2 - aspect ratio is 16:1 | |
| + * 3 - aspect ratio is 64:1 | |
| + */ | |
| +#define AMD_FMT_MOD_MACRO_TILE_ASPECT_SHIFT 31ULL | |
| +#define AMD_FMT_MOD_MACRO_TILE_ASPECT_MASK 0x3 | |
| + | |
| +/* | |
| + * NUM_BANKS, 2 bits. Number of banks. | |
| + * Only relevant to Gfx6-8 macro tiled modes. | |
| + * The actual number of banks is: 2 << field value | |
| + * Possible values: | |
| + * | |
| + * 0 - number of banks is 2 | |
| + * 1 - number of banks is 4 | |
| + * 2 - number of banks is 8 | |
| + * 3 - number of banks is 16 | |
| + */ | |
| +#define AMD_FMT_MOD_NUM_BANKS_SHIFT 33ULL | |
| +#define AMD_FMT_MOD_NUM_BANKS_MASK 0x3 | |
| + | |
| #define AMD_FMT_MOD_SET(field, value) \ | |
| ((__u64)(value) << AMD_FMT_MOD_##field##_SHIFT) | |
| #define AMD_FMT_MOD_GET(field, value) \ | |
| -- | |
| 2.54.0 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/src/amd/common/ac_gpu_info.c b/src/amd/common/ac_gpu_info.c | |
| index 5a6c10d44ab..0500af4016d 100644 | |
| --- a/src/amd/common/ac_gpu_info.c | |
| +++ b/src/amd/common/ac_gpu_info.c | |
| @@ -1855,7 +1855,7 @@ static void ac_print_gpu_modifiers(FILE *f, const struct radeon_info *const info | |
| for (unsigned i = 0; i < modifier_count; i++) { | |
| char *name = drmGetFormatModifierName(modifiers[i]); | |
| - fprintf(f, " 0x%lx - %s\n", modifiers[i], name); | |
| + fprintf(f, " 0x%" PRIx64 " - %s\n", modifiers[i], name); | |
| free(name); | |
| } | |
| } | |
| diff --git a/src/amd/common/ac_surface.c b/src/amd/common/ac_surface.c | |
| index c585f1f7c23..46c895b9551 100644 | |
| --- a/src/amd/common/ac_surface.c | |
| +++ b/src/amd/common/ac_surface.c | |
| @@ -1968,7 +1968,8 @@ static int gfx6_validate_surf_modifier(const struct radeon_info *const info, | |
| const uint64_t actual_modifier = gfx6_compute_surface_modifier(info, surf); | |
| if (surf->modifier != actual_modifier) { | |
| - fprintf(stderr, "Surface modifier inconsistent: specified 0x%lx, actual: 0x%lx\n", | |
| + fprintf(stderr, "Surface modifier inconsistent: specified 0x%" PRIx64 | |
| + ", actual: 0x%" PRIx64 "\n", | |
| surf->modifier, actual_modifier); | |
| return -EINVAL; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Convert the tiling flags to modifers on GFX8 and older, so that | |
| the DC display driver can rely on them like on newer generations. | |
| Note that this code path will only be taken when DC actually | |
| exposes any modifiers on GFX6-8, which is handled in a subsequent | |
| commit after this one. | |
| Signed-off-by: Timur Kristóf <<A HREF="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">timur.kristof at gmail.com</A>> | |
| Tested-by: Link Mauve <<A HREF="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">linkmauve at linkmauve.fr</A>> | |
| Reviewed-by: Marek Olšák <<A HREF="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">maraeo at gmail.com</A>> | |
| --- | |
| drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 111 +++++++++++++++++++- | |
| 1 file changed, 108 insertions(+), 3 deletions(-) | |
| diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | |
| index 950937b363fb..dcca930ed3c0 100644 | |
| --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | |
| +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | |
| @@ -746,7 +746,7 @@ static int convert_tiling_flags_to_modifier_gfx12(struct amdgpu_framebuffer *afb | |
| return 0; | |
| } | |
| -static int convert_tiling_flags_to_modifier(struct amdgpu_framebuffer *afb) | |
| +static int convert_tiling_flags_to_modifier_gfx9(struct amdgpu_framebuffer *afb) | |
| { | |
| struct amdgpu_device *adev = drm_to_adev(afb->base.dev); | |
| uint64_t modifier = 0; | |
| @@ -940,6 +940,55 @@ static int convert_tiling_flags_to_modifier(struct amdgpu_framebuffer *afb) | |
| return 0; | |
| } | |
| +static int convert_tiling_flags_to_modifier_gfx6(struct amdgpu_framebuffer *afb) | |
| +{ | |
| + const uint32_t array_mode = AMDGPU_TILING_GET(afb->tiling_flags, ARRAY_MODE); | |
| + const uint32_t pipe_config = AMDGPU_TILING_GET(afb->tiling_flags, PIPE_CONFIG); | |
| + const uint32_t tile_split = AMDGPU_TILING_GET(afb->tiling_flags, TILE_SPLIT); | |
| + const uint32_t micro_tile_mode = AMDGPU_TILING_GET(afb->tiling_flags, MICRO_TILE_MODE); | |
| + const uint32_t bank_width = AMDGPU_TILING_GET(afb->tiling_flags, BANK_WIDTH); | |
| + const uint32_t bank_height = AMDGPU_TILING_GET(afb->tiling_flags, BANK_HEIGHT); | |
| + const uint32_t macro_tile_aspect = AMDGPU_TILING_GET(afb->tiling_flags, MACRO_TILE_ASPECT); | |
| + const uint32_t num_banks = AMDGPU_TILING_GET(afb->tiling_flags, NUM_BANKS); | |
| + struct amdgpu_device *adev = drm_to_adev(afb->base.dev); | |
| + uint64_t modifier = 0; | |
| + | |
| + switch (array_mode) { | |
| + case DC_ARRAY_LINEAR_GENERAL: | |
| + case DC_ARRAY_LINEAR_ALLIGNED: | |
| + modifier = DRM_FORMAT_MOD_LINEAR; | |
| + break; | |
| + | |
| + case DC_ARRAY_2D_TILED_THIN1: | |
| + /* Macro tiled modes only */ | |
| + modifier |= | |
| + AMD_FMT_MOD_SET(PIPE_CONFIG, pipe_config) | | |
| + AMD_FMT_MOD_SET(TILE_SPLIT, tile_split) | | |
| + AMD_FMT_MOD_SET(BANK_WIDTH, bank_width) | | |
| + AMD_FMT_MOD_SET(BANK_HEIGHT, bank_height) | | |
| + AMD_FMT_MOD_SET(MACRO_TILE_ASPECT, macro_tile_aspect) | | |
| + AMD_FMT_MOD_SET(NUM_BANKS, num_banks); | |
| + fallthrough; | |
| + | |
| + case DC_ARRAY_1D_TILED_THIN1: | |
| + /* Micro and macro tiled modes */ | |
| + modifier |= | |
| + AMD_FMT_MOD | | |
| + AMD_FMT_MOD_SET(TILE_VERSION, AMD_FMT_MOD_TILE_VER_GFX6) | | |
| + AMD_FMT_MOD_SET(TILE, array_mode) | | |
| + AMD_FMT_MOD_SET(MICROTILE, micro_tile_mode); | |
| + break; | |
| + | |
| + default: | |
| + drm_err(&adev->ddev, "array mode 0x%x not supported by DCE\n", array_mode); | |
| + return -EINVAL; | |
| + } | |
| + | |
| + afb->base.modifier = modifier; | |
| + afb->base.flags |= DRM_MODE_FB_MODIFIERS; | |
| + return 0; | |
| +} | |
| + | |
| /* Mirrors the is_displayable check in radeonsi's gfx6_compute_surface */ | |
| static int check_tiling_flags_gfx6(struct amdgpu_framebuffer *afb) | |
| { | |
| @@ -1093,7 +1142,7 @@ static int amdgpu_display_verify_sizes(struct amdgpu_framebuffer *rfb) | |
| get_block_dimensions(block_size_log2, format_info->cpp[i], | |
| &block_width, &block_height); | |
| - } else { | |
| + } else if (AMD_FMT_MOD_GET(TILE_VERSION, modifier) >= AMD_FMT_MOD_TILE_VER_GFX9) { | |
| int swizzle = AMD_FMT_MOD_GET(TILE, modifier); | |
| switch ((swizzle & ~3) + 1) { | |
| @@ -1120,6 +1169,60 @@ static int amdgpu_display_verify_sizes(struct amdgpu_framebuffer *rfb) | |
| get_block_dimensions(block_size_log2, format_info->cpp[i], | |
| &block_width, &block_height); | |
| + } else if (AMD_FMT_MOD_GET(TILE_VERSION, modifier) == AMD_FMT_MOD_TILE_VER_GFX6) { | |
| + const u32 display_micro_tile_pitch = 32; /* required by DCE */ | |
| + const u32 micro_tile_width = 8; | |
| + const u32 micro_tile_height = 8; | |
| + const u32 micro_tile_mode = AMD_FMT_MOD_GET(MICROTILE, modifier); | |
| + const u32 array_mode = AMD_FMT_MOD_GET(TILE, modifier); | |
| + u32 num_banks, bank_width, bank_height, pipe_config, macro_tile_aspect; | |
| + u32 num_pipes; | |
| + | |
| + if (AMD_FMT_MOD_GET(DCC, modifier)) { | |
| + drm_dbg_kms(rfb->base.dev, "DCC is not displayable on GFX6-8\n"); | |
| + return -EINVAL; | |
| + } | |
| + if (array_mode != AMD_FMT_MOD_TILE_GFX6_1D_TILED_THIN1 && | |
| + array_mode != AMD_FMT_MOD_TILE_GFX6_2D_TILED_THIN1) { | |
| + drm_dbg_kms(rfb->base.dev, | |
| + "Array mode %u is not supported by the display driver\n", | |
| + array_mode); | |
| + return -EINVAL; | |
| + } | |
| + if (micro_tile_mode != AMD_FMT_MOD_MICROTILE_DISPLAY) { | |
| + drm_dbg_kms(rfb->base.dev, | |
| + "Micro tile mode %u is not displayable on GFX6-8\n", | |
| + micro_tile_mode); | |
| + return -EINVAL; | |
| + } | |
| + | |
| + num_banks = 2 << AMD_FMT_MOD_GET(NUM_BANKS, modifier); | |
| + bank_width = 1 << AMD_FMT_MOD_GET(BANK_WIDTH, modifier); | |
| + bank_height = 1 << AMD_FMT_MOD_GET(BANK_HEIGHT, modifier); | |
| + pipe_config = AMD_FMT_MOD_GET(PIPE_CONFIG, modifier); | |
| + macro_tile_aspect = 1 << AMD_FMT_MOD_GET(MACRO_TILE_ASPECT, modifier); | |
| + | |
| + if (pipe_config >= AMD_FMT_MOD_PIPE_CONFIG_P16_32x32_8x16) | |
| + num_pipes = 16; | |
| + else if (pipe_config >= AMD_FMT_MOD_PIPE_CONFIG_P8_16x16_8x16) | |
| + num_pipes = 8; | |
| + else if (pipe_config >= AMD_FMT_MOD_PIPE_CONFIG_P4_8x16) | |
| + num_pipes = 4; | |
| + else if (pipe_config == AMD_FMT_MOD_PIPE_CONFIG_P2) | |
| + num_pipes = 2; | |
| + else | |
| + unreachable(); | |
| + | |
| + if (array_mode < AMD_FMT_MOD_TILE_GFX6_2D_TILED_THIN1) { | |
| + block_width = display_micro_tile_pitch; | |
| + block_height = micro_tile_height; | |
| + } else { | |
| + /* Assume non-PRT macro tiling modes */ | |
| + block_width = num_pipes * micro_tile_width * | |
| + bank_width * macro_tile_aspect; | |
| + block_height = micro_tile_height * bank_height * | |
| + num_banks / macro_tile_aspect; | |
| + } | |
| } | |
| ret = amdgpu_display_verify_plane(rfb, i, format_info, | |
| @@ -1271,8 +1374,10 @@ static int amdgpu_display_framebuffer_init(struct drm_device *dev, | |
| !(rfb->base.flags & DRM_MODE_FB_MODIFIERS)) { | |
| if (amdgpu_ip_version(adev, GC_HWIP, 0) >= IP_VERSION(12, 0, 0)) | |
| ret = convert_tiling_flags_to_modifier_gfx12(rfb); | |
| + else if (amdgpu_ip_version(adev, GC_HWIP, 0) >= IP_VERSION(9, 0, 0)) | |
| + ret = convert_tiling_flags_to_modifier_gfx9(rfb); | |
| else | |
| - ret = convert_tiling_flags_to_modifier(rfb); | |
| + ret = convert_tiling_flags_to_modifier_gfx6(rfb); | |
| if (ret) { | |
| drm_dbg_kms(dev, "Failed to convert tiling flags 0x%llX to a modifier", | |
| -- | |
| 2.54.0 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| modes are supported by the GFX block. | |
| Technically, DCE could support all possible modes independently | |
| of what GFX supports, but it doesn't make sense to expose all | |
| possible permutations. | |
| The following modes will be advertised: | |
| - 2D_TILED_THIN1 + DISPLAY (macro tiled) | |
| - 1D_TILED_THIN1 + DISPLAY (micro tiled only) | |
| - LINEAR | |
| The macro tiling configuration depends on how many bits per pixel | |
| the given surface has. | |
| When sharing buffers between different GPUs, it is unlikely that | |
| they will support the same macro tile mode, so it will likely | |
| need to use the micro tiled only mode. | |
| Signed-off-by: Timur Kristóf <<A HREF="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">timur.kristof at gmail.com</A>> | |
| Tested-by: Link Mauve <<A HREF="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">linkmauve at linkmauve.fr</A>> | |
| Reviewed-by: Marek Olšák <<A HREF="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">maraeo at gmail.com</A>> | |
| --- | |
| .../amd/display/amdgpu_dm/amdgpu_dm_plane.c | 313 +++++++++++++++++- | |
| 1 file changed, 306 insertions(+), 7 deletions(-) | |
| diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c | |
| index 23a9faa2ea89..24e3510613ce 100644 | |
| --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c | |
| +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c | |
| @@ -165,6 +165,18 @@ static void amdgpu_dm_plane_add_modifier(uint64_t **mods, uint64_t *size, uint64 | |
| *size += 1; | |
| } | |
| +static void amdgpu_dm_plane_add_modifier_dedup(uint64_t **mods, uint64_t *size, | |
| + uint64_t *cap, uint64_t mod) | |
| +{ | |
| + uint64_t i; | |
| + | |
| + for (i = 0; i < *size; ++i) | |
| + if ((*mods)[i] == mod) | |
| + return; | |
| + | |
| + amdgpu_dm_plane_add_modifier(mods, size, cap, mod); | |
| +} | |
| + | |
| static bool amdgpu_dm_plane_modifier_has_dcc(uint64_t modifier) | |
| { | |
| return IS_AMD_FMT_MOD(modifier) && AMD_FMT_MOD_GET(DCC, modifier); | |
| @@ -211,6 +223,39 @@ static void amdgpu_dm_plane_fill_gfx8_tiling_info_from_flags(struct dc_tiling_in | |
| AMDGPU_TILING_GET(tiling_flags, PIPE_CONFIG); | |
| } | |
| +static int amdgpu_dm_plane_fill_gfx6_tiling_info_from_modifier(struct dc_tiling_info *tiling_info, | |
| + uint64_t modifier) | |
| +{ | |
| + if (modifier == DRM_FORMAT_MOD_LINEAR) { | |
| + tiling_info->gfx8.array_mode = DC_ARRAY_LINEAR_GENERAL; | |
| + tiling_info->gfxversion = DcGfxVersion8; | |
| + | |
| + return 0; | |
| + } | |
| + | |
| + if (!IS_AMD_FMT_MOD(modifier)) | |
| + return -EINVAL; | |
| + | |
| + if (AMD_FMT_MOD_GET(TILE_VERSION, modifier) != AMD_FMT_MOD_TILE_VER_GFX6) | |
| + return -EINVAL; | |
| + | |
| + tiling_info->gfx8.array_mode = AMD_FMT_MOD_GET(TILE, modifier); | |
| + tiling_info->gfxversion = DcGfxVersion8; | |
| + tiling_info->gfx8.tile_mode = AMD_FMT_MOD_GET(MICROTILE, modifier); | |
| + | |
| + if (AMD_FMT_MOD_GET(TILE, modifier) < AMD_FMT_MOD_TILE_GFX6_2D_TILED_THIN1) | |
| + return 0; | |
| + | |
| + tiling_info->gfx8.pipe_config = AMD_FMT_MOD_GET(PIPE_CONFIG, modifier); | |
| + tiling_info->gfx8.tile_split = AMD_FMT_MOD_GET(TILE_SPLIT, modifier); | |
| + tiling_info->gfx8.bank_width = AMD_FMT_MOD_GET(BANK_WIDTH, modifier); | |
| + tiling_info->gfx8.bank_height = AMD_FMT_MOD_GET(BANK_HEIGHT, modifier); | |
| + tiling_info->gfx8.tile_aspect = AMD_FMT_MOD_GET(MACRO_TILE_ASPECT, modifier); | |
| + tiling_info->gfx8.num_banks = AMD_FMT_MOD_GET(NUM_BANKS, modifier); | |
| + | |
| + return 0; | |
| +} | |
| + | |
| static void amdgpu_dm_plane_fill_gfx9_tiling_info_from_device(const struct amdgpu_device *adev, | |
| struct dc_tiling_info *tiling_info) | |
| { | |
| @@ -446,6 +491,246 @@ static void amdgpu_dm_plane_add_gfx10_1_modifiers(const struct amdgpu_device *ad | |
| AMD_FMT_MOD_SET(TILE_VERSION, AMD_FMT_MOD_TILE_VER_GFX9)); | |
| } | |
| +/** | |
| + * amdgpu_dm_plane_get_gfx6_tile_idx() - Get tile mode index on GFX6-8 | |
| + * | |
| + * @adev: amdgpu_device pointer | |
| + * @bpp: bits per pixel in the image | |
| + * @arr: array mode (aka. tile mode) of the image layout | |
| + * | |
| + * Select which tiling mode from the table is suitable for the given bits per pixel | |
| + * using the given array mode, assuming the displayable micro tile mode is used. | |
| + * | |
| + * On GFX6-8, the GFX block can only use pre-programmed tiling modes from GB_TILE_MODEn | |
| + * registers which are programmed by the kernel according to the tiling mode table. | |
| + * Note that the tiling table is uAPI and userspace relies on specific modes being | |
| + * present at specific indices. | |
| + * See SiLib::HwlSetupTileInfo() and CiLib::HwlSetupTileInfo() in addrlib. | |
| + */ | |
| +static u32 amdgpu_dm_plane_get_gfx6_tile_idx(const struct amdgpu_device *adev, | |
| + const u32 bpp, | |
| + const enum array_mode_values arr) | |
| +{ | |
| + /* Assume that the microtile mode is DISPLAY. */ | |
| + | |
| + if (arr == DC_ARRAY_1D_TILED_THIN1) | |
| + return 9; | |
| + | |
| + ASSERT(arr == DC_ARRAY_2D_TILED_THIN1); | |
| + | |
| + if (adev->family > AMDGPU_FAMILY_SI) | |
| + return 10; | |
| + | |
| + switch (bpp) { | |
| + case 8: | |
| + return 10; | |
| + case 16: | |
| + return 11; | |
| + default: | |
| + return 12; | |
| + } | |
| +} | |
| + | |
| +/** | |
| + * amdgpu_dm_plane_calc_gfx7_tile_split() - Calculate tile split on GFX7-8 | |
| + * | |
| + * @adev: amdgpu_device pointer | |
| + * @bpp: bits per pixel in the image | |
| + * @gb_tile_mode: GB_TILE_MODEn register value for the current tiling mode | |
| + * | |
| + * Calculate the actual tile split value on GFX7-8, assuming 2D_TILED_THIN1 array mode | |
| + * with a non-depth micro tile mode. | |
| + * | |
| + * On GFX7-8, SAMPLE_SPLIT holds a factor from which the actual tile split bytes | |
| + * can be calculated. The TILE_SPLIT field is only used for the depth micro tile mode. | |
| + * See CiLib::HwlComputeMacroModeIndex() in addrlib. | |
| + */ | |
| +static u32 amdgpu_dm_plane_calc_gfx7_tile_split(const struct amdgpu_device *adev, | |
| + const u32 bpp, | |
| + const u32 gb_tile_mode) | |
| +{ | |
| + /* Assume 2D_TILED_THIN1 mode with non-DEPTH microtiles */ | |
| + const u32 sample_split = (gb_tile_mode >> 25) & 0x3; | |
| + const u32 thickness = 1; | |
| + const u32 tile_size_pixels = 8 * 8; | |
| + const u32 tile_bytes_1x = tile_size_pixels * bpp * thickness / 8; | |
| + const u32 sample_split_factor = 1 << sample_split; | |
| + | |
| + return clamp(tile_bytes_1x * sample_split_factor, | |
| + 256, | |
| + adev->gfx.config.mem_row_size_in_kb * 1024); | |
| +} | |
| + | |
| +/** | |
| + * amdgpu_dm_plane_get_gfx7_macro_tile_idx() - Get macro tile mode index on GFX7-8 | |
| + * | |
| + * @bpp: bits per pixel in the image | |
| + * @tile_split_bytes: actual tile split bytes, see amdgpu_dm_plane_calc_gfx7_tile_split() | |
| + * | |
| + * Select which macro tiling mode from the table is suitable for the given bits per pixel, | |
| + * assuming 2D_TILED_THIN1 array mode and DISPLAY micro tile mode (and no multisampling). | |
| + * Note that the tiling table is uAPI and userspace relies on specific modes being | |
| + * present at specific indices. | |
| + * See CiLib::HwlComputeMacroModeIndex() in addrlib. | |
| + */ | |
| +static u32 amdgpu_dm_plane_get_gfx7_macro_tile_idx(const u32 bpp, const u32 tile_split_bytes) | |
| +{ | |
| + const u32 tile_bytes = clamp(8 * 8 * bpp, 64, tile_split_bytes); | |
| + const u32 macro_tile_idx = ilog2(tile_bytes / 64); | |
| + | |
| + WARN_ON(macro_tile_idx >= 16); | |
| + | |
| + return macro_tile_idx; | |
| +} | |
| + | |
| +/** | |
| + * amdgpu_dm_plane_calc_gfx6_mod() - Calculate a DRM format modifier for GFX6-8 | |
| + * | |
| + * @adev: amdgpu_device pointer | |
| + * @bpp: bits per pixel in the image | |
| + * @arr: array mode (aka. tile mode) of the image layout | |
| + * | |
| + * Select suitable micro and macro tile modes for the given bits per pixel, | |
| + * and calculate the corresponding DRM format modifier. | |
| + */ | |
| +static u64 amdgpu_dm_plane_calc_gfx6_mod(const struct amdgpu_device *adev, | |
| + const u32 bpp, | |
| + const enum array_mode_values arr) | |
| +{ | |
| + u32 array_mode, micro_tile_mode, tile_split_bytes; | |
| + u32 gb_macrotile_mode, macrotile_idx; | |
| + u32 gb_tile_mode, tile_idx; | |
| + | |
| + u64 modifier_base = | |
| + AMD_FMT_MOD | | |
| + AMD_FMT_MOD_SET(TILE_VERSION, AMD_FMT_MOD_TILE_VER_GFX6) | | |
| + AMD_FMT_MOD_SET(TILE, arr) | | |
| + AMD_FMT_MOD_SET(MICROTILE, AMD_FMT_MOD_MICROTILE_DISPLAY); | |
| + | |
| + if (arr < DC_ARRAY_2D_TILED_THIN1) | |
| + return modifier_base; | |
| + | |
| + tile_idx = amdgpu_dm_plane_get_gfx6_tile_idx(adev, bpp, arr); | |
| + gb_tile_mode = adev->gfx.config.tile_mode_array[tile_idx]; | |
| + array_mode = (gb_tile_mode >> 2) & 0xf; | |
| + | |
| + if (adev->family == AMDGPU_FAMILY_SI) { | |
| + micro_tile_mode = (gb_tile_mode >> 0) & 0x3; | |
| + tile_split_bytes = 64 << ((gb_tile_mode >> 11) & 0x7); | |
| + } else { | |
| + micro_tile_mode = (gb_tile_mode >> 22) & 0x7; | |
| + tile_split_bytes = amdgpu_dm_plane_calc_gfx7_tile_split(adev, bpp, gb_tile_mode); | |
| + } | |
| + | |
| + ASSERT(array_mode == arr); | |
| + ASSERT(micro_tile_mode == AMD_FMT_MOD_MICROTILE_DISPLAY); | |
| + | |
| + modifier_base |= | |
| + AMD_FMT_MOD_SET(PIPE_CONFIG, (gb_tile_mode >> 6) & 0x1f) | | |
| + AMD_FMT_MOD_SET(TILE_SPLIT, ilog2(tile_split_bytes / 64)); | |
| + | |
| + if (adev->family == AMDGPU_FAMILY_SI) | |
| + return modifier_base | | |
| + AMD_FMT_MOD_SET(BANK_WIDTH, (gb_tile_mode >> 14) & 0x3) | | |
| + AMD_FMT_MOD_SET(BANK_HEIGHT, (gb_tile_mode >> 16) & 0x3) | | |
| + AMD_FMT_MOD_SET(MACRO_TILE_ASPECT, (gb_tile_mode >> 18) & 0x3) | | |
| + AMD_FMT_MOD_SET(NUM_BANKS, (gb_tile_mode >> 20) & 0x3); | |
| + | |
| + macrotile_idx = amdgpu_dm_plane_get_gfx7_macro_tile_idx(bpp, tile_split_bytes); | |
| + gb_macrotile_mode = adev->gfx.config.macrotile_mode_array[macrotile_idx]; | |
| + | |
| + return modifier_base | | |
| + AMD_FMT_MOD_SET(BANK_WIDTH, (gb_macrotile_mode >> 0) & 0x3) | | |
| + AMD_FMT_MOD_SET(BANK_HEIGHT, (gb_macrotile_mode >> 2) & 0x3) | | |
| + AMD_FMT_MOD_SET(MACRO_TILE_ASPECT, (gb_macrotile_mode >> 4) & 0x3) | | |
| + AMD_FMT_MOD_SET(NUM_BANKS, (gb_macrotile_mode >> 6) & 0x3); | |
| +} | |
| + | |
| +/** | |
| + * amdgpu_dm_plane_gfx6_format_mod_supported() - Check if a modifier is supported on GFX6-8 | |
| + * | |
| + * @adev: amdgpu_device pointer | |
| + * @bpp: bits per pixel in the image | |
| + * @modifier: the modifier whose support we check | |
| + * | |
| + * On GFX6-8, not all DRM format modifier can be used with all image formats. | |
| + * Check whether the specified modifier is supported with the given bits per pixel value. | |
| + */ | |
| +static bool amdgpu_dm_plane_gfx6_format_mod_supported(const struct amdgpu_device *adev, | |
| + const u32 bpp, | |
| + const u64 modifier) | |
| +{ | |
| + const u32 array_mode = AMD_FMT_MOD_GET(TILE, modifier); | |
| + const u32 micro_tile_mode = AMD_FMT_MOD_GET(MICROTILE, modifier); | |
| + | |
| + if (!IS_AMD_FMT_MOD(modifier)) | |
| + return false; | |
| + | |
| + /* GFX9 and newer format modifiers are not supported on GFX6-8 yet. */ | |
| + if (AMD_FMT_MOD_GET(TILE_VERSION, modifier) != AMD_FMT_MOD_TILE_VER_GFX6) | |
| + return false; | |
| + | |
| + /* GFX8 and older format modifiers are not supported on GFX9+ yet. */ | |
| + if (adev->family >= AMDGPU_FAMILY_AI) | |
| + return false; | |
| + | |
| + /* GFX6-7 doesn't have any DCC, GFX8 doesn't have displayable DCC. */ | |
| + if (AMD_FMT_MOD_GET(DCC, modifier)) | |
| + return false; | |
| + | |
| + /* | |
| + * For now, only expose 1D and 2D tiles THIN array modes. | |
| + * Linear is already exposed through DRM_FORMAT_MOD_LINEAR. | |
| + */ | |
| + if (array_mode != AMD_FMT_MOD_TILE_GFX6_1D_TILED_THIN1 && | |
| + array_mode != AMD_FMT_MOD_TILE_GFX6_2D_TILED_THIN1) | |
| + return false; | |
| + | |
| + /* | |
| + * For now, only expose DISPLAY micro tile mode. | |
| + * THIN, DEPTH and THICK modes are not displayable. | |
| + * ROTATED has never been supported on Linux. | |
| + */ | |
| + if (micro_tile_mode != AMD_FMT_MOD_MICROTILE_DISPLAY) | |
| + return false; | |
| + | |
| + /* Verify that the modifier is the same that we'd expose for this bpp */ | |
| + return amdgpu_dm_plane_calc_gfx6_mod(adev, bpp, array_mode) == modifier; | |
| +} | |
| + | |
| +/** | |
| + * amdgpu_dm_plane_add_gfx6_modifiers() - Expose modifiers for GFX6-8 | |
| + * | |
| + * @adev: amdgpu_device pointer | |
| + * @mods: Pointer to array of format modifiers | |
| + * @size: Pointer to size of the array | |
| + * @capacity: Pointer to capacity of the array | |
| + * | |
| + * Calculate a DRM format modifier for macro tiled modes for each supported | |
| + * bits per pixel value. Use de-duplication because on some GPUs it may happen | |
| + * that different bpp results in the exact same macro tiling mode, depending | |
| + * on the tiling table. | |
| + * | |
| + * Also expose a micro tiled only mode. This is less optimal, but supported. | |
| + */ | |
| +static void amdgpu_dm_plane_add_gfx6_modifiers(const struct amdgpu_device *adev, | |
| + u64 **mods, | |
| + u64 *size, | |
| + u64 *capacity) | |
| +{ | |
| + /* 2D tiled displayable */ | |
| + amdgpu_dm_plane_add_modifier(mods, size, capacity, | |
| + amdgpu_dm_plane_calc_gfx6_mod(adev, 16, DC_ARRAY_2D_TILED_THIN1)); | |
| + amdgpu_dm_plane_add_modifier_dedup(mods, size, capacity, | |
| + amdgpu_dm_plane_calc_gfx6_mod(adev, 32, DC_ARRAY_2D_TILED_THIN1)); | |
| + amdgpu_dm_plane_add_modifier_dedup(mods, size, capacity, | |
| + amdgpu_dm_plane_calc_gfx6_mod(adev, 64, DC_ARRAY_2D_TILED_THIN1)); | |
| + | |
| + /* 1D tiled displayable */ | |
| + amdgpu_dm_plane_add_modifier(mods, size, capacity, | |
| + amdgpu_dm_plane_calc_gfx6_mod(adev, 0, DC_ARRAY_1D_TILED_THIN1)); | |
| +} | |
| + | |
| static void amdgpu_dm_plane_add_gfx9_modifiers(const struct amdgpu_device *adev, | |
| uint64_t **mods, | |
| uint64_t *size, | |
| @@ -727,12 +1012,6 @@ static void amdgpu_dm_plane_add_gfx12_modifiers(struct amdgpu_device *adev, | |
| static int amdgpu_dm_plane_get_plane_modifiers(struct amdgpu_device *adev, unsigned int plane_type, uint64_t **mods) | |
| { | |
| uint64_t size = 0, capacity = 128; | |
| - *mods = NULL; | |
| - | |
| - /* We have not hooked up any pre-GFX9 modifiers. */ | |
| - if (adev->family < AMDGPU_FAMILY_AI) | |
| - return 0; | |
| - | |
| *mods = kmalloc_array(capacity, sizeof(uint64_t), GFP_KERNEL); | |
| if (plane_type == DRM_PLANE_TYPE_CURSOR) { | |
| @@ -742,6 +1021,13 @@ static int amdgpu_dm_plane_get_plane_modifiers(struct amdgpu_device *adev, unsig | |
| } | |
| switch (adev->family) { | |
| + case AMDGPU_FAMILY_SI: | |
| + case AMDGPU_FAMILY_CI: | |
| + case AMDGPU_FAMILY_KV: | |
| + case AMDGPU_FAMILY_VI: | |
| + case AMDGPU_FAMILY_CZ: | |
| + amdgpu_dm_plane_add_gfx6_modifiers(adev, mods, &size, &capacity); | |
| + break; | |
| case AMDGPU_FAMILY_AI: | |
| case AMDGPU_FAMILY_RV: | |
| amdgpu_dm_plane_add_gfx9_modifiers(adev, mods, &size, &capacity); | |
| @@ -916,8 +1202,13 @@ int amdgpu_dm_plane_fill_plane_buffer_attributes(struct amdgpu_device *adev, | |
| address); | |
| if (ret) | |
| return ret; | |
| - } else { | |
| + } else if (!afb->base.modifier) { | |
| amdgpu_dm_plane_fill_gfx8_tiling_info_from_flags(tiling_info, tiling_flags); | |
| + } else { | |
| + ret = amdgpu_dm_plane_fill_gfx6_tiling_info_from_modifier(tiling_info, | |
| + afb->base.modifier); | |
| + if (ret) | |
| + return ret; | |
| } | |
| return 0; | |
| @@ -1552,6 +1843,7 @@ static bool amdgpu_dm_plane_format_mod_supported(struct drm_plane *plane, | |
| { | |
| struct amdgpu_device *adev = drm_to_adev(plane->dev); | |
| const struct drm_format_info *info = drm_format_info(format); | |
| + const u32 bpp = drm_format_info_bpp(info, 0); | |
| int i; | |
| if (!info) | |
| @@ -1575,6 +1867,13 @@ static bool amdgpu_dm_plane_format_mod_supported(struct drm_plane *plane, | |
| if (i == plane->modifier_count) | |
| return false; | |
| + if (AMD_FMT_MOD_GET(TILE_VERSION, modifier) == AMD_FMT_MOD_TILE_VER_GFX6) | |
| + return amdgpu_dm_plane_gfx6_format_mod_supported(adev, bpp, modifier); | |
| + | |
| + /* GFX9+ modifers are not supported on GFX8 and older yet. */ | |
| + if (adev->family < AMDGPU_FAMILY_AI) | |
| + return false; | |
| + | |
| /* GFX12 doesn't have these limitations. */ | |
| if (AMD_FMT_MOD_GET(TILE_VERSION, modifier) <= AMD_FMT_MOD_TILE_VER_GFX11) { | |
| enum dm_micro_swizzle microtile = amdgpu_dm_plane_modifier_gfx9_swizzle_mode(modifier) & 3; | |
| -- | |
| 2.54.0 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Remove all code from amdgpu_dm that dealt with tiling flags. | |
| Note that the legacy non-DC display code still relies on | |
| tiling flags, so we can't remove them outside of DC. | |
| Signed-off-by: Timur Kristóf <<A HREF="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">timur.kristof at gmail.com</A>> | |
| Tested-by: Link Mauve <<A HREF="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">linkmauve at linkmauve.fr</A>> | |
| Reviewed-by: Marek Olšák <<A HREF="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">maraeo at gmail.com</A>> | |
| --- | |
| .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 29 +--------- | |
| .../amd/display/amdgpu_dm/amdgpu_dm_plane.c | 53 +++---------------- | |
| .../amd/display/amdgpu_dm/amdgpu_dm_plane.h | 1 - | |
| 3 files changed, 8 insertions(+), 75 deletions(-) | |
| diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | |
| index c41f017fe8f2..a9cb085d7029 100644 | |
| --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | |
| +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | |
| @@ -6299,7 +6299,6 @@ fill_plane_color_attributes(const struct drm_plane_state *plane_state, | |
| static int | |
| fill_dc_plane_info_and_addr(struct amdgpu_device *adev, | |
| const struct drm_plane_state *plane_state, | |
| - const u64 tiling_flags, | |
| struct dc_plane_info *plane_info, | |
| struct dc_plane_address *address, | |
| bool tmz_surface) | |
| @@ -6397,7 +6396,7 @@ fill_dc_plane_info_and_addr(struct amdgpu_device *adev, | |
| return ret; | |
| ret = amdgpu_dm_plane_fill_plane_buffer_attributes(adev, afb, plane_info->format, | |
| - plane_info->rotation, tiling_flags, | |
| + plane_info->rotation, | |
| &plane_info->tiling_info, | |
| &plane_info->plane_size, | |
| &plane_info->dcc, address, | |
| @@ -6433,7 +6432,6 @@ static int fill_dc_plane_attributes(struct amdgpu_device *adev, | |
| dc_plane_state->scaling_quality = scaling_info.scaling_quality; | |
| ret = fill_dc_plane_info_and_addr(adev, plane_state, | |
| - afb->tiling_flags, | |
| &plane_info, | |
| &dc_plane_state->address, | |
| afb->tmz_surface); | |
| @@ -10221,7 +10219,6 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, | |
| fill_dc_plane_info_and_addr( | |
| dm->adev, new_plane_state, | |
| - afb->tiling_flags, | |
| &bundle->plane_infos[planes_count], | |
| &bundle->flip_addrs[planes_count].address, | |
| afb->tmz_surface); | |
| @@ -12123,8 +12120,7 @@ static bool should_reset_plane(struct drm_atomic_state *state, | |
| new_afb = (struct amdgpu_framebuffer *)new_other_state->fb; | |
| /* Tiling and DCC changes also require bandwidth updates. */ | |
| - if (old_afb->tiling_flags != new_afb->tiling_flags || | |
| - old_afb->base.modifier != new_afb->base.modifier) | |
| + if (old_afb->base.modifier != new_afb->base.modifier) | |
| return true; | |
| } | |
| @@ -12136,9 +12132,7 @@ static int dm_check_cursor_fb(struct amdgpu_crtc *new_acrtc, | |
| struct drm_framebuffer *fb) | |
| { | |
| struct amdgpu_device *adev = drm_to_adev(new_acrtc->base.dev); | |
| - struct amdgpu_framebuffer *afb = to_amdgpu_framebuffer(fb); | |
| unsigned int pitch; | |
| - bool linear; | |
| if (fb->width > new_acrtc->max_cursor_width || | |
| fb->height > new_acrtc->max_cursor_height) { | |
| @@ -12173,25 +12167,6 @@ static int dm_check_cursor_fb(struct amdgpu_crtc *new_acrtc, | |
| return -EINVAL; | |
| } | |
| - /* Core DRM takes care of checking FB modifiers, so we only need to | |
| - * check tiling flags when the FB doesn't have a modifier. | |
| - */ | |
| - if (!(fb->flags & DRM_MODE_FB_MODIFIERS)) { | |
| - if (adev->family == AMDGPU_FAMILY_GC_12_0_0) { | |
| - linear = AMDGPU_TILING_GET(afb->tiling_flags, GFX12_SWIZZLE_MODE) == 0; | |
| - } else if (adev->family >= AMDGPU_FAMILY_AI) { | |
| - linear = AMDGPU_TILING_GET(afb->tiling_flags, SWIZZLE_MODE) == 0; | |
| - } else { | |
| - linear = AMDGPU_TILING_GET(afb->tiling_flags, ARRAY_MODE) != DC_ARRAY_2D_TILED_THIN1 && | |
| - AMDGPU_TILING_GET(afb->tiling_flags, ARRAY_MODE) != DC_ARRAY_1D_TILED_THIN1 && | |
| - AMDGPU_TILING_GET(afb->tiling_flags, MICRO_TILE_MODE) == 0; | |
| - } | |
| - if (!linear) { | |
| - drm_dbg_atomic(adev_to_drm(adev), "Cursor FB not linear"); | |
| - return -EINVAL; | |
| - } | |
| - } | |
| - | |
| return 0; | |
| } | |
| diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c | |
| index 24e3510613ce..c5203d7b1a44 100644 | |
| --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c | |
| +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c | |
| @@ -190,39 +190,6 @@ static unsigned int amdgpu_dm_plane_modifier_gfx9_swizzle_mode(uint64_t modifier | |
| return AMD_FMT_MOD_GET(TILE, modifier); | |
| } | |
| -static void amdgpu_dm_plane_fill_gfx8_tiling_info_from_flags(struct dc_tiling_info *tiling_info, | |
| - uint64_t tiling_flags) | |
| -{ | |
| - /* Fill GFX8 params */ | |
| - if (AMDGPU_TILING_GET(tiling_flags, ARRAY_MODE) == DC_ARRAY_2D_TILED_THIN1) { | |
| - unsigned int bankw, bankh, mtaspect, tile_split, num_banks; | |
| - | |
| - bankw = AMDGPU_TILING_GET(tiling_flags, BANK_WIDTH); | |
| - bankh = AMDGPU_TILING_GET(tiling_flags, BANK_HEIGHT); | |
| - mtaspect = AMDGPU_TILING_GET(tiling_flags, MACRO_TILE_ASPECT); | |
| - tile_split = AMDGPU_TILING_GET(tiling_flags, TILE_SPLIT); | |
| - num_banks = AMDGPU_TILING_GET(tiling_flags, NUM_BANKS); | |
| - | |
| - tiling_info->gfxversion = DcGfxVersion8; | |
| - /* XXX fix me for VI */ | |
| - tiling_info->gfx8.num_banks = num_banks; | |
| - tiling_info->gfx8.array_mode = | |
| - DC_ARRAY_2D_TILED_THIN1; | |
| - tiling_info->gfx8.tile_split = tile_split; | |
| - tiling_info->gfx8.bank_width = bankw; | |
| - tiling_info->gfx8.bank_height = bankh; | |
| - tiling_info->gfx8.tile_aspect = mtaspect; | |
| - tiling_info->gfx8.tile_mode = | |
| - DC_ADDR_SURF_MICRO_TILING_DISPLAY; | |
| - } else if (AMDGPU_TILING_GET(tiling_flags, ARRAY_MODE) | |
| - == DC_ARRAY_1D_TILED_THIN1) { | |
| - tiling_info->gfx8.array_mode = DC_ARRAY_1D_TILED_THIN1; | |
| - } | |
| - | |
| - tiling_info->gfx8.pipe_config = | |
| - AMDGPU_TILING_GET(tiling_flags, PIPE_CONFIG); | |
| -} | |
| - | |
| static int amdgpu_dm_plane_fill_gfx6_tiling_info_from_modifier(struct dc_tiling_info *tiling_info, | |
| uint64_t modifier) | |
| { | |
| @@ -1127,7 +1094,6 @@ int amdgpu_dm_plane_fill_plane_buffer_attributes(struct amdgpu_device *adev, | |
| const struct amdgpu_framebuffer *afb, | |
| const enum surface_pixel_format format, | |
| const enum dc_rotation_angle rotation, | |
| - const uint64_t tiling_flags, | |
| struct dc_tiling_info *tiling_info, | |
| struct plane_size *plane_size, | |
| struct dc_plane_dcc_param *dcc, | |
| @@ -1188,28 +1154,22 @@ int amdgpu_dm_plane_fill_plane_buffer_attributes(struct amdgpu_device *adev, | |
| upper_32_bits(chroma_addr); | |
| } | |
| - if (adev->family == AMDGPU_FAMILY_GC_12_0_0) { | |
| + if (adev->family == AMDGPU_FAMILY_GC_12_0_0) | |
| ret = amdgpu_dm_plane_fill_gfx12_plane_attributes_from_modifiers(adev, afb, format, | |
| rotation, plane_size, | |
| tiling_info, dcc, | |
| address); | |
| - if (ret) | |
| - return ret; | |
| - } else if (adev->family >= AMDGPU_FAMILY_AI) { | |
| + else if (adev->family >= AMDGPU_FAMILY_AI) | |
| ret = amdgpu_dm_plane_fill_gfx9_plane_attributes_from_modifiers(adev, afb, format, | |
| rotation, plane_size, | |
| tiling_info, dcc, | |
| address); | |
| - if (ret) | |
| - return ret; | |
| - } else if (!afb->base.modifier) { | |
| - amdgpu_dm_plane_fill_gfx8_tiling_info_from_flags(tiling_info, tiling_flags); | |
| - } else { | |
| + else | |
| ret = amdgpu_dm_plane_fill_gfx6_tiling_info_from_modifier(tiling_info, | |
| afb->base.modifier); | |
| - if (ret) | |
| - return ret; | |
| - } | |
| + | |
| + if (ret) | |
| + return ret; | |
| return 0; | |
| } | |
| @@ -1296,7 +1256,6 @@ static int amdgpu_dm_plane_helper_prepare_fb(struct drm_plane *plane, | |
| amdgpu_dm_plane_fill_plane_buffer_attributes( | |
| adev, afb, plane_state->format, plane_state->rotation, | |
| - afb->tiling_flags, | |
| &plane_state->tiling_info, &plane_state->plane_size, | |
| &plane_state->dcc, &plane_state->address, | |
| afb->tmz_surface); | |
| diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.h | |
| index ea2619b507db..91c05b744b98 100644 | |
| --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.h | |
| +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.h | |
| @@ -46,7 +46,6 @@ int amdgpu_dm_plane_fill_plane_buffer_attributes(struct amdgpu_device *adev, | |
| const struct amdgpu_framebuffer *afb, | |
| const enum surface_pixel_format format, | |
| const enum dc_rotation_angle rotation, | |
| - const uint64_t tiling_flags, | |
| struct dc_tiling_info *tiling_info, | |
| struct plane_size *plane_size, | |
| struct dc_plane_dcc_param *dcc, | |
| -- | |
| 2.54.0 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| lib, | |
| pkgs, | |
| pkgs-master, | |
| ... | |
| }: | |
| let | |
| mesaGfx68Src = pkgs.fetchFromGitLab { | |
| domain = "gitlab.freedesktop.org"; | |
| owner = "mesa"; | |
| repo = "mesa"; | |
| rev = "54b33b0d6f054876d9ee38f3819a544ea67528a3"; | |
| hash = "sha256-XGO/+7OexsWi0c3RQGEM47XVEDdfk6A+lJ751y8U8do="; | |
| }; | |
| mesaGfx68 = | |
| mesa: libdisplay-info: libdrm: | |
| mesa.overrideAttrs (old: { | |
| version = "${old.version}-gfx6-8-format-modifiers-41557"; | |
| src = mesaGfx68Src; | |
| buildInputs = [ | |
| libdisplay-info | |
| libdrm | |
| ] | |
| ++ builtins.filter (input: !(lib.hasInfix "libdrm-" (toString input))) (old.buildInputs or [ ]); | |
| patches = builtins.filter (patch: !(lib.hasInfix "gallivm-llvm-21.patch" (toString patch))) ( | |
| old.patches or [ ] | |
| ) ++ [ ./patches/mesa-gfx6-8-format-modifiers/0001-fix-i686-uint64-format.patch ]; | |
| outputs = builtins.filter (output: output != "spirv2dxil") (old.outputs or [ ]); | |
| postInstall = lib.replaceStrings | |
| [ | |
| "moveToOutput bin/spirv2dxil $spirv2dxil" | |
| ''moveToOutput "lib/libspirv_to_dxil*" $spirv2dxil'' | |
| ] | |
| [ | |
| "# spirv2dxil is not built in this AMD-only WIP Mesa build." | |
| "# libspirv_to_dxil is not built in this AMD-only WIP Mesa build." | |
| ] | |
| (old.postInstall or ""); | |
| mesonFlags = map ( | |
| flag: | |
| if lib.hasPrefix "-Dgallium-drivers=" flag then | |
| "-Dgallium-drivers=radeonsi,llvmpipe,softpipe,zink" | |
| else if lib.hasPrefix "-Dvulkan-drivers=" flag then | |
| "-Dvulkan-drivers=amd,swrast" | |
| else | |
| lib.replaceStrings [ "imagination-experimental" ] [ "imagination" ] flag | |
| ) (old.mesonFlags or [ ]); | |
| }); | |
| patchDir = ./patches/gfx6-8-format-modifiers; | |
| in | |
| { | |
| # GFX6-8 DRM format modifier support is still WIP upstream. Keep this pinned | |
| # to the Mesa MR commit and the matching amd-gfx kernel series. | |
| boot.kernelPackages = pkgs.linuxPackages_latest; | |
| boot.kernelPatches = [ | |
| { | |
| name = "gfx6-8-format-modifiers-fourcc"; | |
| patch = "${patchDir}/0001-drm-fourcc-add-amd-gfx6-8-modifiers.patch"; | |
| } | |
| { | |
| name = "gfx6-8-format-modifiers-amdgpu-tiling"; | |
| patch = "${patchDir}/0002-drm-amdgpu-convert-tiling-flags-gfx6-8.patch"; | |
| } | |
| { | |
| name = "gfx6-8-format-modifiers-display"; | |
| patch = "${patchDir}/0003-drm-amd-display-support-modifiers-gfx6-8.patch"; | |
| } | |
| { | |
| name = "gfx6-8-format-modifiers-drop-dc-tiling-flags"; | |
| patch = "${patchDir}/0004-drm-amd-display-stop-using-tiling-flags.patch"; | |
| } | |
| ]; | |
| hardware.graphics.package = mesaGfx68 pkgs.mesa pkgs.libdisplay-info pkgs-master.libdrm; | |
| hardware.graphics.package32 = | |
| mesaGfx68 pkgs.pkgsi686Linux.mesa pkgs.pkgsi686Linux.libdisplay-info | |
| pkgs-master.pkgsi686Linux.libdrm; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { pkgs, ... }: | |
| let | |
| flatpakSpawnStub = pkgs.writeShellScriptBin "flatpak-spawn" '' | |
| if [ "''${1:-}" = "--host" ]; then | |
| shift | |
| fi | |
| exec "$@" | |
| ''; | |
| launcher = pkgs.writeShellScript "geforcenow-direct-launcher" '' | |
| set -euo pipefail | |
| real_home="$HOME" | |
| export HOME="''${GFN_DIRECT_HOME:-$real_home/.local/share/geforcenow-direct/home}" | |
| mkdir -p "$HOME/.var/NVIDIA/GeForceNOW" | |
| ln -sfn /app/mall "$HOME/.var/NVIDIA/GeForceNOW/mall" | |
| export SDL_VIDEODRIVER=x11 | |
| export RADV_EXPERIMENTAL="''${RADV_EXPERIMENTAL:-video_decode}" | |
| export XDG_STATE_HOME="''${XDG_STATE_HOME:-$HOME/.local/state}" | |
| export GSETTINGS_BACKEND="''${GSETTINGS_BACKEND:-dconf}" | |
| export VK_ICD_FILENAMES="''${VK_ICD_FILENAMES:-/run/opengl-driver/share/vulkan/icd.d/radeon_icd.x86_64.json}" | |
| export VK_LAYER_PATH="''${VK_LAYER_PATH:-/run/opengl-driver/share/vulkan/explicit_layer.d:/run/opengl-driver/share/vulkan/implicit_layer.d}" | |
| export LIBVA_DRIVERS_PATH="''${LIBVA_DRIVERS_PATH:-/run/opengl-driver/lib/dri}" | |
| export LD_LIBRARY_PATH="/app/cef:/app/cef/dependencies:/app:/app/lib:/run/opengl-driver/lib:''${LD_LIBRARY_PATH:-}" | |
| export PATH="${flatpakSpawnStub}/bin:${pkgs.xorg.xrandr}/bin:${pkgs.xdg-utils}/bin:${pkgs.coreutils}/bin:${pkgs.findutils}/bin:${pkgs.gnugrep}/bin:${pkgs.gawk}/bin:${pkgs.procps}/bin:${pkgs.bash}/bin:/app/bin:/usr/bin:/bin:''${PATH:-}" | |
| mkdir -p "$XDG_STATE_HOME/NVIDIA/GeForceNOW" | |
| cd /app/cef | |
| exec ./GeForceNOW "$@" | |
| ''; | |
| geforceNowDirect = pkgs.buildFHSEnv { | |
| pname = "geforcenow-direct"; | |
| version = "2.0.85.133"; | |
| runScript = launcher; | |
| extraPreBwrapCmds = '' | |
| payload_dir="''${GFN_DIRECT_PAYLOAD:-$HOME/.local/share/geforcenow-direct/files}" | |
| if [[ ! -x "$payload_dir/cef/GeForceNOW" ]]; then | |
| echo "GeForce NOW direct payload not found: $payload_dir" >&2 | |
| echo "Run: geforcenow-direct-sync" >&2 | |
| exit 1 | |
| fi | |
| ''; | |
| extraBwrapArgs = [ | |
| ''--ro-bind "$payload_dir" /app'' | |
| ]; | |
| targetPkgs = | |
| pkgs': | |
| with pkgs'; | |
| [ | |
| alsa-lib | |
| at-spi2-atk | |
| at-spi2-core | |
| atk | |
| bash | |
| cairo | |
| coreutils | |
| cups | |
| dbus | |
| expat | |
| findutils | |
| fontconfig | |
| freetype | |
| gawk | |
| gcc.cc.lib | |
| glib | |
| gnugrep | |
| gtk3 | |
| iw | |
| lsb-release | |
| libdrm | |
| libgbm | |
| libglvnd | |
| libpulseaudio | |
| libsecret | |
| libuuid | |
| libxkbcommon | |
| mesa | |
| nspr | |
| nss | |
| pango | |
| pciutils | |
| procps | |
| systemd | |
| vulkan-loader | |
| wayland | |
| wget | |
| wireguard-tools | |
| wirelesstools | |
| xdg-utils | |
| xorg.libICE | |
| xorg.libSM | |
| xorg.libX11 | |
| xorg.libXScrnSaver | |
| xorg.libXcomposite | |
| xorg.libXcursor | |
| xorg.libXdamage | |
| xorg.libXext | |
| xorg.libXfixes | |
| xorg.libXi | |
| xorg.libXrandr | |
| xorg.libXrender | |
| xorg.libXtst | |
| xorg.libxcb | |
| xorg.xrandr | |
| zlib | |
| ]; | |
| }; | |
| geforceNowDirectSync = pkgs.writeShellScriptBin "geforcenow-direct-sync" '' | |
| set -euo pipefail | |
| src="''${1:-}" | |
| if [ -z "$src" ]; then | |
| if command -v flatpak >/dev/null 2>&1; then | |
| location="$(flatpak info --show-location com.nvidia.geforcenow 2>/dev/null || true)" | |
| else | |
| location="" | |
| fi | |
| if [ -n "''${location:-}" ]; then | |
| src="$location/files" | |
| else | |
| src="$HOME/.local/share/flatpak/app/com.nvidia.geforcenow/current/active/files" | |
| fi | |
| fi | |
| if [ ! -x "$src/cef/GeForceNOW" ]; then | |
| echo "Invalid GeForce NOW payload: $src" >&2 | |
| exit 1 | |
| fi | |
| base="''${GFN_DIRECT_BASE:-$HOME/.local/share/geforcenow-direct}" | |
| dst="''${GFN_DIRECT_PAYLOAD:-$base/files}" | |
| mkdir -p "$base" | |
| tmp="$(mktemp -d "$base/.files.tmp.XXXXXX")" | |
| cleanup() { | |
| rm -rf "$tmp" | |
| } | |
| trap cleanup EXIT | |
| cp -a "$src/." "$tmp/" | |
| chmod -R u+rwX "$tmp" | |
| rm -rf "$dst.old" | |
| if [ -e "$dst" ]; then | |
| mv "$dst" "$dst.old" | |
| fi | |
| mv "$tmp" "$dst" | |
| trap - EXIT | |
| echo "GeForce NOW payload synced to $dst" | |
| ''; | |
| in | |
| { | |
| environment.systemPackages = [ | |
| geforceNowDirect | |
| geforceNowDirectSync | |
| ]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment