**************************************************************************/
static boolean TAG(do_cliptest)( struct pt_post_vs *pvs,
- struct draw_vertex_info *info )
+ struct draw_vertex_info *info,
+ const struct draw_prim_info *prim_info )
{
struct vertex_header *out = info->verts;
/* const */ float (*plane)[4] = pvs->draw->plane;
bool have_cd = false;
unsigned viewport_index_output =
draw_current_shader_viewport_index_output(pvs->draw);
+ int viewport_index =
+ draw_current_shader_uses_viewport_index(pvs->draw) ?
+ *((unsigned*)out->data[viewport_index_output]): 0;
cd[0] = draw_current_shader_clipdistance_output(pvs->draw, 0);
cd[1] = draw_current_shader_clipdistance_output(pvs->draw, 1);
for (j = 0; j < info->count; j++) {
float *position = out->data[pos];
- int viewport_index =
- draw_current_shader_uses_viewport_index(pvs->draw) ?
- *((unsigned*)out->data[viewport_index_output]): 0;
unsigned mask = 0x0;
- const float *scale = pvs->draw->viewports[
- draw_clamp_viewport_idx(viewport_index)].scale;
- const float *trans = pvs->draw->viewports[
- draw_clamp_viewport_idx(viewport_index)].translate;
+ float *scale = pvs->draw->viewports[0].scale;
+ float *trans = pvs->draw->viewports[0].translate;
+ if (draw_current_shader_uses_viewport_index(pvs->draw)) {
+ unsigned verts_per_prim = u_vertices_per_prim(prim_info->prim);
+ /* only change the viewport_index for the leading vertex */
+ if (!(j % verts_per_prim)) {
+ viewport_index = *((unsigned*)out->data[viewport_index_output]);
+ viewport_index = draw_clamp_viewport_idx(viewport_index);
+ }
+ scale = pvs->draw->viewports[viewport_index].scale;
+ trans = pvs->draw->viewports[viewport_index].translate;
+ }
initialize_vertex_header(out);
return (struct clip_stage *)stage;
}
+static INLINE unsigned
+draw_viewport_index(struct draw_context *draw,
+ const struct vertex_header *leading_vertex)
+{
+ if (draw_current_shader_uses_viewport_index(draw)) {
+ unsigned viewport_index_output =
+ draw_current_shader_viewport_index_output(draw);
+ unsigned viewport_index =
+ *((unsigned*)leading_vertex->data[viewport_index_output]);
+ return draw_clamp_viewport_idx(viewport_index);
+ } else {
+ return 0;
+ }
+}
+
#define LINTERP(T, OUT, IN) ((OUT) + (T) * ((IN) - (OUT)))
struct vertex_header *dst,
float t,
const struct vertex_header *out,
- const struct vertex_header *in )
+ const struct vertex_header *in,
+ unsigned viewport_index )
{
const unsigned nr_attrs = draw_current_shader_outputs(clip->stage.draw);
const unsigned pos_attr = draw_current_shader_position_output(clip->stage.draw);
const unsigned clip_attr = draw_current_shader_clipvertex_output(clip->stage.draw);
unsigned j;
float t_nopersp;
- unsigned viewport_index_output =
- draw_current_shader_viewport_index_output(clip->stage.draw);
/* Vertex header.
*/
* new window coordinates:
*/
{
- int viewport_index =
- draw_current_shader_uses_viewport_index(clip->stage.draw) ?
- *((unsigned*)in->data[viewport_index_output]) : 0;
const float *pos = dst->pre_clip_pos;
const float *scale =
- clip->stage.draw->viewports[
- draw_clamp_viewport_idx(viewport_index)].scale;
+ clip->stage.draw->viewports[viewport_index].scale;
const float *trans =
- clip->stage.draw->viewports[
- draw_clamp_viewport_idx(viewport_index)].translate;
+ clip->stage.draw->viewports[viewport_index].translate;
const float oow = 1.0f / pos[3];
dst->data[pos_attr][0] = pos[0] * oow * scale[0] + trans[0];
boolean bEdges[MAX_CLIPPED_VERTICES];
boolean *inEdges = aEdges;
boolean *outEdges = bEdges;
+ int viewport_index = 0;
inlist[0] = header->v[0];
inlist[1] = header->v[1];
inlist[2] = header->v[2];
+ viewport_index = draw_viewport_index(clipper->stage.draw, inlist[0]);
+
if (DEBUG_CLIP) {
const float *v0 = header->v[0]->clip;
const float *v1 = header->v[1]->clip;
* know dp != dp_prev from DIFFERENT_SIGNS, above.
*/
float t = dp / (dp - dp_prev);
- interp( clipper, new_vert, t, vert, vert_prev );
+ interp( clipper, new_vert, t, vert, vert_prev, viewport_index );
/* Whether or not to set edge flag for the new vert depends
* on whether it's a user-defined clipping plane. We're
/* Coming back in.
*/
float t = dp_prev / (dp_prev - dp);
- interp( clipper, new_vert, t, vert_prev, vert );
+ interp( clipper, new_vert, t, vert_prev, vert, viewport_index );
/* Copy starting vert's edgeflag:
*/
float t0 = 0.0F;
float t1 = 0.0F;
struct prim_header newprim;
+ int viewport_index = draw_viewport_index(clipper->stage.draw, v0);
while (clipmask) {
const unsigned plane_idx = ffs(clipmask)-1;
}
if (v0->clipmask) {
- interp( clipper, stage->tmp[0], t0, v0, v1 );
+ interp( clipper, stage->tmp[0], t0, v0, v1, viewport_index );
copy_flat(stage, stage->tmp[0], v0);
newprim.v[0] = stage->tmp[0];
}
}
if (v1->clipmask) {
- interp( clipper, stage->tmp[1], t1, v1, v0 );
+ interp( clipper, stage->tmp[1], t1, v1, v0, viewport_index );
newprim.v[1] = stage->tmp[1];
}
else {
#include "util/u_memory.h"
#include "util/u_math.h"
+#include "util/u_prim.h"
#include "pipe/p_context.h"
#include "draw/draw_context.h"
#include "draw/draw_private.h"
unsigned flags;
boolean (*run)( struct pt_post_vs *pvs,
- struct draw_vertex_info *info );
+ struct draw_vertex_info *info,
+ const struct draw_prim_info *prim_info );
};
static INLINE void
boolean draw_pt_post_vs_run( struct pt_post_vs *pvs,
- struct draw_vertex_info *info )
+ struct draw_vertex_info *info,
+ const struct draw_prim_info *prim_info )
{
- return pvs->run( pvs, info );
+ return pvs->run( pvs, info, prim_info );
}