cell_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 "cell/common.h"
00035 #include "cell_screen.h"
00036 #include "cell_texture.h"
00037 #include "cell_winsys.h"
00038 
00039 
00040 static const char *
00041 cell_get_vendor(struct pipe_screen *screen)
00042 {
00043    return "Tungsten Graphics, Inc.";
00044 }
00045 
00046 
00047 static const char *
00048 cell_get_name(struct pipe_screen *screen)
00049 {
00050    return "Cell";
00051 }
00052 
00053 
00054 static int
00055 cell_get_param(struct pipe_screen *screen, int param)
00056 {
00057    switch (param) {
00058    case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
00059       return CELL_MAX_SAMPLERS;
00060    case PIPE_CAP_NPOT_TEXTURES:
00061       return 0;
00062    case PIPE_CAP_TWO_SIDED_STENCIL:
00063       return 0;
00064    case PIPE_CAP_GLSL:
00065       return 1;
00066    case PIPE_CAP_S3TC:
00067       return 0;
00068    case PIPE_CAP_ANISOTROPIC_FILTER:
00069       return 0;
00070    case PIPE_CAP_POINT_SPRITE:
00071       return 0;
00072    case PIPE_CAP_MAX_RENDER_TARGETS:
00073       return 1;
00074    case PIPE_CAP_OCCLUSION_QUERY:
00075       return 0;
00076    case PIPE_CAP_TEXTURE_SHADOW_MAP:
00077       return 0;
00078    case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
00079       return 12; /* max 2Kx2K */
00080    case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
00081       return 8;  /* max 128x128x128 */
00082    case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
00083       return 12; /* max 2Kx2K */
00084    default:
00085       return 0;
00086    }
00087 }
00088 
00089 
00090 static float
00091 cell_get_paramf(struct pipe_screen *screen, int param)
00092 {
00093    switch (param) {
00094    case PIPE_CAP_MAX_LINE_WIDTH:
00095       /* fall-through */
00096    case PIPE_CAP_MAX_LINE_WIDTH_AA:
00097       return 255.0; /* arbitrary */
00098 
00099    case PIPE_CAP_MAX_POINT_WIDTH:
00100       /* fall-through */
00101    case PIPE_CAP_MAX_POINT_WIDTH_AA:
00102       return 255.0; /* arbitrary */
00103 
00104    case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
00105       return 0.0;
00106 
00107    case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
00108       return 16.0; /* arbitrary */
00109 
00110    default:
00111       return 0;
00112    }
00113 }
00114 
00115 
00116 static boolean
00117 cell_is_format_supported( struct pipe_screen *screen,
00118                           enum pipe_format format, 
00119                           enum pipe_texture_target target,
00120                           unsigned tex_usage, 
00121                           unsigned geom_flags )
00122 {
00123    /* cell supports most formats, XXX for now anyway */
00124    if (format == PIPE_FORMAT_DXT5_RGBA ||
00125        format == PIPE_FORMAT_R8G8B8A8_SRGB)
00126       return FALSE;
00127    else
00128       return TRUE;
00129 }
00130 
00131 
00132 static void
00133 cell_destroy_screen( struct pipe_screen *screen )
00134 {
00135    struct pipe_winsys *winsys = screen->winsys;
00136 
00137    if(winsys->destroy)
00138       winsys->destroy(winsys);
00139 
00140    FREE(screen);
00141 }
00142 
00143 
00149 struct pipe_screen *
00150 cell_create_screen(struct pipe_winsys *winsys)
00151 {
00152    struct pipe_screen *screen = CALLOC_STRUCT(pipe_screen);
00153 
00154    if (!screen)
00155       return NULL;
00156 
00157    screen->winsys = winsys;
00158 
00159    screen->destroy = cell_destroy_screen;
00160 
00161    screen->get_name = cell_get_name;
00162    screen->get_vendor = cell_get_vendor;
00163    screen->get_param = cell_get_param;
00164    screen->get_paramf = cell_get_paramf;
00165    screen->is_format_supported = cell_is_format_supported;
00166 
00167    cell_init_screen_texture_funcs(screen);
00168 
00169    return screen;
00170 }

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