mesa/src/intel/isl
Paulo Zanoni eeb6515096 intel/isl: tile 64 calculations work with 1D surfaces
Depth/stencil surfaces cannot be linear but they can be 1D, so they
end up being tile64 when sparse (as we force every sparse resource to
be either tile64 or linear).

According to the "1D surfaces" page from BSpec, our driver treats 1D
surfaces as 2D surfaces with a height of 1 texel, since we don't
enable the corresponding bit from HAS_SLICE_CHICKEN7. And since we
support 2D surfaces, we should also support 1D.

Reviewed-by: Nanley Chery <nanley.g.chery@intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22974>
2023-06-29 23:30:05 +00:00
..
tests intel: Rename the GFX12_CCS_E aux-usage to FCV_CCS_E 2023-06-07 23:39:39 +00:00
gen_format_layout.py intel/isl: Fix map between sRGB and linear formats 2023-05-15 18:49:13 +00:00
isl.c intel/isl: tile 64 calculations work with 1D surfaces 2023-06-29 23:30:05 +00:00
isl.h util: reinstate ENUM_PACKED 2023-06-21 21:51:59 +00:00
isl_aux_info.c intel: Rename the GFX12_CCS_E aux-usage to FCV_CCS_E 2023-06-07 23:39:39 +00:00
isl_drm.c intel/isl: Add MTL MC CCS modifier into modifier info 2023-06-16 17:32:10 +00:00
isl_emit_cpb.c isl: avoid gfx version switch cases on the hot path 2022-10-14 23:03:16 +00:00
isl_emit_depth_stencil.c isl: don't set inconsistent fields for depth when using stencil only 2023-04-17 22:43:37 +00:00
isl_format.c isl: Check all channels in isl_formats_have_same_bits_per_channel 2023-04-27 01:04:44 +00:00
isl_format_layout.csv intel/isl: Use a new HiZ format on XeHP+ 2022-01-11 20:06:02 +00:00
isl_genX_helpers.h isl: Move some genxml surface state helpers into an include file 2021-12-06 17:23:56 -08:00
isl_genX_priv.h isl: avoid gfx version switch cases on the hot path 2022-10-14 23:03:16 +00:00
isl_gfx4.c intel/isl: Require Y-tiling for depth on gfx4-5 2022-01-11 20:06:02 +00:00
isl_gfx4.h intel: Rename genx keyword to gfxx in source files 2021-04-02 18:33:07 +00:00
isl_gfx6.c isl: add surface creation reporting mechanism 2023-06-21 13:28:34 +00:00
isl_gfx6.h intel: Rename genx keyword to gfxx in source files 2021-04-02 18:33:07 +00:00
isl_gfx7.c isl: add surface creation reporting mechanism 2023-06-21 13:28:34 +00:00
isl_gfx7.h intel: Rename genx keyword to gfxx in source files 2021-04-02 18:33:07 +00:00
isl_gfx8.c isl: add surface creation reporting mechanism 2023-06-21 13:28:34 +00:00
isl_gfx8.h intel: Rename genx keyword to gfxx in source files 2021-04-02 18:33:07 +00:00
isl_gfx9.c intel: fix typos found by codespell 2022-06-27 10:20:55 +00:00
isl_gfx9.h intel: Rename genx keyword to gfxx in source files 2021-04-02 18:33:07 +00:00
isl_gfx12.c intel/isl: tile 64 calculations work with 1D surfaces 2023-06-29 23:30:05 +00:00
isl_gfx12.h intel/isl: Update tiling filter functions for XeHP 2021-08-25 22:39:30 +00:00
isl_priv.h isl: add surface creation reporting mechanism 2023-06-21 13:28:34 +00:00
isl_storage_image.c isl: fix a number of errors on storage format support on Gfx9/12.5 2023-04-18 08:38:55 +00:00
isl_surface_state.c isl: Don't set "Enable Unorm Path in Color Pipe" on Alchemist 2023-06-29 21:45:13 +00:00
isl_tiled_memcpy.c treewide: drop mtypes/macros includes from main 2021-12-08 22:14:45 +00:00
isl_tiled_memcpy_normal.c intel/isl: Drop intel_ prefix in function names 2021-03-11 23:01:56 +00:00
isl_tiled_memcpy_sse41.c intel/isl: Drop intel_ prefix in function names 2021-03-11 23:01:56 +00:00
meson.build meson: inline gtest_test_protocol now that it's always 'gtest' 2023-03-10 07:20:29 +00:00
README intel: fix typos found by codespell 2022-06-27 10:20:55 +00:00

