1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright 2015 Intel Corporation 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13bf215546Sopenharmony_ci * Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21bf215546Sopenharmony_ci * IN THE SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ci#include <assert.h> 25bf215546Sopenharmony_ci 26bf215546Sopenharmony_ci#include "isl.h" 27bf215546Sopenharmony_ci#include "isl_priv.h" 28bf215546Sopenharmony_ci#include "dev/intel_device_info.h" 29bf215546Sopenharmony_ci 30bf215546Sopenharmony_ci#include "util/macros.h" /* Needed for MAX3 and MAX2 for format_rgb9e5 */ 31bf215546Sopenharmony_ci#include "util/format_srgb.h" 32bf215546Sopenharmony_ci#include "util/format_rgb9e5.h" 33bf215546Sopenharmony_ci#include "util/format_r11g11b10f.h" 34bf215546Sopenharmony_ci 35bf215546Sopenharmony_ci/* Header-only format conversion include */ 36bf215546Sopenharmony_ci#include "main/format_utils.h" 37bf215546Sopenharmony_ci 38bf215546Sopenharmony_cistruct surface_format_info { 39bf215546Sopenharmony_ci bool exists; 40bf215546Sopenharmony_ci uint8_t sampling; 41bf215546Sopenharmony_ci uint8_t filtering; 42bf215546Sopenharmony_ci uint8_t shadow_compare; 43bf215546Sopenharmony_ci uint8_t chroma_key; 44bf215546Sopenharmony_ci uint8_t render_target; 45bf215546Sopenharmony_ci uint8_t alpha_blend; 46bf215546Sopenharmony_ci uint8_t input_vb; 47bf215546Sopenharmony_ci uint8_t streamed_output_vb; 48bf215546Sopenharmony_ci uint8_t color_processing; 49bf215546Sopenharmony_ci uint8_t typed_write; 50bf215546Sopenharmony_ci uint8_t typed_read; 51bf215546Sopenharmony_ci uint8_t typed_atomics; 52bf215546Sopenharmony_ci uint8_t ccs_e; 53bf215546Sopenharmony_ci}; 54bf215546Sopenharmony_ci 55bf215546Sopenharmony_ci/* This macro allows us to write the table almost as it appears in the PRM, 56bf215546Sopenharmony_ci * while restructuring it to turn it into the C code we want. 57bf215546Sopenharmony_ci */ 58bf215546Sopenharmony_ci#define SF(sampl, filt, shad, ck, rt, ab, vb, so, color, tw, tr, ccs_e, ta, sf) \ 59bf215546Sopenharmony_ci [ISL_FORMAT_##sf] = { true, sampl, filt, shad, ck, rt, ab, vb, so, color, tw, tr, ta, ccs_e}, 60bf215546Sopenharmony_ci 61bf215546Sopenharmony_ci#define Y 0 62bf215546Sopenharmony_ci#define x 255 63bf215546Sopenharmony_ci/** 64bf215546Sopenharmony_ci * This is the table of support for surface (texture, renderbuffer, and vertex 65bf215546Sopenharmony_ci * buffer, but not depthbuffer) formats across the various hardware generations. 66bf215546Sopenharmony_ci * 67bf215546Sopenharmony_ci * The table is formatted to match the documentation, except that the docs have 68bf215546Sopenharmony_ci * this ridiculous mapping of Y[*+~^#&] for "supported on DevWhatever". To put 69bf215546Sopenharmony_ci * it in our table, here's the mapping: 70bf215546Sopenharmony_ci * 71bf215546Sopenharmony_ci * Y*: 45 72bf215546Sopenharmony_ci * Y+: 45 (g45/gm45) 73bf215546Sopenharmony_ci * Y~: 50 (gfx5) 74bf215546Sopenharmony_ci * Y^: 60 (gfx6) 75bf215546Sopenharmony_ci * Y#: 70 (gfx7) 76bf215546Sopenharmony_ci * 77bf215546Sopenharmony_ci * The abbreviations in the header below are: 78bf215546Sopenharmony_ci * smpl - Sampling Engine 79bf215546Sopenharmony_ci * filt - Sampling Engine Filtering 80bf215546Sopenharmony_ci * shad - Sampling Engine Shadow Map 81bf215546Sopenharmony_ci * CK - Sampling Engine Chroma Key 82bf215546Sopenharmony_ci * RT - Render Target 83bf215546Sopenharmony_ci * AB - Alpha Blend Render Target 84bf215546Sopenharmony_ci * VB - Input Vertex Buffer 85bf215546Sopenharmony_ci * SO - Steamed Output Vertex Buffers (transform feedback) 86bf215546Sopenharmony_ci * color - Color Processing 87bf215546Sopenharmony_ci * TW - Typed Write 88bf215546Sopenharmony_ci * TR - Typed Read 89bf215546Sopenharmony_ci * ccs_e - Lossless Compression Support (gfx9+ only) 90bf215546Sopenharmony_ci * sf - Surface Format 91bf215546Sopenharmony_ci * TA - Typed Atomics 92bf215546Sopenharmony_ci * 93bf215546Sopenharmony_ci * See page 88 of the Sandybridge PRM VOL4_Part1 PDF. 94bf215546Sopenharmony_ci * 95bf215546Sopenharmony_ci * As of Ivybridge, the columns are no longer in that table and the 96bf215546Sopenharmony_ci * information can be found spread across: 97bf215546Sopenharmony_ci * 98bf215546Sopenharmony_ci * - VOL2_Part1 section 2.5.11 Format Conversion (vertex fetch). 99bf215546Sopenharmony_ci * - VOL4_Part1 section 2.12.2.1.2 Sampler Output Channel Mapping. 100bf215546Sopenharmony_ci * - VOL4_Part1 section 3.9.11 Render Target Write. 101bf215546Sopenharmony_ci * - Render Target Surface Types [SKL+] 102bf215546Sopenharmony_ci */ 103bf215546Sopenharmony_cistatic const struct surface_format_info format_info[] = { 104bf215546Sopenharmony_ci/* smpl filt shad CK RT AB VB SO color TW TR ccs_e TA */ 105bf215546Sopenharmony_ci SF( Y, 50, x, x, Y, Y, Y, Y, x, 70, 90, 90, x, R32G32B32A32_FLOAT) 106bf215546Sopenharmony_ci SF( Y, x, x, x, Y, x, Y, Y, x, 70, 90, 90, x, R32G32B32A32_SINT) 107bf215546Sopenharmony_ci SF( Y, x, x, x, Y, x, Y, Y, x, 70, 90, 90, x, R32G32B32A32_UINT) 108bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R32G32B32A32_UNORM) 109bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R32G32B32A32_SNORM) 110bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R64G64_FLOAT) 111bf215546Sopenharmony_ci SF( Y, 50, x, x, 100, 100, x, x, x, x, x, 100, x, R32G32B32X32_FLOAT) 112bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R32G32B32A32_SSCALED) 113bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R32G32B32A32_USCALED) 114bf215546Sopenharmony_ci SF( x, x, x, x, x, x, 75, x, x, x, x, x, x, R32G32B32A32_SFIXED) 115bf215546Sopenharmony_ci SF( x, x, x, x, x, x, 80, x, x, x, x, x, x, R64G64_PASSTHRU) 116bf215546Sopenharmony_ci SF( Y, 50, x, x, x, x, Y, Y, x, x, x, x, x, R32G32B32_FLOAT) 117bf215546Sopenharmony_ci SF( Y, x, x, x, x, x, Y, Y, x, x, x, x, x, R32G32B32_SINT) 118bf215546Sopenharmony_ci SF( Y, x, x, x, x, x, Y, Y, x, x, x, x, x, R32G32B32_UINT) 119bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R32G32B32_UNORM) 120bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R32G32B32_SNORM) 121bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R32G32B32_SSCALED) 122bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R32G32B32_USCALED) 123bf215546Sopenharmony_ci SF( x, x, x, x, x, x, 75, x, x, x, x, x, x, R32G32B32_SFIXED) 124bf215546Sopenharmony_ci SF( Y, Y, x, x, Y, 45, Y, x, 60, 70, 110, 90, x, R16G16B16A16_UNORM) 125bf215546Sopenharmony_ci SF( Y, Y, x, x, Y, 60, Y, x, x, 70, 110, 90, x, R16G16B16A16_SNORM) 126bf215546Sopenharmony_ci SF( Y, x, x, x, Y, x, Y, x, x, 70, 90, 90, x, R16G16B16A16_SINT) 127bf215546Sopenharmony_ci SF( Y, x, x, x, Y, x, Y, x, x, 70, 75, 90, x, R16G16B16A16_UINT) 128bf215546Sopenharmony_ci SF( Y, Y, x, x, Y, Y, Y, x, x, 70, 90, 90, x, R16G16B16A16_FLOAT) 129bf215546Sopenharmony_ci SF( Y, 50, x, x, Y, Y, Y, Y, x, 70, 90, 90, x, R32G32_FLOAT) 130bf215546Sopenharmony_ci SF( Y, 70, x, x, Y, Y, Y, Y, x, x, x, x, x, R32G32_FLOAT_LD) 131bf215546Sopenharmony_ci SF( Y, x, x, x, Y, x, Y, Y, x, 70, 90, 90, x, R32G32_SINT) 132bf215546Sopenharmony_ci SF( Y, x, x, x, Y, x, Y, Y, x, 70, 90, 90, x, R32G32_UINT) 133bf215546Sopenharmony_ci SF( Y, 50, Y, x, x, x, x, x, x, x, x, x, x, R32_FLOAT_X8X24_TYPELESS) 134bf215546Sopenharmony_ci SF( Y, x, x, x, x, x, x, x, x, x, x, x, x, X32_TYPELESS_G8X24_UINT) 135bf215546Sopenharmony_ci SF( Y, 50, x, x, x, x, x, x, x, x, x, x, x, L32A32_FLOAT) 136bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R32G32_UNORM) 137bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R32G32_SNORM) 138bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, 90, R64_FLOAT) 139bf215546Sopenharmony_ci SF( Y, Y, x, x, x, x, x, x, x, x, x, x, x, R16G16B16X16_UNORM) 140bf215546Sopenharmony_ci SF( Y, Y, x, x, 90, 90, x, x, x, x, x, 90, x, R16G16B16X16_FLOAT) 141bf215546Sopenharmony_ci SF( Y, 50, x, x, x, x, x, x, x, x, x, x, x, A32X32_FLOAT) 142bf215546Sopenharmony_ci SF( Y, 50, x, x, x, x, x, x, x, x, x, x, x, L32X32_FLOAT) 143bf215546Sopenharmony_ci SF( Y, 50, x, x, x, x, x, x, x, x, x, x, x, I32X32_FLOAT) 144bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R16G16B16A16_SSCALED) 145bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R16G16B16A16_USCALED) 146bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R32G32_SSCALED) 147bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R32G32_USCALED) 148bf215546Sopenharmony_ci SF( x, x, x, x, x, x, 75, x, x, x, x, x, x, R32G32_SFIXED) 149bf215546Sopenharmony_ci SF( x, x, x, x, x, x, 80, x, x, x, x, x, 90, R64_PASSTHRU) 150bf215546Sopenharmony_ci SF( Y, Y, x, Y, Y, Y, Y, x, 60, 70, x, 90, x, B8G8R8A8_UNORM) 151bf215546Sopenharmony_ci SF( Y, Y, x, x, Y, Y, x, x, x, x, x, 100, x, B8G8R8A8_UNORM_SRGB) 152bf215546Sopenharmony_ci/* smpl filt shad CK RT AB VB SO color TW TR ccs_e TA */ 153bf215546Sopenharmony_ci SF( Y, Y, x, x, Y, Y, Y, x, 60, 70, x, 100, x, R10G10B10A2_UNORM) 154bf215546Sopenharmony_ci SF( Y, Y, x, x, x, x, x, x, 60, x, x, 120, x, R10G10B10A2_UNORM_SRGB) 155bf215546Sopenharmony_ci SF( Y, x, x, x, Y, x, Y, x, x, 70, x, 100, x, R10G10B10A2_UINT) 156bf215546Sopenharmony_ci SF( Y, Y, x, x, x, x, Y, x, x, x, x, x, x, R10G10B10_SNORM_A2_UNORM) 157bf215546Sopenharmony_ci SF( Y, Y, x, x, Y, Y, Y, x, 60, 70, 110, 90, x, R8G8B8A8_UNORM) 158bf215546Sopenharmony_ci SF( Y, Y, x, x, Y, Y, x, x, 60, x, x, 100, x, R8G8B8A8_UNORM_SRGB) 159bf215546Sopenharmony_ci SF( Y, Y, x, x, Y, 60, Y, x, x, 70, 110, 90, x, R8G8B8A8_SNORM) 160bf215546Sopenharmony_ci SF( Y, x, x, x, Y, x, Y, x, x, 70, 90, 90, x, R8G8B8A8_SINT) 161bf215546Sopenharmony_ci SF( Y, x, x, x, Y, x, Y, x, x, 70, 75, 90, x, R8G8B8A8_UINT) 162bf215546Sopenharmony_ci SF( Y, Y, x, x, Y, 45, Y, x, x, 70, 110, 90, x, R16G16_UNORM) 163bf215546Sopenharmony_ci SF( Y, Y, x, x, Y, 60, Y, x, x, 70, 110, 90, x, R16G16_SNORM) 164bf215546Sopenharmony_ci SF( Y, x, x, x, Y, x, Y, x, x, 70, 90, 90, x, R16G16_SINT) 165bf215546Sopenharmony_ci SF( Y, x, x, x, Y, x, Y, x, x, 70, 75, 90, x, R16G16_UINT) 166bf215546Sopenharmony_ci SF( Y, Y, x, x, Y, Y, Y, x, x, 70, 90, 90, x, R16G16_FLOAT) 167bf215546Sopenharmony_ci SF( Y, Y, x, x, Y, Y, 75, x, 60, 70, x, 100, x, B10G10R10A2_UNORM) 168bf215546Sopenharmony_ci SF( Y, Y, x, x, Y, Y, x, x, 60, x, x, 100, x, B10G10R10A2_UNORM_SRGB) 169bf215546Sopenharmony_ci SF( Y, Y, x, x, Y, Y, Y, x, x, 70, x, 100, x, R11G11B10_FLOAT) 170bf215546Sopenharmony_ci SF(120, 120, x, x, 120, 120, x, x, x, x, x, 120, x, R10G10B10_FLOAT_A2_UNORM) 171bf215546Sopenharmony_ci SF( Y, x, x, x, Y, x, Y, Y, x, 70, 70, 90, 70, R32_SINT) 172bf215546Sopenharmony_ci SF( Y, x, x, x, Y, x, Y, Y, x, 70, 70, 90, 70, R32_UINT) 173bf215546Sopenharmony_ci SF( Y, 50, Y, x, Y, Y, Y, Y, x, 70, 70, 90, 110, R32_FLOAT) 174bf215546Sopenharmony_ci SF( Y, 50, Y, x, x, x, x, x, x, x, x, 120, x, R24_UNORM_X8_TYPELESS) 175bf215546Sopenharmony_ci SF( Y, x, x, x, x, x, x, x, x, x, x, x, x, X24_TYPELESS_G8_UINT) 176bf215546Sopenharmony_ci SF( Y, Y, x, x, x, x, x, x, x, x, x, x, x, L16A16_UNORM) 177bf215546Sopenharmony_ci SF( Y, 50, Y, x, x, x, x, x, x, x, x, x, x, I24X8_UNORM) 178bf215546Sopenharmony_ci SF( Y, 50, Y, x, x, x, x, x, x, x, x, x, x, L24X8_UNORM) 179bf215546Sopenharmony_ci SF( Y, 50, Y, x, x, x, x, x, x, x, x, x, x, A24X8_UNORM) 180bf215546Sopenharmony_ci SF( Y, 50, Y, x, x, x, x, x, x, x, x, x, x, I32_FLOAT) 181bf215546Sopenharmony_ci SF( Y, 50, Y, x, x, x, x, x, x, x, x, x, x, L32_FLOAT) 182bf215546Sopenharmony_ci SF( Y, 50, Y, x, x, x, x, x, x, x, x, x, x, A32_FLOAT) 183bf215546Sopenharmony_ci SF( Y, Y, x, Y, 80, 80, x, x, 60, x, x, 90, x, B8G8R8X8_UNORM) 184bf215546Sopenharmony_ci SF( Y, Y, x, x, 80, 80, x, x, x, x, x, 100, x, B8G8R8X8_UNORM_SRGB) 185bf215546Sopenharmony_ci SF( Y, Y, x, x, x, x, x, x, x, x, x, x, x, R8G8B8X8_UNORM) 186bf215546Sopenharmony_ci SF( Y, Y, x, x, x, x, x, x, x, x, x, x, x, R8G8B8X8_UNORM_SRGB) 187bf215546Sopenharmony_ci SF( Y, Y, x, x, x, x, x, x, x, x, x, x, x, R9G9B9E5_SHAREDEXP) 188bf215546Sopenharmony_ci SF( Y, Y, x, x, x, x, x, x, x, x, x, x, x, B10G10R10X2_UNORM) 189bf215546Sopenharmony_ci SF( Y, Y, x, x, x, x, x, x, x, x, x, x, x, L16A16_FLOAT) 190bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R32_UNORM) 191bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R32_SNORM) 192bf215546Sopenharmony_ci/* smpl filt shad CK RT AB VB SO color TW TR ccs_e TA */ 193bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R10G10B10X2_USCALED) 194bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R8G8B8A8_SSCALED) 195bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R8G8B8A8_USCALED) 196bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R16G16_SSCALED) 197bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R16G16_USCALED) 198bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R32_SSCALED) 199bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R32_USCALED) 200bf215546Sopenharmony_ci SF( Y, Y, x, Y, Y, Y, x, x, x, 70, x, 120, x, B5G6R5_UNORM) 201bf215546Sopenharmony_ci SF( Y, Y, x, x, Y, Y, x, x, x, x, x, 120, x, B5G6R5_UNORM_SRGB) 202bf215546Sopenharmony_ci SF( Y, Y, x, Y, Y, Y, x, x, x, 70, x, 120, x, B5G5R5A1_UNORM) 203bf215546Sopenharmony_ci SF( Y, Y, x, x, Y, Y, x, x, x, x, x, 120, x, B5G5R5A1_UNORM_SRGB) 204bf215546Sopenharmony_ci SF( Y, Y, x, Y, Y, Y, x, x, x, 70, x, 120, x, B4G4R4A4_UNORM) 205bf215546Sopenharmony_ci SF( Y, Y, x, x, Y, Y, x, x, x, x, x, 120, x, B4G4R4A4_UNORM_SRGB) 206bf215546Sopenharmony_ci SF( Y, Y, x, x, Y, Y, Y, x, x, 70, 110, 120, x, R8G8_UNORM) 207bf215546Sopenharmony_ci SF( Y, Y, x, Y, Y, 60, Y, x, x, 70, 110, 120, x, R8G8_SNORM) 208bf215546Sopenharmony_ci SF( Y, x, x, x, Y, x, Y, x, x, 70, 90, 120, x, R8G8_SINT) 209bf215546Sopenharmony_ci SF( Y, x, x, x, Y, x, Y, x, x, 70, 75, 120, x, R8G8_UINT) 210bf215546Sopenharmony_ci SF( Y, Y, Y, x, Y, 45, Y, x, 70, 70, 110, 120, x, R16_UNORM) 211bf215546Sopenharmony_ci SF( Y, Y, x, x, Y, 60, Y, x, x, 70, 110, 120, x, R16_SNORM) 212bf215546Sopenharmony_ci SF( Y, x, x, x, Y, x, Y, x, x, 70, 90, 120, 120, R16_SINT) 213bf215546Sopenharmony_ci SF( Y, x, x, x, Y, x, Y, x, x, 70, 75, 120, 120, R16_UINT) 214bf215546Sopenharmony_ci SF( Y, Y, x, x, Y, Y, Y, x, x, 70, 90, 120, 120, R16_FLOAT) 215bf215546Sopenharmony_ci SF( 50, 50, x, x, x, x, x, x, x, x, x, x, x, A8P8_UNORM_PALETTE0) 216bf215546Sopenharmony_ci SF( 50, 50, x, x, x, x, x, x, x, x, x, x, x, A8P8_UNORM_PALETTE1) 217bf215546Sopenharmony_ci SF( Y, Y, Y, x, x, x, x, x, x, x, x, x, x, I16_UNORM) 218bf215546Sopenharmony_ci SF( Y, Y, Y, x, x, x, x, x, x, x, x, x, x, L16_UNORM) 219bf215546Sopenharmony_ci SF( Y, Y, Y, x, x, x, x, x, x, x, x, x, x, A16_UNORM) 220bf215546Sopenharmony_ci SF( Y, Y, x, Y, x, x, x, x, x, x, x, x, x, L8A8_UNORM) 221bf215546Sopenharmony_ci SF( Y, Y, Y, x, x, x, x, x, x, x, x, x, x, I16_FLOAT) 222bf215546Sopenharmony_ci SF( Y, Y, Y, x, x, x, x, x, x, x, x, x, x, L16_FLOAT) 223bf215546Sopenharmony_ci SF( Y, Y, Y, x, x, x, x, x, x, x, x, x, x, A16_FLOAT) 224bf215546Sopenharmony_ci SF( 45, 45, x, x, x, x, x, x, x, x, x, x, x, L8A8_UNORM_SRGB) 225bf215546Sopenharmony_ci SF( Y, Y, x, Y, x, x, x, x, x, x, x, x, x, R5G5_SNORM_B6_UNORM) 226bf215546Sopenharmony_ci SF( x, x, x, x, Y, Y, x, x, x, 70, x, 120, x, B5G5R5X1_UNORM) 227bf215546Sopenharmony_ci SF( x, x, x, x, Y, Y, x, x, x, x, x, 120, x, B5G5R5X1_UNORM_SRGB) 228bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R8G8_SSCALED) 229bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R8G8_USCALED) 230bf215546Sopenharmony_ci/* smpl filt shad CK RT AB VB SO color TW TR ccs_e TA */ 231bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R16_SSCALED) 232bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R16_USCALED) 233bf215546Sopenharmony_ci SF( 50, 50, x, x, x, x, x, x, x, x, x, x, x, P8A8_UNORM_PALETTE0) 234bf215546Sopenharmony_ci SF( 50, 50, x, x, x, x, x, x, x, x, x, x, x, P8A8_UNORM_PALETTE1) 235bf215546Sopenharmony_ci SF(120, 120, x, x, 120, 120, x, x, x, x, x, 120, x, A1B5G5R5_UNORM) 236bf215546Sopenharmony_ci /* According to the PRM, A4B4G4R4_UNORM isn't supported until Sky Lake 237bf215546Sopenharmony_ci * but empirical testing indicates that at least sampling works just fine 238bf215546Sopenharmony_ci * on Broadwell. 239bf215546Sopenharmony_ci */ 240bf215546Sopenharmony_ci SF( 80, 80, x, x, 90, 120, x, x, x, x, x, 120, x, A4B4G4R4_UNORM) 241bf215546Sopenharmony_ci SF( 90, x, x, x, x, x, x, x, x, x, x, x, x, L8A8_UINT) 242bf215546Sopenharmony_ci SF( 90, x, x, x, x, x, x, x, x, x, x, x, x, L8A8_SINT) 243bf215546Sopenharmony_ci SF( Y, Y, x, 45, Y, Y, Y, x, x, 70, 110, 120, x, R8_UNORM) 244bf215546Sopenharmony_ci SF( Y, Y, x, x, Y, 60, Y, x, x, 70, 110, 120, x, R8_SNORM) 245bf215546Sopenharmony_ci SF( Y, x, x, x, Y, x, Y, x, x, 70, 90, 120, x, R8_SINT) 246bf215546Sopenharmony_ci SF( Y, x, x, x, Y, x, Y, x, x, 70, 75, 120, x, R8_UINT) 247bf215546Sopenharmony_ci SF( Y, Y, x, Y, Y, Y, x, x, x, 70, 110, 120, x, A8_UNORM) 248bf215546Sopenharmony_ci SF( Y, Y, x, x, x, x, x, x, x, x, x, x, x, I8_UNORM) 249bf215546Sopenharmony_ci SF( Y, Y, x, Y, x, x, x, x, x, x, x, x, x, L8_UNORM) 250bf215546Sopenharmony_ci SF( Y, Y, x, x, x, x, x, x, x, x, x, x, x, P4A4_UNORM_PALETTE0) 251bf215546Sopenharmony_ci SF( Y, Y, x, x, x, x, x, x, x, x, x, x, x, A4P4_UNORM_PALETTE0) 252bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R8_SSCALED) 253bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R8_USCALED) 254bf215546Sopenharmony_ci SF( 45, 45, x, x, x, x, x, x, x, x, x, x, x, P8_UNORM_PALETTE0) 255bf215546Sopenharmony_ci SF( 45, 45, x, x, x, x, x, x, x, x, x, x, x, L8_UNORM_SRGB) 256bf215546Sopenharmony_ci SF( 45, 45, x, x, x, x, x, x, x, x, x, x, x, P8_UNORM_PALETTE1) 257bf215546Sopenharmony_ci SF( 45, 45, x, x, x, x, x, x, x, x, x, x, x, P4A4_UNORM_PALETTE1) 258bf215546Sopenharmony_ci SF( 45, 45, x, x, x, x, x, x, x, x, x, x, x, A4P4_UNORM_PALETTE1) 259bf215546Sopenharmony_ci SF( x, x, x, x, x, x, x, x, x, x, x, x, x, Y8_UNORM) 260bf215546Sopenharmony_ci SF( 90, x, x, x, x, x, x, x, x, x, x, x, x, L8_UINT) 261bf215546Sopenharmony_ci SF( 90, x, x, x, x, x, x, x, x, x, x, x, x, L8_SINT) 262bf215546Sopenharmony_ci SF( 90, x, x, x, x, x, x, x, x, x, x, x, x, I8_UINT) 263bf215546Sopenharmony_ci SF( 90, x, x, x, x, x, x, x, x, x, x, x, x, I8_SINT) 264bf215546Sopenharmony_ci SF( 45, 45, x, x, x, x, x, x, x, x, x, x, x, DXT1_RGB_SRGB) 265bf215546Sopenharmony_ci SF( Y, Y, x, x, x, x, x, x, x, x, x, x, x, R1_UNORM) 266bf215546Sopenharmony_ci SF( Y, Y, x, Y, Y, x, x, x, 60, x, x, 120, x, YCRCB_NORMAL) 267bf215546Sopenharmony_ci SF( Y, Y, x, Y, Y, x, x, x, 60, x, x, x, x, YCRCB_SWAPUVY) 268bf215546Sopenharmony_ci SF( 45, 45, x, x, x, x, x, x, x, x, x, x, x, P2_UNORM_PALETTE0) 269bf215546Sopenharmony_ci SF( 45, 45, x, x, x, x, x, x, x, x, x, x, x, P2_UNORM_PALETTE1) 270bf215546Sopenharmony_ci SF( Y, Y, x, Y, x, x, x, x, x, x, x, x, x, BC1_UNORM) 271bf215546Sopenharmony_ci SF( Y, Y, x, Y, x, x, x, x, x, x, x, x, x, BC2_UNORM) 272bf215546Sopenharmony_ci SF( Y, Y, x, Y, x, x, x, x, x, x, x, x, x, BC3_UNORM) 273bf215546Sopenharmony_ci SF( Y, Y, x, x, x, x, x, x, x, x, x, x, x, BC4_UNORM) 274bf215546Sopenharmony_ci SF( Y, Y, x, x, x, x, x, x, x, x, x, x, x, BC5_UNORM) 275bf215546Sopenharmony_ci SF( Y, Y, x, x, x, x, x, x, x, x, x, x, x, BC1_UNORM_SRGB) 276bf215546Sopenharmony_ci SF( Y, Y, x, x, x, x, x, x, x, x, x, x, x, BC2_UNORM_SRGB) 277bf215546Sopenharmony_ci SF( Y, Y, x, x, x, x, x, x, x, x, x, x, x, BC3_UNORM_SRGB) 278bf215546Sopenharmony_ci SF( Y, x, x, x, x, x, x, x, x, x, x, x, x, MONO8) 279bf215546Sopenharmony_ci SF( Y, Y, x, x, Y, x, x, x, 60, x, x, x, x, YCRCB_SWAPUV) 280bf215546Sopenharmony_ci SF( Y, Y, x, x, Y, x, x, x, 60, x, x, 120, x, YCRCB_SWAPY) 281bf215546Sopenharmony_ci SF( Y, Y, x, x, x, x, x, x, x, x, x, x, x, DXT1_RGB) 282bf215546Sopenharmony_ci/* smpl filt shad CK RT AB VB SO color TW TR ccs_e TA */ 283bf215546Sopenharmony_ci SF( Y, Y, x, x, x, x, x, x, x, x, x, x, x, FXT1) 284bf215546Sopenharmony_ci SF( 75, 75, x, x, x, x, Y, x, x, x, x, x, x, R8G8B8_UNORM) 285bf215546Sopenharmony_ci SF( 75, 75, x, x, x, x, Y, x, x, x, x, x, x, R8G8B8_SNORM) 286bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R8G8B8_SSCALED) 287bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R8G8B8_USCALED) 288bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R64G64B64A64_FLOAT) 289bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R64G64B64_FLOAT) 290bf215546Sopenharmony_ci SF( Y, Y, x, x, x, x, x, x, x, x, x, x, x, BC4_SNORM) 291bf215546Sopenharmony_ci SF( Y, Y, x, x, x, x, x, x, x, x, x, x, x, BC5_SNORM) 292bf215546Sopenharmony_ci SF( 50, 50, x, x, x, x, 60, x, x, x, x, x, x, R16G16B16_FLOAT) 293bf215546Sopenharmony_ci SF( 75, 75, x, x, x, x, Y, x, x, x, x, x, x, R16G16B16_UNORM) 294bf215546Sopenharmony_ci SF( 75, 75, x, x, x, x, Y, x, x, x, x, x, x, R16G16B16_SNORM) 295bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R16G16B16_SSCALED) 296bf215546Sopenharmony_ci SF( x, x, x, x, x, x, Y, x, x, x, x, x, x, R16G16B16_USCALED) 297bf215546Sopenharmony_ci SF( 70, 70, x, x, x, x, x, x, x, x, x, x, x, BC6H_SF16) 298bf215546Sopenharmony_ci SF( 70, 70, x, x, x, x, x, x, x, x, x, x, x, BC7_UNORM) 299bf215546Sopenharmony_ci SF( 70, 70, x, x, x, x, x, x, x, x, x, x, x, BC7_UNORM_SRGB) 300bf215546Sopenharmony_ci SF( 70, 70, x, x, x, x, x, x, x, x, x, x, x, BC6H_UF16) 301bf215546Sopenharmony_ci SF( x, x, x, x, x, x, x, x, x, x, x, x, x, PLANAR_420_8) 302bf215546Sopenharmony_ci /* The format enum for R8G8B8_UNORM_SRGB first shows up in the HSW PRM but 303bf215546Sopenharmony_ci * empirical testing indicates that it doesn't actually sRGB decode and 304bf215546Sopenharmony_ci * acts identical to R8G8B8_UNORM. It does work on gfx8+. 305bf215546Sopenharmony_ci */ 306bf215546Sopenharmony_ci SF( 80, 80, x, x, x, x, x, x, x, x, x, x, x, R8G8B8_UNORM_SRGB) 307bf215546Sopenharmony_ci SF( 80, 80, x, x, x, x, x, x, x, x, x, x, x, ETC1_RGB8) 308bf215546Sopenharmony_ci SF( 80, 80, x, x, x, x, x, x, x, x, x, x, x, ETC2_RGB8) 309bf215546Sopenharmony_ci SF( 80, 80, x, x, x, x, x, x, x, x, x, x, x, EAC_R11) 310bf215546Sopenharmony_ci SF( 80, 80, x, x, x, x, x, x, x, x, x, x, x, EAC_RG11) 311bf215546Sopenharmony_ci SF( 80, 80, x, x, x, x, x, x, x, x, x, x, x, EAC_SIGNED_R11) 312bf215546Sopenharmony_ci SF( 80, 80, x, x, x, x, x, x, x, x, x, x, x, EAC_SIGNED_RG11) 313bf215546Sopenharmony_ci SF( 80, 80, x, x, x, x, x, x, x, x, x, x, x, ETC2_SRGB8) 314bf215546Sopenharmony_ci SF( 90, x, x, x, x, x, 75, x, x, x, x, x, x, R16G16B16_UINT) 315bf215546Sopenharmony_ci SF( 90, x, x, x, x, x, 75, x, x, x, x, x, x, R16G16B16_SINT) 316bf215546Sopenharmony_ci SF( x, x, x, x, x, x, 75, x, x, x, x, x, x, R32_SFIXED) 317bf215546Sopenharmony_ci SF( x, x, x, x, x, x, 75, x, x, x, x, x, x, R10G10B10A2_SNORM) 318bf215546Sopenharmony_ci SF( x, x, x, x, x, x, 75, x, x, x, x, x, x, R10G10B10A2_USCALED) 319bf215546Sopenharmony_ci SF( x, x, x, x, x, x, 75, x, x, x, x, x, x, R10G10B10A2_SSCALED) 320bf215546Sopenharmony_ci SF( x, x, x, x, x, x, 75, x, x, x, x, x, x, R10G10B10A2_SINT) 321bf215546Sopenharmony_ci SF( x, x, x, x, x, x, 75, x, x, x, x, x, x, B10G10R10A2_SNORM) 322bf215546Sopenharmony_ci SF( x, x, x, x, x, x, 75, x, x, x, x, x, x, B10G10R10A2_USCALED) 323bf215546Sopenharmony_ci SF( x, x, x, x, x, x, 75, x, x, x, x, x, x, B10G10R10A2_SSCALED) 324bf215546Sopenharmony_ci SF( x, x, x, x, x, x, 75, x, x, x, x, x, x, B10G10R10A2_UINT) 325bf215546Sopenharmony_ci SF( x, x, x, x, x, x, 75, x, x, x, x, x, x, B10G10R10A2_SINT) 326bf215546Sopenharmony_ci SF( x, x, x, x, x, x, 80, x, x, x, x, x, x, R64G64B64A64_PASSTHRU) 327bf215546Sopenharmony_ci SF( x, x, x, x, x, x, 80, x, x, x, x, x, x, R64G64B64_PASSTHRU) 328bf215546Sopenharmony_ci SF( 80, 80, x, x, x, x, x, x, x, x, x, x, x, ETC2_RGB8_PTA) 329bf215546Sopenharmony_ci SF( 80, 80, x, x, x, x, x, x, x, x, x, x, x, ETC2_SRGB8_PTA) 330bf215546Sopenharmony_ci SF( 80, 80, x, x, x, x, x, x, x, x, x, x, x, ETC2_EAC_RGBA8) 331bf215546Sopenharmony_ci SF( 80, 80, x, x, x, x, x, x, x, x, x, x, x, ETC2_EAC_SRGB8_A8) 332bf215546Sopenharmony_ci SF( 90, x, x, x, x, x, 75, x, x, x, x, x, x, R8G8B8_UINT) 333bf215546Sopenharmony_ci SF( 90, x, x, x, x, x, 75, x, x, x, x, x, x, R8G8B8_SINT) 334bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_4X4_FLT16) 335bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_5X4_FLT16) 336bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_5X5_FLT16) 337bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_6X5_FLT16) 338bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_6X6_FLT16) 339bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_8X5_FLT16) 340bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_8X6_FLT16) 341bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_8X8_FLT16) 342bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_10X5_FLT16) 343bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_10X6_FLT16) 344bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_10X8_FLT16) 345bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_10X10_FLT16) 346bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_12X10_FLT16) 347bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_12X12_FLT16) 348bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_4X4_U8SRGB) 349bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_5X4_U8SRGB) 350bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_5X5_U8SRGB) 351bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_6X5_U8SRGB) 352bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_6X6_U8SRGB) 353bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_8X5_U8SRGB) 354bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_8X6_U8SRGB) 355bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_8X8_U8SRGB) 356bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_10X5_U8SRGB) 357bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_10X6_U8SRGB) 358bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_10X8_U8SRGB) 359bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_10X10_U8SRGB) 360bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_12X10_U8SRGB) 361bf215546Sopenharmony_ci SF( 90, 90, x, x, x, x, x, x, x, x, x, x, x, ASTC_LDR_2D_12X12_U8SRGB) 362bf215546Sopenharmony_ci SF(100, 100, x, x, x, x, x, x, x, x, x, x, x, ASTC_HDR_2D_4X4_FLT16) 363bf215546Sopenharmony_ci SF(100, 100, x, x, x, x, x, x, x, x, x, x, x, ASTC_HDR_2D_5X4_FLT16) 364bf215546Sopenharmony_ci SF(100, 100, x, x, x, x, x, x, x, x, x, x, x, ASTC_HDR_2D_5X5_FLT16) 365bf215546Sopenharmony_ci SF(100, 100, x, x, x, x, x, x, x, x, x, x, x, ASTC_HDR_2D_6X5_FLT16) 366bf215546Sopenharmony_ci SF(100, 100, x, x, x, x, x, x, x, x, x, x, x, ASTC_HDR_2D_6X6_FLT16) 367bf215546Sopenharmony_ci SF(100, 100, x, x, x, x, x, x, x, x, x, x, x, ASTC_HDR_2D_8X5_FLT16) 368bf215546Sopenharmony_ci SF(100, 100, x, x, x, x, x, x, x, x, x, x, x, ASTC_HDR_2D_8X6_FLT16) 369bf215546Sopenharmony_ci SF(100, 100, x, x, x, x, x, x, x, x, x, x, x, ASTC_HDR_2D_8X8_FLT16) 370bf215546Sopenharmony_ci SF(100, 100, x, x, x, x, x, x, x, x, x, x, x, ASTC_HDR_2D_10X5_FLT16) 371bf215546Sopenharmony_ci SF(100, 100, x, x, x, x, x, x, x, x, x, x, x, ASTC_HDR_2D_10X6_FLT16) 372bf215546Sopenharmony_ci SF(100, 100, x, x, x, x, x, x, x, x, x, x, x, ASTC_HDR_2D_10X8_FLT16) 373bf215546Sopenharmony_ci SF(100, 100, x, x, x, x, x, x, x, x, x, x, x, ASTC_HDR_2D_10X10_FLT16) 374bf215546Sopenharmony_ci SF(100, 100, x, x, x, x, x, x, x, x, x, x, x, ASTC_HDR_2D_12X10_FLT16) 375bf215546Sopenharmony_ci SF(100, 100, x, x, x, x, x, x, x, x, x, x, x, ASTC_HDR_2D_12X12_FLT16) 376bf215546Sopenharmony_ci}; 377bf215546Sopenharmony_ci#undef x 378bf215546Sopenharmony_ci#undef Y 379bf215546Sopenharmony_ci 380bf215546Sopenharmony_ci 381bf215546Sopenharmony_cienum isl_format 382bf215546Sopenharmony_ciisl_format_for_pipe_format(enum pipe_format pf) 383bf215546Sopenharmony_ci{ 384bf215546Sopenharmony_ci static const enum isl_format table[PIPE_FORMAT_COUNT] = { 385bf215546Sopenharmony_ci [0 ... PIPE_FORMAT_COUNT-1] = ISL_FORMAT_UNSUPPORTED, 386bf215546Sopenharmony_ci 387bf215546Sopenharmony_ci [PIPE_FORMAT_B8G8R8A8_UNORM] = ISL_FORMAT_B8G8R8A8_UNORM, 388bf215546Sopenharmony_ci [PIPE_FORMAT_B8G8R8X8_UNORM] = ISL_FORMAT_B8G8R8X8_UNORM, 389bf215546Sopenharmony_ci [PIPE_FORMAT_B5G5R5A1_UNORM] = ISL_FORMAT_B5G5R5A1_UNORM, 390bf215546Sopenharmony_ci [PIPE_FORMAT_B4G4R4A4_UNORM] = ISL_FORMAT_B4G4R4A4_UNORM, 391bf215546Sopenharmony_ci [PIPE_FORMAT_B5G6R5_UNORM] = ISL_FORMAT_B5G6R5_UNORM, 392bf215546Sopenharmony_ci [PIPE_FORMAT_R10G10B10A2_UNORM] = ISL_FORMAT_R10G10B10A2_UNORM, 393bf215546Sopenharmony_ci 394bf215546Sopenharmony_ci [PIPE_FORMAT_Z16_UNORM] = ISL_FORMAT_R16_UNORM, 395bf215546Sopenharmony_ci [PIPE_FORMAT_Z32_UNORM] = ISL_FORMAT_R32_UNORM, 396bf215546Sopenharmony_ci [PIPE_FORMAT_Z32_FLOAT] = ISL_FORMAT_R32_FLOAT, 397bf215546Sopenharmony_ci 398bf215546Sopenharmony_ci /* We translate the combined depth/stencil formats to depth only here */ 399bf215546Sopenharmony_ci [PIPE_FORMAT_Z24_UNORM_S8_UINT] = ISL_FORMAT_R24_UNORM_X8_TYPELESS, 400bf215546Sopenharmony_ci [PIPE_FORMAT_Z24X8_UNORM] = ISL_FORMAT_R24_UNORM_X8_TYPELESS, 401bf215546Sopenharmony_ci [PIPE_FORMAT_Z32_FLOAT_S8X24_UINT] = ISL_FORMAT_R32_FLOAT, 402bf215546Sopenharmony_ci 403bf215546Sopenharmony_ci [PIPE_FORMAT_S8_UINT] = ISL_FORMAT_R8_UINT, 404bf215546Sopenharmony_ci [PIPE_FORMAT_X24S8_UINT] = ISL_FORMAT_R8_UINT, 405bf215546Sopenharmony_ci [PIPE_FORMAT_X32_S8X24_UINT] = ISL_FORMAT_R8_UINT, 406bf215546Sopenharmony_ci 407bf215546Sopenharmony_ci [PIPE_FORMAT_R64_FLOAT] = ISL_FORMAT_R64_FLOAT, 408bf215546Sopenharmony_ci [PIPE_FORMAT_R64G64_FLOAT] = ISL_FORMAT_R64G64_FLOAT, 409bf215546Sopenharmony_ci [PIPE_FORMAT_R64G64B64_FLOAT] = ISL_FORMAT_R64G64B64_FLOAT, 410bf215546Sopenharmony_ci [PIPE_FORMAT_R64G64B64A64_FLOAT] = ISL_FORMAT_R64G64B64A64_FLOAT, 411bf215546Sopenharmony_ci [PIPE_FORMAT_R32_FLOAT] = ISL_FORMAT_R32_FLOAT, 412bf215546Sopenharmony_ci [PIPE_FORMAT_R32G32_FLOAT] = ISL_FORMAT_R32G32_FLOAT, 413bf215546Sopenharmony_ci [PIPE_FORMAT_R32G32B32_FLOAT] = ISL_FORMAT_R32G32B32_FLOAT, 414bf215546Sopenharmony_ci [PIPE_FORMAT_R32G32B32A32_FLOAT] = ISL_FORMAT_R32G32B32A32_FLOAT, 415bf215546Sopenharmony_ci [PIPE_FORMAT_R32_UNORM] = ISL_FORMAT_R32_UNORM, 416bf215546Sopenharmony_ci [PIPE_FORMAT_R32G32_UNORM] = ISL_FORMAT_R32G32_UNORM, 417bf215546Sopenharmony_ci [PIPE_FORMAT_R32G32B32_UNORM] = ISL_FORMAT_R32G32B32_UNORM, 418bf215546Sopenharmony_ci [PIPE_FORMAT_R32G32B32A32_UNORM] = ISL_FORMAT_R32G32B32A32_UNORM, 419bf215546Sopenharmony_ci [PIPE_FORMAT_R32_USCALED] = ISL_FORMAT_R32_USCALED, 420bf215546Sopenharmony_ci [PIPE_FORMAT_R32G32_USCALED] = ISL_FORMAT_R32G32_USCALED, 421bf215546Sopenharmony_ci [PIPE_FORMAT_R32G32B32_USCALED] = ISL_FORMAT_R32G32B32_USCALED, 422bf215546Sopenharmony_ci [PIPE_FORMAT_R32G32B32A32_USCALED] = ISL_FORMAT_R32G32B32A32_USCALED, 423bf215546Sopenharmony_ci [PIPE_FORMAT_R32_SNORM] = ISL_FORMAT_R32_SNORM, 424bf215546Sopenharmony_ci [PIPE_FORMAT_R32G32_SNORM] = ISL_FORMAT_R32G32_SNORM, 425bf215546Sopenharmony_ci [PIPE_FORMAT_R32G32B32_SNORM] = ISL_FORMAT_R32G32B32_SNORM, 426bf215546Sopenharmony_ci [PIPE_FORMAT_R32G32B32A32_SNORM] = ISL_FORMAT_R32G32B32A32_SNORM, 427bf215546Sopenharmony_ci [PIPE_FORMAT_R32_SSCALED] = ISL_FORMAT_R32_SSCALED, 428bf215546Sopenharmony_ci [PIPE_FORMAT_R32G32_SSCALED] = ISL_FORMAT_R32G32_SSCALED, 429bf215546Sopenharmony_ci [PIPE_FORMAT_R32G32B32_SSCALED] = ISL_FORMAT_R32G32B32_SSCALED, 430bf215546Sopenharmony_ci [PIPE_FORMAT_R32G32B32A32_SSCALED] = ISL_FORMAT_R32G32B32A32_SSCALED, 431bf215546Sopenharmony_ci [PIPE_FORMAT_R16_UNORM] = ISL_FORMAT_R16_UNORM, 432bf215546Sopenharmony_ci [PIPE_FORMAT_R16G16_UNORM] = ISL_FORMAT_R16G16_UNORM, 433bf215546Sopenharmony_ci [PIPE_FORMAT_R16G16B16_UNORM] = ISL_FORMAT_R16G16B16_UNORM, 434bf215546Sopenharmony_ci [PIPE_FORMAT_R16G16B16A16_UNORM] = ISL_FORMAT_R16G16B16A16_UNORM, 435bf215546Sopenharmony_ci [PIPE_FORMAT_R16_USCALED] = ISL_FORMAT_R16_USCALED, 436bf215546Sopenharmony_ci [PIPE_FORMAT_R16G16_USCALED] = ISL_FORMAT_R16G16_USCALED, 437bf215546Sopenharmony_ci [PIPE_FORMAT_R16G16B16_USCALED] = ISL_FORMAT_R16G16B16_USCALED, 438bf215546Sopenharmony_ci [PIPE_FORMAT_R16G16B16A16_USCALED] = ISL_FORMAT_R16G16B16A16_USCALED, 439bf215546Sopenharmony_ci [PIPE_FORMAT_R16_SNORM] = ISL_FORMAT_R16_SNORM, 440bf215546Sopenharmony_ci [PIPE_FORMAT_R16G16_SNORM] = ISL_FORMAT_R16G16_SNORM, 441bf215546Sopenharmony_ci [PIPE_FORMAT_R16G16B16_SNORM] = ISL_FORMAT_R16G16B16_SNORM, 442bf215546Sopenharmony_ci [PIPE_FORMAT_R16G16B16A16_SNORM] = ISL_FORMAT_R16G16B16A16_SNORM, 443bf215546Sopenharmony_ci [PIPE_FORMAT_R16_SSCALED] = ISL_FORMAT_R16_SSCALED, 444bf215546Sopenharmony_ci [PIPE_FORMAT_R16G16_SSCALED] = ISL_FORMAT_R16G16_SSCALED, 445bf215546Sopenharmony_ci [PIPE_FORMAT_R16G16B16_SSCALED] = ISL_FORMAT_R16G16B16_SSCALED, 446bf215546Sopenharmony_ci [PIPE_FORMAT_R16G16B16A16_SSCALED] = ISL_FORMAT_R16G16B16A16_SSCALED, 447bf215546Sopenharmony_ci [PIPE_FORMAT_R8_UNORM] = ISL_FORMAT_R8_UNORM, 448bf215546Sopenharmony_ci [PIPE_FORMAT_R8G8_UNORM] = ISL_FORMAT_R8G8_UNORM, 449bf215546Sopenharmony_ci [PIPE_FORMAT_R8G8B8_UNORM] = ISL_FORMAT_R8G8B8_UNORM, 450bf215546Sopenharmony_ci [PIPE_FORMAT_R8G8B8A8_UNORM] = ISL_FORMAT_R8G8B8A8_UNORM, 451bf215546Sopenharmony_ci [PIPE_FORMAT_R8_USCALED] = ISL_FORMAT_R8_USCALED, 452bf215546Sopenharmony_ci [PIPE_FORMAT_R8G8_USCALED] = ISL_FORMAT_R8G8_USCALED, 453bf215546Sopenharmony_ci [PIPE_FORMAT_R8G8B8_USCALED] = ISL_FORMAT_R8G8B8_USCALED, 454bf215546Sopenharmony_ci [PIPE_FORMAT_R8G8B8A8_USCALED] = ISL_FORMAT_R8G8B8A8_USCALED, 455bf215546Sopenharmony_ci [PIPE_FORMAT_R8_SNORM] = ISL_FORMAT_R8_SNORM, 456bf215546Sopenharmony_ci [PIPE_FORMAT_R8G8_SNORM] = ISL_FORMAT_R8G8_SNORM, 457bf215546Sopenharmony_ci [PIPE_FORMAT_R8G8B8_SNORM] = ISL_FORMAT_R8G8B8_SNORM, 458bf215546Sopenharmony_ci [PIPE_FORMAT_R8G8B8A8_SNORM] = ISL_FORMAT_R8G8B8A8_SNORM, 459bf215546Sopenharmony_ci [PIPE_FORMAT_R8_SSCALED] = ISL_FORMAT_R8_SSCALED, 460bf215546Sopenharmony_ci [PIPE_FORMAT_R8G8_SSCALED] = ISL_FORMAT_R8G8_SSCALED, 461bf215546Sopenharmony_ci [PIPE_FORMAT_R8G8B8_SSCALED] = ISL_FORMAT_R8G8B8_SSCALED, 462bf215546Sopenharmony_ci [PIPE_FORMAT_R8G8B8A8_SSCALED] = ISL_FORMAT_R8G8B8A8_SSCALED, 463bf215546Sopenharmony_ci [PIPE_FORMAT_R32_FIXED] = ISL_FORMAT_R32_SFIXED, 464bf215546Sopenharmony_ci [PIPE_FORMAT_R32G32_FIXED] = ISL_FORMAT_R32G32_SFIXED, 465bf215546Sopenharmony_ci [PIPE_FORMAT_R32G32B32_FIXED] = ISL_FORMAT_R32G32B32_SFIXED, 466bf215546Sopenharmony_ci [PIPE_FORMAT_R32G32B32A32_FIXED] = ISL_FORMAT_R32G32B32A32_SFIXED, 467bf215546Sopenharmony_ci [PIPE_FORMAT_R16_FLOAT] = ISL_FORMAT_R16_FLOAT, 468bf215546Sopenharmony_ci [PIPE_FORMAT_R16G16_FLOAT] = ISL_FORMAT_R16G16_FLOAT, 469bf215546Sopenharmony_ci [PIPE_FORMAT_R16G16B16_FLOAT] = ISL_FORMAT_R16G16B16_FLOAT, 470bf215546Sopenharmony_ci [PIPE_FORMAT_R16G16B16A16_FLOAT] = ISL_FORMAT_R16G16B16A16_FLOAT, 471bf215546Sopenharmony_ci 472bf215546Sopenharmony_ci [PIPE_FORMAT_R8G8B8_SRGB] = ISL_FORMAT_R8G8B8_UNORM_SRGB, 473bf215546Sopenharmony_ci [PIPE_FORMAT_B8G8R8A8_SRGB] = ISL_FORMAT_B8G8R8A8_UNORM_SRGB, 474bf215546Sopenharmony_ci [PIPE_FORMAT_B8G8R8X8_SRGB] = ISL_FORMAT_B8G8R8X8_UNORM_SRGB, 475bf215546Sopenharmony_ci [PIPE_FORMAT_R8G8B8A8_SRGB] = ISL_FORMAT_R8G8B8A8_UNORM_SRGB, 476bf215546Sopenharmony_ci 477bf215546Sopenharmony_ci [PIPE_FORMAT_DXT1_RGB] = ISL_FORMAT_BC1_UNORM, 478bf215546Sopenharmony_ci [PIPE_FORMAT_DXT1_RGBA] = ISL_FORMAT_BC1_UNORM, 479bf215546Sopenharmony_ci [PIPE_FORMAT_DXT3_RGBA] = ISL_FORMAT_BC2_UNORM, 480bf215546Sopenharmony_ci [PIPE_FORMAT_DXT5_RGBA] = ISL_FORMAT_BC3_UNORM, 481bf215546Sopenharmony_ci 482bf215546Sopenharmony_ci [PIPE_FORMAT_DXT1_SRGB] = ISL_FORMAT_BC1_UNORM_SRGB, 483bf215546Sopenharmony_ci [PIPE_FORMAT_DXT1_SRGBA] = ISL_FORMAT_BC1_UNORM_SRGB, 484bf215546Sopenharmony_ci [PIPE_FORMAT_DXT3_SRGBA] = ISL_FORMAT_BC2_UNORM_SRGB, 485bf215546Sopenharmony_ci [PIPE_FORMAT_DXT5_SRGBA] = ISL_FORMAT_BC3_UNORM_SRGB, 486bf215546Sopenharmony_ci 487bf215546Sopenharmony_ci [PIPE_FORMAT_RGTC1_UNORM] = ISL_FORMAT_BC4_UNORM, 488bf215546Sopenharmony_ci [PIPE_FORMAT_RGTC1_SNORM] = ISL_FORMAT_BC4_SNORM, 489bf215546Sopenharmony_ci [PIPE_FORMAT_RGTC2_UNORM] = ISL_FORMAT_BC5_UNORM, 490bf215546Sopenharmony_ci [PIPE_FORMAT_RGTC2_SNORM] = ISL_FORMAT_BC5_SNORM, 491bf215546Sopenharmony_ci 492bf215546Sopenharmony_ci [PIPE_FORMAT_R10G10B10A2_USCALED] = ISL_FORMAT_R10G10B10A2_USCALED, 493bf215546Sopenharmony_ci [PIPE_FORMAT_R11G11B10_FLOAT] = ISL_FORMAT_R11G11B10_FLOAT, 494bf215546Sopenharmony_ci [PIPE_FORMAT_R9G9B9E5_FLOAT] = ISL_FORMAT_R9G9B9E5_SHAREDEXP, 495bf215546Sopenharmony_ci [PIPE_FORMAT_R1_UNORM] = ISL_FORMAT_R1_UNORM, 496bf215546Sopenharmony_ci [PIPE_FORMAT_R10G10B10X2_USCALED] = ISL_FORMAT_R10G10B10X2_USCALED, 497bf215546Sopenharmony_ci [PIPE_FORMAT_B10G10R10A2_UNORM] = ISL_FORMAT_B10G10R10A2_UNORM, 498bf215546Sopenharmony_ci [PIPE_FORMAT_R8G8B8X8_UNORM] = ISL_FORMAT_R8G8B8X8_UNORM, 499bf215546Sopenharmony_ci 500bf215546Sopenharmony_ci /* Just use red formats for these - they're actually renderable, 501bf215546Sopenharmony_ci * and faster to sample than the legacy L/I/A/LA formats. 502bf215546Sopenharmony_ci */ 503bf215546Sopenharmony_ci [PIPE_FORMAT_I8_UNORM] = ISL_FORMAT_R8_UNORM, 504bf215546Sopenharmony_ci [PIPE_FORMAT_I8_UINT] = ISL_FORMAT_R8_UINT, 505bf215546Sopenharmony_ci [PIPE_FORMAT_I8_SINT] = ISL_FORMAT_R8_SINT, 506bf215546Sopenharmony_ci [PIPE_FORMAT_I8_SNORM] = ISL_FORMAT_R8_SNORM, 507bf215546Sopenharmony_ci [PIPE_FORMAT_I16_UINT] = ISL_FORMAT_R16_UINT, 508bf215546Sopenharmony_ci [PIPE_FORMAT_I16_UNORM] = ISL_FORMAT_R16_UNORM, 509bf215546Sopenharmony_ci [PIPE_FORMAT_I16_SINT] = ISL_FORMAT_R16_SINT, 510bf215546Sopenharmony_ci [PIPE_FORMAT_I16_SNORM] = ISL_FORMAT_R16_SNORM, 511bf215546Sopenharmony_ci [PIPE_FORMAT_I16_FLOAT] = ISL_FORMAT_R16_FLOAT, 512bf215546Sopenharmony_ci [PIPE_FORMAT_I32_UINT] = ISL_FORMAT_R32_UINT, 513bf215546Sopenharmony_ci [PIPE_FORMAT_I32_SINT] = ISL_FORMAT_R32_SINT, 514bf215546Sopenharmony_ci [PIPE_FORMAT_I32_FLOAT] = ISL_FORMAT_R32_FLOAT, 515bf215546Sopenharmony_ci 516bf215546Sopenharmony_ci [PIPE_FORMAT_L8_UINT] = ISL_FORMAT_R8_UINT, 517bf215546Sopenharmony_ci [PIPE_FORMAT_L8_UNORM] = ISL_FORMAT_R8_UNORM, 518bf215546Sopenharmony_ci [PIPE_FORMAT_L8_SINT] = ISL_FORMAT_R8_SINT, 519bf215546Sopenharmony_ci [PIPE_FORMAT_L8_SNORM] = ISL_FORMAT_R8_SNORM, 520bf215546Sopenharmony_ci [PIPE_FORMAT_L16_UINT] = ISL_FORMAT_R16_UINT, 521bf215546Sopenharmony_ci [PIPE_FORMAT_L16_UNORM] = ISL_FORMAT_R16_UNORM, 522bf215546Sopenharmony_ci [PIPE_FORMAT_L16_SINT] = ISL_FORMAT_R16_SINT, 523bf215546Sopenharmony_ci [PIPE_FORMAT_L16_SNORM] = ISL_FORMAT_R16_SNORM, 524bf215546Sopenharmony_ci [PIPE_FORMAT_L16_FLOAT] = ISL_FORMAT_R16_FLOAT, 525bf215546Sopenharmony_ci [PIPE_FORMAT_L32_UINT] = ISL_FORMAT_R32_UINT, 526bf215546Sopenharmony_ci [PIPE_FORMAT_L32_SINT] = ISL_FORMAT_R32_SINT, 527bf215546Sopenharmony_ci [PIPE_FORMAT_L32_FLOAT] = ISL_FORMAT_R32_FLOAT, 528bf215546Sopenharmony_ci 529bf215546Sopenharmony_ci /* We also map alpha and luminance-alpha formats to red as well, 530bf215546Sopenharmony_ci * though most of these (other than A8_UNORM) will be non-renderable. 531bf215546Sopenharmony_ci */ 532bf215546Sopenharmony_ci [PIPE_FORMAT_A8_UINT] = ISL_FORMAT_R8_UINT, 533bf215546Sopenharmony_ci [PIPE_FORMAT_A8_UNORM] = ISL_FORMAT_R8_UNORM, 534bf215546Sopenharmony_ci [PIPE_FORMAT_A8_SINT] = ISL_FORMAT_R8_SINT, 535bf215546Sopenharmony_ci [PIPE_FORMAT_A8_SNORM] = ISL_FORMAT_R8_SNORM, 536bf215546Sopenharmony_ci [PIPE_FORMAT_A16_UINT] = ISL_FORMAT_R16_UINT, 537bf215546Sopenharmony_ci [PIPE_FORMAT_A16_UNORM] = ISL_FORMAT_R16_UNORM, 538bf215546Sopenharmony_ci [PIPE_FORMAT_A16_SINT] = ISL_FORMAT_R16_SINT, 539bf215546Sopenharmony_ci [PIPE_FORMAT_A16_SNORM] = ISL_FORMAT_R16_SNORM, 540bf215546Sopenharmony_ci [PIPE_FORMAT_A16_FLOAT] = ISL_FORMAT_R16_FLOAT, 541bf215546Sopenharmony_ci [PIPE_FORMAT_A32_UINT] = ISL_FORMAT_R32_UINT, 542bf215546Sopenharmony_ci [PIPE_FORMAT_A32_SINT] = ISL_FORMAT_R32_SINT, 543bf215546Sopenharmony_ci [PIPE_FORMAT_A32_FLOAT] = ISL_FORMAT_R32_FLOAT, 544bf215546Sopenharmony_ci 545bf215546Sopenharmony_ci [PIPE_FORMAT_L8A8_UINT] = ISL_FORMAT_R8G8_UINT, 546bf215546Sopenharmony_ci [PIPE_FORMAT_L8A8_UNORM] = ISL_FORMAT_R8G8_UNORM, 547bf215546Sopenharmony_ci [PIPE_FORMAT_L8A8_SINT] = ISL_FORMAT_R8G8_SINT, 548bf215546Sopenharmony_ci [PIPE_FORMAT_L8A8_SNORM] = ISL_FORMAT_R8G8_SNORM, 549bf215546Sopenharmony_ci [PIPE_FORMAT_L16A16_UINT] = ISL_FORMAT_R16G16_UINT, 550bf215546Sopenharmony_ci [PIPE_FORMAT_L16A16_UNORM] = ISL_FORMAT_R16G16_UNORM, 551bf215546Sopenharmony_ci [PIPE_FORMAT_L16A16_SINT] = ISL_FORMAT_R16G16_SINT, 552bf215546Sopenharmony_ci [PIPE_FORMAT_L16A16_SNORM] = ISL_FORMAT_R16G16_SNORM, 553bf215546Sopenharmony_ci [PIPE_FORMAT_L16A16_FLOAT] = ISL_FORMAT_R16G16_FLOAT, 554bf215546Sopenharmony_ci [PIPE_FORMAT_L32A32_UINT] = ISL_FORMAT_R32G32_UINT, 555bf215546Sopenharmony_ci [PIPE_FORMAT_L32A32_SINT] = ISL_FORMAT_R32G32_SINT, 556bf215546Sopenharmony_ci [PIPE_FORMAT_L32A32_FLOAT] = ISL_FORMAT_R32G32_FLOAT, 557bf215546Sopenharmony_ci 558bf215546Sopenharmony_ci /* Sadly, we have to use luminance[-alpha] formats for sRGB decoding. */ 559bf215546Sopenharmony_ci [PIPE_FORMAT_R8_SRGB] = ISL_FORMAT_L8_UNORM_SRGB, 560bf215546Sopenharmony_ci [PIPE_FORMAT_L8_SRGB] = ISL_FORMAT_L8_UNORM_SRGB, 561bf215546Sopenharmony_ci [PIPE_FORMAT_L8A8_SRGB] = ISL_FORMAT_L8A8_UNORM_SRGB, 562bf215546Sopenharmony_ci 563bf215546Sopenharmony_ci [PIPE_FORMAT_R10G10B10A2_SSCALED] = ISL_FORMAT_R10G10B10A2_SSCALED, 564bf215546Sopenharmony_ci [PIPE_FORMAT_R10G10B10A2_SNORM] = ISL_FORMAT_R10G10B10A2_SNORM, 565bf215546Sopenharmony_ci 566bf215546Sopenharmony_ci [PIPE_FORMAT_B10G10R10A2_USCALED] = ISL_FORMAT_B10G10R10A2_USCALED, 567bf215546Sopenharmony_ci [PIPE_FORMAT_B10G10R10A2_SSCALED] = ISL_FORMAT_B10G10R10A2_SSCALED, 568bf215546Sopenharmony_ci [PIPE_FORMAT_B10G10R10A2_SNORM] = ISL_FORMAT_B10G10R10A2_SNORM, 569bf215546Sopenharmony_ci 570bf215546Sopenharmony_ci [PIPE_FORMAT_R8_UINT] = ISL_FORMAT_R8_UINT, 571bf215546Sopenharmony_ci [PIPE_FORMAT_R8G8_UINT] = ISL_FORMAT_R8G8_UINT, 572bf215546Sopenharmony_ci [PIPE_FORMAT_R8G8B8_UINT] = ISL_FORMAT_R8G8B8_UINT, 573bf215546Sopenharmony_ci [PIPE_FORMAT_R8G8B8A8_UINT] = ISL_FORMAT_R8G8B8A8_UINT, 574bf215546Sopenharmony_ci 575bf215546Sopenharmony_ci [PIPE_FORMAT_R8_SINT] = ISL_FORMAT_R8_SINT, 576bf215546Sopenharmony_ci [PIPE_FORMAT_R8G8_SINT] = ISL_FORMAT_R8G8_SINT, 577bf215546Sopenharmony_ci [PIPE_FORMAT_R8G8B8_SINT] = ISL_FORMAT_R8G8B8_SINT, 578bf215546Sopenharmony_ci [PIPE_FORMAT_R8G8B8A8_SINT] = ISL_FORMAT_R8G8B8A8_SINT, 579bf215546Sopenharmony_ci 580bf215546Sopenharmony_ci [PIPE_FORMAT_R16_UINT] = ISL_FORMAT_R16_UINT, 581bf215546Sopenharmony_ci [PIPE_FORMAT_R16G16_UINT] = ISL_FORMAT_R16G16_UINT, 582bf215546Sopenharmony_ci [PIPE_FORMAT_R16G16B16_UINT] = ISL_FORMAT_R16G16B16_UINT, 583bf215546Sopenharmony_ci [PIPE_FORMAT_R16G16B16A16_UINT] = ISL_FORMAT_R16G16B16A16_UINT, 584bf215546Sopenharmony_ci 585bf215546Sopenharmony_ci [PIPE_FORMAT_R16_SINT] = ISL_FORMAT_R16_SINT, 586bf215546Sopenharmony_ci [PIPE_FORMAT_R16G16_SINT] = ISL_FORMAT_R16G16_SINT, 587bf215546Sopenharmony_ci [PIPE_FORMAT_R16G16B16_SINT] = ISL_FORMAT_R16G16B16_SINT, 588bf215546Sopenharmony_ci [PIPE_FORMAT_R16G16B16A16_SINT] = ISL_FORMAT_R16G16B16A16_SINT, 589bf215546Sopenharmony_ci 590bf215546Sopenharmony_ci [PIPE_FORMAT_R32_UINT] = ISL_FORMAT_R32_UINT, 591bf215546Sopenharmony_ci [PIPE_FORMAT_R32G32_UINT] = ISL_FORMAT_R32G32_UINT, 592bf215546Sopenharmony_ci [PIPE_FORMAT_R32G32B32_UINT] = ISL_FORMAT_R32G32B32_UINT, 593bf215546Sopenharmony_ci [PIPE_FORMAT_R32G32B32A32_UINT] = ISL_FORMAT_R32G32B32A32_UINT, 594bf215546Sopenharmony_ci 595bf215546Sopenharmony_ci [PIPE_FORMAT_R32_SINT] = ISL_FORMAT_R32_SINT, 596bf215546Sopenharmony_ci [PIPE_FORMAT_R32G32_SINT] = ISL_FORMAT_R32G32_SINT, 597bf215546Sopenharmony_ci [PIPE_FORMAT_R32G32B32_SINT] = ISL_FORMAT_R32G32B32_SINT, 598bf215546Sopenharmony_ci [PIPE_FORMAT_R32G32B32A32_SINT] = ISL_FORMAT_R32G32B32A32_SINT, 599bf215546Sopenharmony_ci 600bf215546Sopenharmony_ci [PIPE_FORMAT_B10G10R10A2_UINT] = ISL_FORMAT_B10G10R10A2_UINT, 601bf215546Sopenharmony_ci 602bf215546Sopenharmony_ci [PIPE_FORMAT_ETC1_RGB8] = ISL_FORMAT_ETC1_RGB8, 603bf215546Sopenharmony_ci 604bf215546Sopenharmony_ci /* The formats say YCrCb, but there's no colorspace conversion. */ 605bf215546Sopenharmony_ci [PIPE_FORMAT_R8G8_R8B8_UNORM] = ISL_FORMAT_YCRCB_NORMAL, 606bf215546Sopenharmony_ci [PIPE_FORMAT_G8R8_B8R8_UNORM] = ISL_FORMAT_YCRCB_SWAPY, 607bf215546Sopenharmony_ci 608bf215546Sopenharmony_ci /* We map these formats to help configure media compression. */ 609bf215546Sopenharmony_ci [PIPE_FORMAT_YUYV] = ISL_FORMAT_YCRCB_NORMAL, 610bf215546Sopenharmony_ci [PIPE_FORMAT_UYVY] = ISL_FORMAT_YCRCB_SWAPY, 611bf215546Sopenharmony_ci [PIPE_FORMAT_NV12] = ISL_FORMAT_PLANAR_420_8, 612bf215546Sopenharmony_ci [PIPE_FORMAT_P010] = ISL_FORMAT_PLANAR_420_10, 613bf215546Sopenharmony_ci [PIPE_FORMAT_P012] = ISL_FORMAT_PLANAR_420_12, 614bf215546Sopenharmony_ci [PIPE_FORMAT_P016] = ISL_FORMAT_PLANAR_420_16, 615bf215546Sopenharmony_ci 616bf215546Sopenharmony_ci [PIPE_FORMAT_R8G8B8X8_SRGB] = ISL_FORMAT_R8G8B8X8_UNORM_SRGB, 617bf215546Sopenharmony_ci [PIPE_FORMAT_B10G10R10X2_UNORM] = ISL_FORMAT_B10G10R10X2_UNORM, 618bf215546Sopenharmony_ci [PIPE_FORMAT_R16G16B16X16_UNORM] = ISL_FORMAT_R16G16B16X16_UNORM, 619bf215546Sopenharmony_ci [PIPE_FORMAT_R16G16B16X16_FLOAT] = ISL_FORMAT_R16G16B16X16_FLOAT, 620bf215546Sopenharmony_ci [PIPE_FORMAT_R32G32B32X32_FLOAT] = ISL_FORMAT_R32G32B32X32_FLOAT, 621bf215546Sopenharmony_ci 622bf215546Sopenharmony_ci [PIPE_FORMAT_R10G10B10A2_UINT] = ISL_FORMAT_R10G10B10A2_UINT, 623bf215546Sopenharmony_ci 624bf215546Sopenharmony_ci [PIPE_FORMAT_B5G6R5_SRGB] = ISL_FORMAT_B5G6R5_UNORM_SRGB, 625bf215546Sopenharmony_ci 626bf215546Sopenharmony_ci [PIPE_FORMAT_BPTC_RGBA_UNORM] = ISL_FORMAT_BC7_UNORM, 627bf215546Sopenharmony_ci [PIPE_FORMAT_BPTC_SRGBA] = ISL_FORMAT_BC7_UNORM_SRGB, 628bf215546Sopenharmony_ci [PIPE_FORMAT_BPTC_RGB_FLOAT] = ISL_FORMAT_BC6H_SF16, 629bf215546Sopenharmony_ci [PIPE_FORMAT_BPTC_RGB_UFLOAT] = ISL_FORMAT_BC6H_UF16, 630bf215546Sopenharmony_ci 631bf215546Sopenharmony_ci [PIPE_FORMAT_ETC2_RGB8] = ISL_FORMAT_ETC2_RGB8, 632bf215546Sopenharmony_ci [PIPE_FORMAT_ETC2_SRGB8] = ISL_FORMAT_ETC2_SRGB8, 633bf215546Sopenharmony_ci [PIPE_FORMAT_ETC2_RGB8A1] = ISL_FORMAT_ETC2_RGB8_PTA, 634bf215546Sopenharmony_ci [PIPE_FORMAT_ETC2_SRGB8A1] = ISL_FORMAT_ETC2_SRGB8_PTA, 635bf215546Sopenharmony_ci [PIPE_FORMAT_ETC2_RGBA8] = ISL_FORMAT_ETC2_EAC_RGBA8, 636bf215546Sopenharmony_ci [PIPE_FORMAT_ETC2_SRGBA8] = ISL_FORMAT_ETC2_EAC_SRGB8_A8, 637bf215546Sopenharmony_ci [PIPE_FORMAT_ETC2_R11_UNORM] = ISL_FORMAT_EAC_R11, 638bf215546Sopenharmony_ci [PIPE_FORMAT_ETC2_R11_SNORM] = ISL_FORMAT_EAC_SIGNED_R11, 639bf215546Sopenharmony_ci [PIPE_FORMAT_ETC2_RG11_UNORM] = ISL_FORMAT_EAC_RG11, 640bf215546Sopenharmony_ci [PIPE_FORMAT_ETC2_RG11_SNORM] = ISL_FORMAT_EAC_SIGNED_RG11, 641bf215546Sopenharmony_ci 642bf215546Sopenharmony_ci [PIPE_FORMAT_FXT1_RGB] = ISL_FORMAT_FXT1, 643bf215546Sopenharmony_ci [PIPE_FORMAT_FXT1_RGBA] = ISL_FORMAT_FXT1, 644bf215546Sopenharmony_ci 645bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_4x4] = ISL_FORMAT_ASTC_LDR_2D_4X4_FLT16, 646bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_5x4] = ISL_FORMAT_ASTC_LDR_2D_5X4_FLT16, 647bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_5x5] = ISL_FORMAT_ASTC_LDR_2D_5X5_FLT16, 648bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_6x5] = ISL_FORMAT_ASTC_LDR_2D_6X5_FLT16, 649bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_6x6] = ISL_FORMAT_ASTC_LDR_2D_6X6_FLT16, 650bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_8x5] = ISL_FORMAT_ASTC_LDR_2D_8X5_FLT16, 651bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_8x6] = ISL_FORMAT_ASTC_LDR_2D_8X6_FLT16, 652bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_8x8] = ISL_FORMAT_ASTC_LDR_2D_8X8_FLT16, 653bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_10x5] = ISL_FORMAT_ASTC_LDR_2D_10X5_FLT16, 654bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_10x6] = ISL_FORMAT_ASTC_LDR_2D_10X6_FLT16, 655bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_10x8] = ISL_FORMAT_ASTC_LDR_2D_10X8_FLT16, 656bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_10x10] = ISL_FORMAT_ASTC_LDR_2D_10X10_FLT16, 657bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_12x10] = ISL_FORMAT_ASTC_LDR_2D_12X10_FLT16, 658bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_12x12] = ISL_FORMAT_ASTC_LDR_2D_12X12_FLT16, 659bf215546Sopenharmony_ci 660bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_4x4_SRGB] = ISL_FORMAT_ASTC_LDR_2D_4X4_U8SRGB, 661bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_5x4_SRGB] = ISL_FORMAT_ASTC_LDR_2D_5X4_U8SRGB, 662bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_5x5_SRGB] = ISL_FORMAT_ASTC_LDR_2D_5X5_U8SRGB, 663bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_6x5_SRGB] = ISL_FORMAT_ASTC_LDR_2D_6X5_U8SRGB, 664bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_6x6_SRGB] = ISL_FORMAT_ASTC_LDR_2D_6X6_U8SRGB, 665bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_8x5_SRGB] = ISL_FORMAT_ASTC_LDR_2D_8X5_U8SRGB, 666bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_8x6_SRGB] = ISL_FORMAT_ASTC_LDR_2D_8X6_U8SRGB, 667bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_8x8_SRGB] = ISL_FORMAT_ASTC_LDR_2D_8X8_U8SRGB, 668bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_10x5_SRGB] = ISL_FORMAT_ASTC_LDR_2D_10X5_U8SRGB, 669bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_10x6_SRGB] = ISL_FORMAT_ASTC_LDR_2D_10X6_U8SRGB, 670bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_10x8_SRGB] = ISL_FORMAT_ASTC_LDR_2D_10X8_U8SRGB, 671bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_10x10_SRGB] = ISL_FORMAT_ASTC_LDR_2D_10X10_U8SRGB, 672bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_12x10_SRGB] = ISL_FORMAT_ASTC_LDR_2D_12X10_U8SRGB, 673bf215546Sopenharmony_ci [PIPE_FORMAT_ASTC_12x12_SRGB] = ISL_FORMAT_ASTC_LDR_2D_12X12_U8SRGB, 674bf215546Sopenharmony_ci 675bf215546Sopenharmony_ci [PIPE_FORMAT_A1B5G5R5_UNORM] = ISL_FORMAT_A1B5G5R5_UNORM, 676bf215546Sopenharmony_ci 677bf215546Sopenharmony_ci /* We support these so that we know the API expects no alpha channel. 678bf215546Sopenharmony_ci * Otherwise, the state tracker would just give us a format with alpha 679bf215546Sopenharmony_ci * and we wouldn't know to override the swizzle to 1. 680bf215546Sopenharmony_ci */ 681bf215546Sopenharmony_ci [PIPE_FORMAT_R16G16B16X16_UINT] = ISL_FORMAT_R16G16B16A16_UINT, 682bf215546Sopenharmony_ci [PIPE_FORMAT_R16G16B16X16_SINT] = ISL_FORMAT_R16G16B16A16_SINT, 683bf215546Sopenharmony_ci [PIPE_FORMAT_R32G32B32X32_UINT] = ISL_FORMAT_R32G32B32A32_UINT, 684bf215546Sopenharmony_ci [PIPE_FORMAT_R32G32B32X32_SINT] = ISL_FORMAT_R32G32B32A32_SINT, 685bf215546Sopenharmony_ci [PIPE_FORMAT_R10G10B10X2_SNORM] = ISL_FORMAT_R10G10B10A2_SNORM, 686bf215546Sopenharmony_ci }; 687bf215546Sopenharmony_ci assert(pf < PIPE_FORMAT_COUNT); 688bf215546Sopenharmony_ci return table[pf]; 689bf215546Sopenharmony_ci} 690bf215546Sopenharmony_ci 691bf215546Sopenharmony_cistatic bool 692bf215546Sopenharmony_ciformat_info_exists(enum isl_format format) 693bf215546Sopenharmony_ci{ 694bf215546Sopenharmony_ci assert(format != ISL_FORMAT_UNSUPPORTED); 695bf215546Sopenharmony_ci assert(format < ISL_NUM_FORMATS); 696bf215546Sopenharmony_ci return format < ARRAY_SIZE(format_info) && format_info[format].exists; 697bf215546Sopenharmony_ci} 698bf215546Sopenharmony_ci 699bf215546Sopenharmony_cibool 700bf215546Sopenharmony_ciisl_format_supports_rendering(const struct intel_device_info *devinfo, 701bf215546Sopenharmony_ci enum isl_format format) 702bf215546Sopenharmony_ci{ 703bf215546Sopenharmony_ci if (!format_info_exists(format)) 704bf215546Sopenharmony_ci return false; 705bf215546Sopenharmony_ci 706bf215546Sopenharmony_ci return devinfo->verx10 >= format_info[format].render_target; 707bf215546Sopenharmony_ci} 708bf215546Sopenharmony_ci 709bf215546Sopenharmony_cibool 710bf215546Sopenharmony_ciisl_format_supports_alpha_blending(const struct intel_device_info *devinfo, 711bf215546Sopenharmony_ci enum isl_format format) 712bf215546Sopenharmony_ci{ 713bf215546Sopenharmony_ci if (!format_info_exists(format)) 714bf215546Sopenharmony_ci return false; 715bf215546Sopenharmony_ci 716bf215546Sopenharmony_ci return devinfo->verx10 >= format_info[format].alpha_blend; 717bf215546Sopenharmony_ci} 718bf215546Sopenharmony_ci 719bf215546Sopenharmony_cibool 720bf215546Sopenharmony_ciisl_format_supports_sampling(const struct intel_device_info *devinfo, 721bf215546Sopenharmony_ci enum isl_format format) 722bf215546Sopenharmony_ci{ 723bf215546Sopenharmony_ci if (!format_info_exists(format)) 724bf215546Sopenharmony_ci return false; 725bf215546Sopenharmony_ci 726bf215546Sopenharmony_ci if (devinfo->platform == INTEL_PLATFORM_BYT) { 727bf215546Sopenharmony_ci const struct isl_format_layout *fmtl = isl_format_get_layout(format); 728bf215546Sopenharmony_ci /* Support for ETC1 and ETC2 exists on Bay Trail even though big-core 729bf215546Sopenharmony_ci * GPUs didn't get it until Broadwell. 730bf215546Sopenharmony_ci */ 731bf215546Sopenharmony_ci if (fmtl->txc == ISL_TXC_ETC1 || fmtl->txc == ISL_TXC_ETC2) 732bf215546Sopenharmony_ci return true; 733bf215546Sopenharmony_ci } else if (devinfo->platform == INTEL_PLATFORM_CHV) { 734bf215546Sopenharmony_ci /* Support for ASTC LDR theoretically exists on Cherry View even though 735bf215546Sopenharmony_ci * big-core GPUs didn't get it until Skylake. However, it's fairly 736bf215546Sopenharmony_ci * badly broken and requires some nasty workarounds which no Mesa driver 737bf215546Sopenharmony_ci * has ever implemented. 738bf215546Sopenharmony_ci */ 739bf215546Sopenharmony_ci } else if (intel_device_info_is_9lp(devinfo)) { 740bf215546Sopenharmony_ci const struct isl_format_layout *fmtl = isl_format_get_layout(format); 741bf215546Sopenharmony_ci /* Support for ASTC HDR exists on Broxton even though big-core 742bf215546Sopenharmony_ci * GPUs didn't get it until Cannonlake. 743bf215546Sopenharmony_ci */ 744bf215546Sopenharmony_ci if (fmtl->txc == ISL_TXC_ASTC) 745bf215546Sopenharmony_ci return true; 746bf215546Sopenharmony_ci } else if (devinfo->verx10 >= 125) { 747bf215546Sopenharmony_ci const struct isl_format_layout *fmtl = isl_format_get_layout(format); 748bf215546Sopenharmony_ci /* ASTC & FXT1 support was removed from the hardware on Gfx12.5. 749bf215546Sopenharmony_ci * Annoyingly, our format_info table doesn't have a concept of things 750bf215546Sopenharmony_ci * being removed so we handle it as yet another special case. 751bf215546Sopenharmony_ci * 752bf215546Sopenharmony_ci * See HSD 1408144932 (ASTC), 1407633611 (FXT1) 753bf215546Sopenharmony_ci * 754bf215546Sopenharmony_ci */ 755bf215546Sopenharmony_ci if (fmtl->txc == ISL_TXC_ASTC || fmtl->txc == ISL_TXC_FXT1) 756bf215546Sopenharmony_ci return false; 757bf215546Sopenharmony_ci } 758bf215546Sopenharmony_ci 759bf215546Sopenharmony_ci return devinfo->verx10 >= format_info[format].sampling; 760bf215546Sopenharmony_ci} 761bf215546Sopenharmony_ci 762bf215546Sopenharmony_cibool 763bf215546Sopenharmony_ciisl_format_supports_filtering(const struct intel_device_info *devinfo, 764bf215546Sopenharmony_ci enum isl_format format) 765bf215546Sopenharmony_ci{ 766bf215546Sopenharmony_ci if (!format_info_exists(format)) 767bf215546Sopenharmony_ci return false; 768bf215546Sopenharmony_ci 769bf215546Sopenharmony_ci if (isl_format_is_compressed(format)) { 770bf215546Sopenharmony_ci assert(format_info[format].filtering == format_info[format].sampling); 771bf215546Sopenharmony_ci return isl_format_supports_sampling(devinfo, format); 772bf215546Sopenharmony_ci } 773bf215546Sopenharmony_ci 774bf215546Sopenharmony_ci return devinfo->verx10 >= format_info[format].filtering; 775bf215546Sopenharmony_ci} 776bf215546Sopenharmony_ci 777bf215546Sopenharmony_cibool 778bf215546Sopenharmony_ciisl_format_supports_vertex_fetch(const struct intel_device_info *devinfo, 779bf215546Sopenharmony_ci enum isl_format format) 780bf215546Sopenharmony_ci{ 781bf215546Sopenharmony_ci if (!format_info_exists(format)) 782bf215546Sopenharmony_ci return false; 783bf215546Sopenharmony_ci 784bf215546Sopenharmony_ci /* For vertex fetch, Bay Trail supports the same set of formats as Haswell 785bf215546Sopenharmony_ci * but is a superset of Ivy Bridge. 786bf215546Sopenharmony_ci */ 787bf215546Sopenharmony_ci if (devinfo->platform == INTEL_PLATFORM_BYT) 788bf215546Sopenharmony_ci return 75 >= format_info[format].input_vb; 789bf215546Sopenharmony_ci 790bf215546Sopenharmony_ci return devinfo->verx10 >= format_info[format].input_vb; 791bf215546Sopenharmony_ci} 792bf215546Sopenharmony_ci 793bf215546Sopenharmony_ci/** 794bf215546Sopenharmony_ci * Returns true if the given format can support typed writes. 795bf215546Sopenharmony_ci */ 796bf215546Sopenharmony_cibool 797bf215546Sopenharmony_ciisl_format_supports_typed_writes(const struct intel_device_info *devinfo, 798bf215546Sopenharmony_ci enum isl_format format) 799bf215546Sopenharmony_ci{ 800bf215546Sopenharmony_ci if (!format_info_exists(format)) 801bf215546Sopenharmony_ci return false; 802bf215546Sopenharmony_ci 803bf215546Sopenharmony_ci return devinfo->verx10 >= format_info[format].typed_write; 804bf215546Sopenharmony_ci} 805bf215546Sopenharmony_ci 806bf215546Sopenharmony_ci/** 807bf215546Sopenharmony_ci * Returns true if the given format can support typed atomics. 808bf215546Sopenharmony_ci */ 809bf215546Sopenharmony_cibool 810bf215546Sopenharmony_ciisl_format_supports_typed_atomics(const struct intel_device_info *devinfo, 811bf215546Sopenharmony_ci enum isl_format format) 812bf215546Sopenharmony_ci{ 813bf215546Sopenharmony_ci if (!format_info_exists(format)) 814bf215546Sopenharmony_ci return false; 815bf215546Sopenharmony_ci 816bf215546Sopenharmony_ci return devinfo->verx10 >= format_info[format].typed_atomics; 817bf215546Sopenharmony_ci} 818bf215546Sopenharmony_ci 819bf215546Sopenharmony_ci/** 820bf215546Sopenharmony_ci * Returns true if the given format can support typed reads with format 821bf215546Sopenharmony_ci * conversion fully handled by hardware. On Sky Lake, all formats which are 822bf215546Sopenharmony_ci * supported for typed writes also support typed reads but some of them return 823bf215546Sopenharmony_ci * the raw image data and don't provide format conversion. 824bf215546Sopenharmony_ci * 825bf215546Sopenharmony_ci * For anyone looking to find this data in the PRM, the easiest way to find 826bf215546Sopenharmony_ci * format tables is to search for R11G11B10. There are only a few 827bf215546Sopenharmony_ci * occurrences. 828bf215546Sopenharmony_ci */ 829bf215546Sopenharmony_cibool 830bf215546Sopenharmony_ciisl_format_supports_typed_reads(const struct intel_device_info *devinfo, 831bf215546Sopenharmony_ci enum isl_format format) 832bf215546Sopenharmony_ci{ 833bf215546Sopenharmony_ci if (!format_info_exists(format)) 834bf215546Sopenharmony_ci return false; 835bf215546Sopenharmony_ci 836bf215546Sopenharmony_ci return devinfo->verx10 >= format_info[format].typed_read; 837bf215546Sopenharmony_ci} 838bf215546Sopenharmony_ci 839bf215546Sopenharmony_ci/** 840bf215546Sopenharmony_ci * Returns true if the given format can support single-sample fast clears. 841bf215546Sopenharmony_ci * This function only checks the format. In order to determine if a surface 842bf215546Sopenharmony_ci * supports CCS_E, several other factors need to be considered such as tiling 843bf215546Sopenharmony_ci * and sample count. See isl_surf_get_ccs_surf for details. 844bf215546Sopenharmony_ci */ 845bf215546Sopenharmony_cibool 846bf215546Sopenharmony_ciisl_format_supports_ccs_d(const struct intel_device_info *devinfo, 847bf215546Sopenharmony_ci enum isl_format format) 848bf215546Sopenharmony_ci{ 849bf215546Sopenharmony_ci /* Clear-only compression was first added on Ivy Bridge and was last 850bf215546Sopenharmony_ci * implemented on Ice lake (see BSpec: 43862). 851bf215546Sopenharmony_ci */ 852bf215546Sopenharmony_ci if (devinfo->ver < 7 || devinfo->ver > 11) 853bf215546Sopenharmony_ci return false; 854bf215546Sopenharmony_ci 855bf215546Sopenharmony_ci if (!isl_format_supports_rendering(devinfo, format)) 856bf215546Sopenharmony_ci return false; 857bf215546Sopenharmony_ci 858bf215546Sopenharmony_ci const struct isl_format_layout *fmtl = isl_format_get_layout(format); 859bf215546Sopenharmony_ci 860bf215546Sopenharmony_ci /* From the Ivy Bridge PRM, Vol2 Part1 11.7 "MCS Buffer for Render 861bf215546Sopenharmony_ci * Target(s)", beneath the "Fast Color Clear" bullet (p326): 862bf215546Sopenharmony_ci * 863bf215546Sopenharmony_ci * - MCS buffer for non-MSRT is supported only for RT formats 32bpp, 864bf215546Sopenharmony_ci * 64bpp, and 128bpp. 865bf215546Sopenharmony_ci */ 866bf215546Sopenharmony_ci return fmtl->bpb == 32 || fmtl->bpb == 64 || fmtl->bpb == 128; 867bf215546Sopenharmony_ci} 868bf215546Sopenharmony_ci 869bf215546Sopenharmony_ci/** 870bf215546Sopenharmony_ci * Returns true if the given format can support single-sample color 871bf215546Sopenharmony_ci * compression. This function only checks the format. In order to determine 872bf215546Sopenharmony_ci * if a surface supports CCS_E, several other factors need to be considered 873bf215546Sopenharmony_ci * such as tiling and sample count. See isl_surf_get_ccs_surf for details. 874bf215546Sopenharmony_ci */ 875bf215546Sopenharmony_cibool 876bf215546Sopenharmony_ciisl_format_supports_ccs_e(const struct intel_device_info *devinfo, 877bf215546Sopenharmony_ci enum isl_format format) 878bf215546Sopenharmony_ci{ 879bf215546Sopenharmony_ci /* Wa_22011186057: Disable compression on ADL-P A0 */ 880bf215546Sopenharmony_ci if (devinfo->platform == INTEL_PLATFORM_ADL && devinfo->gt == 2 && devinfo->revision == 0) 881bf215546Sopenharmony_ci return false; 882bf215546Sopenharmony_ci 883bf215546Sopenharmony_ci if (!format_info_exists(format)) 884bf215546Sopenharmony_ci return false; 885bf215546Sopenharmony_ci 886bf215546Sopenharmony_ci /* For simplicity, only report that a format supports CCS_E if blorp can 887bf215546Sopenharmony_ci * perform bit-for-bit copies with an image of that format while compressed. 888bf215546Sopenharmony_ci * Unfortunately, R11G11B10_FLOAT is in a compression class of its own and 889bf215546Sopenharmony_ci * there is no way to copy to/from it which doesn't potentially loose data 890bf215546Sopenharmony_ci * if one of the bit patterns being copied isn't valid finite floats. 891bf215546Sopenharmony_ci */ 892bf215546Sopenharmony_ci if (format == ISL_FORMAT_R11G11B10_FLOAT) 893bf215546Sopenharmony_ci return false; 894bf215546Sopenharmony_ci 895bf215546Sopenharmony_ci return devinfo->verx10 >= format_info[format].ccs_e; 896bf215546Sopenharmony_ci} 897bf215546Sopenharmony_ci 898bf215546Sopenharmony_cibool 899bf215546Sopenharmony_ciisl_format_supports_multisampling(const struct intel_device_info *devinfo, 900bf215546Sopenharmony_ci enum isl_format format) 901bf215546Sopenharmony_ci{ 902bf215546Sopenharmony_ci /* From the Sandybridge PRM, Volume 4 Part 1 p72, SURFACE_STATE, Surface 903bf215546Sopenharmony_ci * Format: 904bf215546Sopenharmony_ci * 905bf215546Sopenharmony_ci * If Number of Multisamples is set to a value other than 906bf215546Sopenharmony_ci * MULTISAMPLECOUNT_1, this field cannot be set to the following 907bf215546Sopenharmony_ci * formats: 908bf215546Sopenharmony_ci * 909bf215546Sopenharmony_ci * - any format with greater than 64 bits per element 910bf215546Sopenharmony_ci * - any compressed texture format (BC*) 911bf215546Sopenharmony_ci * - any YCRCB* format 912bf215546Sopenharmony_ci * 913bf215546Sopenharmony_ci * The restriction on the format's size is removed on Broadwell. Moreover, 914bf215546Sopenharmony_ci * empirically it looks that even IvyBridge can handle multisampled surfaces 915bf215546Sopenharmony_ci * with format sizes all the way to 128-bits (RGBA32F, RGBA32I, RGBA32UI). 916bf215546Sopenharmony_ci * 917bf215546Sopenharmony_ci * Also, there is an exception for HiZ which we treat as a compressed 918bf215546Sopenharmony_ci * format and is allowed to be multisampled on Broadwell and earlier. 919bf215546Sopenharmony_ci */ 920bf215546Sopenharmony_ci if (format == ISL_FORMAT_HIZ) { 921bf215546Sopenharmony_ci /* On SKL+, HiZ is always single-sampled even when the primary surface 922bf215546Sopenharmony_ci * is multisampled. See also isl_surf_get_hiz_surf(). 923bf215546Sopenharmony_ci */ 924bf215546Sopenharmony_ci return devinfo->ver <= 8; 925bf215546Sopenharmony_ci } else if (devinfo->ver == 7 && isl_format_has_sint_channel(format)) { 926bf215546Sopenharmony_ci /* From the Ivy Bridge PRM, Vol4 Part1 p73 ("Number of Multisamples"): 927bf215546Sopenharmony_ci * 928bf215546Sopenharmony_ci * This field must be set to MULTISAMPLECOUNT_1 for SINT MSRTs when 929bf215546Sopenharmony_ci * all RT channels are not written 930bf215546Sopenharmony_ci * 931bf215546Sopenharmony_ci * From the Ivy Bridge PRM, Vol4 Part1 p77 ("MCS Enable"): 932bf215546Sopenharmony_ci * 933bf215546Sopenharmony_ci * This field must be set to 0 for all SINT MSRTs when all RT channels 934bf215546Sopenharmony_ci * are not written 935bf215546Sopenharmony_ci * 936bf215546Sopenharmony_ci * Disable multisampling support now as we don't handle the case when 937bf215546Sopenharmony_ci * one of the render target channels is disabled. 938bf215546Sopenharmony_ci */ 939bf215546Sopenharmony_ci return false; 940bf215546Sopenharmony_ci } else if (devinfo->ver < 7 && isl_format_get_layout(format)->bpb > 64) { 941bf215546Sopenharmony_ci return false; 942bf215546Sopenharmony_ci } else if (isl_format_is_compressed(format)) { 943bf215546Sopenharmony_ci return false; 944bf215546Sopenharmony_ci } else if (isl_format_is_yuv(format)) { 945bf215546Sopenharmony_ci return false; 946bf215546Sopenharmony_ci } else { 947bf215546Sopenharmony_ci return true; 948bf215546Sopenharmony_ci } 949bf215546Sopenharmony_ci} 950bf215546Sopenharmony_ci 951bf215546Sopenharmony_ci/** 952bf215546Sopenharmony_ci * Returns true if the two formats are component size compatible meaning that 953bf215546Sopenharmony_ci * each component from one format has the same number of bits as the other 954bf215546Sopenharmony_ci * format. 955bf215546Sopenharmony_ci * 956bf215546Sopenharmony_ci * This is useful to check whether an image used with 2 different formats can 957bf215546Sopenharmony_ci * be fast cleared with a non 0 clear color. 958bf215546Sopenharmony_ci */ 959bf215546Sopenharmony_cibool 960bf215546Sopenharmony_ciisl_formats_have_same_bits_per_channel(enum isl_format format1, 961bf215546Sopenharmony_ci enum isl_format format2) 962bf215546Sopenharmony_ci{ 963bf215546Sopenharmony_ci const struct isl_format_layout *fmtl1 = isl_format_get_layout(format1); 964bf215546Sopenharmony_ci const struct isl_format_layout *fmtl2 = isl_format_get_layout(format2); 965bf215546Sopenharmony_ci 966bf215546Sopenharmony_ci return fmtl1->channels.r.bits == fmtl2->channels.r.bits && 967bf215546Sopenharmony_ci fmtl1->channels.g.bits == fmtl2->channels.g.bits && 968bf215546Sopenharmony_ci fmtl1->channels.b.bits == fmtl2->channels.b.bits && 969bf215546Sopenharmony_ci fmtl1->channels.a.bits == fmtl2->channels.a.bits; 970bf215546Sopenharmony_ci} 971bf215546Sopenharmony_ci 972bf215546Sopenharmony_ci/** 973bf215546Sopenharmony_ci * Returns true if the two formats are "CCS_E compatible" meaning that you can 974bf215546Sopenharmony_ci * render in one format with CCS_E enabled and then texture using the other 975bf215546Sopenharmony_ci * format without needing a resolve. 976bf215546Sopenharmony_ci * 977bf215546Sopenharmony_ci * Note: Even if the formats are compatible, special care must be taken if a 978bf215546Sopenharmony_ci * clear color is involved because the encoding of the clear color is heavily 979bf215546Sopenharmony_ci * format-dependent. 980bf215546Sopenharmony_ci */ 981bf215546Sopenharmony_cibool 982bf215546Sopenharmony_ciisl_formats_are_ccs_e_compatible(const struct intel_device_info *devinfo, 983bf215546Sopenharmony_ci enum isl_format format1, 984bf215546Sopenharmony_ci enum isl_format format2) 985bf215546Sopenharmony_ci{ 986bf215546Sopenharmony_ci /* They must support CCS_E */ 987bf215546Sopenharmony_ci if (!isl_format_supports_ccs_e(devinfo, format1) || 988bf215546Sopenharmony_ci !isl_format_supports_ccs_e(devinfo, format2)) 989bf215546Sopenharmony_ci return false; 990bf215546Sopenharmony_ci 991bf215546Sopenharmony_ci /* Gfx12 added CCS_E support for A8_UNORM, A8_UNORM and R8_UNORM share the 992bf215546Sopenharmony_ci * same aux map format encoding so they are definitely compatible. 993bf215546Sopenharmony_ci */ 994bf215546Sopenharmony_ci if (format1 == ISL_FORMAT_A8_UNORM) 995bf215546Sopenharmony_ci format1 = ISL_FORMAT_R8_UNORM; 996bf215546Sopenharmony_ci 997bf215546Sopenharmony_ci if (format2 == ISL_FORMAT_A8_UNORM) 998bf215546Sopenharmony_ci format2 = ISL_FORMAT_R8_UNORM; 999bf215546Sopenharmony_ci 1000bf215546Sopenharmony_ci /* The compression used by CCS is not dependent on the actual data encoding 1001bf215546Sopenharmony_ci * of the format but only depends on the bit-layout of the channels. 1002bf215546Sopenharmony_ci */ 1003bf215546Sopenharmony_ci return isl_formats_have_same_bits_per_channel(format1, format2); 1004bf215546Sopenharmony_ci} 1005bf215546Sopenharmony_ci 1006bf215546Sopenharmony_cistatic bool 1007bf215546Sopenharmony_ciisl_format_has_channel_type(enum isl_format fmt, enum isl_base_type type) 1008bf215546Sopenharmony_ci{ 1009bf215546Sopenharmony_ci const struct isl_format_layout *fmtl = isl_format_get_layout(fmt); 1010bf215546Sopenharmony_ci 1011bf215546Sopenharmony_ci return fmtl->channels.r.type == type || 1012bf215546Sopenharmony_ci fmtl->channels.g.type == type || 1013bf215546Sopenharmony_ci fmtl->channels.b.type == type || 1014bf215546Sopenharmony_ci fmtl->channels.a.type == type || 1015bf215546Sopenharmony_ci fmtl->channels.l.type == type || 1016bf215546Sopenharmony_ci fmtl->channels.i.type == type || 1017bf215546Sopenharmony_ci fmtl->channels.p.type == type; 1018bf215546Sopenharmony_ci} 1019bf215546Sopenharmony_ci 1020bf215546Sopenharmony_cibool 1021bf215546Sopenharmony_ciisl_format_has_unorm_channel(enum isl_format fmt) 1022bf215546Sopenharmony_ci{ 1023bf215546Sopenharmony_ci return isl_format_has_channel_type(fmt, ISL_UNORM); 1024bf215546Sopenharmony_ci} 1025bf215546Sopenharmony_ci 1026bf215546Sopenharmony_cibool 1027bf215546Sopenharmony_ciisl_format_has_snorm_channel(enum isl_format fmt) 1028bf215546Sopenharmony_ci{ 1029bf215546Sopenharmony_ci return isl_format_has_channel_type(fmt, ISL_SNORM); 1030bf215546Sopenharmony_ci} 1031bf215546Sopenharmony_ci 1032bf215546Sopenharmony_cibool 1033bf215546Sopenharmony_ciisl_format_has_ufloat_channel(enum isl_format fmt) 1034bf215546Sopenharmony_ci{ 1035bf215546Sopenharmony_ci return isl_format_has_channel_type(fmt, ISL_UFLOAT); 1036bf215546Sopenharmony_ci} 1037bf215546Sopenharmony_ci 1038bf215546Sopenharmony_cibool 1039bf215546Sopenharmony_ciisl_format_has_sfloat_channel(enum isl_format fmt) 1040bf215546Sopenharmony_ci{ 1041bf215546Sopenharmony_ci return isl_format_has_channel_type(fmt, ISL_SFLOAT); 1042bf215546Sopenharmony_ci} 1043bf215546Sopenharmony_ci 1044bf215546Sopenharmony_cibool 1045bf215546Sopenharmony_ciisl_format_has_uint_channel(enum isl_format fmt) 1046bf215546Sopenharmony_ci{ 1047bf215546Sopenharmony_ci return isl_format_has_channel_type(fmt, ISL_UINT); 1048bf215546Sopenharmony_ci} 1049bf215546Sopenharmony_ci 1050bf215546Sopenharmony_cibool 1051bf215546Sopenharmony_ciisl_format_has_sint_channel(enum isl_format fmt) 1052bf215546Sopenharmony_ci{ 1053bf215546Sopenharmony_ci return isl_format_has_channel_type(fmt, ISL_SINT); 1054bf215546Sopenharmony_ci} 1055bf215546Sopenharmony_ci 1056bf215546Sopenharmony_cibool 1057bf215546Sopenharmony_ciisl_format_has_color_component(enum isl_format fmt, int component) 1058bf215546Sopenharmony_ci{ 1059bf215546Sopenharmony_ci const struct isl_format_layout *fmtl = isl_format_get_layout(fmt); 1060bf215546Sopenharmony_ci const uint8_t intensity = fmtl->channels.i.bits; 1061bf215546Sopenharmony_ci const uint8_t luminance = fmtl->channels.l.bits; 1062bf215546Sopenharmony_ci 1063bf215546Sopenharmony_ci switch (component) { 1064bf215546Sopenharmony_ci case 0: 1065bf215546Sopenharmony_ci return (fmtl->channels.r.bits + intensity + luminance) > 0; 1066bf215546Sopenharmony_ci case 1: 1067bf215546Sopenharmony_ci return (fmtl->channels.g.bits + intensity + luminance) > 0; 1068bf215546Sopenharmony_ci case 2: 1069bf215546Sopenharmony_ci return (fmtl->channels.b.bits + intensity + luminance) > 0; 1070bf215546Sopenharmony_ci case 3: 1071bf215546Sopenharmony_ci return (fmtl->channels.a.bits + intensity) > 0; 1072bf215546Sopenharmony_ci default: 1073bf215546Sopenharmony_ci assert(!"Invalid color component: must be 0..3"); 1074bf215546Sopenharmony_ci return false; 1075bf215546Sopenharmony_ci } 1076bf215546Sopenharmony_ci} 1077bf215546Sopenharmony_ci 1078bf215546Sopenharmony_ciunsigned 1079bf215546Sopenharmony_ciisl_format_get_num_channels(enum isl_format fmt) 1080bf215546Sopenharmony_ci{ 1081bf215546Sopenharmony_ci const struct isl_format_layout *fmtl = isl_format_get_layout(fmt); 1082bf215546Sopenharmony_ci 1083bf215546Sopenharmony_ci assert(fmtl->channels.p.bits == 0); 1084bf215546Sopenharmony_ci 1085bf215546Sopenharmony_ci return (fmtl->channels.r.bits > 0) + 1086bf215546Sopenharmony_ci (fmtl->channels.g.bits > 0) + 1087bf215546Sopenharmony_ci (fmtl->channels.b.bits > 0) + 1088bf215546Sopenharmony_ci (fmtl->channels.a.bits > 0) + 1089bf215546Sopenharmony_ci (fmtl->channels.l.bits > 0) + 1090bf215546Sopenharmony_ci (fmtl->channels.i.bits > 0); 1091bf215546Sopenharmony_ci} 1092bf215546Sopenharmony_ci 1093bf215546Sopenharmony_ciuint32_t 1094bf215546Sopenharmony_ciisl_format_get_depth_format(enum isl_format fmt, bool has_stencil) 1095bf215546Sopenharmony_ci{ 1096bf215546Sopenharmony_ci switch (fmt) { 1097bf215546Sopenharmony_ci default: 1098bf215546Sopenharmony_ci unreachable("bad isl depth format"); 1099bf215546Sopenharmony_ci case ISL_FORMAT_R32_FLOAT_X8X24_TYPELESS: 1100bf215546Sopenharmony_ci assert(has_stencil); 1101bf215546Sopenharmony_ci return 0; /* D32_FLOAT_S8X24_UINT */ 1102bf215546Sopenharmony_ci case ISL_FORMAT_R32_FLOAT: 1103bf215546Sopenharmony_ci assert(!has_stencil); 1104bf215546Sopenharmony_ci return 1; /* D32_FLOAT */ 1105bf215546Sopenharmony_ci case ISL_FORMAT_R24_UNORM_X8_TYPELESS: 1106bf215546Sopenharmony_ci if (has_stencil) { 1107bf215546Sopenharmony_ci return 2; /* D24_UNORM_S8_UINT */ 1108bf215546Sopenharmony_ci } else { 1109bf215546Sopenharmony_ci return 3; /* D24_UNORM_X8_UINT */ 1110bf215546Sopenharmony_ci } 1111bf215546Sopenharmony_ci case ISL_FORMAT_R16_UNORM: 1112bf215546Sopenharmony_ci assert(!has_stencil); 1113bf215546Sopenharmony_ci return 5; /* D16_UNORM */ 1114bf215546Sopenharmony_ci } 1115bf215546Sopenharmony_ci} 1116bf215546Sopenharmony_ci 1117bf215546Sopenharmony_cienum isl_format 1118bf215546Sopenharmony_ciisl_format_rgb_to_rgba(enum isl_format rgb) 1119bf215546Sopenharmony_ci{ 1120bf215546Sopenharmony_ci assert(isl_format_is_rgb(rgb)); 1121bf215546Sopenharmony_ci 1122bf215546Sopenharmony_ci switch (rgb) { 1123bf215546Sopenharmony_ci case ISL_FORMAT_R32G32B32_FLOAT: return ISL_FORMAT_R32G32B32A32_FLOAT; 1124bf215546Sopenharmony_ci case ISL_FORMAT_R32G32B32_SINT: return ISL_FORMAT_R32G32B32A32_SINT; 1125bf215546Sopenharmony_ci case ISL_FORMAT_R32G32B32_UINT: return ISL_FORMAT_R32G32B32A32_UINT; 1126bf215546Sopenharmony_ci case ISL_FORMAT_R32G32B32_UNORM: return ISL_FORMAT_R32G32B32A32_UNORM; 1127bf215546Sopenharmony_ci case ISL_FORMAT_R32G32B32_SNORM: return ISL_FORMAT_R32G32B32A32_SNORM; 1128bf215546Sopenharmony_ci case ISL_FORMAT_R32G32B32_SSCALED: return ISL_FORMAT_R32G32B32A32_SSCALED; 1129bf215546Sopenharmony_ci case ISL_FORMAT_R32G32B32_USCALED: return ISL_FORMAT_R32G32B32A32_USCALED; 1130bf215546Sopenharmony_ci case ISL_FORMAT_R32G32B32_SFIXED: return ISL_FORMAT_R32G32B32A32_SFIXED; 1131bf215546Sopenharmony_ci case ISL_FORMAT_R8G8B8_UNORM: return ISL_FORMAT_R8G8B8A8_UNORM; 1132bf215546Sopenharmony_ci case ISL_FORMAT_R8G8B8_SNORM: return ISL_FORMAT_R8G8B8A8_SNORM; 1133bf215546Sopenharmony_ci case ISL_FORMAT_R8G8B8_SSCALED: return ISL_FORMAT_R8G8B8A8_SSCALED; 1134bf215546Sopenharmony_ci case ISL_FORMAT_R8G8B8_USCALED: return ISL_FORMAT_R8G8B8A8_USCALED; 1135bf215546Sopenharmony_ci case ISL_FORMAT_R16G16B16_FLOAT: return ISL_FORMAT_R16G16B16A16_FLOAT; 1136bf215546Sopenharmony_ci case ISL_FORMAT_R16G16B16_UNORM: return ISL_FORMAT_R16G16B16A16_UNORM; 1137bf215546Sopenharmony_ci case ISL_FORMAT_R16G16B16_SNORM: return ISL_FORMAT_R16G16B16A16_SNORM; 1138bf215546Sopenharmony_ci case ISL_FORMAT_R16G16B16_SSCALED: return ISL_FORMAT_R16G16B16A16_SSCALED; 1139bf215546Sopenharmony_ci case ISL_FORMAT_R16G16B16_USCALED: return ISL_FORMAT_R16G16B16A16_USCALED; 1140bf215546Sopenharmony_ci case ISL_FORMAT_R8G8B8_UNORM_SRGB: return ISL_FORMAT_R8G8B8A8_UNORM_SRGB; 1141bf215546Sopenharmony_ci case ISL_FORMAT_R16G16B16_UINT: return ISL_FORMAT_R16G16B16A16_UINT; 1142bf215546Sopenharmony_ci case ISL_FORMAT_R16G16B16_SINT: return ISL_FORMAT_R16G16B16A16_SINT; 1143bf215546Sopenharmony_ci case ISL_FORMAT_R8G8B8_UINT: return ISL_FORMAT_R8G8B8A8_UINT; 1144bf215546Sopenharmony_ci case ISL_FORMAT_R8G8B8_SINT: return ISL_FORMAT_R8G8B8A8_SINT; 1145bf215546Sopenharmony_ci default: 1146bf215546Sopenharmony_ci return ISL_FORMAT_UNSUPPORTED; 1147bf215546Sopenharmony_ci } 1148bf215546Sopenharmony_ci} 1149bf215546Sopenharmony_ci 1150bf215546Sopenharmony_cienum isl_format 1151bf215546Sopenharmony_ciisl_format_rgb_to_rgbx(enum isl_format rgb) 1152bf215546Sopenharmony_ci{ 1153bf215546Sopenharmony_ci assert(isl_format_is_rgb(rgb)); 1154bf215546Sopenharmony_ci 1155bf215546Sopenharmony_ci switch (rgb) { 1156bf215546Sopenharmony_ci case ISL_FORMAT_R32G32B32_FLOAT: 1157bf215546Sopenharmony_ci return ISL_FORMAT_R32G32B32X32_FLOAT; 1158bf215546Sopenharmony_ci case ISL_FORMAT_R16G16B16_UNORM: 1159bf215546Sopenharmony_ci return ISL_FORMAT_R16G16B16X16_UNORM; 1160bf215546Sopenharmony_ci case ISL_FORMAT_R16G16B16_FLOAT: 1161bf215546Sopenharmony_ci return ISL_FORMAT_R16G16B16X16_FLOAT; 1162bf215546Sopenharmony_ci case ISL_FORMAT_R8G8B8_UNORM: 1163bf215546Sopenharmony_ci return ISL_FORMAT_R8G8B8X8_UNORM; 1164bf215546Sopenharmony_ci case ISL_FORMAT_R8G8B8_UNORM_SRGB: 1165bf215546Sopenharmony_ci return ISL_FORMAT_R8G8B8X8_UNORM_SRGB; 1166bf215546Sopenharmony_ci default: 1167bf215546Sopenharmony_ci return ISL_FORMAT_UNSUPPORTED; 1168bf215546Sopenharmony_ci } 1169bf215546Sopenharmony_ci} 1170bf215546Sopenharmony_ci 1171bf215546Sopenharmony_cienum isl_format 1172bf215546Sopenharmony_ciisl_format_rgbx_to_rgba(enum isl_format rgbx) 1173bf215546Sopenharmony_ci{ 1174bf215546Sopenharmony_ci assert(isl_format_is_rgbx(rgbx)); 1175bf215546Sopenharmony_ci 1176bf215546Sopenharmony_ci switch (rgbx) { 1177bf215546Sopenharmony_ci case ISL_FORMAT_R32G32B32X32_FLOAT: 1178bf215546Sopenharmony_ci return ISL_FORMAT_R32G32B32A32_FLOAT; 1179bf215546Sopenharmony_ci case ISL_FORMAT_R16G16B16X16_UNORM: 1180bf215546Sopenharmony_ci return ISL_FORMAT_R16G16B16A16_UNORM; 1181bf215546Sopenharmony_ci case ISL_FORMAT_R16G16B16X16_FLOAT: 1182bf215546Sopenharmony_ci return ISL_FORMAT_R16G16B16A16_FLOAT; 1183bf215546Sopenharmony_ci case ISL_FORMAT_B8G8R8X8_UNORM: 1184bf215546Sopenharmony_ci return ISL_FORMAT_B8G8R8A8_UNORM; 1185bf215546Sopenharmony_ci case ISL_FORMAT_B8G8R8X8_UNORM_SRGB: 1186bf215546Sopenharmony_ci return ISL_FORMAT_B8G8R8A8_UNORM_SRGB; 1187bf215546Sopenharmony_ci case ISL_FORMAT_R8G8B8X8_UNORM: 1188bf215546Sopenharmony_ci return ISL_FORMAT_R8G8B8A8_UNORM; 1189bf215546Sopenharmony_ci case ISL_FORMAT_R8G8B8X8_UNORM_SRGB: 1190bf215546Sopenharmony_ci return ISL_FORMAT_R8G8B8A8_UNORM_SRGB; 1191bf215546Sopenharmony_ci case ISL_FORMAT_B10G10R10X2_UNORM: 1192bf215546Sopenharmony_ci return ISL_FORMAT_B10G10R10A2_UNORM; 1193bf215546Sopenharmony_ci case ISL_FORMAT_B5G5R5X1_UNORM: 1194bf215546Sopenharmony_ci return ISL_FORMAT_B5G5R5A1_UNORM; 1195bf215546Sopenharmony_ci case ISL_FORMAT_B5G5R5X1_UNORM_SRGB: 1196bf215546Sopenharmony_ci return ISL_FORMAT_B5G5R5A1_UNORM_SRGB; 1197bf215546Sopenharmony_ci default: 1198bf215546Sopenharmony_ci assert(!"Invalid RGBX format"); 1199bf215546Sopenharmony_ci return rgbx; 1200bf215546Sopenharmony_ci } 1201bf215546Sopenharmony_ci} 1202bf215546Sopenharmony_ci 1203bf215546Sopenharmony_cistatic inline void 1204bf215546Sopenharmony_cipack_channel(const union isl_color_value *value, unsigned i, 1205bf215546Sopenharmony_ci const struct isl_channel_layout *layout, 1206bf215546Sopenharmony_ci enum isl_colorspace colorspace, 1207bf215546Sopenharmony_ci uint32_t data_out[4]) 1208bf215546Sopenharmony_ci{ 1209bf215546Sopenharmony_ci if (layout->type == ISL_VOID) 1210bf215546Sopenharmony_ci return; 1211bf215546Sopenharmony_ci 1212bf215546Sopenharmony_ci if (colorspace == ISL_COLORSPACE_SRGB) 1213bf215546Sopenharmony_ci assert(layout->type == ISL_UNORM); 1214bf215546Sopenharmony_ci 1215bf215546Sopenharmony_ci uint32_t packed; 1216bf215546Sopenharmony_ci switch (layout->type) { 1217bf215546Sopenharmony_ci case ISL_UNORM: 1218bf215546Sopenharmony_ci if (colorspace == ISL_COLORSPACE_SRGB) { 1219bf215546Sopenharmony_ci if (layout->bits == 8) { 1220bf215546Sopenharmony_ci packed = util_format_linear_float_to_srgb_8unorm(value->f32[i]); 1221bf215546Sopenharmony_ci } else { 1222bf215546Sopenharmony_ci float srgb = util_format_linear_to_srgb_float(value->f32[i]); 1223bf215546Sopenharmony_ci packed = _mesa_float_to_unorm(srgb, layout->bits); 1224bf215546Sopenharmony_ci } 1225bf215546Sopenharmony_ci } else { 1226bf215546Sopenharmony_ci packed = _mesa_float_to_unorm(value->f32[i], layout->bits); 1227bf215546Sopenharmony_ci } 1228bf215546Sopenharmony_ci break; 1229bf215546Sopenharmony_ci case ISL_SNORM: 1230bf215546Sopenharmony_ci packed = _mesa_float_to_snorm(value->f32[i], layout->bits); 1231bf215546Sopenharmony_ci break; 1232bf215546Sopenharmony_ci case ISL_SFLOAT: 1233bf215546Sopenharmony_ci assert(layout->bits == 16 || layout->bits == 32); 1234bf215546Sopenharmony_ci if (layout->bits == 16) { 1235bf215546Sopenharmony_ci packed = _mesa_float_to_half(value->f32[i]); 1236bf215546Sopenharmony_ci } else { 1237bf215546Sopenharmony_ci packed = value->u32[i]; 1238bf215546Sopenharmony_ci } 1239bf215546Sopenharmony_ci break; 1240bf215546Sopenharmony_ci case ISL_UINT: 1241bf215546Sopenharmony_ci packed = MIN(value->u32[i], u_uintN_max(layout->bits)); 1242bf215546Sopenharmony_ci break; 1243bf215546Sopenharmony_ci case ISL_SINT: 1244bf215546Sopenharmony_ci packed = CLAMP(value->u32[i], u_intN_min(layout->bits), 1245bf215546Sopenharmony_ci u_intN_max(layout->bits)); 1246bf215546Sopenharmony_ci break; 1247bf215546Sopenharmony_ci 1248bf215546Sopenharmony_ci default: 1249bf215546Sopenharmony_ci unreachable("Invalid channel type"); 1250bf215546Sopenharmony_ci } 1251bf215546Sopenharmony_ci 1252bf215546Sopenharmony_ci unsigned dword = layout->start_bit / 32; 1253bf215546Sopenharmony_ci unsigned bit = layout->start_bit % 32; 1254bf215546Sopenharmony_ci assert(bit + layout->bits <= 32); 1255bf215546Sopenharmony_ci data_out[dword] |= (packed & u_uintN_max(layout->bits)) << bit; 1256bf215546Sopenharmony_ci} 1257bf215546Sopenharmony_ci 1258bf215546Sopenharmony_ci/** 1259bf215546Sopenharmony_ci * Take an isl_color_value and pack it into the actual bits as specified by 1260bf215546Sopenharmony_ci * the isl_format. This function is very slow for a format conversion 1261bf215546Sopenharmony_ci * function but should be fine for a single pixel worth of data. 1262bf215546Sopenharmony_ci */ 1263bf215546Sopenharmony_civoid 1264bf215546Sopenharmony_ciisl_color_value_pack(const union isl_color_value *value, 1265bf215546Sopenharmony_ci enum isl_format format, 1266bf215546Sopenharmony_ci uint32_t *data_out) 1267bf215546Sopenharmony_ci{ 1268bf215546Sopenharmony_ci const struct isl_format_layout *fmtl = isl_format_get_layout(format); 1269bf215546Sopenharmony_ci assert(fmtl->colorspace == ISL_COLORSPACE_LINEAR || 1270bf215546Sopenharmony_ci fmtl->colorspace == ISL_COLORSPACE_SRGB); 1271bf215546Sopenharmony_ci assert(!isl_format_is_compressed(format)); 1272bf215546Sopenharmony_ci 1273bf215546Sopenharmony_ci memset(data_out, 0, isl_align(fmtl->bpb, 32) / 8); 1274bf215546Sopenharmony_ci 1275bf215546Sopenharmony_ci if (format == ISL_FORMAT_R9G9B9E5_SHAREDEXP) { 1276bf215546Sopenharmony_ci data_out[0] = float3_to_rgb9e5(value->f32); 1277bf215546Sopenharmony_ci return; 1278bf215546Sopenharmony_ci } else if (format == ISL_FORMAT_R11G11B10_FLOAT) { 1279bf215546Sopenharmony_ci data_out[0] = float3_to_r11g11b10f(value->f32); 1280bf215546Sopenharmony_ci return; 1281bf215546Sopenharmony_ci } 1282bf215546Sopenharmony_ci 1283bf215546Sopenharmony_ci pack_channel(value, 0, &fmtl->channels.r, fmtl->colorspace, data_out); 1284bf215546Sopenharmony_ci pack_channel(value, 1, &fmtl->channels.g, fmtl->colorspace, data_out); 1285bf215546Sopenharmony_ci pack_channel(value, 2, &fmtl->channels.b, fmtl->colorspace, data_out); 1286bf215546Sopenharmony_ci pack_channel(value, 3, &fmtl->channels.a, ISL_COLORSPACE_LINEAR, data_out); 1287bf215546Sopenharmony_ci pack_channel(value, 0, &fmtl->channels.l, fmtl->colorspace, data_out); 1288bf215546Sopenharmony_ci pack_channel(value, 0, &fmtl->channels.i, ISL_COLORSPACE_LINEAR, data_out); 1289bf215546Sopenharmony_ci assert(fmtl->channels.p.bits == 0); 1290bf215546Sopenharmony_ci} 1291bf215546Sopenharmony_ci 1292bf215546Sopenharmony_cistatic inline void 1293bf215546Sopenharmony_ciunpack_channel(union isl_color_value *value, 1294bf215546Sopenharmony_ci unsigned start, unsigned count, 1295bf215546Sopenharmony_ci const struct isl_channel_layout *layout, 1296bf215546Sopenharmony_ci enum isl_colorspace colorspace, 1297bf215546Sopenharmony_ci const uint32_t *data_in) 1298bf215546Sopenharmony_ci{ 1299bf215546Sopenharmony_ci if (layout->type == ISL_VOID) 1300bf215546Sopenharmony_ci return; 1301bf215546Sopenharmony_ci 1302bf215546Sopenharmony_ci unsigned dword = layout->start_bit / 32; 1303bf215546Sopenharmony_ci unsigned bit = layout->start_bit % 32; 1304bf215546Sopenharmony_ci assert(bit + layout->bits <= 32); 1305bf215546Sopenharmony_ci uint32_t packed = (data_in[dword] >> bit) & u_uintN_max(layout->bits); 1306bf215546Sopenharmony_ci 1307bf215546Sopenharmony_ci union { 1308bf215546Sopenharmony_ci uint32_t u32; 1309bf215546Sopenharmony_ci float f32; 1310bf215546Sopenharmony_ci } unpacked; 1311bf215546Sopenharmony_ci 1312bf215546Sopenharmony_ci if (colorspace == ISL_COLORSPACE_SRGB) 1313bf215546Sopenharmony_ci assert(layout->type == ISL_UNORM); 1314bf215546Sopenharmony_ci 1315bf215546Sopenharmony_ci switch (layout->type) { 1316bf215546Sopenharmony_ci case ISL_UNORM: 1317bf215546Sopenharmony_ci if (colorspace == ISL_COLORSPACE_SRGB) { 1318bf215546Sopenharmony_ci if (layout->bits == 8) { 1319bf215546Sopenharmony_ci unpacked.f32 = util_format_srgb_8unorm_to_linear_float(packed); 1320bf215546Sopenharmony_ci } else { 1321bf215546Sopenharmony_ci float srgb = _mesa_unorm_to_float(packed, layout->bits); 1322bf215546Sopenharmony_ci unpacked.f32 = util_format_srgb_to_linear_float(srgb); 1323bf215546Sopenharmony_ci } 1324bf215546Sopenharmony_ci } else { 1325bf215546Sopenharmony_ci unpacked.f32 = _mesa_unorm_to_float(packed, layout->bits); 1326bf215546Sopenharmony_ci } 1327bf215546Sopenharmony_ci break; 1328bf215546Sopenharmony_ci case ISL_SNORM: 1329bf215546Sopenharmony_ci unpacked.f32 = _mesa_snorm_to_float(util_sign_extend(packed, layout->bits), 1330bf215546Sopenharmony_ci layout->bits); 1331bf215546Sopenharmony_ci break; 1332bf215546Sopenharmony_ci case ISL_SFLOAT: 1333bf215546Sopenharmony_ci assert(layout->bits == 16 || layout->bits == 32); 1334bf215546Sopenharmony_ci if (layout->bits == 16) { 1335bf215546Sopenharmony_ci unpacked.f32 = _mesa_half_to_float(packed); 1336bf215546Sopenharmony_ci } else { 1337bf215546Sopenharmony_ci unpacked.u32 = packed; 1338bf215546Sopenharmony_ci } 1339bf215546Sopenharmony_ci break; 1340bf215546Sopenharmony_ci case ISL_UINT: 1341bf215546Sopenharmony_ci unpacked.u32 = packed; 1342bf215546Sopenharmony_ci break; 1343bf215546Sopenharmony_ci case ISL_SINT: 1344bf215546Sopenharmony_ci unpacked.u32 = util_sign_extend(packed, layout->bits); 1345bf215546Sopenharmony_ci break; 1346bf215546Sopenharmony_ci 1347bf215546Sopenharmony_ci default: 1348bf215546Sopenharmony_ci unreachable("Invalid channel type"); 1349bf215546Sopenharmony_ci } 1350bf215546Sopenharmony_ci 1351bf215546Sopenharmony_ci for (unsigned i = 0; i < count; i++) 1352bf215546Sopenharmony_ci value->u32[start + i] = unpacked.u32; 1353bf215546Sopenharmony_ci} 1354bf215546Sopenharmony_ci 1355bf215546Sopenharmony_ci/** 1356bf215546Sopenharmony_ci * Take unpack an isl_color_value from the actual bits as specified by 1357bf215546Sopenharmony_ci * the isl_format. This function is very slow for a format conversion 1358bf215546Sopenharmony_ci * function but should be fine for a single pixel worth of data. 1359bf215546Sopenharmony_ci */ 1360bf215546Sopenharmony_civoid 1361bf215546Sopenharmony_ciisl_color_value_unpack(union isl_color_value *value, 1362bf215546Sopenharmony_ci enum isl_format format, 1363bf215546Sopenharmony_ci const uint32_t *data_in) 1364bf215546Sopenharmony_ci{ 1365bf215546Sopenharmony_ci const struct isl_format_layout *fmtl = isl_format_get_layout(format); 1366bf215546Sopenharmony_ci assert(fmtl->colorspace == ISL_COLORSPACE_LINEAR || 1367bf215546Sopenharmony_ci fmtl->colorspace == ISL_COLORSPACE_SRGB); 1368bf215546Sopenharmony_ci assert(!isl_format_is_compressed(format)); 1369bf215546Sopenharmony_ci 1370bf215546Sopenharmony_ci /* Default to opaque black. */ 1371bf215546Sopenharmony_ci memset(value, 0, sizeof(*value)); 1372bf215546Sopenharmony_ci if (isl_format_has_int_channel(format)) { 1373bf215546Sopenharmony_ci value->u32[3] = 1u; 1374bf215546Sopenharmony_ci } else { 1375bf215546Sopenharmony_ci value->f32[3] = 1.0f; 1376bf215546Sopenharmony_ci } 1377bf215546Sopenharmony_ci 1378bf215546Sopenharmony_ci if (format == ISL_FORMAT_R9G9B9E5_SHAREDEXP) { 1379bf215546Sopenharmony_ci rgb9e5_to_float3(data_in[0], value->f32); 1380bf215546Sopenharmony_ci return; 1381bf215546Sopenharmony_ci } else if (format == ISL_FORMAT_R11G11B10_FLOAT) { 1382bf215546Sopenharmony_ci r11g11b10f_to_float3(data_in[0], value->f32); 1383bf215546Sopenharmony_ci return; 1384bf215546Sopenharmony_ci } 1385bf215546Sopenharmony_ci 1386bf215546Sopenharmony_ci unpack_channel(value, 0, 1, &fmtl->channels.r, fmtl->colorspace, data_in); 1387bf215546Sopenharmony_ci unpack_channel(value, 1, 1, &fmtl->channels.g, fmtl->colorspace, data_in); 1388bf215546Sopenharmony_ci unpack_channel(value, 2, 1, &fmtl->channels.b, fmtl->colorspace, data_in); 1389bf215546Sopenharmony_ci unpack_channel(value, 3, 1, &fmtl->channels.a, ISL_COLORSPACE_LINEAR, data_in); 1390bf215546Sopenharmony_ci unpack_channel(value, 0, 3, &fmtl->channels.l, fmtl->colorspace, data_in); 1391bf215546Sopenharmony_ci unpack_channel(value, 0, 4, &fmtl->channels.i, ISL_COLORSPACE_LINEAR, data_in); 1392bf215546Sopenharmony_ci assert(fmtl->channels.p.bits == 0); 1393bf215546Sopenharmony_ci} 1394