18e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell/**************************************************************************
28e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell *
3ee295fccdd0c94cb6b8af4dfb30283e39f548223Michal Krol * 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
28f79c225d9e5adee6287a9bba35f014c3fe00d3f9Brian#include "pipe/p_defines.h"
294f25420bdd834e81a3e22733304efc5261c2998aBrian Paul#include "util/u_memory.h"
306393cda6766b707ef01e925d378239a66d143ae0Keith Whitwell#include "sp_context.h"
316393cda6766b707ef01e925d378239a66d143ae0Keith Whitwell#include "sp_state.h"
326acd63a4980951727939c0dd545a0324965b3834José Fonseca#include "draw/draw_context.h"
338e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
348e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
35294401814d1d89cc731de1c22c25333aa5d59374Zack Rusin
36bd13a0d282d5468c083d06f4443dfaf375e01ddaBrian Paulstatic void *
37294401814d1d89cc731de1c22c25333aa5d59374Zack Rusinsoftpipe_create_rasterizer_state(struct pipe_context *pipe,
38f12d641ab2bafe20f876dddb90ada76c83732757Brian                                 const struct pipe_rasterizer_state *rast)
39294401814d1d89cc731de1c22c25333aa5d59374Zack Rusin{
40f12d641ab2bafe20f876dddb90ada76c83732757Brian   return mem_dup(rast, sizeof(*rast));
41294401814d1d89cc731de1c22c25333aa5d59374Zack Rusin}
42294401814d1d89cc731de1c22c25333aa5d59374Zack Rusin
43bd13a0d282d5468c083d06f4443dfaf375e01ddaBrian Paul
44bd13a0d282d5468c083d06f4443dfaf375e01ddaBrian Paulstatic void
45bd13a0d282d5468c083d06f4443dfaf375e01ddaBrian Paulsoftpipe_bind_rasterizer_state(struct pipe_context *pipe,
46bd13a0d282d5468c083d06f4443dfaf375e01ddaBrian Paul                               void *rasterizer)
478e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell{
486393cda6766b707ef01e925d378239a66d143ae0Keith Whitwell   struct softpipe_context *softpipe = softpipe_context(pipe);
498e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
504ccf0bb74e7f88ff51bba64a2a94a29f997231f5José Fonseca   if (softpipe->rasterizer == rasterizer)
514ccf0bb74e7f88ff51bba64a2a94a29f997231f5José Fonseca      return;
524ccf0bb74e7f88ff51bba64a2a94a29f997231f5José Fonseca
53279ffe3f163fd6a5e7bfa108db14c81acbb06eceBrian   /* pass-through to draw module */
54e3a34cc7f6c9f959cdc2af4486e84587fab4d0d7Brian Paul   draw_set_rasterizer_state(softpipe->draw, rasterizer, rasterizer);
55279ffe3f163fd6a5e7bfa108db14c81acbb06eceBrian
564ccf0bb74e7f88ff51bba64a2a94a29f997231f5José Fonseca   softpipe->rasterizer = rasterizer;
57294401814d1d89cc731de1c22c25333aa5d59374Zack Rusin
58294401814d1d89cc731de1c22c25333aa5d59374Zack Rusin   softpipe->dirty |= SP_NEW_RASTERIZER;
59294401814d1d89cc731de1c22c25333aa5d59374Zack Rusin}
608e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
61bd13a0d282d5468c083d06f4443dfaf375e01ddaBrian Paul
62bd13a0d282d5468c083d06f4443dfaf375e01ddaBrian Paulstatic void
63bd13a0d282d5468c083d06f4443dfaf375e01ddaBrian Paulsoftpipe_delete_rasterizer_state(struct pipe_context *pipe,
64bd13a0d282d5468c083d06f4443dfaf375e01ddaBrian Paul                                 void *rasterizer)
65294401814d1d89cc731de1c22c25333aa5d59374Zack Rusin{
66ee295fccdd0c94cb6b8af4dfb30283e39f548223Michal Krol   FREE( rasterizer );
678e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell}
688e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
698e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
70bd13a0d282d5468c083d06f4443dfaf375e01ddaBrian Paulvoid
71bd13a0d282d5468c083d06f4443dfaf375e01ddaBrian Paulsoftpipe_init_rasterizer_funcs(struct pipe_context *pipe)
72bd13a0d282d5468c083d06f4443dfaf375e01ddaBrian Paul{
73bd13a0d282d5468c083d06f4443dfaf375e01ddaBrian Paul   pipe->create_rasterizer_state = softpipe_create_rasterizer_state;
74bd13a0d282d5468c083d06f4443dfaf375e01ddaBrian Paul   pipe->bind_rasterizer_state   = softpipe_bind_rasterizer_state;
75bd13a0d282d5468c083d06f4443dfaf375e01ddaBrian Paul   pipe->delete_rasterizer_state = softpipe_delete_rasterizer_state;
76bd13a0d282d5468c083d06f4443dfaf375e01ddaBrian Paul}
77