Path: blob/21.2-virgl/src/gallium/drivers/freedreno/a5xx/fd5_rasterizer.c
4574 views
/*1* Copyright (C) 2016 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 "fd5_context.h"31#include "fd5_format.h"32#include "fd5_rasterizer.h"3334void *35fd5_rasterizer_state_create(struct pipe_context *pctx,36const struct pipe_rasterizer_state *cso)37{38struct fd5_rasterizer_stateobj *so;39float psize_min, psize_max;4041so = CALLOC_STRUCT(fd5_rasterizer_stateobj);42if (!so)43return NULL;4445so->base = *cso;4647if (cso->point_size_per_vertex) {48psize_min = util_get_min_point_size(cso);49psize_max = 4092;50} else {51/* Force the point size to be as if the vertex output was disabled. */52psize_min = cso->point_size;53psize_max = cso->point_size;54}5556so->gras_su_point_minmax = A5XX_GRAS_SU_POINT_MINMAX_MIN(psize_min) |57A5XX_GRAS_SU_POINT_MINMAX_MAX(psize_max);58so->gras_su_point_size = A5XX_GRAS_SU_POINT_SIZE(cso->point_size);59so->gras_su_poly_offset_scale =60A5XX_GRAS_SU_POLY_OFFSET_SCALE(cso->offset_scale);61so->gras_su_poly_offset_offset =62A5XX_GRAS_SU_POLY_OFFSET_OFFSET(cso->offset_units);63so->gras_su_poly_offset_clamp =64A5XX_GRAS_SU_POLY_OFFSET_OFFSET_CLAMP(cso->offset_clamp);6566so->gras_su_cntl = A5XX_GRAS_SU_CNTL_LINEHALFWIDTH(cso->line_width / 2.0);67so->pc_raster_cntl =68A5XX_PC_RASTER_CNTL_POLYMODE_FRONT_PTYPE(69fd_polygon_mode(cso->fill_front)) |70A5XX_PC_RASTER_CNTL_POLYMODE_BACK_PTYPE(fd_polygon_mode(cso->fill_back));7172if (cso->fill_front != PIPE_POLYGON_MODE_FILL ||73cso->fill_back != PIPE_POLYGON_MODE_FILL)74so->pc_raster_cntl |= A5XX_PC_RASTER_CNTL_POLYMODE_ENABLE;7576if (cso->cull_face & PIPE_FACE_FRONT)77so->gras_su_cntl |= A5XX_GRAS_SU_CNTL_CULL_FRONT;78if (cso->cull_face & PIPE_FACE_BACK)79so->gras_su_cntl |= A5XX_GRAS_SU_CNTL_CULL_BACK;80if (!cso->front_ccw)81so->gras_su_cntl |= A5XX_GRAS_SU_CNTL_FRONT_CW;82if (cso->offset_tri)83so->gras_su_cntl |= A5XX_GRAS_SU_CNTL_POLY_OFFSET;8485if (!cso->flatshade_first)86so->pc_primitive_cntl |= A5XX_PC_PRIMITIVE_CNTL_PROVOKING_VTX_LAST;8788// if (!cso->depth_clip)89// so->gras_cl_clip_cntl |=90// A5XX_GRAS_CL_CLIP_CNTL_ZNEAR_CLIP_DISABLE |91// A5XX_GRAS_CL_CLIP_CNTL_ZFAR_CLIP_DISABLE;92if (cso->clip_halfz)93so->gras_cl_clip_cntl |= A5XX_GRAS_CL_CNTL_ZERO_GB_SCALE_Z;9495return so;96}979899