History

drm/nouveau: Add DRM_IOCTL_NOUVEAU_GET_ZCULL_INFO

Add kernel-side support for using the zcull hardware in nvidia gpus. zcull aims to improve memory bandwidth by using an early approximate depth test, similar to hierarchical Z on an AMD card. Add a new ioctl that exposes zcull information that has been read from the hardware. Userspace uses each of these parameters either in a heuristic for determining zcull region parameters or in the calculation of a buffer size. It appears the hardware hasn't changed its structure for these values since FERMI_C (circa 2011), so the assumption is that it won't change on us too quickly, and is therefore reasonable to include in UAPI. This bypasses the nvif layer and instead accesses nvkm_gr directly, which mirrors existing usage of nvkm_gr_units(). There is no nvif object for nvkm_gr yet, and adding one is not trivial.

Mel Henning committed 8 months ago

Commit 196b2b91 parent 27e125e4 files · +97 −0Browse files

Showing the changes to include/uapi (1 of 4 files). Show all

Unified · Split

include/uapi/drm/nouveau_drm.h+66−0
@@ -432,6 +432,69 @@ struct drm_nouveau_exec { · 431 unmodified lines
432432 __u64 push_ptr;
433433 };
434434
435+struct drm_nouveau_get_zcull_info {
436+ /**
437+ * @width_align_pixels: required alignment for region widths, in pixels
438+ * (typically #TPC's * 16).
439+ */
440+ __u32 width_align_pixels;
441+ /**
442+ * @height_align_pixels: required alignment for region heights, in
443+ * pixels (typically 32).
444+ */
445+ __u32 height_align_pixels;
446+ /**
447+ * @pixel_squares_by_aliquots: the pixel area covered by an aliquot
448+ * (typically #Zcull_banks * 16 * 16).
449+ */
450+ __u32 pixel_squares_by_aliquots;
451+ /**
452+ * @aliquot_total: the total aliquot pool available in hardware
453+ */
454+ __u32 aliquot_total;
455+ /**
456+ * @zcull_region_byte_multiplier: the size of an aliquot in bytes, which
457+ * is used for save/restore operations on a region
458+ */
459+ __u32 zcull_region_byte_multiplier;
460+ /**
461+ * @zcull_region_header_size: the region header size in bytes, which is
462+ * used for save/restore operations on a region
463+ */
464+ __u32 zcull_region_header_size;
465+ /**
466+ * @zcull_subregion_header_size: the subregion header size in bytes,
467+ * which is used for save/restore operations on a region
468+ */
469+ __u32 zcull_subregion_header_size;
470+ /**
471+ * @subregion_count: the total number of subregions the hardware
472+ * supports
473+ */
474+ __u32 subregion_count;
475+ /**
476+ * @subregion_width_align_pixels: required alignment for subregion
477+ * widths, in pixels (typically #TPC's * 16).
478+ */
479+ __u32 subregion_width_align_pixels;
480+ /**
481+ * @subregion_height_align_pixels: required alignment for subregion
482+ * heights, in pixels
483+ */
484+ __u32 subregion_height_align_pixels;
485+
486+ /**
487+ * @ctxsw_size: the size, in bytes, of a zcull context switching region.
488+ * Will be zero if the kernel does not support zcull context switching.
489+ */
490+ __u32 ctxsw_size;
491+ /**
492+ * @ctxsw_align: the alignment, in bytes, of a zcull context switching
493+ * region
494+ */
495+ __u32 ctxsw_align;
496+};
497+
435498 #define DRM_NOUVEAU_GETPARAM 0x00
436499 #define DRM_NOUVEAU_SETPARAM 0x01 /* deprecated */
437500 #define DRM_NOUVEAU_CHANNEL_ALLOC 0x02
@@ -445,6 +508,7 @@ struct drm_nouveau_exec { · 7 unmodified lines
445508 #define DRM_NOUVEAU_VM_INIT 0x10
446509 #define DRM_NOUVEAU_VM_BIND 0x11
447510 #define DRM_NOUVEAU_EXEC 0x12
511+#define DRM_NOUVEAU_GET_ZCULL_INFO 0x13
448512 #define DRM_NOUVEAU_GEM_NEW 0x40
449513 #define DRM_NOUVEAU_GEM_PUSHBUF 0x41
450514 #define DRM_NOUVEAU_GEM_CPU_PREP 0x42
@@ -513,6 +577,8 @@ struct drm_nouveau_svm_bind { · 62 unmodified lines
513577 #define DRM_IOCTL_NOUVEAU_VM_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_VM_INIT, struct drm_nouveau_vm_init)
514578 #define DRM_IOCTL_NOUVEAU_VM_BIND DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_VM_BIND, struct drm_nouveau_vm_bind)
515579 #define DRM_IOCTL_NOUVEAU_EXEC DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_EXEC, struct drm_nouveau_exec)
580+
581+#define DRM_IOCTL_NOUVEAU_GET_ZCULL_INFO DRM_IOR (DRM_COMMAND_BASE + DRM_NOUVEAU_GET_ZCULL_INFO, struct drm_nouveau_get_zcull_info)
516582 #if defined(__cplusplus)
517583 }
518584 #endif