Intel Surface Layout

Introduction
============
isl is a small library that calculates the layout of Intel GPU surfaces, queries
those layouts, and queries the properties of surface formats.


Independence from User APIs
===========================
isl's API is independent of any user-facing graphics API, such as OpenGL and
Vulkan. This independence allows isl to be used a shared component by multiple
Intel drivers.

Rather than mimic the user-facing APIs, the isl API attempts to reflect Intel
hardware: the actual memory layout of Intel GPU surfaces and how one programs
the GPU to use those surfaces. For example:

  - The tokens of `enum isl_format` (such as `ISL_FORMAT_R8G8B8A8_UNORM`)
    match those of the hardware enum `SURFACE_FORMAT` rather than the OpenGL
    or Vulkan format tokens.  And the values of `isl_format` and
    `SURFACE_FORMAT` are identical.

  - The OpenGL and Vulkan APIs contain depth and stencil formats. However the
    hardware enum `SURFACE_FORMAT` does not, and therefore neither does `enum
    isl_format`. Rather than define new pixel formats that have no hardware
    counterpart, isl records the intent to use a surface as a depth or stencil
    buffer with the usage flags `ISL_SURF_USAGE_DEPTH_BIT` and
    `ISL_SURF_USAGE_STENCIL_BIT`.

  - `struct isl_surf` distinguishes between the surface's logical dimension
    from the user API's perspective (`enum isl_surf_dim`, which may be 1D, 2D,
    or 3D) and the layout of those dimensions in memory (`enum isl_dim_layout`).


Surface Units
=============

Intro
-----
ISL takes care in its equations to correctly handle conversion among surface
units (such as pixels and compression blocks) and to carefully distinguish
between a surface's logical layout in the client API and its physical layout
in memory.

Symbol names often explicitly declare their unit with a suffix:

   - px: logical pixels
   - sa: physical surface samples
   - el: physical surface elements
   - sa_rows: rows of physical surface samples
   - el_rows: rows of physical surface elements

Logical units are independent of hardware generation and are closely related
to the user-facing API (OpenGL and Vulkan). Physical units are dependent on
hardware generation and reflect the surface's layout in memory.

Definitions
-----------
- Logical Pixels (px):

  The surface's layout from the perspective of the client API (OpenGL and
  Vulkan) is in units of logical pixels. Logical pixels are independent of the
  surface's layout in memory.

  A surface's width and height, in units of logical pixels, is not affected by
  the surface's sample count. For example, consider a VkImage created with
  VkImageCreateInfo{width=w0, height=h0, samples=s0}. The surface's width and
  height at level 0 is, in units of logical pixels, w0 and h0 regardless of
  the value of s0.

  For example, the logical array length of a 3D surface is always 1, even on
  Gfx9 where the surface's memory layout is that of an array surface
  (ISL_DIM_LAYOUT_GFX4_2D).

- Physical Surface Samples (sa):

  For a multisampled surface, this unit has the obvious meaning.
  A singlesampled surface, from ISL's perspective, is simply a multisampled
  surface whose sample count is 1.

  For example, consider a 2D single-level non-array surface with samples=4,
  width_px=64, and height_px=64 (note that the suffix 'px' indicates logical
  pixels). If the surface's multisample layout is ISL_MSAA_LAYOUT_INTERLEAVED,
  then the extent of level 0 is, in units of physical surface samples,
  width_sa=128, height_sa=128, depth_sa=1, array_length_sa=1. If
  ISL_MSAA_LAYOUT_ARRAY, then width_sa=64, height_sa=64, depth_sa=1,
  array_length_sa=4.

- Physical Surface Elements (el):

  This unit allows ISL to treat compressed and uncompressed formats
  identically in many calculations.

  If the surface's pixel format is compressed, such as ETC2, then a surface
  element is equivalent to a compression block. If uncompressed, then
  a surface element is equivalent to a surface sample. As a corollary, for
  a given surface a surface element is at least as large as a surface sample.

Errata
------
ISL acquired the term 'surface element' from the Broadwell PRM [1], which
defines it as follows:

   An element is defined as a pixel in uncompressed surface formats, and as
   a compression block in compressed surface formats. For MSFMT_DEPTH_STENCIL
   type multisampled surfaces, an element is a sample.


References
==========
[1]: Broadwell PRM >> Volume 2d: Command Reference: Structures >>
     RENDER_SURFACE_STATE Surface Vertical Alignment (p325)