Home | History | Annotate | Line # | Download | only in src
      1 /*
      2  * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario,
      3  *                      Precision Insight, Inc., Cedar Park, Texas, and
      4  *                      VA Linux Systems Inc., Fremont, California.
      5  *
      6  * All Rights Reserved.
      7  *
      8  * Permission is hereby granted, free of charge, to any person obtaining
      9  * a copy of this software and associated documentation files (the
     10  * "Software"), to deal in the Software without restriction, including
     11  * without limitation on the rights to use, copy, modify, merge,
     12  * publish, distribute, sublicense, and/or sell copies of the Software,
     13  * and to permit persons to whom the Software is furnished to do so,
     14  * subject to the following conditions:
     15  *
     16  * The above copyright notice and this permission notice (including the
     17  * next paragraph) shall be included in all copies or substantial
     18  * portions of the Software.
     19  *
     20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
     21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
     23  * NON-INFRINGEMENT.  IN NO EVENT SHALL ATI, PRECISION INSIGHT, VA LINUX
     24  * SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
     25  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     27  * OTHER DEALINGS IN THE SOFTWARE.
     28  */
     29 
     30 /*
     31  * Authors:
     32  *   Kevin E. Martin <martin (at) valinux.com>
     33  *   Gareth Hughes <gareth (at) valinux.com>
     34  *
     35  */
     36 
     37 #ifndef _R128_SAREA_H_
     38 #define _R128_SAREA_H_
     39 
     40 #include <X11/Xmd.h>
     41 
     42 /* WARNING: If you change any of these defines, make sure to change the
     43  * defines in the kernel file (r128_drm.h)
     44  */
     45 #ifndef __R128_SAREA_DEFINES__
     46 #define __R128_SAREA_DEFINES__
     47 
     48 /* What needs to be changed for the current vertex buffer?
     49  */
     50 #define R128_UPLOAD_CONTEXT		0x001
     51 #define R128_UPLOAD_SETUP		0x002
     52 #define R128_UPLOAD_TEX0		0x004
     53 #define R128_UPLOAD_TEX1		0x008
     54 #define R128_UPLOAD_TEX0IMAGES		0x010
     55 #define R128_UPLOAD_TEX1IMAGES		0x020
     56 #define R128_UPLOAD_CORE		0x040
     57 #define R128_UPLOAD_MASKS		0x080
     58 #define R128_UPLOAD_WINDOW		0x100
     59 #define R128_UPLOAD_CLIPRECTS		0x200	/* handled client-side */
     60 #define R128_REQUIRE_QUIESCENCE		0x400
     61 #define R128_UPLOAD_ALL			0x7ff
     62 
     63 #define R128_FRONT			0x1
     64 #define R128_BACK			0x2
     65 #define R128_DEPTH			0x4
     66 
     67 /* Primitive types
     68  */
     69 #define R128_POINTS			0x1
     70 #define R128_LINES			0x2
     71 #define R128_LINE_STRIP			0x3
     72 #define R128_TRIANGLES			0x4
     73 #define R128_TRIANGLE_FAN		0x5
     74 #define R128_TRIANGLE_STRIP		0x6
     75 
     76 /* Vertex/indirect buffer size
     77  */
     78 #define R128_BUFFER_SIZE		16384
     79 
     80 /* Byte offsets for indirect buffer data
     81  */
     82 #define R128_INDEX_PRIM_OFFSET		20
     83 #define R128_HOSTDATA_BLIT_OFFSET	32
     84 
     85 /* Keep these small for testing
     86  */
     87 #define R128_NR_SAREA_CLIPRECTS		12
     88 
     89 /* There are 2 heaps (local/AGP).  Each region within a heap is a
     90  * minimum of 64k, and there are at most 64 of them per heap.
     91  */
     92 #define R128_CARD_HEAP			0
     93 #define R128_AGP_HEAP			1
     94 #define R128_NR_TEX_HEAPS		2
     95 #define R128_NR_TEX_REGIONS		64
     96 #define R128_LOG_TEX_GRANULARITY	16
     97 
     98 #define R128_NR_CONTEXT_REGS		12
     99 
    100 #define R128_MAX_TEXTURE_LEVELS		11
    101 #define R128_MAX_TEXTURE_UNITS		2
    102 
    103 #endif /* __R128_SAREA_DEFINES__ */
    104 
    105 typedef struct {
    106     /* Context state - can be written in one large chunk */
    107     unsigned int dst_pitch_offset_c;
    108     unsigned int dp_gui_master_cntl_c;
    109     unsigned int sc_top_left_c;
    110     unsigned int sc_bottom_right_c;
    111     unsigned int z_offset_c;
    112     unsigned int z_pitch_c;
    113     unsigned int z_sten_cntl_c;
    114     unsigned int tex_cntl_c;
    115     unsigned int misc_3d_state_cntl_reg;
    116     unsigned int texture_clr_cmp_clr_c;
    117     unsigned int texture_clr_cmp_msk_c;
    118     unsigned int fog_color_c;
    119 
    120     /* Texture state */
    121     unsigned int tex_size_pitch_c;
    122     unsigned int constant_color_c;
    123 
    124     /* Setup state */
    125     unsigned int pm4_vc_fpu_setup;
    126     unsigned int setup_cntl;
    127 
    128     /* Mask state */
    129     unsigned int dp_write_mask;
    130     unsigned int sten_ref_mask_c;
    131     unsigned int plane_3d_mask_c;
    132 
    133     /* Window state */
    134     unsigned int window_xy_offset;
    135 
    136     /* Core state */
    137     unsigned int scale_3d_cntl;
    138 } r128_context_regs_t;
    139 
    140 /* Setup registers for each texture unit
    141  */
    142 typedef struct {
    143     unsigned int tex_cntl;
    144     unsigned int tex_combine_cntl;
    145     unsigned int tex_size_pitch;
    146     unsigned int tex_offset[R128_MAX_TEXTURE_LEVELS];
    147     unsigned int tex_border_color;
    148 } r128_texture_regs_t;
    149 
    150 typedef struct {
    151     /* The channel for communication of state information to the kernel
    152      * on firing a vertex buffer.
    153      */
    154     r128_context_regs_t	ContextState;
    155     r128_texture_regs_t	TexState[R128_MAX_TEXTURE_UNITS];
    156     unsigned int dirty;
    157     unsigned int vertsize;
    158     unsigned int vc_format;
    159 
    160     /* The current cliprects, or a subset thereof.
    161      */
    162     drm_clip_rect_t boxes[R128_NR_SAREA_CLIPRECTS];
    163     unsigned int nbox;
    164 
    165     /* Counters for throttling of rendering clients.
    166      */
    167     unsigned int last_frame;
    168     unsigned int last_dispatch;
    169 
    170     /* Maintain an LRU of contiguous regions of texture space.  If you
    171      * think you own a region of texture memory, and it has an age
    172      * different to the one you set, then you are mistaken and it has
    173      * been stolen by another client.  If global texAge hasn't changed,
    174      * there is no need to walk the list.
    175      *
    176      * These regions can be used as a proxy for the fine-grained texture
    177      * information of other clients - by maintaining them in the same
    178      * lru which is used to age their own textures, clients have an
    179      * approximate lru for the whole of global texture space, and can
    180      * make informed decisions as to which areas to kick out.  There is
    181      * no need to choose whether to kick out your own texture or someone
    182      * else's - simply eject them all in LRU order.
    183      */
    184 				/* Last elt is sentinel */
    185     drmTextureRegion texList[R128_NR_TEX_HEAPS][R128_NR_TEX_REGIONS+1];
    186 				/* last time texture was uploaded */
    187     unsigned int texAge[R128_NR_TEX_HEAPS];
    188 
    189     int ctxOwner;		/* last context to upload state */
    190     int pfAllowPageFlip;	/* set by the 2d driver, read by the client */
    191     int pfCurrentPage;		/* set by kernel, read by others */
    192 } R128SAREAPriv, *R128SAREAPrivPtr;
    193 
    194 #endif
    195