Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
  2.  
  3. /*
  4.  * Copyright (C) 2013 Rob Clark <robclark@freedesktop.org>
  5.  *
  6.  * Permission is hereby granted, free of charge, to any person obtaining a
  7.  * copy of this software and associated documentation files (the "Software"),
  8.  * to deal in the Software without restriction, including without limitation
  9.  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10.  * and/or sell copies of the Software, and to permit persons to whom the
  11.  * Software is furnished to do so, subject to the following conditions:
  12.  *
  13.  * The above copyright notice and this permission notice (including the next
  14.  * paragraph) shall be included in all copies or substantial portions of the
  15.  * Software.
  16.  *
  17.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  20.  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21.  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22.  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  23.  * SOFTWARE.
  24.  *
  25.  * Authors:
  26.  *    Rob Clark <robclark@freedesktop.org>
  27.  */
  28.  
  29.  
  30. #include "pipe/p_state.h"
  31. #include "util/u_string.h"
  32. #include "util/u_memory.h"
  33.  
  34. #include "fd3_rasterizer.h"
  35. #include "fd3_context.h"
  36. #include "fd3_util.h"
  37.  
  38. void *
  39. fd3_rasterizer_state_create(struct pipe_context *pctx,
  40.                 const struct pipe_rasterizer_state *cso)
  41. {
  42.         struct fd3_rasterizer_stateobj *so;
  43.  
  44.         so = CALLOC_STRUCT(fd3_rasterizer_stateobj);
  45.         if (!so)
  46.                 return NULL;
  47.  
  48.         so->base = *cso;
  49.  
  50. /*
  51.         if (cso->line_stipple_enable) {
  52.                 ??? TODO line stipple
  53.         }
  54.         TODO cso->half_pixel_center
  55.         TODO cso->point_size
  56.         TODO psize_min/psize_max
  57. */
  58.         so->gras_cl_clip_cntl = A3XX_GRAS_CL_CLIP_CNTL_IJ_PERSP_CENTER; /* ??? */
  59.         so->gras_su_point_minmax = 0xffc00010;  /* ??? */
  60.         so->gras_su_point_size   = 0x00000008;  /* ??? */
  61.         so->gras_su_poly_offset_scale =
  62.                         A3XX_GRAS_SU_POLY_OFFSET_SCALE_VAL(cso->offset_scale);
  63.         so->gras_su_poly_offset_offset =
  64.                         A3XX_GRAS_SU_POLY_OFFSET_OFFSET(cso->offset_units);
  65.  
  66.         so->gras_su_mode_control =
  67.                         A3XX_GRAS_SU_MODE_CONTROL_LINEHALFWIDTH(cso->line_width/2);
  68.  
  69.         so->pc_prim_vtx_cntl =
  70.                 A3XX_PC_PRIM_VTX_CNTL_POLYMODE_FRONT_PTYPE(fd_polygon_mode(cso->fill_front)) |
  71.                 A3XX_PC_PRIM_VTX_CNTL_POLYMODE_BACK_PTYPE(fd_polygon_mode(cso->fill_back));
  72.  
  73.         if (cso->cull_face & PIPE_FACE_FRONT)
  74.                 so->gras_su_mode_control |= A3XX_GRAS_SU_MODE_CONTROL_CULL_FRONT;
  75.         if (cso->cull_face & PIPE_FACE_BACK)
  76.                 so->gras_su_mode_control |= A3XX_GRAS_SU_MODE_CONTROL_CULL_BACK;
  77.         if (!cso->flatshade_first)
  78.                 so->pc_prim_vtx_cntl |= A3XX_PC_PRIM_VTX_CNTL_PROVOKING_VTX_LAST;
  79. /*
  80.         if (!cso->front_ccw)
  81.                 TODO
  82.         if (cso->line_stipple_enable)
  83.                 TODO
  84.         if (cso->multisample)
  85.                 TODO
  86. */
  87.  
  88.         if (cso->offset_tri)
  89.                 so->gras_su_mode_control |= A3XX_GRAS_SU_MODE_CONTROL_POLY_OFFSET;
  90.  
  91.         return so;
  92. }
  93.