#include "brw_context.h"
#include "brw_eu.h"
-#define MAX_VERTS (3+6+6)
+/* Initial 3 verts, plus at most 6 additional verts from intersections
+ * with fixed planes, plus at most 8 additional verts from intersections
+ * with user clip planes
+ */
+#define MAX_VERTS (3+6+8)
/* Note that if unfilled primitives are being emitted, we have to fix
* up polygon offset and flatshading at this point:
if (unlikely(INTEL_DEBUG & DEBUG_STATS))
clip->thread4.stats_enable = 1;
- clip->clip5.userclip_enable_flags = 0x7f;
+ /* _NEW_TRANSFORM */
+ if (brw->gen == 5 || brw->is_g4x)
+ clip->clip5.userclip_enable_flags = ctx->Transform.ClipPlanesEnabled;
+ else
+ /* Up to 6 actual clip flags, plus the 7th for negative RHW workaround. */
+ clip->clip5.userclip_enable_flags = (ctx->Transform.ClipPlanesEnabled & 0x3f) | 0x40;
+
clip->clip5.userclip_must_clip = 1;
/* enable guardband clipping if we can */
brw_MOV(p, get_addr_reg(freelist_ptr), brw_address(c->reg.vertex[3]) );
/* Set the initial vertex source mask: The first 6 planes are the bounds
- * of the view volume; the next 6 planes are the user clipping planes.
+ * of the view volume; the next 8 planes are the user clipping planes.
*/
- brw_MOV(p, c->reg.vertex_src_mask, brw_imm_ud(0xfc0));
+ brw_MOV(p, c->reg.vertex_src_mask, brw_imm_ud(0x3fc0));
/* Set the initial clipdistance offset to be 6 floats before gl_ClipDistance[0].
* We'll increment 6 times before we start hitting actual user clipping. */
{
struct brw_compile *p = &c->func;
struct brw_reg incoming = get_element_ud(c->reg.R0, 2);
+ struct brw_context *brw = p->brw;
/* Shift so that lowest outcode bit is rightmost:
*/
/* Rearrange userclip outcodes so that they come directly after
* the fixed plane bits.
*/
- brw_AND(p, tmp, incoming, brw_imm_ud(0x3f<<14));
+ if (brw->gen == 5 || brw->is_g4x)
+ brw_AND(p, tmp, incoming, brw_imm_ud(0xff<<14));
+ else
+ brw_AND(p, tmp, incoming, brw_imm_ud(0x3f<<14));
+
brw_SHR(p, tmp, tmp, brw_imm_ud(8));
brw_OR(p, c->reg.planemask, c->reg.planemask, tmp);
ctx->Const.MaxPointSizeAA = 255.0;
ctx->Const.PointSizeGranularity = 1.0;
- if (brw->gen >= 6)
+ if (brw->gen >= 5 || brw->is_g4x)
ctx->Const.MaxClipPlanes = 8;
ctx->Const.VertexProgram.MaxNativeInstructions = 16 * 1024;