brw_screen.c

Go to the documentation of this file.
00001 /**************************************************************************
00002  * 
00003  * Copyright 2008 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 
00028 
00029 #include "util/u_memory.h"
00030 #include "pipe/p_winsys.h"
00031 #include "util/u_string.h"
00032 
00033 #include "brw_context.h"
00034 #include "brw_screen.h"
00035 #include "brw_tex_layout.h"
00036 
00037 
00038 static const char *
00039 brw_get_vendor( struct pipe_screen *screen )
00040 {
00041    return "Tungsten Graphics, Inc.";
00042 }
00043 
00044 
00045 static const char *
00046 brw_get_name( struct pipe_screen *screen )
00047 {
00048    static char buffer[128];
00049    const char *chipset;
00050 
00051    switch (brw_screen(screen)->pci_id) {
00052    case PCI_CHIP_I965_Q:
00053       chipset = "Intel(R) 965Q";
00054       break;
00055    case PCI_CHIP_I965_G:
00056    case PCI_CHIP_I965_G_1:
00057       chipset = "Intel(R) 965G";
00058       break;
00059    case PCI_CHIP_I965_GM:
00060       chipset = "Intel(R) 965GM";
00061       break;
00062    case PCI_CHIP_I965_GME:
00063       chipset = "Intel(R) 965GME/GLE";
00064       break;
00065    default:
00066       chipset = "unknown";
00067       break;
00068    }
00069 
00070    util_snprintf(buffer, sizeof(buffer), "i965 (chipset: %s)", chipset);
00071    return buffer;
00072 }
00073 
00074 
00075 static int
00076 brw_get_param(struct pipe_screen *screen, int param)
00077 {
00078    switch (param) {
00079    case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
00080       return 8;
00081    case PIPE_CAP_NPOT_TEXTURES:
00082       return 1;
00083    case PIPE_CAP_TWO_SIDED_STENCIL:
00084       return 1;
00085    case PIPE_CAP_GLSL:
00086       return 0;
00087    case PIPE_CAP_S3TC:
00088       return 0;
00089    case PIPE_CAP_ANISOTROPIC_FILTER:
00090       return 0;
00091    case PIPE_CAP_POINT_SPRITE:
00092       return 0;
00093    case PIPE_CAP_MAX_RENDER_TARGETS:
00094       return 1;
00095    case PIPE_CAP_OCCLUSION_QUERY:
00096       return 0;
00097    case PIPE_CAP_TEXTURE_SHADOW_MAP:
00098       return 1;
00099    case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
00100       return 11; /* max 1024x1024 */
00101    case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
00102       return 8;  /* max 128x128x128 */
00103    case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
00104       return 11; /* max 1024x1024 */
00105    default:
00106       return 0;
00107    }
00108 }
00109 
00110 
00111 static float
00112 brw_get_paramf(struct pipe_screen *screen, int param)
00113 {
00114    switch (param) {
00115    case PIPE_CAP_MAX_LINE_WIDTH:
00116       /* fall-through */
00117    case PIPE_CAP_MAX_LINE_WIDTH_AA:
00118       return 7.5;
00119 
00120    case PIPE_CAP_MAX_POINT_WIDTH:
00121       /* fall-through */
00122    case PIPE_CAP_MAX_POINT_WIDTH_AA:
00123       return 255.0;
00124 
00125    case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
00126       return 4.0;
00127 
00128    case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
00129       return 16.0;
00130 
00131    default:
00132       return 0;
00133    }
00134 }
00135 
00136 
00137 static boolean
00138 brw_is_format_supported( struct pipe_screen *screen,
00139                          enum pipe_format format, 
00140                          enum pipe_texture_target target,
00141                          unsigned tex_usage, 
00142                          unsigned geom_flags )
00143 {
00144 #if 0
00145    /* XXX: This is broken -- rewrite if still needed. */
00146    static const unsigned tex_supported[] = {
00147       PIPE_FORMAT_R8G8B8A8_UNORM,
00148       PIPE_FORMAT_A8R8G8B8_UNORM,
00149       PIPE_FORMAT_R5G6B5_UNORM,
00150       PIPE_FORMAT_L8_UNORM,
00151       PIPE_FORMAT_A8_UNORM,
00152       PIPE_FORMAT_I8_UNORM,
00153       PIPE_FORMAT_L8A8_UNORM,
00154       PIPE_FORMAT_YCBCR,
00155       PIPE_FORMAT_YCBCR_REV,
00156       PIPE_FORMAT_S8_Z24,
00157    };
00158 
00159 
00160    /* Actually a lot more than this - add later:
00161     */
00162    static const unsigned render_supported[] = {
00163       PIPE_FORMAT_A8R8G8B8_UNORM,
00164       PIPE_FORMAT_R5G6B5_UNORM,
00165    };
00166 
00167    /*
00168     */
00169    static const unsigned z_stencil_supported[] = {
00170       PIPE_FORMAT_Z16_UNORM,
00171       PIPE_FORMAT_Z32_UNORM,
00172       PIPE_FORMAT_S8Z24_UNORM,
00173    };
00174 
00175    switch (type) {
00176    case PIPE_RENDER_FORMAT:
00177       *numFormats = Elements(render_supported);
00178       return render_supported;
00179 
00180    case PIPE_TEX_FORMAT:
00181       *numFormats = Elements(tex_supported);
00182       return render_supported;
00183 
00184    case PIPE_Z_STENCIL_FORMAT:
00185       *numFormats = Elements(render_supported);
00186       return render_supported;
00187 
00188    default:
00189       *numFormats = 0;
00190       return NULL;
00191    }
00192 #else
00193    switch (format) {
00194    case PIPE_FORMAT_A8R8G8B8_UNORM:
00195    case PIPE_FORMAT_R5G6B5_UNORM:
00196    case PIPE_FORMAT_S8Z24_UNORM:
00197       return TRUE;
00198    default:
00199       return FALSE;
00200    };
00201    return FALSE;
00202 #endif
00203 }
00204 
00205 
00206 static void
00207 brw_destroy_screen( struct pipe_screen *screen )
00208 {
00209    struct pipe_winsys *winsys = screen->winsys;
00210 
00211    if(winsys->destroy)
00212       winsys->destroy(winsys);
00213 
00214    FREE(screen);
00215 }
00216 
00217 
00221 struct pipe_screen *
00222 brw_create_screen(struct pipe_winsys *winsys, uint pci_id)
00223 {
00224    struct brw_screen *brwscreen = CALLOC_STRUCT(brw_screen);
00225 
00226    if (!brwscreen)
00227       return NULL;
00228 
00229    brwscreen->pci_id = pci_id;
00230 
00231    brwscreen->screen.winsys = winsys;
00232 
00233    brwscreen->screen.destroy = brw_destroy_screen;
00234 
00235    brwscreen->screen.get_name = brw_get_name;
00236    brwscreen->screen.get_vendor = brw_get_vendor;
00237    brwscreen->screen.get_param = brw_get_param;
00238    brwscreen->screen.get_paramf = brw_get_paramf;
00239    brwscreen->screen.is_format_supported = brw_is_format_supported;
00240 
00241    brw_init_screen_texture_funcs(&brwscreen->screen);
00242 
00243    return &brwscreen->screen;
00244 }

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