Path: blob/21.2-virgl/src/gallium/drivers/freedreno/a2xx/fd2_rasterizer.c
4574 views
/*1* Copyright (C) 2012-2013 Rob Clark <[email protected]>2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,19* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE20* SOFTWARE.21*22* Authors:23* Rob Clark <[email protected]>24*/2526#include "pipe/p_state.h"27#include "util/u_memory.h"28#include "util/u_string.h"2930#include "fd2_context.h"31#include "fd2_rasterizer.h"32#include "fd2_util.h"3334void *35fd2_rasterizer_state_create(struct pipe_context *pctx,36const struct pipe_rasterizer_state *cso)37{38struct fd2_rasterizer_stateobj *so;39float psize_min, psize_max;4041so = CALLOC_STRUCT(fd2_rasterizer_stateobj);42if (!so)43return NULL;4445if (cso->point_size_per_vertex) {46psize_min = util_get_min_point_size(cso);47psize_max = 8192.0 - 0.0625;48} else {49/* Force the point size to be as if the vertex output was disabled. */50psize_min = cso->point_size;51psize_max = cso->point_size;52}5354so->base = *cso;5556so->pa_sc_line_stipple =57cso->line_stipple_enable58? A2XX_PA_SC_LINE_STIPPLE_LINE_PATTERN(cso->line_stipple_pattern) |59A2XX_PA_SC_LINE_STIPPLE_REPEAT_COUNT(cso->line_stipple_factor)60: 0;6162so->pa_cl_clip_cntl = 0; // TODO6364so->pa_su_vtx_cntl =65A2XX_PA_SU_VTX_CNTL_PIX_CENTER(cso->half_pixel_center ? PIXCENTER_OGL66: PIXCENTER_D3D) |67A2XX_PA_SU_VTX_CNTL_QUANT_MODE(ONE_SIXTEENTH);6869so->pa_su_point_size = A2XX_PA_SU_POINT_SIZE_HEIGHT(cso->point_size / 2) |70A2XX_PA_SU_POINT_SIZE_WIDTH(cso->point_size / 2);7172so->pa_su_point_minmax = A2XX_PA_SU_POINT_MINMAX_MIN(psize_min / 2) |73A2XX_PA_SU_POINT_MINMAX_MAX(psize_max / 2);7475so->pa_su_line_cntl = A2XX_PA_SU_LINE_CNTL_WIDTH(cso->line_width / 2);7677so->pa_su_sc_mode_cntl =78A2XX_PA_SU_SC_MODE_CNTL_VTX_WINDOW_OFFSET_ENABLE |79A2XX_PA_SU_SC_MODE_CNTL_FRONT_PTYPE(fd_polygon_mode(cso->fill_front)) |80A2XX_PA_SU_SC_MODE_CNTL_BACK_PTYPE(fd_polygon_mode(cso->fill_back));8182if (cso->cull_face & PIPE_FACE_FRONT)83so->pa_su_sc_mode_cntl |= A2XX_PA_SU_SC_MODE_CNTL_CULL_FRONT;84if (cso->cull_face & PIPE_FACE_BACK)85so->pa_su_sc_mode_cntl |= A2XX_PA_SU_SC_MODE_CNTL_CULL_BACK;86if (!cso->flatshade_first)87so->pa_su_sc_mode_cntl |= A2XX_PA_SU_SC_MODE_CNTL_PROVOKING_VTX_LAST;88if (!cso->front_ccw)89so->pa_su_sc_mode_cntl |= A2XX_PA_SU_SC_MODE_CNTL_FACE;90if (cso->line_stipple_enable)91so->pa_su_sc_mode_cntl |= A2XX_PA_SU_SC_MODE_CNTL_LINE_STIPPLE_ENABLE;92if (cso->multisample)93so->pa_su_sc_mode_cntl |= A2XX_PA_SU_SC_MODE_CNTL_MSAA_ENABLE;9495if (cso->fill_front != PIPE_POLYGON_MODE_FILL ||96cso->fill_back != PIPE_POLYGON_MODE_FILL)97so->pa_su_sc_mode_cntl |= A2XX_PA_SU_SC_MODE_CNTL_POLYMODE(POLY_DUALMODE);98else99so->pa_su_sc_mode_cntl |= A2XX_PA_SU_SC_MODE_CNTL_POLYMODE(POLY_DISABLED);100101if (cso->offset_tri)102so->pa_su_sc_mode_cntl |=103A2XX_PA_SU_SC_MODE_CNTL_POLY_OFFSET_FRONT_ENABLE |104A2XX_PA_SU_SC_MODE_CNTL_POLY_OFFSET_BACK_ENABLE |105A2XX_PA_SU_SC_MODE_CNTL_POLY_OFFSET_PARA_ENABLE;106107return so;108}109110111