1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright 2010 Christoph Bumiller 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 shall be included in 12bf215546Sopenharmony_ci * all copies or substantial portions of the Software. 13bf215546Sopenharmony_ci * 14bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18bf215546Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19bf215546Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20bf215546Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 21bf215546Sopenharmony_ci */ 22bf215546Sopenharmony_ci 23bf215546Sopenharmony_ci#include <errno.h> 24bf215546Sopenharmony_ci#include <xf86drm.h> 25bf215546Sopenharmony_ci#include <nouveau_drm.h> 26bf215546Sopenharmony_ci#include "util/format/u_format.h" 27bf215546Sopenharmony_ci#include "util/format/u_format_s3tc.h" 28bf215546Sopenharmony_ci#include "util/u_screen.h" 29bf215546Sopenharmony_ci#include "pipe/p_screen.h" 30bf215546Sopenharmony_ci 31bf215546Sopenharmony_ci#include "nv50_ir_driver.h" 32bf215546Sopenharmony_ci 33bf215546Sopenharmony_ci#include "nv50/nv50_context.h" 34bf215546Sopenharmony_ci#include "nv50/nv50_screen.h" 35bf215546Sopenharmony_ci 36bf215546Sopenharmony_ci#include "nouveau_vp3_video.h" 37bf215546Sopenharmony_ci 38bf215546Sopenharmony_ci#include "nv_object.xml.h" 39bf215546Sopenharmony_ci 40bf215546Sopenharmony_ci/* affected by LOCAL_WARPS_LOG_ALLOC / LOCAL_WARPS_NO_CLAMP */ 41bf215546Sopenharmony_ci#define LOCAL_WARPS_ALLOC 32 42bf215546Sopenharmony_ci/* affected by STACK_WARPS_LOG_ALLOC / STACK_WARPS_NO_CLAMP */ 43bf215546Sopenharmony_ci#define STACK_WARPS_ALLOC 32 44bf215546Sopenharmony_ci 45bf215546Sopenharmony_ci#define THREADS_IN_WARP 32 46bf215546Sopenharmony_ci 47bf215546Sopenharmony_cistatic bool 48bf215546Sopenharmony_cinv50_screen_is_format_supported(struct pipe_screen *pscreen, 49bf215546Sopenharmony_ci enum pipe_format format, 50bf215546Sopenharmony_ci enum pipe_texture_target target, 51bf215546Sopenharmony_ci unsigned sample_count, 52bf215546Sopenharmony_ci unsigned storage_sample_count, 53bf215546Sopenharmony_ci unsigned bindings) 54bf215546Sopenharmony_ci{ 55bf215546Sopenharmony_ci if (sample_count > 8) 56bf215546Sopenharmony_ci return false; 57bf215546Sopenharmony_ci if (!(0x117 & (1 << sample_count))) /* 0, 1, 2, 4 or 8 */ 58bf215546Sopenharmony_ci return false; 59bf215546Sopenharmony_ci if (sample_count == 8 && util_format_get_blocksizebits(format) >= 128) 60bf215546Sopenharmony_ci return false; 61bf215546Sopenharmony_ci 62bf215546Sopenharmony_ci if (MAX2(1, sample_count) != MAX2(1, storage_sample_count)) 63bf215546Sopenharmony_ci return false; 64bf215546Sopenharmony_ci 65bf215546Sopenharmony_ci /* Short-circuit the rest of the logic -- this is used by the gallium frontend 66bf215546Sopenharmony_ci * to determine valid MS levels in a no-attachments scenario. 67bf215546Sopenharmony_ci */ 68bf215546Sopenharmony_ci if (format == PIPE_FORMAT_NONE && bindings & PIPE_BIND_RENDER_TARGET) 69bf215546Sopenharmony_ci return true; 70bf215546Sopenharmony_ci 71bf215546Sopenharmony_ci switch (format) { 72bf215546Sopenharmony_ci case PIPE_FORMAT_Z16_UNORM: 73bf215546Sopenharmony_ci if (nv50_screen(pscreen)->tesla->oclass < NVA0_3D_CLASS) 74bf215546Sopenharmony_ci return false; 75bf215546Sopenharmony_ci break; 76bf215546Sopenharmony_ci default: 77bf215546Sopenharmony_ci break; 78bf215546Sopenharmony_ci } 79bf215546Sopenharmony_ci 80bf215546Sopenharmony_ci if (bindings & PIPE_BIND_LINEAR) 81bf215546Sopenharmony_ci if (util_format_is_depth_or_stencil(format) || 82bf215546Sopenharmony_ci (target != PIPE_TEXTURE_1D && 83bf215546Sopenharmony_ci target != PIPE_TEXTURE_2D && 84bf215546Sopenharmony_ci target != PIPE_TEXTURE_RECT) || 85bf215546Sopenharmony_ci sample_count > 1) 86bf215546Sopenharmony_ci return false; 87bf215546Sopenharmony_ci 88bf215546Sopenharmony_ci /* shared is always supported */ 89bf215546Sopenharmony_ci bindings &= ~(PIPE_BIND_LINEAR | 90bf215546Sopenharmony_ci PIPE_BIND_SHARED); 91bf215546Sopenharmony_ci 92bf215546Sopenharmony_ci if (bindings & PIPE_BIND_INDEX_BUFFER) { 93bf215546Sopenharmony_ci if (format != PIPE_FORMAT_R8_UINT && 94bf215546Sopenharmony_ci format != PIPE_FORMAT_R16_UINT && 95bf215546Sopenharmony_ci format != PIPE_FORMAT_R32_UINT) 96bf215546Sopenharmony_ci return false; 97bf215546Sopenharmony_ci bindings &= ~PIPE_BIND_INDEX_BUFFER; 98bf215546Sopenharmony_ci } 99bf215546Sopenharmony_ci 100bf215546Sopenharmony_ci return (( nv50_format_table[format].usage | 101bf215546Sopenharmony_ci nv50_vertex_format[format].usage) & bindings) == bindings; 102bf215546Sopenharmony_ci} 103bf215546Sopenharmony_ci 104bf215546Sopenharmony_cistatic int 105bf215546Sopenharmony_cinv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) 106bf215546Sopenharmony_ci{ 107bf215546Sopenharmony_ci struct nouveau_screen *screen = nouveau_screen(pscreen); 108bf215546Sopenharmony_ci const uint16_t class_3d = screen->class_3d; 109bf215546Sopenharmony_ci struct nouveau_device *dev = screen->device; 110bf215546Sopenharmony_ci static bool debug_cap_printed[PIPE_CAP_LAST] = {}; 111bf215546Sopenharmony_ci 112bf215546Sopenharmony_ci switch (param) { 113bf215546Sopenharmony_ci /* non-boolean caps */ 114bf215546Sopenharmony_ci case PIPE_CAP_MAX_TEXTURE_2D_SIZE: 115bf215546Sopenharmony_ci return 8192; 116bf215546Sopenharmony_ci case PIPE_CAP_MAX_TEXTURE_3D_LEVELS: 117bf215546Sopenharmony_ci return 12; 118bf215546Sopenharmony_ci case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS: 119bf215546Sopenharmony_ci return 14; 120bf215546Sopenharmony_ci case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS: 121bf215546Sopenharmony_ci return 512; 122bf215546Sopenharmony_ci case PIPE_CAP_MIN_TEXTURE_GATHER_OFFSET: 123bf215546Sopenharmony_ci case PIPE_CAP_MIN_TEXEL_OFFSET: 124bf215546Sopenharmony_ci return -8; 125bf215546Sopenharmony_ci case PIPE_CAP_MAX_TEXTURE_GATHER_OFFSET: 126bf215546Sopenharmony_ci case PIPE_CAP_MAX_TEXEL_OFFSET: 127bf215546Sopenharmony_ci return 7; 128bf215546Sopenharmony_ci case PIPE_CAP_MAX_TEXEL_BUFFER_ELEMENTS_UINT: 129bf215546Sopenharmony_ci return 128 * 1024 * 1024; 130bf215546Sopenharmony_ci case PIPE_CAP_GLSL_FEATURE_LEVEL: 131bf215546Sopenharmony_ci return 330; 132bf215546Sopenharmony_ci case PIPE_CAP_GLSL_FEATURE_LEVEL_COMPATIBILITY: 133bf215546Sopenharmony_ci return 330; 134bf215546Sopenharmony_ci case PIPE_CAP_ESSL_FEATURE_LEVEL: 135bf215546Sopenharmony_ci return class_3d >= NVA3_3D_CLASS ? 310 : 300; 136bf215546Sopenharmony_ci case PIPE_CAP_MAX_RENDER_TARGETS: 137bf215546Sopenharmony_ci return 8; 138bf215546Sopenharmony_ci case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS: 139bf215546Sopenharmony_ci return 1; 140bf215546Sopenharmony_ci case PIPE_CAP_MAX_COMBINED_SHADER_OUTPUT_RESOURCES: 141bf215546Sopenharmony_ci return NV50_MAX_GLOBALS - 1; 142bf215546Sopenharmony_ci case PIPE_CAP_VIEWPORT_SUBPIXEL_BITS: 143bf215546Sopenharmony_ci case PIPE_CAP_RASTERIZER_SUBPIXEL_BITS: 144bf215546Sopenharmony_ci return 8; 145bf215546Sopenharmony_ci case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS: 146bf215546Sopenharmony_ci return 4; 147bf215546Sopenharmony_ci case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS: 148bf215546Sopenharmony_ci return 64; 149bf215546Sopenharmony_ci case PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS: 150bf215546Sopenharmony_ci return 4; 151bf215546Sopenharmony_ci case PIPE_CAP_MAX_GEOMETRY_OUTPUT_VERTICES: 152bf215546Sopenharmony_ci case PIPE_CAP_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS: 153bf215546Sopenharmony_ci return 1024; 154bf215546Sopenharmony_ci case PIPE_CAP_MAX_VERTEX_STREAMS: 155bf215546Sopenharmony_ci return 1; 156bf215546Sopenharmony_ci case PIPE_CAP_MAX_GS_INVOCATIONS: 157bf215546Sopenharmony_ci return 0; 158bf215546Sopenharmony_ci case PIPE_CAP_MAX_SHADER_BUFFER_SIZE_UINT: 159bf215546Sopenharmony_ci return 1 << 27; 160bf215546Sopenharmony_ci case PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE: 161bf215546Sopenharmony_ci return 2048; 162bf215546Sopenharmony_ci case PIPE_CAP_MAX_VERTEX_ELEMENT_SRC_OFFSET: 163bf215546Sopenharmony_ci return 2047; 164bf215546Sopenharmony_ci case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT: 165bf215546Sopenharmony_ci return 256; 166bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT: 167bf215546Sopenharmony_ci return 16; /* 256 for binding as RT, but that's not possible in GL */ 168bf215546Sopenharmony_ci case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT: 169bf215546Sopenharmony_ci return 256; /* the access limit is aligned to 256 */ 170bf215546Sopenharmony_ci case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT: 171bf215546Sopenharmony_ci return NOUVEAU_MIN_BUFFER_MAP_ALIGN; 172bf215546Sopenharmony_ci case PIPE_CAP_MAX_VIEWPORTS: 173bf215546Sopenharmony_ci return NV50_MAX_VIEWPORTS; 174bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK: 175bf215546Sopenharmony_ci return PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50; 176bf215546Sopenharmony_ci case PIPE_CAP_ENDIANNESS: 177bf215546Sopenharmony_ci return PIPE_ENDIAN_LITTLE; 178bf215546Sopenharmony_ci case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS: 179bf215546Sopenharmony_ci return (class_3d >= NVA3_3D_CLASS) ? 4 : 0; 180bf215546Sopenharmony_ci case PIPE_CAP_MAX_WINDOW_RECTANGLES: 181bf215546Sopenharmony_ci return NV50_MAX_WINDOW_RECTANGLES; 182bf215546Sopenharmony_ci case PIPE_CAP_MAX_TEXTURE_UPLOAD_MEMORY_BUDGET: 183bf215546Sopenharmony_ci return 16 * 1024 * 1024; 184bf215546Sopenharmony_ci case PIPE_CAP_MAX_VARYINGS: 185bf215546Sopenharmony_ci return 15; 186bf215546Sopenharmony_ci case PIPE_CAP_MAX_VERTEX_BUFFERS: 187bf215546Sopenharmony_ci return 16; 188bf215546Sopenharmony_ci case PIPE_CAP_GL_BEGIN_END_BUFFER_SIZE: 189bf215546Sopenharmony_ci return 512 * 1024; /* TODO: Investigate tuning this */ 190bf215546Sopenharmony_ci case PIPE_CAP_MAX_TEXTURE_MB: 191bf215546Sopenharmony_ci return 0; /* TODO: use 1/2 of VRAM for this? */ 192bf215546Sopenharmony_ci 193bf215546Sopenharmony_ci case PIPE_CAP_SUPPORTED_PRIM_MODES_WITH_RESTART: 194bf215546Sopenharmony_ci case PIPE_CAP_SUPPORTED_PRIM_MODES: 195bf215546Sopenharmony_ci return BITFIELD_MASK(PIPE_PRIM_MAX); 196bf215546Sopenharmony_ci 197bf215546Sopenharmony_ci /* supported caps */ 198bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_MIRROR_CLAMP: 199bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_MIRROR_CLAMP_TO_EDGE: 200bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_SWIZZLE: 201bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_SHADOW_MAP: 202bf215546Sopenharmony_ci case PIPE_CAP_NPOT_TEXTURES: 203bf215546Sopenharmony_ci case PIPE_CAP_MIXED_FRAMEBUFFER_SIZES: 204bf215546Sopenharmony_ci case PIPE_CAP_MIXED_COLOR_DEPTH_BITS: 205bf215546Sopenharmony_ci case PIPE_CAP_ANISOTROPIC_FILTER: 206bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_BUFFER_OBJECTS: 207bf215546Sopenharmony_ci case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT: 208bf215546Sopenharmony_ci case PIPE_CAP_DEPTH_CLIP_DISABLE: 209bf215546Sopenharmony_ci case PIPE_CAP_POINT_SPRITE: 210bf215546Sopenharmony_ci case PIPE_CAP_FRAGMENT_SHADER_TEXTURE_LOD: 211bf215546Sopenharmony_ci case PIPE_CAP_FRAGMENT_SHADER_DERIVATIVES: 212bf215546Sopenharmony_ci case PIPE_CAP_FRAGMENT_COLOR_CLAMPED: 213bf215546Sopenharmony_ci case PIPE_CAP_VERTEX_COLOR_UNCLAMPED: 214bf215546Sopenharmony_ci case PIPE_CAP_VERTEX_COLOR_CLAMPED: 215bf215546Sopenharmony_ci case PIPE_CAP_QUERY_TIMESTAMP: 216bf215546Sopenharmony_ci case PIPE_CAP_QUERY_TIME_ELAPSED: 217bf215546Sopenharmony_ci case PIPE_CAP_OCCLUSION_QUERY: 218bf215546Sopenharmony_ci case PIPE_CAP_BLEND_EQUATION_SEPARATE: 219bf215546Sopenharmony_ci case PIPE_CAP_INDEP_BLEND_ENABLE: 220bf215546Sopenharmony_ci case PIPE_CAP_FS_COORD_ORIGIN_UPPER_LEFT: 221bf215546Sopenharmony_ci case PIPE_CAP_FS_COORD_PIXEL_CENTER_HALF_INTEGER: 222bf215546Sopenharmony_ci case PIPE_CAP_POINT_COORD_ORIGIN_UPPER_LEFT: 223bf215546Sopenharmony_ci case PIPE_CAP_PRIMITIVE_RESTART: 224bf215546Sopenharmony_ci case PIPE_CAP_PRIMITIVE_RESTART_FIXED_INDEX: 225bf215546Sopenharmony_ci case PIPE_CAP_VS_INSTANCEID: 226bf215546Sopenharmony_ci case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR: 227bf215546Sopenharmony_ci case PIPE_CAP_MIXED_COLORBUFFER_FORMATS: 228bf215546Sopenharmony_ci case PIPE_CAP_CONDITIONAL_RENDER: 229bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_BARRIER: 230bf215546Sopenharmony_ci case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION: 231bf215546Sopenharmony_ci case PIPE_CAP_START_INSTANCE: 232bf215546Sopenharmony_ci case PIPE_CAP_USER_VERTEX_BUFFERS: 233bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_MULTISAMPLE: 234bf215546Sopenharmony_ci case PIPE_CAP_FS_FINE_DERIVATIVE: 235bf215546Sopenharmony_ci case PIPE_CAP_SAMPLER_VIEW_TARGET: 236bf215546Sopenharmony_ci case PIPE_CAP_CONDITIONAL_RENDER_INVERTED: 237bf215546Sopenharmony_ci case PIPE_CAP_CLIP_HALFZ: 238bf215546Sopenharmony_ci case PIPE_CAP_POLYGON_OFFSET_CLAMP: 239bf215546Sopenharmony_ci case PIPE_CAP_QUERY_PIPELINE_STATISTICS: 240bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_FLOAT_LINEAR: 241bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_HALF_FLOAT_LINEAR: 242bf215546Sopenharmony_ci case PIPE_CAP_DEPTH_BOUNDS_TEST: 243bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_QUERY_SAMPLES: 244bf215546Sopenharmony_ci case PIPE_CAP_COPY_BETWEEN_COMPRESSED_AND_PLAIN_FORMATS: 245bf215546Sopenharmony_ci case PIPE_CAP_CLEAR_TEXTURE: 246bf215546Sopenharmony_ci case PIPE_CAP_FS_FACE_IS_INTEGER_SYSVAL: 247bf215546Sopenharmony_ci case PIPE_CAP_INVALIDATE_BUFFER: 248bf215546Sopenharmony_ci case PIPE_CAP_STRING_MARKER: 249bf215546Sopenharmony_ci case PIPE_CAP_CULL_DISTANCE: 250bf215546Sopenharmony_ci case PIPE_CAP_SHADER_ARRAY_COMPONENTS: 251bf215546Sopenharmony_ci case PIPE_CAP_LEGACY_MATH_RULES: 252bf215546Sopenharmony_ci case PIPE_CAP_TGSI_TEX_TXF_LZ: 253bf215546Sopenharmony_ci case PIPE_CAP_SHADER_CLOCK: 254bf215546Sopenharmony_ci case PIPE_CAP_CAN_BIND_CONST_BUFFER_AS_VERTEX: 255bf215546Sopenharmony_ci case PIPE_CAP_ALLOW_MAPPED_BUFFERS_DURING_EXECUTION: 256bf215546Sopenharmony_ci case PIPE_CAP_DEST_SURFACE_SRGB_CONTROL: 257bf215546Sopenharmony_ci case PIPE_CAP_TGSI_DIV: 258bf215546Sopenharmony_ci case PIPE_CAP_PREFER_IMM_ARRAYS_AS_CONSTBUF: 259bf215546Sopenharmony_ci case PIPE_CAP_FLATSHADE: 260bf215546Sopenharmony_ci case PIPE_CAP_POINT_SIZE_FIXED: 261bf215546Sopenharmony_ci case PIPE_CAP_TWO_SIDED_COLOR: 262bf215546Sopenharmony_ci case PIPE_CAP_CLIP_PLANES: 263bf215546Sopenharmony_ci case PIPE_CAP_PACKED_STREAM_OUTPUT: 264bf215546Sopenharmony_ci case PIPE_CAP_CLEAR_SCISSORED: 265bf215546Sopenharmony_ci case PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT: 266bf215546Sopenharmony_ci case PIPE_CAP_COMPUTE: 267bf215546Sopenharmony_ci case PIPE_CAP_GL_CLAMP: 268bf215546Sopenharmony_ci case PIPE_CAP_TEXRECT: 269bf215546Sopenharmony_ci case PIPE_CAP_ALLOW_DYNAMIC_VAO_FASTPATH: 270bf215546Sopenharmony_ci case PIPE_CAP_SHAREABLE_SHADERS: 271bf215546Sopenharmony_ci case PIPE_CAP_PREFER_BACK_BUFFER_REUSE: 272bf215546Sopenharmony_ci return 1; 273bf215546Sopenharmony_ci 274bf215546Sopenharmony_ci case PIPE_CAP_ALPHA_TEST: 275bf215546Sopenharmony_ci /* nvc0 has fixed function alpha test support, but nv50 doesn't. The TGSI 276bf215546Sopenharmony_ci * backend emits the conditional discard code against a driver-uploaded 277bf215546Sopenharmony_ci * uniform, but with NIR we can have the st emit it for us. 278bf215546Sopenharmony_ci */ 279bf215546Sopenharmony_ci return class_3d >= NVC0_3D_CLASS || !screen->prefer_nir; 280bf215546Sopenharmony_ci 281bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_TRANSFER_MODES: 282bf215546Sopenharmony_ci return PIPE_TEXTURE_TRANSFER_BLIT; 283bf215546Sopenharmony_ci case PIPE_CAP_SEAMLESS_CUBE_MAP: 284bf215546Sopenharmony_ci return 1; /* class_3d >= NVA0_3D_CLASS; */ 285bf215546Sopenharmony_ci /* supported on nva0+ */ 286bf215546Sopenharmony_ci case PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME: 287bf215546Sopenharmony_ci return class_3d >= NVA0_3D_CLASS; 288bf215546Sopenharmony_ci /* supported on nva3+ */ 289bf215546Sopenharmony_ci case PIPE_CAP_CUBE_MAP_ARRAY: 290bf215546Sopenharmony_ci case PIPE_CAP_INDEP_BLEND_FUNC: 291bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_QUERY_LOD: 292bf215546Sopenharmony_ci case PIPE_CAP_SAMPLE_SHADING: 293bf215546Sopenharmony_ci case PIPE_CAP_FORCE_PERSAMPLE_INTERP: 294bf215546Sopenharmony_ci return class_3d >= NVA3_3D_CLASS; 295bf215546Sopenharmony_ci 296bf215546Sopenharmony_ci /* unsupported caps */ 297bf215546Sopenharmony_ci case PIPE_CAP_EMULATE_NONFIXED_PRIMITIVE_RESTART: 298bf215546Sopenharmony_ci case PIPE_CAP_DEPTH_CLIP_DISABLE_SEPARATE: 299bf215546Sopenharmony_ci case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE: 300bf215546Sopenharmony_ci case PIPE_CAP_FS_COORD_ORIGIN_LOWER_LEFT: 301bf215546Sopenharmony_ci case PIPE_CAP_FS_COORD_PIXEL_CENTER_INTEGER: 302bf215546Sopenharmony_ci case PIPE_CAP_SHADER_STENCIL_EXPORT: 303bf215546Sopenharmony_ci case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS: 304bf215546Sopenharmony_ci case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY: 305bf215546Sopenharmony_ci case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY: 306bf215546Sopenharmony_ci case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY: 307bf215546Sopenharmony_ci case PIPE_CAP_VERTEX_ATTRIB_ELEMENT_ALIGNED_ONLY: 308bf215546Sopenharmony_ci case PIPE_CAP_TGSI_TEXCOORD: 309bf215546Sopenharmony_ci case PIPE_CAP_VS_LAYER_VIEWPORT: 310bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_GATHER_SM5: 311bf215546Sopenharmony_ci case PIPE_CAP_FAKE_SW_MSAA: 312bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_GATHER_OFFSETS: 313bf215546Sopenharmony_ci case PIPE_CAP_VS_WINDOW_SPACE_POSITION: 314bf215546Sopenharmony_ci case PIPE_CAP_DRAW_INDIRECT: 315bf215546Sopenharmony_ci case PIPE_CAP_MULTI_DRAW_INDIRECT: 316bf215546Sopenharmony_ci case PIPE_CAP_MULTI_DRAW_INDIRECT_PARAMS: 317bf215546Sopenharmony_ci case PIPE_CAP_VERTEXID_NOBASE: 318bf215546Sopenharmony_ci case PIPE_CAP_MULTISAMPLE_Z_RESOLVE: /* potentially supported on some hw */ 319bf215546Sopenharmony_ci case PIPE_CAP_RESOURCE_FROM_USER_MEMORY: 320bf215546Sopenharmony_ci case PIPE_CAP_DEVICE_RESET_STATUS_QUERY: 321bf215546Sopenharmony_ci case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS: 322bf215546Sopenharmony_ci case PIPE_CAP_DRAW_PARAMETERS: 323bf215546Sopenharmony_ci case PIPE_CAP_SHADER_PACK_HALF_FLOAT: 324bf215546Sopenharmony_ci case PIPE_CAP_FS_POSITION_IS_SYSVAL: 325bf215546Sopenharmony_ci case PIPE_CAP_FS_POINT_IS_SYSVAL: 326bf215546Sopenharmony_ci case PIPE_CAP_GENERATE_MIPMAP: 327bf215546Sopenharmony_ci case PIPE_CAP_BUFFER_SAMPLER_VIEW_RGBA_ONLY: 328bf215546Sopenharmony_ci case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS: 329bf215546Sopenharmony_ci case PIPE_CAP_QUERY_BUFFER_OBJECT: 330bf215546Sopenharmony_ci case PIPE_CAP_QUERY_MEMORY_INFO: 331bf215546Sopenharmony_ci case PIPE_CAP_PCI_GROUP: 332bf215546Sopenharmony_ci case PIPE_CAP_PCI_BUS: 333bf215546Sopenharmony_ci case PIPE_CAP_PCI_DEVICE: 334bf215546Sopenharmony_ci case PIPE_CAP_PCI_FUNCTION: 335bf215546Sopenharmony_ci case PIPE_CAP_ROBUST_BUFFER_ACCESS_BEHAVIOR: 336bf215546Sopenharmony_ci case PIPE_CAP_SHADER_GROUP_VOTE: 337bf215546Sopenharmony_ci case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED: 338bf215546Sopenharmony_ci case PIPE_CAP_STREAM_OUTPUT_INTERLEAVE_BUFFERS: 339bf215546Sopenharmony_ci case PIPE_CAP_SHADER_CAN_READ_OUTPUTS: 340bf215546Sopenharmony_ci case PIPE_CAP_NATIVE_FENCE_FD: 341bf215546Sopenharmony_ci case PIPE_CAP_FBFETCH: 342bf215546Sopenharmony_ci case PIPE_CAP_DOUBLES: 343bf215546Sopenharmony_ci case PIPE_CAP_INT64: 344bf215546Sopenharmony_ci case PIPE_CAP_INT64_DIVMOD: 345bf215546Sopenharmony_ci case PIPE_CAP_POLYGON_MODE_FILL_RECTANGLE: 346bf215546Sopenharmony_ci case PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE: 347bf215546Sopenharmony_ci case PIPE_CAP_SHADER_BALLOT: 348bf215546Sopenharmony_ci case PIPE_CAP_TES_LAYER_VIEWPORT: 349bf215546Sopenharmony_ci case PIPE_CAP_POST_DEPTH_COVERAGE: 350bf215546Sopenharmony_ci case PIPE_CAP_BINDLESS_TEXTURE: 351bf215546Sopenharmony_ci case PIPE_CAP_NIR_SAMPLERS_AS_DEREF: 352bf215546Sopenharmony_ci case PIPE_CAP_QUERY_SO_OVERFLOW: 353bf215546Sopenharmony_ci case PIPE_CAP_MEMOBJ: 354bf215546Sopenharmony_ci case PIPE_CAP_LOAD_CONSTBUF: 355bf215546Sopenharmony_ci case PIPE_CAP_TILE_RASTER_ORDER: 356bf215546Sopenharmony_ci case PIPE_CAP_FRAMEBUFFER_MSAA_CONSTRAINTS: 357bf215546Sopenharmony_ci case PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET: 358bf215546Sopenharmony_ci case PIPE_CAP_CONTEXT_PRIORITY_MASK: 359bf215546Sopenharmony_ci case PIPE_CAP_FENCE_SIGNAL: 360bf215546Sopenharmony_ci case PIPE_CAP_CONSTBUF0_FLAGS: 361bf215546Sopenharmony_ci case PIPE_CAP_PACKED_UNIFORMS: 362bf215546Sopenharmony_ci case PIPE_CAP_CONSERVATIVE_RASTER_POST_SNAP_TRIANGLES: 363bf215546Sopenharmony_ci case PIPE_CAP_CONSERVATIVE_RASTER_POST_SNAP_POINTS_LINES: 364bf215546Sopenharmony_ci case PIPE_CAP_CONSERVATIVE_RASTER_PRE_SNAP_TRIANGLES: 365bf215546Sopenharmony_ci case PIPE_CAP_CONSERVATIVE_RASTER_PRE_SNAP_POINTS_LINES: 366bf215546Sopenharmony_ci case PIPE_CAP_CONSERVATIVE_RASTER_POST_DEPTH_COVERAGE: 367bf215546Sopenharmony_ci case PIPE_CAP_MAX_CONSERVATIVE_RASTER_SUBPIXEL_PRECISION_BIAS: 368bf215546Sopenharmony_ci case PIPE_CAP_PROGRAMMABLE_SAMPLE_LOCATIONS: 369bf215546Sopenharmony_ci case PIPE_CAP_MAX_COMBINED_SHADER_BUFFERS: 370bf215546Sopenharmony_ci case PIPE_CAP_MAX_COMBINED_HW_ATOMIC_COUNTERS: 371bf215546Sopenharmony_ci case PIPE_CAP_MAX_COMBINED_HW_ATOMIC_COUNTER_BUFFERS: 372bf215546Sopenharmony_ci case PIPE_CAP_SURFACE_SAMPLE_COUNT: 373bf215546Sopenharmony_ci case PIPE_CAP_IMAGE_ATOMIC_FLOAT_ADD: 374bf215546Sopenharmony_ci case PIPE_CAP_QUERY_PIPELINE_STATISTICS_SINGLE: 375bf215546Sopenharmony_ci case PIPE_CAP_RGB_OVERRIDE_DST_ALPHA_BLEND: 376bf215546Sopenharmony_ci case PIPE_CAP_GLSL_TESS_LEVELS_AS_INPUTS: 377bf215546Sopenharmony_ci case PIPE_CAP_NIR_COMPACT_ARRAYS: 378bf215546Sopenharmony_ci case PIPE_CAP_IMAGE_LOAD_FORMATTED: 379bf215546Sopenharmony_ci case PIPE_CAP_IMAGE_STORE_FORMATTED: 380bf215546Sopenharmony_ci case PIPE_CAP_COMPUTE_SHADER_DERIVATIVES: 381bf215546Sopenharmony_ci case PIPE_CAP_ATOMIC_FLOAT_MINMAX: 382bf215546Sopenharmony_ci case PIPE_CAP_CONSERVATIVE_RASTER_INNER_COVERAGE: 383bf215546Sopenharmony_ci case PIPE_CAP_FRAGMENT_SHADER_INTERLOCK: 384bf215546Sopenharmony_ci case PIPE_CAP_CS_DERIVED_SYSTEM_VALUES_SUPPORTED: 385bf215546Sopenharmony_ci case PIPE_CAP_FBFETCH_COHERENT: 386bf215546Sopenharmony_ci case PIPE_CAP_IMAGE_ATOMIC_INC_WRAP: 387bf215546Sopenharmony_ci case PIPE_CAP_DEMOTE_TO_HELPER_INVOCATION: 388bf215546Sopenharmony_ci case PIPE_CAP_TGSI_TG4_COMPONENT_IN_SWIZZLE: 389bf215546Sopenharmony_ci case PIPE_CAP_OPENCL_INTEGER_FUNCTIONS: 390bf215546Sopenharmony_ci case PIPE_CAP_INTEGER_MULTIPLY_32X16: /* could be done */ 391bf215546Sopenharmony_ci case PIPE_CAP_FRONTEND_NOOP: 392bf215546Sopenharmony_ci case PIPE_CAP_GL_SPIRV: 393bf215546Sopenharmony_ci case PIPE_CAP_SHADER_SAMPLES_IDENTICAL: 394bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_SHADOW_LOD: 395bf215546Sopenharmony_ci case PIPE_CAP_VIEWPORT_TRANSFORM_LOWERED: 396bf215546Sopenharmony_ci case PIPE_CAP_PSIZ_CLAMPED: 397bf215546Sopenharmony_ci case PIPE_CAP_VIEWPORT_SWIZZLE: 398bf215546Sopenharmony_ci case PIPE_CAP_VIEWPORT_MASK: 399bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_BUFFER_SAMPLER: 400bf215546Sopenharmony_ci case PIPE_CAP_PREFER_REAL_BUFFER_IN_CONSTBUF0: 401bf215546Sopenharmony_ci case PIPE_CAP_MAP_UNSYNCHRONIZED_THREAD_SAFE: /* when we fix MT stuff */ 402bf215546Sopenharmony_ci case PIPE_CAP_ALPHA_TO_COVERAGE_DITHER_CONTROL: 403bf215546Sopenharmony_ci case PIPE_CAP_SHADER_ATOMIC_INT64: 404bf215546Sopenharmony_ci case PIPE_CAP_GLSL_ZERO_INIT: 405bf215546Sopenharmony_ci case PIPE_CAP_BLEND_EQUATION_ADVANCED: 406bf215546Sopenharmony_ci case PIPE_CAP_NO_CLIP_ON_COPY_TEX: 407bf215546Sopenharmony_ci case PIPE_CAP_DEVICE_PROTECTED_CONTENT: 408bf215546Sopenharmony_ci case PIPE_CAP_NIR_IMAGES_AS_DEREF: 409bf215546Sopenharmony_ci case PIPE_CAP_SAMPLER_REDUCTION_MINMAX: 410bf215546Sopenharmony_ci case PIPE_CAP_SAMPLER_REDUCTION_MINMAX_ARB: 411bf215546Sopenharmony_ci case PIPE_CAP_DRAW_VERTEX_STATE: 412bf215546Sopenharmony_ci case PIPE_CAP_PREFER_POT_ALIGNED_VARYINGS: 413bf215546Sopenharmony_ci case PIPE_CAP_MAX_SPARSE_TEXTURE_SIZE: 414bf215546Sopenharmony_ci case PIPE_CAP_MAX_SPARSE_3D_TEXTURE_SIZE: 415bf215546Sopenharmony_ci case PIPE_CAP_MAX_SPARSE_ARRAY_TEXTURE_LAYERS: 416bf215546Sopenharmony_ci case PIPE_CAP_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS: 417bf215546Sopenharmony_ci case PIPE_CAP_QUERY_SPARSE_TEXTURE_RESIDENCY: 418bf215546Sopenharmony_ci case PIPE_CAP_CLAMP_SPARSE_TEXTURE_LOD: 419bf215546Sopenharmony_ci case PIPE_CAP_HARDWARE_GL_SELECT: 420bf215546Sopenharmony_ci return 0; 421bf215546Sopenharmony_ci 422bf215546Sopenharmony_ci case PIPE_CAP_VENDOR_ID: 423bf215546Sopenharmony_ci return 0x10de; 424bf215546Sopenharmony_ci case PIPE_CAP_DEVICE_ID: { 425bf215546Sopenharmony_ci uint64_t device_id; 426bf215546Sopenharmony_ci if (nouveau_getparam(dev, NOUVEAU_GETPARAM_PCI_DEVICE, &device_id)) { 427bf215546Sopenharmony_ci NOUVEAU_ERR("NOUVEAU_GETPARAM_PCI_DEVICE failed.\n"); 428bf215546Sopenharmony_ci return -1; 429bf215546Sopenharmony_ci } 430bf215546Sopenharmony_ci return device_id; 431bf215546Sopenharmony_ci } 432bf215546Sopenharmony_ci case PIPE_CAP_ACCELERATED: 433bf215546Sopenharmony_ci return 1; 434bf215546Sopenharmony_ci case PIPE_CAP_VIDEO_MEMORY: 435bf215546Sopenharmony_ci return dev->vram_size >> 20; 436bf215546Sopenharmony_ci case PIPE_CAP_UMA: 437bf215546Sopenharmony_ci return 0; 438bf215546Sopenharmony_ci 439bf215546Sopenharmony_ci default: 440bf215546Sopenharmony_ci if (!debug_cap_printed[param]) { 441bf215546Sopenharmony_ci debug_printf("%s: unhandled cap %d\n", __func__, param); 442bf215546Sopenharmony_ci debug_cap_printed[param] = true; 443bf215546Sopenharmony_ci } 444bf215546Sopenharmony_ci FALLTHROUGH; 445bf215546Sopenharmony_ci /* caps where we want the default value */ 446bf215546Sopenharmony_ci case PIPE_CAP_DMABUF: 447bf215546Sopenharmony_ci case PIPE_CAP_THROTTLE: 448bf215546Sopenharmony_ci return u_pipe_screen_get_param_defaults(pscreen, param); 449bf215546Sopenharmony_ci } 450bf215546Sopenharmony_ci} 451bf215546Sopenharmony_ci 452bf215546Sopenharmony_cistatic int 453bf215546Sopenharmony_cinv50_screen_get_shader_param(struct pipe_screen *pscreen, 454bf215546Sopenharmony_ci enum pipe_shader_type shader, 455bf215546Sopenharmony_ci enum pipe_shader_cap param) 456bf215546Sopenharmony_ci{ 457bf215546Sopenharmony_ci const struct nouveau_screen *screen = nouveau_screen(pscreen); 458bf215546Sopenharmony_ci 459bf215546Sopenharmony_ci switch (shader) { 460bf215546Sopenharmony_ci case PIPE_SHADER_VERTEX: 461bf215546Sopenharmony_ci case PIPE_SHADER_GEOMETRY: 462bf215546Sopenharmony_ci case PIPE_SHADER_FRAGMENT: 463bf215546Sopenharmony_ci case PIPE_SHADER_COMPUTE: 464bf215546Sopenharmony_ci break; 465bf215546Sopenharmony_ci default: 466bf215546Sopenharmony_ci return 0; 467bf215546Sopenharmony_ci } 468bf215546Sopenharmony_ci 469bf215546Sopenharmony_ci switch (param) { 470bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_INSTRUCTIONS: 471bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS: 472bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS: 473bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS: 474bf215546Sopenharmony_ci return 16384; 475bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH: 476bf215546Sopenharmony_ci return 4; 477bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_INPUTS: 478bf215546Sopenharmony_ci if (shader == PIPE_SHADER_VERTEX) 479bf215546Sopenharmony_ci return 32; 480bf215546Sopenharmony_ci return 15; 481bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_OUTPUTS: 482bf215546Sopenharmony_ci return 16; 483bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_CONST_BUFFER0_SIZE: 484bf215546Sopenharmony_ci return 65536; 485bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_CONST_BUFFERS: 486bf215546Sopenharmony_ci return NV50_MAX_PIPE_CONSTBUFS; 487bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR: 488bf215546Sopenharmony_ci return shader != PIPE_SHADER_FRAGMENT; 489bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR: 490bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR: 491bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR: 492bf215546Sopenharmony_ci return 1; 493bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_TEMPS: 494bf215546Sopenharmony_ci return nv50_screen(pscreen)->max_tls_space / ONE_TEMP_SIZE; 495bf215546Sopenharmony_ci case PIPE_SHADER_CAP_CONT_SUPPORTED: 496bf215546Sopenharmony_ci return 1; 497bf215546Sopenharmony_ci case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED: 498bf215546Sopenharmony_ci return 1; 499bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INT64_ATOMICS: 500bf215546Sopenharmony_ci case PIPE_SHADER_CAP_FP16: 501bf215546Sopenharmony_ci case PIPE_SHADER_CAP_FP16_DERIVATIVES: 502bf215546Sopenharmony_ci case PIPE_SHADER_CAP_FP16_CONST_BUFFERS: 503bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INT16: 504bf215546Sopenharmony_ci case PIPE_SHADER_CAP_GLSL_16BIT_CONSTS: 505bf215546Sopenharmony_ci case PIPE_SHADER_CAP_SUBROUTINES: 506bf215546Sopenharmony_ci return 0; /* please inline, or provide function declarations */ 507bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INTEGERS: 508bf215546Sopenharmony_ci return 1; 509bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS: 510bf215546Sopenharmony_ci /* The chip could handle more sampler views than samplers */ 511bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS: 512bf215546Sopenharmony_ci return MIN2(16, PIPE_MAX_SAMPLERS); 513bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_SHADER_BUFFERS: 514bf215546Sopenharmony_ci return shader == PIPE_SHADER_COMPUTE ? NV50_MAX_GLOBALS - 1 : 0; 515bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_SHADER_IMAGES: 516bf215546Sopenharmony_ci return shader == PIPE_SHADER_COMPUTE ? NV50_MAX_GLOBALS - 1 : 0; 517bf215546Sopenharmony_ci case PIPE_SHADER_CAP_PREFERRED_IR: 518bf215546Sopenharmony_ci return screen->prefer_nir ? PIPE_SHADER_IR_NIR : PIPE_SHADER_IR_TGSI; 519bf215546Sopenharmony_ci case PIPE_SHADER_CAP_SUPPORTED_IRS: 520bf215546Sopenharmony_ci return (1 << PIPE_SHADER_IR_TGSI) | (1 << PIPE_SHADER_IR_NIR); 521bf215546Sopenharmony_ci case PIPE_SHADER_CAP_DROUND_SUPPORTED: 522bf215546Sopenharmony_ci case PIPE_SHADER_CAP_DFRACEXP_DLDEXP_SUPPORTED: 523bf215546Sopenharmony_ci case PIPE_SHADER_CAP_LDEXP_SUPPORTED: 524bf215546Sopenharmony_ci case PIPE_SHADER_CAP_TGSI_ANY_INOUT_DECL_RANGE: 525bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTERS: 526bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTER_BUFFERS: 527bf215546Sopenharmony_ci return 0; 528bf215546Sopenharmony_ci default: 529bf215546Sopenharmony_ci NOUVEAU_ERR("unknown PIPE_SHADER_CAP %d\n", param); 530bf215546Sopenharmony_ci return 0; 531bf215546Sopenharmony_ci } 532bf215546Sopenharmony_ci} 533bf215546Sopenharmony_ci 534bf215546Sopenharmony_cistatic float 535bf215546Sopenharmony_cinv50_screen_get_paramf(struct pipe_screen *pscreen, enum pipe_capf param) 536bf215546Sopenharmony_ci{ 537bf215546Sopenharmony_ci switch (param) { 538bf215546Sopenharmony_ci case PIPE_CAPF_MIN_LINE_WIDTH: 539bf215546Sopenharmony_ci case PIPE_CAPF_MIN_LINE_WIDTH_AA: 540bf215546Sopenharmony_ci case PIPE_CAPF_MIN_POINT_SIZE: 541bf215546Sopenharmony_ci case PIPE_CAPF_MIN_POINT_SIZE_AA: 542bf215546Sopenharmony_ci return 1; 543bf215546Sopenharmony_ci case PIPE_CAPF_POINT_SIZE_GRANULARITY: 544bf215546Sopenharmony_ci case PIPE_CAPF_LINE_WIDTH_GRANULARITY: 545bf215546Sopenharmony_ci return 0.1; 546bf215546Sopenharmony_ci case PIPE_CAPF_MAX_LINE_WIDTH: 547bf215546Sopenharmony_ci case PIPE_CAPF_MAX_LINE_WIDTH_AA: 548bf215546Sopenharmony_ci return 10.0f; 549bf215546Sopenharmony_ci case PIPE_CAPF_MAX_POINT_SIZE: 550bf215546Sopenharmony_ci case PIPE_CAPF_MAX_POINT_SIZE_AA: 551bf215546Sopenharmony_ci return 64.0f; 552bf215546Sopenharmony_ci case PIPE_CAPF_MAX_TEXTURE_ANISOTROPY: 553bf215546Sopenharmony_ci return 16.0f; 554bf215546Sopenharmony_ci case PIPE_CAPF_MAX_TEXTURE_LOD_BIAS: 555bf215546Sopenharmony_ci return 15.0f; 556bf215546Sopenharmony_ci case PIPE_CAPF_MIN_CONSERVATIVE_RASTER_DILATE: 557bf215546Sopenharmony_ci case PIPE_CAPF_MAX_CONSERVATIVE_RASTER_DILATE: 558bf215546Sopenharmony_ci case PIPE_CAPF_CONSERVATIVE_RASTER_DILATE_GRANULARITY: 559bf215546Sopenharmony_ci return 0.0f; 560bf215546Sopenharmony_ci } 561bf215546Sopenharmony_ci 562bf215546Sopenharmony_ci NOUVEAU_ERR("unknown PIPE_CAPF %d\n", param); 563bf215546Sopenharmony_ci return 0.0f; 564bf215546Sopenharmony_ci} 565bf215546Sopenharmony_ci 566bf215546Sopenharmony_cistatic int 567bf215546Sopenharmony_cinv50_screen_get_compute_param(struct pipe_screen *pscreen, 568bf215546Sopenharmony_ci enum pipe_shader_ir ir_type, 569bf215546Sopenharmony_ci enum pipe_compute_cap param, void *data) 570bf215546Sopenharmony_ci{ 571bf215546Sopenharmony_ci struct nv50_screen *screen = nv50_screen(pscreen); 572bf215546Sopenharmony_ci 573bf215546Sopenharmony_ci#define RET(x) do { \ 574bf215546Sopenharmony_ci if (data) \ 575bf215546Sopenharmony_ci memcpy(data, x, sizeof(x)); \ 576bf215546Sopenharmony_ci return sizeof(x); \ 577bf215546Sopenharmony_ci} while (0) 578bf215546Sopenharmony_ci 579bf215546Sopenharmony_ci switch (param) { 580bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_GRID_DIMENSION: 581bf215546Sopenharmony_ci RET((uint64_t []) { 3 }); 582bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_MAX_GRID_SIZE: 583bf215546Sopenharmony_ci RET(((uint64_t []) { 65535, 65535, 65535 })); 584bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE: 585bf215546Sopenharmony_ci RET(((uint64_t []) { 512, 512, 64 })); 586bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_MAX_THREADS_PER_BLOCK: 587bf215546Sopenharmony_ci RET((uint64_t []) { 512 }); 588bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE: /* g0-15[] */ 589bf215546Sopenharmony_ci RET((uint64_t []) { 1ULL << 32 }); 590bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_MAX_LOCAL_SIZE: /* s[] */ 591bf215546Sopenharmony_ci RET((uint64_t []) { 16 << 10 }); 592bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_MAX_PRIVATE_SIZE: /* l[] */ 593bf215546Sopenharmony_ci RET((uint64_t []) { 16 << 10 }); 594bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_MAX_INPUT_SIZE: /* c[], arbitrary limit */ 595bf215546Sopenharmony_ci RET((uint64_t []) { 4096 }); 596bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_SUBGROUP_SIZE: 597bf215546Sopenharmony_ci RET((uint32_t []) { 32 }); 598bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_MAX_MEM_ALLOC_SIZE: 599bf215546Sopenharmony_ci RET((uint64_t []) { 1ULL << 40 }); 600bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_IMAGES_SUPPORTED: 601bf215546Sopenharmony_ci RET((uint32_t []) { 0 }); 602bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_MAX_COMPUTE_UNITS: 603bf215546Sopenharmony_ci RET((uint32_t []) { screen->mp_count }); 604bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_MAX_CLOCK_FREQUENCY: 605bf215546Sopenharmony_ci RET((uint32_t []) { 512 }); /* FIXME: arbitrary limit */ 606bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_ADDRESS_BITS: 607bf215546Sopenharmony_ci RET((uint32_t []) { 32 }); 608bf215546Sopenharmony_ci case PIPE_COMPUTE_CAP_MAX_VARIABLE_THREADS_PER_BLOCK: 609bf215546Sopenharmony_ci RET((uint64_t []) { 0 }); 610bf215546Sopenharmony_ci default: 611bf215546Sopenharmony_ci return 0; 612bf215546Sopenharmony_ci } 613bf215546Sopenharmony_ci 614bf215546Sopenharmony_ci#undef RET 615bf215546Sopenharmony_ci} 616bf215546Sopenharmony_ci 617bf215546Sopenharmony_cistatic void 618bf215546Sopenharmony_cinv50_screen_destroy(struct pipe_screen *pscreen) 619bf215546Sopenharmony_ci{ 620bf215546Sopenharmony_ci struct nv50_screen *screen = nv50_screen(pscreen); 621bf215546Sopenharmony_ci 622bf215546Sopenharmony_ci if (!nouveau_drm_screen_unref(&screen->base)) 623bf215546Sopenharmony_ci return; 624bf215546Sopenharmony_ci 625bf215546Sopenharmony_ci nouveau_fence_cleanup(&screen->base); 626bf215546Sopenharmony_ci 627bf215546Sopenharmony_ci if (screen->base.pushbuf) 628bf215546Sopenharmony_ci screen->base.pushbuf->user_priv = NULL; 629bf215546Sopenharmony_ci 630bf215546Sopenharmony_ci if (screen->blitter) 631bf215546Sopenharmony_ci nv50_blitter_destroy(screen); 632bf215546Sopenharmony_ci if (screen->pm.prog) { 633bf215546Sopenharmony_ci screen->pm.prog->code = NULL; /* hardcoded, don't FREE */ 634bf215546Sopenharmony_ci nv50_program_destroy(NULL, screen->pm.prog); 635bf215546Sopenharmony_ci FREE(screen->pm.prog); 636bf215546Sopenharmony_ci } 637bf215546Sopenharmony_ci 638bf215546Sopenharmony_ci nouveau_bo_ref(NULL, &screen->code); 639bf215546Sopenharmony_ci nouveau_bo_ref(NULL, &screen->tls_bo); 640bf215546Sopenharmony_ci nouveau_bo_ref(NULL, &screen->stack_bo); 641bf215546Sopenharmony_ci nouveau_bo_ref(NULL, &screen->txc); 642bf215546Sopenharmony_ci nouveau_bo_ref(NULL, &screen->uniforms); 643bf215546Sopenharmony_ci nouveau_bo_ref(NULL, &screen->fence.bo); 644bf215546Sopenharmony_ci 645bf215546Sopenharmony_ci nouveau_heap_destroy(&screen->vp_code_heap); 646bf215546Sopenharmony_ci nouveau_heap_destroy(&screen->gp_code_heap); 647bf215546Sopenharmony_ci nouveau_heap_destroy(&screen->fp_code_heap); 648bf215546Sopenharmony_ci 649bf215546Sopenharmony_ci FREE(screen->tic.entries); 650bf215546Sopenharmony_ci 651bf215546Sopenharmony_ci nouveau_object_del(&screen->tesla); 652bf215546Sopenharmony_ci nouveau_object_del(&screen->eng2d); 653bf215546Sopenharmony_ci nouveau_object_del(&screen->m2mf); 654bf215546Sopenharmony_ci nouveau_object_del(&screen->compute); 655bf215546Sopenharmony_ci nouveau_object_del(&screen->sync); 656bf215546Sopenharmony_ci 657bf215546Sopenharmony_ci nouveau_screen_fini(&screen->base); 658bf215546Sopenharmony_ci 659bf215546Sopenharmony_ci FREE(screen); 660bf215546Sopenharmony_ci} 661bf215546Sopenharmony_ci 662bf215546Sopenharmony_cistatic void 663bf215546Sopenharmony_cinv50_screen_fence_emit(struct pipe_screen *pscreen, u32 *sequence) 664bf215546Sopenharmony_ci{ 665bf215546Sopenharmony_ci struct nv50_screen *screen = nv50_screen(pscreen); 666bf215546Sopenharmony_ci struct nouveau_pushbuf *push = screen->base.pushbuf; 667bf215546Sopenharmony_ci 668bf215546Sopenharmony_ci /* we need to do it after possible flush in MARK_RING */ 669bf215546Sopenharmony_ci *sequence = ++screen->base.fence.sequence; 670bf215546Sopenharmony_ci 671bf215546Sopenharmony_ci assert(PUSH_AVAIL(push) + push->rsvd_kick >= 5); 672bf215546Sopenharmony_ci PUSH_DATA (push, NV50_FIFO_PKHDR(NV50_3D(QUERY_ADDRESS_HIGH), 4)); 673bf215546Sopenharmony_ci PUSH_DATAh(push, screen->fence.bo->offset); 674bf215546Sopenharmony_ci PUSH_DATA (push, screen->fence.bo->offset); 675bf215546Sopenharmony_ci PUSH_DATA (push, *sequence); 676bf215546Sopenharmony_ci PUSH_DATA (push, NV50_3D_QUERY_GET_MODE_WRITE_UNK0 | 677bf215546Sopenharmony_ci NV50_3D_QUERY_GET_UNK4 | 678bf215546Sopenharmony_ci NV50_3D_QUERY_GET_UNIT_CROP | 679bf215546Sopenharmony_ci NV50_3D_QUERY_GET_TYPE_QUERY | 680bf215546Sopenharmony_ci NV50_3D_QUERY_GET_QUERY_SELECT_ZERO | 681bf215546Sopenharmony_ci NV50_3D_QUERY_GET_SHORT); 682bf215546Sopenharmony_ci} 683bf215546Sopenharmony_ci 684bf215546Sopenharmony_cistatic u32 685bf215546Sopenharmony_cinv50_screen_fence_update(struct pipe_screen *pscreen) 686bf215546Sopenharmony_ci{ 687bf215546Sopenharmony_ci return nv50_screen(pscreen)->fence.map[0]; 688bf215546Sopenharmony_ci} 689bf215546Sopenharmony_ci 690bf215546Sopenharmony_cistatic void 691bf215546Sopenharmony_cinv50_screen_init_hwctx(struct nv50_screen *screen) 692bf215546Sopenharmony_ci{ 693bf215546Sopenharmony_ci struct nouveau_pushbuf *push = screen->base.pushbuf; 694bf215546Sopenharmony_ci struct nv04_fifo *fifo; 695bf215546Sopenharmony_ci unsigned i; 696bf215546Sopenharmony_ci 697bf215546Sopenharmony_ci fifo = (struct nv04_fifo *)screen->base.channel->data; 698bf215546Sopenharmony_ci 699bf215546Sopenharmony_ci BEGIN_NV04(push, SUBC_M2MF(NV01_SUBCHAN_OBJECT), 1); 700bf215546Sopenharmony_ci PUSH_DATA (push, screen->m2mf->handle); 701bf215546Sopenharmony_ci BEGIN_NV04(push, SUBC_M2MF(NV03_M2MF_DMA_NOTIFY), 3); 702bf215546Sopenharmony_ci PUSH_DATA (push, screen->sync->handle); 703bf215546Sopenharmony_ci PUSH_DATA (push, fifo->vram); 704bf215546Sopenharmony_ci PUSH_DATA (push, fifo->vram); 705bf215546Sopenharmony_ci 706bf215546Sopenharmony_ci BEGIN_NV04(push, SUBC_2D(NV01_SUBCHAN_OBJECT), 1); 707bf215546Sopenharmony_ci PUSH_DATA (push, screen->eng2d->handle); 708bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_2D(DMA_NOTIFY), 4); 709bf215546Sopenharmony_ci PUSH_DATA (push, screen->sync->handle); 710bf215546Sopenharmony_ci PUSH_DATA (push, fifo->vram); 711bf215546Sopenharmony_ci PUSH_DATA (push, fifo->vram); 712bf215546Sopenharmony_ci PUSH_DATA (push, fifo->vram); 713bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_2D(OPERATION), 1); 714bf215546Sopenharmony_ci PUSH_DATA (push, NV50_2D_OPERATION_SRCCOPY); 715bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_2D(CLIP_ENABLE), 1); 716bf215546Sopenharmony_ci PUSH_DATA (push, 0); 717bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_2D(COLOR_KEY_ENABLE), 1); 718bf215546Sopenharmony_ci PUSH_DATA (push, 0); 719bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_2D(SET_PIXELS_FROM_MEMORY_SAFE_OVERLAP), 1); 720bf215546Sopenharmony_ci PUSH_DATA (push, 1); 721bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_2D(COND_MODE), 1); 722bf215546Sopenharmony_ci PUSH_DATA (push, NV50_2D_COND_MODE_ALWAYS); 723bf215546Sopenharmony_ci 724bf215546Sopenharmony_ci BEGIN_NV04(push, SUBC_3D(NV01_SUBCHAN_OBJECT), 1); 725bf215546Sopenharmony_ci PUSH_DATA (push, screen->tesla->handle); 726bf215546Sopenharmony_ci 727bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(COND_MODE), 1); 728bf215546Sopenharmony_ci PUSH_DATA (push, NV50_3D_COND_MODE_ALWAYS); 729bf215546Sopenharmony_ci 730bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(DMA_NOTIFY), 1); 731bf215546Sopenharmony_ci PUSH_DATA (push, screen->sync->handle); 732bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(DMA_ZETA), 11); 733bf215546Sopenharmony_ci for (i = 0; i < 11; ++i) 734bf215546Sopenharmony_ci PUSH_DATA(push, fifo->vram); 735bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(DMA_COLOR(0)), NV50_3D_DMA_COLOR__LEN); 736bf215546Sopenharmony_ci for (i = 0; i < NV50_3D_DMA_COLOR__LEN; ++i) 737bf215546Sopenharmony_ci PUSH_DATA(push, fifo->vram); 738bf215546Sopenharmony_ci 739bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(REG_MODE), 1); 740bf215546Sopenharmony_ci PUSH_DATA (push, NV50_3D_REG_MODE_STRIPED); 741bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(UNK1400_LANES), 1); 742bf215546Sopenharmony_ci PUSH_DATA (push, 0xf); 743bf215546Sopenharmony_ci 744bf215546Sopenharmony_ci if (debug_get_bool_option("NOUVEAU_SHADER_WATCHDOG", true)) { 745bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(WATCHDOG_TIMER), 1); 746bf215546Sopenharmony_ci PUSH_DATA (push, 0x18); 747bf215546Sopenharmony_ci } 748bf215546Sopenharmony_ci 749bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(ZETA_COMP_ENABLE), 1); 750bf215546Sopenharmony_ci PUSH_DATA(push, screen->base.drm->version >= 0x01000101); 751bf215546Sopenharmony_ci 752bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(RT_COMP_ENABLE(0)), 8); 753bf215546Sopenharmony_ci for (i = 0; i < 8; ++i) 754bf215546Sopenharmony_ci PUSH_DATA(push, screen->base.drm->version >= 0x01000101); 755bf215546Sopenharmony_ci 756bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(RT_CONTROL), 1); 757bf215546Sopenharmony_ci PUSH_DATA (push, 1); 758bf215546Sopenharmony_ci 759bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(CSAA_ENABLE), 1); 760bf215546Sopenharmony_ci PUSH_DATA (push, 0); 761bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(MULTISAMPLE_ENABLE), 1); 762bf215546Sopenharmony_ci PUSH_DATA (push, 0); 763bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(MULTISAMPLE_MODE), 1); 764bf215546Sopenharmony_ci PUSH_DATA (push, NV50_3D_MULTISAMPLE_MODE_MS1); 765bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(MULTISAMPLE_CTRL), 1); 766bf215546Sopenharmony_ci PUSH_DATA (push, 0); 767bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(PRIM_RESTART_WITH_DRAW_ARRAYS), 1); 768bf215546Sopenharmony_ci PUSH_DATA (push, 1); 769bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(BLEND_SEPARATE_ALPHA), 1); 770bf215546Sopenharmony_ci PUSH_DATA (push, 1); 771bf215546Sopenharmony_ci 772bf215546Sopenharmony_ci if (screen->tesla->oclass >= NVA0_3D_CLASS) { 773bf215546Sopenharmony_ci BEGIN_NV04(push, SUBC_3D(NVA0_3D_TEX_MISC), 1); 774bf215546Sopenharmony_ci PUSH_DATA (push, 0); 775bf215546Sopenharmony_ci } 776bf215546Sopenharmony_ci 777bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(SCREEN_Y_CONTROL), 1); 778bf215546Sopenharmony_ci PUSH_DATA (push, 0); 779bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(WINDOW_OFFSET_X), 2); 780bf215546Sopenharmony_ci PUSH_DATA (push, 0); 781bf215546Sopenharmony_ci PUSH_DATA (push, 0); 782bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(ZCULL_REGION), 1); 783bf215546Sopenharmony_ci PUSH_DATA (push, 0x3f); 784bf215546Sopenharmony_ci 785bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(VP_ADDRESS_HIGH), 2); 786bf215546Sopenharmony_ci PUSH_DATAh(push, screen->code->offset + (0 << NV50_CODE_BO_SIZE_LOG2)); 787bf215546Sopenharmony_ci PUSH_DATA (push, screen->code->offset + (0 << NV50_CODE_BO_SIZE_LOG2)); 788bf215546Sopenharmony_ci 789bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(FP_ADDRESS_HIGH), 2); 790bf215546Sopenharmony_ci PUSH_DATAh(push, screen->code->offset + (1 << NV50_CODE_BO_SIZE_LOG2)); 791bf215546Sopenharmony_ci PUSH_DATA (push, screen->code->offset + (1 << NV50_CODE_BO_SIZE_LOG2)); 792bf215546Sopenharmony_ci 793bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(GP_ADDRESS_HIGH), 2); 794bf215546Sopenharmony_ci PUSH_DATAh(push, screen->code->offset + (2 << NV50_CODE_BO_SIZE_LOG2)); 795bf215546Sopenharmony_ci PUSH_DATA (push, screen->code->offset + (2 << NV50_CODE_BO_SIZE_LOG2)); 796bf215546Sopenharmony_ci 797bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(LOCAL_ADDRESS_HIGH), 3); 798bf215546Sopenharmony_ci PUSH_DATAh(push, screen->tls_bo->offset); 799bf215546Sopenharmony_ci PUSH_DATA (push, screen->tls_bo->offset); 800bf215546Sopenharmony_ci PUSH_DATA (push, util_logbase2(screen->cur_tls_space / 8)); 801bf215546Sopenharmony_ci 802bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(STACK_ADDRESS_HIGH), 3); 803bf215546Sopenharmony_ci PUSH_DATAh(push, screen->stack_bo->offset); 804bf215546Sopenharmony_ci PUSH_DATA (push, screen->stack_bo->offset); 805bf215546Sopenharmony_ci PUSH_DATA (push, 4); 806bf215546Sopenharmony_ci 807bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(CB_DEF_ADDRESS_HIGH), 3); 808bf215546Sopenharmony_ci PUSH_DATAh(push, screen->uniforms->offset + (0 << 16)); 809bf215546Sopenharmony_ci PUSH_DATA (push, screen->uniforms->offset + (0 << 16)); 810bf215546Sopenharmony_ci PUSH_DATA (push, (NV50_CB_PVP << 16) | 0x0000); 811bf215546Sopenharmony_ci 812bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(CB_DEF_ADDRESS_HIGH), 3); 813bf215546Sopenharmony_ci PUSH_DATAh(push, screen->uniforms->offset + (1 << 16)); 814bf215546Sopenharmony_ci PUSH_DATA (push, screen->uniforms->offset + (1 << 16)); 815bf215546Sopenharmony_ci PUSH_DATA (push, (NV50_CB_PGP << 16) | 0x0000); 816bf215546Sopenharmony_ci 817bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(CB_DEF_ADDRESS_HIGH), 3); 818bf215546Sopenharmony_ci PUSH_DATAh(push, screen->uniforms->offset + (2 << 16)); 819bf215546Sopenharmony_ci PUSH_DATA (push, screen->uniforms->offset + (2 << 16)); 820bf215546Sopenharmony_ci PUSH_DATA (push, (NV50_CB_PFP << 16) | 0x0000); 821bf215546Sopenharmony_ci 822bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(CB_DEF_ADDRESS_HIGH), 3); 823bf215546Sopenharmony_ci PUSH_DATAh(push, screen->uniforms->offset + (4 << 16)); 824bf215546Sopenharmony_ci PUSH_DATA (push, screen->uniforms->offset + (4 << 16)); 825bf215546Sopenharmony_ci PUSH_DATA (push, (NV50_CB_AUX << 16) | (NV50_CB_AUX_SIZE & 0xffff)); 826bf215546Sopenharmony_ci 827bf215546Sopenharmony_ci BEGIN_NI04(push, NV50_3D(SET_PROGRAM_CB), 3); 828bf215546Sopenharmony_ci PUSH_DATA (push, (NV50_CB_AUX << 12) | 0xf01); 829bf215546Sopenharmony_ci PUSH_DATA (push, (NV50_CB_AUX << 12) | 0xf21); 830bf215546Sopenharmony_ci PUSH_DATA (push, (NV50_CB_AUX << 12) | 0xf31); 831bf215546Sopenharmony_ci 832bf215546Sopenharmony_ci /* return { 0.0, 0.0, 0.0, 0.0 } on out-of-bounds vtxbuf access */ 833bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(CB_ADDR), 1); 834bf215546Sopenharmony_ci PUSH_DATA (push, (NV50_CB_AUX_RUNOUT_OFFSET << (8 - 2)) | NV50_CB_AUX); 835bf215546Sopenharmony_ci BEGIN_NI04(push, NV50_3D(CB_DATA(0)), 4); 836bf215546Sopenharmony_ci PUSH_DATAf(push, 0.0f); 837bf215546Sopenharmony_ci PUSH_DATAf(push, 0.0f); 838bf215546Sopenharmony_ci PUSH_DATAf(push, 0.0f); 839bf215546Sopenharmony_ci PUSH_DATAf(push, 0.0f); 840bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(VERTEX_RUNOUT_ADDRESS_HIGH), 2); 841bf215546Sopenharmony_ci PUSH_DATAh(push, screen->uniforms->offset + (4 << 16) + NV50_CB_AUX_RUNOUT_OFFSET); 842bf215546Sopenharmony_ci PUSH_DATA (push, screen->uniforms->offset + (4 << 16) + NV50_CB_AUX_RUNOUT_OFFSET); 843bf215546Sopenharmony_ci 844bf215546Sopenharmony_ci /* set the membar offset */ 845bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(CB_ADDR), 1); 846bf215546Sopenharmony_ci PUSH_DATA (push, (NV50_CB_AUX_MEMBAR_OFFSET << (8 - 2)) | NV50_CB_AUX); 847bf215546Sopenharmony_ci BEGIN_NI04(push, NV50_3D(CB_DATA(0)), 1); 848bf215546Sopenharmony_ci PUSH_DATA (push, screen->uniforms->offset + (4 << 16) + NV50_CB_AUX_MEMBAR_OFFSET); 849bf215546Sopenharmony_ci 850bf215546Sopenharmony_ci nv50_upload_ms_info(push); 851bf215546Sopenharmony_ci 852bf215546Sopenharmony_ci /* max TIC (bits 4:8) & TSC bindings, per program type */ 853bf215546Sopenharmony_ci for (i = 0; i < NV50_MAX_3D_SHADER_STAGES; ++i) { 854bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(TEX_LIMITS(i)), 1); 855bf215546Sopenharmony_ci PUSH_DATA (push, 0x54); 856bf215546Sopenharmony_ci } 857bf215546Sopenharmony_ci 858bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(TIC_ADDRESS_HIGH), 3); 859bf215546Sopenharmony_ci PUSH_DATAh(push, screen->txc->offset); 860bf215546Sopenharmony_ci PUSH_DATA (push, screen->txc->offset); 861bf215546Sopenharmony_ci PUSH_DATA (push, NV50_TIC_MAX_ENTRIES - 1); 862bf215546Sopenharmony_ci 863bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(TSC_ADDRESS_HIGH), 3); 864bf215546Sopenharmony_ci PUSH_DATAh(push, screen->txc->offset + 65536); 865bf215546Sopenharmony_ci PUSH_DATA (push, screen->txc->offset + 65536); 866bf215546Sopenharmony_ci PUSH_DATA (push, NV50_TSC_MAX_ENTRIES - 1); 867bf215546Sopenharmony_ci 868bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(LINKED_TSC), 1); 869bf215546Sopenharmony_ci PUSH_DATA (push, 0); 870bf215546Sopenharmony_ci 871bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(CLIP_RECTS_EN), 1); 872bf215546Sopenharmony_ci PUSH_DATA (push, 0); 873bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(CLIP_RECTS_MODE), 1); 874bf215546Sopenharmony_ci PUSH_DATA (push, NV50_3D_CLIP_RECTS_MODE_INSIDE_ANY); 875bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(CLIP_RECT_HORIZ(0)), 8 * 2); 876bf215546Sopenharmony_ci for (i = 0; i < 8 * 2; ++i) 877bf215546Sopenharmony_ci PUSH_DATA(push, 0); 878bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(CLIPID_ENABLE), 1); 879bf215546Sopenharmony_ci PUSH_DATA (push, 0); 880bf215546Sopenharmony_ci 881bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(VIEWPORT_TRANSFORM_EN), 1); 882bf215546Sopenharmony_ci PUSH_DATA (push, 1); 883bf215546Sopenharmony_ci for (i = 0; i < NV50_MAX_VIEWPORTS; i++) { 884bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(DEPTH_RANGE_NEAR(i)), 2); 885bf215546Sopenharmony_ci PUSH_DATAf(push, 0.0f); 886bf215546Sopenharmony_ci PUSH_DATAf(push, 1.0f); 887bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(VIEWPORT_HORIZ(i)), 2); 888bf215546Sopenharmony_ci PUSH_DATA (push, 8192 << 16); 889bf215546Sopenharmony_ci PUSH_DATA (push, 8192 << 16); 890bf215546Sopenharmony_ci } 891bf215546Sopenharmony_ci 892bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(VIEW_VOLUME_CLIP_CTRL), 1); 893bf215546Sopenharmony_ci#ifdef NV50_SCISSORS_CLIPPING 894bf215546Sopenharmony_ci PUSH_DATA (push, 0x0000); 895bf215546Sopenharmony_ci#else 896bf215546Sopenharmony_ci PUSH_DATA (push, 0x1080); 897bf215546Sopenharmony_ci#endif 898bf215546Sopenharmony_ci 899bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(CLEAR_FLAGS), 1); 900bf215546Sopenharmony_ci PUSH_DATA (push, NV50_3D_CLEAR_FLAGS_CLEAR_RECT_VIEWPORT); 901bf215546Sopenharmony_ci 902bf215546Sopenharmony_ci /* We use scissors instead of exact view volume clipping, 903bf215546Sopenharmony_ci * so they're always enabled. 904bf215546Sopenharmony_ci */ 905bf215546Sopenharmony_ci for (i = 0; i < NV50_MAX_VIEWPORTS; i++) { 906bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(SCISSOR_ENABLE(i)), 3); 907bf215546Sopenharmony_ci PUSH_DATA (push, 1); 908bf215546Sopenharmony_ci PUSH_DATA (push, 8192 << 16); 909bf215546Sopenharmony_ci PUSH_DATA (push, 8192 << 16); 910bf215546Sopenharmony_ci } 911bf215546Sopenharmony_ci 912bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(RASTERIZE_ENABLE), 1); 913bf215546Sopenharmony_ci PUSH_DATA (push, 1); 914bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(POINT_RASTER_RULES), 1); 915bf215546Sopenharmony_ci PUSH_DATA (push, NV50_3D_POINT_RASTER_RULES_OGL); 916bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(FRAG_COLOR_CLAMP_EN), 1); 917bf215546Sopenharmony_ci PUSH_DATA (push, 0x11111111); 918bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(EDGEFLAG), 1); 919bf215546Sopenharmony_ci PUSH_DATA (push, 1); 920bf215546Sopenharmony_ci 921bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(VB_ELEMENT_BASE), 1); 922bf215546Sopenharmony_ci PUSH_DATA (push, 0); 923bf215546Sopenharmony_ci if (screen->base.class_3d >= NV84_3D_CLASS) { 924bf215546Sopenharmony_ci BEGIN_NV04(push, NV84_3D(VERTEX_ID_BASE), 1); 925bf215546Sopenharmony_ci PUSH_DATA (push, 0); 926bf215546Sopenharmony_ci } 927bf215546Sopenharmony_ci 928bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(UNK0FDC), 1); 929bf215546Sopenharmony_ci PUSH_DATA (push, 1); 930bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(UNK19C0), 1); 931bf215546Sopenharmony_ci PUSH_DATA (push, 1); 932bf215546Sopenharmony_ci 933bf215546Sopenharmony_ci PUSH_KICK (push); 934bf215546Sopenharmony_ci} 935bf215546Sopenharmony_ci 936bf215546Sopenharmony_cistatic int nv50_tls_alloc(struct nv50_screen *screen, unsigned tls_space, 937bf215546Sopenharmony_ci uint64_t *tls_size) 938bf215546Sopenharmony_ci{ 939bf215546Sopenharmony_ci struct nouveau_device *dev = screen->base.device; 940bf215546Sopenharmony_ci int ret; 941bf215546Sopenharmony_ci 942bf215546Sopenharmony_ci assert(tls_space % ONE_TEMP_SIZE == 0); 943bf215546Sopenharmony_ci screen->cur_tls_space = util_next_power_of_two(tls_space / ONE_TEMP_SIZE) * 944bf215546Sopenharmony_ci ONE_TEMP_SIZE; 945bf215546Sopenharmony_ci if (nouveau_mesa_debug) 946bf215546Sopenharmony_ci debug_printf("allocating space for %u temps\n", 947bf215546Sopenharmony_ci util_next_power_of_two(tls_space / ONE_TEMP_SIZE)); 948bf215546Sopenharmony_ci *tls_size = screen->cur_tls_space * util_next_power_of_two(screen->TPs) * 949bf215546Sopenharmony_ci screen->MPsInTP * LOCAL_WARPS_ALLOC * THREADS_IN_WARP; 950bf215546Sopenharmony_ci 951bf215546Sopenharmony_ci ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 1 << 16, 952bf215546Sopenharmony_ci *tls_size, NULL, &screen->tls_bo); 953bf215546Sopenharmony_ci if (ret) { 954bf215546Sopenharmony_ci NOUVEAU_ERR("Failed to allocate local bo: %d\n", ret); 955bf215546Sopenharmony_ci return ret; 956bf215546Sopenharmony_ci } 957bf215546Sopenharmony_ci 958bf215546Sopenharmony_ci return 0; 959bf215546Sopenharmony_ci} 960bf215546Sopenharmony_ci 961bf215546Sopenharmony_ciint nv50_tls_realloc(struct nv50_screen *screen, unsigned tls_space) 962bf215546Sopenharmony_ci{ 963bf215546Sopenharmony_ci struct nouveau_pushbuf *push = screen->base.pushbuf; 964bf215546Sopenharmony_ci int ret; 965bf215546Sopenharmony_ci uint64_t tls_size; 966bf215546Sopenharmony_ci 967bf215546Sopenharmony_ci if (tls_space < screen->cur_tls_space) 968bf215546Sopenharmony_ci return 0; 969bf215546Sopenharmony_ci if (tls_space > screen->max_tls_space) { 970bf215546Sopenharmony_ci /* fixable by limiting number of warps (LOCAL_WARPS_LOG_ALLOC / 971bf215546Sopenharmony_ci * LOCAL_WARPS_NO_CLAMP) */ 972bf215546Sopenharmony_ci NOUVEAU_ERR("Unsupported number of temporaries (%u > %u). Fixable if someone cares.\n", 973bf215546Sopenharmony_ci (unsigned)(tls_space / ONE_TEMP_SIZE), 974bf215546Sopenharmony_ci (unsigned)(screen->max_tls_space / ONE_TEMP_SIZE)); 975bf215546Sopenharmony_ci return -ENOMEM; 976bf215546Sopenharmony_ci } 977bf215546Sopenharmony_ci 978bf215546Sopenharmony_ci nouveau_bo_ref(NULL, &screen->tls_bo); 979bf215546Sopenharmony_ci ret = nv50_tls_alloc(screen, tls_space, &tls_size); 980bf215546Sopenharmony_ci if (ret) 981bf215546Sopenharmony_ci return ret; 982bf215546Sopenharmony_ci 983bf215546Sopenharmony_ci BEGIN_NV04(push, NV50_3D(LOCAL_ADDRESS_HIGH), 3); 984bf215546Sopenharmony_ci PUSH_DATAh(push, screen->tls_bo->offset); 985bf215546Sopenharmony_ci PUSH_DATA (push, screen->tls_bo->offset); 986bf215546Sopenharmony_ci PUSH_DATA (push, util_logbase2(screen->cur_tls_space / 8)); 987bf215546Sopenharmony_ci 988bf215546Sopenharmony_ci return 1; 989bf215546Sopenharmony_ci} 990bf215546Sopenharmony_ci 991bf215546Sopenharmony_cistatic const void * 992bf215546Sopenharmony_cinv50_screen_get_compiler_options(struct pipe_screen *pscreen, 993bf215546Sopenharmony_ci enum pipe_shader_ir ir, 994bf215546Sopenharmony_ci enum pipe_shader_type shader) 995bf215546Sopenharmony_ci{ 996bf215546Sopenharmony_ci if (ir == PIPE_SHADER_IR_NIR) 997bf215546Sopenharmony_ci return nv50_ir_nir_shader_compiler_options(NVISA_G80_CHIPSET, shader); 998bf215546Sopenharmony_ci return NULL; 999bf215546Sopenharmony_ci} 1000bf215546Sopenharmony_ci 1001bf215546Sopenharmony_cistruct nouveau_screen * 1002bf215546Sopenharmony_cinv50_screen_create(struct nouveau_device *dev) 1003bf215546Sopenharmony_ci{ 1004bf215546Sopenharmony_ci struct nv50_screen *screen; 1005bf215546Sopenharmony_ci struct pipe_screen *pscreen; 1006bf215546Sopenharmony_ci struct nouveau_object *chan; 1007bf215546Sopenharmony_ci uint64_t value; 1008bf215546Sopenharmony_ci uint32_t tesla_class; 1009bf215546Sopenharmony_ci unsigned stack_size; 1010bf215546Sopenharmony_ci int ret; 1011bf215546Sopenharmony_ci 1012bf215546Sopenharmony_ci screen = CALLOC_STRUCT(nv50_screen); 1013bf215546Sopenharmony_ci if (!screen) 1014bf215546Sopenharmony_ci return NULL; 1015bf215546Sopenharmony_ci pscreen = &screen->base.base; 1016bf215546Sopenharmony_ci pscreen->destroy = nv50_screen_destroy; 1017bf215546Sopenharmony_ci 1018bf215546Sopenharmony_ci ret = nouveau_screen_init(&screen->base, dev); 1019bf215546Sopenharmony_ci if (ret) { 1020bf215546Sopenharmony_ci NOUVEAU_ERR("nouveau_screen_init failed: %d\n", ret); 1021bf215546Sopenharmony_ci goto fail; 1022bf215546Sopenharmony_ci } 1023bf215546Sopenharmony_ci 1024bf215546Sopenharmony_ci /* TODO: Prevent FIFO prefetch before transfer of index buffers and 1025bf215546Sopenharmony_ci * admit them to VRAM. 1026bf215546Sopenharmony_ci */ 1027bf215546Sopenharmony_ci screen->base.vidmem_bindings |= PIPE_BIND_CONSTANT_BUFFER | 1028bf215546Sopenharmony_ci PIPE_BIND_VERTEX_BUFFER; 1029bf215546Sopenharmony_ci screen->base.sysmem_bindings |= 1030bf215546Sopenharmony_ci PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER; 1031bf215546Sopenharmony_ci 1032bf215546Sopenharmony_ci screen->base.pushbuf->user_priv = screen; 1033bf215546Sopenharmony_ci screen->base.pushbuf->rsvd_kick = 5; 1034bf215546Sopenharmony_ci 1035bf215546Sopenharmony_ci chan = screen->base.channel; 1036bf215546Sopenharmony_ci 1037bf215546Sopenharmony_ci pscreen->context_create = nv50_create; 1038bf215546Sopenharmony_ci pscreen->is_format_supported = nv50_screen_is_format_supported; 1039bf215546Sopenharmony_ci pscreen->get_param = nv50_screen_get_param; 1040bf215546Sopenharmony_ci pscreen->get_shader_param = nv50_screen_get_shader_param; 1041bf215546Sopenharmony_ci pscreen->get_paramf = nv50_screen_get_paramf; 1042bf215546Sopenharmony_ci pscreen->get_compute_param = nv50_screen_get_compute_param; 1043bf215546Sopenharmony_ci pscreen->get_driver_query_info = nv50_screen_get_driver_query_info; 1044bf215546Sopenharmony_ci pscreen->get_driver_query_group_info = nv50_screen_get_driver_query_group_info; 1045bf215546Sopenharmony_ci 1046bf215546Sopenharmony_ci /* nir stuff */ 1047bf215546Sopenharmony_ci pscreen->get_compiler_options = nv50_screen_get_compiler_options; 1048bf215546Sopenharmony_ci 1049bf215546Sopenharmony_ci nv50_screen_init_resource_functions(pscreen); 1050bf215546Sopenharmony_ci 1051bf215546Sopenharmony_ci if (screen->base.device->chipset < 0x84 || 1052bf215546Sopenharmony_ci debug_get_bool_option("NOUVEAU_PMPEG", false)) { 1053bf215546Sopenharmony_ci /* PMPEG */ 1054bf215546Sopenharmony_ci nouveau_screen_init_vdec(&screen->base); 1055bf215546Sopenharmony_ci } else if (screen->base.device->chipset < 0x98 || 1056bf215546Sopenharmony_ci screen->base.device->chipset == 0xa0) { 1057bf215546Sopenharmony_ci /* VP2 */ 1058bf215546Sopenharmony_ci screen->base.base.get_video_param = nv84_screen_get_video_param; 1059bf215546Sopenharmony_ci screen->base.base.is_video_format_supported = nv84_screen_video_supported; 1060bf215546Sopenharmony_ci } else { 1061bf215546Sopenharmony_ci /* VP3/4 */ 1062bf215546Sopenharmony_ci screen->base.base.get_video_param = nouveau_vp3_screen_get_video_param; 1063bf215546Sopenharmony_ci screen->base.base.is_video_format_supported = nouveau_vp3_screen_video_supported; 1064bf215546Sopenharmony_ci } 1065bf215546Sopenharmony_ci 1066bf215546Sopenharmony_ci ret = nouveau_bo_new(dev, NOUVEAU_BO_GART | NOUVEAU_BO_MAP, 0, 4096, 1067bf215546Sopenharmony_ci NULL, &screen->fence.bo); 1068bf215546Sopenharmony_ci if (ret) { 1069bf215546Sopenharmony_ci NOUVEAU_ERR("Failed to allocate fence bo: %d\n", ret); 1070bf215546Sopenharmony_ci goto fail; 1071bf215546Sopenharmony_ci } 1072bf215546Sopenharmony_ci 1073bf215546Sopenharmony_ci nouveau_bo_map(screen->fence.bo, 0, NULL); 1074bf215546Sopenharmony_ci screen->fence.map = screen->fence.bo->map; 1075bf215546Sopenharmony_ci screen->base.fence.emit = nv50_screen_fence_emit; 1076bf215546Sopenharmony_ci screen->base.fence.update = nv50_screen_fence_update; 1077bf215546Sopenharmony_ci 1078bf215546Sopenharmony_ci ret = nouveau_object_new(chan, 0xbeef0301, NOUVEAU_NOTIFIER_CLASS, 1079bf215546Sopenharmony_ci &(struct nv04_notify){ .length = 32 }, 1080bf215546Sopenharmony_ci sizeof(struct nv04_notify), &screen->sync); 1081bf215546Sopenharmony_ci if (ret) { 1082bf215546Sopenharmony_ci NOUVEAU_ERR("Failed to allocate notifier: %d\n", ret); 1083bf215546Sopenharmony_ci goto fail; 1084bf215546Sopenharmony_ci } 1085bf215546Sopenharmony_ci 1086bf215546Sopenharmony_ci ret = nouveau_object_new(chan, 0xbeef5039, NV50_M2MF_CLASS, 1087bf215546Sopenharmony_ci NULL, 0, &screen->m2mf); 1088bf215546Sopenharmony_ci if (ret) { 1089bf215546Sopenharmony_ci NOUVEAU_ERR("Failed to allocate PGRAPH context for M2MF: %d\n", ret); 1090bf215546Sopenharmony_ci goto fail; 1091bf215546Sopenharmony_ci } 1092bf215546Sopenharmony_ci 1093bf215546Sopenharmony_ci ret = nouveau_object_new(chan, 0xbeef502d, NV50_2D_CLASS, 1094bf215546Sopenharmony_ci NULL, 0, &screen->eng2d); 1095bf215546Sopenharmony_ci if (ret) { 1096bf215546Sopenharmony_ci NOUVEAU_ERR("Failed to allocate PGRAPH context for 2D: %d\n", ret); 1097bf215546Sopenharmony_ci goto fail; 1098bf215546Sopenharmony_ci } 1099bf215546Sopenharmony_ci 1100bf215546Sopenharmony_ci switch (dev->chipset & 0xf0) { 1101bf215546Sopenharmony_ci case 0x50: 1102bf215546Sopenharmony_ci tesla_class = NV50_3D_CLASS; 1103bf215546Sopenharmony_ci break; 1104bf215546Sopenharmony_ci case 0x80: 1105bf215546Sopenharmony_ci case 0x90: 1106bf215546Sopenharmony_ci tesla_class = NV84_3D_CLASS; 1107bf215546Sopenharmony_ci break; 1108bf215546Sopenharmony_ci case 0xa0: 1109bf215546Sopenharmony_ci switch (dev->chipset) { 1110bf215546Sopenharmony_ci case 0xa0: 1111bf215546Sopenharmony_ci case 0xaa: 1112bf215546Sopenharmony_ci case 0xac: 1113bf215546Sopenharmony_ci tesla_class = NVA0_3D_CLASS; 1114bf215546Sopenharmony_ci break; 1115bf215546Sopenharmony_ci case 0xaf: 1116bf215546Sopenharmony_ci tesla_class = NVAF_3D_CLASS; 1117bf215546Sopenharmony_ci break; 1118bf215546Sopenharmony_ci default: 1119bf215546Sopenharmony_ci tesla_class = NVA3_3D_CLASS; 1120bf215546Sopenharmony_ci break; 1121bf215546Sopenharmony_ci } 1122bf215546Sopenharmony_ci break; 1123bf215546Sopenharmony_ci default: 1124bf215546Sopenharmony_ci NOUVEAU_ERR("Not a known NV50 chipset: NV%02x\n", dev->chipset); 1125bf215546Sopenharmony_ci goto fail; 1126bf215546Sopenharmony_ci } 1127bf215546Sopenharmony_ci screen->base.class_3d = tesla_class; 1128bf215546Sopenharmony_ci 1129bf215546Sopenharmony_ci ret = nouveau_object_new(chan, 0xbeef5097, tesla_class, 1130bf215546Sopenharmony_ci NULL, 0, &screen->tesla); 1131bf215546Sopenharmony_ci if (ret) { 1132bf215546Sopenharmony_ci NOUVEAU_ERR("Failed to allocate PGRAPH context for 3D: %d\n", ret); 1133bf215546Sopenharmony_ci goto fail; 1134bf215546Sopenharmony_ci } 1135bf215546Sopenharmony_ci 1136bf215546Sopenharmony_ci /* This over-allocates by a page. The GP, which would execute at the end of 1137bf215546Sopenharmony_ci * the last page, would trigger faults. The going theory is that it 1138bf215546Sopenharmony_ci * prefetches up to a certain amount. 1139bf215546Sopenharmony_ci */ 1140bf215546Sopenharmony_ci ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 1 << 16, 1141bf215546Sopenharmony_ci (3 << NV50_CODE_BO_SIZE_LOG2) + 0x1000, 1142bf215546Sopenharmony_ci NULL, &screen->code); 1143bf215546Sopenharmony_ci if (ret) { 1144bf215546Sopenharmony_ci NOUVEAU_ERR("Failed to allocate code bo: %d\n", ret); 1145bf215546Sopenharmony_ci goto fail; 1146bf215546Sopenharmony_ci } 1147bf215546Sopenharmony_ci 1148bf215546Sopenharmony_ci nouveau_heap_init(&screen->vp_code_heap, 0, 1 << NV50_CODE_BO_SIZE_LOG2); 1149bf215546Sopenharmony_ci nouveau_heap_init(&screen->gp_code_heap, 0, 1 << NV50_CODE_BO_SIZE_LOG2); 1150bf215546Sopenharmony_ci nouveau_heap_init(&screen->fp_code_heap, 0, 1 << NV50_CODE_BO_SIZE_LOG2); 1151bf215546Sopenharmony_ci 1152bf215546Sopenharmony_ci nouveau_getparam(dev, NOUVEAU_GETPARAM_GRAPH_UNITS, &value); 1153bf215546Sopenharmony_ci 1154bf215546Sopenharmony_ci screen->TPs = util_bitcount(value & 0xffff); 1155bf215546Sopenharmony_ci screen->MPsInTP = util_bitcount(value & 0x0f000000); 1156bf215546Sopenharmony_ci 1157bf215546Sopenharmony_ci screen->mp_count = screen->TPs * screen->MPsInTP; 1158bf215546Sopenharmony_ci 1159bf215546Sopenharmony_ci stack_size = util_next_power_of_two(screen->TPs) * screen->MPsInTP * 1160bf215546Sopenharmony_ci STACK_WARPS_ALLOC * 64 * 8; 1161bf215546Sopenharmony_ci 1162bf215546Sopenharmony_ci ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 1 << 16, stack_size, NULL, 1163bf215546Sopenharmony_ci &screen->stack_bo); 1164bf215546Sopenharmony_ci if (ret) { 1165bf215546Sopenharmony_ci NOUVEAU_ERR("Failed to allocate stack bo: %d\n", ret); 1166bf215546Sopenharmony_ci goto fail; 1167bf215546Sopenharmony_ci } 1168bf215546Sopenharmony_ci 1169bf215546Sopenharmony_ci uint64_t size_of_one_temp = util_next_power_of_two(screen->TPs) * 1170bf215546Sopenharmony_ci screen->MPsInTP * LOCAL_WARPS_ALLOC * THREADS_IN_WARP * 1171bf215546Sopenharmony_ci ONE_TEMP_SIZE; 1172bf215546Sopenharmony_ci screen->max_tls_space = dev->vram_size / size_of_one_temp * ONE_TEMP_SIZE; 1173bf215546Sopenharmony_ci screen->max_tls_space /= 2; /* half of vram */ 1174bf215546Sopenharmony_ci 1175bf215546Sopenharmony_ci /* hw can address max 64 KiB */ 1176bf215546Sopenharmony_ci screen->max_tls_space = MIN2(screen->max_tls_space, 64 << 10); 1177bf215546Sopenharmony_ci 1178bf215546Sopenharmony_ci uint64_t tls_size; 1179bf215546Sopenharmony_ci unsigned tls_space = 4/*temps*/ * ONE_TEMP_SIZE; 1180bf215546Sopenharmony_ci ret = nv50_tls_alloc(screen, tls_space, &tls_size); 1181bf215546Sopenharmony_ci if (ret) 1182bf215546Sopenharmony_ci goto fail; 1183bf215546Sopenharmony_ci 1184bf215546Sopenharmony_ci if (nouveau_mesa_debug) 1185bf215546Sopenharmony_ci debug_printf("TPs = %u, MPsInTP = %u, VRAM = %"PRIu64" MiB, tls_size = %"PRIu64" KiB\n", 1186bf215546Sopenharmony_ci screen->TPs, screen->MPsInTP, dev->vram_size >> 20, tls_size >> 10); 1187bf215546Sopenharmony_ci 1188bf215546Sopenharmony_ci ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 1 << 16, 5 << 16, NULL, 1189bf215546Sopenharmony_ci &screen->uniforms); 1190bf215546Sopenharmony_ci if (ret) { 1191bf215546Sopenharmony_ci NOUVEAU_ERR("Failed to allocate uniforms bo: %d\n", ret); 1192bf215546Sopenharmony_ci goto fail; 1193bf215546Sopenharmony_ci } 1194bf215546Sopenharmony_ci 1195bf215546Sopenharmony_ci ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 1 << 16, 3 << 16, NULL, 1196bf215546Sopenharmony_ci &screen->txc); 1197bf215546Sopenharmony_ci if (ret) { 1198bf215546Sopenharmony_ci NOUVEAU_ERR("Failed to allocate TIC/TSC bo: %d\n", ret); 1199bf215546Sopenharmony_ci goto fail; 1200bf215546Sopenharmony_ci } 1201bf215546Sopenharmony_ci 1202bf215546Sopenharmony_ci screen->tic.entries = CALLOC(4096, sizeof(void *)); 1203bf215546Sopenharmony_ci screen->tsc.entries = screen->tic.entries + 2048; 1204bf215546Sopenharmony_ci 1205bf215546Sopenharmony_ci if (!nv50_blitter_create(screen)) 1206bf215546Sopenharmony_ci goto fail; 1207bf215546Sopenharmony_ci 1208bf215546Sopenharmony_ci nv50_screen_init_hwctx(screen); 1209bf215546Sopenharmony_ci 1210bf215546Sopenharmony_ci ret = nv50_screen_compute_setup(screen, screen->base.pushbuf); 1211bf215546Sopenharmony_ci if (ret) { 1212bf215546Sopenharmony_ci NOUVEAU_ERR("Failed to init compute context: %d\n", ret); 1213bf215546Sopenharmony_ci goto fail; 1214bf215546Sopenharmony_ci } 1215bf215546Sopenharmony_ci 1216bf215546Sopenharmony_ci nouveau_fence_new(&screen->base, &screen->base.fence.current); 1217bf215546Sopenharmony_ci 1218bf215546Sopenharmony_ci return &screen->base; 1219bf215546Sopenharmony_ci 1220bf215546Sopenharmony_cifail: 1221bf215546Sopenharmony_ci screen->base.base.context_create = NULL; 1222bf215546Sopenharmony_ci return &screen->base; 1223bf215546Sopenharmony_ci} 1224bf215546Sopenharmony_ci 1225bf215546Sopenharmony_ciint 1226bf215546Sopenharmony_cinv50_screen_tic_alloc(struct nv50_screen *screen, void *entry) 1227bf215546Sopenharmony_ci{ 1228bf215546Sopenharmony_ci int i = screen->tic.next; 1229bf215546Sopenharmony_ci 1230bf215546Sopenharmony_ci while (screen->tic.lock[i / 32] & (1 << (i % 32))) 1231bf215546Sopenharmony_ci i = (i + 1) & (NV50_TIC_MAX_ENTRIES - 1); 1232bf215546Sopenharmony_ci 1233bf215546Sopenharmony_ci screen->tic.next = (i + 1) & (NV50_TIC_MAX_ENTRIES - 1); 1234bf215546Sopenharmony_ci 1235bf215546Sopenharmony_ci if (screen->tic.entries[i]) 1236bf215546Sopenharmony_ci nv50_tic_entry(screen->tic.entries[i])->id = -1; 1237bf215546Sopenharmony_ci 1238bf215546Sopenharmony_ci screen->tic.entries[i] = entry; 1239bf215546Sopenharmony_ci return i; 1240bf215546Sopenharmony_ci} 1241bf215546Sopenharmony_ci 1242bf215546Sopenharmony_ciint 1243bf215546Sopenharmony_cinv50_screen_tsc_alloc(struct nv50_screen *screen, void *entry) 1244bf215546Sopenharmony_ci{ 1245bf215546Sopenharmony_ci int i = screen->tsc.next; 1246bf215546Sopenharmony_ci 1247bf215546Sopenharmony_ci while (screen->tsc.lock[i / 32] & (1 << (i % 32))) 1248bf215546Sopenharmony_ci i = (i + 1) & (NV50_TSC_MAX_ENTRIES - 1); 1249bf215546Sopenharmony_ci 1250bf215546Sopenharmony_ci screen->tsc.next = (i + 1) & (NV50_TSC_MAX_ENTRIES - 1); 1251bf215546Sopenharmony_ci 1252bf215546Sopenharmony_ci if (screen->tsc.entries[i]) 1253bf215546Sopenharmony_ci nv50_tsc_entry(screen->tsc.entries[i])->id = -1; 1254bf215546Sopenharmony_ci 1255bf215546Sopenharmony_ci screen->tsc.entries[i] = entry; 1256bf215546Sopenharmony_ci return i; 1257bf215546Sopenharmony_ci} 1258