Path: blob/21.2-virgl/src/gallium/drivers/etnaviv/etnaviv_rasterizer.c
4570 views
/*1* Copyright (c) 2012-2015 Etnaviv Project2*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, sub license,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 the11* next paragraph) shall be included in all copies or substantial portions12* of the 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 NON-INFRINGEMENT. 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, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER20* DEALINGS IN THE SOFTWARE.21*/2223#include "etnaviv_rasterizer.h"24#include "etnaviv_context.h"25#include "etnaviv_screen.h"2627#include "hw/common.xml.h"2829#include "etnaviv_translate.h"30#include "util/u_math.h"31#include "util/u_memory.h"3233void *34etna_rasterizer_state_create(struct pipe_context *pctx,35const struct pipe_rasterizer_state *so)36{37struct etna_rasterizer_state *cs;38struct etna_context *ctx = etna_context(pctx);3940if (so->fill_front != so->fill_back)41DBG("Different front and back fill mode not supported");4243cs = CALLOC_STRUCT(etna_rasterizer_state);44if (!cs)45return NULL;4647cs->base = *so;4849cs->PA_CONFIG = (so->flatshade ? VIVS_PA_CONFIG_SHADE_MODEL_FLAT : VIVS_PA_CONFIG_SHADE_MODEL_SMOOTH) |50translate_cull_face(so->cull_face, so->front_ccw) |51translate_polygon_mode(so->fill_front) |52COND(so->point_quad_rasterization, VIVS_PA_CONFIG_POINT_SPRITE_ENABLE) |53COND(so->point_size_per_vertex, VIVS_PA_CONFIG_POINT_SIZE_ENABLE) |54COND(VIV_FEATURE(ctx->screen, chipMinorFeatures1, WIDE_LINE), VIVS_PA_CONFIG_WIDE_LINE);55cs->PA_LINE_WIDTH = fui(so->line_width / 2.0f);56cs->PA_POINT_SIZE = fui(so->point_size / 2.0f);57cs->SE_DEPTH_SCALE = fui(so->offset_scale);58cs->SE_DEPTH_BIAS = fui((so->offset_units / 65535.0f) * 2.0f);59cs->SE_CONFIG = COND(so->line_last_pixel, VIVS_SE_CONFIG_LAST_PIXEL_ENABLE);60/* XXX anything else? */61/* XXX bottom_edge_rule */62cs->PA_SYSTEM_MODE =63COND(!so->flatshade_first, VIVS_PA_SYSTEM_MODE_PROVOKING_VERTEX_LAST) |64COND(so->half_pixel_center, VIVS_PA_SYSTEM_MODE_HALF_PIXEL_CENTER);6566/* so->scissor overrides the scissor, defaulting to the whole framebuffer,67* with the scissor state */68cs->scissor = so->scissor;6970/* point size per vertex adds a vertex shader output */71cs->point_size_per_vertex = so->point_size_per_vertex;7273assert(!so->clip_halfz); /* could be supported with shader magic, actually74D3D z is default on older gc */7576return cs;77}787980