#include "st_context.h"
#include "pipe/p_context.h"
#include "st_atom.h"
+#include "st_program.h"
+#include "util/u_debug.h"
+#include "cso_cache/cso_context.h"
/* Second state atom for user clip planes:
static void update_clip( struct st_context *st )
{
struct pipe_clip_state clip;
- GLuint i;
+ const struct gl_context *ctx = st->ctx;
+ bool use_eye = FALSE;
- memset(&clip, 0, sizeof(clip));
+ STATIC_ASSERT(sizeof(clip.ucp) <= sizeof(ctx->Transform._ClipUserPlane));
- for (i = 0; i < PIPE_MAX_CLIP_PLANES; i++) {
- if (st->ctx->Transform.ClipPlanesEnabled & (1 << i)) {
- memcpy(clip.ucp[clip.nr],
- st->ctx->Transform._ClipUserPlane[i],
- sizeof(clip.ucp[0]));
- clip.nr++;
- }
- }
-
- if (memcmp(&clip, &st->state.clip, sizeof(clip)) != 0) {
- st->state.clip = clip;
- st->pipe->set_clip_state(st->pipe, &clip);
+ /* if we have a vertex shader that writes clip vertex we need to pass
+ the pre-projection transformed coordinates into the driver. */
+ if (st->vp) {
+ if (ctx->Shader.CurrentVertexProgram)
+ use_eye = TRUE;
}
+
+ memcpy(clip.ucp,
+ use_eye ? ctx->Transform.EyeUserPlane
+ : ctx->Transform._ClipUserPlane, sizeof(clip.ucp));
+ st->state.clip = clip;
+ cso_set_clip(st->cso_context, &clip);
}
const struct st_tracked_state st_update_clip = {
"st_update_clip", /* name */
{ /* dirty */
- (_NEW_TRANSFORM), /* mesa */
- 0, /* st */
+ _NEW_TRANSFORM, /* mesa */
+ ST_NEW_VERTEX_PROGRAM, /* st */
},
update_clip /* update */
};