16b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/************************************************************************** 26b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * 36b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. 46b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * All Rights Reserved. 56b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * 66b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * Permission is hereby granted, free of charge, to any person obtaining a 76b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * copy of this software and associated documentation files (the 86b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * "Software"), to deal in the Software without restriction, including 96b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * without limitation the rights to use, copy, modify, merge, publish, 106b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * distribute, sub license, and/or sell copies of the Software, and to 116b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * permit persons to whom the Software is furnished to do so, subject to 126b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * the following conditions: 136b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * 146b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * The above copyright notice and this permission notice (including the 156b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * next paragraph) shall be included in all copies or substantial portions 166b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * of the Software. 176b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * 186b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 196b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 206b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 216b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR 226b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 236b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 246b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 256b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * 266b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell **************************************************************************/ 276b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 286b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/* 296b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * Render unclipped vertex buffers by emitting vertices directly to 306b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * dma buffers. Use strip/fan hardware acceleration where possible. 316b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * 326b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */ 33ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/glheader.h" 34ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/context.h" 35ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/macros.h" 36ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/imports.h" 37ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/mtypes.h" 38ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/enums.h" 396b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 40facf368df29b6889e9566aaa642aa1937e6dfc56Vinson Lee#include "math/m_xform.h" 41facf368df29b6889e9566aaa642aa1937e6dfc56Vinson Lee 426b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#include "tnl/t_context.h" 436b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#include "tnl/t_vertex.h" 44dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg#include "tnl/t_pipeline.h" 456b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 466b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#include "intel_screen.h" 476b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#include "intel_context.h" 486b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#include "intel_tris.h" 496b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#include "intel_batchbuffer.h" 506b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#include "intel_reg.h" 516b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 526b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/* 536b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * Render unclipped vertex buffers by emitting vertices directly to 546b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * dma buffers. Use strip/fan hardware primitives where possible. 556b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * Try to simulate missing primitives with indexed vertices. 566b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */ 576b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define HAVE_POINTS 0 /* Has it, but can't use because subpixel has to 586b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * be adjusted for points on the INTEL/I845G 596b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */ 606b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define HAVE_LINES 1 616b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define HAVE_LINE_STRIPS 1 626b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define HAVE_TRIANGLES 1 636b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define HAVE_TRI_STRIPS 1 646b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define HAVE_TRI_STRIP_1 0 /* has it, template can't use it yet */ 656b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define HAVE_TRI_FANS 1 666b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define HAVE_POLYGONS 1 676b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define HAVE_QUADS 0 686b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define HAVE_QUAD_STRIPS 0 696b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 706b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define HAVE_ELTS 0 716b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 72f75843a517bd188639e6866db2a7b04de3524e16Dave Airliestatic uint32_t hw_prim[GL_POLYGON + 1] = { 736b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 0, 746b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell PRIM3D_LINELIST, 756b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell PRIM3D_LINESTRIP, 766b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell PRIM3D_LINESTRIP, 776b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell PRIM3D_TRILIST, 786b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell PRIM3D_TRISTRIP, 796b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell PRIM3D_TRIFAN, 806b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 0, 816b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 0, 826b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell PRIM3D_POLY 836b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}; 846b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 856b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic const GLenum reduced_prim[GL_POLYGON + 1] = { 866b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GL_POINTS, 876b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GL_LINES, 886b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GL_LINES, 896b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GL_LINES, 906b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GL_TRIANGLES, 916b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GL_TRIANGLES, 926b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GL_TRIANGLES, 936b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GL_TRIANGLES, 946b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GL_TRIANGLES, 956b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GL_TRIANGLES 966b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}; 976b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 986b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic const int scale_prim[GL_POLYGON + 1] = { 996b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 0, /* fallback case */ 1006b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1, 1016b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2, 1026b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2, 1036b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1, 1046b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 3, 1056b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 3, 1066b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 0, /* fallback case */ 1076b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 0, /* fallback case */ 1086b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 3 1096b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}; 1106b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1116b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1126b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void 1136b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith WhitwellintelDmaPrimitive(struct intel_context *intel, GLenum prim) 1146b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{ 1156b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (0) 1166b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell fprintf(stderr, "%s %s\n", __FUNCTION__, _mesa_lookup_enum_by_nr(prim)); 1176b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell INTEL_FIREVERTICES(intel); 1186b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell intel->vtbl.reduced_primitive_state(intel, reduced_prim[prim]); 119f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie intel_set_prim(intel, hw_prim[prim]); 1206b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell} 1216b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 12233b07893e92dcee495908c549be872887096c894Chris Wilson#define INTEL_NO_VBO_STATE_RESERVED 1500 12333b07893e92dcee495908c549be872887096c894Chris Wilson 124c67bb15d4e3da430d511444bd7d159ccb0c84b73Vinson Leestatic INLINE GLuint intel_get_vb_max(struct intel_context *intel) 125cd031749a75883a6fbf8fb7bf989b77a7c705819Dave Airlie{ 126cd031749a75883a6fbf8fb7bf989b77a7c705819Dave Airlie GLuint ret; 127cd031749a75883a6fbf8fb7bf989b77a7c705819Dave Airlie 128024ece7523f1735d2fca0067c0a3bdcf53fde8f9Kurt Roeckx if (intel->intelScreen->no_vbo) { 129024ece7523f1735d2fca0067c0a3bdcf53fde8f9Kurt Roeckx ret = intel->batch.bo->size - INTEL_NO_VBO_STATE_RESERVED; 130024ece7523f1735d2fca0067c0a3bdcf53fde8f9Kurt Roeckx } else 131cd031749a75883a6fbf8fb7bf989b77a7c705819Dave Airlie ret = INTEL_VB_SIZE; 132cd031749a75883a6fbf8fb7bf989b77a7c705819Dave Airlie ret /= (intel->vertex_size * 4); 133cd031749a75883a6fbf8fb7bf989b77a7c705819Dave Airlie return ret; 134cd031749a75883a6fbf8fb7bf989b77a7c705819Dave Airlie} 135cd031749a75883a6fbf8fb7bf989b77a7c705819Dave Airlie 136c67bb15d4e3da430d511444bd7d159ccb0c84b73Vinson Leestatic INLINE GLuint intel_get_current_max(struct intel_context *intel) 137cd031749a75883a6fbf8fb7bf989b77a7c705819Dave Airlie{ 13833b07893e92dcee495908c549be872887096c894Chris Wilson GLuint ret; 139cd031749a75883a6fbf8fb7bf989b77a7c705819Dave Airlie 14033b07893e92dcee495908c549be872887096c894Chris Wilson if (intel->intelScreen->no_vbo) { 14133b07893e92dcee495908c549be872887096c894Chris Wilson ret = intel_batchbuffer_space(intel); 14233b07893e92dcee495908c549be872887096c894Chris Wilson ret = ret <= INTEL_NO_VBO_STATE_RESERVED ? 0 : ret - INTEL_NO_VBO_STATE_RESERVED; 14333b07893e92dcee495908c549be872887096c894Chris Wilson } else 14433b07893e92dcee495908c549be872887096c894Chris Wilson ret = (INTEL_VB_SIZE - intel->prim.current_offset); 14533b07893e92dcee495908c549be872887096c894Chris Wilson 14633b07893e92dcee495908c549be872887096c894Chris Wilson return ret / (intel->vertex_size * 4); 147cd031749a75883a6fbf8fb7bf989b77a7c705819Dave Airlie} 1486b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1496b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define LOCAL_VARS struct intel_context *intel = intel_context(ctx) 1506b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define INIT( prim ) \ 1516b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwelldo { \ 1526b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell intelDmaPrimitive( intel, prim ); \ 1536b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell} while (0) 1546b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1556b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define FLUSH() INTEL_FIREVERTICES(intel) 1566b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 157cd031749a75883a6fbf8fb7bf989b77a7c705819Dave Airlie#define GET_SUBSEQUENT_VB_MAX_VERTS() intel_get_vb_max(intel) 158cd031749a75883a6fbf8fb7bf989b77a7c705819Dave Airlie#define GET_CURRENT_VB_MAX_VERTS() intel_get_current_max(intel) 1596b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 160f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie#define ALLOC_VERTS(nr) intel_get_prim_space(intel, nr) 1616b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1626b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define EMIT_VERTS( ctx, j, nr, buf ) \ 1636b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell _tnl_emit_vertices_to_buffer(ctx, j, (j)+(nr), buf ) 1646b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1656b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define TAG(x) intel_##x 1666b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#include "tnl_dd/t_dd_dmatmp.h" 1676b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1686b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1696b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/**********************************************************************/ 1706b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/* Render pipeline stage */ 1716b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/**********************************************************************/ 1726b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1736b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/* Heuristic to choose between the two render paths: 1746b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */ 1752e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunkestatic bool 1766b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellchoose_render(struct intel_context *intel, struct vertex_buffer *VB) 1776b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{ 1786b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell int vertsz = intel->vertex_size; 1796b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell int cost_render = 0; 1806b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell int cost_fallback = 0; 1816b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell int nr_prims = 0; 1826b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell int nr_rprims = 0; 1836b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell int nr_rverts = 0; 1846b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell int rprim = intel->reduced_primitive; 1856b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell int i = 0; 1866b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1876b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell for (i = 0; i < VB->PrimitiveCount; i++) { 1886b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GLuint prim = VB->Primitive[i].mode; 1896b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GLuint length = VB->Primitive[i].count; 1906b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1916b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (!length) 1926b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell continue; 1936b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1946b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell nr_prims++; 1956b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell nr_rverts += length * scale_prim[prim & PRIM_MODE_MASK]; 1966b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1976b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (reduced_prim[prim & PRIM_MODE_MASK] != rprim) { 1986b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell nr_rprims++; 1996b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell rprim = reduced_prim[prim & PRIM_MODE_MASK]; 2006b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell } 2016b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell } 2026b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2036b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell /* One point for each generated primitive: 2046b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */ 2056b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell cost_render = nr_prims; 2066b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell cost_fallback = nr_rprims; 2076b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2086b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell /* One point for every 1024 dwords (4k) of dma: 2096b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */ 2106b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell cost_render += (vertsz * i) / 1024; 2116b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell cost_fallback += (vertsz * nr_rverts) / 1024; 2126b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2136b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (0) 2146b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell fprintf(stderr, "cost render: %d fallback: %d\n", 2156b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell cost_render, cost_fallback); 2166b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2176b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (cost_render > cost_fallback) 2182e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke return false; 2196b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2202e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke return true; 2216b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell} 2226b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2236b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2246b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic GLboolean 225f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergintel_run_render(struct gl_context * ctx, struct tnl_pipeline_stage *stage) 2266b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{ 2276b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell struct intel_context *intel = intel_context(ctx); 2286b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell TNLcontext *tnl = TNL_CONTEXT(ctx); 2296b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell struct vertex_buffer *VB = &tnl->vb; 2306b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GLuint i; 2316b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 232a188ba4bf9364df24842d8727f4c7ddb2f894a2cRoland Scheidegger intel->vtbl.render_prevalidate( intel ); 233a188ba4bf9364df24842d8727f4c7ddb2f894a2cRoland Scheidegger 2346b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell /* Don't handle clipping or indexed vertices. 2356b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */ 2366b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (intel->RenderIndex != 0 || 2376b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell !intel_validate_render(ctx, VB) || !choose_render(intel, VB)) { 2382e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke return true; 2396b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell } 2406b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2416b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell tnl->clipspace.new_inputs |= VERT_BIT_POS; 2426b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2436b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell tnl->Driver.Render.Start(ctx); 2446b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2456b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell for (i = 0; i < VB->PrimitiveCount; i++) { 24626473140b9c5e6aa962961c836f79fd5aa6cd246Roland Scheidegger GLuint prim = _tnl_translate_prim(&VB->Primitive[i]); 2476b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GLuint start = VB->Primitive[i].start; 2486b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GLuint length = VB->Primitive[i].count; 2496b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2506b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (!length) 2516b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell continue; 2526b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2536b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell intel_render_tab_verts[prim & PRIM_MODE_MASK] (ctx, start, 2546b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell start + length, prim); 2556b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell } 2566b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2576b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell tnl->Driver.Render.Finish(ctx); 2586b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2596b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell INTEL_FIREVERTICES(intel); 2606b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2612e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke return false; /* finished the pipe */ 2626b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell} 2636b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 264dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsbergstatic const struct tnl_pipeline_stage _intel_render_stage = { 2656b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell "intel render", 2666b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell NULL, 2676b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell NULL, 2686b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell NULL, 2696b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell NULL, 2706b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell intel_run_render /* run */ 2716b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}; 272dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg 273dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsbergconst struct tnl_pipeline_stage *intel_pipeline[] = { 274dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg &_tnl_vertex_transform_stage, 275dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg &_tnl_normal_transform_stage, 276dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg &_tnl_lighting_stage, 277dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg &_tnl_fog_coordinate_stage, 278dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg &_tnl_texgen_stage, 279dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg &_tnl_texture_transform_stage, 280dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg &_tnl_point_attenuation_stage, 281dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg &_tnl_vertex_program_stage, 282dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg#if 1 283dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg &_intel_render_stage, /* ADD: unclipped rastersetup-to-dma */ 284dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg#endif 285dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg &_tnl_render_stage, 286dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg 0, 287dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg}; 288