1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright 2017 Advanced Micro Devices, Inc. 3bf215546Sopenharmony_ci * All Rights Reserved. 4bf215546Sopenharmony_ci * 5bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 6bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 7bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 8bf215546Sopenharmony_ci * on the rights to use, copy, modify, merge, publish, distribute, sub 9bf215546Sopenharmony_ci * license, and/or sell copies of the Software, and to permit persons to whom 10bf215546Sopenharmony_ci * the Software is furnished to do so, subject to the following conditions: 11bf215546Sopenharmony_ci * 12bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 13bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 14bf215546Sopenharmony_ci * Software. 15bf215546Sopenharmony_ci * 16bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 19bf215546Sopenharmony_ci * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 20bf215546Sopenharmony_ci * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 21bf215546Sopenharmony_ci * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 22bf215546Sopenharmony_ci * USE OR OTHER DEALINGS IN THE SOFTWARE. 23bf215546Sopenharmony_ci */ 24bf215546Sopenharmony_ci 25bf215546Sopenharmony_ci#include "compiler/nir/nir.h" 26bf215546Sopenharmony_ci#include "radeon_uvd_enc.h" 27bf215546Sopenharmony_ci#include "radeon_vce.h" 28bf215546Sopenharmony_ci#include "radeon_video.h" 29bf215546Sopenharmony_ci#include "si_pipe.h" 30bf215546Sopenharmony_ci#include "util/u_cpu_detect.h" 31bf215546Sopenharmony_ci#include "util/u_screen.h" 32bf215546Sopenharmony_ci#include "util/u_video.h" 33bf215546Sopenharmony_ci#include "vl/vl_decoder.h" 34bf215546Sopenharmony_ci#include "vl/vl_video_buffer.h" 35bf215546Sopenharmony_ci#include <sys/utsname.h> 36bf215546Sopenharmony_ci 37bf215546Sopenharmony_cistatic const char *si_get_vendor(struct pipe_screen *pscreen) 38bf215546Sopenharmony_ci{ 39bf215546Sopenharmony_ci return "AMD"; 40bf215546Sopenharmony_ci} 41bf215546Sopenharmony_ci 42bf215546Sopenharmony_cistatic const char *si_get_device_vendor(struct pipe_screen *pscreen) 43bf215546Sopenharmony_ci{ 44bf215546Sopenharmony_ci return "AMD"; 45bf215546Sopenharmony_ci} 46bf215546Sopenharmony_ci 47bf215546Sopenharmony_cistatic int si_get_param(struct pipe_screen *pscreen, enum pipe_cap param) 48bf215546Sopenharmony_ci{ 49bf215546Sopenharmony_ci struct si_screen *sscreen = (struct si_screen *)pscreen; 50bf215546Sopenharmony_ci 51bf215546Sopenharmony_ci /* Gfx8 (Polaris11) hangs, so don't enable this on Gfx8 and older chips. */ 52bf215546Sopenharmony_ci bool enable_sparse = sscreen->info.gfx_level >= GFX9 && 53bf215546Sopenharmony_ci sscreen->info.has_sparse_vm_mappings; 54bf215546Sopenharmony_ci 55bf215546Sopenharmony_ci switch (param) { 56bf215546Sopenharmony_ci /* Supported features (boolean caps). */ 57bf215546Sopenharmony_ci case PIPE_CAP_ACCELERATED: 58bf215546Sopenharmony_ci case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS: 59bf215546Sopenharmony_ci case PIPE_CAP_ANISOTROPIC_FILTER: 60bf215546Sopenharmony_ci case PIPE_CAP_POINT_SPRITE: 61bf215546Sopenharmony_ci case PIPE_CAP_OCCLUSION_QUERY: 62bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_MIRROR_CLAMP: 63bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_SHADOW_LOD: 64bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_MIRROR_CLAMP_TO_EDGE: 65bf215546Sopenharmony_ci case PIPE_CAP_BLEND_EQUATION_SEPARATE: 66bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_SWIZZLE: 67bf215546Sopenharmony_ci case PIPE_CAP_DEPTH_CLIP_DISABLE: 68bf215546Sopenharmony_ci case PIPE_CAP_DEPTH_CLIP_DISABLE_SEPARATE: 69bf215546Sopenharmony_ci case PIPE_CAP_SHADER_STENCIL_EXPORT: 70bf215546Sopenharmony_ci case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR: 71bf215546Sopenharmony_ci case PIPE_CAP_MIXED_COLORBUFFER_FORMATS: 72bf215546Sopenharmony_ci case PIPE_CAP_FS_COORD_ORIGIN_UPPER_LEFT: 73bf215546Sopenharmony_ci case PIPE_CAP_FS_COORD_PIXEL_CENTER_HALF_INTEGER: 74bf215546Sopenharmony_ci case PIPE_CAP_FS_COORD_PIXEL_CENTER_INTEGER: 75bf215546Sopenharmony_ci case PIPE_CAP_FRAGMENT_SHADER_TEXTURE_LOD: 76bf215546Sopenharmony_ci case PIPE_CAP_FRAGMENT_SHADER_DERIVATIVES: 77bf215546Sopenharmony_ci case PIPE_CAP_PRIMITIVE_RESTART: 78bf215546Sopenharmony_ci case PIPE_CAP_PRIMITIVE_RESTART_FIXED_INDEX: 79bf215546Sopenharmony_ci case PIPE_CAP_CONDITIONAL_RENDER: 80bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_BARRIER: 81bf215546Sopenharmony_ci case PIPE_CAP_INDEP_BLEND_ENABLE: 82bf215546Sopenharmony_ci case PIPE_CAP_INDEP_BLEND_FUNC: 83bf215546Sopenharmony_ci case PIPE_CAP_VERTEX_COLOR_UNCLAMPED: 84bf215546Sopenharmony_ci case PIPE_CAP_START_INSTANCE: 85bf215546Sopenharmony_ci case PIPE_CAP_NPOT_TEXTURES: 86bf215546Sopenharmony_ci case PIPE_CAP_MIXED_FRAMEBUFFER_SIZES: 87bf215546Sopenharmony_ci case PIPE_CAP_MIXED_COLOR_DEPTH_BITS: 88bf215546Sopenharmony_ci case PIPE_CAP_VERTEX_COLOR_CLAMPED: 89bf215546Sopenharmony_ci case PIPE_CAP_FRAGMENT_COLOR_CLAMPED: 90bf215546Sopenharmony_ci case PIPE_CAP_VS_INSTANCEID: 91bf215546Sopenharmony_ci case PIPE_CAP_COMPUTE: 92bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_BUFFER_OBJECTS: 93bf215546Sopenharmony_ci case PIPE_CAP_VS_LAYER_VIEWPORT: 94bf215546Sopenharmony_ci case PIPE_CAP_QUERY_PIPELINE_STATISTICS: 95bf215546Sopenharmony_ci case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT: 96bf215546Sopenharmony_ci case PIPE_CAP_SAMPLE_SHADING: 97bf215546Sopenharmony_ci case PIPE_CAP_DRAW_INDIRECT: 98bf215546Sopenharmony_ci case PIPE_CAP_CLIP_HALFZ: 99bf215546Sopenharmony_ci case PIPE_CAP_VS_WINDOW_SPACE_POSITION: 100bf215546Sopenharmony_ci case PIPE_CAP_POLYGON_OFFSET_CLAMP: 101bf215546Sopenharmony_ci case PIPE_CAP_MULTISAMPLE_Z_RESOLVE: 102bf215546Sopenharmony_ci case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION: 103bf215546Sopenharmony_ci case PIPE_CAP_TGSI_TEXCOORD: 104bf215546Sopenharmony_ci case PIPE_CAP_FS_FINE_DERIVATIVE: 105bf215546Sopenharmony_ci case PIPE_CAP_CONDITIONAL_RENDER_INVERTED: 106bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_FLOAT_LINEAR: 107bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_HALF_FLOAT_LINEAR: 108bf215546Sopenharmony_ci case PIPE_CAP_DEPTH_BOUNDS_TEST: 109bf215546Sopenharmony_ci case PIPE_CAP_SAMPLER_VIEW_TARGET: 110bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_QUERY_LOD: 111bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_GATHER_SM5: 112bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_QUERY_SAMPLES: 113bf215546Sopenharmony_ci case PIPE_CAP_FORCE_PERSAMPLE_INTERP: 114bf215546Sopenharmony_ci case PIPE_CAP_COPY_BETWEEN_COMPRESSED_AND_PLAIN_FORMATS: 115bf215546Sopenharmony_ci case PIPE_CAP_FS_POSITION_IS_SYSVAL: 116bf215546Sopenharmony_ci case PIPE_CAP_FS_FACE_IS_INTEGER_SYSVAL: 117bf215546Sopenharmony_ci case PIPE_CAP_INVALIDATE_BUFFER: 118bf215546Sopenharmony_ci case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS: 119bf215546Sopenharmony_ci case PIPE_CAP_QUERY_BUFFER_OBJECT: 120bf215546Sopenharmony_ci case PIPE_CAP_QUERY_MEMORY_INFO: 121bf215546Sopenharmony_ci case PIPE_CAP_SHADER_PACK_HALF_FLOAT: 122bf215546Sopenharmony_ci case PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT: 123bf215546Sopenharmony_ci case PIPE_CAP_ROBUST_BUFFER_ACCESS_BEHAVIOR: 124bf215546Sopenharmony_ci case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED: 125bf215546Sopenharmony_ci case PIPE_CAP_STRING_MARKER: 126bf215546Sopenharmony_ci case PIPE_CAP_CLEAR_TEXTURE: 127bf215546Sopenharmony_ci case PIPE_CAP_CULL_DISTANCE: 128bf215546Sopenharmony_ci case PIPE_CAP_SHADER_ARRAY_COMPONENTS: 129bf215546Sopenharmony_ci case PIPE_CAP_SHADER_CAN_READ_OUTPUTS: 130bf215546Sopenharmony_ci case PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME: 131bf215546Sopenharmony_ci case PIPE_CAP_STREAM_OUTPUT_INTERLEAVE_BUFFERS: 132bf215546Sopenharmony_ci case PIPE_CAP_DOUBLES: 133bf215546Sopenharmony_ci case PIPE_CAP_TGSI_TEX_TXF_LZ: 134bf215546Sopenharmony_ci case PIPE_CAP_TES_LAYER_VIEWPORT: 135bf215546Sopenharmony_ci case PIPE_CAP_BINDLESS_TEXTURE: 136bf215546Sopenharmony_ci case PIPE_CAP_QUERY_TIMESTAMP: 137bf215546Sopenharmony_ci case PIPE_CAP_QUERY_TIME_ELAPSED: 138bf215546Sopenharmony_ci case PIPE_CAP_NIR_SAMPLERS_AS_DEREF: 139bf215546Sopenharmony_ci case PIPE_CAP_MEMOBJ: 140bf215546Sopenharmony_ci case PIPE_CAP_LOAD_CONSTBUF: 141bf215546Sopenharmony_ci case PIPE_CAP_INT64: 142bf215546Sopenharmony_ci case PIPE_CAP_INT64_DIVMOD: 143bf215546Sopenharmony_ci case PIPE_CAP_SHADER_CLOCK: 144bf215546Sopenharmony_ci case PIPE_CAP_CAN_BIND_CONST_BUFFER_AS_VERTEX: 145bf215546Sopenharmony_ci case PIPE_CAP_ALLOW_MAPPED_BUFFERS_DURING_EXECUTION: 146bf215546Sopenharmony_ci case PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET: 147bf215546Sopenharmony_ci case PIPE_CAP_SHADER_BALLOT: 148bf215546Sopenharmony_ci case PIPE_CAP_SHADER_GROUP_VOTE: 149bf215546Sopenharmony_ci case PIPE_CAP_FBFETCH: 150bf215546Sopenharmony_ci case PIPE_CAP_COMPUTE_GRID_INFO_LAST_BLOCK: 151bf215546Sopenharmony_ci case PIPE_CAP_IMAGE_LOAD_FORMATTED: 152bf215546Sopenharmony_ci case PIPE_CAP_PREFER_COMPUTE_FOR_MULTIMEDIA: 153bf215546Sopenharmony_ci case PIPE_CAP_TGSI_DIV: 154bf215546Sopenharmony_ci case PIPE_CAP_PACKED_UNIFORMS: 155bf215546Sopenharmony_ci case PIPE_CAP_GL_SPIRV: 156bf215546Sopenharmony_ci case PIPE_CAP_ALPHA_TO_COVERAGE_DITHER_CONTROL: 157bf215546Sopenharmony_ci case PIPE_CAP_MAP_UNSYNCHRONIZED_THREAD_SAFE: 158bf215546Sopenharmony_ci case PIPE_CAP_NO_CLIP_ON_COPY_TEX: 159bf215546Sopenharmony_ci case PIPE_CAP_SHADER_ATOMIC_INT64: 160bf215546Sopenharmony_ci case PIPE_CAP_FRONTEND_NOOP: 161bf215546Sopenharmony_ci case PIPE_CAP_DEMOTE_TO_HELPER_INVOCATION: 162bf215546Sopenharmony_ci case PIPE_CAP_PREFER_REAL_BUFFER_IN_CONSTBUF0: 163bf215546Sopenharmony_ci case PIPE_CAP_COMPUTE_SHADER_DERIVATIVES: 164bf215546Sopenharmony_ci case PIPE_CAP_IMAGE_ATOMIC_INC_WRAP: 165bf215546Sopenharmony_ci case PIPE_CAP_IMAGE_STORE_FORMATTED: 166bf215546Sopenharmony_ci case PIPE_CAP_ALLOW_DRAW_OUT_OF_ORDER: 167bf215546Sopenharmony_ci case PIPE_CAP_QUERY_SO_OVERFLOW: 168bf215546Sopenharmony_ci case PIPE_CAP_GLSL_TESS_LEVELS_AS_INPUTS: 169bf215546Sopenharmony_ci case PIPE_CAP_DEVICE_RESET_STATUS_QUERY: 170bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_MULTISAMPLE: 171bf215546Sopenharmony_ci return 1; 172bf215546Sopenharmony_ci 173bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_TRANSFER_MODES: 174bf215546Sopenharmony_ci return PIPE_TEXTURE_TRANSFER_BLIT; 175bf215546Sopenharmony_ci 176bf215546Sopenharmony_ci case PIPE_CAP_DRAW_VERTEX_STATE: 177bf215546Sopenharmony_ci return !(sscreen->debug_flags & DBG(NO_FAST_DISPLAY_LIST)); 178bf215546Sopenharmony_ci 179bf215546Sopenharmony_ci case PIPE_CAP_SHADER_SAMPLES_IDENTICAL: 180bf215546Sopenharmony_ci return sscreen->info.gfx_level < GFX11; 181bf215546Sopenharmony_ci 182bf215546Sopenharmony_ci case PIPE_CAP_GLSL_ZERO_INIT: 183bf215546Sopenharmony_ci return 2; 184bf215546Sopenharmony_ci 185bf215546Sopenharmony_ci case PIPE_CAP_GENERATE_MIPMAP: 186bf215546Sopenharmony_ci case PIPE_CAP_SEAMLESS_CUBE_MAP: 187bf215546Sopenharmony_ci case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE: 188bf215546Sopenharmony_ci case PIPE_CAP_CUBE_MAP_ARRAY: 189bf215546Sopenharmony_ci return sscreen->info.has_3d_cube_border_color_mipmap; 190bf215546Sopenharmony_ci 191bf215546Sopenharmony_ci case PIPE_CAP_POST_DEPTH_COVERAGE: 192bf215546Sopenharmony_ci return sscreen->info.gfx_level >= GFX10; 193bf215546Sopenharmony_ci 194bf215546Sopenharmony_ci case PIPE_CAP_GRAPHICS: 195bf215546Sopenharmony_ci return sscreen->info.has_graphics; 196bf215546Sopenharmony_ci 197bf215546Sopenharmony_ci case PIPE_CAP_RESOURCE_FROM_USER_MEMORY: 198bf215546Sopenharmony_ci return !SI_BIG_ENDIAN && sscreen->info.has_userptr; 199bf215546Sopenharmony_ci 200bf215546Sopenharmony_ci case PIPE_CAP_DEVICE_PROTECTED_CONTENT: 201bf215546Sopenharmony_ci return sscreen->info.has_tmz_support; 202bf215546Sopenharmony_ci 203bf215546Sopenharmony_ci case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT: 204bf215546Sopenharmony_ci return SI_MAP_BUFFER_ALIGNMENT; 205bf215546Sopenharmony_ci 206bf215546Sopenharmony_ci case PIPE_CAP_MAX_VERTEX_BUFFERS: 207bf215546Sopenharmony_ci return SI_MAX_ATTRIBS; 208bf215546Sopenharmony_ci 209bf215546Sopenharmony_ci case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT: 210bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT: 211bf215546Sopenharmony_ci case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS: 212bf215546Sopenharmony_ci case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS: 213bf215546Sopenharmony_ci case PIPE_CAP_MAX_VERTEX_STREAMS: 214bf215546Sopenharmony_ci case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT: 215bf215546Sopenharmony_ci case PIPE_CAP_MAX_WINDOW_RECTANGLES: 216bf215546Sopenharmony_ci return 4; 217bf215546Sopenharmony_ci 218bf215546Sopenharmony_ci case PIPE_CAP_GLSL_FEATURE_LEVEL: 219bf215546Sopenharmony_ci case PIPE_CAP_GLSL_FEATURE_LEVEL_COMPATIBILITY: 220bf215546Sopenharmony_ci return 460; 221bf215546Sopenharmony_ci 222bf215546Sopenharmony_ci case PIPE_CAP_MAX_TEXTURE_UPLOAD_MEMORY_BUDGET: 223bf215546Sopenharmony_ci /* Optimal number for good TexSubImage performance on Polaris10. */ 224bf215546Sopenharmony_ci return 64 * 1024 * 1024; 225bf215546Sopenharmony_ci 226bf215546Sopenharmony_ci case PIPE_CAP_GL_BEGIN_END_BUFFER_SIZE: 227bf215546Sopenharmony_ci return 4096 * 1024; 228bf215546Sopenharmony_ci 229bf215546Sopenharmony_ci case PIPE_CAP_MAX_TEXEL_BUFFER_ELEMENTS_UINT: { 230bf215546Sopenharmony_ci unsigned max_texels = 231bf215546Sopenharmony_ci pscreen->get_param(pscreen, PIPE_CAP_MAX_SHADER_BUFFER_SIZE_UINT); 232bf215546Sopenharmony_ci 233bf215546Sopenharmony_ci /* FYI, BUF_RSRC_WORD2.NUM_RECORDS field limit is UINT32_MAX. */ 234bf215546Sopenharmony_ci 235bf215546Sopenharmony_ci /* Gfx8 and older use the size in bytes for bounds checking, and the max element size 236bf215546Sopenharmony_ci * is 16B. Gfx9 and newer use the VGPR index for bounds checking. 237bf215546Sopenharmony_ci */ 238bf215546Sopenharmony_ci if (sscreen->info.gfx_level <= GFX8) 239bf215546Sopenharmony_ci max_texels = MIN2(max_texels, UINT32_MAX / 16); 240bf215546Sopenharmony_ci else 241bf215546Sopenharmony_ci /* Gallium has a limitation that it can only bind UINT32_MAX bytes, not texels. 242bf215546Sopenharmony_ci * TODO: Remove this after the gallium interface is changed. */ 243bf215546Sopenharmony_ci max_texels = MIN2(max_texels, UINT32_MAX / 16); 244bf215546Sopenharmony_ci 245bf215546Sopenharmony_ci return max_texels; 246bf215546Sopenharmony_ci } 247bf215546Sopenharmony_ci 248bf215546Sopenharmony_ci case PIPE_CAP_MAX_CONSTANT_BUFFER_SIZE_UINT: 249bf215546Sopenharmony_ci case PIPE_CAP_MAX_SHADER_BUFFER_SIZE_UINT: { 250bf215546Sopenharmony_ci /* Return 1/4th of the heap size as the maximum because the max size is not practically 251bf215546Sopenharmony_ci * allocatable. Also, this can only return UINT32_MAX at most. 252bf215546Sopenharmony_ci */ 253bf215546Sopenharmony_ci unsigned max_size = MIN2((sscreen->info.max_heap_size_kb * 1024ull) / 4, UINT32_MAX); 254bf215546Sopenharmony_ci 255bf215546Sopenharmony_ci /* Allow max 512 MB to pass CTS with a 32-bit build. */ 256bf215546Sopenharmony_ci if (sizeof(void*) == 4) 257bf215546Sopenharmony_ci max_size = MIN2(max_size, 512 * 1024 * 1024); 258bf215546Sopenharmony_ci 259bf215546Sopenharmony_ci return max_size; 260bf215546Sopenharmony_ci } 261bf215546Sopenharmony_ci 262bf215546Sopenharmony_ci case PIPE_CAP_MAX_TEXTURE_MB: 263bf215546Sopenharmony_ci /* Allow 1/4th of the heap size. */ 264bf215546Sopenharmony_ci return sscreen->info.max_heap_size_kb / 1024 / 4; 265bf215546Sopenharmony_ci 266bf215546Sopenharmony_ci case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY: 267bf215546Sopenharmony_ci case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY: 268bf215546Sopenharmony_ci case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY: 269bf215546Sopenharmony_ci case PIPE_CAP_PREFER_BACK_BUFFER_REUSE: 270bf215546Sopenharmony_ci return 0; 271bf215546Sopenharmony_ci 272bf215546Sopenharmony_ci case PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE: 273bf215546Sopenharmony_ci return enable_sparse ? RADEON_SPARSE_PAGE_SIZE : 0; 274bf215546Sopenharmony_ci 275bf215546Sopenharmony_ci case PIPE_CAP_UMA: 276bf215546Sopenharmony_ci case PIPE_CAP_PREFER_IMM_ARRAYS_AS_CONSTBUF: 277bf215546Sopenharmony_ci return 0; 278bf215546Sopenharmony_ci 279bf215546Sopenharmony_ci case PIPE_CAP_CONTEXT_PRIORITY_MASK: 280bf215546Sopenharmony_ci if (!(sscreen->info.is_amdgpu && sscreen->info.drm_minor >= 22)) 281bf215546Sopenharmony_ci return 0; 282bf215546Sopenharmony_ci return PIPE_CONTEXT_PRIORITY_LOW | 283bf215546Sopenharmony_ci PIPE_CONTEXT_PRIORITY_MEDIUM | 284bf215546Sopenharmony_ci PIPE_CONTEXT_PRIORITY_HIGH; 285bf215546Sopenharmony_ci 286bf215546Sopenharmony_ci case PIPE_CAP_FENCE_SIGNAL: 287bf215546Sopenharmony_ci return sscreen->info.has_syncobj; 288bf215546Sopenharmony_ci 289bf215546Sopenharmony_ci case PIPE_CAP_CONSTBUF0_FLAGS: 290bf215546Sopenharmony_ci return SI_RESOURCE_FLAG_32BIT; 291bf215546Sopenharmony_ci 292bf215546Sopenharmony_ci case PIPE_CAP_NATIVE_FENCE_FD: 293bf215546Sopenharmony_ci return sscreen->info.has_fence_to_handle; 294bf215546Sopenharmony_ci 295bf215546Sopenharmony_ci case PIPE_CAP_DRAW_PARAMETERS: 296bf215546Sopenharmony_ci case PIPE_CAP_MULTI_DRAW_INDIRECT: 297bf215546Sopenharmony_ci case PIPE_CAP_MULTI_DRAW_INDIRECT_PARAMS: 298bf215546Sopenharmony_ci return sscreen->has_draw_indirect_multi; 299bf215546Sopenharmony_ci 300bf215546Sopenharmony_ci case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS: 301bf215546Sopenharmony_ci return 30; 302bf215546Sopenharmony_ci 303bf215546Sopenharmony_ci case PIPE_CAP_MAX_VARYINGS: 304bf215546Sopenharmony_ci return 32; 305bf215546Sopenharmony_ci 306bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK: 307bf215546Sopenharmony_ci return sscreen->info.gfx_level <= GFX8 ? PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_R600 : 0; 308bf215546Sopenharmony_ci 309bf215546Sopenharmony_ci /* Stream output. */ 310bf215546Sopenharmony_ci case PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS: 311bf215546Sopenharmony_ci case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS: 312bf215546Sopenharmony_ci return 32 * 4; 313bf215546Sopenharmony_ci 314bf215546Sopenharmony_ci /* Geometry shader output. */ 315bf215546Sopenharmony_ci case PIPE_CAP_MAX_GEOMETRY_OUTPUT_VERTICES: 316bf215546Sopenharmony_ci /* gfx9 has to report 256 to make piglit/gs-max-output pass. 317bf215546Sopenharmony_ci * gfx8 and earlier can do 1024. 318bf215546Sopenharmony_ci */ 319bf215546Sopenharmony_ci return 256; 320bf215546Sopenharmony_ci case PIPE_CAP_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS: 321bf215546Sopenharmony_ci return 4095; 322bf215546Sopenharmony_ci case PIPE_CAP_MAX_GS_INVOCATIONS: 323bf215546Sopenharmony_ci /* Even though the hw supports more, we officially wanna expose only 32. */ 324bf215546Sopenharmony_ci return 32; 325bf215546Sopenharmony_ci 326bf215546Sopenharmony_ci case PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE: 327bf215546Sopenharmony_ci return 2048; 328bf215546Sopenharmony_ci 329bf215546Sopenharmony_ci /* Texturing. */ 330bf215546Sopenharmony_ci case PIPE_CAP_MAX_TEXTURE_2D_SIZE: 331bf215546Sopenharmony_ci return 16384; 332bf215546Sopenharmony_ci case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS: 333bf215546Sopenharmony_ci if (!sscreen->info.has_3d_cube_border_color_mipmap) 334bf215546Sopenharmony_ci return 0; 335bf215546Sopenharmony_ci return 15; /* 16384 */ 336bf215546Sopenharmony_ci case PIPE_CAP_MAX_TEXTURE_3D_LEVELS: 337bf215546Sopenharmony_ci if (!sscreen->info.has_3d_cube_border_color_mipmap) 338bf215546Sopenharmony_ci return 0; 339bf215546Sopenharmony_ci if (sscreen->info.gfx_level >= GFX10) 340bf215546Sopenharmony_ci return 14; 341bf215546Sopenharmony_ci /* textures support 8192, but layered rendering supports 2048 */ 342bf215546Sopenharmony_ci return 12; 343bf215546Sopenharmony_ci case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS: 344bf215546Sopenharmony_ci if (sscreen->info.gfx_level >= GFX10) 345bf215546Sopenharmony_ci return 8192; 346bf215546Sopenharmony_ci /* textures support 8192, but layered rendering supports 2048 */ 347bf215546Sopenharmony_ci return 2048; 348bf215546Sopenharmony_ci 349bf215546Sopenharmony_ci /* Sparse texture */ 350bf215546Sopenharmony_ci case PIPE_CAP_MAX_SPARSE_TEXTURE_SIZE: 351bf215546Sopenharmony_ci return enable_sparse ? 352bf215546Sopenharmony_ci si_get_param(pscreen, PIPE_CAP_MAX_TEXTURE_2D_SIZE) : 0; 353bf215546Sopenharmony_ci case PIPE_CAP_MAX_SPARSE_3D_TEXTURE_SIZE: 354bf215546Sopenharmony_ci return enable_sparse ? 355bf215546Sopenharmony_ci (1 << (si_get_param(pscreen, PIPE_CAP_MAX_TEXTURE_3D_LEVELS) - 1)) : 0; 356bf215546Sopenharmony_ci case PIPE_CAP_MAX_SPARSE_ARRAY_TEXTURE_LAYERS: 357bf215546Sopenharmony_ci return enable_sparse ? 358bf215546Sopenharmony_ci si_get_param(pscreen, PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS) : 0; 359bf215546Sopenharmony_ci case PIPE_CAP_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS: 360bf215546Sopenharmony_ci case PIPE_CAP_QUERY_SPARSE_TEXTURE_RESIDENCY: 361bf215546Sopenharmony_ci case PIPE_CAP_CLAMP_SPARSE_TEXTURE_LOD: 362bf215546Sopenharmony_ci return enable_sparse; 363bf215546Sopenharmony_ci 364bf215546Sopenharmony_ci /* Viewports and render targets. */ 365bf215546Sopenharmony_ci case PIPE_CAP_MAX_VIEWPORTS: 366bf215546Sopenharmony_ci return SI_MAX_VIEWPORTS; 367bf215546Sopenharmony_ci case PIPE_CAP_VIEWPORT_SUBPIXEL_BITS: 368bf215546Sopenharmony_ci case PIPE_CAP_RASTERIZER_SUBPIXEL_BITS: 369bf215546Sopenharmony_ci case PIPE_CAP_MAX_RENDER_TARGETS: 370bf215546Sopenharmony_ci return 8; 371bf215546Sopenharmony_ci case PIPE_CAP_FRAMEBUFFER_MSAA_CONSTRAINTS: 372bf215546Sopenharmony_ci return sscreen->info.has_eqaa_surface_allocator ? 2 : 0; 373bf215546Sopenharmony_ci 374bf215546Sopenharmony_ci case PIPE_CAP_MIN_TEXTURE_GATHER_OFFSET: 375bf215546Sopenharmony_ci case PIPE_CAP_MIN_TEXEL_OFFSET: 376bf215546Sopenharmony_ci return -32; 377bf215546Sopenharmony_ci 378bf215546Sopenharmony_ci case PIPE_CAP_MAX_TEXTURE_GATHER_OFFSET: 379bf215546Sopenharmony_ci case PIPE_CAP_MAX_TEXEL_OFFSET: 380bf215546Sopenharmony_ci return 31; 381bf215546Sopenharmony_ci 382bf215546Sopenharmony_ci case PIPE_CAP_ENDIANNESS: 383bf215546Sopenharmony_ci return PIPE_ENDIAN_LITTLE; 384bf215546Sopenharmony_ci 385bf215546Sopenharmony_ci case PIPE_CAP_VENDOR_ID: 386bf215546Sopenharmony_ci return ATI_VENDOR_ID; 387bf215546Sopenharmony_ci case PIPE_CAP_DEVICE_ID: 388bf215546Sopenharmony_ci return sscreen->info.pci_id; 389bf215546Sopenharmony_ci case PIPE_CAP_VIDEO_MEMORY: 390bf215546Sopenharmony_ci return sscreen->info.vram_size_kb >> 10; 391bf215546Sopenharmony_ci case PIPE_CAP_PCI_GROUP: 392bf215546Sopenharmony_ci return sscreen->info.pci_domain; 393bf215546Sopenharmony_ci case PIPE_CAP_PCI_BUS: 394bf215546Sopenharmony_ci return sscreen->info.pci_bus; 395bf215546Sopenharmony_ci case PIPE_CAP_PCI_DEVICE: 396bf215546Sopenharmony_ci return sscreen->info.pci_dev; 397bf215546Sopenharmony_ci case PIPE_CAP_PCI_FUNCTION: 398bf215546Sopenharmony_ci return sscreen->info.pci_func; 399bf215546Sopenharmony_ci 400bf215546Sopenharmony_ci default: 401bf215546Sopenharmony_ci return u_pipe_screen_get_param_defaults(pscreen, param); 402bf215546Sopenharmony_ci } 403bf215546Sopenharmony_ci} 404bf215546Sopenharmony_ci 405bf215546Sopenharmony_cistatic float si_get_paramf(struct pipe_screen *pscreen, enum pipe_capf param) 406bf215546Sopenharmony_ci{ 407bf215546Sopenharmony_ci switch (param) { 408bf215546Sopenharmony_ci case PIPE_CAPF_MIN_LINE_WIDTH: 409bf215546Sopenharmony_ci case PIPE_CAPF_MIN_LINE_WIDTH_AA: 410bf215546Sopenharmony_ci return 1; /* due to axis-aligned end caps at line width 1 */ 411bf215546Sopenharmony_ci case PIPE_CAPF_MIN_POINT_SIZE: 412bf215546Sopenharmony_ci case PIPE_CAPF_MIN_POINT_SIZE_AA: 413bf215546Sopenharmony_ci case PIPE_CAPF_POINT_SIZE_GRANULARITY: 414bf215546Sopenharmony_ci case PIPE_CAPF_LINE_WIDTH_GRANULARITY: 415bf215546Sopenharmony_ci return 1.0 / 8.0; /* due to the register field precision */ 416bf215546Sopenharmony_ci case PIPE_CAPF_MAX_LINE_WIDTH: 417bf215546Sopenharmony_ci case PIPE_CAPF_MAX_LINE_WIDTH_AA: 418bf215546Sopenharmony_ci /* This depends on the quant mode, though the precise interactions 419bf215546Sopenharmony_ci * are unknown. */ 420bf215546Sopenharmony_ci return 2048; 421bf215546Sopenharmony_ci case PIPE_CAPF_MAX_POINT_SIZE: 422bf215546Sopenharmony_ci case PIPE_CAPF_MAX_POINT_SIZE_AA: 423bf215546Sopenharmony_ci return SI_MAX_POINT_SIZE; 424bf215546Sopenharmony_ci case PIPE_CAPF_MAX_TEXTURE_ANISOTROPY: 425bf215546Sopenharmony_ci return 16.0f; 426bf215546Sopenharmony_ci case PIPE_CAPF_MAX_TEXTURE_LOD_BIAS: 427bf215546Sopenharmony_ci return 16.0f; 428bf215546Sopenharmony_ci case PIPE_CAPF_MIN_CONSERVATIVE_RASTER_DILATE: 429bf215546Sopenharmony_ci case PIPE_CAPF_MAX_CONSERVATIVE_RASTER_DILATE: 430bf215546Sopenharmony_ci case PIPE_CAPF_CONSERVATIVE_RASTER_DILATE_GRANULARITY: 431bf215546Sopenharmony_ci return 0.0f; 432bf215546Sopenharmony_ci } 433bf215546Sopenharmony_ci return 0.0f; 434bf215546Sopenharmony_ci} 435bf215546Sopenharmony_ci 436bf215546Sopenharmony_cistatic int si_get_shader_param(struct pipe_screen *pscreen, enum pipe_shader_type shader, 437bf215546Sopenharmony_ci enum pipe_shader_cap param) 438bf215546Sopenharmony_ci{ 439bf215546Sopenharmony_ci struct si_screen *sscreen = (struct si_screen *)pscreen; 440bf215546Sopenharmony_ci 441bf215546Sopenharmony_ci switch (param) { 442bf215546Sopenharmony_ci /* Shader limits. */ 443bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_INSTRUCTIONS: 444bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS: 445bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS: 446bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS: 447bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH: 448bf215546Sopenharmony_ci return 16384; 449bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_INPUTS: 450bf215546Sopenharmony_ci return shader == PIPE_SHADER_VERTEX ? SI_MAX_ATTRIBS : 32; 451bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_OUTPUTS: 452bf215546Sopenharmony_ci return shader == PIPE_SHADER_FRAGMENT ? 8 : 32; 453bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_TEMPS: 454bf215546Sopenharmony_ci return 256; /* Max native temporaries. */ 455bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_CONST_BUFFER0_SIZE: 456bf215546Sopenharmony_ci return 1 << 26; /* 64 MB */ 457bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_CONST_BUFFERS: 458bf215546Sopenharmony_ci return SI_NUM_CONST_BUFFERS; 459bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS: 460bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS: 461bf215546Sopenharmony_ci return SI_NUM_SAMPLERS; 462bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_SHADER_BUFFERS: 463bf215546Sopenharmony_ci return SI_NUM_SHADER_BUFFERS; 464bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_SHADER_IMAGES: 465bf215546Sopenharmony_ci return SI_NUM_IMAGES; 466bf215546Sopenharmony_ci case PIPE_SHADER_CAP_PREFERRED_IR: 467bf215546Sopenharmony_ci return PIPE_SHADER_IR_NIR; 468bf215546Sopenharmony_ci 469bf215546Sopenharmony_ci case PIPE_SHADER_CAP_SUPPORTED_IRS: 470bf215546Sopenharmony_ci if (shader == PIPE_SHADER_COMPUTE) { 471bf215546Sopenharmony_ci return (1 << PIPE_SHADER_IR_NATIVE) | 472bf215546Sopenharmony_ci (1 << PIPE_SHADER_IR_NIR) | 473bf215546Sopenharmony_ci (1 << PIPE_SHADER_IR_TGSI); 474bf215546Sopenharmony_ci } 475bf215546Sopenharmony_ci return (1 << PIPE_SHADER_IR_TGSI) | 476bf215546Sopenharmony_ci (1 << PIPE_SHADER_IR_NIR); 477bf215546Sopenharmony_ci 478bf215546Sopenharmony_ci /* Supported boolean features. */ 479bf215546Sopenharmony_ci case PIPE_SHADER_CAP_CONT_SUPPORTED: 480bf215546Sopenharmony_ci case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED: 481bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR: 482bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR: 483bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INTEGERS: 484bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INT64_ATOMICS: 485bf215546Sopenharmony_ci case PIPE_SHADER_CAP_TGSI_ANY_INOUT_DECL_RANGE: 486bf215546Sopenharmony_ci case PIPE_SHADER_CAP_DROUND_SUPPORTED: 487bf215546Sopenharmony_ci case PIPE_SHADER_CAP_LDEXP_SUPPORTED: 488bf215546Sopenharmony_ci case PIPE_SHADER_CAP_DFRACEXP_DLDEXP_SUPPORTED: 489bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR: /* lowered in finalize_nir */ 490bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR: /* lowered in finalize_nir */ 491bf215546Sopenharmony_ci return 1; 492bf215546Sopenharmony_ci 493bf215546Sopenharmony_ci case PIPE_SHADER_CAP_FP16_CONST_BUFFERS: 494bf215546Sopenharmony_ci /* We need f16c for fast FP16 conversions in glUniform. */ 495bf215546Sopenharmony_ci if (!util_get_cpu_caps()->has_f16c) 496bf215546Sopenharmony_ci return 0; 497bf215546Sopenharmony_ci FALLTHROUGH; 498bf215546Sopenharmony_ci case PIPE_SHADER_CAP_FP16: 499bf215546Sopenharmony_ci case PIPE_SHADER_CAP_FP16_DERIVATIVES: 500bf215546Sopenharmony_ci case PIPE_SHADER_CAP_GLSL_16BIT_CONSTS: 501bf215546Sopenharmony_ci return sscreen->info.gfx_level >= GFX8 && sscreen->options.fp16; 502bf215546Sopenharmony_ci 503bf215546Sopenharmony_ci /* Unsupported boolean features. */ 504bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INT16: 505bf215546Sopenharmony_ci case PIPE_SHADER_CAP_SUBROUTINES: 506bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTERS: 507bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTER_BUFFERS: 508bf215546Sopenharmony_ci return 0; 509bf215546Sopenharmony_ci } 510bf215546Sopenharmony_ci return 0; 511bf215546Sopenharmony_ci} 512bf215546Sopenharmony_ci 513bf215546Sopenharmony_cistatic const void *si_get_compiler_options(struct pipe_screen *screen, enum pipe_shader_ir ir, 514bf215546Sopenharmony_ci enum pipe_shader_type shader) 515bf215546Sopenharmony_ci{ 516bf215546Sopenharmony_ci struct si_screen *sscreen = (struct si_screen *)screen; 517bf215546Sopenharmony_ci 518bf215546Sopenharmony_ci assert(ir == PIPE_SHADER_IR_NIR); 519bf215546Sopenharmony_ci return &sscreen->nir_options; 520bf215546Sopenharmony_ci} 521bf215546Sopenharmony_ci 522bf215546Sopenharmony_cistatic void si_get_driver_uuid(struct pipe_screen *pscreen, char *uuid) 523bf215546Sopenharmony_ci{ 524bf215546Sopenharmony_ci ac_compute_driver_uuid(uuid, PIPE_UUID_SIZE); 525bf215546Sopenharmony_ci} 526bf215546Sopenharmony_ci 527bf215546Sopenharmony_cistatic void si_get_device_uuid(struct pipe_screen *pscreen, char *uuid) 528bf215546Sopenharmony_ci{ 529bf215546Sopenharmony_ci struct si_screen *sscreen = (struct si_screen *)pscreen; 530bf215546Sopenharmony_ci 531bf215546Sopenharmony_ci ac_compute_device_uuid(&sscreen->info, uuid, PIPE_UUID_SIZE); 532bf215546Sopenharmony_ci} 533bf215546Sopenharmony_ci 534bf215546Sopenharmony_cistatic const char *si_get_name(struct pipe_screen *pscreen) 535bf215546Sopenharmony_ci{ 536bf215546Sopenharmony_ci struct si_screen *sscreen = (struct si_screen *)pscreen; 537bf215546Sopenharmony_ci 538bf215546Sopenharmony_ci return sscreen->renderer_string; 539bf215546Sopenharmony_ci} 540bf215546Sopenharmony_ci 541bf215546Sopenharmony_cistatic int si_get_video_param_no_video_hw(struct pipe_screen *screen, enum pipe_video_profile profile, 542bf215546Sopenharmony_ci enum pipe_video_entrypoint entrypoint, 543bf215546Sopenharmony_ci enum pipe_video_cap param) 544bf215546Sopenharmony_ci{ 545bf215546Sopenharmony_ci switch (param) { 546bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_SUPPORTED: 547bf215546Sopenharmony_ci return vl_profile_supported(screen, profile, entrypoint); 548bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_NPOT_TEXTURES: 549bf215546Sopenharmony_ci return 1; 550bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_MAX_WIDTH: 551bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_MAX_HEIGHT: 552bf215546Sopenharmony_ci return vl_video_buffer_max_size(screen); 553bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_PREFERED_FORMAT: 554bf215546Sopenharmony_ci return PIPE_FORMAT_NV12; 555bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_PREFERS_INTERLACED: 556bf215546Sopenharmony_ci return false; 557bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_SUPPORTS_INTERLACED: 558bf215546Sopenharmony_ci return false; 559bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_SUPPORTS_PROGRESSIVE: 560bf215546Sopenharmony_ci return true; 561bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_MAX_LEVEL: 562bf215546Sopenharmony_ci return vl_level_supported(screen, profile); 563bf215546Sopenharmony_ci default: 564bf215546Sopenharmony_ci return 0; 565bf215546Sopenharmony_ci } 566bf215546Sopenharmony_ci} 567bf215546Sopenharmony_ci 568bf215546Sopenharmony_cistatic int si_get_video_param(struct pipe_screen *screen, enum pipe_video_profile profile, 569bf215546Sopenharmony_ci enum pipe_video_entrypoint entrypoint, enum pipe_video_cap param) 570bf215546Sopenharmony_ci{ 571bf215546Sopenharmony_ci struct si_screen *sscreen = (struct si_screen *)screen; 572bf215546Sopenharmony_ci enum pipe_video_format codec = u_reduce_video_profile(profile); 573bf215546Sopenharmony_ci 574bf215546Sopenharmony_ci if (entrypoint == PIPE_VIDEO_ENTRYPOINT_ENCODE) { 575bf215546Sopenharmony_ci if (!(sscreen->info.ip[AMD_IP_VCE].num_queues || 576bf215546Sopenharmony_ci sscreen->info.ip[AMD_IP_UVD_ENC].num_queues || 577bf215546Sopenharmony_ci sscreen->info.ip[AMD_IP_VCN_ENC].num_queues)) 578bf215546Sopenharmony_ci return 0; 579bf215546Sopenharmony_ci 580bf215546Sopenharmony_ci switch (param) { 581bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_SUPPORTED: 582bf215546Sopenharmony_ci return ( 583bf215546Sopenharmony_ci (codec == PIPE_VIDEO_FORMAT_MPEG4_AVC && 584bf215546Sopenharmony_ci (sscreen->info.family >= CHIP_RAVEN || si_vce_is_fw_version_supported(sscreen))) || 585bf215546Sopenharmony_ci (profile == PIPE_VIDEO_PROFILE_HEVC_MAIN && 586bf215546Sopenharmony_ci (sscreen->info.family >= CHIP_RAVEN || si_radeon_uvd_enc_supported(sscreen))) || 587bf215546Sopenharmony_ci (profile == PIPE_VIDEO_PROFILE_HEVC_MAIN_10 && sscreen->info.family >= CHIP_RENOIR)); 588bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_NPOT_TEXTURES: 589bf215546Sopenharmony_ci return 1; 590bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_MAX_WIDTH: 591bf215546Sopenharmony_ci if (codec != PIPE_VIDEO_FORMAT_UNKNOWN && 592bf215546Sopenharmony_ci sscreen->info.enc_caps.codec_info[codec - 1].valid) 593bf215546Sopenharmony_ci return sscreen->info.enc_caps.codec_info[codec - 1].max_width; 594bf215546Sopenharmony_ci else 595bf215546Sopenharmony_ci return (sscreen->info.family < CHIP_TONGA) ? 2048 : 4096; 596bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_MAX_HEIGHT: 597bf215546Sopenharmony_ci if (codec != PIPE_VIDEO_FORMAT_UNKNOWN && 598bf215546Sopenharmony_ci sscreen->info.enc_caps.codec_info[codec - 1].valid) 599bf215546Sopenharmony_ci return sscreen->info.enc_caps.codec_info[codec - 1].max_height; 600bf215546Sopenharmony_ci else 601bf215546Sopenharmony_ci return (sscreen->info.family < CHIP_TONGA) ? 1152 : 2304; 602bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_PREFERED_FORMAT: 603bf215546Sopenharmony_ci if (profile == PIPE_VIDEO_PROFILE_HEVC_MAIN_10) 604bf215546Sopenharmony_ci return PIPE_FORMAT_P010; 605bf215546Sopenharmony_ci else 606bf215546Sopenharmony_ci return PIPE_FORMAT_NV12; 607bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_PREFERS_INTERLACED: 608bf215546Sopenharmony_ci return false; 609bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_SUPPORTS_INTERLACED: 610bf215546Sopenharmony_ci return false; 611bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_SUPPORTS_PROGRESSIVE: 612bf215546Sopenharmony_ci return true; 613bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_STACKED_FRAMES: 614bf215546Sopenharmony_ci return (sscreen->info.family < CHIP_TONGA) ? 1 : 2; 615bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_MAX_TEMPORAL_LAYERS: 616bf215546Sopenharmony_ci if (codec == PIPE_VIDEO_FORMAT_MPEG4_AVC && 617bf215546Sopenharmony_ci sscreen->info.family >= CHIP_RAVEN) 618bf215546Sopenharmony_ci return 4; 619bf215546Sopenharmony_ci else 620bf215546Sopenharmony_ci return 0; 621bf215546Sopenharmony_ci default: 622bf215546Sopenharmony_ci return 0; 623bf215546Sopenharmony_ci } 624bf215546Sopenharmony_ci } 625bf215546Sopenharmony_ci 626bf215546Sopenharmony_ci switch (param) { 627bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_SUPPORTED: 628bf215546Sopenharmony_ci if (codec < PIPE_VIDEO_FORMAT_MPEG4_AVC && 629bf215546Sopenharmony_ci sscreen->info.family >= CHIP_NAVI24) 630bf215546Sopenharmony_ci return false; 631bf215546Sopenharmony_ci if (codec != PIPE_VIDEO_FORMAT_JPEG && 632bf215546Sopenharmony_ci !(sscreen->info.ip[AMD_IP_UVD].num_queues || 633bf215546Sopenharmony_ci sscreen->info.has_video_hw.vcn_decode)) 634bf215546Sopenharmony_ci return false; 635bf215546Sopenharmony_ci 636bf215546Sopenharmony_ci switch (codec) { 637bf215546Sopenharmony_ci case PIPE_VIDEO_FORMAT_MPEG12: 638bf215546Sopenharmony_ci if (sscreen->info.gfx_level >= GFX11) 639bf215546Sopenharmony_ci return false; 640bf215546Sopenharmony_ci else 641bf215546Sopenharmony_ci return profile != PIPE_VIDEO_PROFILE_MPEG1; 642bf215546Sopenharmony_ci case PIPE_VIDEO_FORMAT_MPEG4: 643bf215546Sopenharmony_ci if (sscreen->info.gfx_level >= GFX11) 644bf215546Sopenharmony_ci return false; 645bf215546Sopenharmony_ci else 646bf215546Sopenharmony_ci return true; 647bf215546Sopenharmony_ci case PIPE_VIDEO_FORMAT_MPEG4_AVC: 648bf215546Sopenharmony_ci if ((sscreen->info.family == CHIP_POLARIS10 || sscreen->info.family == CHIP_POLARIS11) && 649bf215546Sopenharmony_ci sscreen->info.uvd_fw_version < UVD_FW_1_66_16) { 650bf215546Sopenharmony_ci RVID_ERR("POLARIS10/11 firmware version need to be updated.\n"); 651bf215546Sopenharmony_ci return false; 652bf215546Sopenharmony_ci } 653bf215546Sopenharmony_ci return true; 654bf215546Sopenharmony_ci case PIPE_VIDEO_FORMAT_VC1: 655bf215546Sopenharmony_ci if (sscreen->info.gfx_level >= GFX11) 656bf215546Sopenharmony_ci return false; 657bf215546Sopenharmony_ci else 658bf215546Sopenharmony_ci return true; 659bf215546Sopenharmony_ci case PIPE_VIDEO_FORMAT_HEVC: 660bf215546Sopenharmony_ci /* Carrizo only supports HEVC Main */ 661bf215546Sopenharmony_ci if (sscreen->info.family >= CHIP_STONEY) 662bf215546Sopenharmony_ci return (profile == PIPE_VIDEO_PROFILE_HEVC_MAIN || 663bf215546Sopenharmony_ci profile == PIPE_VIDEO_PROFILE_HEVC_MAIN_10); 664bf215546Sopenharmony_ci else if (sscreen->info.family >= CHIP_CARRIZO) 665bf215546Sopenharmony_ci return profile == PIPE_VIDEO_PROFILE_HEVC_MAIN; 666bf215546Sopenharmony_ci return false; 667bf215546Sopenharmony_ci case PIPE_VIDEO_FORMAT_JPEG: 668bf215546Sopenharmony_ci if (sscreen->info.family >= CHIP_RAVEN) { 669bf215546Sopenharmony_ci if (!sscreen->info.ip[AMD_IP_VCN_JPEG].num_queues) 670bf215546Sopenharmony_ci return false; 671bf215546Sopenharmony_ci else 672bf215546Sopenharmony_ci return true; 673bf215546Sopenharmony_ci } 674bf215546Sopenharmony_ci if (sscreen->info.family < CHIP_CARRIZO || sscreen->info.family >= CHIP_VEGA10) 675bf215546Sopenharmony_ci return false; 676bf215546Sopenharmony_ci if (!(sscreen->info.is_amdgpu && sscreen->info.drm_minor >= 19)) { 677bf215546Sopenharmony_ci RVID_ERR("No MJPEG support for the kernel version\n"); 678bf215546Sopenharmony_ci return false; 679bf215546Sopenharmony_ci } 680bf215546Sopenharmony_ci return true; 681bf215546Sopenharmony_ci case PIPE_VIDEO_FORMAT_VP9: 682bf215546Sopenharmony_ci if (sscreen->info.family < CHIP_RAVEN) 683bf215546Sopenharmony_ci return false; 684bf215546Sopenharmony_ci return true; 685bf215546Sopenharmony_ci case PIPE_VIDEO_FORMAT_AV1: 686bf215546Sopenharmony_ci if (sscreen->info.family < CHIP_NAVI21) 687bf215546Sopenharmony_ci return false; 688bf215546Sopenharmony_ci return true; 689bf215546Sopenharmony_ci default: 690bf215546Sopenharmony_ci return false; 691bf215546Sopenharmony_ci } 692bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_NPOT_TEXTURES: 693bf215546Sopenharmony_ci return 1; 694bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_MAX_WIDTH: 695bf215546Sopenharmony_ci if (codec != PIPE_VIDEO_FORMAT_UNKNOWN && 696bf215546Sopenharmony_ci sscreen->info.dec_caps.codec_info[codec - 1].valid) { 697bf215546Sopenharmony_ci return sscreen->info.dec_caps.codec_info[codec - 1].max_width; 698bf215546Sopenharmony_ci } else { 699bf215546Sopenharmony_ci switch (codec) { 700bf215546Sopenharmony_ci case PIPE_VIDEO_FORMAT_HEVC: 701bf215546Sopenharmony_ci case PIPE_VIDEO_FORMAT_VP9: 702bf215546Sopenharmony_ci case PIPE_VIDEO_FORMAT_AV1: 703bf215546Sopenharmony_ci return (sscreen->info.family < CHIP_RENOIR) ? 704bf215546Sopenharmony_ci ((sscreen->info.family < CHIP_TONGA) ? 2048 : 4096) : 8192; 705bf215546Sopenharmony_ci default: 706bf215546Sopenharmony_ci return (sscreen->info.family < CHIP_TONGA) ? 2048 : 4096; 707bf215546Sopenharmony_ci } 708bf215546Sopenharmony_ci } 709bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_MAX_HEIGHT: 710bf215546Sopenharmony_ci if (codec != PIPE_VIDEO_FORMAT_UNKNOWN && 711bf215546Sopenharmony_ci sscreen->info.dec_caps.codec_info[codec - 1].valid) { 712bf215546Sopenharmony_ci return sscreen->info.dec_caps.codec_info[codec - 1].max_height; 713bf215546Sopenharmony_ci } else { 714bf215546Sopenharmony_ci switch (codec) { 715bf215546Sopenharmony_ci case PIPE_VIDEO_FORMAT_HEVC: 716bf215546Sopenharmony_ci case PIPE_VIDEO_FORMAT_VP9: 717bf215546Sopenharmony_ci case PIPE_VIDEO_FORMAT_AV1: 718bf215546Sopenharmony_ci return (sscreen->info.family < CHIP_RENOIR) ? 719bf215546Sopenharmony_ci ((sscreen->info.family < CHIP_TONGA) ? 1152 : 4096) : 4352; 720bf215546Sopenharmony_ci default: 721bf215546Sopenharmony_ci return (sscreen->info.family < CHIP_TONGA) ? 1152 : 4096; 722bf215546Sopenharmony_ci } 723bf215546Sopenharmony_ci } 724bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_PREFERED_FORMAT: 725bf215546Sopenharmony_ci if (profile == PIPE_VIDEO_PROFILE_HEVC_MAIN_10) 726bf215546Sopenharmony_ci return PIPE_FORMAT_P010; 727bf215546Sopenharmony_ci else if (profile == PIPE_VIDEO_PROFILE_VP9_PROFILE2) 728bf215546Sopenharmony_ci return PIPE_FORMAT_P010; 729bf215546Sopenharmony_ci else 730bf215546Sopenharmony_ci return PIPE_FORMAT_NV12; 731bf215546Sopenharmony_ci 732bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_PREFERS_INTERLACED: 733bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_SUPPORTS_INTERLACED: { 734bf215546Sopenharmony_ci enum pipe_video_format format = u_reduce_video_profile(profile); 735bf215546Sopenharmony_ci 736bf215546Sopenharmony_ci if (format >= PIPE_VIDEO_FORMAT_HEVC) 737bf215546Sopenharmony_ci return false; 738bf215546Sopenharmony_ci return true; 739bf215546Sopenharmony_ci } 740bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_SUPPORTS_PROGRESSIVE: 741bf215546Sopenharmony_ci return true; 742bf215546Sopenharmony_ci case PIPE_VIDEO_CAP_MAX_LEVEL: 743bf215546Sopenharmony_ci if ((profile == PIPE_VIDEO_PROFILE_MPEG2_SIMPLE || 744bf215546Sopenharmony_ci profile == PIPE_VIDEO_PROFILE_MPEG2_MAIN || 745bf215546Sopenharmony_ci profile == PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE || 746bf215546Sopenharmony_ci profile == PIPE_VIDEO_PROFILE_VC1_ADVANCED) && 747bf215546Sopenharmony_ci sscreen->info.dec_caps.codec_info[codec - 1].valid) { 748bf215546Sopenharmony_ci return sscreen->info.dec_caps.codec_info[codec - 1].max_level; 749bf215546Sopenharmony_ci } else { 750bf215546Sopenharmony_ci switch (profile) { 751bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_MPEG1: 752bf215546Sopenharmony_ci return 0; 753bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE: 754bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_MPEG2_MAIN: 755bf215546Sopenharmony_ci return 3; 756bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_MPEG4_SIMPLE: 757bf215546Sopenharmony_ci return 3; 758bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE: 759bf215546Sopenharmony_ci return 5; 760bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_VC1_SIMPLE: 761bf215546Sopenharmony_ci return 1; 762bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_VC1_MAIN: 763bf215546Sopenharmony_ci return 2; 764bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_VC1_ADVANCED: 765bf215546Sopenharmony_ci return 4; 766bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE: 767bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN: 768bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH: 769bf215546Sopenharmony_ci return (sscreen->info.family < CHIP_TONGA) ? 41 : 52; 770bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_HEVC_MAIN: 771bf215546Sopenharmony_ci case PIPE_VIDEO_PROFILE_HEVC_MAIN_10: 772bf215546Sopenharmony_ci return 186; 773bf215546Sopenharmony_ci default: 774bf215546Sopenharmony_ci return 0; 775bf215546Sopenharmony_ci } 776bf215546Sopenharmony_ci } 777bf215546Sopenharmony_ci default: 778bf215546Sopenharmony_ci return 0; 779bf215546Sopenharmony_ci } 780bf215546Sopenharmony_ci} 781bf215546Sopenharmony_ci 782bf215546Sopenharmony_cistatic bool si_vid_is_format_supported(struct pipe_screen *screen, enum pipe_format format, 783bf215546Sopenharmony_ci enum pipe_video_profile profile, 784bf215546Sopenharmony_ci enum pipe_video_entrypoint entrypoint) 785bf215546Sopenharmony_ci{ 786bf215546Sopenharmony_ci /* HEVC 10 bit decoding should use P010 instead of NV12 if possible */ 787bf215546Sopenharmony_ci if (profile == PIPE_VIDEO_PROFILE_HEVC_MAIN_10) 788bf215546Sopenharmony_ci return (format == PIPE_FORMAT_NV12) || (format == PIPE_FORMAT_P010) || 789bf215546Sopenharmony_ci (format == PIPE_FORMAT_P016); 790bf215546Sopenharmony_ci 791bf215546Sopenharmony_ci /* Vp9 profile 2 supports 10 bit decoding using P016 */ 792bf215546Sopenharmony_ci if (profile == PIPE_VIDEO_PROFILE_VP9_PROFILE2) 793bf215546Sopenharmony_ci return (format == PIPE_FORMAT_P010) || (format == PIPE_FORMAT_P016); 794bf215546Sopenharmony_ci 795bf215546Sopenharmony_ci /* we can only handle this one with UVD */ 796bf215546Sopenharmony_ci if (profile != PIPE_VIDEO_PROFILE_UNKNOWN) 797bf215546Sopenharmony_ci return format == PIPE_FORMAT_NV12; 798bf215546Sopenharmony_ci 799bf215546Sopenharmony_ci return vl_video_buffer_is_format_supported(screen, format, profile, entrypoint); 800bf215546Sopenharmony_ci} 801bf215546Sopenharmony_ci 802bf215546Sopenharmony_cistatic unsigned get_max_threads_per_block(struct si_screen *screen, enum pipe_shader_ir ir_type) 803bf215546Sopenharmony_ci{ 804bf215546Sopenharmony_ci if (ir_type == PIPE_SHADER_IR_NATIVE) 805bf215546Sopenharmony_ci return 256; 806bf215546Sopenharmony_ci 807bf215546Sopenharmony_ci /* LLVM only supports 1024 threads per block. */ 808bf215546Sopenharmony_ci return 1024; 809bf215546Sopenharmony_ci} 810bf215546Sopenharmony_ci 811bf215546Sopenharmony_cistatic int si_get_compute_param(struct pipe_screen *screen, enum pipe_shader_ir ir_type, 812bf215546Sopenharmony_ci enum pipe_compute_cap param, void *ret) 813bf215546Sopenharmony_ci{ 814bf215546Sopenharmony_ci struct si_screen *sscreen = (struct si_screen *)screen; 815bf215546Sopenharmony_ci 816bf215546Sopenharmony_ci // TODO: select these params by asic 817bf215546Sopenharmony_ci switch (param) { 818bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_IR_TARGET: { 819bf215546Sopenharmony_ci const char *gpu, *triple; 820bf215546Sopenharmony_ci 821bf215546Sopenharmony_ci triple = "amdgcn-mesa-mesa3d"; 822bf215546Sopenharmony_ci gpu = ac_get_llvm_processor_name(sscreen->info.family); 823bf215546Sopenharmony_ci if (ret) { 824bf215546Sopenharmony_ci sprintf(ret, "%s-%s", gpu, triple); 825bf215546Sopenharmony_ci } 826bf215546Sopenharmony_ci /* +2 for dash and terminating NIL byte */ 827bf215546Sopenharmony_ci return (strlen(triple) + strlen(gpu) + 2) * sizeof(char); 828bf215546Sopenharmony_ci } 829bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_GRID_DIMENSION: 830bf215546Sopenharmony_ci if (ret) { 831bf215546Sopenharmony_ci uint64_t *grid_dimension = ret; 832bf215546Sopenharmony_ci grid_dimension[0] = 3; 833bf215546Sopenharmony_ci } 834bf215546Sopenharmony_ci return 1 * sizeof(uint64_t); 835bf215546Sopenharmony_ci 836bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_MAX_GRID_SIZE: 837bf215546Sopenharmony_ci if (ret) { 838bf215546Sopenharmony_ci uint64_t *grid_size = ret; 839bf215546Sopenharmony_ci grid_size[0] = UINT32_MAX; 840bf215546Sopenharmony_ci grid_size[1] = UINT32_MAX; 841bf215546Sopenharmony_ci grid_size[2] = UINT32_MAX; 842bf215546Sopenharmony_ci } 843bf215546Sopenharmony_ci return 3 * sizeof(uint64_t); 844bf215546Sopenharmony_ci 845bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE: 846bf215546Sopenharmony_ci if (ret) { 847bf215546Sopenharmony_ci uint64_t *block_size = ret; 848bf215546Sopenharmony_ci unsigned threads_per_block = get_max_threads_per_block(sscreen, ir_type); 849bf215546Sopenharmony_ci block_size[0] = threads_per_block; 850bf215546Sopenharmony_ci block_size[1] = threads_per_block; 851bf215546Sopenharmony_ci block_size[2] = threads_per_block; 852bf215546Sopenharmony_ci } 853bf215546Sopenharmony_ci return 3 * sizeof(uint64_t); 854bf215546Sopenharmony_ci 855bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_MAX_THREADS_PER_BLOCK: 856bf215546Sopenharmony_ci if (ret) { 857bf215546Sopenharmony_ci uint64_t *max_threads_per_block = ret; 858bf215546Sopenharmony_ci *max_threads_per_block = get_max_threads_per_block(sscreen, ir_type); 859bf215546Sopenharmony_ci } 860bf215546Sopenharmony_ci return sizeof(uint64_t); 861bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_ADDRESS_BITS: 862bf215546Sopenharmony_ci if (ret) { 863bf215546Sopenharmony_ci uint32_t *address_bits = ret; 864bf215546Sopenharmony_ci address_bits[0] = 64; 865bf215546Sopenharmony_ci } 866bf215546Sopenharmony_ci return 1 * sizeof(uint32_t); 867bf215546Sopenharmony_ci 868bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE: 869bf215546Sopenharmony_ci if (ret) { 870bf215546Sopenharmony_ci uint64_t *max_global_size = ret; 871bf215546Sopenharmony_ci uint64_t max_mem_alloc_size; 872bf215546Sopenharmony_ci 873bf215546Sopenharmony_ci si_get_compute_param(screen, ir_type, PIPE_COMPUTE_CAP_MAX_MEM_ALLOC_SIZE, 874bf215546Sopenharmony_ci &max_mem_alloc_size); 875bf215546Sopenharmony_ci 876bf215546Sopenharmony_ci /* In OpenCL, the MAX_MEM_ALLOC_SIZE must be at least 877bf215546Sopenharmony_ci * 1/4 of the MAX_GLOBAL_SIZE. Since the 878bf215546Sopenharmony_ci * MAX_MEM_ALLOC_SIZE is fixed for older kernels, 879bf215546Sopenharmony_ci * make sure we never report more than 880bf215546Sopenharmony_ci * 4 * MAX_MEM_ALLOC_SIZE. 881bf215546Sopenharmony_ci */ 882bf215546Sopenharmony_ci *max_global_size = 883bf215546Sopenharmony_ci MIN2(4 * max_mem_alloc_size, sscreen->info.max_heap_size_kb * 1024ull); 884bf215546Sopenharmony_ci } 885bf215546Sopenharmony_ci return sizeof(uint64_t); 886bf215546Sopenharmony_ci 887bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_MAX_LOCAL_SIZE: 888bf215546Sopenharmony_ci if (ret) { 889bf215546Sopenharmony_ci uint64_t *max_local_size = ret; 890bf215546Sopenharmony_ci /* Value reported by the closed source driver. */ 891bf215546Sopenharmony_ci if (sscreen->info.gfx_level == GFX6) 892bf215546Sopenharmony_ci *max_local_size = 32 * 1024; 893bf215546Sopenharmony_ci else 894bf215546Sopenharmony_ci *max_local_size = 64 * 1024; 895bf215546Sopenharmony_ci } 896bf215546Sopenharmony_ci return sizeof(uint64_t); 897bf215546Sopenharmony_ci 898bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_MAX_INPUT_SIZE: 899bf215546Sopenharmony_ci if (ret) { 900bf215546Sopenharmony_ci uint64_t *max_input_size = ret; 901bf215546Sopenharmony_ci /* Value reported by the closed source driver. */ 902bf215546Sopenharmony_ci *max_input_size = 1024; 903bf215546Sopenharmony_ci } 904bf215546Sopenharmony_ci return sizeof(uint64_t); 905bf215546Sopenharmony_ci 906bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_MAX_MEM_ALLOC_SIZE: 907bf215546Sopenharmony_ci if (ret) { 908bf215546Sopenharmony_ci uint64_t *max_mem_alloc_size = ret; 909bf215546Sopenharmony_ci 910bf215546Sopenharmony_ci /* Return 1/4 of the heap size as the maximum because the max size is not practically 911bf215546Sopenharmony_ci * allocatable. 912bf215546Sopenharmony_ci */ 913bf215546Sopenharmony_ci *max_mem_alloc_size = (sscreen->info.max_heap_size_kb / 4) * 1024ull; 914bf215546Sopenharmony_ci } 915bf215546Sopenharmony_ci return sizeof(uint64_t); 916bf215546Sopenharmony_ci 917bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_MAX_CLOCK_FREQUENCY: 918bf215546Sopenharmony_ci if (ret) { 919bf215546Sopenharmony_ci uint32_t *max_clock_frequency = ret; 920bf215546Sopenharmony_ci *max_clock_frequency = sscreen->info.max_gpu_freq_mhz; 921bf215546Sopenharmony_ci } 922bf215546Sopenharmony_ci return sizeof(uint32_t); 923bf215546Sopenharmony_ci 924bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_MAX_COMPUTE_UNITS: 925bf215546Sopenharmony_ci if (ret) { 926bf215546Sopenharmony_ci uint32_t *max_compute_units = ret; 927bf215546Sopenharmony_ci *max_compute_units = sscreen->info.num_cu; 928bf215546Sopenharmony_ci } 929bf215546Sopenharmony_ci return sizeof(uint32_t); 930bf215546Sopenharmony_ci 931bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_IMAGES_SUPPORTED: 932bf215546Sopenharmony_ci if (ret) { 933bf215546Sopenharmony_ci uint32_t *images_supported = ret; 934bf215546Sopenharmony_ci *images_supported = 0; 935bf215546Sopenharmony_ci } 936bf215546Sopenharmony_ci return sizeof(uint32_t); 937bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_MAX_PRIVATE_SIZE: 938bf215546Sopenharmony_ci break; /* unused */ 939bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_SUBGROUP_SIZE: 940bf215546Sopenharmony_ci if (ret) { 941bf215546Sopenharmony_ci uint32_t *subgroup_size = ret; 942bf215546Sopenharmony_ci *subgroup_size = si_determine_wave_size(sscreen, NULL); 943bf215546Sopenharmony_ci } 944bf215546Sopenharmony_ci return sizeof(uint32_t); 945bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_MAX_VARIABLE_THREADS_PER_BLOCK: 946bf215546Sopenharmony_ci if (ret) { 947bf215546Sopenharmony_ci uint64_t *max_variable_threads_per_block = ret; 948bf215546Sopenharmony_ci if (ir_type == PIPE_SHADER_IR_NATIVE) 949bf215546Sopenharmony_ci *max_variable_threads_per_block = 0; 950bf215546Sopenharmony_ci else 951bf215546Sopenharmony_ci *max_variable_threads_per_block = SI_MAX_VARIABLE_THREADS_PER_BLOCK; 952bf215546Sopenharmony_ci } 953bf215546Sopenharmony_ci return sizeof(uint64_t); 954bf215546Sopenharmony_ci } 955bf215546Sopenharmony_ci 956bf215546Sopenharmony_ci fprintf(stderr, "unknown PIPE_COMPUTE_CAP %d\n", param); 957bf215546Sopenharmony_ci return 0; 958bf215546Sopenharmony_ci} 959bf215546Sopenharmony_ci 960bf215546Sopenharmony_cistatic uint64_t si_get_timestamp(struct pipe_screen *screen) 961bf215546Sopenharmony_ci{ 962bf215546Sopenharmony_ci struct si_screen *sscreen = (struct si_screen *)screen; 963bf215546Sopenharmony_ci 964bf215546Sopenharmony_ci return 1000000 * sscreen->ws->query_value(sscreen->ws, RADEON_TIMESTAMP) / 965bf215546Sopenharmony_ci sscreen->info.clock_crystal_freq; 966bf215546Sopenharmony_ci} 967bf215546Sopenharmony_ci 968bf215546Sopenharmony_cistatic void si_query_memory_info(struct pipe_screen *screen, struct pipe_memory_info *info) 969bf215546Sopenharmony_ci{ 970bf215546Sopenharmony_ci struct si_screen *sscreen = (struct si_screen *)screen; 971bf215546Sopenharmony_ci struct radeon_winsys *ws = sscreen->ws; 972bf215546Sopenharmony_ci unsigned vram_usage, gtt_usage; 973bf215546Sopenharmony_ci 974bf215546Sopenharmony_ci info->total_device_memory = sscreen->info.vram_size_kb; 975bf215546Sopenharmony_ci info->total_staging_memory = sscreen->info.gart_size_kb; 976bf215546Sopenharmony_ci 977bf215546Sopenharmony_ci /* The real TTM memory usage is somewhat random, because: 978bf215546Sopenharmony_ci * 979bf215546Sopenharmony_ci * 1) TTM delays freeing memory, because it can only free it after 980bf215546Sopenharmony_ci * fences expire. 981bf215546Sopenharmony_ci * 982bf215546Sopenharmony_ci * 2) The memory usage can be really low if big VRAM evictions are 983bf215546Sopenharmony_ci * taking place, but the real usage is well above the size of VRAM. 984bf215546Sopenharmony_ci * 985bf215546Sopenharmony_ci * Instead, return statistics of this process. 986bf215546Sopenharmony_ci */ 987bf215546Sopenharmony_ci vram_usage = ws->query_value(ws, RADEON_VRAM_USAGE) / 1024; 988bf215546Sopenharmony_ci gtt_usage = ws->query_value(ws, RADEON_GTT_USAGE) / 1024; 989bf215546Sopenharmony_ci 990bf215546Sopenharmony_ci info->avail_device_memory = 991bf215546Sopenharmony_ci vram_usage <= info->total_device_memory ? info->total_device_memory - vram_usage : 0; 992bf215546Sopenharmony_ci info->avail_staging_memory = 993bf215546Sopenharmony_ci gtt_usage <= info->total_staging_memory ? info->total_staging_memory - gtt_usage : 0; 994bf215546Sopenharmony_ci 995bf215546Sopenharmony_ci info->device_memory_evicted = ws->query_value(ws, RADEON_NUM_BYTES_MOVED) / 1024; 996bf215546Sopenharmony_ci 997bf215546Sopenharmony_ci if (sscreen->info.is_amdgpu) 998bf215546Sopenharmony_ci info->nr_device_memory_evictions = ws->query_value(ws, RADEON_NUM_EVICTIONS); 999bf215546Sopenharmony_ci else 1000bf215546Sopenharmony_ci /* Just return the number of evicted 64KB pages. */ 1001bf215546Sopenharmony_ci info->nr_device_memory_evictions = info->device_memory_evicted / 64; 1002bf215546Sopenharmony_ci} 1003bf215546Sopenharmony_ci 1004bf215546Sopenharmony_cistatic struct disk_cache *si_get_disk_shader_cache(struct pipe_screen *pscreen) 1005bf215546Sopenharmony_ci{ 1006bf215546Sopenharmony_ci struct si_screen *sscreen = (struct si_screen *)pscreen; 1007bf215546Sopenharmony_ci 1008bf215546Sopenharmony_ci return sscreen->disk_shader_cache; 1009bf215546Sopenharmony_ci} 1010bf215546Sopenharmony_ci 1011bf215546Sopenharmony_cistatic void si_init_renderer_string(struct si_screen *sscreen) 1012bf215546Sopenharmony_ci{ 1013bf215546Sopenharmony_ci char first_name[256], second_name[32] = {}, kernel_version[128] = {}; 1014bf215546Sopenharmony_ci struct utsname uname_data; 1015bf215546Sopenharmony_ci 1016bf215546Sopenharmony_ci snprintf(first_name, sizeof(first_name), "%s", 1017bf215546Sopenharmony_ci sscreen->info.marketing_name ? sscreen->info.marketing_name : sscreen->info.name); 1018bf215546Sopenharmony_ci snprintf(second_name, sizeof(second_name), "%s, ", sscreen->info.lowercase_name); 1019bf215546Sopenharmony_ci 1020bf215546Sopenharmony_ci if (uname(&uname_data) == 0) 1021bf215546Sopenharmony_ci snprintf(kernel_version, sizeof(kernel_version), ", %s", uname_data.release); 1022bf215546Sopenharmony_ci 1023bf215546Sopenharmony_ci snprintf(sscreen->renderer_string, sizeof(sscreen->renderer_string), 1024bf215546Sopenharmony_ci "%s (%sLLVM " MESA_LLVM_VERSION_STRING ", DRM %i.%i%s)", first_name, second_name, 1025bf215546Sopenharmony_ci sscreen->info.drm_major, sscreen->info.drm_minor, kernel_version); 1026bf215546Sopenharmony_ci} 1027bf215546Sopenharmony_ci 1028bf215546Sopenharmony_civoid si_init_screen_get_functions(struct si_screen *sscreen) 1029bf215546Sopenharmony_ci{ 1030bf215546Sopenharmony_ci sscreen->b.get_name = si_get_name; 1031bf215546Sopenharmony_ci sscreen->b.get_vendor = si_get_vendor; 1032bf215546Sopenharmony_ci sscreen->b.get_device_vendor = si_get_device_vendor; 1033bf215546Sopenharmony_ci sscreen->b.get_param = si_get_param; 1034bf215546Sopenharmony_ci sscreen->b.get_paramf = si_get_paramf; 1035bf215546Sopenharmony_ci sscreen->b.get_compute_param = si_get_compute_param; 1036bf215546Sopenharmony_ci sscreen->b.get_timestamp = si_get_timestamp; 1037bf215546Sopenharmony_ci sscreen->b.get_shader_param = si_get_shader_param; 1038bf215546Sopenharmony_ci sscreen->b.get_compiler_options = si_get_compiler_options; 1039bf215546Sopenharmony_ci sscreen->b.get_device_uuid = si_get_device_uuid; 1040bf215546Sopenharmony_ci sscreen->b.get_driver_uuid = si_get_driver_uuid; 1041bf215546Sopenharmony_ci sscreen->b.query_memory_info = si_query_memory_info; 1042bf215546Sopenharmony_ci sscreen->b.get_disk_shader_cache = si_get_disk_shader_cache; 1043bf215546Sopenharmony_ci 1044bf215546Sopenharmony_ci if (sscreen->info.ip[AMD_IP_UVD].num_queues || sscreen->info.has_video_hw.vcn_decode || 1045bf215546Sopenharmony_ci sscreen->info.ip[AMD_IP_VCN_JPEG].num_queues || sscreen->info.ip[AMD_IP_VCE].num_queues || 1046bf215546Sopenharmony_ci sscreen->info.ip[AMD_IP_UVD_ENC].num_queues || sscreen->info.ip[AMD_IP_VCN_ENC].num_queues) { 1047bf215546Sopenharmony_ci sscreen->b.get_video_param = si_get_video_param; 1048bf215546Sopenharmony_ci sscreen->b.is_video_format_supported = si_vid_is_format_supported; 1049bf215546Sopenharmony_ci } else { 1050bf215546Sopenharmony_ci sscreen->b.get_video_param = si_get_video_param_no_video_hw; 1051bf215546Sopenharmony_ci sscreen->b.is_video_format_supported = vl_video_buffer_is_format_supported; 1052bf215546Sopenharmony_ci } 1053bf215546Sopenharmony_ci 1054bf215546Sopenharmony_ci si_init_renderer_string(sscreen); 1055bf215546Sopenharmony_ci 1056bf215546Sopenharmony_ci /* fma32 is too slow for gpu < gfx9, so force it only when gpu >= gfx9 */ 1057bf215546Sopenharmony_ci bool force_fma32 = 1058bf215546Sopenharmony_ci sscreen->info.gfx_level >= GFX9 && sscreen->options.force_use_fma32; 1059bf215546Sopenharmony_ci 1060bf215546Sopenharmony_ci const struct nir_shader_compiler_options nir_options = { 1061bf215546Sopenharmony_ci .vertex_id_zero_based = true, 1062bf215546Sopenharmony_ci .lower_scmp = true, 1063bf215546Sopenharmony_ci .lower_flrp16 = true, 1064bf215546Sopenharmony_ci .lower_flrp32 = true, 1065bf215546Sopenharmony_ci .lower_flrp64 = true, 1066bf215546Sopenharmony_ci .lower_fsat = true, 1067bf215546Sopenharmony_ci .lower_fdiv = true, 1068bf215546Sopenharmony_ci .lower_bitfield_insert_to_bitfield_select = true, 1069bf215546Sopenharmony_ci .lower_bitfield_extract = true, 1070bf215546Sopenharmony_ci /* |---------------------------------- Performance & Availability --------------------------------| 1071bf215546Sopenharmony_ci * |MAD/MAC/MADAK/MADMK|MAD_LEGACY|MAC_LEGACY| FMA |FMAC/FMAAK/FMAMK|FMA_LEGACY|PK_FMA_F16,|Best choice 1072bf215546Sopenharmony_ci * Arch | F32,F16,F64 | F32,F16 | F32,F16 |F32,F16,F64 | F32,F16 | F32,F16 |PK_FMAC_F16|F16,F32,F64 1073bf215546Sopenharmony_ci * ------------------------------------------------------------------------------------------------------------------ 1074bf215546Sopenharmony_ci * gfx6,7 | 1 , - , - | 1 , - | 1 , - |1/4, - ,1/16| - , - | - , - | - , - | - ,MAD,FMA 1075bf215546Sopenharmony_ci * gfx8 | 1 , 1 , - | 1 , - | - , - |1/4, 1 ,1/16| - , - | - , - | - , - |MAD,MAD,FMA 1076bf215546Sopenharmony_ci * gfx9 | 1 ,1|0, - | 1 , - | - , - | 1 , 1 ,1/16| 0|1, - | - , 1 | 2 , - |FMA,MAD,FMA 1077bf215546Sopenharmony_ci * gfx10 | 1 , - , - | 1 , - | 1 , - | 1 , 1 ,1/16| 1 , 1 | - , - | 2 , 2 |FMA,MAD,FMA 1078bf215546Sopenharmony_ci * gfx10.3| - , - , - | - , - | - , - | 1 , 1 ,1/16| 1 , 1 | 1 , - | 2 , 2 | all FMA 1079bf215546Sopenharmony_ci * 1080bf215546Sopenharmony_ci * Tahiti, Hawaii, Carrizo, Vega20: FMA_F32 is full rate, FMA_F64 is 1/4 1081bf215546Sopenharmony_ci * gfx9 supports MAD_F16 only on Vega10, Raven, Raven2, Renoir. 1082bf215546Sopenharmony_ci * gfx9 supports FMAC_F32 only on Vega20, but doesn't support FMAAK and FMAMK. 1083bf215546Sopenharmony_ci * 1084bf215546Sopenharmony_ci * gfx8 prefers MAD for F16 because of MAC/MADAK/MADMK. 1085bf215546Sopenharmony_ci * gfx9 and newer prefer FMA for F16 because of the packed instruction. 1086bf215546Sopenharmony_ci * gfx10 and older prefer MAD for F32 because of the legacy instruction. 1087bf215546Sopenharmony_ci */ 1088bf215546Sopenharmony_ci .lower_ffma16 = sscreen->info.gfx_level < GFX9, 1089bf215546Sopenharmony_ci .lower_ffma32 = sscreen->info.gfx_level < GFX10_3 && !force_fma32, 1090bf215546Sopenharmony_ci .lower_ffma64 = false, 1091bf215546Sopenharmony_ci .fuse_ffma16 = sscreen->info.gfx_level >= GFX9, 1092bf215546Sopenharmony_ci .fuse_ffma32 = sscreen->info.gfx_level >= GFX10_3 || force_fma32, 1093bf215546Sopenharmony_ci .fuse_ffma64 = true, 1094bf215546Sopenharmony_ci .lower_fmod = true, 1095bf215546Sopenharmony_ci .lower_pack_snorm_4x8 = true, 1096bf215546Sopenharmony_ci .lower_pack_unorm_4x8 = true, 1097bf215546Sopenharmony_ci .lower_unpack_snorm_2x16 = true, 1098bf215546Sopenharmony_ci .lower_unpack_snorm_4x8 = true, 1099bf215546Sopenharmony_ci .lower_unpack_unorm_2x16 = true, 1100bf215546Sopenharmony_ci .lower_unpack_unorm_4x8 = true, 1101bf215546Sopenharmony_ci .lower_extract_byte = true, 1102bf215546Sopenharmony_ci .lower_extract_word = true, 1103bf215546Sopenharmony_ci .lower_insert_byte = true, 1104bf215546Sopenharmony_ci .lower_insert_word = true, 1105bf215546Sopenharmony_ci .lower_rotate = true, 1106bf215546Sopenharmony_ci .lower_to_scalar = true, 1107bf215546Sopenharmony_ci .lower_int64_options = nir_lower_imul_2x32_64, 1108bf215546Sopenharmony_ci .has_sdot_4x8 = sscreen->info.has_accelerated_dot_product, 1109bf215546Sopenharmony_ci .has_udot_4x8 = sscreen->info.has_accelerated_dot_product, 1110bf215546Sopenharmony_ci .has_dot_2x16 = sscreen->info.has_accelerated_dot_product, 1111bf215546Sopenharmony_ci .optimize_sample_mask_in = true, 1112bf215546Sopenharmony_ci .max_unroll_iterations = LLVM_VERSION_MAJOR >= 13 ? 128 : 32, 1113bf215546Sopenharmony_ci .max_unroll_iterations_aggressive = LLVM_VERSION_MAJOR >= 13 ? 128 : 32, 1114bf215546Sopenharmony_ci .use_interpolated_input_intrinsics = true, 1115bf215546Sopenharmony_ci .lower_uniforms_to_ubo = true, 1116bf215546Sopenharmony_ci .support_16bit_alu = sscreen->info.gfx_level >= GFX8, 1117bf215546Sopenharmony_ci .vectorize_vec2_16bit = sscreen->info.has_packed_math_16bit, 1118bf215546Sopenharmony_ci .pack_varying_options = 1119bf215546Sopenharmony_ci nir_pack_varying_interp_mode_none | 1120bf215546Sopenharmony_ci nir_pack_varying_interp_mode_smooth | 1121bf215546Sopenharmony_ci nir_pack_varying_interp_mode_noperspective | 1122bf215546Sopenharmony_ci nir_pack_varying_interp_loc_center | 1123bf215546Sopenharmony_ci nir_pack_varying_interp_loc_sample | 1124bf215546Sopenharmony_ci nir_pack_varying_interp_loc_centroid, 1125bf215546Sopenharmony_ci .lower_io_variables = true, 1126bf215546Sopenharmony_ci .lower_fs_color_inputs = true, 1127bf215546Sopenharmony_ci /* HW supports indirect indexing for: | Enabled in driver 1128bf215546Sopenharmony_ci * ------------------------------------------------------- 1129bf215546Sopenharmony_ci * TCS inputs | Yes 1130bf215546Sopenharmony_ci * TES inputs | Yes 1131bf215546Sopenharmony_ci * GS inputs | No 1132bf215546Sopenharmony_ci * ------------------------------------------------------- 1133bf215546Sopenharmony_ci * VS outputs before TCS | No 1134bf215546Sopenharmony_ci * TCS outputs | Yes 1135bf215546Sopenharmony_ci * VS/TES outputs before GS | No 1136bf215546Sopenharmony_ci */ 1137bf215546Sopenharmony_ci .support_indirect_inputs = BITFIELD_BIT(MESA_SHADER_TESS_CTRL) | 1138bf215546Sopenharmony_ci BITFIELD_BIT(MESA_SHADER_TESS_EVAL), 1139bf215546Sopenharmony_ci .support_indirect_outputs = BITFIELD_BIT(MESA_SHADER_TESS_CTRL), 1140bf215546Sopenharmony_ci }; 1141bf215546Sopenharmony_ci sscreen->nir_options = nir_options; 1142bf215546Sopenharmony_ci} 1143