brw_winsys.h

Go to the documentation of this file.
00001 /**************************************************************************
00002  *
00003  * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
00004  * All Rights Reserved.
00005  *
00006  * Permission is hereby granted, free of charge, to any person obtaining a
00007  * copy of this software and associated documentation files (the
00008  * "Software"), to deal in the Software without restriction, including
00009  * without limitation the rights to use, copy, modify, merge, publish,
00010  * distribute, sub license, and/or sell copies of the Software, and to
00011  * permit persons to whom the Software is furnished to do so, subject to
00012  * the following conditions:
00013  *
00014  * The above copyright notice and this permission notice (including the
00015  * next paragraph) shall be included in all copies or substantial portions
00016  * of the Software.
00017  *
00018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00019  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00020  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
00021  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
00022  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
00023  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
00024  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00025  *
00026  **************************************************************************/
00027 
00036 #ifndef BRW_WINSYS_H
00037 #define BRW_WINSYS_H
00038 
00039 
00040 #include "pipe/p_defines.h"
00041 
00042 
00043 /* Pipe drivers are (meant to be!) independent of both GL and the
00044  * window system.  The window system provides a buffer manager and a
00045  * set of additional hooks for things like command buffer submission,
00046  * etc.
00047  *
00048  * There clearly has to be some agreement between the window system
00049  * driver and the hardware driver about the format of command buffers,
00050  * etc.
00051  */
00052 
00053 struct pipe_buffer;
00054 struct pipe_fence_handle;
00055 struct pipe_winsys;
00056 struct pipe_screen;
00057 
00058 
00059 /* The pipe driver currently understands the following chipsets:
00060  */
00061 #define PCI_CHIP_I965_G                 0x29A2
00062 #define PCI_CHIP_I965_Q                 0x2992
00063 #define PCI_CHIP_I965_G_1               0x2982
00064 #define PCI_CHIP_I965_GM                0x2A02
00065 #define PCI_CHIP_I965_GME               0x2A12
00066 
00067 
00068 /* These are the names of all the state caches managed by the driver.
00069  * 
00070  * When data is uploaded to a buffer with buffer_subdata, we use the
00071  * special version of that function below so that information about
00072  * what type of data this is can be passed to the winsys backend.
00073  * That in turn allows the correct flags to be set in the aub file
00074  * dump to allow human-readable file dumps later on.
00075  */
00076 
00077 enum brw_cache_id {
00078    BRW_CC_VP,
00079    BRW_CC_UNIT,
00080    BRW_WM_PROG,
00081    BRW_SAMPLER_DEFAULT_COLOR,
00082    BRW_SAMPLER,
00083    BRW_WM_UNIT,
00084    BRW_SF_PROG,
00085    BRW_SF_VP,
00086    BRW_SF_UNIT,
00087    BRW_VS_UNIT,
00088    BRW_VS_PROG,
00089    BRW_GS_UNIT,
00090    BRW_GS_PROG,
00091    BRW_CLIP_VP,
00092    BRW_CLIP_UNIT,
00093    BRW_CLIP_PROG,
00094    BRW_SS_SURFACE,
00095    BRW_SS_SURF_BIND,
00096 
00097    BRW_MAX_CACHE
00098 };
00099 
00100 #define BRW_CONSTANT_BUFFER BRW_MAX_CACHE
00101 
00113 struct brw_winsys {
00114 
00115    void (*destroy)(struct brw_winsys *);
00116    
00125    unsigned *(*batch_start)(struct brw_winsys *sws,
00126                             unsigned dwords,
00127                             unsigned relocs);
00128 
00129    void (*batch_dword)(struct brw_winsys *sws,
00130                        unsigned dword);
00131 
00142    void (*batch_reloc)(struct brw_winsys *sws,
00143                        struct pipe_buffer *buf,
00144                        unsigned access_flags,
00145                        unsigned delta);
00146 
00147 
00148    /* Not used yet, but really want this:
00149     */
00150    void (*batch_end)( struct brw_winsys *sws );
00151 
00158    void (*batch_flush)(struct brw_winsys *sws,
00159                        struct pipe_fence_handle **fence);
00160 
00161 
00162    /* A version of buffer_subdata that includes information for the
00163     * simulator:
00164     */
00165    void (*buffer_subdata_typed)(struct brw_winsys *sws, 
00166                                 struct pipe_buffer *buf,
00167                                 unsigned long offset, 
00168                                 unsigned long size, 
00169                                 const void *data,
00170                                 unsigned data_type);
00171    
00172 
00173    /* A cheat so we don't have to think about relocations in a couple
00174     * of places yet:
00175     */
00176    unsigned (*get_buffer_offset)( struct brw_winsys *sws,
00177                                   struct pipe_buffer *buf,
00178                                   unsigned flags );
00179 
00180 };
00181 
00182 #define BRW_BUFFER_ACCESS_WRITE   0x1
00183 #define BRW_BUFFER_ACCESS_READ    0x2
00184 
00185 #define BRW_BUFFER_USAGE_LIT_VERTEX  (PIPE_BUFFER_USAGE_CUSTOM << 0)
00186 
00187 
00188 struct pipe_context *brw_create(struct pipe_screen *,
00189                                 struct brw_winsys *,
00190                                 unsigned pci_id);
00191 
00192 static inline boolean brw_batchbuffer_data(struct brw_winsys *winsys,
00193                                            const void *data,
00194                                            unsigned bytes)
00195 {
00196    static const unsigned incr = sizeof(unsigned);
00197    uint i;
00198    const unsigned *udata = (const unsigned*)(data);
00199    unsigned size = bytes/incr;
00200 
00201    winsys->batch_start(winsys, size, 0);
00202    for (i = 0; i < size; ++i) {
00203       winsys->batch_dword(winsys, udata[i]);
00204    }
00205    winsys->batch_end(winsys);
00206 
00207    return (i == size);
00208 }
00209 #endif

Generated on Tue Sep 29 06:25:17 2009 for Gallium3D by  doxygen 1.5.4