Brian Paul | 4006c5e | 2009-01-26 12:22:04 -0700 | [diff] [blame] | 1 | /************************************************************************** |
Kenneth Graunke | a7bdd4c | 2013-11-25 15:46:34 -0800 | [diff] [blame] | 2 | * |
José Fonseca | 8771285 | 2014-01-17 16:27:50 +0000 | [diff] [blame] | 3 | * Copyright 2003 VMware, Inc. |
Brian Paul | 4006c5e | 2009-01-26 12:22:04 -0700 | [diff] [blame] | 4 | * All Rights Reserved. |
Kenneth Graunke | a7bdd4c | 2013-11-25 15:46:34 -0800 | [diff] [blame] | 5 | * |
Brian Paul | 4006c5e | 2009-01-26 12:22:04 -0700 | [diff] [blame] | 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the |
| 8 | * "Software"), to deal in the Software without restriction, including |
| 9 | * without limitation the rights to use, copy, modify, merge, publish, |
| 10 | * distribute, sub license, and/or sell copies of the Software, and to |
| 11 | * permit persons to whom the Software is furnished to do so, subject to |
| 12 | * the following conditions: |
Kenneth Graunke | a7bdd4c | 2013-11-25 15:46:34 -0800 | [diff] [blame] | 13 | * |
Brian Paul | 4006c5e | 2009-01-26 12:22:04 -0700 | [diff] [blame] | 14 | * The above copyright notice and this permission notice (including the |
| 15 | * next paragraph) shall be included in all copies or substantial portions |
| 16 | * of the Software. |
Kenneth Graunke | a7bdd4c | 2013-11-25 15:46:34 -0800 | [diff] [blame] | 17 | * |
Brian Paul | 4006c5e | 2009-01-26 12:22:04 -0700 | [diff] [blame] | 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 19 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. |
José Fonseca | 8771285 | 2014-01-17 16:27:50 +0000 | [diff] [blame] | 21 | * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR |
Brian Paul | 4006c5e | 2009-01-26 12:22:04 -0700 | [diff] [blame] | 22 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 23 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 24 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Kenneth Graunke | a7bdd4c | 2013-11-25 15:46:34 -0800 | [diff] [blame] | 25 | * |
Brian Paul | 4006c5e | 2009-01-26 12:22:04 -0700 | [diff] [blame] | 26 | **************************************************************************/ |
| 27 | |
Brian Paul | e4394fb | 2011-09-29 16:29:30 -0600 | [diff] [blame] | 28 | #include "main/version.h" |
Vinson Lee | 45a56e4 | 2011-01-09 01:25:54 -0800 | [diff] [blame] | 29 | |
Kenneth Graunke | a692744 | 2013-07-02 18:56:43 -0700 | [diff] [blame] | 30 | #include "brw_context.h" |
Kenneth Graunke | 129da5b | 2013-05-27 20:09:56 -0700 | [diff] [blame] | 31 | #include "intel_batchbuffer.h" |
Eric Anholt | f015901 | 2012-07-18 10:18:26 -0700 | [diff] [blame] | 32 | #include "intel_reg.h" |
Chia-I Wu | 17ef1f6 | 2009-10-08 10:33:57 +0800 | [diff] [blame] | 33 | #include "utils.h" |
Brian Paul | 4006c5e | 2009-01-26 12:22:04 -0700 | [diff] [blame] | 34 | |
Brian Paul | 4006c5e | 2009-01-26 12:22:04 -0700 | [diff] [blame] | 35 | /** |
Kenneth Graunke | 129da5b | 2013-05-27 20:09:56 -0700 | [diff] [blame] | 36 | * Test if we can use MI_LOAD_REGISTER_MEM from an untrusted batchbuffer. |
| 37 | * |
| 38 | * Some combinations of hardware and kernel versions allow this feature, |
| 39 | * while others don't. Instead of trying to enumerate every case, just |
| 40 | * try and write a register and see if works. |
| 41 | */ |
| 42 | static bool |
| 43 | can_do_pipelined_register_writes(struct brw_context *brw) |
| 44 | { |
Kenneth Graunke | decf070 | 2013-11-04 14:09:07 -0800 | [diff] [blame] | 45 | /* Supposedly, Broadwell just works. */ |
| 46 | if (brw->gen >= 8) |
| 47 | return true; |
| 48 | |
Kenneth Graunke | b7f14e0 | 2014-12-22 00:55:37 -0800 | [diff] [blame] | 49 | static int result = -1; |
| 50 | if (result != -1) |
| 51 | return result; |
| 52 | |
Kenneth Graunke | 129da5b | 2013-05-27 20:09:56 -0700 | [diff] [blame] | 53 | /* We use SO_WRITE_OFFSET0 since you're supposed to write it (unlike the |
| 54 | * statistics registers), and we already reset it to zero before using it. |
| 55 | */ |
| 56 | const int reg = GEN7_SO_WRITE_OFFSET(0); |
| 57 | const int expected_value = 0x1337d0d0; |
| 58 | const int offset = 100; |
| 59 | |
| 60 | /* The register we picked only exists on Gen7+. */ |
Kenneth Graunke | decf070 | 2013-11-04 14:09:07 -0800 | [diff] [blame] | 61 | assert(brw->gen == 7); |
Kenneth Graunke | 129da5b | 2013-05-27 20:09:56 -0700 | [diff] [blame] | 62 | |
| 63 | uint32_t *data; |
| 64 | /* Set a value in a BO to a known quantity. The workaround BO already |
| 65 | * exists and doesn't contain anything important, so we may as well use it. |
| 66 | */ |
| 67 | drm_intel_bo_map(brw->batch.workaround_bo, true); |
| 68 | data = brw->batch.workaround_bo->virtual; |
| 69 | data[offset] = 0xffffffff; |
| 70 | drm_intel_bo_unmap(brw->batch.workaround_bo); |
| 71 | |
| 72 | /* Write the register. */ |
| 73 | BEGIN_BATCH(3); |
| 74 | OUT_BATCH(MI_LOAD_REGISTER_IMM | (3 - 2)); |
| 75 | OUT_BATCH(reg); |
| 76 | OUT_BATCH(expected_value); |
| 77 | ADVANCE_BATCH(); |
| 78 | |
| 79 | intel_batchbuffer_emit_mi_flush(brw); |
| 80 | |
| 81 | /* Save the register's value back to the buffer. */ |
| 82 | BEGIN_BATCH(3); |
| 83 | OUT_BATCH(MI_STORE_REGISTER_MEM | (3 - 2)); |
| 84 | OUT_BATCH(reg); |
| 85 | OUT_RELOC(brw->batch.workaround_bo, |
| 86 | I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION, |
| 87 | offset * sizeof(uint32_t)); |
| 88 | ADVANCE_BATCH(); |
| 89 | |
| 90 | intel_batchbuffer_flush(brw); |
| 91 | |
| 92 | /* Check whether the value got written. */ |
| 93 | drm_intel_bo_map(brw->batch.workaround_bo, false); |
Kenneth Graunke | 94841b6 | 2014-09-29 17:00:51 -0700 | [diff] [blame] | 94 | data = brw->batch.workaround_bo->virtual; |
Kenneth Graunke | 129da5b | 2013-05-27 20:09:56 -0700 | [diff] [blame] | 95 | bool success = data[offset] == expected_value; |
| 96 | drm_intel_bo_unmap(brw->batch.workaround_bo); |
| 97 | |
Kenneth Graunke | b7f14e0 | 2014-12-22 00:55:37 -0800 | [diff] [blame] | 98 | result = success; |
| 99 | |
Kenneth Graunke | 129da5b | 2013-05-27 20:09:56 -0700 | [diff] [blame] | 100 | return success; |
| 101 | } |
| 102 | |
Kenneth Graunke | 7a70f03 | 2013-11-13 15:42:57 -0800 | [diff] [blame] | 103 | static bool |
| 104 | can_write_oacontrol(struct brw_context *brw) |
| 105 | { |
| 106 | if (brw->gen < 6 || brw->gen >= 8) |
| 107 | return false; |
| 108 | |
Kenneth Graunke | b7f14e0 | 2014-12-22 00:55:37 -0800 | [diff] [blame] | 109 | static int result = -1; |
| 110 | if (result != -1) |
| 111 | return result; |
| 112 | |
Kenneth Graunke | 7a70f03 | 2013-11-13 15:42:57 -0800 | [diff] [blame] | 113 | /* Set "Select Context ID" to a particular address (which is likely not a |
| 114 | * context), but leave all counting disabled. This should be harmless. |
| 115 | */ |
| 116 | const int expected_value = 0x31337000; |
| 117 | const int offset = 110; |
| 118 | |
| 119 | uint32_t *data; |
| 120 | /* Set a value in a BO to a known quantity. The workaround BO already |
| 121 | * exists and doesn't contain anything important, so we may as well use it. |
| 122 | */ |
| 123 | drm_intel_bo_map(brw->batch.workaround_bo, true); |
| 124 | data = brw->batch.workaround_bo->virtual; |
| 125 | data[offset] = 0xffffffff; |
| 126 | drm_intel_bo_unmap(brw->batch.workaround_bo); |
| 127 | |
| 128 | /* Write OACONTROL. */ |
| 129 | BEGIN_BATCH(3); |
| 130 | OUT_BATCH(MI_LOAD_REGISTER_IMM | (3 - 2)); |
| 131 | OUT_BATCH(OACONTROL); |
| 132 | OUT_BATCH(expected_value); |
| 133 | ADVANCE_BATCH(); |
| 134 | |
| 135 | intel_batchbuffer_emit_mi_flush(brw); |
| 136 | |
| 137 | /* Save the register's value back to the buffer. */ |
| 138 | BEGIN_BATCH(3); |
| 139 | OUT_BATCH(MI_STORE_REGISTER_MEM | (3 - 2)); |
| 140 | OUT_BATCH(OACONTROL); |
| 141 | OUT_RELOC(brw->batch.workaround_bo, |
| 142 | I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION, |
| 143 | offset * sizeof(uint32_t)); |
| 144 | ADVANCE_BATCH(); |
| 145 | |
| 146 | intel_batchbuffer_emit_mi_flush(brw); |
| 147 | |
| 148 | /* Set OACONTROL back to zero (everything off). */ |
| 149 | BEGIN_BATCH(3); |
| 150 | OUT_BATCH(MI_LOAD_REGISTER_IMM | (3 - 2)); |
| 151 | OUT_BATCH(OACONTROL); |
| 152 | OUT_BATCH(0); |
| 153 | ADVANCE_BATCH(); |
| 154 | |
| 155 | intel_batchbuffer_flush(brw); |
| 156 | |
| 157 | /* Check whether the value got written. */ |
| 158 | drm_intel_bo_map(brw->batch.workaround_bo, false); |
Kenneth Graunke | 94841b6 | 2014-09-29 17:00:51 -0700 | [diff] [blame] | 159 | data = brw->batch.workaround_bo->virtual; |
Kenneth Graunke | 7a70f03 | 2013-11-13 15:42:57 -0800 | [diff] [blame] | 160 | bool success = data[offset] == expected_value; |
| 161 | drm_intel_bo_unmap(brw->batch.workaround_bo); |
| 162 | |
Kenneth Graunke | b7f14e0 | 2014-12-22 00:55:37 -0800 | [diff] [blame] | 163 | result = success; |
| 164 | |
Kenneth Graunke | 7a70f03 | 2013-11-13 15:42:57 -0800 | [diff] [blame] | 165 | return success; |
| 166 | } |
| 167 | |
Kenneth Graunke | 129da5b | 2013-05-27 20:09:56 -0700 | [diff] [blame] | 168 | /** |
Brian Paul | 4006c5e | 2009-01-26 12:22:04 -0700 | [diff] [blame] | 169 | * Initializes potential list of extensions if ctx == NULL, or actually enables |
| 170 | * extensions for a context. |
| 171 | */ |
| 172 | void |
Kristian Høgsberg | f9995b3 | 2010-10-12 12:26:10 -0400 | [diff] [blame] | 173 | intelInitExtensions(struct gl_context *ctx) |
Brian Paul | 4006c5e | 2009-01-26 12:22:04 -0700 | [diff] [blame] | 174 | { |
Kenneth Graunke | fbdd389 | 2013-07-03 10:57:11 -0700 | [diff] [blame] | 175 | struct brw_context *brw = brw_context(ctx); |
Brian Paul | 4006c5e | 2009-01-26 12:22:04 -0700 | [diff] [blame] | 176 | |
Kenneth Graunke | 53631be | 2013-07-06 00:36:46 -0700 | [diff] [blame] | 177 | assert(brw->gen >= 4); |
Ian Romanick | 4ed976f | 2013-06-27 18:20:15 -0700 | [diff] [blame] | 178 | |
Eric Anholt | 2f87935 | 2014-02-25 14:25:46 -0800 | [diff] [blame] | 179 | ctx->Extensions.ARB_buffer_storage = true; |
Neil Roberts | 0779f37 | 2014-06-10 16:21:21 +0100 | [diff] [blame] | 180 | ctx->Extensions.ARB_clear_texture = true; |
Mathias Fröhlich | fdd90fc | 2015-03-29 16:52:57 +0200 | [diff] [blame] | 181 | ctx->Extensions.ARB_clip_control = true; |
Jason Ekstrand | 410fea8 | 2014-06-27 16:05:37 -0700 | [diff] [blame] | 182 | ctx->Extensions.ARB_copy_image = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 183 | ctx->Extensions.ARB_depth_buffer_float = true; |
| 184 | ctx->Extensions.ARB_depth_clamp = true; |
Ian Romanick | 4ed976f | 2013-06-27 18:20:15 -0700 | [diff] [blame] | 185 | ctx->Extensions.ARB_depth_texture = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 186 | ctx->Extensions.ARB_draw_elements_base_vertex = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 187 | ctx->Extensions.ARB_draw_instanced = true; |
Ian Romanick | 4ed976f | 2013-06-27 18:20:15 -0700 | [diff] [blame] | 188 | ctx->Extensions.ARB_ES2_compatibility = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 189 | ctx->Extensions.ARB_explicit_attrib_location = true; |
Tapani Pälli | f3750a2 | 2014-03-05 09:39:10 +0200 | [diff] [blame] | 190 | ctx->Extensions.ARB_explicit_uniform_location = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 191 | ctx->Extensions.ARB_fragment_coord_conventions = true; |
Ian Romanick | 4ed976f | 2013-06-27 18:20:15 -0700 | [diff] [blame] | 192 | ctx->Extensions.ARB_fragment_program = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 193 | ctx->Extensions.ARB_fragment_program_shadow = true; |
Ian Romanick | 4ed976f | 2013-06-27 18:20:15 -0700 | [diff] [blame] | 194 | ctx->Extensions.ARB_fragment_shader = true; |
Ian Romanick | bdba4b3 | 2012-12-01 10:56:40 -0800 | [diff] [blame] | 195 | ctx->Extensions.ARB_framebuffer_object = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 196 | ctx->Extensions.ARB_half_float_vertex = true; |
| 197 | ctx->Extensions.ARB_instanced_arrays = true; |
Ian Romanick | 3c00a52 | 2012-12-01 11:06:31 -0800 | [diff] [blame] | 198 | ctx->Extensions.ARB_internalformat_query = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 199 | ctx->Extensions.ARB_map_buffer_range = true; |
Ian Romanick | 4ed976f | 2013-06-27 18:20:15 -0700 | [diff] [blame] | 200 | ctx->Extensions.ARB_occlusion_query = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 201 | ctx->Extensions.ARB_occlusion_query2 = true; |
Ben Widawsky | e206785 | 2014-12-02 18:33:12 -0800 | [diff] [blame] | 202 | ctx->Extensions.ARB_pipeline_statistics_query = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 203 | ctx->Extensions.ARB_point_sprite = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 204 | ctx->Extensions.ARB_seamless_cube_map = true; |
| 205 | ctx->Extensions.ARB_shader_bit_encoding = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 206 | ctx->Extensions.ARB_shader_texture_lod = true; |
Ian Romanick | 4ed976f | 2013-06-27 18:20:15 -0700 | [diff] [blame] | 207 | ctx->Extensions.ARB_shadow = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 208 | ctx->Extensions.ARB_sync = true; |
| 209 | ctx->Extensions.ARB_texture_border_clamp = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 210 | ctx->Extensions.ARB_texture_compression_rgtc = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 211 | ctx->Extensions.ARB_texture_cube_map = true; |
| 212 | ctx->Extensions.ARB_texture_env_combine = true; |
| 213 | ctx->Extensions.ARB_texture_env_crossbar = true; |
| 214 | ctx->Extensions.ARB_texture_env_dot3 = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 215 | ctx->Extensions.ARB_texture_float = true; |
Kenneth Graunke | 2d32821 | 2013-10-20 20:19:53 -0700 | [diff] [blame] | 216 | ctx->Extensions.ARB_texture_mirror_clamp_to_edge = true; |
Ian Romanick | 4ed976f | 2013-06-27 18:20:15 -0700 | [diff] [blame] | 217 | ctx->Extensions.ARB_texture_non_power_of_two = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 218 | ctx->Extensions.ARB_texture_rg = true; |
| 219 | ctx->Extensions.ARB_texture_rgb10_a2ui = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 220 | ctx->Extensions.ARB_vertex_program = true; |
| 221 | ctx->Extensions.ARB_vertex_shader = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 222 | ctx->Extensions.ARB_vertex_type_2_10_10_10_rev = true; |
Chris Forbes | 351e13c | 2014-03-21 23:00:58 +1300 | [diff] [blame] | 223 | ctx->Extensions.ARB_vertex_type_10f_11f_11f_rev = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 224 | ctx->Extensions.EXT_blend_color = true; |
| 225 | ctx->Extensions.EXT_blend_equation_separate = true; |
| 226 | ctx->Extensions.EXT_blend_func_separate = true; |
| 227 | ctx->Extensions.EXT_blend_minmax = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 228 | ctx->Extensions.EXT_draw_buffers2 = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 229 | ctx->Extensions.EXT_framebuffer_sRGB = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 230 | ctx->Extensions.EXT_gpu_program_parameters = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 231 | ctx->Extensions.EXT_packed_float = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 232 | ctx->Extensions.EXT_pixel_buffer_object = true; |
| 233 | ctx->Extensions.EXT_point_parameters = true; |
| 234 | ctx->Extensions.EXT_provoking_vertex = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 235 | ctx->Extensions.EXT_texture_array = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 236 | ctx->Extensions.EXT_texture_env_dot3 = true; |
| 237 | ctx->Extensions.EXT_texture_filter_anisotropic = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 238 | ctx->Extensions.EXT_texture_integer = true; |
| 239 | ctx->Extensions.EXT_texture_shared_exponent = true; |
| 240 | ctx->Extensions.EXT_texture_snorm = true; |
Ian Romanick | 4ed976f | 2013-06-27 18:20:15 -0700 | [diff] [blame] | 241 | ctx->Extensions.EXT_texture_sRGB = true; |
| 242 | ctx->Extensions.EXT_texture_sRGB_decode = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 243 | ctx->Extensions.EXT_texture_swizzle = true; |
Ian Romanick | 4ed976f | 2013-06-27 18:20:15 -0700 | [diff] [blame] | 244 | ctx->Extensions.EXT_stencil_two_side = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 245 | ctx->Extensions.EXT_vertex_array_bgra = true; |
Ian Romanick | 2937d70 | 2013-09-04 11:15:15 -0700 | [diff] [blame] | 246 | ctx->Extensions.AMD_seamless_cubemap_per_texture = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 247 | ctx->Extensions.APPLE_object_purgeable = true; |
Ian Romanick | 4ed976f | 2013-06-27 18:20:15 -0700 | [diff] [blame] | 248 | ctx->Extensions.ATI_separate_stencil = true; |
| 249 | ctx->Extensions.ATI_texture_env_combine3 = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 250 | ctx->Extensions.MESA_pack_invert = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 251 | ctx->Extensions.NV_conditional_render = true; |
| 252 | ctx->Extensions.NV_primitive_restart = true; |
Ian Romanick | 4ed976f | 2013-06-27 18:20:15 -0700 | [diff] [blame] | 253 | ctx->Extensions.NV_texture_env_combine4 = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 254 | ctx->Extensions.NV_texture_rectangle = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 255 | ctx->Extensions.TDFX_texture_compression_FXT1 = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 256 | ctx->Extensions.OES_compressed_ETC1_RGB8_texture = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 257 | ctx->Extensions.OES_EGL_image = true; |
Kenneth Graunke | 8812851 | 2012-05-23 17:06:45 -0700 | [diff] [blame] | 258 | ctx->Extensions.OES_draw_texture = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 259 | ctx->Extensions.OES_standard_derivatives = true; |
Topi Pohjolainen | f5947c2 | 2012-11-12 13:38:08 +0200 | [diff] [blame] | 260 | ctx->Extensions.OES_EGL_image_external = true; |
Chad Versace | a348179 | 2010-10-07 16:04:30 -0700 | [diff] [blame] | 261 | |
Chris Forbes | c4ed6c7 | 2014-09-20 10:39:37 +1200 | [diff] [blame] | 262 | if (brw->gen >= 6) |
Kenneth Graunke | 567445e | 2013-10-17 23:14:23 -0700 | [diff] [blame] | 263 | ctx->Const.GLSLVersion = 330; |
Eric Anholt | 8727807 | 2011-11-08 19:17:47 -0800 | [diff] [blame] | 264 | else |
| 265 | ctx->Const.GLSLVersion = 120; |
Marek Olšák | d9a6f43 | 2014-08-03 03:40:49 +0200 | [diff] [blame] | 266 | _mesa_override_glsl_version(&ctx->Const); |
Kristian Høgsberg | b91dba4 | 2010-09-22 11:01:11 -0400 | [diff] [blame] | 267 | |
Kenneth Graunke | 53631be | 2013-07-06 00:36:46 -0700 | [diff] [blame] | 268 | if (brw->gen >= 6) { |
Ian Romanick | 0b9398c | 2013-06-27 18:20:17 -0700 | [diff] [blame] | 269 | uint64_t dummy; |
| 270 | |
Paul Berry | dc92b2d | 2013-01-28 11:13:07 -0800 | [diff] [blame] | 271 | ctx->Extensions.EXT_framebuffer_multisample = true; |
Kenneth Graunke | 50e60bf | 2013-04-06 10:27:28 -0700 | [diff] [blame] | 272 | ctx->Extensions.EXT_transform_feedback = true; |
Anuj Phogat | 4330fa9 | 2014-09-04 13:49:04 -0700 | [diff] [blame] | 273 | ctx->Extensions.EXT_framebuffer_multisample_blit_scaled = true; |
Kenneth Graunke | fbdd389 | 2013-07-03 10:57:11 -0700 | [diff] [blame] | 274 | ctx->Extensions.ARB_blend_func_extended = !driQueryOptionb(&brw->optionCache, "disable_blend_func_extended"); |
Eric Anholt | b7932e1 | 2012-04-25 13:19:28 -0700 | [diff] [blame] | 275 | ctx->Extensions.ARB_draw_buffers_blend = true; |
Paul Berry | e4f661a | 2012-08-07 12:39:30 -0700 | [diff] [blame] | 276 | ctx->Extensions.ARB_ES3_compatibility = true; |
Eric Anholt | 4a07851 | 2012-06-27 13:46:26 -0700 | [diff] [blame] | 277 | ctx->Extensions.ARB_uniform_buffer_object = true; |
Kenneth Graunke | 46d9baf | 2013-07-17 18:18:00 -0700 | [diff] [blame] | 278 | ctx->Extensions.ARB_shading_language_420pack = true; |
Marek Olšák | afa902a | 2012-12-08 22:53:23 +0100 | [diff] [blame] | 279 | ctx->Extensions.ARB_texture_buffer_object = true; |
Eric Anholt | 5e529d7 | 2013-01-10 14:53:12 -0800 | [diff] [blame] | 280 | ctx->Extensions.ARB_texture_buffer_object_rgb32 = true; |
Eric Anholt | a5e2e7f | 2013-10-04 17:46:04 -0700 | [diff] [blame] | 281 | ctx->Extensions.ARB_texture_buffer_range = true; |
Chris Forbes | 2f7f095 | 2012-11-22 19:24:22 +1300 | [diff] [blame] | 282 | ctx->Extensions.ARB_texture_cube_map_array = true; |
Ian Romanick | 285fe32 | 2013-01-18 15:44:38 -0800 | [diff] [blame] | 283 | ctx->Extensions.OES_depth_texture_cube_map = true; |
Matt Turner | 9aadc3a | 2013-01-22 21:06:12 -0800 | [diff] [blame] | 284 | ctx->Extensions.ARB_shading_language_packing = true; |
Chris Forbes | 1d4dbee | 2012-12-29 21:28:57 +1300 | [diff] [blame] | 285 | ctx->Extensions.ARB_texture_multisample = true; |
Anuj Phogat | 625a631 | 2013-08-30 13:13:15 -0700 | [diff] [blame] | 286 | ctx->Extensions.ARB_sample_shading = true; |
Chris Forbes | 0c14c5c | 2014-02-02 22:00:18 +1300 | [diff] [blame] | 287 | ctx->Extensions.ARB_texture_gather = true; |
Chris Forbes | 06ca96d | 2014-08-19 23:30:50 +1200 | [diff] [blame] | 288 | ctx->Extensions.ARB_conditional_render_inverted = true; |
Samuel Iglesias Gonsalvez | 74d7ff2 | 2014-07-09 13:19:34 +0200 | [diff] [blame] | 289 | ctx->Extensions.AMD_vertex_shader_layer = true; |
Ilia Mirkin | 2ce29ce | 2014-12-31 02:15:23 -0500 | [diff] [blame] | 290 | ctx->Extensions.EXT_polygon_offset_clamp = true; |
Ian Romanick | 0b9398c | 2013-06-27 18:20:17 -0700 | [diff] [blame] | 291 | |
| 292 | /* Test if the kernel has the ioctl. */ |
Kenneth Graunke | eeb75b4 | 2013-07-03 14:09:51 -0700 | [diff] [blame] | 293 | if (drm_intel_reg_read(brw->bufmgr, TIMESTAMP, &dummy) == 0) |
Ian Romanick | 0b9398c | 2013-06-27 18:20:17 -0700 | [diff] [blame] | 294 | ctx->Extensions.ARB_timer_query = true; |
Eric Anholt | b7932e1 | 2012-04-25 13:19:28 -0700 | [diff] [blame] | 295 | } |
| 296 | |
Kenneth Graunke | 53631be | 2013-07-06 00:36:46 -0700 | [diff] [blame] | 297 | if (brw->gen >= 5) { |
Matt Turner | ed6186f | 2013-03-06 14:54:27 -0800 | [diff] [blame] | 298 | ctx->Extensions.ARB_texture_query_lod = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 299 | ctx->Extensions.EXT_timer_query = true; |
Ian Romanick | ea373f0 | 2013-09-12 11:40:00 -0500 | [diff] [blame] | 300 | ctx->Extensions.EXT_shader_integer_mix = ctx->Const.GLSLVersion >= 130; |
Chris Forbes | 317e172 | 2013-10-05 17:11:57 +1300 | [diff] [blame] | 301 | ctx->Extensions.ARB_texture_query_levels = ctx->Const.GLSLVersion >= 130; |
Matt Turner | ed6186f | 2013-03-06 14:54:27 -0800 | [diff] [blame] | 302 | } |
Eric Anholt | 3b68b6c | 2010-05-25 15:32:54 -0700 | [diff] [blame] | 303 | |
Chris Forbes | 7df985a | 2013-03-24 20:18:55 +1300 | [diff] [blame] | 304 | if (brw->gen >= 7) { |
Chris Forbes | 7ec4668 | 2013-10-05 21:40:57 +1300 | [diff] [blame] | 305 | ctx->Extensions.ARB_conservative_depth = true; |
Matt Turner | ff6ee39 | 2015-04-24 11:28:06 -0700 | [diff] [blame^] | 306 | ctx->Extensions.ARB_gpu_shader5 = true; |
| 307 | ctx->Extensions.ARB_shader_atomic_counters = true; |
Kenneth Graunke | ecfc418 | 2014-05-06 16:04:40 -0700 | [diff] [blame] | 308 | ctx->Extensions.ARB_texture_view = true; |
Kenneth Graunke | 129da5b | 2013-05-27 20:09:56 -0700 | [diff] [blame] | 309 | if (can_do_pipelined_register_writes(brw)) { |
| 310 | ctx->Extensions.ARB_transform_feedback2 = true; |
Kenneth Graunke | c4ec0ad | 2013-10-26 13:20:02 -0700 | [diff] [blame] | 311 | ctx->Extensions.ARB_transform_feedback3 = true; |
Kenneth Graunke | 0eeaf11 | 2013-10-26 13:27:18 -0700 | [diff] [blame] | 312 | ctx->Extensions.ARB_transform_feedback_instanced = true; |
Chris Forbes | e6a0eca | 2013-09-30 21:16:40 +1300 | [diff] [blame] | 313 | ctx->Extensions.ARB_draw_indirect = true; |
Kenneth Graunke | 129da5b | 2013-05-27 20:09:56 -0700 | [diff] [blame] | 314 | } |
Courtney Goeltzenleuchter | 7837f42 | 2013-11-13 13:15:19 -0700 | [diff] [blame] | 315 | |
| 316 | /* Only enable this in core profile because other parts of Mesa behave |
| 317 | * slightly differently when the extension is enabled. |
| 318 | */ |
Ilia Mirkin | 7666a9f | 2014-07-02 15:49:39 -0400 | [diff] [blame] | 319 | if (ctx->API == API_OPENGL_CORE) { |
Courtney Goeltzenleuchter | 7837f42 | 2013-11-13 13:15:19 -0700 | [diff] [blame] | 320 | ctx->Extensions.ARB_viewport_array = true; |
Ilia Mirkin | 7666a9f | 2014-07-02 15:49:39 -0400 | [diff] [blame] | 321 | ctx->Extensions.AMD_vertex_shader_viewport_index = true; |
| 322 | } |
Neil Roberts | 9782b8a | 2014-07-17 14:38:20 +0100 | [diff] [blame] | 323 | |
| 324 | ctx->Extensions.ARB_texture_compression_bptc = true; |
Chris Forbes | 654b778 | 2014-08-14 21:11:28 +1200 | [diff] [blame] | 325 | ctx->Extensions.ARB_derivative_control = true; |
Chris Forbes | 7df985a | 2013-03-24 20:18:55 +1300 | [diff] [blame] | 326 | } |
| 327 | |
Kenneth Graunke | dfa1ab0 | 2014-02-23 21:59:25 -0800 | [diff] [blame] | 328 | if (brw->gen >= 8) { |
| 329 | ctx->Extensions.ARB_stencil_texturing = true; |
| 330 | } |
| 331 | |
Petri Latvala | b4363c8 | 2014-04-23 11:08:54 +0300 | [diff] [blame] | 332 | if (brw->gen == 5 || can_write_oacontrol(brw)) { |
Kenneth Graunke | 7a70f03 | 2013-11-13 15:42:57 -0800 | [diff] [blame] | 333 | ctx->Extensions.AMD_performance_monitor = true; |
Petri Latvala | b4363c8 | 2014-04-23 11:08:54 +0300 | [diff] [blame] | 334 | ctx->Extensions.INTEL_performance_query = true; |
| 335 | } |
Kenneth Graunke | 7a70f03 | 2013-11-13 15:42:57 -0800 | [diff] [blame] | 336 | |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 337 | if (ctx->API == API_OPENGL_CORE) |
| 338 | ctx->Extensions.ARB_base_instance = true; |
| 339 | if (ctx->API != API_OPENGL_CORE) |
| 340 | ctx->Extensions.ARB_color_buffer_float = true; |
Ian Romanick | 425c803 | 2009-01-27 23:44:18 -0800 | [diff] [blame] | 341 | |
Kenneth Graunke | e3c2bb1 | 2013-07-03 23:32:20 -0700 | [diff] [blame] | 342 | if (ctx->Mesa_DXTn || driQueryOptionb(&brw->optionCache, "force_s3tc_enable")) |
Ian Romanick | 0a5478c | 2011-08-22 13:18:06 -0700 | [diff] [blame] | 343 | ctx->Extensions.EXT_texture_compression_s3tc = true; |
Ian Romanick | 5bd86b2 | 2012-08-21 15:33:04 -0700 | [diff] [blame] | 344 | |
| 345 | ctx->Extensions.ANGLE_texture_compression_dxt = true; |
Francisco Jerez | 5976345 | 2013-10-20 14:11:27 -0700 | [diff] [blame] | 346 | |
Kalyan Kondapally | e638841 | 2015-01-07 20:30:27 -0800 | [diff] [blame] | 347 | ctx->Extensions.OES_texture_float = true; |
| 348 | ctx->Extensions.OES_texture_float_linear = true; |
| 349 | ctx->Extensions.OES_texture_half_float = true; |
| 350 | ctx->Extensions.OES_texture_half_float_linear = true; |
Brian Paul | 4006c5e | 2009-01-26 12:22:04 -0700 | [diff] [blame] | 351 | } |