mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 17:40:11 +01:00
draw: don't pretend have_clipdist is per-vertex
This is just for code cleanup, conceptually the have_clipdist really isn't per-vertex state, so don't put it there (just dependent on the shader). Even though there wasn't really any overhead associated with this, we shouldn't store random shader information in the vertex header. Reviewed-by: Brian Paul <brianp@vmware.com Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
This commit is contained in:
parent
9e3f2af3c3
commit
1b22815af6
5 changed files with 20 additions and 18 deletions
|
|
@ -137,7 +137,6 @@ static boolean TAG(do_cliptest)( struct pt_post_vs *pvs,
|
||||||
if (have_cd && num_written_clipdistance) {
|
if (have_cd && num_written_clipdistance) {
|
||||||
float clipdist;
|
float clipdist;
|
||||||
i = plane_idx - 6;
|
i = plane_idx - 6;
|
||||||
out->have_clipdist = 1;
|
|
||||||
/* first four clip distance in first vector etc. */
|
/* first four clip distance in first vector etc. */
|
||||||
if (i < 4)
|
if (i < 4)
|
||||||
clipdist = out->data[cd[0]][i];
|
clipdist = out->data[cd[0]][i];
|
||||||
|
|
|
||||||
|
|
@ -826,7 +826,7 @@ store_aos(struct gallivm_state *gallivm,
|
||||||
* struct vertex_header {
|
* struct vertex_header {
|
||||||
* unsigned clipmask:DRAW_TOTAL_CLIP_PLANES;
|
* unsigned clipmask:DRAW_TOTAL_CLIP_PLANES;
|
||||||
* unsigned edgeflag:1;
|
* unsigned edgeflag:1;
|
||||||
* unsigned have_clipdist:1;
|
* unsigned pad:1;
|
||||||
* unsigned vertex_id:16;
|
* unsigned vertex_id:16;
|
||||||
* [...]
|
* [...]
|
||||||
* }
|
* }
|
||||||
|
|
@ -838,7 +838,7 @@ store_aos(struct gallivm_state *gallivm,
|
||||||
* {
|
* {
|
||||||
* return (x >> 16) | // vertex_id
|
* return (x >> 16) | // vertex_id
|
||||||
* ((x & 0x3fff) << 18) | // clipmask
|
* ((x & 0x3fff) << 18) | // clipmask
|
||||||
* ((x & 0x4000) << 3) | // have_clipdist
|
* ((x & 0x4000) << 3) | // pad
|
||||||
* ((x & 0x8000) << 1); // edgeflag
|
* ((x & 0x8000) << 1); // edgeflag
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
|
|
@ -850,19 +850,23 @@ adjust_mask(struct gallivm_state *gallivm,
|
||||||
LLVMBuilderRef builder = gallivm->builder;
|
LLVMBuilderRef builder = gallivm->builder;
|
||||||
LLVMValueRef vertex_id;
|
LLVMValueRef vertex_id;
|
||||||
LLVMValueRef clipmask;
|
LLVMValueRef clipmask;
|
||||||
LLVMValueRef have_clipdist;
|
LLVMValueRef pad;
|
||||||
LLVMValueRef edgeflag;
|
LLVMValueRef edgeflag;
|
||||||
|
|
||||||
vertex_id = LLVMBuildLShr(builder, mask, lp_build_const_int32(gallivm, 16), "");
|
vertex_id = LLVMBuildLShr(builder, mask, lp_build_const_int32(gallivm, 16), "");
|
||||||
clipmask = LLVMBuildAnd(builder, mask, lp_build_const_int32(gallivm, 0x3fff), "");
|
clipmask = LLVMBuildAnd(builder, mask, lp_build_const_int32(gallivm, 0x3fff), "");
|
||||||
clipmask = LLVMBuildShl(builder, clipmask, lp_build_const_int32(gallivm, 18), "");
|
clipmask = LLVMBuildShl(builder, clipmask, lp_build_const_int32(gallivm, 18), "");
|
||||||
have_clipdist = LLVMBuildAnd(builder, mask, lp_build_const_int32(gallivm, 0x4000), "");
|
if (0) {
|
||||||
have_clipdist = LLVMBuildShl(builder, have_clipdist, lp_build_const_int32(gallivm, 3), "");
|
pad = LLVMBuildAnd(builder, mask, lp_build_const_int32(gallivm, 0x4000), "");
|
||||||
|
pad = LLVMBuildShl(builder, pad, lp_build_const_int32(gallivm, 3), "");
|
||||||
|
}
|
||||||
edgeflag = LLVMBuildAnd(builder, mask, lp_build_const_int32(gallivm, 0x8000), "");
|
edgeflag = LLVMBuildAnd(builder, mask, lp_build_const_int32(gallivm, 0x8000), "");
|
||||||
edgeflag = LLVMBuildShl(builder, edgeflag, lp_build_const_int32(gallivm, 1), "");
|
edgeflag = LLVMBuildShl(builder, edgeflag, lp_build_const_int32(gallivm, 1), "");
|
||||||
|
|
||||||
mask = LLVMBuildOr(builder, vertex_id, clipmask, "");
|
mask = LLVMBuildOr(builder, vertex_id, clipmask, "");
|
||||||
mask = LLVMBuildOr(builder, mask, have_clipdist, "");
|
if (0) {
|
||||||
|
mask = LLVMBuildOr(builder, mask, pad, "");
|
||||||
|
}
|
||||||
mask = LLVMBuildOr(builder, mask, edgeflag, "");
|
mask = LLVMBuildOr(builder, mask, edgeflag, "");
|
||||||
#endif
|
#endif
|
||||||
return mask;
|
return mask;
|
||||||
|
|
@ -876,8 +880,7 @@ store_aos_array(struct gallivm_state *gallivm,
|
||||||
LLVMValueRef* aos,
|
LLVMValueRef* aos,
|
||||||
int attrib,
|
int attrib,
|
||||||
int num_outputs,
|
int num_outputs,
|
||||||
LLVMValueRef clipmask,
|
LLVMValueRef clipmask)
|
||||||
boolean have_clipdist)
|
|
||||||
{
|
{
|
||||||
LLVMBuilderRef builder = gallivm->builder;
|
LLVMBuilderRef builder = gallivm->builder;
|
||||||
LLVMValueRef attr_index = lp_build_const_int32(gallivm, attrib);
|
LLVMValueRef attr_index = lp_build_const_int32(gallivm, attrib);
|
||||||
|
|
@ -908,10 +911,8 @@ store_aos_array(struct gallivm_state *gallivm,
|
||||||
* code here. See struct vertex_header in draw_private.h.
|
* code here. See struct vertex_header in draw_private.h.
|
||||||
*/
|
*/
|
||||||
assert(DRAW_TOTAL_CLIP_PLANES==14);
|
assert(DRAW_TOTAL_CLIP_PLANES==14);
|
||||||
/* initialize vertex id:16 = 0xffff, have_clipdist:1 = 0, edgeflag:1 = 1 */
|
/* initialize vertex id:16 = 0xffff, pad:1 = 0, edgeflag:1 = 1 */
|
||||||
vertex_id_pad_edgeflag = (0xffff << 16) | (1 << DRAW_TOTAL_CLIP_PLANES);
|
vertex_id_pad_edgeflag = (0xffff << 16) | (1 << DRAW_TOTAL_CLIP_PLANES);
|
||||||
if (have_clipdist)
|
|
||||||
vertex_id_pad_edgeflag |= 1 << (DRAW_TOTAL_CLIP_PLANES+1);
|
|
||||||
val = lp_build_const_int_vec(gallivm, lp_int_type(soa_type), vertex_id_pad_edgeflag);
|
val = lp_build_const_int_vec(gallivm, lp_int_type(soa_type), vertex_id_pad_edgeflag);
|
||||||
/* OR with the clipmask */
|
/* OR with the clipmask */
|
||||||
cliptmp = LLVMBuildOr(builder, val, clipmask, "");
|
cliptmp = LLVMBuildOr(builder, val, clipmask, "");
|
||||||
|
|
@ -998,7 +999,7 @@ convert_to_aos(struct gallivm_state *gallivm,
|
||||||
aos,
|
aos,
|
||||||
attrib,
|
attrib,
|
||||||
num_outputs,
|
num_outputs,
|
||||||
clipmask, have_clipdist);
|
clipmask);
|
||||||
}
|
}
|
||||||
#if DEBUG_STORE
|
#if DEBUG_STORE
|
||||||
lp_build_printf(gallivm, " # storing end\n");
|
lp_build_printf(gallivm, " # storing end\n");
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ struct clip_stage {
|
||||||
struct draw_stage stage; /**< base class */
|
struct draw_stage stage; /**< base class */
|
||||||
|
|
||||||
unsigned pos_attr;
|
unsigned pos_attr;
|
||||||
|
boolean have_clipdist;
|
||||||
|
|
||||||
/* List of the attributes to be constant interpolated. */
|
/* List of the attributes to be constant interpolated. */
|
||||||
uint num_const_attribs;
|
uint num_const_attribs;
|
||||||
|
|
@ -145,7 +146,7 @@ static void interp(const struct clip_stage *clip,
|
||||||
*/
|
*/
|
||||||
dst->clipmask = 0;
|
dst->clipmask = 0;
|
||||||
dst->edgeflag = 0; /* will get overwritten later */
|
dst->edgeflag = 0; /* will get overwritten later */
|
||||||
dst->have_clipdist = in->have_clipdist;
|
dst->pad = 0;
|
||||||
dst->vertex_id = UNDEFINED_VERTEX_ID;
|
dst->vertex_id = UNDEFINED_VERTEX_ID;
|
||||||
|
|
||||||
/* Interpolate the clip-space coords.
|
/* Interpolate the clip-space coords.
|
||||||
|
|
@ -350,7 +351,7 @@ static inline float getclipdist(const struct clip_stage *clipper,
|
||||||
plane = clipper->plane[plane_idx];
|
plane = clipper->plane[plane_idx];
|
||||||
dp = dot4(vert->pre_clip_pos, plane);
|
dp = dot4(vert->pre_clip_pos, plane);
|
||||||
}
|
}
|
||||||
else if (vert->have_clipdist) {
|
else if (clipper->have_clipdist) {
|
||||||
/* pick the correct clipdistance element from the output vectors */
|
/* pick the correct clipdistance element from the output vectors */
|
||||||
int _idx = plane_idx - 6;
|
int _idx = plane_idx - 6;
|
||||||
int cdi = _idx >= 4;
|
int cdi = _idx >= 4;
|
||||||
|
|
@ -782,7 +783,7 @@ find_interp(const struct draw_fragment_shader *fs, int *indexed_interp,
|
||||||
static void
|
static void
|
||||||
clip_init_state(struct draw_stage *stage)
|
clip_init_state(struct draw_stage *stage)
|
||||||
{
|
{
|
||||||
struct clip_stage *clipper = clip_stage( stage );
|
struct clip_stage *clipper = clip_stage(stage);
|
||||||
const struct draw_context *draw = stage->draw;
|
const struct draw_context *draw = stage->draw;
|
||||||
const struct draw_fragment_shader *fs = draw->fs.fragment_shader;
|
const struct draw_fragment_shader *fs = draw->fs.fragment_shader;
|
||||||
const struct tgsi_shader_info *info = draw_get_shader_info(draw);
|
const struct tgsi_shader_info *info = draw_get_shader_info(draw);
|
||||||
|
|
@ -790,6 +791,7 @@ clip_init_state(struct draw_stage *stage)
|
||||||
int indexed_interp[2];
|
int indexed_interp[2];
|
||||||
|
|
||||||
clipper->pos_attr = draw_current_shader_position_output(draw);
|
clipper->pos_attr = draw_current_shader_position_output(draw);
|
||||||
|
clipper->have_clipdist = draw_current_shader_num_written_clipdistances(draw) > 0;
|
||||||
|
|
||||||
/* We need to know for each attribute what kind of interpolation is
|
/* We need to know for each attribute what kind of interpolation is
|
||||||
* done on it (flat, smooth or noperspective). But the information
|
* done on it (flat, smooth or noperspective). But the information
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ struct draw_vertex_buffer {
|
||||||
struct vertex_header {
|
struct vertex_header {
|
||||||
unsigned clipmask:DRAW_TOTAL_CLIP_PLANES;
|
unsigned clipmask:DRAW_TOTAL_CLIP_PLANES;
|
||||||
unsigned edgeflag:1;
|
unsigned edgeflag:1;
|
||||||
unsigned have_clipdist:1;
|
unsigned pad:1;
|
||||||
unsigned vertex_id:16;
|
unsigned vertex_id:16;
|
||||||
|
|
||||||
float clip[4];
|
float clip[4];
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ initialize_vertex_header(struct vertex_header *header)
|
||||||
{
|
{
|
||||||
header->clipmask = 0;
|
header->clipmask = 0;
|
||||||
header->edgeflag = 1;
|
header->edgeflag = 1;
|
||||||
header->have_clipdist = 0;
|
header->pad = 0;
|
||||||
header->vertex_id = UNDEFINED_VERTEX_ID;
|
header->vertex_id = UNDEFINED_VERTEX_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue