1 /**************************************************************************
3 * Copyright 2007 VMware, Inc.
4 * Copyright (c) 2008 VMware, Inc.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sub license, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial portions
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
22 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
23 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 **************************************************************************/
29 #include "compiler/nir/nir.h"
31 #include "main/imports.h"
32 #include "main/context.h"
33 #include "main/macros.h"
34 #include "main/version.h"
36 #include "pipe/p_context.h"
37 #include "pipe/p_defines.h"
38 #include "pipe/p_screen.h"
39 #include "tgsi/tgsi_from_mesa.h"
40 #include "util/u_math.h"
42 #include "st_context.h"
44 #include "st_extensions.h"
45 #include "st_format.h"
49 * Note: we use these function rather than the MIN2, MAX2, CLAMP macros to
50 * avoid evaluating arguments (which are often function calls) more than once.
53 static unsigned _min(unsigned a, unsigned b)
55 return (a < b) ? a : b;
58 static float _maxf(float a, float b)
60 return (a > b) ? a : b;
63 static int _clamp(int a, int min, int max)
75 * Query driver to get implementation limits.
76 * Note that we have to limit/clamp against Mesa's internal limits too.
78 void st_init_limits(struct pipe_screen *screen,
79 struct gl_constants *c, struct gl_extensions *extensions,
84 boolean can_ubo = TRUE;
86 bool ssbo_atomic = true;
89 = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS),
93 = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_3D_LEVELS),
94 MAX_3D_TEXTURE_LEVELS);
96 c->MaxCubeTextureLevels
97 = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS),
98 MAX_CUBE_TEXTURE_LEVELS);
100 c->MaxTextureRectSize
101 = _min(1 << (c->MaxTextureLevels - 1), MAX_TEXTURE_RECT_SIZE);
103 c->MaxArrayTextureLayers
104 = screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS);
106 /* Define max viewport size and max renderbuffer size in terms of
107 * max texture size (note: max tex RECT size = max tex 2D size).
108 * If this isn't true for some hardware we'll need new PIPE_CAP_ queries.
110 c->MaxViewportWidth =
111 c->MaxViewportHeight =
112 c->MaxRenderbufferSize = c->MaxTextureRectSize;
115 c->ViewportSubpixelBits =
116 screen->get_param(screen, PIPE_CAP_VIEWPORT_SUBPIXEL_BITS);
118 c->MaxDrawBuffers = c->MaxColorAttachments =
119 _clamp(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS),
120 1, MAX_DRAW_BUFFERS);
122 c->MaxDualSourceDrawBuffers =
123 _clamp(screen->get_param(screen,
124 PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS),
125 0, MAX_DRAW_BUFFERS);
128 _maxf(1.0f, screen->get_paramf(screen, PIPE_CAPF_MAX_LINE_WIDTH));
130 _maxf(1.0f, screen->get_paramf(screen, PIPE_CAPF_MAX_LINE_WIDTH_AA));
133 _maxf(1.0f, screen->get_paramf(screen, PIPE_CAPF_MAX_POINT_WIDTH));
135 _maxf(1.0f, screen->get_paramf(screen, PIPE_CAPF_MAX_POINT_WIDTH_AA));
137 /* these are not queryable. Note that GL basically mandates a 1.0 minimum
138 * for non-aa sizes, but we can go down to 0.0 for aa points.
140 c->MinPointSize = 1.0f;
141 c->MinPointSizeAA = 0.0f;
143 c->MaxTextureMaxAnisotropy =
145 screen->get_paramf(screen, PIPE_CAPF_MAX_TEXTURE_ANISOTROPY));
147 c->MaxTextureLodBias =
148 screen->get_paramf(screen, PIPE_CAPF_MAX_TEXTURE_LOD_BIAS);
150 c->QuadsFollowProvokingVertexConvention =
151 screen->get_param(screen,
152 PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION);
154 c->MaxUniformBlockSize =
155 screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT,
156 PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE);
157 /* GL45-CTS.enhanced_layouts.ssb_member_invalid_offset_alignment fails if
158 * this is larger than INT_MAX - 100. Use a nicely aligned limit.
160 c->MaxUniformBlockSize = MIN2(c->MaxUniformBlockSize, INT_MAX - 127);
162 if (c->MaxUniformBlockSize < 16384) {
166 for (sh = 0; sh < PIPE_SHADER_TYPES; ++sh) {
167 struct gl_shader_compiler_options *options;
168 struct gl_program_constants *pc;
169 const nir_shader_compiler_options *nir_options = NULL;
171 if (screen->get_compiler_options) {
172 nir_options = (const nir_shader_compiler_options *)
173 screen->get_compiler_options(screen, PIPE_SHADER_IR_NIR, sh);
176 const gl_shader_stage stage = tgsi_processor_to_shader_stage(sh);
177 pc = &c->Program[stage];
178 options = &c->ShaderCompilerOptions[stage];
179 c->ShaderCompilerOptions[stage].NirOptions = nir_options;
181 if (sh == PIPE_SHADER_COMPUTE) {
182 if (!screen->get_param(screen, PIPE_CAP_COMPUTE))
185 screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_SUPPORTED_IRS);
186 if (!(supported_irs & (1 << PIPE_SHADER_IR_TGSI)))
190 pc->MaxTextureImageUnits =
191 _min(screen->get_shader_param(screen, sh,
192 PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS),
193 MAX_TEXTURE_IMAGE_UNITS);
195 pc->MaxInstructions =
196 pc->MaxNativeInstructions =
197 screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INSTRUCTIONS);
198 pc->MaxAluInstructions =
199 pc->MaxNativeAluInstructions =
200 screen->get_shader_param(screen, sh,
201 PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS);
202 pc->MaxTexInstructions =
203 pc->MaxNativeTexInstructions =
204 screen->get_shader_param(screen, sh,
205 PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS);
206 pc->MaxTexIndirections =
207 pc->MaxNativeTexIndirections =
208 screen->get_shader_param(screen, sh,
209 PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS);
211 pc->MaxNativeAttribs =
212 screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INPUTS);
215 screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_TEMPS);
217 pc->MaxNativeAddressRegs = sh == PIPE_SHADER_VERTEX ? 1 : 0;
219 pc->MaxUniformComponents =
220 screen->get_shader_param(screen, sh,
221 PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE) / 4;
222 pc->MaxUniformComponents = MIN2(pc->MaxUniformComponents,
226 pc->MaxNativeParameters = pc->MaxUniformComponents / 4;
227 pc->MaxInputComponents =
228 screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INPUTS) * 4;
229 pc->MaxOutputComponents =
230 screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_OUTPUTS) * 4;
233 pc->MaxUniformBlocks =
234 screen->get_shader_param(screen, sh,
235 PIPE_SHADER_CAP_MAX_CONST_BUFFERS);
236 if (pc->MaxUniformBlocks)
237 pc->MaxUniformBlocks -= 1; /* The first one is for ordinary uniforms. */
238 pc->MaxUniformBlocks = _min(pc->MaxUniformBlocks, MAX_UNIFORM_BUFFERS);
240 pc->MaxCombinedUniformComponents =
241 pc->MaxUniformComponents +
242 (uint64_t)c->MaxUniformBlockSize / 4 * pc->MaxUniformBlocks;
244 temp = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTERS);
247 * for separate atomic counters get the actual hw limits
248 * per stage on atomic counters and buffers
251 pc->MaxAtomicCounters = temp;
252 pc->MaxAtomicBuffers = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTER_BUFFERS);
253 pc->MaxShaderStorageBlocks = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_SHADER_BUFFERS);
255 pc->MaxAtomicCounters = MAX_ATOMIC_COUNTERS;
256 pc->MaxAtomicBuffers = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_SHADER_BUFFERS) / 2;
257 pc->MaxShaderStorageBlocks = pc->MaxAtomicBuffers;
259 pc->MaxImageUniforms = screen->get_shader_param(
260 screen, sh, PIPE_SHADER_CAP_MAX_SHADER_IMAGES);
262 /* Gallium doesn't really care about local vs. env parameters so use the
265 pc->MaxLocalParams = MIN2(pc->MaxParameters, MAX_PROGRAM_LOCAL_PARAMS);
266 pc->MaxEnvParams = MIN2(pc->MaxParameters, MAX_PROGRAM_ENV_PARAMS);
268 if (screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_INTEGERS)) {
269 pc->LowInt.RangeMin = 31;
270 pc->LowInt.RangeMax = 30;
271 pc->LowInt.Precision = 0;
272 pc->MediumInt = pc->HighInt = pc->LowInt;
275 /* TODO: make these more fine-grained if anyone needs it */
276 options->MaxIfDepth =
277 screen->get_shader_param(screen, sh,
278 PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH);
279 options->EmitNoLoops =
280 !screen->get_shader_param(screen, sh,
281 PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH);
282 options->EmitNoMainReturn =
283 !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_SUBROUTINES);
285 options->EmitNoCont =
286 !screen->get_shader_param(screen, sh,
287 PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED);
289 options->EmitNoIndirectInput =
290 !screen->get_shader_param(screen, sh,
291 PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR);
292 options->EmitNoIndirectOutput =
293 !screen->get_shader_param(screen, sh,
294 PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR);
295 options->EmitNoIndirectTemp =
296 !screen->get_shader_param(screen, sh,
297 PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR);
298 options->EmitNoIndirectUniform =
299 !screen->get_shader_param(screen, sh,
300 PIPE_SHADER_CAP_INDIRECT_CONST_ADDR);
302 if (pc->MaxNativeInstructions &&
303 (options->EmitNoIndirectUniform || pc->MaxUniformBlocks < 12)) {
307 if (options->EmitNoLoops)
308 options->MaxUnrollIterations =
309 MIN2(screen->get_shader_param(screen, sh,
310 PIPE_SHADER_CAP_MAX_INSTRUCTIONS),
313 options->MaxUnrollIterations =
314 screen->get_shader_param(screen, sh,
315 PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS_HINT);
317 options->LowerCombinedClipCullDistance = true;
318 options->LowerBufferInterfaceBlocks = true;
321 c->MaxUserAssignableUniformLocations =
322 c->Program[MESA_SHADER_VERTEX].MaxUniformComponents +
323 c->Program[MESA_SHADER_TESS_CTRL].MaxUniformComponents +
324 c->Program[MESA_SHADER_TESS_EVAL].MaxUniformComponents +
325 c->Program[MESA_SHADER_GEOMETRY].MaxUniformComponents +
326 c->Program[MESA_SHADER_FRAGMENT].MaxUniformComponents;
328 c->GLSLOptimizeConservatively =
329 screen->get_param(screen, PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY);
330 c->LowerTessLevel = true;
331 c->LowerCsDerivedVariables = true;
332 c->PrimitiveRestartForPatches =
333 screen->get_param(screen, PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES);
335 c->MaxCombinedTextureImageUnits =
336 _min(c->Program[MESA_SHADER_VERTEX].MaxTextureImageUnits +
337 c->Program[MESA_SHADER_TESS_CTRL].MaxTextureImageUnits +
338 c->Program[MESA_SHADER_TESS_EVAL].MaxTextureImageUnits +
339 c->Program[MESA_SHADER_GEOMETRY].MaxTextureImageUnits +
340 c->Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits,
341 MAX_COMBINED_TEXTURE_IMAGE_UNITS);
343 /* This depends on program constants. */
344 c->MaxTextureCoordUnits
345 = _min(c->Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits,
346 MAX_TEXTURE_COORD_UNITS);
349 _min(c->Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits,
350 c->MaxTextureCoordUnits);
352 c->Program[MESA_SHADER_VERTEX].MaxAttribs =
353 MIN2(c->Program[MESA_SHADER_VERTEX].MaxAttribs, 16);
355 /* PIPE_SHADER_CAP_MAX_INPUTS for the FS specifies the maximum number
356 * of inputs. It's always 2 colors + N generic inputs. */
357 c->MaxVarying = screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT,
358 PIPE_SHADER_CAP_MAX_INPUTS);
359 c->MaxVarying = MIN2(c->MaxVarying, MAX_VARYING);
360 c->MaxGeometryOutputVertices =
361 screen->get_param(screen, PIPE_CAP_MAX_GEOMETRY_OUTPUT_VERTICES);
362 c->MaxGeometryTotalOutputComponents =
363 screen->get_param(screen, PIPE_CAP_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS);
364 c->MaxGeometryShaderInvocations =
365 screen->get_param(screen, PIPE_CAP_MAX_GS_INVOCATIONS);
366 c->MaxTessPatchComponents =
367 MIN2(screen->get_param(screen, PIPE_CAP_MAX_SHADER_PATCH_VARYINGS),
370 c->MinProgramTexelOffset =
371 screen->get_param(screen, PIPE_CAP_MIN_TEXEL_OFFSET);
372 c->MaxProgramTexelOffset =
373 screen->get_param(screen, PIPE_CAP_MAX_TEXEL_OFFSET);
375 c->MaxProgramTextureGatherComponents =
376 screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS);
377 c->MinProgramTextureGatherOffset =
378 screen->get_param(screen, PIPE_CAP_MIN_TEXTURE_GATHER_OFFSET);
379 c->MaxProgramTextureGatherOffset =
380 screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_GATHER_OFFSET);
382 c->MaxTransformFeedbackBuffers =
383 screen->get_param(screen, PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS);
384 c->MaxTransformFeedbackBuffers = MIN2(c->MaxTransformFeedbackBuffers,
385 MAX_FEEDBACK_BUFFERS);
386 c->MaxTransformFeedbackSeparateComponents =
387 screen->get_param(screen, PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS);
388 c->MaxTransformFeedbackInterleavedComponents =
389 screen->get_param(screen,
390 PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS);
391 c->MaxVertexStreams =
392 MAX2(1, screen->get_param(screen, PIPE_CAP_MAX_VERTEX_STREAMS));
394 /* The vertex stream must fit into pipe_stream_output_info::stream */
395 assert(c->MaxVertexStreams <= 4);
397 c->MaxVertexAttribStride
398 = screen->get_param(screen, PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE);
400 c->StripTextureBorder = GL_TRUE;
402 c->GLSLSkipStrictMaxUniformLimitCheck =
403 screen->get_param(screen, PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS);
405 c->UniformBufferOffsetAlignment =
406 screen->get_param(screen, PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT);
409 extensions->ARB_uniform_buffer_object = GL_TRUE;
410 c->MaxCombinedUniformBlocks = c->MaxUniformBufferBindings =
411 c->Program[MESA_SHADER_VERTEX].MaxUniformBlocks +
412 c->Program[MESA_SHADER_TESS_CTRL].MaxUniformBlocks +
413 c->Program[MESA_SHADER_TESS_EVAL].MaxUniformBlocks +
414 c->Program[MESA_SHADER_GEOMETRY].MaxUniformBlocks +
415 c->Program[MESA_SHADER_FRAGMENT].MaxUniformBlocks,
416 assert(c->MaxCombinedUniformBlocks <= MAX_COMBINED_UNIFORM_BUFFERS);
419 c->GLSLFragCoordIsSysVal =
420 screen->get_param(screen, PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL);
421 c->GLSLFrontFacingIsSysVal =
422 screen->get_param(screen, PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL);
424 /* GL_ARB_get_program_binary
426 * The QT framework has a bug in their shader program cache, which is built
427 * on GL_ARB_get_program_binary. In an effort to allow them to fix the bug
428 * we don't enable more than 1 binary format for compatibility profiles.
430 if (api != API_OPENGL_COMPAT &&
431 screen->get_disk_shader_cache && screen->get_disk_shader_cache(screen))
432 c->NumProgramBinaryFormats = 1;
434 c->MaxAtomicBufferBindings =
435 c->Program[MESA_SHADER_FRAGMENT].MaxAtomicBuffers;
438 /* for separate atomic buffers - there atomic buffer size will be
440 c->MaxAtomicBufferSize = c->Program[MESA_SHADER_FRAGMENT].MaxAtomicCounters * ATOMIC_COUNTER_SIZE;
441 /* on all HW with separate atomic (evergreen) the following
442 lines are true. not sure it's worth adding CAPs for this at this
444 c->MaxCombinedAtomicCounters = c->Program[MESA_SHADER_FRAGMENT].MaxAtomicCounters;
445 c->MaxCombinedAtomicBuffers = c->Program[MESA_SHADER_FRAGMENT].MaxAtomicBuffers;
447 c->MaxCombinedAtomicBuffers =
448 c->Program[MESA_SHADER_VERTEX].MaxAtomicBuffers +
449 c->Program[MESA_SHADER_TESS_CTRL].MaxAtomicBuffers +
450 c->Program[MESA_SHADER_TESS_EVAL].MaxAtomicBuffers +
451 c->Program[MESA_SHADER_GEOMETRY].MaxAtomicBuffers +
452 c->Program[MESA_SHADER_FRAGMENT].MaxAtomicBuffers;
453 assert(c->MaxCombinedAtomicBuffers <= MAX_COMBINED_ATOMIC_BUFFERS);
456 if (c->MaxCombinedAtomicBuffers > 0) {
457 extensions->ARB_shader_atomic_counters = GL_TRUE;
458 extensions->ARB_shader_atomic_counter_ops = GL_TRUE;
461 c->MaxCombinedShaderOutputResources = c->MaxDrawBuffers;
462 c->ShaderStorageBufferOffsetAlignment =
463 screen->get_param(screen, PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT);
464 if (c->ShaderStorageBufferOffsetAlignment) {
465 /* for hw atomic counters leaves these at default for now */
467 c->MaxCombinedShaderStorageBlocks = c->MaxShaderStorageBufferBindings =
468 c->MaxCombinedAtomicBuffers;
469 c->MaxCombinedShaderOutputResources +=
470 c->MaxCombinedShaderStorageBlocks;
471 c->MaxShaderStorageBlockSize = 1 << 27;
472 extensions->ARB_shader_storage_buffer_object = GL_TRUE;
475 c->MaxCombinedImageUniforms =
476 c->Program[MESA_SHADER_VERTEX].MaxImageUniforms +
477 c->Program[MESA_SHADER_TESS_CTRL].MaxImageUniforms +
478 c->Program[MESA_SHADER_TESS_EVAL].MaxImageUniforms +
479 c->Program[MESA_SHADER_GEOMETRY].MaxImageUniforms +
480 c->Program[MESA_SHADER_FRAGMENT].MaxImageUniforms;
481 c->MaxCombinedShaderOutputResources += c->MaxCombinedImageUniforms;
482 c->MaxImageUnits = MAX_IMAGE_UNITS;
483 if (c->MaxCombinedImageUniforms) {
484 extensions->ARB_shader_image_load_store = GL_TRUE;
485 extensions->ARB_shader_image_size = GL_TRUE;
488 /* ARB_framebuffer_no_attachments */
489 c->MaxFramebufferWidth = c->MaxViewportWidth;
490 c->MaxFramebufferHeight = c->MaxViewportHeight;
491 /* NOTE: we cheat here a little by assuming that
492 * PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS has the same
493 * number of layers as we need, although we technically
494 * could have more the generality is not really useful
497 c->MaxFramebufferLayers =
498 screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS);
500 c->MaxWindowRectangles =
501 screen->get_param(screen, PIPE_CAP_MAX_WINDOW_RECTANGLES);
503 c->SparseBufferPageSize =
504 screen->get_param(screen, PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE);
506 c->AllowMappedBuffersDuringExecution =
507 screen->get_param(screen, PIPE_CAP_ALLOW_MAPPED_BUFFERS_DURING_EXECUTION);
509 c->UseSTD430AsDefaultPacking =
510 screen->get_param(screen, PIPE_CAP_LOAD_CONSTBUF);
512 c->MaxSubpixelPrecisionBiasBits =
513 screen->get_param(screen, PIPE_CAP_MAX_CONSERVATIVE_RASTER_SUBPIXEL_PRECISION_BIAS);
515 c->ConservativeRasterDilateRange[0] =
516 screen->get_paramf(screen, PIPE_CAPF_MIN_CONSERVATIVE_RASTER_DILATE);
517 c->ConservativeRasterDilateRange[1] =
518 screen->get_paramf(screen, PIPE_CAPF_MAX_CONSERVATIVE_RASTER_DILATE);
519 c->ConservativeRasterDilateGranularity =
520 screen->get_paramf(screen, PIPE_CAPF_CONSERVATIVE_RASTER_DILATE_GRANULARITY);
522 /* limit the max combined shader output resources to a driver limit */
523 temp = screen->get_param(screen, PIPE_CAP_MAX_COMBINED_SHADER_OUTPUT_RESOURCES);
524 if (temp > 0 && c->MaxCombinedShaderOutputResources > temp)
525 c->MaxCombinedShaderOutputResources = temp;
530 * Given a member \c x of struct gl_extensions, return offset of
533 #define o(x) offsetof(struct gl_extensions, x)
536 struct st_extension_cap_mapping {
537 int extension_offset;
541 struct st_extension_format_mapping {
542 int extension_offset[2];
543 enum pipe_format format[32];
545 /* If TRUE, at least one format must be supported for the extensions to be
546 * advertised. If FALSE, all the formats must be supported. */
547 GLboolean need_at_least_one;
551 * Enable extensions if certain pipe formats are supported by the driver.
552 * What extensions will be enabled and what formats must be supported is
553 * described by the array of st_extension_format_mapping.
555 * target and bind_flags are passed to is_format_supported.
558 init_format_extensions(struct pipe_screen *screen,
559 struct gl_extensions *extensions,
560 const struct st_extension_format_mapping *mapping,
561 unsigned num_mappings,
562 enum pipe_texture_target target,
565 GLboolean *extension_table = (GLboolean *) extensions;
568 int num_formats = ARRAY_SIZE(mapping->format);
569 int num_ext = ARRAY_SIZE(mapping->extension_offset);
571 for (i = 0; i < num_mappings; i++) {
572 int num_supported = 0;
574 /* Examine each format in the list. */
575 for (j = 0; j < num_formats && mapping[i].format[j]; j++) {
576 if (screen->is_format_supported(screen, mapping[i].format[j],
577 target, 0, 0, bind_flags)) {
582 if (!num_supported ||
583 (!mapping[i].need_at_least_one && num_supported != j)) {
587 /* Enable all extensions in the list. */
588 for (j = 0; j < num_ext && mapping[i].extension_offset[j]; j++)
589 extension_table[mapping[i].extension_offset[j]] = GL_TRUE;
595 * Given a list of formats and bind flags, return the maximum number
596 * of samples supported by any of those formats.
599 get_max_samples_for_formats(struct pipe_screen *screen,
600 unsigned num_formats,
601 const enum pipe_format *formats,
602 unsigned max_samples,
607 for (i = max_samples; i > 0; --i) {
608 for (f = 0; f < num_formats; f++) {
609 if (screen->is_format_supported(screen, formats[f],
610 PIPE_TEXTURE_2D, i, i, bind)) {
619 get_max_samples_for_formats_advanced(struct pipe_screen *screen,
620 unsigned num_formats,
621 const enum pipe_format *formats,
622 unsigned max_samples,
623 unsigned num_storage_samples,
628 for (i = max_samples; i > 0; --i) {
629 for (f = 0; f < num_formats; f++) {
630 if (screen->is_format_supported(screen, formats[f], PIPE_TEXTURE_2D,
631 i, num_storage_samples, bind)) {
640 * Use pipe_screen::get_param() to query PIPE_CAP_ values to determine
641 * which GL extensions are supported.
642 * Quite a few extensions are always supported because they are standard
643 * features or can be built on top of other gallium features.
644 * Some fine tuning may still be needed.
646 void st_init_extensions(struct pipe_screen *screen,
647 struct gl_constants *consts,
648 struct gl_extensions *extensions,
649 struct st_config_options *options,
653 GLboolean *extension_table = (GLboolean *) extensions;
655 static const struct st_extension_cap_mapping cap_mapping[] = {
656 { o(ARB_base_instance), PIPE_CAP_START_INSTANCE },
657 { o(ARB_bindless_texture), PIPE_CAP_BINDLESS_TEXTURE },
658 { o(ARB_buffer_storage), PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT },
659 { o(ARB_clear_texture), PIPE_CAP_CLEAR_TEXTURE },
660 { o(ARB_clip_control), PIPE_CAP_CLIP_HALFZ },
661 { o(ARB_color_buffer_float), PIPE_CAP_VERTEX_COLOR_UNCLAMPED },
662 { o(ARB_conditional_render_inverted), PIPE_CAP_CONDITIONAL_RENDER_INVERTED },
663 { o(ARB_copy_image), PIPE_CAP_COPY_BETWEEN_COMPRESSED_AND_PLAIN_FORMATS },
664 { o(OES_copy_image), PIPE_CAP_COPY_BETWEEN_COMPRESSED_AND_PLAIN_FORMATS },
665 { o(ARB_cull_distance), PIPE_CAP_CULL_DISTANCE },
666 { o(ARB_depth_clamp), PIPE_CAP_DEPTH_CLIP_DISABLE },
667 { o(ARB_derivative_control), PIPE_CAP_TGSI_FS_FINE_DERIVATIVE },
668 { o(ARB_draw_buffers_blend), PIPE_CAP_INDEP_BLEND_FUNC },
669 { o(ARB_draw_indirect), PIPE_CAP_DRAW_INDIRECT },
670 { o(ARB_draw_instanced), PIPE_CAP_TGSI_INSTANCEID },
671 { o(ARB_framebuffer_object), PIPE_CAP_MIXED_FRAMEBUFFER_SIZES },
672 { o(ARB_gpu_shader_int64), PIPE_CAP_INT64 },
673 { o(ARB_indirect_parameters), PIPE_CAP_MULTI_DRAW_INDIRECT_PARAMS },
674 { o(ARB_instanced_arrays), PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR },
675 { o(ARB_occlusion_query), PIPE_CAP_OCCLUSION_QUERY },
676 { o(ARB_occlusion_query2), PIPE_CAP_OCCLUSION_QUERY },
677 { o(ARB_pipeline_statistics_query), PIPE_CAP_QUERY_PIPELINE_STATISTICS },
678 { o(ARB_point_sprite), PIPE_CAP_POINT_SPRITE },
679 { o(ARB_polygon_offset_clamp), PIPE_CAP_POLYGON_OFFSET_CLAMP },
680 { o(ARB_post_depth_coverage), PIPE_CAP_POST_DEPTH_COVERAGE },
681 { o(ARB_query_buffer_object), PIPE_CAP_QUERY_BUFFER_OBJECT },
682 { o(ARB_robust_buffer_access_behavior), PIPE_CAP_ROBUST_BUFFER_ACCESS_BEHAVIOR },
683 { o(ARB_sample_shading), PIPE_CAP_SAMPLE_SHADING },
684 { o(ARB_sample_locations), PIPE_CAP_PROGRAMMABLE_SAMPLE_LOCATIONS },
685 { o(ARB_seamless_cube_map), PIPE_CAP_SEAMLESS_CUBE_MAP },
686 { o(ARB_shader_ballot), PIPE_CAP_TGSI_BALLOT },
687 { o(ARB_shader_clock), PIPE_CAP_TGSI_CLOCK },
688 { o(ARB_shader_draw_parameters), PIPE_CAP_DRAW_PARAMETERS },
689 { o(ARB_shader_group_vote), PIPE_CAP_TGSI_VOTE },
690 { o(ARB_shader_stencil_export), PIPE_CAP_SHADER_STENCIL_EXPORT },
691 { o(ARB_shader_texture_image_samples), PIPE_CAP_TGSI_TXQS },
692 { o(ARB_shader_texture_lod), PIPE_CAP_SM3 },
693 { o(ARB_sparse_buffer), PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE },
694 { o(ARB_texture_buffer_object), PIPE_CAP_TEXTURE_BUFFER_OBJECTS },
695 { o(ARB_texture_cube_map_array), PIPE_CAP_CUBE_MAP_ARRAY },
696 { o(ARB_texture_gather), PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS },
697 { o(ARB_texture_mirror_clamp_to_edge), PIPE_CAP_TEXTURE_MIRROR_CLAMP },
698 { o(ARB_texture_multisample), PIPE_CAP_TEXTURE_MULTISAMPLE },
699 { o(ARB_texture_non_power_of_two), PIPE_CAP_NPOT_TEXTURES },
700 { o(ARB_texture_query_lod), PIPE_CAP_TEXTURE_QUERY_LOD },
701 { o(ARB_texture_view), PIPE_CAP_SAMPLER_VIEW_TARGET },
702 { o(ARB_timer_query), PIPE_CAP_QUERY_TIMESTAMP },
703 { o(ARB_transform_feedback2), PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME },
704 { o(ARB_transform_feedback3), PIPE_CAP_STREAM_OUTPUT_INTERLEAVE_BUFFERS },
705 { o(ARB_transform_feedback_overflow_query), PIPE_CAP_QUERY_SO_OVERFLOW },
707 { o(KHR_blend_equation_advanced), PIPE_CAP_TGSI_FS_FBFETCH },
709 { o(EXT_blend_equation_separate), PIPE_CAP_BLEND_EQUATION_SEPARATE },
710 { o(EXT_depth_bounds_test), PIPE_CAP_DEPTH_BOUNDS_TEST },
711 { o(EXT_draw_buffers2), PIPE_CAP_INDEP_BLEND_ENABLE },
712 { o(EXT_memory_object), PIPE_CAP_MEMOBJ },
713 { o(EXT_memory_object_fd), PIPE_CAP_MEMOBJ },
714 { o(EXT_semaphore), PIPE_CAP_FENCE_SIGNAL },
715 { o(EXT_semaphore_fd), PIPE_CAP_FENCE_SIGNAL },
716 { o(EXT_texture_array), PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS },
717 { o(EXT_texture_filter_anisotropic), PIPE_CAP_ANISOTROPIC_FILTER },
718 { o(EXT_texture_mirror_clamp), PIPE_CAP_TEXTURE_MIRROR_CLAMP },
719 { o(EXT_texture_swizzle), PIPE_CAP_TEXTURE_SWIZZLE },
720 { o(EXT_transform_feedback), PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS },
721 { o(EXT_window_rectangles), PIPE_CAP_MAX_WINDOW_RECTANGLES },
723 { o(AMD_framebuffer_multisample_advanced), PIPE_CAP_FRAMEBUFFER_MSAA_CONSTRAINTS },
724 { o(AMD_pinned_memory), PIPE_CAP_RESOURCE_FROM_USER_MEMORY },
725 { o(ATI_meminfo), PIPE_CAP_QUERY_MEMORY_INFO },
726 { o(AMD_seamless_cubemap_per_texture), PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE },
727 { o(ATI_texture_mirror_once), PIPE_CAP_TEXTURE_MIRROR_CLAMP },
728 { o(MESA_tile_raster_order), PIPE_CAP_TILE_RASTER_ORDER },
729 { o(NV_conditional_render), PIPE_CAP_CONDITIONAL_RENDER },
730 { o(NV_fill_rectangle), PIPE_CAP_POLYGON_MODE_FILL_RECTANGLE },
731 { o(NV_primitive_restart), PIPE_CAP_PRIMITIVE_RESTART },
732 { o(NV_texture_barrier), PIPE_CAP_TEXTURE_BARRIER },
733 { o(NVX_gpu_memory_info), PIPE_CAP_QUERY_MEMORY_INFO },
734 /* GL_NV_point_sprite is not supported by gallium because we don't
735 * support the GL_POINT_SPRITE_R_MODE_NV option. */
737 { o(OES_standard_derivatives), PIPE_CAP_SM3 },
738 { o(OES_texture_float_linear), PIPE_CAP_TEXTURE_FLOAT_LINEAR },
739 { o(OES_texture_half_float_linear), PIPE_CAP_TEXTURE_HALF_FLOAT_LINEAR },
742 /* Required: render target and sampler support */
743 static const struct st_extension_format_mapping rendertarget_mapping[] = {
744 { { o(ARB_texture_float) },
745 { PIPE_FORMAT_R32G32B32A32_FLOAT,
746 PIPE_FORMAT_R16G16B16A16_FLOAT } },
748 { { o(OES_texture_float) },
749 { PIPE_FORMAT_R32G32B32A32_FLOAT } },
751 { { o(OES_texture_half_float) },
752 { PIPE_FORMAT_R16G16B16A16_FLOAT } },
754 { { o(ARB_texture_rgb10_a2ui) },
755 { PIPE_FORMAT_R10G10B10A2_UINT,
756 PIPE_FORMAT_B10G10R10A2_UINT },
757 GL_TRUE }, /* at least one format must be supported */
759 { { o(EXT_framebuffer_sRGB) },
760 { PIPE_FORMAT_A8B8G8R8_SRGB,
761 PIPE_FORMAT_B8G8R8A8_SRGB,
762 PIPE_FORMAT_R8G8B8A8_SRGB },
763 GL_TRUE }, /* at least one format must be supported */
765 { { o(EXT_packed_float) },
766 { PIPE_FORMAT_R11G11B10_FLOAT } },
768 { { o(EXT_texture_integer) },
769 { PIPE_FORMAT_R32G32B32A32_UINT,
770 PIPE_FORMAT_R32G32B32A32_SINT } },
772 { { o(ARB_texture_rg) },
773 { PIPE_FORMAT_R8_UNORM,
774 PIPE_FORMAT_R8G8_UNORM } },
777 /* Required: depth stencil and sampler support */
778 static const struct st_extension_format_mapping depthstencil_mapping[] = {
779 { { o(ARB_depth_buffer_float) },
780 { PIPE_FORMAT_Z32_FLOAT,
781 PIPE_FORMAT_Z32_FLOAT_S8X24_UINT } },
784 /* Required: sampler support */
785 static const struct st_extension_format_mapping texture_mapping[] = {
786 { { o(ARB_texture_compression_rgtc) },
787 { PIPE_FORMAT_RGTC1_UNORM,
788 PIPE_FORMAT_RGTC1_SNORM,
789 PIPE_FORMAT_RGTC2_UNORM,
790 PIPE_FORMAT_RGTC2_SNORM } },
792 { { o(EXT_texture_compression_latc) },
793 { PIPE_FORMAT_LATC1_UNORM,
794 PIPE_FORMAT_LATC1_SNORM,
795 PIPE_FORMAT_LATC2_UNORM,
796 PIPE_FORMAT_LATC2_SNORM } },
798 { { o(EXT_texture_compression_s3tc),
799 o(ANGLE_texture_compression_dxt) },
800 { PIPE_FORMAT_DXT1_RGB,
801 PIPE_FORMAT_DXT1_RGBA,
802 PIPE_FORMAT_DXT3_RGBA,
803 PIPE_FORMAT_DXT5_RGBA } },
805 { { o(ARB_texture_compression_bptc) },
806 { PIPE_FORMAT_BPTC_RGBA_UNORM,
807 PIPE_FORMAT_BPTC_SRGBA,
808 PIPE_FORMAT_BPTC_RGB_FLOAT,
809 PIPE_FORMAT_BPTC_RGB_UFLOAT } },
811 { { o(KHR_texture_compression_astc_ldr) },
812 { PIPE_FORMAT_ASTC_4x4,
813 PIPE_FORMAT_ASTC_5x4,
814 PIPE_FORMAT_ASTC_5x5,
815 PIPE_FORMAT_ASTC_6x5,
816 PIPE_FORMAT_ASTC_6x6,
817 PIPE_FORMAT_ASTC_8x5,
818 PIPE_FORMAT_ASTC_8x6,
819 PIPE_FORMAT_ASTC_8x8,
820 PIPE_FORMAT_ASTC_10x5,
821 PIPE_FORMAT_ASTC_10x6,
822 PIPE_FORMAT_ASTC_10x8,
823 PIPE_FORMAT_ASTC_10x10,
824 PIPE_FORMAT_ASTC_12x10,
825 PIPE_FORMAT_ASTC_12x12,
826 PIPE_FORMAT_ASTC_4x4_SRGB,
827 PIPE_FORMAT_ASTC_5x4_SRGB,
828 PIPE_FORMAT_ASTC_5x5_SRGB,
829 PIPE_FORMAT_ASTC_6x5_SRGB,
830 PIPE_FORMAT_ASTC_6x6_SRGB,
831 PIPE_FORMAT_ASTC_8x5_SRGB,
832 PIPE_FORMAT_ASTC_8x6_SRGB,
833 PIPE_FORMAT_ASTC_8x8_SRGB,
834 PIPE_FORMAT_ASTC_10x5_SRGB,
835 PIPE_FORMAT_ASTC_10x6_SRGB,
836 PIPE_FORMAT_ASTC_10x8_SRGB,
837 PIPE_FORMAT_ASTC_10x10_SRGB,
838 PIPE_FORMAT_ASTC_12x10_SRGB,
839 PIPE_FORMAT_ASTC_12x12_SRGB } },
841 /* ASTC software fallback support. */
842 { { o(KHR_texture_compression_astc_ldr) },
843 { PIPE_FORMAT_R8G8B8A8_UNORM,
844 PIPE_FORMAT_R8G8B8A8_SRGB } },
846 { { o(EXT_texture_shared_exponent) },
847 { PIPE_FORMAT_R9G9B9E5_FLOAT } },
849 { { o(EXT_texture_snorm) },
850 { PIPE_FORMAT_R8G8B8A8_SNORM } },
852 { { o(EXT_texture_sRGB),
853 o(EXT_texture_sRGB_decode) },
854 { PIPE_FORMAT_A8B8G8R8_SRGB,
855 PIPE_FORMAT_B8G8R8A8_SRGB,
856 PIPE_FORMAT_A8R8G8B8_SRGB,
857 PIPE_FORMAT_R8G8B8A8_SRGB},
858 GL_TRUE }, /* at least one format must be supported */
860 { { o(EXT_texture_type_2_10_10_10_REV) },
861 { PIPE_FORMAT_R10G10B10A2_UNORM,
862 PIPE_FORMAT_B10G10R10A2_UNORM },
863 GL_TRUE }, /* at least one format must be supported */
865 { { o(ATI_texture_compression_3dc) },
866 { PIPE_FORMAT_LATC2_UNORM } },
868 { { o(MESA_ycbcr_texture) },
871 GL_TRUE }, /* at least one format must be supported */
873 { { o(OES_compressed_ETC1_RGB8_texture) },
874 { PIPE_FORMAT_ETC1_RGB8,
875 PIPE_FORMAT_R8G8B8A8_UNORM },
876 GL_TRUE }, /* at least one format must be supported */
878 { { o(ARB_stencil_texturing),
879 o(ARB_texture_stencil8) },
880 { PIPE_FORMAT_X24S8_UINT,
881 PIPE_FORMAT_S8X24_UINT },
882 GL_TRUE }, /* at least one format must be supported */
885 /* Required: vertex fetch support. */
886 static const struct st_extension_format_mapping vertex_mapping[] = {
887 { { o(EXT_vertex_array_bgra) },
888 { PIPE_FORMAT_B8G8R8A8_UNORM } },
889 { { o(ARB_vertex_type_2_10_10_10_rev) },
890 { PIPE_FORMAT_R10G10B10A2_UNORM,
891 PIPE_FORMAT_B10G10R10A2_UNORM,
892 PIPE_FORMAT_R10G10B10A2_SNORM,
893 PIPE_FORMAT_B10G10R10A2_SNORM,
894 PIPE_FORMAT_R10G10B10A2_USCALED,
895 PIPE_FORMAT_B10G10R10A2_USCALED,
896 PIPE_FORMAT_R10G10B10A2_SSCALED,
897 PIPE_FORMAT_B10G10R10A2_SSCALED } },
898 { { o(ARB_vertex_type_10f_11f_11f_rev) },
899 { PIPE_FORMAT_R11G11B10_FLOAT } },
902 static const struct st_extension_format_mapping tbo_rgb32[] = {
903 { {o(ARB_texture_buffer_object_rgb32) },
904 { PIPE_FORMAT_R32G32B32_FLOAT,
905 PIPE_FORMAT_R32G32B32_UINT,
906 PIPE_FORMAT_R32G32B32_SINT,
911 * Extensions that are supported by all Gallium drivers:
913 extensions->ARB_ES2_compatibility = GL_TRUE;
914 extensions->ARB_depth_texture = GL_TRUE;
915 extensions->ARB_draw_elements_base_vertex = GL_TRUE;
916 extensions->ARB_explicit_attrib_location = GL_TRUE;
917 extensions->ARB_explicit_uniform_location = GL_TRUE;
918 extensions->ARB_fragment_coord_conventions = GL_TRUE;
919 extensions->ARB_fragment_program = GL_TRUE;
920 extensions->ARB_fragment_program_shadow = GL_TRUE;
921 extensions->ARB_fragment_shader = GL_TRUE;
922 extensions->ARB_half_float_vertex = GL_TRUE;
923 extensions->ARB_internalformat_query = GL_TRUE;
924 extensions->ARB_internalformat_query2 = GL_TRUE;
925 extensions->ARB_map_buffer_range = GL_TRUE;
926 extensions->ARB_shadow = GL_TRUE;
927 extensions->ARB_sync = GL_TRUE;
928 extensions->ARB_texture_border_clamp = GL_TRUE;
929 extensions->ARB_texture_cube_map = GL_TRUE;
930 extensions->ARB_texture_env_combine = GL_TRUE;
931 extensions->ARB_texture_env_crossbar = GL_TRUE;
932 extensions->ARB_texture_env_dot3 = GL_TRUE;
933 extensions->ARB_vertex_program = GL_TRUE;
934 extensions->ARB_vertex_shader = GL_TRUE;
936 extensions->EXT_blend_color = GL_TRUE;
937 extensions->EXT_blend_func_separate = GL_TRUE;
938 extensions->EXT_blend_minmax = GL_TRUE;
939 extensions->EXT_gpu_program_parameters = GL_TRUE;
940 extensions->EXT_pixel_buffer_object = GL_TRUE;
941 extensions->EXT_point_parameters = GL_TRUE;
942 extensions->EXT_provoking_vertex = GL_TRUE;
943 extensions->EXT_stencil_two_side = GL_TRUE;
944 extensions->EXT_texture_env_dot3 = GL_TRUE;
946 extensions->ATI_fragment_shader = GL_TRUE;
947 extensions->ATI_texture_env_combine3 = GL_TRUE;
949 extensions->MESA_pack_invert = GL_TRUE;
951 extensions->NV_fog_distance = GL_TRUE;
952 extensions->NV_texture_env_combine4 = GL_TRUE;
953 extensions->NV_texture_rectangle = GL_TRUE;
955 extensions->OES_EGL_image = GL_TRUE;
956 extensions->OES_EGL_image_external = GL_TRUE;
957 extensions->OES_draw_texture = GL_TRUE;
959 /* Expose the extensions which directly correspond to gallium caps. */
960 for (i = 0; i < ARRAY_SIZE(cap_mapping); i++) {
961 if (screen->get_param(screen, cap_mapping[i].cap)) {
962 extension_table[cap_mapping[i].extension_offset] = GL_TRUE;
966 /* Expose the extensions which directly correspond to gallium formats. */
967 init_format_extensions(screen, extensions, rendertarget_mapping,
968 ARRAY_SIZE(rendertarget_mapping), PIPE_TEXTURE_2D,
969 PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW);
970 init_format_extensions(screen, extensions, depthstencil_mapping,
971 ARRAY_SIZE(depthstencil_mapping), PIPE_TEXTURE_2D,
972 PIPE_BIND_DEPTH_STENCIL | PIPE_BIND_SAMPLER_VIEW);
973 init_format_extensions(screen, extensions, texture_mapping,
974 ARRAY_SIZE(texture_mapping), PIPE_TEXTURE_2D,
975 PIPE_BIND_SAMPLER_VIEW);
976 init_format_extensions(screen, extensions, vertex_mapping,
977 ARRAY_SIZE(vertex_mapping), PIPE_BUFFER,
978 PIPE_BIND_VERTEX_BUFFER);
980 /* Figure out GLSL support and set GLSLVersion to it. */
981 consts->GLSLVersion = screen->get_param(screen, PIPE_CAP_GLSL_FEATURE_LEVEL);
982 consts->GLSLVersionCompat =
983 screen->get_param(screen, PIPE_CAP_GLSL_FEATURE_LEVEL_COMPATIBILITY);
985 const unsigned GLSLVersion =
986 api == API_OPENGL_COMPAT ? consts->GLSLVersionCompat :
989 _mesa_override_glsl_version(consts);
991 if (options->force_glsl_version > 0 &&
992 options->force_glsl_version <= GLSLVersion) {
993 consts->ForceGLSLVersion = options->force_glsl_version;
996 consts->AllowHigherCompatVersion = options->allow_higher_compat_version;
998 consts->ForceGLSLAbsSqrt = options->force_glsl_abs_sqrt;
1000 consts->AllowGLSLBuiltinVariableRedeclaration = options->allow_glsl_builtin_variable_redeclaration;
1002 consts->dri_config_options_sha1 = options->config_options_sha1;
1004 consts->AllowGLSLCrossStageInterpolationMismatch = options->allow_glsl_cross_stage_interpolation_mismatch;
1006 if (GLSLVersion >= 400)
1007 extensions->ARB_gpu_shader5 = GL_TRUE;
1008 if (GLSLVersion >= 410)
1009 extensions->ARB_shader_precision = GL_TRUE;
1011 /* This extension needs full OpenGL 3.2, but we don't know if that's
1012 * supported at this point. Only check the GLSL version. */
1013 if (GLSLVersion >= 150 &&
1014 screen->get_param(screen, PIPE_CAP_TGSI_VS_LAYER_VIEWPORT)) {
1015 extensions->AMD_vertex_shader_layer = GL_TRUE;
1018 if (GLSLVersion >= 140) {
1019 if (screen->get_param(screen, PIPE_CAP_TGSI_ARRAY_COMPONENTS))
1020 extensions->ARB_enhanced_layouts = GL_TRUE;
1023 if (GLSLVersion >= 130) {
1024 consts->NativeIntegers = GL_TRUE;
1025 consts->MaxClipPlanes = 8;
1027 if (screen->get_param(screen, PIPE_CAP_VERTEXID_NOBASE)) {
1028 consts->VertexID_is_zero_based = GL_TRUE;
1031 /* Extensions that either depend on GLSL 1.30 or are a subset thereof. */
1032 extensions->ARB_conservative_depth = GL_TRUE;
1033 extensions->ARB_shading_language_packing = GL_TRUE;
1034 extensions->OES_depth_texture_cube_map = GL_TRUE;
1035 extensions->ARB_shading_language_420pack = GL_TRUE;
1036 extensions->ARB_texture_query_levels = GL_TRUE;
1038 extensions->ARB_shader_bit_encoding = GL_TRUE;
1040 extensions->EXT_shader_integer_mix = GL_TRUE;
1041 extensions->ARB_arrays_of_arrays = GL_TRUE;
1042 extensions->MESA_shader_integer_functions = GL_TRUE;
1044 /* Optional integer support for GLSL 1.2. */
1045 if (screen->get_shader_param(screen, PIPE_SHADER_VERTEX,
1046 PIPE_SHADER_CAP_INTEGERS) &&
1047 screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT,
1048 PIPE_SHADER_CAP_INTEGERS)) {
1049 consts->NativeIntegers = GL_TRUE;
1051 extensions->EXT_shader_integer_mix = GL_TRUE;
1054 /* Integer textures make no sense before GLSL 1.30 */
1055 extensions->EXT_texture_integer = GL_FALSE;
1058 consts->GLSLZeroInit = options->glsl_zero_init;
1060 consts->UniformBooleanTrue = consts->NativeIntegers ? ~0U : fui(1.0f);
1062 /* Below are the cases which cannot be moved into tables easily. */
1064 /* The compatibility profile also requires GLSLVersionCompat >= 400. */
1065 if (screen->get_shader_param(screen, PIPE_SHADER_TESS_CTRL,
1066 PIPE_SHADER_CAP_MAX_INSTRUCTIONS) > 0 &&
1067 (api != API_OPENGL_COMPAT || consts->GLSLVersionCompat >= 400)) {
1068 extensions->ARB_tessellation_shader = GL_TRUE;
1071 /* What this is really checking for is the ability to support multiple
1072 * invocations of a geometry shader. There is no separate cap for that, so
1073 * we check the GLSLVersion.
1075 if (GLSLVersion >= 400 &&
1076 screen->get_shader_param(screen, PIPE_SHADER_GEOMETRY,
1077 PIPE_SHADER_CAP_MAX_INSTRUCTIONS) > 0) {
1078 extensions->OES_geometry_shader = GL_TRUE;
1081 /* Needs PIPE_CAP_SAMPLE_SHADING + all the sample-related bits of
1082 * ARB_gpu_shader5. This enables all the per-sample shading ES extensions.
1084 extensions->OES_sample_variables = extensions->ARB_sample_shading &&
1085 extensions->ARB_gpu_shader5;
1087 /* Maximum sample count. */
1089 static const enum pipe_format color_formats[] = {
1090 PIPE_FORMAT_R8G8B8A8_UNORM,
1091 PIPE_FORMAT_B8G8R8A8_UNORM,
1092 PIPE_FORMAT_A8R8G8B8_UNORM,
1093 PIPE_FORMAT_A8B8G8R8_UNORM,
1095 static const enum pipe_format depth_formats[] = {
1096 PIPE_FORMAT_Z16_UNORM,
1097 PIPE_FORMAT_Z24X8_UNORM,
1098 PIPE_FORMAT_X8Z24_UNORM,
1099 PIPE_FORMAT_Z32_UNORM,
1100 PIPE_FORMAT_Z32_FLOAT
1102 static const enum pipe_format int_formats[] = {
1103 PIPE_FORMAT_R8G8B8A8_SINT
1105 static const enum pipe_format void_formats[] = {
1109 consts->MaxSamples =
1110 get_max_samples_for_formats(screen, ARRAY_SIZE(color_formats),
1112 PIPE_BIND_RENDER_TARGET);
1114 consts->MaxImageSamples =
1115 get_max_samples_for_formats(screen, ARRAY_SIZE(color_formats),
1117 PIPE_BIND_SHADER_IMAGE);
1119 consts->MaxColorTextureSamples =
1120 get_max_samples_for_formats(screen, ARRAY_SIZE(color_formats),
1121 color_formats, consts->MaxSamples,
1122 PIPE_BIND_SAMPLER_VIEW);
1124 consts->MaxDepthTextureSamples =
1125 get_max_samples_for_formats(screen, ARRAY_SIZE(depth_formats),
1126 depth_formats, consts->MaxSamples,
1127 PIPE_BIND_SAMPLER_VIEW);
1129 consts->MaxIntegerSamples =
1130 get_max_samples_for_formats(screen, ARRAY_SIZE(int_formats),
1131 int_formats, consts->MaxSamples,
1132 PIPE_BIND_SAMPLER_VIEW);
1134 /* ARB_framebuffer_no_attachments, assume max no. of samples 32 */
1135 consts->MaxFramebufferSamples =
1136 get_max_samples_for_formats(screen, ARRAY_SIZE(void_formats),
1138 PIPE_BIND_RENDER_TARGET);
1140 if (extensions->AMD_framebuffer_multisample_advanced) {
1141 /* AMD_framebuffer_multisample_advanced */
1142 /* This can be greater than storage samples. */
1143 consts->MaxColorFramebufferSamples =
1144 get_max_samples_for_formats_advanced(screen,
1145 ARRAY_SIZE(color_formats),
1148 PIPE_BIND_RENDER_TARGET);
1150 /* If the driver supports N color samples, it means it supports
1151 * N samples and N storage samples. N samples >= N storage
1154 consts->MaxColorFramebufferStorageSamples = consts->MaxSamples;
1155 consts->MaxDepthStencilFramebufferSamples =
1156 consts->MaxDepthTextureSamples;
1158 assert(consts->MaxColorFramebufferSamples >=
1159 consts->MaxDepthStencilFramebufferSamples);
1160 assert(consts->MaxDepthStencilFramebufferSamples >=
1161 consts->MaxColorFramebufferStorageSamples);
1163 consts->NumSupportedMultisampleModes = 0;
1165 unsigned depth_samples_supported = 0;
1167 for (unsigned samples = 2;
1168 samples <= consts->MaxDepthStencilFramebufferSamples;
1170 if (screen->is_format_supported(screen, PIPE_FORMAT_Z32_FLOAT,
1171 PIPE_TEXTURE_2D, samples, samples,
1172 PIPE_BIND_DEPTH_STENCIL))
1173 depth_samples_supported |= 1 << samples;
1176 for (unsigned samples = 2;
1177 samples <= consts->MaxColorFramebufferSamples;
1179 for (unsigned depth_samples = 2;
1180 depth_samples <= samples; depth_samples++) {
1181 if (!(depth_samples_supported & (1 << depth_samples)))
1184 for (unsigned storage_samples = 2;
1185 storage_samples <= depth_samples; storage_samples++) {
1186 if (screen->is_format_supported(screen,
1187 PIPE_FORMAT_R8G8B8A8_UNORM,
1191 PIPE_BIND_RENDER_TARGET)) {
1192 unsigned i = consts->NumSupportedMultisampleModes;
1194 assert(i < ARRAY_SIZE(consts->SupportedMultisampleModes));
1195 consts->SupportedMultisampleModes[i].NumColorSamples =
1197 consts->SupportedMultisampleModes[i].NumColorStorageSamples =
1199 consts->SupportedMultisampleModes[i].NumDepthStencilSamples =
1201 consts->NumSupportedMultisampleModes++;
1209 if (consts->MaxSamples >= 2) {
1210 /* Real MSAA support */
1211 extensions->EXT_framebuffer_multisample = GL_TRUE;
1212 extensions->EXT_framebuffer_multisample_blit_scaled = GL_TRUE;
1214 else if (consts->MaxSamples > 0 &&
1215 screen->get_param(screen, PIPE_CAP_FAKE_SW_MSAA)) {
1216 /* fake MSAA support */
1217 consts->FakeSWMSAA = GL_TRUE;
1218 extensions->EXT_framebuffer_multisample = GL_TRUE;
1219 extensions->EXT_framebuffer_multisample_blit_scaled = GL_TRUE;
1220 extensions->ARB_texture_multisample = GL_TRUE;
1223 if (consts->MaxDualSourceDrawBuffers > 0 &&
1224 !options->disable_blend_func_extended)
1225 extensions->ARB_blend_func_extended = GL_TRUE;
1227 if (screen->get_param(screen, PIPE_CAP_QUERY_TIME_ELAPSED) ||
1228 extensions->ARB_timer_query) {
1229 extensions->EXT_timer_query = GL_TRUE;
1232 if (extensions->ARB_transform_feedback2 &&
1233 extensions->ARB_draw_instanced) {
1234 extensions->ARB_transform_feedback_instanced = GL_TRUE;
1236 if (options->force_glsl_extensions_warn)
1237 consts->ForceGLSLExtensionsWarn = 1;
1239 if (options->disable_glsl_line_continuations)
1240 consts->DisableGLSLLineContinuations = 1;
1242 if (options->allow_glsl_extension_directive_midshader)
1243 consts->AllowGLSLExtensionDirectiveMidShader = GL_TRUE;
1245 if (options->allow_glsl_builtin_const_expression)
1246 consts->AllowGLSLBuiltinConstantExpression = GL_TRUE;
1248 if (options->allow_glsl_relaxed_es)
1249 consts->AllowGLSLRelaxedES = GL_TRUE;
1251 consts->MinMapBufferAlignment =
1252 screen->get_param(screen, PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT);
1254 /* The OpenGL Compatibility profile requires arbitrary buffer swizzling. */
1255 if (api == API_OPENGL_COMPAT &&
1256 screen->get_param(screen, PIPE_CAP_BUFFER_SAMPLER_VIEW_RGBA_ONLY))
1257 extensions->ARB_texture_buffer_object = GL_FALSE;
1259 if (extensions->ARB_texture_buffer_object) {
1260 consts->MaxTextureBufferSize =
1261 _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE),
1263 consts->TextureBufferOffsetAlignment =
1264 screen->get_param(screen, PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT);
1266 if (consts->TextureBufferOffsetAlignment)
1267 extensions->ARB_texture_buffer_range = GL_TRUE;
1269 init_format_extensions(screen, extensions, tbo_rgb32,
1270 ARRAY_SIZE(tbo_rgb32), PIPE_BUFFER,
1271 PIPE_BIND_SAMPLER_VIEW);
1274 extensions->OES_texture_buffer =
1275 extensions->ARB_texture_buffer_object &&
1276 extensions->ARB_texture_buffer_range &&
1277 extensions->ARB_texture_buffer_object_rgb32 &&
1278 extensions->ARB_shader_image_load_store;
1280 /* Unpacking a varying in the fragment shader costs 1 texture indirection.
1281 * If the number of available texture indirections is very limited, then we
1282 * prefer to disable varying packing rather than run the risk of varying
1283 * packing preventing a shader from running.
1285 if (screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT,
1286 PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS) <= 8) {
1287 /* We can't disable varying packing if transform feedback is available,
1288 * because transform feedback code assumes a packed varying layout.
1290 if (!extensions->EXT_transform_feedback)
1291 consts->DisableVaryingPacking = GL_TRUE;
1294 consts->MaxViewports = screen->get_param(screen, PIPE_CAP_MAX_VIEWPORTS);
1295 if (consts->MaxViewports >= 16) {
1296 if (GLSLVersion >= 400) {
1297 consts->ViewportBounds.Min = -32768.0;
1298 consts->ViewportBounds.Max = 32767.0;
1300 consts->ViewportBounds.Min = -16384.0;
1301 consts->ViewportBounds.Max = 16383.0;
1303 extensions->ARB_viewport_array = GL_TRUE;
1304 extensions->ARB_fragment_layer_viewport = GL_TRUE;
1305 if (extensions->AMD_vertex_shader_layer)
1306 extensions->AMD_vertex_shader_viewport_index = GL_TRUE;
1309 if (extensions->AMD_vertex_shader_layer &&
1310 extensions->AMD_vertex_shader_viewport_index &&
1311 screen->get_param(screen, PIPE_CAP_TGSI_TES_LAYER_VIEWPORT))
1312 extensions->ARB_shader_viewport_layer_array = GL_TRUE;
1314 /* ARB_framebuffer_no_attachments */
1315 if (screen->get_param(screen, PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT) &&
1316 ((consts->MaxSamples >= 4 && consts->MaxFramebufferLayers >= 2048) ||
1317 (consts->MaxFramebufferSamples >= consts->MaxSamples &&
1318 consts->MaxFramebufferLayers >= consts->MaxArrayTextureLayers)))
1319 extensions->ARB_framebuffer_no_attachments = GL_TRUE;
1321 /* GL_ARB_ES3_compatibility.
1322 * Check requirements for GLSL ES 3.00.
1324 if (GLSLVersion >= 130 &&
1325 extensions->ARB_uniform_buffer_object &&
1326 extensions->ARB_shader_bit_encoding &&
1327 extensions->NV_primitive_restart &&
1328 screen->get_shader_param(screen, PIPE_SHADER_VERTEX,
1329 PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS) >= 16 &&
1330 /* Requirements for ETC2 emulation. */
1331 screen->is_format_supported(screen, PIPE_FORMAT_R8G8B8A8_UNORM,
1332 PIPE_TEXTURE_2D, 0, 0,
1333 PIPE_BIND_SAMPLER_VIEW) &&
1334 screen->is_format_supported(screen, PIPE_FORMAT_R8G8B8A8_SRGB,
1335 PIPE_TEXTURE_2D, 0, 0,
1336 PIPE_BIND_SAMPLER_VIEW) &&
1337 screen->is_format_supported(screen, PIPE_FORMAT_R16_UNORM,
1338 PIPE_TEXTURE_2D, 0, 0,
1339 PIPE_BIND_SAMPLER_VIEW) &&
1340 screen->is_format_supported(screen, PIPE_FORMAT_R16G16_UNORM,
1341 PIPE_TEXTURE_2D, 0, 0,
1342 PIPE_BIND_SAMPLER_VIEW) &&
1343 screen->is_format_supported(screen, PIPE_FORMAT_R16_SNORM,
1344 PIPE_TEXTURE_2D, 0, 0,
1345 PIPE_BIND_SAMPLER_VIEW) &&
1346 screen->is_format_supported(screen, PIPE_FORMAT_R16G16_SNORM,
1347 PIPE_TEXTURE_2D, 0, 0,
1348 PIPE_BIND_SAMPLER_VIEW)) {
1349 extensions->ARB_ES3_compatibility = GL_TRUE;
1352 #ifdef HAVE_ST_VDPAU
1353 if (screen->get_video_param &&
1354 screen->get_video_param(screen, PIPE_VIDEO_PROFILE_UNKNOWN,
1355 PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
1356 PIPE_VIDEO_CAP_SUPPORTS_INTERLACED)) {
1357 extensions->NV_vdpau_interop = GL_TRUE;
1361 if (screen->get_param(screen, PIPE_CAP_DOUBLES)) {
1362 extensions->ARB_gpu_shader_fp64 = GL_TRUE;
1363 extensions->ARB_vertex_attrib_64bit = GL_TRUE;
1366 if ((ST_DEBUG & DEBUG_GREMEDY) &&
1367 screen->get_param(screen, PIPE_CAP_STRING_MARKER))
1368 extensions->GREMEDY_string_marker = GL_TRUE;
1370 if (screen->get_param(screen, PIPE_CAP_COMPUTE)) {
1371 int compute_supported_irs =
1372 screen->get_shader_param(screen, PIPE_SHADER_COMPUTE,
1373 PIPE_SHADER_CAP_SUPPORTED_IRS);
1374 if (compute_supported_irs & (1 << PIPE_SHADER_IR_TGSI)) {
1375 uint64_t grid_size[3], block_size[3];
1376 uint64_t max_local_size, max_threads_per_block;
1378 screen->get_compute_param(screen, PIPE_SHADER_IR_TGSI,
1379 PIPE_COMPUTE_CAP_MAX_GRID_SIZE, grid_size);
1380 screen->get_compute_param(screen, PIPE_SHADER_IR_TGSI,
1381 PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE, block_size);
1382 screen->get_compute_param(screen, PIPE_SHADER_IR_TGSI,
1383 PIPE_COMPUTE_CAP_MAX_THREADS_PER_BLOCK,
1384 &max_threads_per_block);
1385 screen->get_compute_param(screen, PIPE_SHADER_IR_TGSI,
1386 PIPE_COMPUTE_CAP_MAX_LOCAL_SIZE,
1389 consts->MaxComputeWorkGroupInvocations = max_threads_per_block;
1390 consts->MaxComputeSharedMemorySize = max_local_size;
1392 for (i = 0; i < 3; i++) {
1393 consts->MaxComputeWorkGroupCount[i] = grid_size[i];
1394 consts->MaxComputeWorkGroupSize[i] = block_size[i];
1397 extensions->ARB_compute_shader =
1398 extensions->ARB_shader_image_load_store &&
1399 extensions->ARB_shader_atomic_counters;
1401 if (extensions->ARB_compute_shader) {
1402 uint64_t max_variable_threads_per_block = 0;
1404 screen->get_compute_param(screen, PIPE_SHADER_IR_TGSI,
1405 PIPE_COMPUTE_CAP_MAX_VARIABLE_THREADS_PER_BLOCK,
1406 &max_variable_threads_per_block);
1408 for (i = 0; i < 3; i++) {
1409 /* Clamp the values to avoid having a local work group size
1410 * greater than the maximum number of invocations.
1412 consts->MaxComputeVariableGroupSize[i] =
1413 MIN2(consts->MaxComputeWorkGroupSize[i],
1414 max_variable_threads_per_block);
1416 consts->MaxComputeVariableGroupInvocations =
1417 max_variable_threads_per_block;
1419 extensions->ARB_compute_variable_group_size =
1420 max_variable_threads_per_block > 0;
1425 if (extensions->EXT_texture_filter_anisotropic &&
1426 screen->get_paramf(screen, PIPE_CAPF_MAX_TEXTURE_ANISOTROPY) >= 16.0)
1427 extensions->ARB_texture_filter_anisotropic = GL_TRUE;
1429 extensions->KHR_robustness = extensions->ARB_robust_buffer_access_behavior;
1431 /* If we support ES 3.1, we support the ES3_1_compatibility ext. However
1432 * there's no clean way of telling whether we would support ES 3.1 from
1433 * here, so copy the condition from compute_version_es2 here. A lot of
1434 * these are redunant, but simpler to just have a (near-)exact copy here.
1436 extensions->ARB_ES3_1_compatibility =
1437 extensions->ARB_ES3_compatibility &&
1438 extensions->ARB_arrays_of_arrays &&
1439 extensions->ARB_compute_shader &&
1440 extensions->ARB_draw_indirect &&
1441 extensions->ARB_explicit_uniform_location &&
1442 extensions->ARB_framebuffer_no_attachments &&
1443 extensions->ARB_shader_atomic_counters &&
1444 extensions->ARB_shader_image_load_store &&
1445 extensions->ARB_shader_image_size &&
1446 extensions->ARB_shader_storage_buffer_object &&
1447 extensions->ARB_shading_language_packing &&
1448 extensions->ARB_stencil_texturing &&
1449 extensions->ARB_texture_multisample &&
1450 extensions->ARB_gpu_shader5 &&
1451 extensions->EXT_shader_integer_mix;
1453 extensions->OES_texture_cube_map_array =
1454 extensions->ARB_ES3_1_compatibility &&
1455 extensions->OES_geometry_shader &&
1456 extensions->ARB_texture_cube_map_array;
1458 extensions->OES_viewport_array =
1459 extensions->ARB_ES3_1_compatibility &&
1460 extensions->OES_geometry_shader &&
1461 extensions->ARB_viewport_array;
1463 extensions->OES_primitive_bounding_box = extensions->ARB_ES3_1_compatibility;
1464 consts->NoPrimitiveBoundingBoxOutput = true;
1466 extensions->ANDROID_extension_pack_es31a =
1467 extensions->KHR_texture_compression_astc_ldr &&
1468 extensions->KHR_blend_equation_advanced &&
1469 extensions->OES_sample_variables &&
1470 extensions->ARB_shader_image_load_store &&
1471 extensions->ARB_texture_stencil8 &&
1472 extensions->ARB_texture_multisample &&
1473 extensions->OES_copy_image &&
1474 extensions->ARB_draw_buffers_blend &&
1475 extensions->OES_geometry_shader &&
1476 extensions->ARB_gpu_shader5 &&
1477 extensions->OES_primitive_bounding_box &&
1478 extensions->ARB_tessellation_shader &&
1479 extensions->ARB_texture_border_clamp &&
1480 extensions->OES_texture_buffer &&
1481 extensions->OES_texture_cube_map_array &&
1482 extensions->EXT_texture_sRGB_decode;
1484 /* Same deal as for ARB_ES3_1_compatibility - this has to be computed
1485 * before overall versions are selected. Also it's actually a subset of ES
1486 * 3.2, since it doesn't require ASTC or advanced blending.
1488 extensions->ARB_ES3_2_compatibility =
1489 extensions->ARB_ES3_1_compatibility &&
1490 extensions->KHR_robustness &&
1491 extensions->ARB_copy_image &&
1492 extensions->ARB_draw_buffers_blend &&
1493 extensions->ARB_draw_elements_base_vertex &&
1494 extensions->OES_geometry_shader &&
1495 extensions->ARB_gpu_shader5 &&
1496 extensions->ARB_sample_shading &&
1497 extensions->ARB_tessellation_shader &&
1498 extensions->ARB_texture_border_clamp &&
1499 extensions->OES_texture_buffer &&
1500 extensions->ARB_texture_cube_map_array &&
1501 extensions->ARB_texture_stencil8 &&
1502 extensions->ARB_texture_multisample;
1504 if (screen->get_param(screen, PIPE_CAP_CONSERVATIVE_RASTER_POST_SNAP_TRIANGLES) &&
1505 screen->get_param(screen, PIPE_CAP_CONSERVATIVE_RASTER_POST_SNAP_POINTS_LINES) &&
1506 screen->get_param(screen, PIPE_CAP_CONSERVATIVE_RASTER_POST_DEPTH_COVERAGE)) {
1508 bool pre_snap_triangles, pre_snap_points_lines;
1510 max_dilate = screen->get_paramf(screen, PIPE_CAPF_MAX_CONSERVATIVE_RASTER_DILATE);
1512 pre_snap_triangles =
1513 screen->get_param(screen, PIPE_CAP_CONSERVATIVE_RASTER_PRE_SNAP_TRIANGLES);
1514 pre_snap_points_lines =
1515 screen->get_param(screen, PIPE_CAP_CONSERVATIVE_RASTER_PRE_SNAP_POINTS_LINES);
1517 extensions->NV_conservative_raster =
1518 screen->get_param(screen, PIPE_CAP_MAX_CONSERVATIVE_RASTER_SUBPIXEL_PRECISION_BIAS) > 1;
1520 if (extensions->NV_conservative_raster) {
1521 extensions->NV_conservative_raster_dilate = max_dilate >= 0.75;
1522 extensions->NV_conservative_raster_pre_snap_triangles = pre_snap_triangles;
1523 extensions->NV_conservative_raster_pre_snap =
1524 pre_snap_triangles && pre_snap_points_lines;