blob: dd3e20180afde040bdd3dd894d089b7ff83b955f [file] [log] [blame]
Eric Anholt9f344b32006-08-09 19:14:05 +00001/*
Ian Romanick2b81cef2015-06-10 17:09:16 -07002 * Copyright (C) Intel Corp. 2006. All Rights Reserved.
3 * Intel funded Tungsten Graphics to
4 * develop this 3D driver.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a 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, sublicense, 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:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial
16 * portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
Eric Anholt9f344b32006-08-09 19:14:05 +000026#include "brw_context.h"
Eric Anholt9f344b32006-08-09 19:14:05 +000027#include "brw_wm.h"
28#include "brw_state.h"
Kristian Høgsberg Kristensen84f2ed22015-09-04 16:55:03 -070029#include "brw_shader.h"
Chris Forbescfa3c8a2013-08-11 09:55:30 +120030#include "main/enums.h"
Eric Anholtc3744872010-08-10 22:21:59 -070031#include "main/formats.h"
Brian Paul4433b032012-04-20 07:58:59 -060032#include "main/fbobject.h"
Eric Anholt1f32c662011-04-20 11:48:31 -070033#include "main/samplerobj.h"
Kevin Rogovin41b6db22015-06-17 13:29:55 +030034#include "main/framebuffer.h"
Eric Anholt87527642011-05-16 15:10:26 -070035#include "program/prog_parameter.h"
Anuj Phogat65d04522013-10-24 15:53:05 -070036#include "program/program.h"
Chris Forbes27359b82013-11-30 10:01:12 +130037#include "intel_mipmap_tree.h"
Kristian Høgsberg Kristensen654e9502016-05-01 21:22:54 -070038#include "intel_image.h"
Jason Ekstrand30c63572015-09-30 17:01:03 -070039#include "brw_nir.h"
Matt Turnerecac1aa2015-11-22 15:30:59 -080040#include "brw_program.h"
Eric Anholt9f344b32006-08-09 19:14:05 +000041
Kenneth Graunke1e0da622014-02-24 23:39:14 -080042#include "util/ralloc.h"
Kenneth Graunke774fb902011-05-16 11:49:57 -070043
Jason Ekstrandea006c42015-10-01 08:55:20 -070044static void
Jason Ekstrand527f3712016-08-22 15:01:08 -070045assign_fs_binding_table_offsets(const struct gen_device_info *devinfo,
Jason Ekstrandea006c42015-10-01 08:55:20 -070046 const struct gl_program *prog,
47 const struct brw_wm_prog_key *key,
48 struct brw_wm_prog_data *prog_data)
49{
50 uint32_t next_binding_table_offset = 0;
51
52 /* If there are no color regions, we still perform an FB write to a null
53 * renderbuffer, which we place at surface index 0.
54 */
55 prog_data->binding_table.render_target_start = next_binding_table_offset;
56 next_binding_table_offset += MAX2(key->nr_color_regions, 1);
57
Francisco Jerez08705ba2016-07-01 13:46:40 -070058 next_binding_table_offset =
Timothy Arceri9ca14f52016-11-05 09:34:52 +110059 brw_assign_common_binding_table_offsets(devinfo, prog, &prog_data->base,
Francisco Jerez08705ba2016-07-01 13:46:40 -070060 next_binding_table_offset);
61
Timothy Arcerie1af20f2016-10-13 11:41:23 +110062 if (prog->nir->info->outputs_read && !key->coherent_fb_fetch) {
Francisco Jerez08705ba2016-07-01 13:46:40 -070063 prog_data->binding_table.render_target_read_start =
64 next_binding_table_offset;
65 next_binding_table_offset += key->nr_color_regions;
66 }
Jason Ekstrandea006c42015-10-01 08:55:20 -070067}
68
Timothy Arceri6f76ca32016-11-04 14:09:35 +110069static void
70brw_wm_debug_recompile(struct brw_context *brw, struct gl_program *prog,
71 const struct brw_wm_prog_key *key)
72{
Timothy Arceri6f76ca32016-11-04 14:09:35 +110073 perf_debug("Recompiling fragment shader for program %d\n", prog->Id);
74
Kenneth Graunkef9edc552016-11-11 13:31:06 -080075 bool found = false;
76 const struct brw_wm_prog_key *old_key =
77 brw_find_previous_compile(&brw->cache, BRW_CACHE_FS_PROG,
78 key->program_string_id);
Timothy Arceri6f76ca32016-11-04 14:09:35 +110079
Kenneth Graunkef9edc552016-11-11 13:31:06 -080080 if (!old_key) {
Timothy Arceri6f76ca32016-11-04 14:09:35 +110081 perf_debug(" Didn't find previous compile in the shader cache for debug\n");
82 return;
83 }
84
85 found |= key_debug(brw, "alphatest, computed depth, depth test, or "
86 "depth write",
87 old_key->iz_lookup, key->iz_lookup);
88 found |= key_debug(brw, "depth statistics",
89 old_key->stats_wm, key->stats_wm);
90 found |= key_debug(brw, "flat shading",
91 old_key->flat_shade, key->flat_shade);
92 found |= key_debug(brw, "per-sample interpolation",
93 old_key->persample_interp, key->persample_interp);
94 found |= key_debug(brw, "number of color buffers",
95 old_key->nr_color_regions, key->nr_color_regions);
96 found |= key_debug(brw, "MRT alpha test or alpha-to-coverage",
97 old_key->replicate_alpha, key->replicate_alpha);
98 found |= key_debug(brw, "fragment color clamping",
99 old_key->clamp_fragment_color, key->clamp_fragment_color);
100 found |= key_debug(brw, "multisampled FBO",
101 old_key->multisample_fbo, key->multisample_fbo);
102 found |= key_debug(brw, "line smoothing",
103 old_key->line_aa, key->line_aa);
104 found |= key_debug(brw, "input slots valid",
105 old_key->input_slots_valid, key->input_slots_valid);
106 found |= key_debug(brw, "mrt alpha test function",
107 old_key->alpha_test_func, key->alpha_test_func);
108 found |= key_debug(brw, "mrt alpha test reference value",
109 old_key->alpha_test_ref, key->alpha_test_ref);
110
111 found |= brw_debug_recompile_sampler_key(brw, &old_key->tex, &key->tex);
112
113 if (!found) {
114 perf_debug(" Something else\n");
115 }
116}
117
Brian Paul2f78d4a2009-02-12 15:35:41 -0700118/**
119 * All Mesa program -> GPU code generation goes through this function.
120 * Depending on the instructions used (i.e. flow control instructions)
121 * we'll use one of two code generators.
122 */
Timothy Arceri6e3f6092016-11-04 16:04:01 +1100123static bool
Jason Ekstranda85c4c92015-04-16 11:06:57 -0700124brw_codegen_wm_prog(struct brw_context *brw,
Timothy Arceri13d0cf52016-10-18 16:17:14 +1100125 struct brw_program *fp,
Timothy Arceri91d61fb2016-10-20 09:59:00 +1100126 struct brw_wm_prog_key *key,
127 struct brw_vue_map *vue_map)
Eric Anholt9f344b32006-08-09 19:14:05 +0000128{
Lionel Landwerlin94d0e7d2016-09-23 00:41:23 +0300129 const struct gen_device_info *devinfo = &brw->screen->devinfo;
Kenneth Graunke5a51a262014-01-18 14:48:11 -0800130 struct gl_context *ctx = &brw->ctx;
Kenneth Graunke2d4ac9b2014-05-14 01:21:02 -0700131 void *mem_ctx = ralloc_context(NULL);
Kenneth Graunke09b4f262014-05-14 01:35:30 -0700132 struct brw_wm_prog_data prog_data;
Eric Anholt9f344b32006-08-09 19:14:05 +0000133 const GLuint *program;
134 GLuint program_size;
Kristian Høgsberg Kristensena548c752015-09-04 17:09:40 -0700135 bool start_busy = false;
136 double start_time = 0;
Eric Anholt9f344b32006-08-09 19:14:05 +0000137
Kenneth Graunke09b4f262014-05-14 01:35:30 -0700138 memset(&prog_data, 0, sizeof(prog_data));
Francisco Jerez786e0852015-02-09 21:04:53 +0200139
Kenneth Graunke7b6620f2014-11-30 01:35:14 -0800140 /* Use ALT floating point mode for ARB programs so that 0^0 == 1. */
Timothy Arceri23848682016-11-09 23:44:39 +1100141 if (fp->program.is_arb_asm)
Kenneth Graunke7b6620f2014-11-30 01:35:14 -0800142 prog_data.base.use_alt_mode = true;
143
Timothy Arceri9ca14f52016-11-05 09:34:52 +1100144 assign_fs_binding_table_offsets(devinfo, &fp->program, key, &prog_data);
Jason Ekstrandea006c42015-10-01 08:55:20 -0700145
Eric Anholtf144b782012-08-26 21:19:05 -0700146 /* Allocate the references to the uniforms that will end up in the
147 * prog_data associated with the compiled program, and which will be freed
148 * by the state cache.
149 */
Timothy Arceri34234882016-10-19 13:23:37 +1100150 int param_count = fp->program.nir->num_uniforms / 4;
Timothy Arceriba40c8b2016-10-27 15:59:46 +1100151 prog_data.base.nr_image_params = fp->program.info.num_images;
Eric Anholta43b1072012-11-08 14:02:22 -0800152 /* The backend also sometimes adds params for texture size. */
Kenneth Graunke5a51a262014-01-18 14:48:11 -0800153 param_count += 2 * ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits;
Neil Roberts2c502122014-08-11 12:21:44 +0100154 prog_data.base.param =
155 rzalloc_array(NULL, const gl_constant_value *, param_count);
Kenneth Graunke09b4f262014-05-14 01:35:30 -0700156 prog_data.base.pull_param =
Neil Roberts2c502122014-08-11 12:21:44 +0100157 rzalloc_array(NULL, const gl_constant_value *, param_count);
Francisco Jerez87a3e022015-01-21 17:34:49 +0200158 prog_data.base.image_param =
159 rzalloc_array(NULL, struct brw_image_param,
160 prog_data.base.nr_image_params);
Kenneth Graunke09b4f262014-05-14 01:35:30 -0700161 prog_data.base.nr_params = param_count;
Eric Anholtf144b782012-08-26 21:19:05 -0700162
Timothy Arceri23848682016-11-09 23:44:39 +1100163 if (!fp->program.is_arb_asm) {
Timothy Arceri2a4d1692016-11-07 20:54:45 +1100164 brw_nir_setup_glsl_uniforms(fp->program.nir, &fp->program,
Jason Ekstrand30c63572015-09-30 17:01:03 -0700165 &prog_data.base, true);
166 } else {
Timothy Arceri34234882016-10-19 13:23:37 +1100167 brw_nir_setup_arb_uniforms(fp->program.nir, &fp->program,
Jason Ekstrand30c63572015-09-30 17:01:03 -0700168 &prog_data.base);
Timothy Arceric3b8bf92016-11-03 21:47:04 +1100169
170 if (unlikely(INTEL_DEBUG & DEBUG_WM))
171 brw_dump_arb_asm("fragment", &fp->program);
Jason Ekstrand30c63572015-09-30 17:01:03 -0700172 }
173
Kristian Høgsberg Kristensena548c752015-09-04 17:09:40 -0700174 if (unlikely(brw->perf_debug)) {
175 start_busy = (brw->batch.last_bo &&
176 drm_intel_bo_busy(brw->batch.last_bo));
177 start_time = get_time();
178 }
179
Kristian Høgsberg Kristensenee0f0102015-10-07 05:06:30 -0700180 int st_index8 = -1, st_index16 = -1;
181 if (INTEL_DEBUG & DEBUG_SHADER_TIME) {
Timothy Arceri6643da62016-12-20 21:37:23 +1100182 st_index8 = brw_get_shader_time_index(brw, &fp->program, ST_FS8,
Timothy Arceri23848682016-11-09 23:44:39 +1100183 !fp->program.is_arb_asm);
Timothy Arceri6643da62016-12-20 21:37:23 +1100184 st_index16 = brw_get_shader_time_index(brw, &fp->program, ST_FS16,
Timothy Arceri23848682016-11-09 23:44:39 +1100185 !fp->program.is_arb_asm);
Kristian Høgsberg Kristensenee0f0102015-10-07 05:06:30 -0700186 }
187
Jason Ekstrand22ad4492015-10-05 19:27:28 -0700188 char *error_str = NULL;
Kenneth Graunke9694b232015-11-30 15:47:13 -0800189 program = brw_compile_fs(brw->screen->compiler, brw, mem_ctx,
Timothy Arceri34234882016-10-19 13:23:37 +1100190 key, &prog_data, fp->program.nir,
191 &fp->program, st_index8, st_index16,
Timothy Arceri91d61fb2016-10-20 09:59:00 +1100192 true, brw->use_rep_send, vue_map,
Jason Ekstrand265487a2016-05-16 14:30:25 -0700193 &program_size, &error_str);
Timothy Arceri91d61fb2016-10-20 09:59:00 +1100194
Kenneth Graunke81b11bf2014-05-14 01:04:02 -0700195 if (program == NULL) {
Timothy Arceri23848682016-11-09 23:44:39 +1100196 if (!fp->program.is_arb_asm) {
Timothy Arceria3fd8bb2017-02-04 10:46:53 +1100197 fp->program.sh.data->LinkStatus = linking_failure;
Timothy Arcerib8802812016-11-08 10:25:57 +1100198 ralloc_strcat(&fp->program.sh.data->InfoLog, error_str);
Jason Ekstrand22ad4492015-10-05 19:27:28 -0700199 }
200
201 _mesa_problem(NULL, "Failed to compile fragment shader: %s\n", error_str);
202
Kenneth Graunke2d4ac9b2014-05-14 01:21:02 -0700203 ralloc_free(mem_ctx);
Kenneth Graunke4d09fe92012-11-20 16:21:27 -0800204 return false;
Kenneth Graunke81b11bf2014-05-14 01:04:02 -0700205 }
Brian Paul2f78d4a2009-02-12 15:35:41 -0700206
Timothy Arceri718a0cf2016-11-04 13:37:21 +1100207 if (unlikely(brw->perf_debug)) {
208 if (fp->compiled_once)
Timothy Arceri6f76ca32016-11-04 14:09:35 +1100209 brw_wm_debug_recompile(brw, &fp->program, key);
Timothy Arceri718a0cf2016-11-04 13:37:21 +1100210 fp->compiled_once = true;
Kristian Høgsberg Kristensena548c752015-09-04 17:09:40 -0700211
212 if (start_busy && !drm_intel_bo_busy(brw->batch.last_bo)) {
213 perf_debug("FS compile took %.03f ms and stalled the GPU\n",
214 (get_time() - start_time) * 1000);
215 }
216 }
217
Francisco Jerezd9602842016-06-13 14:56:22 -0700218 brw_alloc_stage_scratch(brw, &brw->wm.base,
219 prog_data.base.total_scratch,
Lionel Landwerlin94d0e7d2016-09-23 00:41:23 +0300220 devinfo->max_wm_threads);
Eric Anholt4e725252010-10-21 15:07:45 -0700221
Timothy Arceri23848682016-11-09 23:44:39 +1100222 if (unlikely((INTEL_DEBUG & DEBUG_WM) && fp->program.is_arb_asm))
Eric Anholtfc3971d2009-01-08 19:15:04 -0800223 fprintf(stderr, "\n");
224
Kenneth Graunke67c49802014-09-26 11:38:06 -0700225 brw_upload_cache(&brw->cache, BRW_CACHE_FS_PROG,
Timothy Arceria38c8092016-10-05 15:42:02 +1100226 key, sizeof(struct brw_wm_prog_key),
227 program, program_size,
228 &prog_data, sizeof(prog_data),
229 &brw->wm.base.prog_offset, &brw->wm.base.prog_data);
Eric Anholt87527642011-05-16 15:10:26 -0700230
Kenneth Graunke2d4ac9b2014-05-14 01:21:02 -0700231 ralloc_free(mem_ctx);
Eric Anholt2fcaf4e2012-11-06 09:48:51 -0800232
Eric Anholt87527642011-05-16 15:10:26 -0700233 return true;
Eric Anholt9f344b32006-08-09 19:14:05 +0000234}
235
Eric Anholtfc3b7c92012-07-12 13:19:53 -0700236bool
Kenneth Graunkeca437572013-07-02 23:17:14 -0700237brw_debug_recompile_sampler_key(struct brw_context *brw,
Eric Anholt14cec072013-02-22 13:15:20 -0800238 const struct brw_sampler_prog_key_data *old_key,
Eric Anholtfc3b7c92012-07-12 13:19:53 -0700239 const struct brw_sampler_prog_key_data *key)
240{
241 bool found = false;
242
Kenneth Graunkef3d0daf2012-08-26 00:28:38 -0700243 for (unsigned int i = 0; i < MAX_SAMPLERS; i++) {
Kenneth Graunkeca437572013-07-02 23:17:14 -0700244 found |= key_debug(brw, "EXT_texture_swizzle or DEPTH_TEXTURE_MODE",
Kenneth Graunke98211d52012-08-15 16:35:35 -0700245 old_key->swizzles[i], key->swizzles[i]);
Eric Anholtfc3b7c92012-07-12 13:19:53 -0700246 }
Kenneth Graunkeca437572013-07-02 23:17:14 -0700247 found |= key_debug(brw, "GL_CLAMP enabled on any texture unit's 1st coordinate",
Kenneth Graunke98211d52012-08-15 16:35:35 -0700248 old_key->gl_clamp_mask[0], key->gl_clamp_mask[0]);
Kenneth Graunkeca437572013-07-02 23:17:14 -0700249 found |= key_debug(brw, "GL_CLAMP enabled on any texture unit's 2nd coordinate",
Kenneth Graunke98211d52012-08-15 16:35:35 -0700250 old_key->gl_clamp_mask[1], key->gl_clamp_mask[1]);
Kenneth Graunkeca437572013-07-02 23:17:14 -0700251 found |= key_debug(brw, "GL_CLAMP enabled on any texture unit's 3rd coordinate",
Kenneth Graunke98211d52012-08-15 16:35:35 -0700252 old_key->gl_clamp_mask[2], key->gl_clamp_mask[2]);
Chris Forbescfa3c8a2013-08-11 09:55:30 +1200253 found |= key_debug(brw, "gather channel quirk on any texture unit",
254 old_key->gather_channel_quirk_mask, key->gather_channel_quirk_mask);
Kenneth Graunke30c8d8a2015-04-23 23:17:10 -0700255 found |= key_debug(brw, "compressed multisample layout",
256 old_key->compressed_multisample_layout_mask,
257 key->compressed_multisample_layout_mask);
Neil Roberts1a97cac2015-09-15 16:34:35 +0100258 found |= key_debug(brw, "16x msaa",
259 old_key->msaa_16,
260 key->msaa_16);
Kenneth Graunke30c8d8a2015-04-23 23:17:10 -0700261
Kristian Høgsberg Kristensen654e9502016-05-01 21:22:54 -0700262 found |= key_debug(brw, "y_uv image bound",
263 old_key->y_uv_image_mask,
264 key->y_uv_image_mask);
265 found |= key_debug(brw, "y_u_v image bound",
266 old_key->y_u_v_image_mask,
267 key->y_u_v_image_mask);
268 found |= key_debug(brw, "yx_xuxv image bound",
269 old_key->yx_xuxv_image_mask,
270 key->yx_xuxv_image_mask);
271
Kenneth Graunke30c8d8a2015-04-23 23:17:10 -0700272 for (unsigned int i = 0; i < MAX_SAMPLERS; i++) {
273 found |= key_debug(brw, "textureGather workarounds",
274 old_key->gen6_gather_wa[i], key->gen6_gather_wa[i]);
275 }
Eric Anholtfc3b7c92012-07-12 13:19:53 -0700276
277 return found;
278}
279
Chris Forbes2b7bbd82014-02-03 22:13:03 +1300280static uint8_t
281gen6_gather_workaround(GLenum internalformat)
282{
283 switch (internalformat) {
Ian Romanick2b81cef2015-06-10 17:09:16 -0700284 case GL_R8I: return WA_SIGN | WA_8BIT;
285 case GL_R8UI: return WA_8BIT;
286 case GL_R16I: return WA_SIGN | WA_16BIT;
287 case GL_R16UI: return WA_16BIT;
288 default:
289 /* Note that even though GL_R32I and GL_R32UI have format overrides in
290 * the surface state, there is no shader w/a required.
291 */
292 return 0;
Chris Forbes2b7bbd82014-02-03 22:13:03 +1300293 }
294}
295
Kenneth Graunke1b05fc72011-12-06 15:36:21 -0800296void
297brw_populate_sampler_prog_key_data(struct gl_context *ctx,
Timothy Arceria38c8092016-10-05 15:42:02 +1100298 const struct gl_program *prog,
299 struct brw_sampler_prog_key_data *key)
Kenneth Graunke1b05fc72011-12-06 15:36:21 -0800300{
Kenneth Graunke794de2f2013-07-06 00:15:44 -0700301 struct brw_context *brw = brw_context(ctx);
Timothy Arceri8f1ca0e2016-07-05 17:02:46 +1000302 GLbitfield mask = prog->SamplersUsed;
Kenneth Graunke6d6aef72012-09-21 03:13:36 -0700303
Timothy Arceri8f1ca0e2016-07-05 17:02:46 +1000304 while (mask) {
305 const int s = u_bit_scan(&mask);
306
Kenneth Graunkef3d0daf2012-08-26 00:28:38 -0700307 key->swizzles[s] = SWIZZLE_NOOP;
Kenneth Graunke76d13012012-08-14 11:05:55 -0700308
Kenneth Graunkef3d0daf2012-08-26 00:28:38 -0700309 int unit_id = prog->SamplerUnits[s];
310 const struct gl_texture_unit *unit = &ctx->Texture.Unit[unit_id];
Kenneth Graunke1b05fc72011-12-06 15:36:21 -0800311
Eric Anholtff9c3e82014-04-23 17:14:26 -0700312 if (unit->_Current && unit->_Current->Target != GL_TEXTURE_BUFFER) {
Timothy Arceria38c8092016-10-05 15:42:02 +1100313 const struct gl_texture_object *t = unit->_Current;
314 const struct gl_texture_image *img = t->Image[0][t->BaseLevel];
315 struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit_id);
Kenneth Graunkefe911c12012-06-16 13:50:03 -0700316
Kenneth Graunke6d6aef72012-09-21 03:13:36 -0700317 const bool alpha_depth = t->DepthMode == GL_ALPHA &&
318 (img->_BaseFormat == GL_DEPTH_COMPONENT ||
319 img->_BaseFormat == GL_DEPTH_STENCIL);
320
321 /* Haswell handles texture swizzling as surface format overrides
322 * (except for GL_ALPHA); all other platforms need MOVs in the shader.
323 */
Kenneth Graunke57208322013-01-14 21:43:28 -0800324 if (alpha_depth || (brw->gen < 8 && !brw->is_haswell))
Kenneth Graunke9db20982013-01-23 15:27:39 -0800325 key->swizzles[s] = brw_get_texture_swizzle(ctx, t);
Kenneth Graunkefe911c12012-06-16 13:50:03 -0700326
Timothy Arceria38c8092016-10-05 15:42:02 +1100327 if (brw->gen < 8 &&
Kenneth Graunke22116962014-05-28 23:31:48 -0700328 sampler->MinFilter != GL_NEAREST &&
Timothy Arceria38c8092016-10-05 15:42:02 +1100329 sampler->MagFilter != GL_NEAREST) {
330 if (sampler->WrapS == GL_CLAMP)
331 key->gl_clamp_mask[0] |= 1 << s;
332 if (sampler->WrapT == GL_CLAMP)
333 key->gl_clamp_mask[1] |= 1 << s;
334 if (sampler->WrapR == GL_CLAMP)
335 key->gl_clamp_mask[2] |= 1 << s;
336 }
Chris Forbescfa3c8a2013-08-11 09:55:30 +1200337
Kenneth Graunke99c019e2017-01-05 02:51:38 -0800338 /* gather4 for RG32* is broken in multiple ways on Gen7. */
339 if (brw->gen == 7 && prog->nir->info->uses_texture_gather) {
340 switch (img->InternalFormat) {
341 case GL_RG32I:
342 case GL_RG32UI: {
343 /* We have to override the format to R32G32_FLOAT_LD.
344 * This means that SCS_ALPHA and SCS_ONE will return 0x3f8
345 * (1.0) rather than integer 1. This needs shader hacks.
346 *
347 * On Ivybridge, we whack W (alpha) to ONE in our key's
348 * swizzle. On Haswell, we look at the original texture
349 * swizzle, and use XYZW with channels overridden to ONE,
350 * leaving normal texture swizzling to SCS.
351 */
352 unsigned src_swizzle =
353 brw->is_haswell ? t->_Swizzle : key->swizzles[s];
354 for (int i = 0; i < 4; i++) {
355 unsigned src_comp = GET_SWZ(src_swizzle, i);
356 if (src_comp == SWIZZLE_ONE || src_comp == SWIZZLE_W) {
357 key->swizzles[i] &= ~(0x7 << (3 * i));
358 key->swizzles[i] |= SWIZZLE_ONE << (3 * i);
359 }
360 }
361 /* fallthrough */
362 }
363 case GL_RG32F:
364 /* The channel select for green doesn't work - we have to
365 * request blue. Haswell can use SCS for this, but Ivybridge
366 * needs a shader workaround.
367 */
368 if (!brw->is_haswell)
369 key->gather_channel_quirk_mask |= 1 << s;
370 break;
371 }
Chris Forbescfa3c8a2013-08-11 09:55:30 +1200372 }
Chris Forbes27359b82013-11-30 10:01:12 +1300373
Chris Forbes2b7bbd82014-02-03 22:13:03 +1300374 /* Gen6's gather4 is broken for UINT/SINT; we treat them as
375 * UNORM/FLOAT instead and fix it in the shader.
376 */
Timothy Arcerie1af20f2016-10-13 11:41:23 +1100377 if (brw->gen == 6 && prog->nir->info->uses_texture_gather) {
Chris Forbes2b7bbd82014-02-03 22:13:03 +1300378 key->gen6_gather_wa[s] = gen6_gather_workaround(img->InternalFormat);
379 }
380
Chris Forbes27359b82013-11-30 10:01:12 +1300381 /* If this is a multisample sampler, and uses the CMS MSAA layout,
382 * then we need to emit slightly different code to first sample the
383 * MCS surface.
384 */
385 struct intel_texture_object *intel_tex =
386 intel_texture_object((struct gl_texture_object *)t);
387
Topi Pohjolainencda8c2a2016-04-18 21:47:23 +0300388 /* From gen9 onwards some single sampled buffers can also be
389 * compressed. These don't need ld2dms sampling along with mcs fetch.
390 */
Chris Forbes27359b82013-11-30 10:01:12 +1300391 if (brw->gen >= 7 &&
Topi Pohjolainencda8c2a2016-04-18 21:47:23 +0300392 intel_tex->mt->msaa_layout == INTEL_MSAA_LAYOUT_CMS &&
393 intel_tex->mt->num_samples > 1) {
Chris Forbes27359b82013-11-30 10:01:12 +1300394 key->compressed_multisample_layout_mask |= 1 << s;
Neil Roberts1a97cac2015-09-15 16:34:35 +0100395
396 if (intel_tex->mt->num_samples >= 16) {
397 assert(brw->gen >= 9);
398 key->msaa_16 |= 1 << s;
399 }
Chris Forbes27359b82013-11-30 10:01:12 +1300400 }
Kristian Høgsberg Kristensen654e9502016-05-01 21:22:54 -0700401
402 if (t->Target == GL_TEXTURE_EXTERNAL_OES && intel_tex->planar_format) {
403 switch (intel_tex->planar_format->components) {
404 case __DRI_IMAGE_COMPONENTS_Y_UV:
405 key->y_uv_image_mask |= 1 << s;
406 break;
407 case __DRI_IMAGE_COMPONENTS_Y_U_V:
408 key->y_u_v_image_mask |= 1 << s;
409 break;
410 case __DRI_IMAGE_COMPONENTS_Y_XUXV:
411 key->yx_xuxv_image_mask |= 1 << s;
412 break;
413 default:
414 break;
415 }
416 }
417
Kenneth Graunke1b05fc72011-12-06 15:36:21 -0800418 }
Kenneth Graunke1b05fc72011-12-06 15:36:21 -0800419 }
420}
Eric Anholt9f344b32006-08-09 19:14:05 +0000421
Carl Wortha57672f2015-03-20 12:01:33 -0700422static bool
Kenneth Graunkeb23b0992016-04-27 11:26:08 -0700423brw_wm_state_dirty(const struct brw_context *brw)
Carl Wortha57672f2015-03-20 12:01:33 -0700424{
425 return brw_state_dirty(brw,
426 _NEW_BUFFERS |
427 _NEW_COLOR |
428 _NEW_DEPTH |
429 _NEW_FRAG_CLAMP |
430 _NEW_HINT |
431 _NEW_LIGHT |
432 _NEW_LINE |
433 _NEW_MULTISAMPLE |
434 _NEW_POLYGON |
435 _NEW_STENCIL |
436 _NEW_TEXTURE,
437 BRW_NEW_FRAGMENT_PROGRAM |
438 BRW_NEW_REDUCED_PRIMITIVE |
439 BRW_NEW_STATS_WM |
440 BRW_NEW_VUE_MAP_GEOM_OUT);
441}
442
Carl Worth017081a2016-04-14 10:54:38 +1000443void
Ian Romanick2b81cef2015-06-10 17:09:16 -0700444brw_wm_populate_key(struct brw_context *brw, struct brw_wm_prog_key *key)
Eric Anholt9f344b32006-08-09 19:14:05 +0000445{
Kenneth Graunke8c9a54e2013-07-06 00:46:38 -0700446 struct gl_context *ctx = &brw->ctx;
Eric Anholt9f344b32006-08-09 19:14:05 +0000447 /* BRW_NEW_FRAGMENT_PROGRAM */
Timothy Arceri13d0cf52016-10-18 16:17:14 +1100448 const struct brw_program *fp = brw_program_const(brw->fragment_program);
Kenneth Graunke387a3d42011-12-08 12:15:59 -0800449 const struct gl_program *prog = (struct gl_program *) brw->fragment_program;
Eric Anholt9f344b32006-08-09 19:14:05 +0000450 GLuint lookup = 0;
451 GLuint line_aa;
Paul Berry82d25962012-06-20 13:40:45 -0700452
Eric Anholt9f344b32006-08-09 19:14:05 +0000453 memset(key, 0, sizeof(*key));
454
455 /* Build the index for table lookup
456 */
Kenneth Graunke53631be2013-07-06 00:36:46 -0700457 if (brw->gen < 6) {
Kenneth Graunke86e401b2012-07-12 11:25:58 -0700458 /* _NEW_COLOR */
Timothy Arceri17e28a12016-10-19 13:45:18 +1100459 if (prog->info.fs.uses_discard || ctx->Color.AlphaEnabled) {
Jason Ekstrand81234022017-02-28 16:33:49 -0800460 lookup |= BRW_WM_IZ_PS_KILL_ALPHATEST_BIT;
Timothy Arceri556335e2016-10-05 15:13:23 +1100461 }
Eric Anholt9f344b32006-08-09 19:14:05 +0000462
Timothy Arceri17e28a12016-10-19 13:45:18 +1100463 if (prog->info.outputs_written & BITFIELD64_BIT(FRAG_RESULT_DEPTH)) {
Jason Ekstrand81234022017-02-28 16:33:49 -0800464 lookup |= BRW_WM_IZ_PS_COMPUTES_DEPTH_BIT;
Timothy Arceri7ef82862016-10-05 16:24:56 +1100465 }
Eric Anholt9f344b32006-08-09 19:14:05 +0000466
Kenneth Graunke2f8351a2012-06-16 16:34:50 -0700467 /* _NEW_DEPTH */
468 if (ctx->Depth.Test)
Jason Ekstrand81234022017-02-28 16:33:49 -0800469 lookup |= BRW_WM_IZ_DEPTH_TEST_ENABLE_BIT;
Eric Anholt9f344b32006-08-09 19:14:05 +0000470
Kenneth Graunkeff0253a2016-11-16 18:29:22 -0800471 if (brw_depth_writes_enabled(brw))
Jason Ekstrand81234022017-02-28 16:33:49 -0800472 lookup |= BRW_WM_IZ_DEPTH_WRITE_ENABLE_BIT;
Eric Anholt9f344b32006-08-09 19:14:05 +0000473
Eric Anholt94ecf912013-06-20 09:08:30 -0700474 /* _NEW_STENCIL | _NEW_BUFFERS */
Kenneth Graunke2f8351a2012-06-16 16:34:50 -0700475 if (ctx->Stencil._Enabled) {
Jason Ekstrand81234022017-02-28 16:33:49 -0800476 lookup |= BRW_WM_IZ_STENCIL_TEST_ENABLE_BIT;
Kenneth Graunke2f8351a2012-06-16 16:34:50 -0700477
Timothy Arceria38c8092016-10-05 15:42:02 +1100478 if (ctx->Stencil.WriteMask[0] ||
479 ctx->Stencil.WriteMask[ctx->Stencil._BackFace])
Jason Ekstrand81234022017-02-28 16:33:49 -0800480 lookup |= BRW_WM_IZ_STENCIL_WRITE_ENABLE_BIT;
Kenneth Graunke2f8351a2012-06-16 16:34:50 -0700481 }
482 key->iz_lookup = lookup;
Eric Anholt9f344b32006-08-09 19:14:05 +0000483 }
484
Jason Ekstrand81234022017-02-28 16:33:49 -0800485 line_aa = BRW_WM_AA_NEVER;
Eric Anholt9f344b32006-08-09 19:14:05 +0000486
487 /* _NEW_LINE, _NEW_POLYGON, BRW_NEW_REDUCED_PRIMITIVE */
Eric Anholt052c1d62009-01-30 14:32:23 -0800488 if (ctx->Line.SmoothFlag) {
Kenneth Graunkefe0a8cb2013-07-03 11:55:59 -0700489 if (brw->reduced_primitive == GL_LINES) {
Jason Ekstrand81234022017-02-28 16:33:49 -0800490 line_aa = BRW_WM_AA_ALWAYS;
Eric Anholt9f344b32006-08-09 19:14:05 +0000491 }
Kenneth Graunkefe0a8cb2013-07-03 11:55:59 -0700492 else if (brw->reduced_primitive == GL_TRIANGLES) {
Timothy Arceria38c8092016-10-05 15:42:02 +1100493 if (ctx->Polygon.FrontMode == GL_LINE) {
Jason Ekstrand81234022017-02-28 16:33:49 -0800494 line_aa = BRW_WM_AA_SOMETIMES;
Eric Anholt9f344b32006-08-09 19:14:05 +0000495
Timothy Arceria38c8092016-10-05 15:42:02 +1100496 if (ctx->Polygon.BackMode == GL_LINE ||
497 (ctx->Polygon.CullFlag &&
498 ctx->Polygon.CullFaceMode == GL_BACK))
Jason Ekstrand81234022017-02-28 16:33:49 -0800499 line_aa = BRW_WM_AA_ALWAYS;
Timothy Arceria38c8092016-10-05 15:42:02 +1100500 }
501 else if (ctx->Polygon.BackMode == GL_LINE) {
Jason Ekstrand81234022017-02-28 16:33:49 -0800502 line_aa = BRW_WM_AA_SOMETIMES;
Eric Anholt9f344b32006-08-09 19:14:05 +0000503
Timothy Arceria38c8092016-10-05 15:42:02 +1100504 if ((ctx->Polygon.CullFlag &&
505 ctx->Polygon.CullFaceMode == GL_FRONT))
Jason Ekstrand81234022017-02-28 16:33:49 -0800506 line_aa = BRW_WM_AA_ALWAYS;
Timothy Arceria38c8092016-10-05 15:42:02 +1100507 }
Eric Anholt9f344b32006-08-09 19:14:05 +0000508 }
509 }
Eric Anholt9f344b32006-08-09 19:14:05 +0000510
Eric Anholt16f8c822010-11-11 09:30:16 -0800511 key->line_aa = line_aa;
Kenneth Graunke6cc14c22012-08-26 00:47:44 -0700512
Chia-I Wu848c0e72013-09-12 13:00:52 +0800513 /* _NEW_HINT */
Kenneth Graunke2a4f5722014-11-30 21:58:03 -0800514 key->high_quality_derivatives =
515 ctx->Hint.FragmentShaderDerivative == GL_NICEST;
Chia-I Wu848c0e72013-09-12 13:00:52 +0800516
Kenneth Graunke53631be2013-07-06 00:36:46 -0700517 if (brw->gen < 6)
Kenneth Graunkeec995de2013-07-03 14:26:01 -0700518 key->stats_wm = brw->stats_wm;
Eric Anholt9f344b32006-08-09 19:14:05 +0000519
Eric Anholt9f344b32006-08-09 19:14:05 +0000520 /* _NEW_LIGHT */
Eric Anholt052c1d62009-01-30 14:32:23 -0800521 key->flat_shade = (ctx->Light.ShadeModel == GL_FLAT);
Eric Anholt9f344b32006-08-09 19:14:05 +0000522
Eric Anholtd22e2eb2011-04-15 14:40:09 -0700523 /* _NEW_FRAG_CLAMP | _NEW_BUFFERS */
524 key->clamp_fragment_color = ctx->Color._ClampFragmentColor;
525
Eric Anholt9f344b32006-08-09 19:14:05 +0000526 /* _NEW_TEXTURE */
Timothy Arceri8f1ca0e2016-07-05 17:02:46 +1000527 brw_populate_sampler_prog_key_data(ctx, prog, &key->tex);
Eric Anholt9c8f27b2008-02-28 13:18:12 -0800528
529 /* _NEW_BUFFERS */
Eric Anholt1b806222011-01-30 21:13:17 -0800530 key->nr_color_regions = ctx->DrawBuffer->_NumColorDrawBuffers;
Chris Forbes1415a182013-07-01 23:30:55 +1200531
Kenneth Graunkeb3340cd2016-01-20 17:33:14 -0800532 /* _NEW_COLOR */
533 key->force_dual_color_blend = brw->dual_color_blend_by_location &&
534 (ctx->Color.BlendEnabled & 1) && ctx->Color.Blend[0]._UsesDualSrc;
535
Chris Forbes1415a182013-07-01 23:30:55 +1200536 /* _NEW_MULTISAMPLE, _NEW_COLOR, _NEW_BUFFERS */
537 key->replicate_alpha = ctx->DrawBuffer->_NumColorDrawBuffers > 1 &&
Anuj Phogat329ae922016-10-20 11:40:40 -0700538 (_mesa_is_alpha_test_enabled(ctx) ||
539 _mesa_is_alpha_to_coverage_enabled(ctx));
Brian Paul9ef33b82009-10-29 14:53:53 -0600540
Anuj Phogat65d04522013-10-24 15:53:05 -0700541 /* _NEW_BUFFERS _NEW_MULTISAMPLE */
Anuj Phogata92e5f72014-01-06 13:59:18 -0800542 /* Ignore sample qualifier while computing this flag. */
Jason Ekstrand712a9802016-05-09 17:48:24 -0700543 if (ctx->Multisample.Enabled) {
544 key->persample_interp =
545 ctx->Multisample.SampleShading &&
546 (ctx->Multisample.MinSampleShadingValue *
547 _mesa_geometric_samples(ctx->DrawBuffer) > 1);
Anuj Phogata92e5f72014-01-06 13:59:18 -0800548
Jason Ekstrand712a9802016-05-09 17:48:24 -0700549 key->multisample_fbo = _mesa_geometric_samples(ctx->DrawBuffer) > 1;
550 }
Anuj Phogate12bbb52013-10-24 16:17:08 -0700551
Paul Berrybf9bfe82013-03-17 11:29:28 -0700552 /* BRW_NEW_VUE_MAP_GEOM_OUT */
Timothy Arceri17e28a12016-10-19 13:45:18 +1100553 if (brw->gen < 6 || _mesa_bitcount_64(prog->info.inputs_read &
554 BRW_FS_VARYING_INPUT_MASK) > 16) {
Paul Berry0a0deb92013-03-20 10:15:52 -0700555 key->input_slots_valid = brw->vue_map_geom_out.slots_valid;
Timothy Arceri7627fbd2016-10-05 16:45:27 +1100556 }
Eric Anholt0f5113d2009-05-14 09:49:45 -0700557
Chris Forbes1080fc62013-10-27 12:09:51 +1300558 /* _NEW_COLOR | _NEW_BUFFERS */
559 /* Pre-gen6, the hardware alpha test always used each render
560 * target's alpha to do alpha test, as opposed to render target 0's alpha
561 * like GL requires. Fix that by building the alpha test into the
562 * shader, and we'll skip enabling the fixed function alpha test.
563 */
Ian Romanick2b81cef2015-06-10 17:09:16 -0700564 if (brw->gen < 6 && ctx->DrawBuffer->_NumColorDrawBuffers > 1 &&
565 ctx->Color.AlphaEnabled) {
Chris Forbes1080fc62013-10-27 12:09:51 +1300566 key->alpha_test_func = ctx->Color.AlphaFunc;
567 key->alpha_test_ref = ctx->Color.AlphaRef;
568 }
569
Brian Paul55d33e12009-02-20 10:49:30 -0700570 /* The unique fragment program ID */
Eric Anholt9f344b32006-08-09 19:14:05 +0000571 key->program_string_id = fp->id;
Francisco Jerez40b23ad2016-07-21 20:32:12 -0700572
573 /* Whether reads from the framebuffer should behave coherently. */
574 key->coherent_fb_fetch = ctx->Extensions.MESA_shader_framebuffer_fetch;
Eric Anholt9f344b32006-08-09 19:14:05 +0000575}
576
Carl Worth4a6c6c42015-02-11 13:53:31 -0800577void
Eric Anholtdc9a7532011-10-22 11:33:54 -0700578brw_upload_wm_prog(struct brw_context *brw)
Eric Anholt9f344b32006-08-09 19:14:05 +0000579{
580 struct brw_wm_prog_key key;
Timothy Arceri13d0cf52016-10-18 16:17:14 +1100581 struct brw_program *fp = (struct brw_program *) brw->fragment_program;
Eric Anholt662f1b42011-03-11 19:19:01 -0800582
Carl Wortha57672f2015-03-20 12:01:33 -0700583 if (!brw_wm_state_dirty(brw))
Carl Worth4a6c6c42015-02-11 13:53:31 -0800584 return;
585
Eric Anholt9f344b32006-08-09 19:14:05 +0000586 brw_wm_populate_key(brw, &key);
587
Kenneth Graunke67c49802014-09-26 11:38:06 -0700588 if (!brw_search_cache(&brw->cache, BRW_CACHE_FS_PROG,
Timothy Arceria38c8092016-10-05 15:42:02 +1100589 &key, sizeof(key),
590 &brw->wm.base.prog_offset,
Kenneth Graunke16d55362016-09-08 23:48:53 -0700591 &brw->wm.base.prog_data)) {
Timothy Arceri6e3f6092016-11-04 16:04:01 +1100592 bool success = brw_codegen_wm_prog(brw, fp, &key,
Timothy Arceri91d61fb2016-10-20 09:59:00 +1100593 &brw->vue_map_geom_out);
Brian Paul41702272011-10-07 10:38:30 -0600594 (void) success;
Eric Anholt87527642011-05-16 15:10:26 -0700595 assert(success);
596 }
Eric Anholt9f344b32006-08-09 19:14:05 +0000597}
Kristian Høgsberg Kristensen84f2ed22015-09-04 16:55:03 -0700598
599bool
Timothy Arceri6e3f6092016-11-04 16:04:01 +1100600brw_fs_precompile(struct gl_context *ctx, struct gl_program *prog)
Kristian Høgsberg Kristensen84f2ed22015-09-04 16:55:03 -0700601{
602 struct brw_context *brw = brw_context(ctx);
603 struct brw_wm_prog_key key;
604
Timothy Arceri13d0cf52016-10-18 16:17:14 +1100605 struct brw_program *bfp = brw_program(prog);
Kristian Høgsberg Kristensen84f2ed22015-09-04 16:55:03 -0700606
607 memset(&key, 0, sizeof(key));
608
Timothy Arceri17e28a12016-10-19 13:45:18 +1100609 uint64_t outputs_written = prog->info.outputs_written;
Timothy Arceri7ef82862016-10-05 16:24:56 +1100610
Kristian Høgsberg Kristensen84f2ed22015-09-04 16:55:03 -0700611 if (brw->gen < 6) {
Timothy Arceri17e28a12016-10-19 13:45:18 +1100612 if (prog->info.fs.uses_discard)
Jason Ekstrand81234022017-02-28 16:33:49 -0800613 key.iz_lookup |= BRW_WM_IZ_PS_KILL_ALPHATEST_BIT;
Kristian Høgsberg Kristensen84f2ed22015-09-04 16:55:03 -0700614
Timothy Arceri7ef82862016-10-05 16:24:56 +1100615 if (outputs_written & BITFIELD64_BIT(FRAG_RESULT_DEPTH))
Jason Ekstrand81234022017-02-28 16:33:49 -0800616 key.iz_lookup |= BRW_WM_IZ_PS_COMPUTES_DEPTH_BIT;
Kristian Høgsberg Kristensen84f2ed22015-09-04 16:55:03 -0700617
618 /* Just assume depth testing. */
Jason Ekstrand81234022017-02-28 16:33:49 -0800619 key.iz_lookup |= BRW_WM_IZ_DEPTH_TEST_ENABLE_BIT;
620 key.iz_lookup |= BRW_WM_IZ_DEPTH_WRITE_ENABLE_BIT;
Kristian Høgsberg Kristensen84f2ed22015-09-04 16:55:03 -0700621 }
622
Timothy Arceri17e28a12016-10-19 13:45:18 +1100623 if (brw->gen < 6 || _mesa_bitcount_64(prog->info.inputs_read &
Timothy Arceri7627fbd2016-10-05 16:45:27 +1100624 BRW_FS_VARYING_INPUT_MASK) > 16) {
Timothy Arceri17e28a12016-10-19 13:45:18 +1100625 key.input_slots_valid = prog->info.inputs_read | VARYING_BIT_POS;
Timothy Arceri7627fbd2016-10-05 16:45:27 +1100626 }
Kristian Høgsberg Kristensen84f2ed22015-09-04 16:55:03 -0700627
Timothy Arceri34234882016-10-19 13:23:37 +1100628 brw_setup_tex_for_precompile(brw, &key.tex, prog);
Kristian Høgsberg Kristensen84f2ed22015-09-04 16:55:03 -0700629
Timothy Arceri7ef82862016-10-05 16:24:56 +1100630 key.nr_color_regions = _mesa_bitcount_64(outputs_written &
Kristian Høgsberg Kristensen84f2ed22015-09-04 16:55:03 -0700631 ~(BITFIELD64_BIT(FRAG_RESULT_DEPTH) |
Francisco Jerezc8f5bd22016-08-22 18:50:41 -0700632 BITFIELD64_BIT(FRAG_RESULT_STENCIL) |
633 BITFIELD64_BIT(FRAG_RESULT_SAMPLE_MASK)));
Kristian Høgsberg Kristensen84f2ed22015-09-04 16:55:03 -0700634
Kristian Høgsberg Kristensen84f2ed22015-09-04 16:55:03 -0700635 key.program_string_id = bfp->id;
636
Francisco Jerez40b23ad2016-07-21 20:32:12 -0700637 /* Whether reads from the framebuffer should behave coherently. */
638 key.coherent_fb_fetch = ctx->Extensions.MESA_shader_framebuffer_fetch;
639
Kristian Høgsberg Kristensen84f2ed22015-09-04 16:55:03 -0700640 uint32_t old_prog_offset = brw->wm.base.prog_offset;
Kenneth Graunke16d55362016-09-08 23:48:53 -0700641 struct brw_stage_prog_data *old_prog_data = brw->wm.base.prog_data;
Kristian Høgsberg Kristensen84f2ed22015-09-04 16:55:03 -0700642
Timothy Arceri91d61fb2016-10-20 09:59:00 +1100643 struct brw_vue_map vue_map;
644 if (brw->gen < 6) {
645 brw_compute_vue_map(&brw->screen->devinfo, &vue_map,
Timothy Arceri17e28a12016-10-19 13:45:18 +1100646 prog->info.inputs_read | VARYING_BIT_POS,
Timothy Arceri91d61fb2016-10-20 09:59:00 +1100647 false);
648 }
649
Timothy Arceri6e3f6092016-11-04 16:04:01 +1100650 bool success = brw_codegen_wm_prog(brw, bfp, &key, &vue_map);
Kristian Høgsberg Kristensen84f2ed22015-09-04 16:55:03 -0700651
652 brw->wm.base.prog_offset = old_prog_offset;
Kenneth Graunke16d55362016-09-08 23:48:53 -0700653 brw->wm.base.prog_data = old_prog_data;
Kristian Høgsberg Kristensen84f2ed22015-09-04 16:55:03 -0700654
655 return success;
656}