#include "brw_state.h"
#include "program/prog_print.h"
#include "program/prog_parameter.h"
-#include "brw_nir.h"
+#include "compiler/brw_nir.h"
#include "brw_program.h"
#include "util/ralloc.h"
+/**
+ * Decide which set of clip planes should be used when clipping via
+ * gl_Position or gl_ClipVertex.
+ */
+gl_clip_plane *
+brw_select_clip_planes(struct gl_context *ctx)
+{
+ if (ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]) {
+ /* There is currently a GLSL vertex shader, so clip according to GLSL
+ * rules, which means compare gl_ClipVertex (or gl_Position, if
+ * gl_ClipVertex wasn't assigned) against the eye-coordinate clip planes
+ * that were stored in EyeUserPlane at the time the clip planes were
+ * specified.
+ */
+ return ctx->Transform.EyeUserPlane;
+ } else {
+ /* Either we are using fixed function or an ARB vertex program. In
+ * either case the clip planes are going to be compared against
+ * gl_Position (which is in clip coordinates) so we have to clip using
+ * _ClipUserPlane, which was transformed into clip coordinates by Mesa
+ * core.
+ */
+ return ctx->Transform._ClipUserPlane;
+ }
+}
+
GLbitfield64
brw_vs_outputs_written(struct brw_context *brw, struct brw_vs_prog_key *key,
GLbitfield64 user_varyings)
brw_vs_debug_recompile(struct brw_context *brw, struct gl_program *prog,
const struct brw_vs_prog_key *key)
{
- struct brw_cache_item *c = NULL;
- const struct brw_vs_prog_key *old_key = NULL;
- bool found = false;
-
perf_debug("Recompiling vertex shader for program %d\n", prog->Id);
- for (unsigned int i = 0; i < brw->cache.size; i++) {
- for (c = brw->cache.items[i]; c; c = c->next) {
- if (c->cache_id == BRW_CACHE_VS_PROG) {
- old_key = c->key;
-
- if (old_key->program_string_id == key->program_string_id)
- break;
- }
- }
- if (c)
- break;
- }
+ bool found = false;
+ const struct brw_vs_prog_key *old_key =
+ brw_find_previous_compile(&brw->cache, BRW_CACHE_VS_PROG,
+ key->program_string_id);
- if (!c) {
+ if (!old_key) {
perf_debug(" Didn't find previous compile in the shader cache for "
"debug\n");
return;
}
}
-bool
+static bool
brw_codegen_vs_prog(struct brw_context *brw,
- struct gl_shader_program *prog,
struct brw_program *vp,
struct brw_vs_prog_key *key)
{
brw_nir_setup_glsl_uniforms(vp->program.nir, &vp->program,
&prog_data.base.base,
compiler->scalar_stage[MESA_SHADER_VERTEX]);
+ brw_nir_analyze_ubo_ranges(compiler, vp->program.nir,
+ prog_data.base.base.ubo_ranges);
} else {
brw_nir_setup_arb_uniforms(vp->program.nir, &vp->program,
&prog_data.base.base);
uint64_t outputs_written =
brw_vs_outputs_written(brw, key, vp->program.info.outputs_written);
- prog_data.inputs_read = vp->program.info.inputs_read;
- prog_data.double_inputs_read = vp->program.info.double_inputs_read;
-
- if (key->copy_edgeflag) {
- prog_data.inputs_read |= VERT_BIT_EDGEFLAG;
- }
brw_compute_vue_map(devinfo,
&prog_data.base.vue_map, outputs_written,
- vp->program.nir->info->separate_shader);
+ vp->program.nir->info.separate_shader);
if (0) {
_mesa_fprint_program_opt(stderr, &vp->program, PROG_PRINT_DEBUG, true);
if (unlikely(brw->perf_debug)) {
start_busy = (brw->batch.last_bo &&
- drm_intel_bo_busy(brw->batch.last_bo));
+ brw_bo_busy(brw->batch.last_bo));
start_time = get_time();
}
st_index, &program_size, &error_str);
if (program == NULL) {
if (!vp->program.is_arb_asm) {
- vp->program.sh.data->LinkStatus = false;
+ vp->program.sh.data->LinkStatus = linking_failure;
ralloc_strcat(&vp->program.sh.data->InfoLog, error_str);
}
if (vp->compiled_once) {
brw_vs_debug_recompile(brw, &vp->program, key);
}
- if (start_busy && !drm_intel_bo_busy(brw->batch.last_bo)) {
+ if (start_busy && !brw_bo_busy(brw->batch.last_bo)) {
perf_debug("VS compile took %.03f ms and stalled the GPU\n",
(get_time() - start_time) * 1000);
}
if (ctx->Transform.ClipPlanesEnabled != 0 &&
(ctx->API == API_OPENGL_COMPAT || ctx->API == API_OPENGLES) &&
- vp->program.ClipDistanceArraySize == 0) {
+ vp->program.info.clip_distance_array_size == 0) {
key->nr_userclip_plane_consts =
_mesa_logbase2(ctx->Transform.ClipPlanesEnabled) + 1;
}
}
}
- if (prog->nir->info->outputs_written &
+ if (prog->info.outputs_written &
(VARYING_BIT_COL0 | VARYING_BIT_COL1 | VARYING_BIT_BFC0 |
VARYING_BIT_BFC1)) {
/* _NEW_LIGHT | _NEW_BUFFERS */
void
brw_upload_vs_prog(struct brw_context *brw)
{
- struct gl_context *ctx = &brw->ctx;
- struct gl_shader_program **current = ctx->_Shader->CurrentProgram;
struct brw_vs_prog_key key;
/* BRW_NEW_VERTEX_PROGRAM */
struct brw_program *vp = (struct brw_program *)brw->vertex_program;
if (!brw_search_cache(&brw->cache, BRW_CACHE_VS_PROG,
&key, sizeof(key),
&brw->vs.base.prog_offset, &brw->vs.base.prog_data)) {
- bool success = brw_codegen_vs_prog(brw, current[MESA_SHADER_VERTEX],
- vp, &key);
+ bool success = brw_codegen_vs_prog(brw, vp, &key);
(void) success;
assert(success);
}
}
bool
-brw_vs_precompile(struct gl_context *ctx,
- struct gl_shader_program *shader_prog,
- struct gl_program *prog)
+brw_vs_precompile(struct gl_context *ctx, struct gl_program *prog)
{
struct brw_context *brw = brw_context(ctx);
struct brw_vs_prog_key key;
brw_setup_tex_for_precompile(brw, &key.tex, prog);
key.program_string_id = bvp->id;
key.clamp_vertex_color =
- (prog->nir->info->outputs_written &
+ (prog->info.outputs_written &
(VARYING_BIT_COL0 | VARYING_BIT_COL1 | VARYING_BIT_BFC0 |
VARYING_BIT_BFC1));
- success = brw_codegen_vs_prog(brw, shader_prog, bvp, &key);
+ success = brw_codegen_vs_prog(brw, bvp, &key);
brw->vs.base.prog_offset = old_prog_offset;
brw->vs.base.prog_data = old_prog_data;