diff options
author | Rob Clark <[email protected]> | 2013-05-26 17:13:44 -0400 |
---|---|---|
committer | Rob Clark <[email protected]> | 2013-06-08 13:15:51 -0400 |
commit | 2855f3f7bcd9b36a275e942c9c7d0eb8e485c16f (patch) | |
tree | 436514501ba4d2ceb907d5eb940181b0ed3704e6 /src/gallium/drivers/freedreno/a3xx/fd3_rasterizer.c | |
parent | 18c317b21ddc2ec4538544f9dd69dc568dcf821f (diff) |
freedreno: add a3xx support
The adreno a3xx GPU is found in newer snapdragon devices, such as the
nexus4. The a3xx is GLESv3 and OpenCL capable, although that is not
enabled yet in gallium.
Compared to a2xx, it introduces an entirely new unified shader ISA, and
re-shuffles all or nearly all of the registers. The good news is that
(for the most part) the registers are more orthogonal, not combining
unrelated state in a single register. And that there is a lot more
flexibility, so we don't need to patch and re-emit the shader like we
did on a2xx.
The shader compiler is currently quite dumb, there would be a lot of
room for improvement with an optimizing pass. Despite that, with the
a320 in my nexus4 it seems to be ~2-3x faster compared to the a220 in my
HP touchpad.
Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium/drivers/freedreno/a3xx/fd3_rasterizer.c')
-rw-r--r-- | src/gallium/drivers/freedreno/a3xx/fd3_rasterizer.c | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_rasterizer.c b/src/gallium/drivers/freedreno/a3xx/fd3_rasterizer.c new file mode 100644 index 00000000000..8f6c0fe95cf --- /dev/null +++ b/src/gallium/drivers/freedreno/a3xx/fd3_rasterizer.c @@ -0,0 +1,92 @@ +/* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */ + +/* + * Copyright (C) 2013 Rob Clark <[email protected]> + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Authors: + * Rob Clark <[email protected]> + */ + + +#include "pipe/p_state.h" +#include "util/u_string.h" +#include "util/u_memory.h" + +#include "fd3_rasterizer.h" +#include "fd3_context.h" +#include "fd3_util.h" + +void * +fd3_rasterizer_state_create(struct pipe_context *pctx, + const struct pipe_rasterizer_state *cso) +{ + struct fd3_rasterizer_stateobj *so; + + so = CALLOC_STRUCT(fd3_rasterizer_stateobj); + if (!so) + return NULL; + + so->base = *cso; + +/* + if (cso->line_stipple_enable) { + ??? TODO line stipple + } + TODO cso->half_pixel_center + TODO cso->point_size + TODO psize_min/psize_max +*/ + so->gras_cl_clip_cntl = A3XX_GRAS_CL_CLIP_CNTL_IJ_PERSP_CENTER; /* ??? */ + so->gras_su_point_minmax = 0xffc00010; /* ??? */ + so->gras_su_point_size = 0x00000008; /* ??? */ + so->gras_su_poly_offset_scale = + A3XX_GRAS_SU_POLY_OFFSET_SCALE_VAL(cso->offset_scale); + so->gras_su_poly_offset_offset = + A3XX_GRAS_SU_POLY_OFFSET_OFFSET(cso->offset_units); + + so->gras_su_mode_control = + A3XX_GRAS_SU_MODE_CONTROL_LINEHALFWIDTH(cso->line_width/2); + + so->pc_prim_vtx_cntl = + A3XX_PC_PRIM_VTX_CNTL_POLYMODE_FRONT_PTYPE(fd_polygon_mode(cso->fill_front)) | + A3XX_PC_PRIM_VTX_CNTL_POLYMODE_BACK_PTYPE(fd_polygon_mode(cso->fill_back)); + + if (cso->cull_face & PIPE_FACE_FRONT) + so->gras_su_mode_control |= A3XX_GRAS_SU_MODE_CONTROL_CULL_FRONT; + if (cso->cull_face & PIPE_FACE_BACK) + so->gras_su_mode_control |= A3XX_GRAS_SU_MODE_CONTROL_CULL_BACK; + if (!cso->flatshade_first) + so->pc_prim_vtx_cntl |= A3XX_PC_PRIM_VTX_CNTL_PROVOKING_VTX_LAST; +/* + if (!cso->front_ccw) + TODO + if (cso->line_stipple_enable) + TODO + if (cso->multisample) + TODO +*/ + + if (cso->offset_tri) + so->gras_su_mode_control |= A3XX_GRAS_SU_MODE_CONTROL_POLY_OFFSET; + + return so; +} |