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 | 129da5b | 2013-05-27 20:09:56 -0700 | [diff] [blame] | 49 | /* We use SO_WRITE_OFFSET0 since you're supposed to write it (unlike the |
| 50 | * statistics registers), and we already reset it to zero before using it. |
| 51 | */ |
| 52 | const int reg = GEN7_SO_WRITE_OFFSET(0); |
| 53 | const int expected_value = 0x1337d0d0; |
| 54 | const int offset = 100; |
| 55 | |
| 56 | /* The register we picked only exists on Gen7+. */ |
Kenneth Graunke | decf070 | 2013-11-04 14:09:07 -0800 | [diff] [blame] | 57 | assert(brw->gen == 7); |
Kenneth Graunke | 129da5b | 2013-05-27 20:09:56 -0700 | [diff] [blame] | 58 | |
| 59 | uint32_t *data; |
| 60 | /* Set a value in a BO to a known quantity. The workaround BO already |
| 61 | * exists and doesn't contain anything important, so we may as well use it. |
| 62 | */ |
| 63 | drm_intel_bo_map(brw->batch.workaround_bo, true); |
| 64 | data = brw->batch.workaround_bo->virtual; |
| 65 | data[offset] = 0xffffffff; |
| 66 | drm_intel_bo_unmap(brw->batch.workaround_bo); |
| 67 | |
| 68 | /* Write the register. */ |
| 69 | BEGIN_BATCH(3); |
| 70 | OUT_BATCH(MI_LOAD_REGISTER_IMM | (3 - 2)); |
| 71 | OUT_BATCH(reg); |
| 72 | OUT_BATCH(expected_value); |
| 73 | ADVANCE_BATCH(); |
| 74 | |
| 75 | intel_batchbuffer_emit_mi_flush(brw); |
| 76 | |
| 77 | /* Save the register's value back to the buffer. */ |
| 78 | BEGIN_BATCH(3); |
| 79 | OUT_BATCH(MI_STORE_REGISTER_MEM | (3 - 2)); |
| 80 | OUT_BATCH(reg); |
| 81 | OUT_RELOC(brw->batch.workaround_bo, |
| 82 | I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION, |
| 83 | offset * sizeof(uint32_t)); |
| 84 | ADVANCE_BATCH(); |
| 85 | |
| 86 | intel_batchbuffer_flush(brw); |
| 87 | |
| 88 | /* Check whether the value got written. */ |
| 89 | drm_intel_bo_map(brw->batch.workaround_bo, false); |
| 90 | bool success = data[offset] == expected_value; |
| 91 | drm_intel_bo_unmap(brw->batch.workaround_bo); |
| 92 | |
| 93 | return success; |
| 94 | } |
| 95 | |
Kenneth Graunke | 7a70f03 | 2013-11-13 15:42:57 -0800 | [diff] [blame] | 96 | static bool |
| 97 | can_write_oacontrol(struct brw_context *brw) |
| 98 | { |
| 99 | if (brw->gen < 6 || brw->gen >= 8) |
| 100 | return false; |
| 101 | |
| 102 | /* Set "Select Context ID" to a particular address (which is likely not a |
| 103 | * context), but leave all counting disabled. This should be harmless. |
| 104 | */ |
| 105 | const int expected_value = 0x31337000; |
| 106 | const int offset = 110; |
| 107 | |
| 108 | uint32_t *data; |
| 109 | /* Set a value in a BO to a known quantity. The workaround BO already |
| 110 | * exists and doesn't contain anything important, so we may as well use it. |
| 111 | */ |
| 112 | drm_intel_bo_map(brw->batch.workaround_bo, true); |
| 113 | data = brw->batch.workaround_bo->virtual; |
| 114 | data[offset] = 0xffffffff; |
| 115 | drm_intel_bo_unmap(brw->batch.workaround_bo); |
| 116 | |
| 117 | /* Write OACONTROL. */ |
| 118 | BEGIN_BATCH(3); |
| 119 | OUT_BATCH(MI_LOAD_REGISTER_IMM | (3 - 2)); |
| 120 | OUT_BATCH(OACONTROL); |
| 121 | OUT_BATCH(expected_value); |
| 122 | ADVANCE_BATCH(); |
| 123 | |
| 124 | intel_batchbuffer_emit_mi_flush(brw); |
| 125 | |
| 126 | /* Save the register's value back to the buffer. */ |
| 127 | BEGIN_BATCH(3); |
| 128 | OUT_BATCH(MI_STORE_REGISTER_MEM | (3 - 2)); |
| 129 | OUT_BATCH(OACONTROL); |
| 130 | OUT_RELOC(brw->batch.workaround_bo, |
| 131 | I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION, |
| 132 | offset * sizeof(uint32_t)); |
| 133 | ADVANCE_BATCH(); |
| 134 | |
| 135 | intel_batchbuffer_emit_mi_flush(brw); |
| 136 | |
| 137 | /* Set OACONTROL back to zero (everything off). */ |
| 138 | BEGIN_BATCH(3); |
| 139 | OUT_BATCH(MI_LOAD_REGISTER_IMM | (3 - 2)); |
| 140 | OUT_BATCH(OACONTROL); |
| 141 | OUT_BATCH(0); |
| 142 | ADVANCE_BATCH(); |
| 143 | |
| 144 | intel_batchbuffer_flush(brw); |
| 145 | |
| 146 | /* Check whether the value got written. */ |
| 147 | drm_intel_bo_map(brw->batch.workaround_bo, false); |
| 148 | bool success = data[offset] == expected_value; |
| 149 | drm_intel_bo_unmap(brw->batch.workaround_bo); |
| 150 | |
| 151 | return success; |
| 152 | } |
| 153 | |
Kenneth Graunke | 129da5b | 2013-05-27 20:09:56 -0700 | [diff] [blame] | 154 | /** |
Brian Paul | 4006c5e | 2009-01-26 12:22:04 -0700 | [diff] [blame] | 155 | * Initializes potential list of extensions if ctx == NULL, or actually enables |
| 156 | * extensions for a context. |
| 157 | */ |
| 158 | void |
Kristian Høgsberg | f9995b3 | 2010-10-12 12:26:10 -0400 | [diff] [blame] | 159 | intelInitExtensions(struct gl_context *ctx) |
Brian Paul | 4006c5e | 2009-01-26 12:22:04 -0700 | [diff] [blame] | 160 | { |
Kenneth Graunke | fbdd389 | 2013-07-03 10:57:11 -0700 | [diff] [blame] | 161 | struct brw_context *brw = brw_context(ctx); |
Brian Paul | 4006c5e | 2009-01-26 12:22:04 -0700 | [diff] [blame] | 162 | |
Kenneth Graunke | 53631be | 2013-07-06 00:36:46 -0700 | [diff] [blame] | 163 | assert(brw->gen >= 4); |
Ian Romanick | 4ed976f | 2013-06-27 18:20:15 -0700 | [diff] [blame] | 164 | |
Eric Anholt | 2f87935 | 2014-02-25 14:25:46 -0800 | [diff] [blame] | 165 | ctx->Extensions.ARB_buffer_storage = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 166 | ctx->Extensions.ARB_depth_buffer_float = true; |
| 167 | ctx->Extensions.ARB_depth_clamp = true; |
Ian Romanick | 4ed976f | 2013-06-27 18:20:15 -0700 | [diff] [blame] | 168 | ctx->Extensions.ARB_depth_texture = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 169 | ctx->Extensions.ARB_draw_elements_base_vertex = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 170 | ctx->Extensions.ARB_draw_instanced = true; |
Ian Romanick | 4ed976f | 2013-06-27 18:20:15 -0700 | [diff] [blame] | 171 | ctx->Extensions.ARB_ES2_compatibility = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 172 | ctx->Extensions.ARB_explicit_attrib_location = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 173 | ctx->Extensions.ARB_fragment_coord_conventions = true; |
Ian Romanick | 4ed976f | 2013-06-27 18:20:15 -0700 | [diff] [blame] | 174 | ctx->Extensions.ARB_fragment_program = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 175 | ctx->Extensions.ARB_fragment_program_shadow = true; |
Ian Romanick | 4ed976f | 2013-06-27 18:20:15 -0700 | [diff] [blame] | 176 | ctx->Extensions.ARB_fragment_shader = true; |
Ian Romanick | bdba4b3 | 2012-12-01 10:56:40 -0800 | [diff] [blame] | 177 | ctx->Extensions.ARB_framebuffer_object = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 178 | ctx->Extensions.ARB_half_float_vertex = true; |
| 179 | ctx->Extensions.ARB_instanced_arrays = true; |
Ian Romanick | 3c00a52 | 2012-12-01 11:06:31 -0800 | [diff] [blame] | 180 | ctx->Extensions.ARB_internalformat_query = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 181 | ctx->Extensions.ARB_map_buffer_range = true; |
Ian Romanick | 4ed976f | 2013-06-27 18:20:15 -0700 | [diff] [blame] | 182 | ctx->Extensions.ARB_occlusion_query = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 183 | ctx->Extensions.ARB_occlusion_query2 = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 184 | ctx->Extensions.ARB_point_sprite = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 185 | ctx->Extensions.ARB_seamless_cube_map = true; |
| 186 | ctx->Extensions.ARB_shader_bit_encoding = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 187 | ctx->Extensions.ARB_shader_texture_lod = true; |
Ian Romanick | 4ed976f | 2013-06-27 18:20:15 -0700 | [diff] [blame] | 188 | ctx->Extensions.ARB_shadow = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 189 | ctx->Extensions.ARB_sync = true; |
| 190 | ctx->Extensions.ARB_texture_border_clamp = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 191 | ctx->Extensions.ARB_texture_compression_rgtc = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 192 | ctx->Extensions.ARB_texture_cube_map = true; |
| 193 | ctx->Extensions.ARB_texture_env_combine = true; |
| 194 | ctx->Extensions.ARB_texture_env_crossbar = true; |
| 195 | ctx->Extensions.ARB_texture_env_dot3 = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 196 | ctx->Extensions.ARB_texture_float = true; |
Kenneth Graunke | 2d32821 | 2013-10-20 20:19:53 -0700 | [diff] [blame] | 197 | ctx->Extensions.ARB_texture_mirror_clamp_to_edge = true; |
Ian Romanick | 4ed976f | 2013-06-27 18:20:15 -0700 | [diff] [blame] | 198 | ctx->Extensions.ARB_texture_non_power_of_two = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 199 | ctx->Extensions.ARB_texture_rg = true; |
| 200 | ctx->Extensions.ARB_texture_rgb10_a2ui = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 201 | ctx->Extensions.ARB_vertex_program = true; |
| 202 | ctx->Extensions.ARB_vertex_shader = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 203 | ctx->Extensions.ARB_vertex_type_2_10_10_10_rev = true; |
Chris Forbes | 351e13c | 2014-03-21 23:00:58 +1300 | [diff] [blame^] | 204 | ctx->Extensions.ARB_vertex_type_10f_11f_11f_rev = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 205 | ctx->Extensions.EXT_blend_color = true; |
| 206 | ctx->Extensions.EXT_blend_equation_separate = true; |
| 207 | ctx->Extensions.EXT_blend_func_separate = true; |
| 208 | ctx->Extensions.EXT_blend_minmax = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 209 | ctx->Extensions.EXT_draw_buffers2 = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 210 | ctx->Extensions.EXT_framebuffer_sRGB = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 211 | ctx->Extensions.EXT_gpu_program_parameters = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 212 | ctx->Extensions.EXT_packed_float = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 213 | ctx->Extensions.EXT_pixel_buffer_object = true; |
| 214 | ctx->Extensions.EXT_point_parameters = true; |
| 215 | ctx->Extensions.EXT_provoking_vertex = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 216 | ctx->Extensions.EXT_separate_shader_objects = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 217 | ctx->Extensions.EXT_texture_array = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 218 | ctx->Extensions.EXT_texture_env_dot3 = true; |
| 219 | ctx->Extensions.EXT_texture_filter_anisotropic = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 220 | ctx->Extensions.EXT_texture_integer = true; |
| 221 | ctx->Extensions.EXT_texture_shared_exponent = true; |
| 222 | ctx->Extensions.EXT_texture_snorm = true; |
Ian Romanick | 4ed976f | 2013-06-27 18:20:15 -0700 | [diff] [blame] | 223 | ctx->Extensions.EXT_texture_sRGB = true; |
| 224 | ctx->Extensions.EXT_texture_sRGB_decode = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 225 | ctx->Extensions.EXT_texture_swizzle = true; |
Ian Romanick | 4ed976f | 2013-06-27 18:20:15 -0700 | [diff] [blame] | 226 | ctx->Extensions.EXT_stencil_two_side = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 227 | ctx->Extensions.EXT_vertex_array_bgra = true; |
Ian Romanick | 2937d70 | 2013-09-04 11:15:15 -0700 | [diff] [blame] | 228 | ctx->Extensions.AMD_seamless_cubemap_per_texture = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 229 | ctx->Extensions.APPLE_object_purgeable = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 230 | ctx->Extensions.ATI_envmap_bumpmap = true; |
Ian Romanick | 4ed976f | 2013-06-27 18:20:15 -0700 | [diff] [blame] | 231 | ctx->Extensions.ATI_separate_stencil = true; |
| 232 | ctx->Extensions.ATI_texture_env_combine3 = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 233 | ctx->Extensions.MESA_pack_invert = true; |
| 234 | ctx->Extensions.MESA_ycbcr_texture = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 235 | ctx->Extensions.NV_conditional_render = true; |
| 236 | ctx->Extensions.NV_primitive_restart = true; |
Ian Romanick | 4ed976f | 2013-06-27 18:20:15 -0700 | [diff] [blame] | 237 | ctx->Extensions.NV_texture_env_combine4 = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 238 | ctx->Extensions.NV_texture_rectangle = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 239 | ctx->Extensions.TDFX_texture_compression_FXT1 = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 240 | ctx->Extensions.OES_compressed_ETC1_RGB8_texture = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 241 | ctx->Extensions.OES_EGL_image = true; |
Kenneth Graunke | 8812851 | 2012-05-23 17:06:45 -0700 | [diff] [blame] | 242 | ctx->Extensions.OES_draw_texture = true; |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 243 | ctx->Extensions.OES_standard_derivatives = true; |
Topi Pohjolainen | f5947c2 | 2012-11-12 13:38:08 +0200 | [diff] [blame] | 244 | ctx->Extensions.OES_EGL_image_external = true; |
Chad Versace | a348179 | 2010-10-07 16:04:30 -0700 | [diff] [blame] | 245 | |
Paul Berry | b6d6ea3 | 2013-03-22 14:41:17 -0700 | [diff] [blame] | 246 | if (brw->gen >= 7) |
Kenneth Graunke | 567445e | 2013-10-17 23:14:23 -0700 | [diff] [blame] | 247 | ctx->Const.GLSLVersion = 330; |
Paul Berry | b6d6ea3 | 2013-03-22 14:41:17 -0700 | [diff] [blame] | 248 | else if (brw->gen >= 6) |
Marek Olšák | 0ac83a2 | 2012-12-08 22:48:47 +0100 | [diff] [blame] | 249 | ctx->Const.GLSLVersion = 140; |
Eric Anholt | 8727807 | 2011-11-08 19:17:47 -0800 | [diff] [blame] | 250 | else |
| 251 | ctx->Const.GLSLVersion = 120; |
Chad Versace | a1eff55 | 2011-09-27 13:53:11 -0700 | [diff] [blame] | 252 | _mesa_override_glsl_version(ctx); |
Kristian Høgsberg | b91dba4 | 2010-09-22 11:01:11 -0400 | [diff] [blame] | 253 | |
Kenneth Graunke | 53631be | 2013-07-06 00:36:46 -0700 | [diff] [blame] | 254 | if (brw->gen >= 6) { |
Ian Romanick | 0b9398c | 2013-06-27 18:20:17 -0700 | [diff] [blame] | 255 | uint64_t dummy; |
| 256 | |
Paul Berry | dc92b2d | 2013-01-28 11:13:07 -0800 | [diff] [blame] | 257 | ctx->Extensions.EXT_framebuffer_multisample = true; |
Kenneth Graunke | 50e60bf | 2013-04-06 10:27:28 -0700 | [diff] [blame] | 258 | ctx->Extensions.EXT_transform_feedback = true; |
Anuj Phogat | 722721d | 2013-05-14 08:15:59 -0700 | [diff] [blame] | 259 | ctx->Extensions.EXT_framebuffer_multisample_blit_scaled = true; |
Kenneth Graunke | fbdd389 | 2013-07-03 10:57:11 -0700 | [diff] [blame] | 260 | 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] | 261 | ctx->Extensions.ARB_draw_buffers_blend = true; |
Paul Berry | e4f661a | 2012-08-07 12:39:30 -0700 | [diff] [blame] | 262 | ctx->Extensions.ARB_ES3_compatibility = true; |
Eric Anholt | 4a07851 | 2012-06-27 13:46:26 -0700 | [diff] [blame] | 263 | ctx->Extensions.ARB_uniform_buffer_object = true; |
Kenneth Graunke | 46d9baf | 2013-07-17 18:18:00 -0700 | [diff] [blame] | 264 | ctx->Extensions.ARB_shading_language_420pack = true; |
Marek Olšák | afa902a | 2012-12-08 22:53:23 +0100 | [diff] [blame] | 265 | ctx->Extensions.ARB_texture_buffer_object = true; |
Eric Anholt | 5e529d7 | 2013-01-10 14:53:12 -0800 | [diff] [blame] | 266 | ctx->Extensions.ARB_texture_buffer_object_rgb32 = true; |
Eric Anholt | a5e2e7f | 2013-10-04 17:46:04 -0700 | [diff] [blame] | 267 | ctx->Extensions.ARB_texture_buffer_range = true; |
Chris Forbes | 2f7f095 | 2012-11-22 19:24:22 +1300 | [diff] [blame] | 268 | ctx->Extensions.ARB_texture_cube_map_array = true; |
Ian Romanick | 285fe32 | 2013-01-18 15:44:38 -0800 | [diff] [blame] | 269 | ctx->Extensions.OES_depth_texture_cube_map = true; |
Matt Turner | 9aadc3a | 2013-01-22 21:06:12 -0800 | [diff] [blame] | 270 | ctx->Extensions.ARB_shading_language_packing = true; |
Chris Forbes | 1d4dbee | 2012-12-29 21:28:57 +1300 | [diff] [blame] | 271 | ctx->Extensions.ARB_texture_multisample = true; |
Anuj Phogat | 625a631 | 2013-08-30 13:13:15 -0700 | [diff] [blame] | 272 | ctx->Extensions.ARB_sample_shading = true; |
Chris Forbes | 0c14c5c | 2014-02-02 22:00:18 +1300 | [diff] [blame] | 273 | ctx->Extensions.ARB_texture_gather = true; |
Ian Romanick | 0b9398c | 2013-06-27 18:20:17 -0700 | [diff] [blame] | 274 | |
| 275 | /* Test if the kernel has the ioctl. */ |
Kenneth Graunke | eeb75b4 | 2013-07-03 14:09:51 -0700 | [diff] [blame] | 276 | if (drm_intel_reg_read(brw->bufmgr, TIMESTAMP, &dummy) == 0) |
Ian Romanick | 0b9398c | 2013-06-27 18:20:17 -0700 | [diff] [blame] | 277 | ctx->Extensions.ARB_timer_query = true; |
Eric Anholt | b7932e1 | 2012-04-25 13:19:28 -0700 | [diff] [blame] | 278 | } |
| 279 | |
Kenneth Graunke | 53631be | 2013-07-06 00:36:46 -0700 | [diff] [blame] | 280 | if (brw->gen >= 5) { |
Matt Turner | ed6186f | 2013-03-06 14:54:27 -0800 | [diff] [blame] | 281 | ctx->Extensions.ARB_texture_query_lod = true; |
Ian Romanick | 71cecca | 2011-08-22 13:15:42 -0700 | [diff] [blame] | 282 | ctx->Extensions.EXT_timer_query = true; |
Ian Romanick | ea373f0 | 2013-09-12 11:40:00 -0500 | [diff] [blame] | 283 | ctx->Extensions.EXT_shader_integer_mix = ctx->Const.GLSLVersion >= 130; |
Chris Forbes | 317e172 | 2013-10-05 17:11:57 +1300 | [diff] [blame] | 284 | ctx->Extensions.ARB_texture_query_levels = ctx->Const.GLSLVersion >= 130; |
Matt Turner | ed6186f | 2013-03-06 14:54:27 -0800 | [diff] [blame] | 285 | } |
Eric Anholt | 3b68b6c | 2010-05-25 15:32:54 -0700 | [diff] [blame] | 286 | |
Chris Forbes | 7df985a | 2013-03-24 20:18:55 +1300 | [diff] [blame] | 287 | if (brw->gen >= 7) { |
Chris Forbes | 7ec4668 | 2013-10-05 21:40:57 +1300 | [diff] [blame] | 288 | ctx->Extensions.ARB_conservative_depth = true; |
Jordan Justen | bd00c66 | 2013-03-27 13:58:52 -0700 | [diff] [blame] | 289 | ctx->Extensions.AMD_vertex_shader_layer = true; |
Kenneth Graunke | 129da5b | 2013-05-27 20:09:56 -0700 | [diff] [blame] | 290 | if (can_do_pipelined_register_writes(brw)) { |
| 291 | ctx->Extensions.ARB_transform_feedback2 = true; |
Kenneth Graunke | c4ec0ad | 2013-10-26 13:20:02 -0700 | [diff] [blame] | 292 | ctx->Extensions.ARB_transform_feedback3 = true; |
Kenneth Graunke | 0eeaf11 | 2013-10-26 13:27:18 -0700 | [diff] [blame] | 293 | ctx->Extensions.ARB_transform_feedback_instanced = true; |
Chris Forbes | e6a0eca | 2013-09-30 21:16:40 +1300 | [diff] [blame] | 294 | ctx->Extensions.ARB_draw_indirect = true; |
Kenneth Graunke | 129da5b | 2013-05-27 20:09:56 -0700 | [diff] [blame] | 295 | } |
Courtney Goeltzenleuchter | 7837f42 | 2013-11-13 13:15:19 -0700 | [diff] [blame] | 296 | |
| 297 | /* Only enable this in core profile because other parts of Mesa behave |
| 298 | * slightly differently when the extension is enabled. |
| 299 | */ |
| 300 | if (ctx->API == API_OPENGL_CORE) |
| 301 | ctx->Extensions.ARB_viewport_array = true; |
Paul Berry | 25268b9 | 2014-01-06 15:12:05 -0800 | [diff] [blame] | 302 | |
| 303 | if (getenv("INTEL_COMPUTE_SHADER")) |
| 304 | ctx->Extensions.ARB_compute_shader = true; |
Chris Forbes | 7df985a | 2013-03-24 20:18:55 +1300 | [diff] [blame] | 305 | } |
| 306 | |
Kenneth Graunke | dfa1ab0 | 2014-02-23 21:59:25 -0800 | [diff] [blame] | 307 | if (brw->gen >= 8) { |
| 308 | ctx->Extensions.ARB_stencil_texturing = true; |
| 309 | } |
| 310 | |
Kenneth Graunke | 7a70f03 | 2013-11-13 15:42:57 -0800 | [diff] [blame] | 311 | if (brw->gen == 5 || can_write_oacontrol(brw)) |
| 312 | ctx->Extensions.AMD_performance_monitor = true; |
| 313 | |
Ian Romanick | ae66a65 | 2013-06-27 18:20:16 -0700 | [diff] [blame] | 314 | if (ctx->API == API_OPENGL_CORE) |
| 315 | ctx->Extensions.ARB_base_instance = true; |
| 316 | if (ctx->API != API_OPENGL_CORE) |
| 317 | ctx->Extensions.ARB_color_buffer_float = true; |
Ian Romanick | 425c803 | 2009-01-27 23:44:18 -0800 | [diff] [blame] | 318 | |
Kenneth Graunke | e3c2bb1 | 2013-07-03 23:32:20 -0700 | [diff] [blame] | 319 | if (ctx->Mesa_DXTn || driQueryOptionb(&brw->optionCache, "force_s3tc_enable")) |
Ian Romanick | 0a5478c | 2011-08-22 13:18:06 -0700 | [diff] [blame] | 320 | ctx->Extensions.EXT_texture_compression_s3tc = true; |
Ian Romanick | 5bd86b2 | 2012-08-21 15:33:04 -0700 | [diff] [blame] | 321 | |
| 322 | ctx->Extensions.ANGLE_texture_compression_dxt = true; |
Francisco Jerez | 5976345 | 2013-10-20 14:11:27 -0700 | [diff] [blame] | 323 | |
| 324 | if (brw->gen >= 7) |
| 325 | ctx->Extensions.ARB_shader_atomic_counters = true; |
Brian Paul | 4006c5e | 2009-01-26 12:22:04 -0700 | [diff] [blame] | 326 | } |