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