18e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell/************************************************************************** 28e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * 38e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. 48e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * All Rights Reserved. 58e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * 68e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * Permission is hereby granted, free of charge, to any person obtaining a 78e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * copy of this software and associated documentation files (the 88e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * "Software"), to deal in the Software without restriction, including 98e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * without limitation the rights to use, copy, modify, merge, publish, 108e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * distribute, sub license, and/or sell copies of the Software, and to 118e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * permit persons to whom the Software is furnished to do so, subject to 128e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * the following conditions: 138e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * 148e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * The above copyright notice and this permission notice (including the 158e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * next paragraph) shall be included in all copies or substantial portions 168e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * of the Software. 178e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * 188e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 198e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 208e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 218e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR 228e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 238e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 248e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 258e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * 268e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell **************************************************************************/ 278e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell 288e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell /* 298e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * Authors: 308e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * Keith Whitwell <keith@tungstengraphics.com> 318e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell */ 328e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell 338e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell 348e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell#include "st_context.h" 35943964a1e5bad86bdceb0a06d60fb3b302ebce6aKeith Whitwell#include "pipe/p_context.h" 368e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell#include "st_atom.h" 37a103c61d278b7f56208818c4b949c408c00286faDave Airlie#include "st_program.h" 38dc4c821f0817a3db716f965692fb701079f66340Marek Olšák#include "util/u_debug.h" 398039ee09b8c78a70c1c50207cce9a7bb4cffc675Michal Krol#include "cso_cache/cso_context.h" 408039ee09b8c78a70c1c50207cce9a7bb4cffc675Michal Krol 418e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell 428e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell/* Second state atom for user clip planes: 438e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell */ 448e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwellstatic void update_clip( struct st_context *st ) 458e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell{ 46943964a1e5bad86bdceb0a06d60fb3b302ebce6aKeith Whitwell struct pipe_clip_state clip; 4799feecc7d1d0a6efb2511859973d6029d9fed9fdBrian Paul const struct gl_context *ctx = st->ctx; 48a103c61d278b7f56208818c4b949c408c00286faDave Airlie bool use_eye = FALSE; 498e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell 50322a2938f320f8a39cb6d86f249a339625a8772aBrian Paul STATIC_ASSERT(sizeof(clip.ucp) <= sizeof(ctx->Transform._ClipUserPlane)); 518e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell 52a103c61d278b7f56208818c4b949c408c00286faDave Airlie /* if we have a vertex shader that writes clip vertex we need to pass 53a103c61d278b7f56208818c4b949c408c00286faDave Airlie the pre-projection transformed coordinates into the driver. */ 54a103c61d278b7f56208818c4b949c408c00286faDave Airlie if (st->vp) { 55a103c61d278b7f56208818c4b949c408c00286faDave Airlie if (ctx->Shader.CurrentVertexProgram) 56a103c61d278b7f56208818c4b949c408c00286faDave Airlie use_eye = TRUE; 57a103c61d278b7f56208818c4b949c408c00286faDave Airlie } 58a103c61d278b7f56208818c4b949c408c00286faDave Airlie 59dc4c821f0817a3db716f965692fb701079f66340Marek Olšák memcpy(clip.ucp, 60dc4c821f0817a3db716f965692fb701079f66340Marek Olšák use_eye ? ctx->Transform.EyeUserPlane 61dc4c821f0817a3db716f965692fb701079f66340Marek Olšák : ctx->Transform._ClipUserPlane, sizeof(clip.ucp)); 62dc4c821f0817a3db716f965692fb701079f66340Marek Olšák st->state.clip = clip; 63dc4c821f0817a3db716f965692fb701079f66340Marek Olšák cso_set_clip(st->cso_context, &clip); 648e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell} 658e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell 668e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell 678e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwellconst struct st_tracked_state st_update_clip = { 6854507125e735ffa595e252282eaabf38095c21e1Alan Hourihane "st_update_clip", /* name */ 6954507125e735ffa595e252282eaabf38095c21e1Alan Hourihane { /* dirty */ 70a103c61d278b7f56208818c4b949c408c00286faDave Airlie (_NEW_TRANSFORM | _NEW_PROGRAM), /* mesa */ 7154507125e735ffa595e252282eaabf38095c21e1Alan Hourihane 0, /* st */ 728e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell }, 7354507125e735ffa595e252282eaabf38095c21e1Alan Hourihane update_clip /* update */ 748e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell}; 75