diff options
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_vs.c')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vs.c | 94 |
1 files changed, 44 insertions, 50 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c index c53cb49b612..0c60bde511e 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.c +++ b/src/mesa/drivers/dri/i965/brw_vs.c @@ -98,10 +98,12 @@ brw_codegen_vs_prog(struct brw_context *brw, struct brw_stage_prog_data *stage_prog_data = &prog_data.base.base; void *mem_ctx; int i; - struct gl_shader *vs = NULL; + struct brw_shader *vs = NULL; + bool start_busy = false; + double start_time = 0; if (prog) - vs = prog->_LinkedShaders[MESA_SHADER_VERTEX]; + vs = (struct brw_shader *) prog->_LinkedShaders[MESA_SHADER_VERTEX]; memset(&prog_data, 0, sizeof(prog_data)); @@ -121,16 +123,16 @@ brw_codegen_vs_prog(struct brw_context *brw, * case being a float value that gets blown up to a vec4, so be * conservative here. */ - param_count = vs->num_uniform_components * 4 + - vs->NumImages * BRW_IMAGE_PARAM_SIZE; - stage_prog_data->nr_image_params = vs->NumImages; + param_count = vs->base.num_uniform_components * 4 + + vs->base.NumImages * BRW_IMAGE_PARAM_SIZE; + stage_prog_data->nr_image_params = vs->base.NumImages; } else { param_count = vp->program.Base.Parameters->NumParameters * 4; } /* vec4_visitor::setup_uniform_clipplane_values() also uploads user clip * planes as uniforms. */ - param_count += key->base.nr_userclip_plane_consts * 4; + param_count += key->nr_userclip_plane_consts * 4; stage_prog_data->param = rzalloc_array(NULL, const gl_constant_value *, param_count); @@ -172,19 +174,26 @@ brw_codegen_vs_prog(struct brw_context *brw, * distance varying slots whenever clipping is enabled, even if the vertex * shader doesn't write to gl_ClipDistance. */ - if (key->base.userclip_active) { + if (key->nr_userclip_plane_consts > 0) { outputs_written |= BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST0); outputs_written |= BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST1); } brw_compute_vue_map(brw->intelScreen->devinfo, - &prog_data.base.vue_map, outputs_written); + &prog_data.base.vue_map, outputs_written, + prog ? prog->SeparateShader : false); if (0) { _mesa_fprint_program_opt(stderr, &vp->program.Base, PROG_PRINT_DEBUG, true); } + if (unlikely(brw->perf_debug)) { + start_busy = (brw->batch.last_bo && + drm_intel_bo_busy(brw->batch.last_bo)); + start_time = get_time(); + } + /* Emit GEN4 code. */ program = brw_vs_emit(brw, mem_ctx, key, &prog_data, @@ -194,6 +203,17 @@ brw_codegen_vs_prog(struct brw_context *brw, return false; } + if (unlikely(brw->perf_debug) && vs) { + if (vs->compiled_once) { + brw_vs_debug_recompile(brw, prog, key); + } + if (start_busy && !drm_intel_bo_busy(brw->batch.last_bo)) { + perf_debug("VS compile took %.03f ms and stalled the GPU\n", + (get_time() - start_time) * 1000); + } + vs->compiled_once = true; + } + /* Scratch space is used for register spilling */ if (prog_data.base.base.total_scratch) { brw_get_scratch_bo(brw, &brw->vs.base.scratch_bo, @@ -237,7 +257,7 @@ brw_vs_debug_recompile(struct brw_context *brw, if (c->cache_id == BRW_CACHE_VS_PROG) { old_key = c->key; - if (old_key->base.program_string_id == key->base.program_string_id) + if (old_key->program_string_id == key->program_string_id) break; } } @@ -257,12 +277,9 @@ brw_vs_debug_recompile(struct brw_context *brw, key->gl_attrib_wa_flags[i]); } - found |= key_debug(brw, "user clip flags", - old_key->base.userclip_active, key->base.userclip_active); - - found |= key_debug(brw, "user clipping planes as push constants", - old_key->base.nr_userclip_plane_consts, - key->base.nr_userclip_plane_consts); + found |= key_debug(brw, "legacy user clipping", + old_key->nr_userclip_plane_consts, + key->nr_userclip_plane_consts); found |= key_debug(brw, "copy edgeflag", old_key->copy_edgeflag, key->copy_edgeflag); @@ -271,29 +288,13 @@ brw_vs_debug_recompile(struct brw_context *brw, found |= key_debug(brw, "vertex color clamping", old_key->clamp_vertex_color, key->clamp_vertex_color); - found |= brw_debug_recompile_sampler_key(brw, &old_key->base.tex, - &key->base.tex); + found |= brw_debug_recompile_sampler_key(brw, &old_key->tex, &key->tex); if (!found) { perf_debug(" Something else\n"); } } - -void -brw_setup_vue_key_clip_info(struct brw_context *brw, - struct brw_vue_prog_key *key, - bool program_uses_clip_distance) -{ - struct gl_context *ctx = &brw->ctx; - - key->userclip_active = (ctx->Transform.ClipPlanesEnabled != 0); - if (key->userclip_active && !program_uses_clip_distance) { - key->nr_userclip_plane_consts - = _mesa_logbase2(ctx->Transform.ClipPlanesEnabled) + 1; - } -} - static bool brw_vs_state_dirty(struct brw_context *brw) { @@ -324,9 +325,14 @@ brw_vs_populate_key(struct brw_context *brw, /* Just upload the program verbatim for now. Always send it all * the inputs it asks for, whether they are varying or not. */ - key->base.program_string_id = vp->id; - brw_setup_vue_key_clip_info(brw, &key->base, - vp->program.Base.UsesClipDistanceOut); + key->program_string_id = vp->id; + + if (ctx->Transform.ClipPlanesEnabled != 0 && + ctx->API == API_OPENGL_COMPAT && + !vp->program.Base.UsesClipDistanceOut) { + key->nr_userclip_plane_consts = + _mesa_logbase2(ctx->Transform.ClipPlanesEnabled) + 1; + } /* _NEW_POLYGON */ if (brw->gen < 6) { @@ -350,7 +356,7 @@ brw_vs_populate_key(struct brw_context *brw, /* _NEW_TEXTURE */ brw_populate_sampler_prog_key_data(ctx, prog, brw->vs.base.sampler_count, - &key->base.tex); + &key->tex); /* BRW_NEW_VS_ATTRIB_WORKAROUNDS */ memcpy(key->gl_attrib_wa_flags, brw->vb.attrib_wa_flags, @@ -381,19 +387,6 @@ brw_upload_vs_prog(struct brw_context *brw) assert(success); } brw->vs.base.prog_data = &brw->vs.prog_data->base.base; - - if (memcmp(&brw->vs.prog_data->base.vue_map, &brw->vue_map_geom_out, - sizeof(brw->vue_map_geom_out)) != 0) { - brw->vue_map_vs = brw->vs.prog_data->base.vue_map; - brw->ctx.NewDriverState |= BRW_NEW_VUE_MAP_VS; - if (brw->gen < 6) { - /* No geometry shader support, so the VS VUE map is the VUE map for - * the output of the "geometry" portion of the pipeline. - */ - brw->vue_map_geom_out = brw->vue_map_vs; - brw->ctx.NewDriverState |= BRW_NEW_VUE_MAP_GEOM_OUT; - } - } } bool @@ -412,7 +405,8 @@ brw_vs_precompile(struct gl_context *ctx, memset(&key, 0, sizeof(key)); - brw_vue_setup_prog_key_for_precompile(ctx, &key.base, bvp->id, &vp->Base); + brw_setup_tex_for_precompile(brw, &key.tex, prog); + key.program_string_id = bvp->id; key.clamp_vertex_color = (prog->OutputsWritten & (VARYING_BIT_COL0 | VARYING_BIT_COL1 | VARYING_BIT_BFC0 | VARYING_BIT_BFC1)); |