i965: Use NIR to lower legacy userclipping.
This allows us to drop legacy userclip plane handling in both the vec4 and FS backends, and simplifies a few interfaces. v2 (Jason Ekstrand): - Move brw_nir_lower_legacy_clipping to brw_nir_uniforms.cpp because it's i965-specific. - Handle adding the params in brw_nir_lower_legacy_clipping - Call brw_nir_lower_legacy_clipping from brw_codegen_vs_prog Co-authored-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:

committed by
Jason Ekstrand

parent
d10de25309
commit
517005b4cf
@@ -563,87 +563,6 @@ fs_visitor::emit_fb_writes()
|
||||
inst->eot = true;
|
||||
}
|
||||
|
||||
void
|
||||
fs_visitor::setup_uniform_clipplane_values()
|
||||
{
|
||||
const struct brw_vs_prog_key *key =
|
||||
(const struct brw_vs_prog_key *) this->key;
|
||||
|
||||
if (key->nr_userclip_plane_consts == 0)
|
||||
return;
|
||||
|
||||
assert(stage_prog_data->nr_params == uniforms);
|
||||
brw_stage_prog_data_add_params(stage_prog_data,
|
||||
key->nr_userclip_plane_consts * 4);
|
||||
|
||||
for (int i = 0; i < key->nr_userclip_plane_consts; i++) {
|
||||
this->userplane[i] = fs_reg(UNIFORM, uniforms);
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
stage_prog_data->param[uniforms + j] =
|
||||
BRW_PARAM_BUILTIN_CLIP_PLANE(i, j);
|
||||
}
|
||||
uniforms += 4;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Lower legacy fixed-function and gl_ClipVertex clipping to clip distances.
|
||||
*
|
||||
* This does nothing if the shader uses gl_ClipDistance or user clipping is
|
||||
* disabled altogether.
|
||||
*/
|
||||
void fs_visitor::compute_clip_distance()
|
||||
{
|
||||
struct brw_vue_prog_data *vue_prog_data = brw_vue_prog_data(prog_data);
|
||||
const struct brw_vs_prog_key *key =
|
||||
(const struct brw_vs_prog_key *) this->key;
|
||||
|
||||
/* Bail unless some sort of legacy clipping is enabled */
|
||||
if (key->nr_userclip_plane_consts == 0)
|
||||
return;
|
||||
|
||||
/* From the GLSL 1.30 spec, section 7.1 (Vertex Shader Special Variables):
|
||||
*
|
||||
* "If a linked set of shaders forming the vertex stage contains no
|
||||
* static write to gl_ClipVertex or gl_ClipDistance, but the
|
||||
* application has requested clipping against user clip planes through
|
||||
* the API, then the coordinate written to gl_Position is used for
|
||||
* comparison against the user clip planes."
|
||||
*
|
||||
* This function is only called if the shader didn't write to
|
||||
* gl_ClipDistance. Accordingly, we use gl_ClipVertex to perform clipping
|
||||
* if the user wrote to it; otherwise we use gl_Position.
|
||||
*/
|
||||
|
||||
gl_varying_slot clip_vertex = VARYING_SLOT_CLIP_VERTEX;
|
||||
if (!(vue_prog_data->vue_map.slots_valid & VARYING_BIT_CLIP_VERTEX))
|
||||
clip_vertex = VARYING_SLOT_POS;
|
||||
|
||||
/* If the clip vertex isn't written, skip this. Typically this means
|
||||
* the GS will set up clipping. */
|
||||
if (outputs[clip_vertex].file == BAD_FILE)
|
||||
return;
|
||||
|
||||
setup_uniform_clipplane_values();
|
||||
|
||||
const fs_builder abld = bld.annotate("user clip distances");
|
||||
|
||||
this->outputs[VARYING_SLOT_CLIP_DIST0] = vgrf(glsl_type::vec4_type);
|
||||
this->outputs[VARYING_SLOT_CLIP_DIST1] = vgrf(glsl_type::vec4_type);
|
||||
|
||||
for (int i = 0; i < key->nr_userclip_plane_consts; i++) {
|
||||
fs_reg u = userplane[i];
|
||||
const fs_reg output = offset(outputs[VARYING_SLOT_CLIP_DIST0 + i / 4],
|
||||
bld, i & 3);
|
||||
|
||||
abld.MUL(output, outputs[clip_vertex], u);
|
||||
for (int j = 1; j < 4; j++) {
|
||||
u.nr = userplane[i].nr + j;
|
||||
abld.MAD(output, output, offset(outputs[clip_vertex], bld, j), u);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
fs_visitor::emit_urb_writes(const fs_reg &gs_vertex_count)
|
||||
{
|
||||
|
Reference in New Issue
Block a user