1bf215546Sopenharmony_ci/************************************************************************** 2bf215546Sopenharmony_ci * 3bf215546Sopenharmony_ci * Copyright 2007 VMware, Inc. 4bf215546Sopenharmony_ci * Copyright (c) 2008 VMware, Inc. 5bf215546Sopenharmony_ci * All Rights Reserved. 6bf215546Sopenharmony_ci * 7bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 8bf215546Sopenharmony_ci * copy of this software and associated documentation files (the 9bf215546Sopenharmony_ci * "Software"), to deal in the Software without restriction, including 10bf215546Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish, 11bf215546Sopenharmony_ci * distribute, sub license, and/or sell copies of the Software, and to 12bf215546Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to 13bf215546Sopenharmony_ci * the following conditions: 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the 16bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions 17bf215546Sopenharmony_ci * of the Software. 18bf215546Sopenharmony_ci * 19bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 20bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21bf215546Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 22bf215546Sopenharmony_ci * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 23bf215546Sopenharmony_ci * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24bf215546Sopenharmony_ci * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25bf215546Sopenharmony_ci * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26bf215546Sopenharmony_ci * 27bf215546Sopenharmony_ci **************************************************************************/ 28bf215546Sopenharmony_ci 29bf215546Sopenharmony_ci#include "compiler/nir/nir.h" 30bf215546Sopenharmony_ci 31bf215546Sopenharmony_ci 32bf215546Sopenharmony_ci#include "main/context.h" 33bf215546Sopenharmony_ci#include "main/macros.h" 34bf215546Sopenharmony_ci#include "main/spirv_extensions.h" 35bf215546Sopenharmony_ci#include "main/version.h" 36bf215546Sopenharmony_ci#include "nir/nir_to_tgsi.h" 37bf215546Sopenharmony_ci 38bf215546Sopenharmony_ci#include "pipe/p_context.h" 39bf215546Sopenharmony_ci#include "pipe/p_defines.h" 40bf215546Sopenharmony_ci#include "pipe/p_screen.h" 41bf215546Sopenharmony_ci#include "tgsi/tgsi_from_mesa.h" 42bf215546Sopenharmony_ci#include "util/u_math.h" 43bf215546Sopenharmony_ci#include "util/u_memory.h" 44bf215546Sopenharmony_ci 45bf215546Sopenharmony_ci#include "st_context.h" 46bf215546Sopenharmony_ci#include "st_debug.h" 47bf215546Sopenharmony_ci#include "st_extensions.h" 48bf215546Sopenharmony_ci#include "st_format.h" 49bf215546Sopenharmony_ci 50bf215546Sopenharmony_ci 51bf215546Sopenharmony_ci/* 52bf215546Sopenharmony_ci * Note: we use these function rather than the MIN2, MAX2, CLAMP macros to 53bf215546Sopenharmony_ci * avoid evaluating arguments (which are often function calls) more than once. 54bf215546Sopenharmony_ci */ 55bf215546Sopenharmony_ci 56bf215546Sopenharmony_cistatic unsigned _min(unsigned a, unsigned b) 57bf215546Sopenharmony_ci{ 58bf215546Sopenharmony_ci return (a < b) ? a : b; 59bf215546Sopenharmony_ci} 60bf215546Sopenharmony_ci 61bf215546Sopenharmony_cistatic float _maxf(float a, float b) 62bf215546Sopenharmony_ci{ 63bf215546Sopenharmony_ci return (a > b) ? a : b; 64bf215546Sopenharmony_ci} 65bf215546Sopenharmony_ci 66bf215546Sopenharmony_cistatic int _clamp(int a, int min, int max) 67bf215546Sopenharmony_ci{ 68bf215546Sopenharmony_ci if (a < min) 69bf215546Sopenharmony_ci return min; 70bf215546Sopenharmony_ci else if (a > max) 71bf215546Sopenharmony_ci return max; 72bf215546Sopenharmony_ci else 73bf215546Sopenharmony_ci return a; 74bf215546Sopenharmony_ci} 75bf215546Sopenharmony_ci 76bf215546Sopenharmony_ci 77bf215546Sopenharmony_ci/** 78bf215546Sopenharmony_ci * Query driver to get implementation limits. 79bf215546Sopenharmony_ci * Note that we have to limit/clamp against Mesa's internal limits too. 80bf215546Sopenharmony_ci */ 81bf215546Sopenharmony_civoid st_init_limits(struct pipe_screen *screen, 82bf215546Sopenharmony_ci struct gl_constants *c, struct gl_extensions *extensions) 83bf215546Sopenharmony_ci{ 84bf215546Sopenharmony_ci int supported_irs; 85bf215546Sopenharmony_ci unsigned sh; 86bf215546Sopenharmony_ci bool can_ubo = true; 87bf215546Sopenharmony_ci int temp; 88bf215546Sopenharmony_ci 89bf215546Sopenharmony_ci c->MaxTextureSize = screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_SIZE); 90bf215546Sopenharmony_ci c->MaxTextureSize = MIN2(c->MaxTextureSize, 1 << (MAX_TEXTURE_LEVELS - 1)); 91bf215546Sopenharmony_ci c->MaxTextureMbytes = MAX2(c->MaxTextureMbytes, 92bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_MB)); 93bf215546Sopenharmony_ci 94bf215546Sopenharmony_ci c->Max3DTextureLevels 95bf215546Sopenharmony_ci = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_3D_LEVELS), 96bf215546Sopenharmony_ci MAX_TEXTURE_LEVELS); 97bf215546Sopenharmony_ci extensions->OES_texture_3D = c->Max3DTextureLevels != 0; 98bf215546Sopenharmony_ci 99bf215546Sopenharmony_ci c->MaxCubeTextureLevels 100bf215546Sopenharmony_ci = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS), 101bf215546Sopenharmony_ci MAX_TEXTURE_LEVELS); 102bf215546Sopenharmony_ci 103bf215546Sopenharmony_ci c->MaxTextureRectSize = _min(c->MaxTextureSize, MAX_TEXTURE_RECT_SIZE); 104bf215546Sopenharmony_ci 105bf215546Sopenharmony_ci c->MaxArrayTextureLayers 106bf215546Sopenharmony_ci = screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS); 107bf215546Sopenharmony_ci 108bf215546Sopenharmony_ci /* Define max viewport size and max renderbuffer size in terms of 109bf215546Sopenharmony_ci * max texture size (note: max tex RECT size = max tex 2D size). 110bf215546Sopenharmony_ci * If this isn't true for some hardware we'll need new PIPE_CAP_ queries. 111bf215546Sopenharmony_ci */ 112bf215546Sopenharmony_ci c->MaxViewportWidth = 113bf215546Sopenharmony_ci c->MaxViewportHeight = 114bf215546Sopenharmony_ci c->MaxRenderbufferSize = c->MaxTextureRectSize; 115bf215546Sopenharmony_ci 116bf215546Sopenharmony_ci c->SubPixelBits = 117bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_RASTERIZER_SUBPIXEL_BITS); 118bf215546Sopenharmony_ci c->ViewportSubpixelBits = 119bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_VIEWPORT_SUBPIXEL_BITS); 120bf215546Sopenharmony_ci 121bf215546Sopenharmony_ci c->MaxDrawBuffers = c->MaxColorAttachments = 122bf215546Sopenharmony_ci _clamp(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS), 123bf215546Sopenharmony_ci 1, MAX_DRAW_BUFFERS); 124bf215546Sopenharmony_ci 125bf215546Sopenharmony_ci c->MaxDualSourceDrawBuffers = 126bf215546Sopenharmony_ci _clamp(screen->get_param(screen, 127bf215546Sopenharmony_ci PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS), 128bf215546Sopenharmony_ci 0, MAX_DRAW_BUFFERS); 129bf215546Sopenharmony_ci 130bf215546Sopenharmony_ci c->MaxLineWidth = 131bf215546Sopenharmony_ci _maxf(1.0f, screen->get_paramf(screen, PIPE_CAPF_MAX_LINE_WIDTH)); 132bf215546Sopenharmony_ci c->MaxLineWidthAA = 133bf215546Sopenharmony_ci _maxf(1.0f, screen->get_paramf(screen, PIPE_CAPF_MAX_LINE_WIDTH_AA)); 134bf215546Sopenharmony_ci 135bf215546Sopenharmony_ci c->MinLineWidth = screen->get_paramf(screen, PIPE_CAPF_MIN_LINE_WIDTH); 136bf215546Sopenharmony_ci c->MinLineWidthAA = screen->get_paramf(screen, PIPE_CAPF_MIN_LINE_WIDTH_AA); 137bf215546Sopenharmony_ci c->LineWidthGranularity = screen->get_paramf(screen, PIPE_CAPF_LINE_WIDTH_GRANULARITY); 138bf215546Sopenharmony_ci 139bf215546Sopenharmony_ci c->MaxPointSize = 140bf215546Sopenharmony_ci _maxf(1.0f, screen->get_paramf(screen, PIPE_CAPF_MAX_POINT_SIZE)); 141bf215546Sopenharmony_ci c->MaxPointSizeAA = 142bf215546Sopenharmony_ci _maxf(1.0f, screen->get_paramf(screen, PIPE_CAPF_MAX_POINT_SIZE_AA)); 143bf215546Sopenharmony_ci 144bf215546Sopenharmony_ci c->MinPointSize = MAX2(screen->get_paramf(screen, PIPE_CAPF_MIN_POINT_SIZE), 0.01); 145bf215546Sopenharmony_ci c->MinPointSizeAA = MAX2(screen->get_paramf(screen, PIPE_CAPF_MIN_POINT_SIZE_AA), 0.01); 146bf215546Sopenharmony_ci c->PointSizeGranularity = screen->get_paramf(screen, PIPE_CAPF_POINT_SIZE_GRANULARITY); 147bf215546Sopenharmony_ci 148bf215546Sopenharmony_ci c->MaxTextureMaxAnisotropy = 149bf215546Sopenharmony_ci _maxf(2.0f, 150bf215546Sopenharmony_ci screen->get_paramf(screen, PIPE_CAPF_MAX_TEXTURE_ANISOTROPY)); 151bf215546Sopenharmony_ci 152bf215546Sopenharmony_ci c->MaxTextureLodBias = 153bf215546Sopenharmony_ci screen->get_paramf(screen, PIPE_CAPF_MAX_TEXTURE_LOD_BIAS); 154bf215546Sopenharmony_ci 155bf215546Sopenharmony_ci c->QuadsFollowProvokingVertexConvention = 156bf215546Sopenharmony_ci screen->get_param(screen, 157bf215546Sopenharmony_ci PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION); 158bf215546Sopenharmony_ci 159bf215546Sopenharmony_ci c->MaxUniformBlockSize = 160bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_MAX_CONSTANT_BUFFER_SIZE_UINT); 161bf215546Sopenharmony_ci 162bf215546Sopenharmony_ci if (c->MaxUniformBlockSize < 16384) { 163bf215546Sopenharmony_ci can_ubo = false; 164bf215546Sopenharmony_ci } 165bf215546Sopenharmony_ci 166bf215546Sopenharmony_ci /* Round down to a multiple of 4 to make piglit happy. Bytes are not 167bf215546Sopenharmony_ci * addressible by UBOs anyway. 168bf215546Sopenharmony_ci */ 169bf215546Sopenharmony_ci c->MaxUniformBlockSize &= ~3; 170bf215546Sopenharmony_ci 171bf215546Sopenharmony_ci for (sh = 0; sh < PIPE_SHADER_TYPES; ++sh) { 172bf215546Sopenharmony_ci const gl_shader_stage stage = tgsi_processor_to_shader_stage(sh); 173bf215546Sopenharmony_ci struct gl_shader_compiler_options *options = 174bf215546Sopenharmony_ci &c->ShaderCompilerOptions[stage]; 175bf215546Sopenharmony_ci struct gl_program_constants *pc = &c->Program[stage]; 176bf215546Sopenharmony_ci 177bf215546Sopenharmony_ci bool prefer_nir = PIPE_SHADER_IR_NIR == 178bf215546Sopenharmony_ci screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_PREFERRED_IR); 179bf215546Sopenharmony_ci if (screen->get_compiler_options) 180bf215546Sopenharmony_ci options->NirOptions = screen->get_compiler_options(screen, PIPE_SHADER_IR_NIR, sh); 181bf215546Sopenharmony_ci 182bf215546Sopenharmony_ci if (!options->NirOptions) { 183bf215546Sopenharmony_ci options->NirOptions = 184bf215546Sopenharmony_ci nir_to_tgsi_get_compiler_options(screen, PIPE_SHADER_IR_NIR, sh); 185bf215546Sopenharmony_ci } 186bf215546Sopenharmony_ci 187bf215546Sopenharmony_ci if (sh == PIPE_SHADER_COMPUTE) { 188bf215546Sopenharmony_ci if (!screen->get_param(screen, PIPE_CAP_COMPUTE)) 189bf215546Sopenharmony_ci continue; 190bf215546Sopenharmony_ci supported_irs = 191bf215546Sopenharmony_ci screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_SUPPORTED_IRS); 192bf215546Sopenharmony_ci if (!(supported_irs & ((1 << PIPE_SHADER_IR_TGSI) | 193bf215546Sopenharmony_ci (1 << PIPE_SHADER_IR_NIR)))) 194bf215546Sopenharmony_ci continue; 195bf215546Sopenharmony_ci } 196bf215546Sopenharmony_ci 197bf215546Sopenharmony_ci pc->MaxTextureImageUnits = 198bf215546Sopenharmony_ci _min(screen->get_shader_param(screen, sh, 199bf215546Sopenharmony_ci PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS), 200bf215546Sopenharmony_ci MAX_TEXTURE_IMAGE_UNITS); 201bf215546Sopenharmony_ci 202bf215546Sopenharmony_ci pc->MaxInstructions = 203bf215546Sopenharmony_ci pc->MaxNativeInstructions = 204bf215546Sopenharmony_ci screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INSTRUCTIONS); 205bf215546Sopenharmony_ci pc->MaxAluInstructions = 206bf215546Sopenharmony_ci pc->MaxNativeAluInstructions = 207bf215546Sopenharmony_ci screen->get_shader_param(screen, sh, 208bf215546Sopenharmony_ci PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS); 209bf215546Sopenharmony_ci pc->MaxTexInstructions = 210bf215546Sopenharmony_ci pc->MaxNativeTexInstructions = 211bf215546Sopenharmony_ci screen->get_shader_param(screen, sh, 212bf215546Sopenharmony_ci PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS); 213bf215546Sopenharmony_ci pc->MaxTexIndirections = 214bf215546Sopenharmony_ci pc->MaxNativeTexIndirections = 215bf215546Sopenharmony_ci screen->get_shader_param(screen, sh, 216bf215546Sopenharmony_ci PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS); 217bf215546Sopenharmony_ci pc->MaxAttribs = 218bf215546Sopenharmony_ci pc->MaxNativeAttribs = 219bf215546Sopenharmony_ci screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INPUTS); 220bf215546Sopenharmony_ci pc->MaxTemps = 221bf215546Sopenharmony_ci pc->MaxNativeTemps = 222bf215546Sopenharmony_ci screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_TEMPS); 223bf215546Sopenharmony_ci pc->MaxAddressRegs = 224bf215546Sopenharmony_ci pc->MaxNativeAddressRegs = sh == PIPE_SHADER_VERTEX ? 1 : 0; 225bf215546Sopenharmony_ci 226bf215546Sopenharmony_ci pc->MaxUniformComponents = 227bf215546Sopenharmony_ci screen->get_shader_param(screen, sh, 228bf215546Sopenharmony_ci PIPE_SHADER_CAP_MAX_CONST_BUFFER0_SIZE) / 4; 229bf215546Sopenharmony_ci 230bf215546Sopenharmony_ci /* reserve space in the default-uniform for lowered state */ 231bf215546Sopenharmony_ci if (sh == PIPE_SHADER_VERTEX || 232bf215546Sopenharmony_ci sh == PIPE_SHADER_TESS_EVAL || 233bf215546Sopenharmony_ci sh == PIPE_SHADER_GEOMETRY) { 234bf215546Sopenharmony_ci 235bf215546Sopenharmony_ci if (!screen->get_param(screen, PIPE_CAP_CLIP_PLANES)) 236bf215546Sopenharmony_ci pc->MaxUniformComponents -= 4 * MAX_CLIP_PLANES; 237bf215546Sopenharmony_ci 238bf215546Sopenharmony_ci if (!screen->get_param(screen, PIPE_CAP_POINT_SIZE_FIXED)) 239bf215546Sopenharmony_ci pc->MaxUniformComponents -= 4; 240bf215546Sopenharmony_ci } else if (sh == PIPE_SHADER_FRAGMENT) { 241bf215546Sopenharmony_ci if (!screen->get_param(screen, PIPE_CAP_ALPHA_TEST)) 242bf215546Sopenharmony_ci pc->MaxUniformComponents -= 4; 243bf215546Sopenharmony_ci } 244bf215546Sopenharmony_ci 245bf215546Sopenharmony_ci 246bf215546Sopenharmony_ci pc->MaxUniformComponents = MIN2(pc->MaxUniformComponents, 247bf215546Sopenharmony_ci MAX_UNIFORMS * 4); 248bf215546Sopenharmony_ci 249bf215546Sopenharmony_ci /* For ARB programs, prog_src_register::Index is a signed 13-bit number. 250bf215546Sopenharmony_ci * This gives us a limit of 4096 values - but we may need to generate 251bf215546Sopenharmony_ci * internal values in addition to what the source program uses. So, we 252bf215546Sopenharmony_ci * drop the limit one step lower, to 2048, to be safe. 253bf215546Sopenharmony_ci */ 254bf215546Sopenharmony_ci pc->MaxParameters = 255bf215546Sopenharmony_ci pc->MaxNativeParameters = MIN2(pc->MaxUniformComponents / 4, 2048); 256bf215546Sopenharmony_ci pc->MaxInputComponents = 257bf215546Sopenharmony_ci screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INPUTS) * 4; 258bf215546Sopenharmony_ci pc->MaxOutputComponents = 259bf215546Sopenharmony_ci screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_OUTPUTS) * 4; 260bf215546Sopenharmony_ci 261bf215546Sopenharmony_ci 262bf215546Sopenharmony_ci pc->MaxUniformBlocks = 263bf215546Sopenharmony_ci screen->get_shader_param(screen, sh, 264bf215546Sopenharmony_ci PIPE_SHADER_CAP_MAX_CONST_BUFFERS); 265bf215546Sopenharmony_ci if (pc->MaxUniformBlocks) 266bf215546Sopenharmony_ci pc->MaxUniformBlocks -= 1; /* The first one is for ordinary uniforms. */ 267bf215546Sopenharmony_ci pc->MaxUniformBlocks = _min(pc->MaxUniformBlocks, MAX_UNIFORM_BUFFERS); 268bf215546Sopenharmony_ci 269bf215546Sopenharmony_ci pc->MaxCombinedUniformComponents = 270bf215546Sopenharmony_ci pc->MaxUniformComponents + 271bf215546Sopenharmony_ci (uint64_t)c->MaxUniformBlockSize / 4 * pc->MaxUniformBlocks; 272bf215546Sopenharmony_ci 273bf215546Sopenharmony_ci pc->MaxShaderStorageBlocks = 274bf215546Sopenharmony_ci screen->get_shader_param(screen, sh, 275bf215546Sopenharmony_ci PIPE_SHADER_CAP_MAX_SHADER_BUFFERS); 276bf215546Sopenharmony_ci 277bf215546Sopenharmony_ci temp = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTERS); 278bf215546Sopenharmony_ci if (temp) { 279bf215546Sopenharmony_ci /* 280bf215546Sopenharmony_ci * for separate atomic counters get the actual hw limits 281bf215546Sopenharmony_ci * per stage on atomic counters and buffers 282bf215546Sopenharmony_ci */ 283bf215546Sopenharmony_ci pc->MaxAtomicCounters = temp; 284bf215546Sopenharmony_ci pc->MaxAtomicBuffers = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTER_BUFFERS); 285bf215546Sopenharmony_ci } else if (pc->MaxShaderStorageBlocks) { 286bf215546Sopenharmony_ci pc->MaxAtomicCounters = MAX_ATOMIC_COUNTERS; 287bf215546Sopenharmony_ci /* 288bf215546Sopenharmony_ci * without separate atomic counters, reserve half of the available 289bf215546Sopenharmony_ci * SSBOs for atomic buffers, and the other half for normal SSBOs. 290bf215546Sopenharmony_ci */ 291bf215546Sopenharmony_ci pc->MaxAtomicBuffers = pc->MaxShaderStorageBlocks / 2; 292bf215546Sopenharmony_ci pc->MaxShaderStorageBlocks -= pc->MaxAtomicBuffers; 293bf215546Sopenharmony_ci } 294bf215546Sopenharmony_ci pc->MaxImageUniforms = 295bf215546Sopenharmony_ci _min(screen->get_shader_param(screen, sh, 296bf215546Sopenharmony_ci PIPE_SHADER_CAP_MAX_SHADER_IMAGES), 297bf215546Sopenharmony_ci MAX_IMAGE_UNIFORMS); 298bf215546Sopenharmony_ci 299bf215546Sopenharmony_ci /* Gallium doesn't really care about local vs. env parameters so use the 300bf215546Sopenharmony_ci * same limits. 301bf215546Sopenharmony_ci */ 302bf215546Sopenharmony_ci pc->MaxLocalParams = MIN2(pc->MaxParameters, MAX_PROGRAM_LOCAL_PARAMS); 303bf215546Sopenharmony_ci pc->MaxEnvParams = MIN2(pc->MaxParameters, MAX_PROGRAM_ENV_PARAMS); 304bf215546Sopenharmony_ci 305bf215546Sopenharmony_ci if (screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_INTEGERS)) { 306bf215546Sopenharmony_ci pc->LowInt.RangeMin = 31; 307bf215546Sopenharmony_ci pc->LowInt.RangeMax = 30; 308bf215546Sopenharmony_ci pc->LowInt.Precision = 0; 309bf215546Sopenharmony_ci pc->MediumInt = pc->HighInt = pc->LowInt; 310bf215546Sopenharmony_ci 311bf215546Sopenharmony_ci if (screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_INT16)) { 312bf215546Sopenharmony_ci pc->LowInt.RangeMin = 15; 313bf215546Sopenharmony_ci pc->LowInt.RangeMax = 14; 314bf215546Sopenharmony_ci pc->MediumInt = pc->LowInt; 315bf215546Sopenharmony_ci } 316bf215546Sopenharmony_ci } 317bf215546Sopenharmony_ci 318bf215546Sopenharmony_ci if (screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_FP16)) { 319bf215546Sopenharmony_ci pc->LowFloat.RangeMin = 15; 320bf215546Sopenharmony_ci pc->LowFloat.RangeMax = 15; 321bf215546Sopenharmony_ci pc->LowFloat.Precision = 10; 322bf215546Sopenharmony_ci pc->MediumFloat = pc->LowFloat; 323bf215546Sopenharmony_ci } 324bf215546Sopenharmony_ci 325bf215546Sopenharmony_ci /* TODO: make these more fine-grained if anyone needs it */ 326bf215546Sopenharmony_ci options->MaxIfDepth = 327bf215546Sopenharmony_ci screen->get_shader_param(screen, sh, 328bf215546Sopenharmony_ci PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH); 329bf215546Sopenharmony_ci 330bf215546Sopenharmony_ci options->EmitNoMainReturn = 331bf215546Sopenharmony_ci !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_SUBROUTINES); 332bf215546Sopenharmony_ci 333bf215546Sopenharmony_ci options->EmitNoCont = 334bf215546Sopenharmony_ci !screen->get_shader_param(screen, sh, 335bf215546Sopenharmony_ci PIPE_SHADER_CAP_CONT_SUPPORTED); 336bf215546Sopenharmony_ci 337bf215546Sopenharmony_ci options->EmitNoIndirectInput = 338bf215546Sopenharmony_ci !screen->get_shader_param(screen, sh, 339bf215546Sopenharmony_ci PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR); 340bf215546Sopenharmony_ci options->EmitNoIndirectOutput = 341bf215546Sopenharmony_ci !screen->get_shader_param(screen, sh, 342bf215546Sopenharmony_ci PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR); 343bf215546Sopenharmony_ci options->EmitNoIndirectTemp = 344bf215546Sopenharmony_ci !screen->get_shader_param(screen, sh, 345bf215546Sopenharmony_ci PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR); 346bf215546Sopenharmony_ci options->EmitNoIndirectUniform = 347bf215546Sopenharmony_ci !screen->get_shader_param(screen, sh, 348bf215546Sopenharmony_ci PIPE_SHADER_CAP_INDIRECT_CONST_ADDR); 349bf215546Sopenharmony_ci 350bf215546Sopenharmony_ci if (pc->MaxNativeInstructions && 351bf215546Sopenharmony_ci (options->EmitNoIndirectUniform || pc->MaxUniformBlocks < 12)) { 352bf215546Sopenharmony_ci can_ubo = false; 353bf215546Sopenharmony_ci } 354bf215546Sopenharmony_ci 355bf215546Sopenharmony_ci if (!screen->get_param(screen, PIPE_CAP_NIR_COMPACT_ARRAYS)) 356bf215546Sopenharmony_ci options->LowerCombinedClipCullDistance = true; 357bf215546Sopenharmony_ci 358bf215546Sopenharmony_ci if (sh == PIPE_SHADER_VERTEX || sh == PIPE_SHADER_GEOMETRY) { 359bf215546Sopenharmony_ci if (screen->get_param(screen, PIPE_CAP_VIEWPORT_TRANSFORM_LOWERED)) 360bf215546Sopenharmony_ci options->LowerBuiltinVariablesXfb |= VARYING_BIT_POS; 361bf215546Sopenharmony_ci if (screen->get_param(screen, PIPE_CAP_PSIZ_CLAMPED)) 362bf215546Sopenharmony_ci options->LowerBuiltinVariablesXfb |= VARYING_BIT_PSIZ; 363bf215546Sopenharmony_ci } 364bf215546Sopenharmony_ci 365bf215546Sopenharmony_ci /* Note: If the driver doesn't prefer NIR, then st_create_nir_shader() 366bf215546Sopenharmony_ci * will call nir_to_tgsi, and TGSI doesn't support 16-bit ops. 367bf215546Sopenharmony_ci */ 368bf215546Sopenharmony_ci if (prefer_nir) { 369bf215546Sopenharmony_ci options->LowerPrecisionFloat16 = 370bf215546Sopenharmony_ci screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_FP16); 371bf215546Sopenharmony_ci options->LowerPrecisionDerivatives = 372bf215546Sopenharmony_ci screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_FP16_DERIVATIVES); 373bf215546Sopenharmony_ci options->LowerPrecisionInt16 = 374bf215546Sopenharmony_ci screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_INT16); 375bf215546Sopenharmony_ci options->LowerPrecisionConstants = 376bf215546Sopenharmony_ci screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_GLSL_16BIT_CONSTS); 377bf215546Sopenharmony_ci options->LowerPrecisionFloat16Uniforms = 378bf215546Sopenharmony_ci screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_FP16_CONST_BUFFERS); 379bf215546Sopenharmony_ci } 380bf215546Sopenharmony_ci } 381bf215546Sopenharmony_ci 382bf215546Sopenharmony_ci c->MaxUserAssignableUniformLocations = 383bf215546Sopenharmony_ci c->Program[MESA_SHADER_VERTEX].MaxUniformComponents + 384bf215546Sopenharmony_ci c->Program[MESA_SHADER_TESS_CTRL].MaxUniformComponents + 385bf215546Sopenharmony_ci c->Program[MESA_SHADER_TESS_EVAL].MaxUniformComponents + 386bf215546Sopenharmony_ci c->Program[MESA_SHADER_GEOMETRY].MaxUniformComponents + 387bf215546Sopenharmony_ci c->Program[MESA_SHADER_FRAGMENT].MaxUniformComponents; 388bf215546Sopenharmony_ci 389bf215546Sopenharmony_ci c->GLSLLowerConstArrays = 390bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_PREFER_IMM_ARRAYS_AS_CONSTBUF); 391bf215546Sopenharmony_ci c->GLSLTessLevelsAsInputs = 392bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_GLSL_TESS_LEVELS_AS_INPUTS); 393bf215546Sopenharmony_ci c->LowerTessLevel = 394bf215546Sopenharmony_ci !screen->get_param(screen, PIPE_CAP_NIR_COMPACT_ARRAYS); 395bf215546Sopenharmony_ci c->LowerCsDerivedVariables = 396bf215546Sopenharmony_ci !screen->get_param(screen, PIPE_CAP_CS_DERIVED_SYSTEM_VALUES_SUPPORTED); 397bf215546Sopenharmony_ci c->PrimitiveRestartForPatches = false; 398bf215546Sopenharmony_ci 399bf215546Sopenharmony_ci c->MaxCombinedTextureImageUnits = 400bf215546Sopenharmony_ci _min(c->Program[MESA_SHADER_VERTEX].MaxTextureImageUnits + 401bf215546Sopenharmony_ci c->Program[MESA_SHADER_TESS_CTRL].MaxTextureImageUnits + 402bf215546Sopenharmony_ci c->Program[MESA_SHADER_TESS_EVAL].MaxTextureImageUnits + 403bf215546Sopenharmony_ci c->Program[MESA_SHADER_GEOMETRY].MaxTextureImageUnits + 404bf215546Sopenharmony_ci c->Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits + 405bf215546Sopenharmony_ci c->Program[MESA_SHADER_COMPUTE].MaxTextureImageUnits, 406bf215546Sopenharmony_ci MAX_COMBINED_TEXTURE_IMAGE_UNITS); 407bf215546Sopenharmony_ci 408bf215546Sopenharmony_ci /* This depends on program constants. */ 409bf215546Sopenharmony_ci c->MaxTextureCoordUnits 410bf215546Sopenharmony_ci = _min(c->Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits, 411bf215546Sopenharmony_ci MAX_TEXTURE_COORD_UNITS); 412bf215546Sopenharmony_ci 413bf215546Sopenharmony_ci c->MaxTextureUnits = 414bf215546Sopenharmony_ci _min(c->Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits, 415bf215546Sopenharmony_ci c->MaxTextureCoordUnits); 416bf215546Sopenharmony_ci 417bf215546Sopenharmony_ci c->Program[MESA_SHADER_VERTEX].MaxAttribs = 418bf215546Sopenharmony_ci MIN2(c->Program[MESA_SHADER_VERTEX].MaxAttribs, 16); 419bf215546Sopenharmony_ci 420bf215546Sopenharmony_ci c->MaxVarying = screen->get_param(screen, PIPE_CAP_MAX_VARYINGS); 421bf215546Sopenharmony_ci c->MaxVarying = MIN2(c->MaxVarying, MAX_VARYING); 422bf215546Sopenharmony_ci c->MaxGeometryOutputVertices = 423bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_MAX_GEOMETRY_OUTPUT_VERTICES); 424bf215546Sopenharmony_ci c->MaxGeometryTotalOutputComponents = 425bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS); 426bf215546Sopenharmony_ci c->MaxGeometryShaderInvocations = 427bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_MAX_GS_INVOCATIONS); 428bf215546Sopenharmony_ci c->MaxTessPatchComponents = 429bf215546Sopenharmony_ci MIN2(screen->get_param(screen, PIPE_CAP_MAX_SHADER_PATCH_VARYINGS), 430bf215546Sopenharmony_ci MAX_VARYING) * 4; 431bf215546Sopenharmony_ci 432bf215546Sopenharmony_ci c->MinProgramTexelOffset = 433bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_MIN_TEXEL_OFFSET); 434bf215546Sopenharmony_ci c->MaxProgramTexelOffset = 435bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_MAX_TEXEL_OFFSET); 436bf215546Sopenharmony_ci 437bf215546Sopenharmony_ci c->MaxProgramTextureGatherComponents = 438bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS); 439bf215546Sopenharmony_ci c->MinProgramTextureGatherOffset = 440bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_MIN_TEXTURE_GATHER_OFFSET); 441bf215546Sopenharmony_ci c->MaxProgramTextureGatherOffset = 442bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_GATHER_OFFSET); 443bf215546Sopenharmony_ci 444bf215546Sopenharmony_ci c->MaxTransformFeedbackBuffers = 445bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS); 446bf215546Sopenharmony_ci c->MaxTransformFeedbackBuffers = MIN2(c->MaxTransformFeedbackBuffers, 447bf215546Sopenharmony_ci MAX_FEEDBACK_BUFFERS); 448bf215546Sopenharmony_ci c->MaxTransformFeedbackSeparateComponents = 449bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS); 450bf215546Sopenharmony_ci c->MaxTransformFeedbackInterleavedComponents = 451bf215546Sopenharmony_ci screen->get_param(screen, 452bf215546Sopenharmony_ci PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS); 453bf215546Sopenharmony_ci c->MaxVertexStreams = 454bf215546Sopenharmony_ci MAX2(1, screen->get_param(screen, PIPE_CAP_MAX_VERTEX_STREAMS)); 455bf215546Sopenharmony_ci 456bf215546Sopenharmony_ci /* The vertex stream must fit into pipe_stream_output_info::stream */ 457bf215546Sopenharmony_ci assert(c->MaxVertexStreams <= 4); 458bf215546Sopenharmony_ci 459bf215546Sopenharmony_ci c->MaxVertexAttribStride 460bf215546Sopenharmony_ci = screen->get_param(screen, PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE); 461bf215546Sopenharmony_ci 462bf215546Sopenharmony_ci /* The value cannot be larger than that since pipe_vertex_buffer::src_offset 463bf215546Sopenharmony_ci * is only 16 bits. 464bf215546Sopenharmony_ci */ 465bf215546Sopenharmony_ci temp = screen->get_param(screen, PIPE_CAP_MAX_VERTEX_ELEMENT_SRC_OFFSET); 466bf215546Sopenharmony_ci c->MaxVertexAttribRelativeOffset = MIN2(0xffff, temp); 467bf215546Sopenharmony_ci 468bf215546Sopenharmony_ci c->GLSLSkipStrictMaxUniformLimitCheck = 469bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS); 470bf215546Sopenharmony_ci 471bf215546Sopenharmony_ci c->UniformBufferOffsetAlignment = 472bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT); 473bf215546Sopenharmony_ci 474bf215546Sopenharmony_ci if (can_ubo) { 475bf215546Sopenharmony_ci extensions->ARB_uniform_buffer_object = GL_TRUE; 476bf215546Sopenharmony_ci c->MaxCombinedUniformBlocks = c->MaxUniformBufferBindings = 477bf215546Sopenharmony_ci c->Program[MESA_SHADER_VERTEX].MaxUniformBlocks + 478bf215546Sopenharmony_ci c->Program[MESA_SHADER_TESS_CTRL].MaxUniformBlocks + 479bf215546Sopenharmony_ci c->Program[MESA_SHADER_TESS_EVAL].MaxUniformBlocks + 480bf215546Sopenharmony_ci c->Program[MESA_SHADER_GEOMETRY].MaxUniformBlocks + 481bf215546Sopenharmony_ci c->Program[MESA_SHADER_FRAGMENT].MaxUniformBlocks + 482bf215546Sopenharmony_ci c->Program[MESA_SHADER_COMPUTE].MaxUniformBlocks; 483bf215546Sopenharmony_ci assert(c->MaxCombinedUniformBlocks <= MAX_COMBINED_UNIFORM_BUFFERS); 484bf215546Sopenharmony_ci } 485bf215546Sopenharmony_ci 486bf215546Sopenharmony_ci c->GLSLFragCoordIsSysVal = 487bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_FS_POSITION_IS_SYSVAL); 488bf215546Sopenharmony_ci c->GLSLPointCoordIsSysVal = 489bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_FS_POINT_IS_SYSVAL); 490bf215546Sopenharmony_ci c->GLSLFrontFacingIsSysVal = 491bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_FS_FACE_IS_INTEGER_SYSVAL); 492bf215546Sopenharmony_ci 493bf215546Sopenharmony_ci /* GL_ARB_get_program_binary */ 494bf215546Sopenharmony_ci if (screen->get_disk_shader_cache && screen->get_disk_shader_cache(screen)) 495bf215546Sopenharmony_ci c->NumProgramBinaryFormats = 1; 496bf215546Sopenharmony_ci 497bf215546Sopenharmony_ci c->MaxAtomicBufferBindings = 498bf215546Sopenharmony_ci MAX2(c->Program[MESA_SHADER_FRAGMENT].MaxAtomicBuffers, 499bf215546Sopenharmony_ci c->Program[MESA_SHADER_COMPUTE].MaxAtomicBuffers); 500bf215546Sopenharmony_ci c->MaxAtomicBufferSize = ATOMIC_COUNTER_SIZE * 501bf215546Sopenharmony_ci MAX2(c->Program[MESA_SHADER_FRAGMENT].MaxAtomicCounters, 502bf215546Sopenharmony_ci c->Program[MESA_SHADER_COMPUTE].MaxAtomicCounters); 503bf215546Sopenharmony_ci 504bf215546Sopenharmony_ci c->MaxCombinedAtomicBuffers = 505bf215546Sopenharmony_ci MIN2(screen->get_param(screen, 506bf215546Sopenharmony_ci PIPE_CAP_MAX_COMBINED_HW_ATOMIC_COUNTER_BUFFERS), 507bf215546Sopenharmony_ci MAX_COMBINED_ATOMIC_BUFFERS); 508bf215546Sopenharmony_ci if (!c->MaxCombinedAtomicBuffers) { 509bf215546Sopenharmony_ci c->MaxCombinedAtomicBuffers = MAX2( 510bf215546Sopenharmony_ci c->Program[MESA_SHADER_VERTEX].MaxAtomicBuffers + 511bf215546Sopenharmony_ci c->Program[MESA_SHADER_TESS_CTRL].MaxAtomicBuffers + 512bf215546Sopenharmony_ci c->Program[MESA_SHADER_TESS_EVAL].MaxAtomicBuffers + 513bf215546Sopenharmony_ci c->Program[MESA_SHADER_GEOMETRY].MaxAtomicBuffers + 514bf215546Sopenharmony_ci c->Program[MESA_SHADER_FRAGMENT].MaxAtomicBuffers, 515bf215546Sopenharmony_ci c->Program[MESA_SHADER_COMPUTE].MaxAtomicBuffers); 516bf215546Sopenharmony_ci assert(c->MaxCombinedAtomicBuffers <= MAX_COMBINED_ATOMIC_BUFFERS); 517bf215546Sopenharmony_ci } 518bf215546Sopenharmony_ci 519bf215546Sopenharmony_ci c->MaxCombinedAtomicCounters = 520bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_MAX_COMBINED_HW_ATOMIC_COUNTERS); 521bf215546Sopenharmony_ci if (!c->MaxCombinedAtomicCounters) 522bf215546Sopenharmony_ci c->MaxCombinedAtomicCounters = MAX_ATOMIC_COUNTERS; 523bf215546Sopenharmony_ci 524bf215546Sopenharmony_ci if (c->Program[MESA_SHADER_FRAGMENT].MaxAtomicBuffers) { 525bf215546Sopenharmony_ci extensions->ARB_shader_atomic_counters = GL_TRUE; 526bf215546Sopenharmony_ci extensions->ARB_shader_atomic_counter_ops = GL_TRUE; 527bf215546Sopenharmony_ci } 528bf215546Sopenharmony_ci 529bf215546Sopenharmony_ci c->MaxCombinedShaderOutputResources = c->MaxDrawBuffers; 530bf215546Sopenharmony_ci c->ShaderStorageBufferOffsetAlignment = 531bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT); 532bf215546Sopenharmony_ci if (c->ShaderStorageBufferOffsetAlignment) { 533bf215546Sopenharmony_ci c->MaxCombinedShaderStorageBlocks = 534bf215546Sopenharmony_ci MIN2(screen->get_param(screen, PIPE_CAP_MAX_COMBINED_SHADER_BUFFERS), 535bf215546Sopenharmony_ci MAX_COMBINED_SHADER_STORAGE_BUFFERS); 536bf215546Sopenharmony_ci if (!c->MaxCombinedShaderStorageBlocks) { 537bf215546Sopenharmony_ci c->MaxCombinedShaderStorageBlocks = MAX2( 538bf215546Sopenharmony_ci c->Program[MESA_SHADER_VERTEX].MaxShaderStorageBlocks + 539bf215546Sopenharmony_ci c->Program[MESA_SHADER_TESS_CTRL].MaxShaderStorageBlocks + 540bf215546Sopenharmony_ci c->Program[MESA_SHADER_TESS_EVAL].MaxShaderStorageBlocks + 541bf215546Sopenharmony_ci c->Program[MESA_SHADER_GEOMETRY].MaxShaderStorageBlocks + 542bf215546Sopenharmony_ci c->Program[MESA_SHADER_FRAGMENT].MaxShaderStorageBlocks, 543bf215546Sopenharmony_ci c->Program[MESA_SHADER_COMPUTE].MaxShaderStorageBlocks); 544bf215546Sopenharmony_ci assert(c->MaxCombinedShaderStorageBlocks < MAX_COMBINED_SHADER_STORAGE_BUFFERS); 545bf215546Sopenharmony_ci } 546bf215546Sopenharmony_ci c->MaxShaderStorageBufferBindings = c->MaxCombinedShaderStorageBlocks; 547bf215546Sopenharmony_ci 548bf215546Sopenharmony_ci c->MaxCombinedShaderOutputResources += 549bf215546Sopenharmony_ci c->MaxCombinedShaderStorageBlocks; 550bf215546Sopenharmony_ci c->MaxShaderStorageBlockSize = 551bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_MAX_SHADER_BUFFER_SIZE_UINT); 552bf215546Sopenharmony_ci if (c->Program[MESA_SHADER_FRAGMENT].MaxShaderStorageBlocks) 553bf215546Sopenharmony_ci extensions->ARB_shader_storage_buffer_object = GL_TRUE; 554bf215546Sopenharmony_ci } 555bf215546Sopenharmony_ci 556bf215546Sopenharmony_ci c->MaxCombinedImageUniforms = 557bf215546Sopenharmony_ci c->Program[MESA_SHADER_VERTEX].MaxImageUniforms + 558bf215546Sopenharmony_ci c->Program[MESA_SHADER_TESS_CTRL].MaxImageUniforms + 559bf215546Sopenharmony_ci c->Program[MESA_SHADER_TESS_EVAL].MaxImageUniforms + 560bf215546Sopenharmony_ci c->Program[MESA_SHADER_GEOMETRY].MaxImageUniforms + 561bf215546Sopenharmony_ci c->Program[MESA_SHADER_FRAGMENT].MaxImageUniforms + 562bf215546Sopenharmony_ci c->Program[MESA_SHADER_COMPUTE].MaxImageUniforms; 563bf215546Sopenharmony_ci c->MaxCombinedShaderOutputResources += c->MaxCombinedImageUniforms; 564bf215546Sopenharmony_ci c->MaxImageUnits = MAX_IMAGE_UNITS; 565bf215546Sopenharmony_ci if (c->Program[MESA_SHADER_FRAGMENT].MaxImageUniforms && 566bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_IMAGE_STORE_FORMATTED)) { 567bf215546Sopenharmony_ci extensions->ARB_shader_image_load_store = GL_TRUE; 568bf215546Sopenharmony_ci extensions->ARB_shader_image_size = GL_TRUE; 569bf215546Sopenharmony_ci } 570bf215546Sopenharmony_ci 571bf215546Sopenharmony_ci /* ARB_framebuffer_no_attachments */ 572bf215546Sopenharmony_ci c->MaxFramebufferWidth = c->MaxViewportWidth; 573bf215546Sopenharmony_ci c->MaxFramebufferHeight = c->MaxViewportHeight; 574bf215546Sopenharmony_ci /* NOTE: we cheat here a little by assuming that 575bf215546Sopenharmony_ci * PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS has the same 576bf215546Sopenharmony_ci * number of layers as we need, although we technically 577bf215546Sopenharmony_ci * could have more the generality is not really useful 578bf215546Sopenharmony_ci * in practicality. 579bf215546Sopenharmony_ci */ 580bf215546Sopenharmony_ci c->MaxFramebufferLayers = 581bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS); 582bf215546Sopenharmony_ci 583bf215546Sopenharmony_ci c->MaxWindowRectangles = 584bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_MAX_WINDOW_RECTANGLES); 585bf215546Sopenharmony_ci 586bf215546Sopenharmony_ci c->SparseBufferPageSize = 587bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE); 588bf215546Sopenharmony_ci 589bf215546Sopenharmony_ci c->AllowMappedBuffersDuringExecution = 590bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_ALLOW_MAPPED_BUFFERS_DURING_EXECUTION); 591bf215546Sopenharmony_ci 592bf215546Sopenharmony_ci c->BufferCreateMapUnsynchronizedThreadSafe = 593bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_MAP_UNSYNCHRONIZED_THREAD_SAFE); 594bf215546Sopenharmony_ci 595bf215546Sopenharmony_ci c->UseSTD430AsDefaultPacking = 596bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_LOAD_CONSTBUF); 597bf215546Sopenharmony_ci 598bf215546Sopenharmony_ci c->MaxSubpixelPrecisionBiasBits = 599bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_MAX_CONSERVATIVE_RASTER_SUBPIXEL_PRECISION_BIAS); 600bf215546Sopenharmony_ci 601bf215546Sopenharmony_ci c->ConservativeRasterDilateRange[0] = 602bf215546Sopenharmony_ci screen->get_paramf(screen, PIPE_CAPF_MIN_CONSERVATIVE_RASTER_DILATE); 603bf215546Sopenharmony_ci c->ConservativeRasterDilateRange[1] = 604bf215546Sopenharmony_ci screen->get_paramf(screen, PIPE_CAPF_MAX_CONSERVATIVE_RASTER_DILATE); 605bf215546Sopenharmony_ci c->ConservativeRasterDilateGranularity = 606bf215546Sopenharmony_ci screen->get_paramf(screen, PIPE_CAPF_CONSERVATIVE_RASTER_DILATE_GRANULARITY); 607bf215546Sopenharmony_ci 608bf215546Sopenharmony_ci /* limit the max combined shader output resources to a driver limit */ 609bf215546Sopenharmony_ci temp = screen->get_param(screen, PIPE_CAP_MAX_COMBINED_SHADER_OUTPUT_RESOURCES); 610bf215546Sopenharmony_ci if (temp > 0 && c->MaxCombinedShaderOutputResources > temp) 611bf215546Sopenharmony_ci c->MaxCombinedShaderOutputResources = temp; 612bf215546Sopenharmony_ci 613bf215546Sopenharmony_ci c->VertexBufferOffsetIsInt32 = 614bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET); 615bf215546Sopenharmony_ci 616bf215546Sopenharmony_ci c->AllowDynamicVAOFastPath = 617bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_ALLOW_DYNAMIC_VAO_FASTPATH); 618bf215546Sopenharmony_ci 619bf215546Sopenharmony_ci c->glBeginEndBufferSize = 620bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_GL_BEGIN_END_BUFFER_SIZE); 621bf215546Sopenharmony_ci 622bf215546Sopenharmony_ci c->MaxSparseTextureSize = 623bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_MAX_SPARSE_TEXTURE_SIZE); 624bf215546Sopenharmony_ci c->MaxSparse3DTextureSize = 625bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_MAX_SPARSE_3D_TEXTURE_SIZE); 626bf215546Sopenharmony_ci c->MaxSparseArrayTextureLayers = 627bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_MAX_SPARSE_ARRAY_TEXTURE_LAYERS); 628bf215546Sopenharmony_ci c->SparseTextureFullArrayCubeMipmaps = 629bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS); 630bf215546Sopenharmony_ci 631bf215546Sopenharmony_ci c->HardwareAcceleratedSelect = 632bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_HARDWARE_GL_SELECT); 633bf215546Sopenharmony_ci} 634bf215546Sopenharmony_ci 635bf215546Sopenharmony_ci 636bf215546Sopenharmony_ci/** 637bf215546Sopenharmony_ci * Given a member \c x of struct gl_extensions, return offset of 638bf215546Sopenharmony_ci * \c x in bytes. 639bf215546Sopenharmony_ci */ 640bf215546Sopenharmony_ci#define o(x) offsetof(struct gl_extensions, x) 641bf215546Sopenharmony_ci 642bf215546Sopenharmony_ci 643bf215546Sopenharmony_cistruct st_extension_cap_mapping { 644bf215546Sopenharmony_ci int extension_offset; 645bf215546Sopenharmony_ci int cap; 646bf215546Sopenharmony_ci}; 647bf215546Sopenharmony_ci 648bf215546Sopenharmony_cistruct st_extension_format_mapping { 649bf215546Sopenharmony_ci int extension_offset[2]; 650bf215546Sopenharmony_ci enum pipe_format format[32]; 651bf215546Sopenharmony_ci 652bf215546Sopenharmony_ci /* If TRUE, at least one format must be supported for the extensions to be 653bf215546Sopenharmony_ci * advertised. If FALSE, all the formats must be supported. */ 654bf215546Sopenharmony_ci GLboolean need_at_least_one; 655bf215546Sopenharmony_ci}; 656bf215546Sopenharmony_ci 657bf215546Sopenharmony_ci/** 658bf215546Sopenharmony_ci * Enable extensions if certain pipe formats are supported by the driver. 659bf215546Sopenharmony_ci * What extensions will be enabled and what formats must be supported is 660bf215546Sopenharmony_ci * described by the array of st_extension_format_mapping. 661bf215546Sopenharmony_ci * 662bf215546Sopenharmony_ci * target and bind_flags are passed to is_format_supported. 663bf215546Sopenharmony_ci */ 664bf215546Sopenharmony_cistatic void 665bf215546Sopenharmony_ciinit_format_extensions(struct pipe_screen *screen, 666bf215546Sopenharmony_ci struct gl_extensions *extensions, 667bf215546Sopenharmony_ci const struct st_extension_format_mapping *mapping, 668bf215546Sopenharmony_ci unsigned num_mappings, 669bf215546Sopenharmony_ci enum pipe_texture_target target, 670bf215546Sopenharmony_ci unsigned bind_flags) 671bf215546Sopenharmony_ci{ 672bf215546Sopenharmony_ci GLboolean *extension_table = (GLboolean *) extensions; 673bf215546Sopenharmony_ci unsigned i; 674bf215546Sopenharmony_ci int j; 675bf215546Sopenharmony_ci int num_formats = ARRAY_SIZE(mapping->format); 676bf215546Sopenharmony_ci int num_ext = ARRAY_SIZE(mapping->extension_offset); 677bf215546Sopenharmony_ci 678bf215546Sopenharmony_ci for (i = 0; i < num_mappings; i++) { 679bf215546Sopenharmony_ci int num_supported = 0; 680bf215546Sopenharmony_ci 681bf215546Sopenharmony_ci /* Examine each format in the list. */ 682bf215546Sopenharmony_ci for (j = 0; j < num_formats && mapping[i].format[j]; j++) { 683bf215546Sopenharmony_ci if (screen->is_format_supported(screen, mapping[i].format[j], 684bf215546Sopenharmony_ci target, 0, 0, bind_flags)) { 685bf215546Sopenharmony_ci num_supported++; 686bf215546Sopenharmony_ci } 687bf215546Sopenharmony_ci } 688bf215546Sopenharmony_ci 689bf215546Sopenharmony_ci if (!num_supported || 690bf215546Sopenharmony_ci (!mapping[i].need_at_least_one && num_supported != j)) { 691bf215546Sopenharmony_ci continue; 692bf215546Sopenharmony_ci } 693bf215546Sopenharmony_ci 694bf215546Sopenharmony_ci /* Enable all extensions in the list. */ 695bf215546Sopenharmony_ci for (j = 0; j < num_ext && mapping[i].extension_offset[j]; j++) 696bf215546Sopenharmony_ci extension_table[mapping[i].extension_offset[j]] = GL_TRUE; 697bf215546Sopenharmony_ci } 698bf215546Sopenharmony_ci} 699bf215546Sopenharmony_ci 700bf215546Sopenharmony_ci 701bf215546Sopenharmony_ci/** 702bf215546Sopenharmony_ci * Given a list of formats and bind flags, return the maximum number 703bf215546Sopenharmony_ci * of samples supported by any of those formats. 704bf215546Sopenharmony_ci */ 705bf215546Sopenharmony_cistatic unsigned 706bf215546Sopenharmony_ciget_max_samples_for_formats(struct pipe_screen *screen, 707bf215546Sopenharmony_ci unsigned num_formats, 708bf215546Sopenharmony_ci const enum pipe_format *formats, 709bf215546Sopenharmony_ci unsigned max_samples, 710bf215546Sopenharmony_ci unsigned bind) 711bf215546Sopenharmony_ci{ 712bf215546Sopenharmony_ci unsigned i, f; 713bf215546Sopenharmony_ci 714bf215546Sopenharmony_ci for (i = max_samples; i > 0; --i) { 715bf215546Sopenharmony_ci for (f = 0; f < num_formats; f++) { 716bf215546Sopenharmony_ci if (screen->is_format_supported(screen, formats[f], 717bf215546Sopenharmony_ci PIPE_TEXTURE_2D, i, i, bind)) { 718bf215546Sopenharmony_ci return i; 719bf215546Sopenharmony_ci } 720bf215546Sopenharmony_ci } 721bf215546Sopenharmony_ci } 722bf215546Sopenharmony_ci return 0; 723bf215546Sopenharmony_ci} 724bf215546Sopenharmony_ci 725bf215546Sopenharmony_cistatic unsigned 726bf215546Sopenharmony_ciget_max_samples_for_formats_advanced(struct pipe_screen *screen, 727bf215546Sopenharmony_ci unsigned num_formats, 728bf215546Sopenharmony_ci const enum pipe_format *formats, 729bf215546Sopenharmony_ci unsigned max_samples, 730bf215546Sopenharmony_ci unsigned num_storage_samples, 731bf215546Sopenharmony_ci unsigned bind) 732bf215546Sopenharmony_ci{ 733bf215546Sopenharmony_ci unsigned i, f; 734bf215546Sopenharmony_ci 735bf215546Sopenharmony_ci for (i = max_samples; i > 0; --i) { 736bf215546Sopenharmony_ci for (f = 0; f < num_formats; f++) { 737bf215546Sopenharmony_ci if (screen->is_format_supported(screen, formats[f], PIPE_TEXTURE_2D, 738bf215546Sopenharmony_ci i, num_storage_samples, bind)) { 739bf215546Sopenharmony_ci return i; 740bf215546Sopenharmony_ci } 741bf215546Sopenharmony_ci } 742bf215546Sopenharmony_ci } 743bf215546Sopenharmony_ci return 0; 744bf215546Sopenharmony_ci} 745bf215546Sopenharmony_ci 746bf215546Sopenharmony_ci/** 747bf215546Sopenharmony_ci * Use pipe_screen::get_param() to query PIPE_CAP_ values to determine 748bf215546Sopenharmony_ci * which GL extensions are supported. 749bf215546Sopenharmony_ci * Quite a few extensions are always supported because they are standard 750bf215546Sopenharmony_ci * features or can be built on top of other gallium features. 751bf215546Sopenharmony_ci * Some fine tuning may still be needed. 752bf215546Sopenharmony_ci */ 753bf215546Sopenharmony_civoid st_init_extensions(struct pipe_screen *screen, 754bf215546Sopenharmony_ci struct gl_constants *consts, 755bf215546Sopenharmony_ci struct gl_extensions *extensions, 756bf215546Sopenharmony_ci struct st_config_options *options, 757bf215546Sopenharmony_ci gl_api api) 758bf215546Sopenharmony_ci{ 759bf215546Sopenharmony_ci unsigned i; 760bf215546Sopenharmony_ci GLboolean *extension_table = (GLboolean *) extensions; 761bf215546Sopenharmony_ci 762bf215546Sopenharmony_ci static const struct st_extension_cap_mapping cap_mapping[] = { 763bf215546Sopenharmony_ci { o(ARB_base_instance), PIPE_CAP_START_INSTANCE }, 764bf215546Sopenharmony_ci { o(ARB_bindless_texture), PIPE_CAP_BINDLESS_TEXTURE }, 765bf215546Sopenharmony_ci { o(ARB_buffer_storage), PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT }, 766bf215546Sopenharmony_ci { o(ARB_clear_texture), PIPE_CAP_CLEAR_TEXTURE }, 767bf215546Sopenharmony_ci { o(ARB_clip_control), PIPE_CAP_CLIP_HALFZ }, 768bf215546Sopenharmony_ci { o(ARB_color_buffer_float), PIPE_CAP_VERTEX_COLOR_UNCLAMPED }, 769bf215546Sopenharmony_ci { o(ARB_conditional_render_inverted), PIPE_CAP_CONDITIONAL_RENDER_INVERTED }, 770bf215546Sopenharmony_ci { o(ARB_copy_image), PIPE_CAP_COPY_BETWEEN_COMPRESSED_AND_PLAIN_FORMATS }, 771bf215546Sopenharmony_ci { o(OES_copy_image), PIPE_CAP_COPY_BETWEEN_COMPRESSED_AND_PLAIN_FORMATS }, 772bf215546Sopenharmony_ci { o(ARB_cull_distance), PIPE_CAP_CULL_DISTANCE }, 773bf215546Sopenharmony_ci { o(ARB_depth_clamp), PIPE_CAP_DEPTH_CLIP_DISABLE }, 774bf215546Sopenharmony_ci { o(ARB_derivative_control), PIPE_CAP_FS_FINE_DERIVATIVE }, 775bf215546Sopenharmony_ci { o(ARB_draw_buffers_blend), PIPE_CAP_INDEP_BLEND_FUNC }, 776bf215546Sopenharmony_ci { o(ARB_draw_indirect), PIPE_CAP_DRAW_INDIRECT }, 777bf215546Sopenharmony_ci { o(ARB_draw_instanced), PIPE_CAP_VS_INSTANCEID }, 778bf215546Sopenharmony_ci { o(ARB_fragment_program_shadow), PIPE_CAP_TEXTURE_SHADOW_MAP }, 779bf215546Sopenharmony_ci { o(ARB_framebuffer_object), PIPE_CAP_MIXED_FRAMEBUFFER_SIZES }, 780bf215546Sopenharmony_ci { o(ARB_gpu_shader_int64), PIPE_CAP_INT64 }, 781bf215546Sopenharmony_ci { o(ARB_gl_spirv), PIPE_CAP_GL_SPIRV }, 782bf215546Sopenharmony_ci { o(ARB_indirect_parameters), PIPE_CAP_MULTI_DRAW_INDIRECT_PARAMS }, 783bf215546Sopenharmony_ci { o(ARB_instanced_arrays), PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR }, 784bf215546Sopenharmony_ci { o(ARB_occlusion_query2), PIPE_CAP_OCCLUSION_QUERY }, 785bf215546Sopenharmony_ci { o(ARB_pipeline_statistics_query), PIPE_CAP_QUERY_PIPELINE_STATISTICS }, 786bf215546Sopenharmony_ci { o(ARB_pipeline_statistics_query), PIPE_CAP_QUERY_PIPELINE_STATISTICS_SINGLE }, 787bf215546Sopenharmony_ci { o(ARB_point_sprite), PIPE_CAP_POINT_SPRITE }, 788bf215546Sopenharmony_ci { o(ARB_polygon_offset_clamp), PIPE_CAP_POLYGON_OFFSET_CLAMP }, 789bf215546Sopenharmony_ci { o(ARB_post_depth_coverage), PIPE_CAP_POST_DEPTH_COVERAGE }, 790bf215546Sopenharmony_ci { o(ARB_query_buffer_object), PIPE_CAP_QUERY_BUFFER_OBJECT }, 791bf215546Sopenharmony_ci { o(ARB_robust_buffer_access_behavior), PIPE_CAP_ROBUST_BUFFER_ACCESS_BEHAVIOR }, 792bf215546Sopenharmony_ci { o(ARB_sample_shading), PIPE_CAP_SAMPLE_SHADING }, 793bf215546Sopenharmony_ci { o(ARB_sample_locations), PIPE_CAP_PROGRAMMABLE_SAMPLE_LOCATIONS }, 794bf215546Sopenharmony_ci { o(ARB_seamless_cube_map), PIPE_CAP_SEAMLESS_CUBE_MAP }, 795bf215546Sopenharmony_ci { o(ARB_shader_ballot), PIPE_CAP_SHADER_BALLOT }, 796bf215546Sopenharmony_ci { o(ARB_shader_clock), PIPE_CAP_SHADER_CLOCK }, 797bf215546Sopenharmony_ci { o(ARB_shader_draw_parameters), PIPE_CAP_DRAW_PARAMETERS }, 798bf215546Sopenharmony_ci { o(ARB_shader_group_vote), PIPE_CAP_SHADER_GROUP_VOTE }, 799bf215546Sopenharmony_ci { o(EXT_shader_image_load_formatted), PIPE_CAP_IMAGE_LOAD_FORMATTED }, 800bf215546Sopenharmony_ci { o(EXT_shader_image_load_store), PIPE_CAP_IMAGE_ATOMIC_INC_WRAP }, 801bf215546Sopenharmony_ci { o(ARB_shader_stencil_export), PIPE_CAP_SHADER_STENCIL_EXPORT }, 802bf215546Sopenharmony_ci { o(ARB_shader_texture_image_samples), PIPE_CAP_TEXTURE_QUERY_SAMPLES }, 803bf215546Sopenharmony_ci { o(ARB_shader_texture_lod), PIPE_CAP_FRAGMENT_SHADER_TEXTURE_LOD }, 804bf215546Sopenharmony_ci { o(ARB_shadow), PIPE_CAP_TEXTURE_SHADOW_MAP }, 805bf215546Sopenharmony_ci { o(ARB_sparse_buffer), PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE }, 806bf215546Sopenharmony_ci { o(ARB_sparse_texture), PIPE_CAP_MAX_SPARSE_TEXTURE_SIZE }, 807bf215546Sopenharmony_ci { o(ARB_sparse_texture2), PIPE_CAP_QUERY_SPARSE_TEXTURE_RESIDENCY }, 808bf215546Sopenharmony_ci { o(ARB_sparse_texture_clamp), PIPE_CAP_CLAMP_SPARSE_TEXTURE_LOD }, 809bf215546Sopenharmony_ci { o(ARB_spirv_extensions), PIPE_CAP_GL_SPIRV }, 810bf215546Sopenharmony_ci { o(ARB_texture_buffer_object), PIPE_CAP_TEXTURE_BUFFER_OBJECTS }, 811bf215546Sopenharmony_ci { o(ARB_texture_cube_map_array), PIPE_CAP_CUBE_MAP_ARRAY }, 812bf215546Sopenharmony_ci { o(ARB_texture_filter_minmax), PIPE_CAP_SAMPLER_REDUCTION_MINMAX_ARB }, 813bf215546Sopenharmony_ci { o(ARB_texture_gather), PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS }, 814bf215546Sopenharmony_ci { o(ARB_texture_mirror_clamp_to_edge), PIPE_CAP_TEXTURE_MIRROR_CLAMP_TO_EDGE }, 815bf215546Sopenharmony_ci { o(ARB_texture_multisample), PIPE_CAP_TEXTURE_MULTISAMPLE }, 816bf215546Sopenharmony_ci { o(ARB_texture_non_power_of_two), PIPE_CAP_NPOT_TEXTURES }, 817bf215546Sopenharmony_ci { o(ARB_texture_query_lod), PIPE_CAP_TEXTURE_QUERY_LOD }, 818bf215546Sopenharmony_ci { o(ARB_texture_view), PIPE_CAP_SAMPLER_VIEW_TARGET }, 819bf215546Sopenharmony_ci { o(ARB_timer_query), PIPE_CAP_QUERY_TIMESTAMP }, 820bf215546Sopenharmony_ci { o(ARB_transform_feedback2), PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME }, 821bf215546Sopenharmony_ci { o(ARB_transform_feedback3), PIPE_CAP_STREAM_OUTPUT_INTERLEAVE_BUFFERS }, 822bf215546Sopenharmony_ci { o(ARB_transform_feedback_overflow_query), PIPE_CAP_QUERY_SO_OVERFLOW }, 823bf215546Sopenharmony_ci { o(ARB_fragment_shader_interlock), PIPE_CAP_FRAGMENT_SHADER_INTERLOCK }, 824bf215546Sopenharmony_ci 825bf215546Sopenharmony_ci { o(EXT_blend_equation_separate), PIPE_CAP_BLEND_EQUATION_SEPARATE }, 826bf215546Sopenharmony_ci { o(EXT_demote_to_helper_invocation), PIPE_CAP_DEMOTE_TO_HELPER_INVOCATION }, 827bf215546Sopenharmony_ci { o(EXT_depth_bounds_test), PIPE_CAP_DEPTH_BOUNDS_TEST }, 828bf215546Sopenharmony_ci { o(EXT_disjoint_timer_query), PIPE_CAP_QUERY_TIMESTAMP }, 829bf215546Sopenharmony_ci { o(EXT_draw_buffers2), PIPE_CAP_INDEP_BLEND_ENABLE }, 830bf215546Sopenharmony_ci { o(EXT_memory_object), PIPE_CAP_MEMOBJ }, 831bf215546Sopenharmony_ci#ifndef _WIN32 832bf215546Sopenharmony_ci { o(EXT_memory_object_fd), PIPE_CAP_MEMOBJ }, 833bf215546Sopenharmony_ci#else 834bf215546Sopenharmony_ci { o(EXT_memory_object_win32), PIPE_CAP_MEMOBJ }, 835bf215546Sopenharmony_ci#endif 836bf215546Sopenharmony_ci { o(EXT_multisampled_render_to_texture), PIPE_CAP_SURFACE_SAMPLE_COUNT }, 837bf215546Sopenharmony_ci { o(EXT_semaphore), PIPE_CAP_FENCE_SIGNAL }, 838bf215546Sopenharmony_ci#ifndef _WIN32 839bf215546Sopenharmony_ci { o(EXT_semaphore_fd), PIPE_CAP_FENCE_SIGNAL }, 840bf215546Sopenharmony_ci#else 841bf215546Sopenharmony_ci { o(EXT_semaphore_win32), PIPE_CAP_FENCE_SIGNAL }, 842bf215546Sopenharmony_ci#endif 843bf215546Sopenharmony_ci { o(EXT_shader_samples_identical), PIPE_CAP_SHADER_SAMPLES_IDENTICAL }, 844bf215546Sopenharmony_ci { o(EXT_texture_array), PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS }, 845bf215546Sopenharmony_ci { o(EXT_texture_filter_anisotropic), PIPE_CAP_ANISOTROPIC_FILTER }, 846bf215546Sopenharmony_ci { o(EXT_texture_filter_minmax), PIPE_CAP_SAMPLER_REDUCTION_MINMAX }, 847bf215546Sopenharmony_ci { o(EXT_texture_mirror_clamp), PIPE_CAP_TEXTURE_MIRROR_CLAMP }, 848bf215546Sopenharmony_ci { o(EXT_texture_shadow_lod), PIPE_CAP_TEXTURE_SHADOW_LOD }, 849bf215546Sopenharmony_ci { o(EXT_texture_swizzle), PIPE_CAP_TEXTURE_SWIZZLE }, 850bf215546Sopenharmony_ci { o(EXT_transform_feedback), PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS }, 851bf215546Sopenharmony_ci { o(EXT_window_rectangles), PIPE_CAP_MAX_WINDOW_RECTANGLES }, 852bf215546Sopenharmony_ci 853bf215546Sopenharmony_ci { o(AMD_depth_clamp_separate), PIPE_CAP_DEPTH_CLIP_DISABLE_SEPARATE }, 854bf215546Sopenharmony_ci { o(AMD_framebuffer_multisample_advanced), PIPE_CAP_FRAMEBUFFER_MSAA_CONSTRAINTS }, 855bf215546Sopenharmony_ci { o(AMD_pinned_memory), PIPE_CAP_RESOURCE_FROM_USER_MEMORY }, 856bf215546Sopenharmony_ci { o(ATI_meminfo), PIPE_CAP_QUERY_MEMORY_INFO }, 857bf215546Sopenharmony_ci { o(AMD_seamless_cubemap_per_texture), PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE }, 858bf215546Sopenharmony_ci { o(ATI_texture_mirror_once), PIPE_CAP_TEXTURE_MIRROR_CLAMP }, 859bf215546Sopenharmony_ci { o(INTEL_conservative_rasterization), PIPE_CAP_CONSERVATIVE_RASTER_INNER_COVERAGE }, 860bf215546Sopenharmony_ci { o(INTEL_shader_atomic_float_minmax), PIPE_CAP_ATOMIC_FLOAT_MINMAX }, 861bf215546Sopenharmony_ci { o(MESA_tile_raster_order), PIPE_CAP_TILE_RASTER_ORDER }, 862bf215546Sopenharmony_ci { o(NV_alpha_to_coverage_dither_control), PIPE_CAP_ALPHA_TO_COVERAGE_DITHER_CONTROL }, 863bf215546Sopenharmony_ci { o(NV_compute_shader_derivatives), PIPE_CAP_COMPUTE_SHADER_DERIVATIVES }, 864bf215546Sopenharmony_ci { o(NV_conditional_render), PIPE_CAP_CONDITIONAL_RENDER }, 865bf215546Sopenharmony_ci { o(NV_fill_rectangle), PIPE_CAP_POLYGON_MODE_FILL_RECTANGLE }, 866bf215546Sopenharmony_ci { o(NV_primitive_restart), PIPE_CAP_PRIMITIVE_RESTART }, 867bf215546Sopenharmony_ci { o(NV_shader_atomic_float), PIPE_CAP_IMAGE_ATOMIC_FLOAT_ADD }, 868bf215546Sopenharmony_ci { o(NV_shader_atomic_int64), PIPE_CAP_SHADER_ATOMIC_INT64 }, 869bf215546Sopenharmony_ci { o(NV_texture_barrier), PIPE_CAP_TEXTURE_BARRIER }, 870bf215546Sopenharmony_ci { o(NV_viewport_array2), PIPE_CAP_VIEWPORT_MASK }, 871bf215546Sopenharmony_ci { o(NV_viewport_swizzle), PIPE_CAP_VIEWPORT_SWIZZLE }, 872bf215546Sopenharmony_ci { o(NVX_gpu_memory_info), PIPE_CAP_QUERY_MEMORY_INFO }, 873bf215546Sopenharmony_ci 874bf215546Sopenharmony_ci { o(OES_standard_derivatives), PIPE_CAP_FRAGMENT_SHADER_DERIVATIVES }, 875bf215546Sopenharmony_ci { o(OES_texture_float_linear), PIPE_CAP_TEXTURE_FLOAT_LINEAR }, 876bf215546Sopenharmony_ci { o(OES_texture_half_float_linear), PIPE_CAP_TEXTURE_HALF_FLOAT_LINEAR }, 877bf215546Sopenharmony_ci { o(OES_texture_view), PIPE_CAP_SAMPLER_VIEW_TARGET }, 878bf215546Sopenharmony_ci { o(INTEL_blackhole_render), PIPE_CAP_FRONTEND_NOOP }, 879bf215546Sopenharmony_ci { o(ARM_shader_framebuffer_fetch_depth_stencil), PIPE_CAP_FBFETCH_ZS }, 880bf215546Sopenharmony_ci }; 881bf215546Sopenharmony_ci 882bf215546Sopenharmony_ci /* Required: render target and sampler support */ 883bf215546Sopenharmony_ci static const struct st_extension_format_mapping rendertarget_mapping[] = { 884bf215546Sopenharmony_ci { { o(OES_texture_float) }, 885bf215546Sopenharmony_ci { PIPE_FORMAT_R32G32B32A32_FLOAT } }, 886bf215546Sopenharmony_ci 887bf215546Sopenharmony_ci { { o(OES_texture_half_float) }, 888bf215546Sopenharmony_ci { PIPE_FORMAT_R16G16B16A16_FLOAT } }, 889bf215546Sopenharmony_ci 890bf215546Sopenharmony_ci { { o(ARB_texture_rgb10_a2ui) }, 891bf215546Sopenharmony_ci { PIPE_FORMAT_R10G10B10A2_UINT, 892bf215546Sopenharmony_ci PIPE_FORMAT_B10G10R10A2_UINT }, 893bf215546Sopenharmony_ci GL_TRUE }, /* at least one format must be supported */ 894bf215546Sopenharmony_ci 895bf215546Sopenharmony_ci { { o(EXT_sRGB) }, 896bf215546Sopenharmony_ci { PIPE_FORMAT_A8B8G8R8_SRGB, 897bf215546Sopenharmony_ci PIPE_FORMAT_B8G8R8A8_SRGB, 898bf215546Sopenharmony_ci PIPE_FORMAT_R8G8B8A8_SRGB }, 899bf215546Sopenharmony_ci GL_TRUE }, /* at least one format must be supported */ 900bf215546Sopenharmony_ci 901bf215546Sopenharmony_ci { { o(EXT_packed_float) }, 902bf215546Sopenharmony_ci { PIPE_FORMAT_R11G11B10_FLOAT } }, 903bf215546Sopenharmony_ci 904bf215546Sopenharmony_ci { { o(EXT_texture_integer) }, 905bf215546Sopenharmony_ci { PIPE_FORMAT_R32G32B32A32_UINT, 906bf215546Sopenharmony_ci PIPE_FORMAT_R32G32B32A32_SINT } }, 907bf215546Sopenharmony_ci 908bf215546Sopenharmony_ci { { o(ARB_texture_rg) }, 909bf215546Sopenharmony_ci { PIPE_FORMAT_R8_UNORM, 910bf215546Sopenharmony_ci PIPE_FORMAT_R8G8_UNORM } }, 911bf215546Sopenharmony_ci 912bf215546Sopenharmony_ci { { o(EXT_texture_norm16) }, 913bf215546Sopenharmony_ci { PIPE_FORMAT_R16_UNORM, 914bf215546Sopenharmony_ci PIPE_FORMAT_R16G16_UNORM, 915bf215546Sopenharmony_ci PIPE_FORMAT_R16G16B16A16_UNORM } }, 916bf215546Sopenharmony_ci 917bf215546Sopenharmony_ci { { o(EXT_render_snorm) }, 918bf215546Sopenharmony_ci { PIPE_FORMAT_R8_SNORM, 919bf215546Sopenharmony_ci PIPE_FORMAT_R8G8_SNORM, 920bf215546Sopenharmony_ci PIPE_FORMAT_R8G8B8A8_SNORM, 921bf215546Sopenharmony_ci PIPE_FORMAT_R16_SNORM, 922bf215546Sopenharmony_ci PIPE_FORMAT_R16G16_SNORM, 923bf215546Sopenharmony_ci PIPE_FORMAT_R16G16B16A16_SNORM } }, 924bf215546Sopenharmony_ci 925bf215546Sopenharmony_ci { { o(EXT_color_buffer_half_float) }, 926bf215546Sopenharmony_ci { PIPE_FORMAT_R16_FLOAT, 927bf215546Sopenharmony_ci PIPE_FORMAT_R16G16_FLOAT, 928bf215546Sopenharmony_ci PIPE_FORMAT_R16G16B16X16_FLOAT, 929bf215546Sopenharmony_ci PIPE_FORMAT_R16G16B16A16_FLOAT } }, 930bf215546Sopenharmony_ci }; 931bf215546Sopenharmony_ci 932bf215546Sopenharmony_ci /* Required: render target, sampler, and blending */ 933bf215546Sopenharmony_ci static const struct st_extension_format_mapping rt_blendable[] = { 934bf215546Sopenharmony_ci { { o(EXT_float_blend) }, 935bf215546Sopenharmony_ci { PIPE_FORMAT_R32G32B32A32_FLOAT } }, 936bf215546Sopenharmony_ci }; 937bf215546Sopenharmony_ci 938bf215546Sopenharmony_ci /* Required: depth stencil and sampler support */ 939bf215546Sopenharmony_ci static const struct st_extension_format_mapping depthstencil_mapping[] = { 940bf215546Sopenharmony_ci { { o(ARB_depth_buffer_float) }, 941bf215546Sopenharmony_ci { PIPE_FORMAT_Z32_FLOAT, 942bf215546Sopenharmony_ci PIPE_FORMAT_Z32_FLOAT_S8X24_UINT } }, 943bf215546Sopenharmony_ci }; 944bf215546Sopenharmony_ci 945bf215546Sopenharmony_ci /* Required: sampler support */ 946bf215546Sopenharmony_ci static const struct st_extension_format_mapping texture_mapping[] = { 947bf215546Sopenharmony_ci { { o(ARB_texture_compression_rgtc) }, 948bf215546Sopenharmony_ci { PIPE_FORMAT_RGTC1_UNORM, 949bf215546Sopenharmony_ci PIPE_FORMAT_RGTC1_SNORM, 950bf215546Sopenharmony_ci PIPE_FORMAT_RGTC2_UNORM, 951bf215546Sopenharmony_ci PIPE_FORMAT_RGTC2_SNORM } }, 952bf215546Sopenharmony_ci 953bf215546Sopenharmony_ci { { o(EXT_texture_compression_latc) }, 954bf215546Sopenharmony_ci { PIPE_FORMAT_LATC1_UNORM, 955bf215546Sopenharmony_ci PIPE_FORMAT_LATC1_SNORM, 956bf215546Sopenharmony_ci PIPE_FORMAT_LATC2_UNORM, 957bf215546Sopenharmony_ci PIPE_FORMAT_LATC2_SNORM } }, 958bf215546Sopenharmony_ci 959bf215546Sopenharmony_ci { { o(EXT_texture_compression_s3tc), 960bf215546Sopenharmony_ci o(ANGLE_texture_compression_dxt) }, 961bf215546Sopenharmony_ci { PIPE_FORMAT_DXT1_RGB, 962bf215546Sopenharmony_ci PIPE_FORMAT_DXT1_RGBA, 963bf215546Sopenharmony_ci PIPE_FORMAT_DXT3_RGBA, 964bf215546Sopenharmony_ci PIPE_FORMAT_DXT5_RGBA } }, 965bf215546Sopenharmony_ci 966bf215546Sopenharmony_ci { { o(EXT_texture_compression_s3tc_srgb) }, 967bf215546Sopenharmony_ci { PIPE_FORMAT_DXT1_SRGB, 968bf215546Sopenharmony_ci PIPE_FORMAT_DXT1_SRGBA, 969bf215546Sopenharmony_ci PIPE_FORMAT_DXT3_SRGBA, 970bf215546Sopenharmony_ci PIPE_FORMAT_DXT5_SRGBA } }, 971bf215546Sopenharmony_ci 972bf215546Sopenharmony_ci { { o(ARB_texture_compression_bptc) }, 973bf215546Sopenharmony_ci { PIPE_FORMAT_BPTC_RGBA_UNORM, 974bf215546Sopenharmony_ci PIPE_FORMAT_BPTC_SRGBA, 975bf215546Sopenharmony_ci PIPE_FORMAT_BPTC_RGB_FLOAT, 976bf215546Sopenharmony_ci PIPE_FORMAT_BPTC_RGB_UFLOAT } }, 977bf215546Sopenharmony_ci 978bf215546Sopenharmony_ci { { o(TDFX_texture_compression_FXT1) }, 979bf215546Sopenharmony_ci { PIPE_FORMAT_FXT1_RGB, 980bf215546Sopenharmony_ci PIPE_FORMAT_FXT1_RGBA } }, 981bf215546Sopenharmony_ci 982bf215546Sopenharmony_ci { { o(KHR_texture_compression_astc_ldr), 983bf215546Sopenharmony_ci o(KHR_texture_compression_astc_sliced_3d) }, 984bf215546Sopenharmony_ci { PIPE_FORMAT_ASTC_4x4, 985bf215546Sopenharmony_ci PIPE_FORMAT_ASTC_5x4, 986bf215546Sopenharmony_ci PIPE_FORMAT_ASTC_5x5, 987bf215546Sopenharmony_ci PIPE_FORMAT_ASTC_6x5, 988bf215546Sopenharmony_ci PIPE_FORMAT_ASTC_6x6, 989bf215546Sopenharmony_ci PIPE_FORMAT_ASTC_8x5, 990bf215546Sopenharmony_ci PIPE_FORMAT_ASTC_8x6, 991bf215546Sopenharmony_ci PIPE_FORMAT_ASTC_8x8, 992bf215546Sopenharmony_ci PIPE_FORMAT_ASTC_10x5, 993bf215546Sopenharmony_ci PIPE_FORMAT_ASTC_10x6, 994bf215546Sopenharmony_ci PIPE_FORMAT_ASTC_10x8, 995bf215546Sopenharmony_ci PIPE_FORMAT_ASTC_10x10, 996bf215546Sopenharmony_ci PIPE_FORMAT_ASTC_12x10, 997bf215546Sopenharmony_ci PIPE_FORMAT_ASTC_12x12, 998bf215546Sopenharmony_ci PIPE_FORMAT_ASTC_4x4_SRGB, 999bf215546Sopenharmony_ci PIPE_FORMAT_ASTC_5x4_SRGB, 1000bf215546Sopenharmony_ci PIPE_FORMAT_ASTC_5x5_SRGB, 1001bf215546Sopenharmony_ci PIPE_FORMAT_ASTC_6x5_SRGB, 1002bf215546Sopenharmony_ci PIPE_FORMAT_ASTC_6x6_SRGB, 1003bf215546Sopenharmony_ci PIPE_FORMAT_ASTC_8x5_SRGB, 1004bf215546Sopenharmony_ci PIPE_FORMAT_ASTC_8x6_SRGB, 1005bf215546Sopenharmony_ci PIPE_FORMAT_ASTC_8x8_SRGB, 1006bf215546Sopenharmony_ci PIPE_FORMAT_ASTC_10x5_SRGB, 1007bf215546Sopenharmony_ci PIPE_FORMAT_ASTC_10x6_SRGB, 1008bf215546Sopenharmony_ci PIPE_FORMAT_ASTC_10x8_SRGB, 1009bf215546Sopenharmony_ci PIPE_FORMAT_ASTC_10x10_SRGB, 1010bf215546Sopenharmony_ci PIPE_FORMAT_ASTC_12x10_SRGB, 1011bf215546Sopenharmony_ci PIPE_FORMAT_ASTC_12x12_SRGB } }, 1012bf215546Sopenharmony_ci 1013bf215546Sopenharmony_ci /* ASTC software fallback support. */ 1014bf215546Sopenharmony_ci { { o(KHR_texture_compression_astc_ldr), 1015bf215546Sopenharmony_ci o(KHR_texture_compression_astc_sliced_3d) }, 1016bf215546Sopenharmony_ci { PIPE_FORMAT_R8G8B8A8_UNORM, 1017bf215546Sopenharmony_ci PIPE_FORMAT_R8G8B8A8_SRGB } }, 1018bf215546Sopenharmony_ci 1019bf215546Sopenharmony_ci { { o(EXT_texture_shared_exponent) }, 1020bf215546Sopenharmony_ci { PIPE_FORMAT_R9G9B9E5_FLOAT } }, 1021bf215546Sopenharmony_ci 1022bf215546Sopenharmony_ci { { o(EXT_texture_snorm) }, 1023bf215546Sopenharmony_ci { PIPE_FORMAT_R8G8B8A8_SNORM } }, 1024bf215546Sopenharmony_ci 1025bf215546Sopenharmony_ci { { o(EXT_texture_sRGB), 1026bf215546Sopenharmony_ci o(EXT_texture_sRGB_decode) }, 1027bf215546Sopenharmony_ci { PIPE_FORMAT_A8B8G8R8_SRGB, 1028bf215546Sopenharmony_ci PIPE_FORMAT_B8G8R8A8_SRGB, 1029bf215546Sopenharmony_ci PIPE_FORMAT_A8R8G8B8_SRGB, 1030bf215546Sopenharmony_ci PIPE_FORMAT_R8G8B8A8_SRGB}, 1031bf215546Sopenharmony_ci GL_TRUE }, /* at least one format must be supported */ 1032bf215546Sopenharmony_ci 1033bf215546Sopenharmony_ci { { o(EXT_texture_sRGB_R8) }, 1034bf215546Sopenharmony_ci { PIPE_FORMAT_R8_SRGB }, }, 1035bf215546Sopenharmony_ci 1036bf215546Sopenharmony_ci { { o(EXT_texture_sRGB_RG8) }, 1037bf215546Sopenharmony_ci { PIPE_FORMAT_R8G8_SRGB }, }, 1038bf215546Sopenharmony_ci 1039bf215546Sopenharmony_ci { { o(EXT_texture_type_2_10_10_10_REV) }, 1040bf215546Sopenharmony_ci { PIPE_FORMAT_R10G10B10A2_UNORM, 1041bf215546Sopenharmony_ci PIPE_FORMAT_B10G10R10A2_UNORM }, 1042bf215546Sopenharmony_ci GL_TRUE }, /* at least one format must be supported */ 1043bf215546Sopenharmony_ci 1044bf215546Sopenharmony_ci { { o(ATI_texture_compression_3dc) }, 1045bf215546Sopenharmony_ci { PIPE_FORMAT_LATC2_UNORM } }, 1046bf215546Sopenharmony_ci 1047bf215546Sopenharmony_ci { { o(MESA_ycbcr_texture) }, 1048bf215546Sopenharmony_ci { PIPE_FORMAT_UYVY, 1049bf215546Sopenharmony_ci PIPE_FORMAT_YUYV }, 1050bf215546Sopenharmony_ci GL_TRUE }, /* at least one format must be supported */ 1051bf215546Sopenharmony_ci 1052bf215546Sopenharmony_ci { { o(OES_compressed_ETC1_RGB8_texture) }, 1053bf215546Sopenharmony_ci { PIPE_FORMAT_ETC1_RGB8, 1054bf215546Sopenharmony_ci PIPE_FORMAT_R8G8B8A8_UNORM }, 1055bf215546Sopenharmony_ci GL_TRUE }, /* at least one format must be supported */ 1056bf215546Sopenharmony_ci 1057bf215546Sopenharmony_ci { { o(ARB_stencil_texturing), 1058bf215546Sopenharmony_ci o(ARB_texture_stencil8) }, 1059bf215546Sopenharmony_ci { PIPE_FORMAT_X24S8_UINT, 1060bf215546Sopenharmony_ci PIPE_FORMAT_S8X24_UINT }, 1061bf215546Sopenharmony_ci GL_TRUE }, /* at least one format must be supported */ 1062bf215546Sopenharmony_ci 1063bf215546Sopenharmony_ci { { o(AMD_compressed_ATC_texture) }, 1064bf215546Sopenharmony_ci { PIPE_FORMAT_ATC_RGB, 1065bf215546Sopenharmony_ci PIPE_FORMAT_ATC_RGBA_EXPLICIT, 1066bf215546Sopenharmony_ci PIPE_FORMAT_ATC_RGBA_INTERPOLATED } }, 1067bf215546Sopenharmony_ci }; 1068bf215546Sopenharmony_ci 1069bf215546Sopenharmony_ci /* Required: vertex fetch support. */ 1070bf215546Sopenharmony_ci static const struct st_extension_format_mapping vertex_mapping[] = { 1071bf215546Sopenharmony_ci { { o(EXT_vertex_array_bgra) }, 1072bf215546Sopenharmony_ci { PIPE_FORMAT_B8G8R8A8_UNORM } }, 1073bf215546Sopenharmony_ci { { o(ARB_vertex_type_2_10_10_10_rev) }, 1074bf215546Sopenharmony_ci { PIPE_FORMAT_R10G10B10A2_UNORM, 1075bf215546Sopenharmony_ci PIPE_FORMAT_B10G10R10A2_UNORM, 1076bf215546Sopenharmony_ci PIPE_FORMAT_R10G10B10A2_SNORM, 1077bf215546Sopenharmony_ci PIPE_FORMAT_B10G10R10A2_SNORM, 1078bf215546Sopenharmony_ci PIPE_FORMAT_R10G10B10A2_USCALED, 1079bf215546Sopenharmony_ci PIPE_FORMAT_B10G10R10A2_USCALED, 1080bf215546Sopenharmony_ci PIPE_FORMAT_R10G10B10A2_SSCALED, 1081bf215546Sopenharmony_ci PIPE_FORMAT_B10G10R10A2_SSCALED } }, 1082bf215546Sopenharmony_ci { { o(ARB_vertex_type_10f_11f_11f_rev) }, 1083bf215546Sopenharmony_ci { PIPE_FORMAT_R11G11B10_FLOAT } }, 1084bf215546Sopenharmony_ci }; 1085bf215546Sopenharmony_ci 1086bf215546Sopenharmony_ci static const struct st_extension_format_mapping tbo_rgb32[] = { 1087bf215546Sopenharmony_ci { {o(ARB_texture_buffer_object_rgb32) }, 1088bf215546Sopenharmony_ci { PIPE_FORMAT_R32G32B32_FLOAT, 1089bf215546Sopenharmony_ci PIPE_FORMAT_R32G32B32_UINT, 1090bf215546Sopenharmony_ci PIPE_FORMAT_R32G32B32_SINT, 1091bf215546Sopenharmony_ci } }, 1092bf215546Sopenharmony_ci }; 1093bf215546Sopenharmony_ci 1094bf215546Sopenharmony_ci /* Expose the extensions which directly correspond to gallium caps. */ 1095bf215546Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(cap_mapping); i++) { 1096bf215546Sopenharmony_ci if (screen->get_param(screen, cap_mapping[i].cap)) { 1097bf215546Sopenharmony_ci extension_table[cap_mapping[i].extension_offset] = GL_TRUE; 1098bf215546Sopenharmony_ci } 1099bf215546Sopenharmony_ci } 1100bf215546Sopenharmony_ci 1101bf215546Sopenharmony_ci /* EXT implies ARB here */ 1102bf215546Sopenharmony_ci if (extensions->EXT_texture_filter_minmax) 1103bf215546Sopenharmony_ci extensions->ARB_texture_filter_minmax = GL_TRUE; 1104bf215546Sopenharmony_ci 1105bf215546Sopenharmony_ci /* Expose the extensions which directly correspond to gallium formats. */ 1106bf215546Sopenharmony_ci init_format_extensions(screen, extensions, rendertarget_mapping, 1107bf215546Sopenharmony_ci ARRAY_SIZE(rendertarget_mapping), PIPE_TEXTURE_2D, 1108bf215546Sopenharmony_ci PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW); 1109bf215546Sopenharmony_ci init_format_extensions(screen, extensions, rt_blendable, 1110bf215546Sopenharmony_ci ARRAY_SIZE(rt_blendable), PIPE_TEXTURE_2D, 1111bf215546Sopenharmony_ci PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW | 1112bf215546Sopenharmony_ci PIPE_BIND_BLENDABLE); 1113bf215546Sopenharmony_ci init_format_extensions(screen, extensions, depthstencil_mapping, 1114bf215546Sopenharmony_ci ARRAY_SIZE(depthstencil_mapping), PIPE_TEXTURE_2D, 1115bf215546Sopenharmony_ci PIPE_BIND_DEPTH_STENCIL | PIPE_BIND_SAMPLER_VIEW); 1116bf215546Sopenharmony_ci init_format_extensions(screen, extensions, texture_mapping, 1117bf215546Sopenharmony_ci ARRAY_SIZE(texture_mapping), PIPE_TEXTURE_2D, 1118bf215546Sopenharmony_ci PIPE_BIND_SAMPLER_VIEW); 1119bf215546Sopenharmony_ci init_format_extensions(screen, extensions, vertex_mapping, 1120bf215546Sopenharmony_ci ARRAY_SIZE(vertex_mapping), PIPE_BUFFER, 1121bf215546Sopenharmony_ci PIPE_BIND_VERTEX_BUFFER); 1122bf215546Sopenharmony_ci 1123bf215546Sopenharmony_ci /* Figure out GLSL support and set GLSLVersion to it. */ 1124bf215546Sopenharmony_ci consts->GLSLVersion = screen->get_param(screen, PIPE_CAP_GLSL_FEATURE_LEVEL); 1125bf215546Sopenharmony_ci consts->GLSLVersionCompat = 1126bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_GLSL_FEATURE_LEVEL_COMPATIBILITY); 1127bf215546Sopenharmony_ci 1128bf215546Sopenharmony_ci const unsigned ESSLVersion = 1129bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_ESSL_FEATURE_LEVEL); 1130bf215546Sopenharmony_ci const unsigned GLSLVersion = 1131bf215546Sopenharmony_ci api == API_OPENGL_COMPAT ? consts->GLSLVersionCompat : 1132bf215546Sopenharmony_ci consts->GLSLVersion; 1133bf215546Sopenharmony_ci 1134bf215546Sopenharmony_ci _mesa_override_glsl_version(consts); 1135bf215546Sopenharmony_ci 1136bf215546Sopenharmony_ci if (options->force_glsl_version > 0 && 1137bf215546Sopenharmony_ci options->force_glsl_version <= GLSLVersion) { 1138bf215546Sopenharmony_ci consts->ForceGLSLVersion = options->force_glsl_version; 1139bf215546Sopenharmony_ci } 1140bf215546Sopenharmony_ci 1141bf215546Sopenharmony_ci consts->ForceCompatShaders = options->force_compat_shaders; 1142bf215546Sopenharmony_ci 1143bf215546Sopenharmony_ci consts->AllowExtraPPTokens = options->allow_extra_pp_tokens; 1144bf215546Sopenharmony_ci 1145bf215546Sopenharmony_ci consts->AllowHigherCompatVersion = options->allow_higher_compat_version; 1146bf215546Sopenharmony_ci consts->AllowGLSLCompatShaders = options->allow_glsl_compat_shaders; 1147bf215546Sopenharmony_ci 1148bf215546Sopenharmony_ci consts->ForceGLSLAbsSqrt = options->force_glsl_abs_sqrt; 1149bf215546Sopenharmony_ci 1150bf215546Sopenharmony_ci consts->AllowGLSLBuiltinVariableRedeclaration = options->allow_glsl_builtin_variable_redeclaration; 1151bf215546Sopenharmony_ci 1152bf215546Sopenharmony_ci consts->dri_config_options_sha1 = options->config_options_sha1; 1153bf215546Sopenharmony_ci 1154bf215546Sopenharmony_ci consts->AllowGLSLCrossStageInterpolationMismatch = options->allow_glsl_cross_stage_interpolation_mismatch; 1155bf215546Sopenharmony_ci 1156bf215546Sopenharmony_ci consts->DoDCEBeforeClipCullAnalysis = options->do_dce_before_clip_cull_analysis; 1157bf215546Sopenharmony_ci 1158bf215546Sopenharmony_ci consts->GLSLIgnoreWriteToReadonlyVar = options->glsl_ignore_write_to_readonly_var; 1159bf215546Sopenharmony_ci 1160bf215546Sopenharmony_ci consts->ForceMapBufferSynchronized = options->force_gl_map_buffer_synchronized; 1161bf215546Sopenharmony_ci 1162bf215546Sopenharmony_ci consts->PrimitiveRestartFixedIndex = 1163bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_PRIMITIVE_RESTART_FIXED_INDEX); 1164bf215546Sopenharmony_ci 1165bf215546Sopenharmony_ci /* Technically we are turning on the EXT_gpu_shader5 extension, 1166bf215546Sopenharmony_ci * ARB_gpu_shader5 does not exist in GLES, but this flag is what 1167bf215546Sopenharmony_ci * switches on EXT_gpu_shader5: 1168bf215546Sopenharmony_ci */ 1169bf215546Sopenharmony_ci if (api == API_OPENGLES2 && ESSLVersion >= 320) 1170bf215546Sopenharmony_ci extensions->ARB_gpu_shader5 = GL_TRUE; 1171bf215546Sopenharmony_ci 1172bf215546Sopenharmony_ci if (GLSLVersion >= 400 && !options->disable_arb_gpu_shader5) 1173bf215546Sopenharmony_ci extensions->ARB_gpu_shader5 = GL_TRUE; 1174bf215546Sopenharmony_ci if (GLSLVersion >= 410) 1175bf215546Sopenharmony_ci extensions->ARB_shader_precision = GL_TRUE; 1176bf215546Sopenharmony_ci 1177bf215546Sopenharmony_ci /* This extension needs full OpenGL 3.2, but we don't know if that's 1178bf215546Sopenharmony_ci * supported at this point. Only check the GLSL version. */ 1179bf215546Sopenharmony_ci if (GLSLVersion >= 150 && 1180bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_VS_LAYER_VIEWPORT)) { 1181bf215546Sopenharmony_ci extensions->AMD_vertex_shader_layer = GL_TRUE; 1182bf215546Sopenharmony_ci } 1183bf215546Sopenharmony_ci 1184bf215546Sopenharmony_ci if (GLSLVersion >= 140) { 1185bf215546Sopenharmony_ci /* Since GLSL 1.40 has support for all of the features of gpu_shader4, 1186bf215546Sopenharmony_ci * we can always expose it if the driver can do 140. Supporting 1187bf215546Sopenharmony_ci * gpu_shader4 on drivers without GLSL 1.40 is left for a future 1188bf215546Sopenharmony_ci * pipe cap. 1189bf215546Sopenharmony_ci */ 1190bf215546Sopenharmony_ci extensions->EXT_gpu_shader4 = GL_TRUE; 1191bf215546Sopenharmony_ci extensions->EXT_texture_buffer_object = GL_TRUE; 1192bf215546Sopenharmony_ci 1193bf215546Sopenharmony_ci if (consts->MaxTransformFeedbackBuffers && 1194bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_SHADER_ARRAY_COMPONENTS)) 1195bf215546Sopenharmony_ci extensions->ARB_enhanced_layouts = GL_TRUE; 1196bf215546Sopenharmony_ci } 1197bf215546Sopenharmony_ci 1198bf215546Sopenharmony_ci if (GLSLVersion >= 130) { 1199bf215546Sopenharmony_ci consts->NativeIntegers = GL_TRUE; 1200bf215546Sopenharmony_ci consts->MaxClipPlanes = 8; 1201bf215546Sopenharmony_ci 1202bf215546Sopenharmony_ci uint32_t drv_clip_planes = screen->get_param(screen, PIPE_CAP_CLIP_PLANES); 1203bf215546Sopenharmony_ci /* only override for > 1 - 0 if none, 1 is MAX, >2 overrides MAX */ 1204bf215546Sopenharmony_ci if (drv_clip_planes > 1) 1205bf215546Sopenharmony_ci consts->MaxClipPlanes = drv_clip_planes; 1206bf215546Sopenharmony_ci 1207bf215546Sopenharmony_ci if (screen->get_param(screen, PIPE_CAP_VERTEXID_NOBASE)) { 1208bf215546Sopenharmony_ci consts->VertexID_is_zero_based = GL_TRUE; 1209bf215546Sopenharmony_ci } 1210bf215546Sopenharmony_ci 1211bf215546Sopenharmony_ci /* Extensions that either depend on GLSL 1.30 or are a subset thereof. */ 1212bf215546Sopenharmony_ci extensions->ARB_conservative_depth = GL_TRUE; 1213bf215546Sopenharmony_ci extensions->ARB_shading_language_packing = GL_TRUE; 1214bf215546Sopenharmony_ci extensions->OES_depth_texture_cube_map = GL_TRUE; 1215bf215546Sopenharmony_ci extensions->ARB_shading_language_420pack = GL_TRUE; 1216bf215546Sopenharmony_ci extensions->ARB_texture_query_levels = GL_TRUE; 1217bf215546Sopenharmony_ci 1218bf215546Sopenharmony_ci extensions->ARB_shader_bit_encoding = GL_TRUE; 1219bf215546Sopenharmony_ci 1220bf215546Sopenharmony_ci extensions->EXT_shader_integer_mix = GL_TRUE; 1221bf215546Sopenharmony_ci extensions->ARB_arrays_of_arrays = GL_TRUE; 1222bf215546Sopenharmony_ci extensions->MESA_shader_integer_functions = GL_TRUE; 1223bf215546Sopenharmony_ci 1224bf215546Sopenharmony_ci if (screen->get_param(screen, PIPE_CAP_OPENCL_INTEGER_FUNCTIONS) && 1225bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_INTEGER_MULTIPLY_32X16)) { 1226bf215546Sopenharmony_ci extensions->INTEL_shader_integer_functions2 = GL_TRUE; 1227bf215546Sopenharmony_ci } 1228bf215546Sopenharmony_ci } else { 1229bf215546Sopenharmony_ci /* Optional integer support for GLSL 1.2. */ 1230bf215546Sopenharmony_ci if (screen->get_shader_param(screen, PIPE_SHADER_VERTEX, 1231bf215546Sopenharmony_ci PIPE_SHADER_CAP_INTEGERS) && 1232bf215546Sopenharmony_ci screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT, 1233bf215546Sopenharmony_ci PIPE_SHADER_CAP_INTEGERS)) { 1234bf215546Sopenharmony_ci consts->NativeIntegers = GL_TRUE; 1235bf215546Sopenharmony_ci 1236bf215546Sopenharmony_ci extensions->EXT_shader_integer_mix = GL_TRUE; 1237bf215546Sopenharmony_ci } 1238bf215546Sopenharmony_ci 1239bf215546Sopenharmony_ci /* Integer textures make no sense before GLSL 1.30 */ 1240bf215546Sopenharmony_ci extensions->EXT_texture_integer = GL_FALSE; 1241bf215546Sopenharmony_ci extensions->ARB_texture_rgb10_a2ui = GL_FALSE; 1242bf215546Sopenharmony_ci } 1243bf215546Sopenharmony_ci 1244bf215546Sopenharmony_ci if (options->glsl_zero_init) { 1245bf215546Sopenharmony_ci consts->GLSLZeroInit = 1; 1246bf215546Sopenharmony_ci } else { 1247bf215546Sopenharmony_ci consts->GLSLZeroInit = screen->get_param(screen, PIPE_CAP_GLSL_ZERO_INIT); 1248bf215546Sopenharmony_ci } 1249bf215546Sopenharmony_ci 1250bf215546Sopenharmony_ci consts->ForceGLNamesReuse = options->force_gl_names_reuse; 1251bf215546Sopenharmony_ci 1252bf215546Sopenharmony_ci consts->ForceIntegerTexNearest = options->force_integer_tex_nearest; 1253bf215546Sopenharmony_ci 1254bf215546Sopenharmony_ci consts->VendorOverride = options->force_gl_vendor; 1255bf215546Sopenharmony_ci consts->RendererOverride = options->force_gl_renderer; 1256bf215546Sopenharmony_ci 1257bf215546Sopenharmony_ci consts->UniformBooleanTrue = consts->NativeIntegers ? ~0U : fui(1.0f); 1258bf215546Sopenharmony_ci 1259bf215546Sopenharmony_ci /* Below are the cases which cannot be moved into tables easily. */ 1260bf215546Sopenharmony_ci 1261bf215546Sopenharmony_ci /* The compatibility profile also requires GLSLVersionCompat >= 400. */ 1262bf215546Sopenharmony_ci if (screen->get_shader_param(screen, PIPE_SHADER_TESS_CTRL, 1263bf215546Sopenharmony_ci PIPE_SHADER_CAP_MAX_INSTRUCTIONS) > 0 && 1264bf215546Sopenharmony_ci (api != API_OPENGL_COMPAT || consts->GLSLVersionCompat >= 400)) { 1265bf215546Sopenharmony_ci extensions->ARB_tessellation_shader = GL_TRUE; 1266bf215546Sopenharmony_ci } 1267bf215546Sopenharmony_ci 1268bf215546Sopenharmony_ci /* OES_geometry_shader requires instancing */ 1269bf215546Sopenharmony_ci if ((GLSLVersion >= 400 || ESSLVersion >= 310) && 1270bf215546Sopenharmony_ci screen->get_shader_param(screen, PIPE_SHADER_GEOMETRY, 1271bf215546Sopenharmony_ci PIPE_SHADER_CAP_MAX_INSTRUCTIONS) > 0 && 1272bf215546Sopenharmony_ci consts->MaxGeometryShaderInvocations >= 32) { 1273bf215546Sopenharmony_ci extensions->OES_geometry_shader = GL_TRUE; 1274bf215546Sopenharmony_ci } 1275bf215546Sopenharmony_ci 1276bf215546Sopenharmony_ci /* Some hardware may not support indirect draws, but still wants ES 1277bf215546Sopenharmony_ci * 3.1. This allows the extension to be enabled only in ES contexts to 1278bf215546Sopenharmony_ci * avoid claiming hw support when there is none, and using a software 1279bf215546Sopenharmony_ci * fallback for ES. 1280bf215546Sopenharmony_ci */ 1281bf215546Sopenharmony_ci if (api == API_OPENGLES2 && ESSLVersion >= 310) { 1282bf215546Sopenharmony_ci extensions->ARB_draw_indirect = GL_TRUE; 1283bf215546Sopenharmony_ci } 1284bf215546Sopenharmony_ci 1285bf215546Sopenharmony_ci /* Needs PIPE_CAP_SAMPLE_SHADING + all the sample-related bits of 1286bf215546Sopenharmony_ci * ARB_gpu_shader5. This enables all the per-sample shading ES extensions. 1287bf215546Sopenharmony_ci */ 1288bf215546Sopenharmony_ci extensions->OES_sample_variables = extensions->ARB_sample_shading && 1289bf215546Sopenharmony_ci extensions->ARB_gpu_shader5; 1290bf215546Sopenharmony_ci 1291bf215546Sopenharmony_ci /* Maximum sample count. */ 1292bf215546Sopenharmony_ci { 1293bf215546Sopenharmony_ci static const enum pipe_format color_formats[] = { 1294bf215546Sopenharmony_ci PIPE_FORMAT_R8G8B8A8_UNORM, 1295bf215546Sopenharmony_ci PIPE_FORMAT_B8G8R8A8_UNORM, 1296bf215546Sopenharmony_ci PIPE_FORMAT_A8R8G8B8_UNORM, 1297bf215546Sopenharmony_ci PIPE_FORMAT_A8B8G8R8_UNORM, 1298bf215546Sopenharmony_ci }; 1299bf215546Sopenharmony_ci static const enum pipe_format depth_formats[] = { 1300bf215546Sopenharmony_ci PIPE_FORMAT_Z16_UNORM, 1301bf215546Sopenharmony_ci PIPE_FORMAT_Z24X8_UNORM, 1302bf215546Sopenharmony_ci PIPE_FORMAT_X8Z24_UNORM, 1303bf215546Sopenharmony_ci PIPE_FORMAT_Z32_UNORM, 1304bf215546Sopenharmony_ci PIPE_FORMAT_Z32_FLOAT 1305bf215546Sopenharmony_ci }; 1306bf215546Sopenharmony_ci static const enum pipe_format int_formats[] = { 1307bf215546Sopenharmony_ci PIPE_FORMAT_R8G8B8A8_SINT 1308bf215546Sopenharmony_ci }; 1309bf215546Sopenharmony_ci static const enum pipe_format void_formats[] = { 1310bf215546Sopenharmony_ci PIPE_FORMAT_NONE 1311bf215546Sopenharmony_ci }; 1312bf215546Sopenharmony_ci 1313bf215546Sopenharmony_ci consts->MaxSamples = 1314bf215546Sopenharmony_ci get_max_samples_for_formats(screen, ARRAY_SIZE(color_formats), 1315bf215546Sopenharmony_ci color_formats, 16, 1316bf215546Sopenharmony_ci PIPE_BIND_RENDER_TARGET); 1317bf215546Sopenharmony_ci 1318bf215546Sopenharmony_ci consts->MaxImageSamples = 1319bf215546Sopenharmony_ci get_max_samples_for_formats(screen, ARRAY_SIZE(color_formats), 1320bf215546Sopenharmony_ci color_formats, 16, 1321bf215546Sopenharmony_ci PIPE_BIND_SHADER_IMAGE); 1322bf215546Sopenharmony_ci 1323bf215546Sopenharmony_ci consts->MaxColorTextureSamples = 1324bf215546Sopenharmony_ci get_max_samples_for_formats(screen, ARRAY_SIZE(color_formats), 1325bf215546Sopenharmony_ci color_formats, consts->MaxSamples, 1326bf215546Sopenharmony_ci PIPE_BIND_SAMPLER_VIEW); 1327bf215546Sopenharmony_ci 1328bf215546Sopenharmony_ci consts->MaxDepthTextureSamples = 1329bf215546Sopenharmony_ci get_max_samples_for_formats(screen, ARRAY_SIZE(depth_formats), 1330bf215546Sopenharmony_ci depth_formats, consts->MaxSamples, 1331bf215546Sopenharmony_ci PIPE_BIND_SAMPLER_VIEW); 1332bf215546Sopenharmony_ci 1333bf215546Sopenharmony_ci consts->MaxIntegerSamples = 1334bf215546Sopenharmony_ci get_max_samples_for_formats(screen, ARRAY_SIZE(int_formats), 1335bf215546Sopenharmony_ci int_formats, consts->MaxSamples, 1336bf215546Sopenharmony_ci PIPE_BIND_SAMPLER_VIEW); 1337bf215546Sopenharmony_ci 1338bf215546Sopenharmony_ci /* ARB_framebuffer_no_attachments, assume max no. of samples 32 */ 1339bf215546Sopenharmony_ci consts->MaxFramebufferSamples = 1340bf215546Sopenharmony_ci get_max_samples_for_formats(screen, ARRAY_SIZE(void_formats), 1341bf215546Sopenharmony_ci void_formats, 32, 1342bf215546Sopenharmony_ci PIPE_BIND_RENDER_TARGET); 1343bf215546Sopenharmony_ci 1344bf215546Sopenharmony_ci if (extensions->AMD_framebuffer_multisample_advanced) { 1345bf215546Sopenharmony_ci /* AMD_framebuffer_multisample_advanced */ 1346bf215546Sopenharmony_ci /* This can be greater than storage samples. */ 1347bf215546Sopenharmony_ci consts->MaxColorFramebufferSamples = 1348bf215546Sopenharmony_ci get_max_samples_for_formats_advanced(screen, 1349bf215546Sopenharmony_ci ARRAY_SIZE(color_formats), 1350bf215546Sopenharmony_ci color_formats, 16, 1351bf215546Sopenharmony_ci consts->MaxSamples, 1352bf215546Sopenharmony_ci PIPE_BIND_RENDER_TARGET); 1353bf215546Sopenharmony_ci 1354bf215546Sopenharmony_ci /* If the driver supports N color samples, it means it supports 1355bf215546Sopenharmony_ci * N samples and N storage samples. N samples >= N storage 1356bf215546Sopenharmony_ci * samples. 1357bf215546Sopenharmony_ci */ 1358bf215546Sopenharmony_ci consts->MaxColorFramebufferStorageSamples = consts->MaxSamples; 1359bf215546Sopenharmony_ci consts->MaxDepthStencilFramebufferSamples = 1360bf215546Sopenharmony_ci consts->MaxDepthTextureSamples; 1361bf215546Sopenharmony_ci 1362bf215546Sopenharmony_ci assert(consts->MaxColorFramebufferSamples >= 1363bf215546Sopenharmony_ci consts->MaxDepthStencilFramebufferSamples); 1364bf215546Sopenharmony_ci assert(consts->MaxDepthStencilFramebufferSamples >= 1365bf215546Sopenharmony_ci consts->MaxColorFramebufferStorageSamples); 1366bf215546Sopenharmony_ci 1367bf215546Sopenharmony_ci consts->NumSupportedMultisampleModes = 0; 1368bf215546Sopenharmony_ci 1369bf215546Sopenharmony_ci unsigned depth_samples_supported = 0; 1370bf215546Sopenharmony_ci 1371bf215546Sopenharmony_ci for (unsigned samples = 2; 1372bf215546Sopenharmony_ci samples <= consts->MaxDepthStencilFramebufferSamples; 1373bf215546Sopenharmony_ci samples++) { 1374bf215546Sopenharmony_ci if (screen->is_format_supported(screen, PIPE_FORMAT_Z32_FLOAT, 1375bf215546Sopenharmony_ci PIPE_TEXTURE_2D, samples, samples, 1376bf215546Sopenharmony_ci PIPE_BIND_DEPTH_STENCIL)) 1377bf215546Sopenharmony_ci depth_samples_supported |= 1 << samples; 1378bf215546Sopenharmony_ci } 1379bf215546Sopenharmony_ci 1380bf215546Sopenharmony_ci for (unsigned samples = 2; 1381bf215546Sopenharmony_ci samples <= consts->MaxColorFramebufferSamples; 1382bf215546Sopenharmony_ci samples++) { 1383bf215546Sopenharmony_ci for (unsigned depth_samples = 2; 1384bf215546Sopenharmony_ci depth_samples <= samples; depth_samples++) { 1385bf215546Sopenharmony_ci if (!(depth_samples_supported & (1 << depth_samples))) 1386bf215546Sopenharmony_ci continue; 1387bf215546Sopenharmony_ci 1388bf215546Sopenharmony_ci for (unsigned storage_samples = 2; 1389bf215546Sopenharmony_ci storage_samples <= depth_samples; storage_samples++) { 1390bf215546Sopenharmony_ci if (screen->is_format_supported(screen, 1391bf215546Sopenharmony_ci PIPE_FORMAT_R8G8B8A8_UNORM, 1392bf215546Sopenharmony_ci PIPE_TEXTURE_2D, 1393bf215546Sopenharmony_ci samples, 1394bf215546Sopenharmony_ci storage_samples, 1395bf215546Sopenharmony_ci PIPE_BIND_RENDER_TARGET)) { 1396bf215546Sopenharmony_ci unsigned i = consts->NumSupportedMultisampleModes; 1397bf215546Sopenharmony_ci 1398bf215546Sopenharmony_ci assert(i < ARRAY_SIZE(consts->SupportedMultisampleModes)); 1399bf215546Sopenharmony_ci consts->SupportedMultisampleModes[i].NumColorSamples = 1400bf215546Sopenharmony_ci samples; 1401bf215546Sopenharmony_ci consts->SupportedMultisampleModes[i].NumColorStorageSamples = 1402bf215546Sopenharmony_ci storage_samples; 1403bf215546Sopenharmony_ci consts->SupportedMultisampleModes[i].NumDepthStencilSamples = 1404bf215546Sopenharmony_ci depth_samples; 1405bf215546Sopenharmony_ci consts->NumSupportedMultisampleModes++; 1406bf215546Sopenharmony_ci } 1407bf215546Sopenharmony_ci } 1408bf215546Sopenharmony_ci } 1409bf215546Sopenharmony_ci } 1410bf215546Sopenharmony_ci } 1411bf215546Sopenharmony_ci } 1412bf215546Sopenharmony_ci 1413bf215546Sopenharmony_ci if (consts->MaxSamples >= 2) { 1414bf215546Sopenharmony_ci /* Real MSAA support */ 1415bf215546Sopenharmony_ci extensions->EXT_framebuffer_multisample = GL_TRUE; 1416bf215546Sopenharmony_ci extensions->EXT_framebuffer_multisample_blit_scaled = GL_TRUE; 1417bf215546Sopenharmony_ci } 1418bf215546Sopenharmony_ci else if (consts->MaxSamples > 0 && 1419bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_FAKE_SW_MSAA)) { 1420bf215546Sopenharmony_ci /* fake MSAA support */ 1421bf215546Sopenharmony_ci consts->FakeSWMSAA = GL_TRUE; 1422bf215546Sopenharmony_ci extensions->EXT_framebuffer_multisample = GL_TRUE; 1423bf215546Sopenharmony_ci extensions->EXT_framebuffer_multisample_blit_scaled = GL_TRUE; 1424bf215546Sopenharmony_ci extensions->ARB_texture_multisample = GL_TRUE; 1425bf215546Sopenharmony_ci } 1426bf215546Sopenharmony_ci 1427bf215546Sopenharmony_ci if (consts->MaxDualSourceDrawBuffers > 0 && 1428bf215546Sopenharmony_ci !options->disable_blend_func_extended) 1429bf215546Sopenharmony_ci extensions->ARB_blend_func_extended = GL_TRUE; 1430bf215546Sopenharmony_ci 1431bf215546Sopenharmony_ci if (screen->get_param(screen, PIPE_CAP_QUERY_TIME_ELAPSED) || 1432bf215546Sopenharmony_ci extensions->ARB_timer_query) { 1433bf215546Sopenharmony_ci extensions->EXT_timer_query = GL_TRUE; 1434bf215546Sopenharmony_ci } 1435bf215546Sopenharmony_ci 1436bf215546Sopenharmony_ci if (extensions->ARB_transform_feedback2 && 1437bf215546Sopenharmony_ci extensions->ARB_draw_instanced) { 1438bf215546Sopenharmony_ci extensions->ARB_transform_feedback_instanced = GL_TRUE; 1439bf215546Sopenharmony_ci } 1440bf215546Sopenharmony_ci if (options->force_glsl_extensions_warn) 1441bf215546Sopenharmony_ci consts->ForceGLSLExtensionsWarn = 1; 1442bf215546Sopenharmony_ci 1443bf215546Sopenharmony_ci if (options->disable_glsl_line_continuations) 1444bf215546Sopenharmony_ci consts->DisableGLSLLineContinuations = 1; 1445bf215546Sopenharmony_ci 1446bf215546Sopenharmony_ci if (options->allow_glsl_extension_directive_midshader) 1447bf215546Sopenharmony_ci consts->AllowGLSLExtensionDirectiveMidShader = GL_TRUE; 1448bf215546Sopenharmony_ci 1449bf215546Sopenharmony_ci if (options->allow_glsl_120_subset_in_110) 1450bf215546Sopenharmony_ci consts->AllowGLSL120SubsetIn110 = GL_TRUE; 1451bf215546Sopenharmony_ci 1452bf215546Sopenharmony_ci if (options->allow_glsl_builtin_const_expression) 1453bf215546Sopenharmony_ci consts->AllowGLSLBuiltinConstantExpression = GL_TRUE; 1454bf215546Sopenharmony_ci 1455bf215546Sopenharmony_ci if (options->allow_glsl_relaxed_es) 1456bf215546Sopenharmony_ci consts->AllowGLSLRelaxedES = GL_TRUE; 1457bf215546Sopenharmony_ci 1458bf215546Sopenharmony_ci consts->MinMapBufferAlignment = 1459bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT); 1460bf215546Sopenharmony_ci 1461bf215546Sopenharmony_ci /* The OpenGL Compatibility profile requires arbitrary buffer swizzling. */ 1462bf215546Sopenharmony_ci if (api == API_OPENGL_COMPAT && 1463bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_BUFFER_SAMPLER_VIEW_RGBA_ONLY)) 1464bf215546Sopenharmony_ci extensions->ARB_texture_buffer_object = GL_FALSE; 1465bf215546Sopenharmony_ci 1466bf215546Sopenharmony_ci if (extensions->ARB_texture_buffer_object) { 1467bf215546Sopenharmony_ci consts->MaxTextureBufferSize = 1468bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_MAX_TEXEL_BUFFER_ELEMENTS_UINT); 1469bf215546Sopenharmony_ci consts->TextureBufferOffsetAlignment = 1470bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT); 1471bf215546Sopenharmony_ci 1472bf215546Sopenharmony_ci if (consts->TextureBufferOffsetAlignment) 1473bf215546Sopenharmony_ci extensions->ARB_texture_buffer_range = GL_TRUE; 1474bf215546Sopenharmony_ci 1475bf215546Sopenharmony_ci init_format_extensions(screen, extensions, tbo_rgb32, 1476bf215546Sopenharmony_ci ARRAY_SIZE(tbo_rgb32), PIPE_BUFFER, 1477bf215546Sopenharmony_ci PIPE_BIND_SAMPLER_VIEW); 1478bf215546Sopenharmony_ci } 1479bf215546Sopenharmony_ci 1480bf215546Sopenharmony_ci extensions->OES_texture_buffer = 1481bf215546Sopenharmony_ci consts->Program[MESA_SHADER_COMPUTE].MaxImageUniforms && 1482bf215546Sopenharmony_ci extensions->ARB_texture_buffer_object && 1483bf215546Sopenharmony_ci extensions->ARB_texture_buffer_range && 1484bf215546Sopenharmony_ci extensions->ARB_texture_buffer_object_rgb32; 1485bf215546Sopenharmony_ci 1486bf215546Sopenharmony_ci extensions->EXT_framebuffer_sRGB = 1487bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_DEST_SURFACE_SRGB_CONTROL) && 1488bf215546Sopenharmony_ci extensions->EXT_sRGB; 1489bf215546Sopenharmony_ci 1490bf215546Sopenharmony_ci /* Unpacking a varying in the fragment shader costs 1 texture indirection. 1491bf215546Sopenharmony_ci * If the number of available texture indirections is very limited, then we 1492bf215546Sopenharmony_ci * prefer to disable varying packing rather than run the risk of varying 1493bf215546Sopenharmony_ci * packing preventing a shader from running. 1494bf215546Sopenharmony_ci */ 1495bf215546Sopenharmony_ci if (screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT, 1496bf215546Sopenharmony_ci PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS) <= 8) { 1497bf215546Sopenharmony_ci /* We can't disable varying packing if transform feedback is available, 1498bf215546Sopenharmony_ci * because transform feedback code assumes a packed varying layout. 1499bf215546Sopenharmony_ci */ 1500bf215546Sopenharmony_ci if (!extensions->EXT_transform_feedback) 1501bf215546Sopenharmony_ci consts->DisableVaryingPacking = GL_TRUE; 1502bf215546Sopenharmony_ci } 1503bf215546Sopenharmony_ci 1504bf215546Sopenharmony_ci if (!screen->get_param(screen, PIPE_CAP_PACKED_STREAM_OUTPUT)) 1505bf215546Sopenharmony_ci consts->DisableTransformFeedbackPacking = GL_TRUE; 1506bf215546Sopenharmony_ci 1507bf215546Sopenharmony_ci if (screen->get_param(screen, PIPE_CAP_PREFER_POT_ALIGNED_VARYINGS)) 1508bf215546Sopenharmony_ci consts->PreferPOTAlignedVaryings = GL_TRUE; 1509bf215546Sopenharmony_ci 1510bf215546Sopenharmony_ci unsigned max_fb_fetch_rts = screen->get_param(screen, PIPE_CAP_FBFETCH); 1511bf215546Sopenharmony_ci bool coherent_fb_fetch = 1512bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_FBFETCH_COHERENT); 1513bf215546Sopenharmony_ci 1514bf215546Sopenharmony_ci if (screen->get_param(screen, PIPE_CAP_BLEND_EQUATION_ADVANCED)) 1515bf215546Sopenharmony_ci extensions->KHR_blend_equation_advanced = true; 1516bf215546Sopenharmony_ci 1517bf215546Sopenharmony_ci if (max_fb_fetch_rts > 0) { 1518bf215546Sopenharmony_ci extensions->KHR_blend_equation_advanced = true; 1519bf215546Sopenharmony_ci extensions->KHR_blend_equation_advanced_coherent = coherent_fb_fetch; 1520bf215546Sopenharmony_ci 1521bf215546Sopenharmony_ci if (max_fb_fetch_rts >= 1522bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS)) { 1523bf215546Sopenharmony_ci extensions->EXT_shader_framebuffer_fetch_non_coherent = true; 1524bf215546Sopenharmony_ci extensions->EXT_shader_framebuffer_fetch = coherent_fb_fetch; 1525bf215546Sopenharmony_ci } 1526bf215546Sopenharmony_ci } 1527bf215546Sopenharmony_ci 1528bf215546Sopenharmony_ci consts->MaxViewports = screen->get_param(screen, PIPE_CAP_MAX_VIEWPORTS); 1529bf215546Sopenharmony_ci if (consts->MaxViewports >= 16) { 1530bf215546Sopenharmony_ci if (GLSLVersion >= 400) { 1531bf215546Sopenharmony_ci consts->ViewportBounds.Min = -32768.0; 1532bf215546Sopenharmony_ci consts->ViewportBounds.Max = 32767.0; 1533bf215546Sopenharmony_ci } else { 1534bf215546Sopenharmony_ci consts->ViewportBounds.Min = -16384.0; 1535bf215546Sopenharmony_ci consts->ViewportBounds.Max = 16383.0; 1536bf215546Sopenharmony_ci } 1537bf215546Sopenharmony_ci extensions->ARB_viewport_array = GL_TRUE; 1538bf215546Sopenharmony_ci extensions->ARB_fragment_layer_viewport = GL_TRUE; 1539bf215546Sopenharmony_ci if (extensions->AMD_vertex_shader_layer) 1540bf215546Sopenharmony_ci extensions->AMD_vertex_shader_viewport_index = GL_TRUE; 1541bf215546Sopenharmony_ci } 1542bf215546Sopenharmony_ci 1543bf215546Sopenharmony_ci if (extensions->AMD_vertex_shader_layer && 1544bf215546Sopenharmony_ci extensions->AMD_vertex_shader_viewport_index && 1545bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_TES_LAYER_VIEWPORT)) 1546bf215546Sopenharmony_ci extensions->ARB_shader_viewport_layer_array = GL_TRUE; 1547bf215546Sopenharmony_ci 1548bf215546Sopenharmony_ci /* ARB_framebuffer_no_attachments */ 1549bf215546Sopenharmony_ci if (screen->get_param(screen, PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT) && 1550bf215546Sopenharmony_ci ((consts->MaxSamples >= 4 && consts->MaxFramebufferLayers >= 2048) || 1551bf215546Sopenharmony_ci (consts->MaxFramebufferSamples >= consts->MaxSamples && 1552bf215546Sopenharmony_ci consts->MaxFramebufferLayers >= consts->MaxArrayTextureLayers))) 1553bf215546Sopenharmony_ci extensions->ARB_framebuffer_no_attachments = GL_TRUE; 1554bf215546Sopenharmony_ci 1555bf215546Sopenharmony_ci /* GL_ARB_ES3_compatibility. 1556bf215546Sopenharmony_ci * Check requirements for GLSL ES 3.00. 1557bf215546Sopenharmony_ci */ 1558bf215546Sopenharmony_ci if (GLSLVersion >= 130 && 1559bf215546Sopenharmony_ci extensions->ARB_uniform_buffer_object && 1560bf215546Sopenharmony_ci (extensions->NV_primitive_restart || 1561bf215546Sopenharmony_ci consts->PrimitiveRestartFixedIndex) && 1562bf215546Sopenharmony_ci screen->get_shader_param(screen, PIPE_SHADER_VERTEX, 1563bf215546Sopenharmony_ci PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS) >= 16 && 1564bf215546Sopenharmony_ci /* Requirements for ETC2 emulation. */ 1565bf215546Sopenharmony_ci screen->is_format_supported(screen, PIPE_FORMAT_R8G8B8A8_UNORM, 1566bf215546Sopenharmony_ci PIPE_TEXTURE_2D, 0, 0, 1567bf215546Sopenharmony_ci PIPE_BIND_SAMPLER_VIEW) && 1568bf215546Sopenharmony_ci screen->is_format_supported(screen, PIPE_FORMAT_R8G8B8A8_SRGB, 1569bf215546Sopenharmony_ci PIPE_TEXTURE_2D, 0, 0, 1570bf215546Sopenharmony_ci PIPE_BIND_SAMPLER_VIEW) && 1571bf215546Sopenharmony_ci screen->is_format_supported(screen, PIPE_FORMAT_R16_UNORM, 1572bf215546Sopenharmony_ci PIPE_TEXTURE_2D, 0, 0, 1573bf215546Sopenharmony_ci PIPE_BIND_SAMPLER_VIEW) && 1574bf215546Sopenharmony_ci screen->is_format_supported(screen, PIPE_FORMAT_R16G16_UNORM, 1575bf215546Sopenharmony_ci PIPE_TEXTURE_2D, 0, 0, 1576bf215546Sopenharmony_ci PIPE_BIND_SAMPLER_VIEW) && 1577bf215546Sopenharmony_ci screen->is_format_supported(screen, PIPE_FORMAT_R16_SNORM, 1578bf215546Sopenharmony_ci PIPE_TEXTURE_2D, 0, 0, 1579bf215546Sopenharmony_ci PIPE_BIND_SAMPLER_VIEW) && 1580bf215546Sopenharmony_ci screen->is_format_supported(screen, PIPE_FORMAT_R16G16_SNORM, 1581bf215546Sopenharmony_ci PIPE_TEXTURE_2D, 0, 0, 1582bf215546Sopenharmony_ci PIPE_BIND_SAMPLER_VIEW)) { 1583bf215546Sopenharmony_ci extensions->ARB_ES3_compatibility = GL_TRUE; 1584bf215546Sopenharmony_ci } 1585bf215546Sopenharmony_ci 1586bf215546Sopenharmony_ci#ifdef HAVE_ST_VDPAU 1587bf215546Sopenharmony_ci if (screen->get_video_param && 1588bf215546Sopenharmony_ci screen->get_video_param(screen, PIPE_VIDEO_PROFILE_UNKNOWN, 1589bf215546Sopenharmony_ci PIPE_VIDEO_ENTRYPOINT_BITSTREAM, 1590bf215546Sopenharmony_ci PIPE_VIDEO_CAP_SUPPORTS_INTERLACED)) { 1591bf215546Sopenharmony_ci extensions->NV_vdpau_interop = GL_TRUE; 1592bf215546Sopenharmony_ci } 1593bf215546Sopenharmony_ci#endif 1594bf215546Sopenharmony_ci 1595bf215546Sopenharmony_ci if (screen->get_param(screen, PIPE_CAP_DOUBLES)) { 1596bf215546Sopenharmony_ci extensions->ARB_gpu_shader_fp64 = GL_TRUE; 1597bf215546Sopenharmony_ci extensions->ARB_vertex_attrib_64bit = GL_TRUE; 1598bf215546Sopenharmony_ci } 1599bf215546Sopenharmony_ci 1600bf215546Sopenharmony_ci if ((ST_DEBUG & DEBUG_GREMEDY) && 1601bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_STRING_MARKER)) 1602bf215546Sopenharmony_ci extensions->GREMEDY_string_marker = GL_TRUE; 1603bf215546Sopenharmony_ci 1604bf215546Sopenharmony_ci if (screen->get_param(screen, PIPE_CAP_COMPUTE)) { 1605bf215546Sopenharmony_ci int compute_supported_irs = 1606bf215546Sopenharmony_ci screen->get_shader_param(screen, PIPE_SHADER_COMPUTE, 1607bf215546Sopenharmony_ci PIPE_SHADER_CAP_SUPPORTED_IRS); 1608bf215546Sopenharmony_ci if (compute_supported_irs & ((1 << PIPE_SHADER_IR_TGSI) | 1609bf215546Sopenharmony_ci (1 << PIPE_SHADER_IR_NIR))) { 1610bf215546Sopenharmony_ci enum pipe_shader_ir ir = 1611bf215546Sopenharmony_ci (compute_supported_irs & PIPE_SHADER_IR_NIR) ? 1612bf215546Sopenharmony_ci PIPE_SHADER_IR_NIR : PIPE_SHADER_IR_TGSI; 1613bf215546Sopenharmony_ci uint64_t grid_size[3], block_size[3]; 1614bf215546Sopenharmony_ci uint64_t max_local_size, max_threads_per_block; 1615bf215546Sopenharmony_ci 1616bf215546Sopenharmony_ci screen->get_compute_param(screen, ir, 1617bf215546Sopenharmony_ci PIPE_COMPUTE_CAP_MAX_GRID_SIZE, grid_size); 1618bf215546Sopenharmony_ci screen->get_compute_param(screen, ir, 1619bf215546Sopenharmony_ci PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE, block_size); 1620bf215546Sopenharmony_ci screen->get_compute_param(screen, ir, 1621bf215546Sopenharmony_ci PIPE_COMPUTE_CAP_MAX_THREADS_PER_BLOCK, 1622bf215546Sopenharmony_ci &max_threads_per_block); 1623bf215546Sopenharmony_ci screen->get_compute_param(screen, ir, 1624bf215546Sopenharmony_ci PIPE_COMPUTE_CAP_MAX_LOCAL_SIZE, 1625bf215546Sopenharmony_ci &max_local_size); 1626bf215546Sopenharmony_ci 1627bf215546Sopenharmony_ci consts->MaxComputeWorkGroupInvocations = max_threads_per_block; 1628bf215546Sopenharmony_ci consts->MaxComputeSharedMemorySize = max_local_size; 1629bf215546Sopenharmony_ci 1630bf215546Sopenharmony_ci for (i = 0; i < 3; i++) { 1631bf215546Sopenharmony_ci /* There are tests that fail if we report more that INT_MAX - 1. */ 1632bf215546Sopenharmony_ci consts->MaxComputeWorkGroupCount[i] = MIN2(grid_size[i], INT_MAX - 1); 1633bf215546Sopenharmony_ci consts->MaxComputeWorkGroupSize[i] = block_size[i]; 1634bf215546Sopenharmony_ci } 1635bf215546Sopenharmony_ci 1636bf215546Sopenharmony_ci extensions->ARB_compute_shader = 1637bf215546Sopenharmony_ci max_threads_per_block >= 1024 && 1638bf215546Sopenharmony_ci extensions->ARB_shader_image_load_store && 1639bf215546Sopenharmony_ci extensions->ARB_shader_atomic_counters; 1640bf215546Sopenharmony_ci 1641bf215546Sopenharmony_ci if (extensions->ARB_compute_shader) { 1642bf215546Sopenharmony_ci uint64_t max_variable_threads_per_block = 0; 1643bf215546Sopenharmony_ci 1644bf215546Sopenharmony_ci screen->get_compute_param(screen, ir, 1645bf215546Sopenharmony_ci PIPE_COMPUTE_CAP_MAX_VARIABLE_THREADS_PER_BLOCK, 1646bf215546Sopenharmony_ci &max_variable_threads_per_block); 1647bf215546Sopenharmony_ci 1648bf215546Sopenharmony_ci for (i = 0; i < 3; i++) { 1649bf215546Sopenharmony_ci /* Clamp the values to avoid having a local work group size 1650bf215546Sopenharmony_ci * greater than the maximum number of invocations. 1651bf215546Sopenharmony_ci */ 1652bf215546Sopenharmony_ci consts->MaxComputeVariableGroupSize[i] = 1653bf215546Sopenharmony_ci MIN2(consts->MaxComputeWorkGroupSize[i], 1654bf215546Sopenharmony_ci max_variable_threads_per_block); 1655bf215546Sopenharmony_ci } 1656bf215546Sopenharmony_ci consts->MaxComputeVariableGroupInvocations = 1657bf215546Sopenharmony_ci max_variable_threads_per_block; 1658bf215546Sopenharmony_ci 1659bf215546Sopenharmony_ci extensions->ARB_compute_variable_group_size = 1660bf215546Sopenharmony_ci max_variable_threads_per_block > 0; 1661bf215546Sopenharmony_ci } 1662bf215546Sopenharmony_ci } 1663bf215546Sopenharmony_ci } 1664bf215546Sopenharmony_ci 1665bf215546Sopenharmony_ci extensions->ARB_texture_float = 1666bf215546Sopenharmony_ci extensions->OES_texture_half_float && 1667bf215546Sopenharmony_ci extensions->OES_texture_float; 1668bf215546Sopenharmony_ci 1669bf215546Sopenharmony_ci if (extensions->EXT_texture_filter_anisotropic && 1670bf215546Sopenharmony_ci screen->get_paramf(screen, PIPE_CAPF_MAX_TEXTURE_ANISOTROPY) >= 16.0) 1671bf215546Sopenharmony_ci extensions->ARB_texture_filter_anisotropic = GL_TRUE; 1672bf215546Sopenharmony_ci 1673bf215546Sopenharmony_ci extensions->KHR_robustness = extensions->ARB_robust_buffer_access_behavior; 1674bf215546Sopenharmony_ci 1675bf215546Sopenharmony_ci /* If we support ES 3.1, we support the ES3_1_compatibility ext. However 1676bf215546Sopenharmony_ci * there's no clean way of telling whether we would support ES 3.1 from 1677bf215546Sopenharmony_ci * here, so copy the condition from compute_version_es2 here. A lot of 1678bf215546Sopenharmony_ci * these are redunant, but simpler to just have a (near-)exact copy here. 1679bf215546Sopenharmony_ci */ 1680bf215546Sopenharmony_ci extensions->ARB_ES3_1_compatibility = 1681bf215546Sopenharmony_ci consts->Program[MESA_SHADER_FRAGMENT].MaxImageUniforms && 1682bf215546Sopenharmony_ci extensions->ARB_ES3_compatibility && 1683bf215546Sopenharmony_ci extensions->ARB_arrays_of_arrays && 1684bf215546Sopenharmony_ci extensions->ARB_compute_shader && 1685bf215546Sopenharmony_ci extensions->ARB_draw_indirect && 1686bf215546Sopenharmony_ci extensions->ARB_explicit_uniform_location && 1687bf215546Sopenharmony_ci extensions->ARB_framebuffer_no_attachments && 1688bf215546Sopenharmony_ci extensions->ARB_shader_atomic_counters && 1689bf215546Sopenharmony_ci extensions->ARB_shader_image_load_store && 1690bf215546Sopenharmony_ci extensions->ARB_shader_image_size && 1691bf215546Sopenharmony_ci extensions->ARB_shader_storage_buffer_object && 1692bf215546Sopenharmony_ci extensions->ARB_shading_language_packing && 1693bf215546Sopenharmony_ci extensions->ARB_stencil_texturing && 1694bf215546Sopenharmony_ci extensions->ARB_texture_multisample && 1695bf215546Sopenharmony_ci extensions->ARB_gpu_shader5 && 1696bf215546Sopenharmony_ci extensions->EXT_shader_integer_mix; 1697bf215546Sopenharmony_ci 1698bf215546Sopenharmony_ci extensions->OES_texture_cube_map_array = 1699bf215546Sopenharmony_ci (extensions->ARB_ES3_1_compatibility || ESSLVersion >= 310) && 1700bf215546Sopenharmony_ci extensions->OES_geometry_shader && 1701bf215546Sopenharmony_ci extensions->ARB_texture_cube_map_array; 1702bf215546Sopenharmony_ci 1703bf215546Sopenharmony_ci extensions->OES_viewport_array = 1704bf215546Sopenharmony_ci (extensions->ARB_ES3_1_compatibility || ESSLVersion >= 310) && 1705bf215546Sopenharmony_ci extensions->OES_geometry_shader && 1706bf215546Sopenharmony_ci extensions->ARB_viewport_array; 1707bf215546Sopenharmony_ci 1708bf215546Sopenharmony_ci extensions->OES_primitive_bounding_box = 1709bf215546Sopenharmony_ci extensions->ARB_ES3_1_compatibility || ESSLVersion >= 310; 1710bf215546Sopenharmony_ci 1711bf215546Sopenharmony_ci consts->NoPrimitiveBoundingBoxOutput = true; 1712bf215546Sopenharmony_ci 1713bf215546Sopenharmony_ci extensions->ANDROID_extension_pack_es31a = 1714bf215546Sopenharmony_ci consts->Program[MESA_SHADER_FRAGMENT].MaxImageUniforms && 1715bf215546Sopenharmony_ci extensions->KHR_texture_compression_astc_ldr && 1716bf215546Sopenharmony_ci extensions->KHR_blend_equation_advanced && 1717bf215546Sopenharmony_ci extensions->OES_sample_variables && 1718bf215546Sopenharmony_ci extensions->ARB_texture_stencil8 && 1719bf215546Sopenharmony_ci extensions->ARB_texture_multisample && 1720bf215546Sopenharmony_ci extensions->OES_copy_image && 1721bf215546Sopenharmony_ci extensions->ARB_draw_buffers_blend && 1722bf215546Sopenharmony_ci extensions->OES_geometry_shader && 1723bf215546Sopenharmony_ci extensions->ARB_gpu_shader5 && 1724bf215546Sopenharmony_ci extensions->OES_primitive_bounding_box && 1725bf215546Sopenharmony_ci extensions->ARB_tessellation_shader && 1726bf215546Sopenharmony_ci extensions->OES_texture_buffer && 1727bf215546Sopenharmony_ci extensions->OES_texture_cube_map_array && 1728bf215546Sopenharmony_ci extensions->EXT_texture_sRGB_decode; 1729bf215546Sopenharmony_ci 1730bf215546Sopenharmony_ci /* Same deal as for ARB_ES3_1_compatibility - this has to be computed 1731bf215546Sopenharmony_ci * before overall versions are selected. Also it's actually a subset of ES 1732bf215546Sopenharmony_ci * 3.2, since it doesn't require ASTC or advanced blending. 1733bf215546Sopenharmony_ci */ 1734bf215546Sopenharmony_ci extensions->ARB_ES3_2_compatibility = 1735bf215546Sopenharmony_ci extensions->ARB_ES3_1_compatibility && 1736bf215546Sopenharmony_ci extensions->KHR_robustness && 1737bf215546Sopenharmony_ci extensions->ARB_copy_image && 1738bf215546Sopenharmony_ci extensions->ARB_draw_buffers_blend && 1739bf215546Sopenharmony_ci extensions->ARB_draw_elements_base_vertex && 1740bf215546Sopenharmony_ci extensions->OES_geometry_shader && 1741bf215546Sopenharmony_ci extensions->ARB_gpu_shader5 && 1742bf215546Sopenharmony_ci extensions->ARB_sample_shading && 1743bf215546Sopenharmony_ci extensions->ARB_tessellation_shader && 1744bf215546Sopenharmony_ci extensions->OES_texture_buffer && 1745bf215546Sopenharmony_ci extensions->ARB_texture_cube_map_array && 1746bf215546Sopenharmony_ci extensions->ARB_texture_stencil8 && 1747bf215546Sopenharmony_ci extensions->ARB_texture_multisample; 1748bf215546Sopenharmony_ci 1749bf215546Sopenharmony_ci if (screen->get_param(screen, PIPE_CAP_CONSERVATIVE_RASTER_POST_SNAP_TRIANGLES) && 1750bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_CONSERVATIVE_RASTER_POST_SNAP_POINTS_LINES) && 1751bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_CONSERVATIVE_RASTER_POST_DEPTH_COVERAGE)) { 1752bf215546Sopenharmony_ci float max_dilate; 1753bf215546Sopenharmony_ci bool pre_snap_triangles, pre_snap_points_lines; 1754bf215546Sopenharmony_ci 1755bf215546Sopenharmony_ci max_dilate = screen->get_paramf(screen, PIPE_CAPF_MAX_CONSERVATIVE_RASTER_DILATE); 1756bf215546Sopenharmony_ci 1757bf215546Sopenharmony_ci pre_snap_triangles = 1758bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_CONSERVATIVE_RASTER_PRE_SNAP_TRIANGLES); 1759bf215546Sopenharmony_ci pre_snap_points_lines = 1760bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_CONSERVATIVE_RASTER_PRE_SNAP_POINTS_LINES); 1761bf215546Sopenharmony_ci 1762bf215546Sopenharmony_ci extensions->NV_conservative_raster = 1763bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_MAX_CONSERVATIVE_RASTER_SUBPIXEL_PRECISION_BIAS) > 1; 1764bf215546Sopenharmony_ci 1765bf215546Sopenharmony_ci if (extensions->NV_conservative_raster) { 1766bf215546Sopenharmony_ci extensions->NV_conservative_raster_dilate = max_dilate >= 0.75; 1767bf215546Sopenharmony_ci extensions->NV_conservative_raster_pre_snap_triangles = pre_snap_triangles; 1768bf215546Sopenharmony_ci extensions->NV_conservative_raster_pre_snap = 1769bf215546Sopenharmony_ci pre_snap_triangles && pre_snap_points_lines; 1770bf215546Sopenharmony_ci } 1771bf215546Sopenharmony_ci } 1772bf215546Sopenharmony_ci 1773bf215546Sopenharmony_ci if (extensions->ARB_gl_spirv) { 1774bf215546Sopenharmony_ci struct spirv_supported_capabilities *spirv_caps = &consts->SpirVCapabilities; 1775bf215546Sopenharmony_ci 1776bf215546Sopenharmony_ci spirv_caps->atomic_storage = extensions->ARB_shader_atomic_counters; 1777bf215546Sopenharmony_ci spirv_caps->demote_to_helper_invocation = extensions->EXT_demote_to_helper_invocation; 1778bf215546Sopenharmony_ci spirv_caps->draw_parameters = extensions->ARB_shader_draw_parameters; 1779bf215546Sopenharmony_ci spirv_caps->derivative_group = extensions->NV_compute_shader_derivatives; 1780bf215546Sopenharmony_ci spirv_caps->float64 = extensions->ARB_gpu_shader_fp64; 1781bf215546Sopenharmony_ci spirv_caps->geometry_streams = extensions->ARB_gpu_shader5; 1782bf215546Sopenharmony_ci spirv_caps->image_ms_array = extensions->ARB_shader_image_load_store && 1783bf215546Sopenharmony_ci consts->MaxImageSamples > 1; 1784bf215546Sopenharmony_ci spirv_caps->image_read_without_format = extensions->EXT_shader_image_load_formatted; 1785bf215546Sopenharmony_ci spirv_caps->image_write_without_format = extensions->ARB_shader_image_load_store; 1786bf215546Sopenharmony_ci spirv_caps->int64 = extensions->ARB_gpu_shader_int64; 1787bf215546Sopenharmony_ci spirv_caps->int64_atomics = extensions->NV_shader_atomic_int64; 1788bf215546Sopenharmony_ci spirv_caps->post_depth_coverage = extensions->ARB_post_depth_coverage; 1789bf215546Sopenharmony_ci spirv_caps->shader_clock = extensions->ARB_shader_clock; 1790bf215546Sopenharmony_ci spirv_caps->shader_viewport_index_layer = extensions->ARB_shader_viewport_layer_array; 1791bf215546Sopenharmony_ci spirv_caps->stencil_export = extensions->ARB_shader_stencil_export; 1792bf215546Sopenharmony_ci spirv_caps->storage_image_ms = extensions->ARB_shader_image_load_store && 1793bf215546Sopenharmony_ci consts->MaxImageSamples > 1; 1794bf215546Sopenharmony_ci spirv_caps->subgroup_ballot = extensions->ARB_shader_ballot; 1795bf215546Sopenharmony_ci spirv_caps->subgroup_vote = extensions->ARB_shader_group_vote; 1796bf215546Sopenharmony_ci spirv_caps->tessellation = extensions->ARB_tessellation_shader; 1797bf215546Sopenharmony_ci spirv_caps->transform_feedback = extensions->ARB_transform_feedback3; 1798bf215546Sopenharmony_ci spirv_caps->variable_pointers = 1799bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_GL_SPIRV_VARIABLE_POINTERS); 1800bf215546Sopenharmony_ci spirv_caps->integer_functions2 = extensions->INTEL_shader_integer_functions2; 1801bf215546Sopenharmony_ci 1802bf215546Sopenharmony_ci consts->SpirVExtensions = CALLOC_STRUCT(spirv_supported_extensions); 1803bf215546Sopenharmony_ci _mesa_fill_supported_spirv_extensions(consts->SpirVExtensions, spirv_caps); 1804bf215546Sopenharmony_ci } 1805bf215546Sopenharmony_ci 1806bf215546Sopenharmony_ci consts->AllowDrawOutOfOrder = 1807bf215546Sopenharmony_ci api == API_OPENGL_COMPAT && 1808bf215546Sopenharmony_ci options->allow_draw_out_of_order && 1809bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_ALLOW_DRAW_OUT_OF_ORDER); 1810bf215546Sopenharmony_ci consts->GLThreadNopCheckFramebufferStatus = options->glthread_nop_check_framebuffer_status; 1811bf215546Sopenharmony_ci 1812bf215546Sopenharmony_ci bool prefer_nir = PIPE_SHADER_IR_NIR == 1813bf215546Sopenharmony_ci screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT, PIPE_SHADER_CAP_PREFERRED_IR); 1814bf215546Sopenharmony_ci const struct nir_shader_compiler_options *nir_options = 1815bf215546Sopenharmony_ci consts->ShaderCompilerOptions[MESA_SHADER_FRAGMENT].NirOptions; 1816bf215546Sopenharmony_ci 1817bf215546Sopenharmony_ci if (prefer_nir && 1818bf215546Sopenharmony_ci screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT, PIPE_SHADER_CAP_INTEGERS) && 1819bf215546Sopenharmony_ci extensions->ARB_stencil_texturing && 1820bf215546Sopenharmony_ci screen->get_param(screen, PIPE_CAP_DOUBLES) && 1821bf215546Sopenharmony_ci !(nir_options->lower_doubles_options & nir_lower_fp64_full_software)) 1822bf215546Sopenharmony_ci extensions->NV_copy_depth_to_color = TRUE; 1823bf215546Sopenharmony_ci 1824bf215546Sopenharmony_ci if (prefer_nir) 1825bf215546Sopenharmony_ci extensions->ARB_point_sprite = GL_TRUE; 1826bf215546Sopenharmony_ci} 1827