19f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt/*
29f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt Copyright (C) Intel Corp.  2006.  All Rights Reserved.
39f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
49f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt develop this 3D driver.
59f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
69f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt Permission is hereby granted, free of charge, to any person obtaining
79f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt a copy of this software and associated documentation files (the
89f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt "Software"), to deal in the Software without restriction, including
99f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt without limitation the rights to use, copy, modify, merge, publish,
109f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt distribute, sublicense, and/or sell copies of the Software, and to
119f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt permit persons to whom the Software is furnished to do so, subject to
129f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt the following conditions:
139f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
149f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt The above copyright notice and this permission notice (including the
159f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt next paragraph) shall be included in all copies or substantial
169f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt portions of the Software.
179f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
189f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
199f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
209f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
219f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
229f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
239f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
249f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
259f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
269f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt **********************************************************************/
279f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt /*
289f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt  * Authors:
299f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt  *   Keith Whitwell <keith@tungstengraphics.com>
309f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt  */
319f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
329f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
339f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#ifndef BRW_GS_H
349f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#define BRW_GS_H
359f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
369f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
379f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#include "brw_context.h"
389f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#include "brw_eu.h"
399f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
409f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#define MAX_GS_VERTS (4)
419f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
429f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtstruct brw_gs_prog_key {
435606dfb572bf4b89b4882265924705bacc8c182bIan Romanick   GLbitfield64 attrs;
44fcae281f067f933d95734a932e66d3111d9f2192Paul Berry
45fcae281f067f933d95734a932e66d3111d9f2192Paul Berry   /**
46fcae281f067f933d95734a932e66d3111d9f2192Paul Berry    * Hardware primitive type being drawn, e.g. _3DPRIM_TRILIST.
47fcae281f067f933d95734a932e66d3111d9f2192Paul Berry    */
48fcae281f067f933d95734a932e66d3111d9f2192Paul Berry   GLuint primitive:8;
49fcae281f067f933d95734a932e66d3111d9f2192Paul Berry
50ab12e764ba3f57ad9f0d7252262cfc6e07839928Roland Scheidegger   GLuint pv_first:1;
519f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   GLuint need_gs_prog:1;
5218e2e19b07b312c978dfbb6d336f69fa84b3ffe2Paul Berry   GLuint userclip_active:1;
537d2ff0bf0b7422c34676c2f47dbe754f57edb51ePaul Berry   GLuint rasterizer_discard:1;
549308f298300beaa757194a0db8ed50924754c011Paul Berry
559308f298300beaa757194a0db8ed50924754c011Paul Berry   /**
569308f298300beaa757194a0db8ed50924754c011Paul Berry    * Number of varyings that are output to transform feedback.
579308f298300beaa757194a0db8ed50924754c011Paul Berry    */
589308f298300beaa757194a0db8ed50924754c011Paul Berry   GLuint num_transform_feedback_bindings:7; /* 0-BRW_MAX_SOL_BINDINGS */
599308f298300beaa757194a0db8ed50924754c011Paul Berry
609308f298300beaa757194a0db8ed50924754c011Paul Berry   /**
619308f298300beaa757194a0db8ed50924754c011Paul Berry    * Map from the index of a transform feedback binding table entry to the
629308f298300beaa757194a0db8ed50924754c011Paul Berry    * gl_vert_result that should be streamed out through that binding table
639308f298300beaa757194a0db8ed50924754c011Paul Berry    * entry.
649308f298300beaa757194a0db8ed50924754c011Paul Berry    */
659308f298300beaa757194a0db8ed50924754c011Paul Berry   unsigned char transform_feedback_bindings[BRW_MAX_SOL_BINDINGS];
66e8357cb03d354756d238e99101998b028db63f0fPaul Berry
67e8357cb03d354756d238e99101998b028db63f0fPaul Berry   /**
68e8357cb03d354756d238e99101998b028db63f0fPaul Berry    * Map from the index of a transform feedback binding table entry to the
69e8357cb03d354756d238e99101998b028db63f0fPaul Berry    * swizzles that should be used when streaming out data through that
70e8357cb03d354756d238e99101998b028db63f0fPaul Berry    * binding table entry.
71e8357cb03d354756d238e99101998b028db63f0fPaul Berry    */
72e8357cb03d354756d238e99101998b028db63f0fPaul Berry   unsigned char transform_feedback_swizzles[BRW_MAX_SOL_BINDINGS];
739f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt};
749f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
759f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtstruct brw_gs_compile {
769f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   struct brw_compile func;
779f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   struct brw_gs_prog_key key;
789f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   struct brw_gs_prog_data prog_data;
799f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
809f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   struct {
819f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      struct brw_reg R0;
829308f298300beaa757194a0db8ed50924754c011Paul Berry
839308f298300beaa757194a0db8ed50924754c011Paul Berry      /**
849308f298300beaa757194a0db8ed50924754c011Paul Berry       * Register holding streamed vertex buffer pointers -- see the Sandy
859308f298300beaa757194a0db8ed50924754c011Paul Berry       * Bridge PRM, volume 2 part 1, section 4.4.2 (GS Thread Payload
869308f298300beaa757194a0db8ed50924754c011Paul Berry       * [DevSNB]).  These pointers are delivered in GRF 1.
879308f298300beaa757194a0db8ed50924754c011Paul Berry       */
889308f298300beaa757194a0db8ed50924754c011Paul Berry      struct brw_reg SVBI;
899308f298300beaa757194a0db8ed50924754c011Paul Berry
909f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      struct brw_reg vertex[MAX_GS_VERTS];
913f2283172bcaf3db00a99baad0319bc7e0be5fc2Paul Berry      struct brw_reg header;
92e8e79c1d7eed0f5ae8820611cb86bdbd6ce595e6Zhenyu Wang      struct brw_reg temp;
93b31f62c9074cb88fbb2e0b327e053778dea5b83fPaul Berry
94b31f62c9074cb88fbb2e0b327e053778dea5b83fPaul Berry      /**
95b31f62c9074cb88fbb2e0b327e053778dea5b83fPaul Berry       * Register holding destination indices for streamed buffer writes.
96b31f62c9074cb88fbb2e0b327e053778dea5b83fPaul Berry       * Only used for SOL programs.
97b31f62c9074cb88fbb2e0b327e053778dea5b83fPaul Berry       */
98b31f62c9074cb88fbb2e0b327e053778dea5b83fPaul Berry      struct brw_reg destination_indices;
999f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   } reg;
1009f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
10118dcda2dcff0ba49cf35656bb8936e3edd61c90dPaul Berry   /* Number of registers used to store vertex data */
1029f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   GLuint nr_regs;
1031413f955ebe213037a9d893e0b7391cac4ba3a57Paul Berry
1041413f955ebe213037a9d893e0b7391cac4ba3a57Paul Berry   struct brw_vue_map vue_map;
1059f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt};
1069f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
1079f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#define ATTR_SIZE  (4*4)
1089f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
109ab12e764ba3f57ad9f0d7252262cfc6e07839928Roland Scheideggervoid brw_gs_quads( struct brw_gs_compile *c, struct brw_gs_prog_key *key );
110ab12e764ba3f57ad9f0d7252262cfc6e07839928Roland Scheideggervoid brw_gs_quad_strip( struct brw_gs_compile *c, struct brw_gs_prog_key *key );
1119f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtvoid brw_gs_lines( struct brw_gs_compile *c );
112d4976158c7f32705b48c773c3abd1b22bebe9c16Paul Berryvoid gen6_sol_program(struct brw_gs_compile *c, struct brw_gs_prog_key *key,
113d4976158c7f32705b48c773c3abd1b22bebe9c16Paul Berry                      unsigned num_verts, bool check_edge_flag);
1149f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
1159f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#endif
116