mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 09:18:04 +02:00
draw: asst. clean-ups in draw_pt_post_vs.c
Signed-off-by: Brian Paul <brianp@vmware.com> Acked-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19024>
This commit is contained in:
parent
6f1b99ab06
commit
b813bab889
2 changed files with 47 additions and 57 deletions
|
|
@ -46,7 +46,6 @@ struct pt_emit {
|
|||
const struct vertex_info *vinfo;
|
||||
|
||||
float zero4[4];
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -57,9 +56,7 @@ draw_pt_emit_prepare(struct pt_emit *emit,
|
|||
{
|
||||
struct draw_context *draw = emit->draw;
|
||||
const struct vertex_info *vinfo;
|
||||
unsigned dst_offset;
|
||||
struct translate_key hw_key;
|
||||
unsigned i;
|
||||
|
||||
/* XXX: need to flush to get prim_vbuf.c to release its allocation??
|
||||
*/
|
||||
|
|
@ -80,8 +77,8 @@ draw_pt_emit_prepare(struct pt_emit *emit,
|
|||
|
||||
/* Translate from pipeline vertices to hw vertices.
|
||||
*/
|
||||
dst_offset = 0;
|
||||
for (i = 0; i < vinfo->num_attribs; i++) {
|
||||
unsigned dst_offset = 0;
|
||||
for (unsigned i = 0; i < vinfo->num_attribs; i++) {
|
||||
unsigned emit_sz = 0;
|
||||
unsigned src_buffer = 0;
|
||||
unsigned output_format;
|
||||
|
|
@ -96,8 +93,7 @@ draw_pt_emit_prepare(struct pt_emit *emit,
|
|||
if (vinfo->attrib[i].emit == EMIT_1F_PSIZE) {
|
||||
src_buffer = 1;
|
||||
src_offset = 0;
|
||||
}
|
||||
else if (vinfo->attrib[i].src_index == DRAW_ATTR_NONEXIST) {
|
||||
} else if (vinfo->attrib[i].src_index == DRAW_ATTR_NONEXIST) {
|
||||
/* elements which don't exist will get assigned zeros */
|
||||
src_buffer = 2;
|
||||
src_offset = 0;
|
||||
|
|
@ -197,8 +193,7 @@ draw_pt_emit(struct pt_emit *emit,
|
|||
|
||||
for (start = i = 0;
|
||||
i < prim_info->primitive_count;
|
||||
start += prim_info->primitive_lengths[i], i++)
|
||||
{
|
||||
start += prim_info->primitive_lengths[i], i++) {
|
||||
render->draw_elements(render,
|
||||
elts + start,
|
||||
prim_info->primitive_lengths[i]);
|
||||
|
|
@ -261,8 +256,7 @@ draw_pt_emit_linear(struct pt_emit *emit,
|
|||
hw_verts);
|
||||
|
||||
if (0) {
|
||||
unsigned i;
|
||||
for (i = 0; i < count; i++) {
|
||||
for (unsigned i = 0; i < count; i++) {
|
||||
debug_printf("\n\n%s vertex %d:\n", __FUNCTION__, i);
|
||||
draw_dump_emitted_vertex(emit->vinfo,
|
||||
(const uint8_t *)hw_verts +
|
||||
|
|
@ -274,8 +268,7 @@ draw_pt_emit_linear(struct pt_emit *emit,
|
|||
|
||||
for (start = i = 0;
|
||||
i < prim_info->primitive_count;
|
||||
start += prim_info->primitive_lengths[i], i++)
|
||||
{
|
||||
start += prim_info->primitive_lengths[i], i++) {
|
||||
render->draw_arrays(render,
|
||||
start,
|
||||
prim_info->primitive_lengths[i]);
|
||||
|
|
|
|||
|
|
@ -48,11 +48,12 @@ struct pt_post_vs {
|
|||
|
||||
unsigned flags;
|
||||
|
||||
boolean (*run)( struct pt_post_vs *pvs,
|
||||
struct draw_vertex_info *info,
|
||||
const struct draw_prim_info *prim_info );
|
||||
boolean (*run)(struct pt_post_vs *pvs,
|
||||
struct draw_vertex_info *info,
|
||||
const struct draw_prim_info *prim_info);
|
||||
};
|
||||
|
||||
|
||||
static inline void
|
||||
initialize_vertex_header(struct vertex_header *header)
|
||||
{
|
||||
|
|
@ -62,15 +63,17 @@ initialize_vertex_header(struct vertex_header *header)
|
|||
header->vertex_id = UNDEFINED_VERTEX_ID;
|
||||
}
|
||||
|
||||
|
||||
static inline float
|
||||
dot4(const float *a, const float *b)
|
||||
{
|
||||
return (a[0]*b[0] +
|
||||
a[1]*b[1] +
|
||||
a[2]*b[2] +
|
||||
a[3]*b[3]);
|
||||
return (a[0] * b[0] +
|
||||
a[1] * b[1] +
|
||||
a[2] * b[2] +
|
||||
a[3] * b[3]);
|
||||
}
|
||||
|
||||
|
||||
#define FLAGS (0)
|
||||
#define TAG(x) x##_none
|
||||
#include "draw_cliptest_tmp.h"
|
||||
|
|
@ -119,48 +122,48 @@ dot4(const float *a, const float *b)
|
|||
#include "draw_cliptest_tmp.h"
|
||||
|
||||
|
||||
|
||||
boolean draw_pt_post_vs_run( struct pt_post_vs *pvs,
|
||||
struct draw_vertex_info *info,
|
||||
const struct draw_prim_info *prim_info )
|
||||
boolean
|
||||
draw_pt_post_vs_run(struct pt_post_vs *pvs,
|
||||
struct draw_vertex_info *info,
|
||||
const struct draw_prim_info *prim_info)
|
||||
{
|
||||
return pvs->run( pvs, info, prim_info );
|
||||
return pvs->run(pvs, info, prim_info);
|
||||
}
|
||||
|
||||
|
||||
void draw_pt_post_vs_prepare( struct pt_post_vs *pvs,
|
||||
boolean clip_xy,
|
||||
boolean clip_z,
|
||||
boolean clip_user,
|
||||
boolean guard_band,
|
||||
boolean bypass_viewport,
|
||||
boolean clip_halfz,
|
||||
boolean need_edgeflags )
|
||||
void
|
||||
draw_pt_post_vs_prepare(struct pt_post_vs *pvs,
|
||||
boolean clip_xy,
|
||||
boolean clip_z,
|
||||
boolean clip_user,
|
||||
boolean guard_band,
|
||||
boolean bypass_viewport,
|
||||
boolean clip_halfz,
|
||||
boolean need_edgeflags)
|
||||
{
|
||||
pvs->flags = 0;
|
||||
|
||||
if (clip_xy && !guard_band) {
|
||||
pvs->flags |= DO_CLIP_XY;
|
||||
ASSIGN_4V( pvs->draw->plane[0], -1, 0, 0, 1 );
|
||||
ASSIGN_4V( pvs->draw->plane[1], 1, 0, 0, 1 );
|
||||
ASSIGN_4V( pvs->draw->plane[2], 0, -1, 0, 1 );
|
||||
ASSIGN_4V( pvs->draw->plane[3], 0, 1, 0, 1 );
|
||||
}
|
||||
else if (clip_xy && guard_band) {
|
||||
ASSIGN_4V(pvs->draw->plane[0], -1, 0, 0, 1);
|
||||
ASSIGN_4V(pvs->draw->plane[1], 1, 0, 0, 1);
|
||||
ASSIGN_4V(pvs->draw->plane[2], 0, -1, 0, 1);
|
||||
ASSIGN_4V(pvs->draw->plane[3], 0, 1, 0, 1);
|
||||
} else if (clip_xy && guard_band) {
|
||||
pvs->flags |= DO_CLIP_XY_GUARD_BAND;
|
||||
ASSIGN_4V( pvs->draw->plane[0], -0.5, 0, 0, 1 );
|
||||
ASSIGN_4V( pvs->draw->plane[1], 0.5, 0, 0, 1 );
|
||||
ASSIGN_4V( pvs->draw->plane[2], 0, -0.5, 0, 1 );
|
||||
ASSIGN_4V( pvs->draw->plane[3], 0, 0.5, 0, 1 );
|
||||
ASSIGN_4V(pvs->draw->plane[0], -0.5, 0, 0, 1);
|
||||
ASSIGN_4V(pvs->draw->plane[1], 0.5, 0, 0, 1);
|
||||
ASSIGN_4V(pvs->draw->plane[2], 0, -0.5, 0, 1);
|
||||
ASSIGN_4V(pvs->draw->plane[3], 0, 0.5, 0, 1);
|
||||
}
|
||||
|
||||
if (clip_z) {
|
||||
if (clip_halfz) {
|
||||
pvs->flags |= DO_CLIP_HALF_Z;
|
||||
ASSIGN_4V( pvs->draw->plane[4], 0, 0, 1, 0 );
|
||||
ASSIGN_4V(pvs->draw->plane[4], 0, 0, 1, 0);
|
||||
} else {
|
||||
pvs->flags |= DO_CLIP_FULL_Z;
|
||||
ASSIGN_4V( pvs->draw->plane[4], 0, 0, 1, 1 );
|
||||
ASSIGN_4V(pvs->draw->plane[4], 0, 0, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -179,40 +182,31 @@ void draw_pt_post_vs_prepare( struct pt_post_vs *pvs,
|
|||
case 0:
|
||||
pvs->run = do_cliptest_none;
|
||||
break;
|
||||
|
||||
case DO_CLIP_XY | DO_CLIP_FULL_Z | DO_VIEWPORT:
|
||||
pvs->run = do_cliptest_xy_fullz_viewport;
|
||||
break;
|
||||
|
||||
case DO_CLIP_XY | DO_CLIP_HALF_Z | DO_VIEWPORT:
|
||||
pvs->run = do_cliptest_xy_halfz_viewport;
|
||||
break;
|
||||
|
||||
case DO_CLIP_XY_GUARD_BAND | DO_CLIP_HALF_Z | DO_VIEWPORT:
|
||||
pvs->run = do_cliptest_xy_gb_halfz_viewport;
|
||||
break;
|
||||
|
||||
case DO_CLIP_XY_GUARD_BAND | DO_CLIP_FULL_Z | DO_VIEWPORT:
|
||||
pvs->run = do_cliptest_xy_gb_fullz_viewport;
|
||||
break;
|
||||
|
||||
case DO_CLIP_FULL_Z | DO_VIEWPORT:
|
||||
pvs->run = do_cliptest_fullz_viewport;
|
||||
break;
|
||||
|
||||
case DO_CLIP_HALF_Z | DO_VIEWPORT:
|
||||
pvs->run = do_cliptest_halfz_viewport;
|
||||
break;
|
||||
|
||||
case DO_CLIP_XY | DO_CLIP_FULL_Z | DO_CLIP_USER | DO_VIEWPORT:
|
||||
pvs->run = do_cliptest_xy_fullz_user_viewport;
|
||||
break;
|
||||
|
||||
case (DO_CLIP_XY | DO_CLIP_FULL_Z | DO_CLIP_USER |
|
||||
DO_VIEWPORT | DO_EDGEFLAG):
|
||||
pvs->run = do_cliptest_xy_fullz_user_viewport_edgeflag;
|
||||
break;
|
||||
|
||||
default:
|
||||
pvs->run = do_cliptest_generic;
|
||||
break;
|
||||
|
|
@ -220,9 +214,10 @@ void draw_pt_post_vs_prepare( struct pt_post_vs *pvs,
|
|||
}
|
||||
|
||||
|
||||
struct pt_post_vs *draw_pt_post_vs_create( struct draw_context *draw )
|
||||
struct pt_post_vs *
|
||||
draw_pt_post_vs_create(struct draw_context *draw)
|
||||
{
|
||||
struct pt_post_vs *pvs = CALLOC_STRUCT( pt_post_vs );
|
||||
struct pt_post_vs *pvs = CALLOC_STRUCT(pt_post_vs);
|
||||
if (!pvs)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -231,7 +226,9 @@ struct pt_post_vs *draw_pt_post_vs_create( struct draw_context *draw )
|
|||
return pvs;
|
||||
}
|
||||
|
||||
void draw_pt_post_vs_destroy( struct pt_post_vs *pvs )
|
||||
|
||||
void
|
||||
draw_pt_post_vs_destroy(struct pt_post_vs *pvs)
|
||||
{
|
||||
FREE(pvs);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue