sp_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 "pipe/p_defines.h"
00032 #include "pipe/p_screen.h"
00033 
00034 #include "sp_texture.h"
00035 #include "sp_winsys.h"
00036 #include "sp_screen.h"
00037 
00038 
00039 static const char *
00040 softpipe_get_vendor(struct pipe_screen *screen)
00041 {
00042    return "Tungsten Graphics, Inc.";
00043 }
00044 
00045 
00046 static const char *
00047 softpipe_get_name(struct pipe_screen *screen)
00048 {
00049    return "softpipe";
00050 }
00051 
00052 
00053 static int
00054 softpipe_get_param(struct pipe_screen *screen, int param)
00055 {
00056    switch (param) {
00057    case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
00058       return 8;
00059    case PIPE_CAP_NPOT_TEXTURES:
00060       return 1;
00061    case PIPE_CAP_TWO_SIDED_STENCIL:
00062       return 1;
00063    case PIPE_CAP_GLSL:
00064       return 1;
00065    case PIPE_CAP_S3TC:
00066       return 0;
00067    case PIPE_CAP_ANISOTROPIC_FILTER:
00068       return 0;
00069    case PIPE_CAP_POINT_SPRITE:
00070       return 1;
00071    case PIPE_CAP_MAX_RENDER_TARGETS:
00072       return PIPE_MAX_COLOR_BUFS;
00073    case PIPE_CAP_OCCLUSION_QUERY:
00074       return 1;
00075    case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
00076       return 1;
00077    case PIPE_CAP_TEXTURE_MIRROR_REPEAT:
00078       return 1;
00079    case PIPE_CAP_TEXTURE_SHADOW_MAP:
00080       return 1;
00081    case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
00082       return 12; /* max 2Kx2K */
00083    case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
00084       return 8;  /* max 128x128x128 */
00085    case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
00086       return 12; /* max 2Kx2K */
00087    default:
00088       return 0;
00089    }
00090 }
00091 
00092 
00093 static float
00094 softpipe_get_paramf(struct pipe_screen *screen, int param)
00095 {
00096    switch (param) {
00097    case PIPE_CAP_MAX_LINE_WIDTH:
00098       /* fall-through */
00099    case PIPE_CAP_MAX_LINE_WIDTH_AA:
00100       return 255.0; /* arbitrary */
00101    case PIPE_CAP_MAX_POINT_WIDTH:
00102       /* fall-through */
00103    case PIPE_CAP_MAX_POINT_WIDTH_AA:
00104       return 255.0; /* arbitrary */
00105    case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
00106       return 0.0;
00107    case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
00108       return 16.0; /* arbitrary */
00109    default:
00110       return 0;
00111    }
00112 }
00113 
00114 
00120 static boolean
00121 softpipe_is_format_supported( struct pipe_screen *screen,
00122                               enum pipe_format format, 
00123                               enum pipe_texture_target target,
00124                               unsigned tex_usage, 
00125                               unsigned geom_flags )
00126 {
00127    switch(format) {
00128    case PIPE_FORMAT_DXT1_RGB:
00129    case PIPE_FORMAT_DXT1_RGBA:
00130    case PIPE_FORMAT_DXT3_RGBA:
00131    case PIPE_FORMAT_DXT5_RGBA:
00132    case PIPE_FORMAT_Z32_FLOAT:
00133       return FALSE;
00134    default:
00135       return TRUE;
00136    }
00137 }
00138 
00139 
00140 static void
00141 softpipe_destroy_screen( struct pipe_screen *screen )
00142 {
00143    struct pipe_winsys *winsys = screen->winsys;
00144 
00145    if(winsys->destroy)
00146       winsys->destroy(winsys);
00147 
00148    FREE(screen);
00149 }
00150 
00151 
00152 
00157 struct pipe_screen *
00158 softpipe_create_screen(struct pipe_winsys *winsys)
00159 {
00160    struct softpipe_screen *screen = CALLOC_STRUCT(softpipe_screen);
00161 
00162    if (!screen)
00163       return NULL;
00164 
00165    screen->base.winsys = winsys;
00166 
00167    screen->base.destroy = softpipe_destroy_screen;
00168 
00169    screen->base.get_name = softpipe_get_name;
00170    screen->base.get_vendor = softpipe_get_vendor;
00171    screen->base.get_param = softpipe_get_param;
00172    screen->base.get_paramf = softpipe_get_paramf;
00173    screen->base.is_format_supported = softpipe_is_format_supported;
00174 
00175    softpipe_init_screen_texture_funcs(&screen->base);
00176 
00177    return &screen->base;
00178 }

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