00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "util/u_memory.h"
00030 #include "pipe/p_winsys.h"
00031 #include "pipe/p_inlines.h"
00032 #include "util/u_string.h"
00033
00034 #include "i915_reg.h"
00035 #include "i915_context.h"
00036 #include "i915_screen.h"
00037 #include "i915_texture.h"
00038
00039
00040 static const char *
00041 i915_get_vendor( struct pipe_screen *pscreen )
00042 {
00043 return "Tungsten Graphics, Inc.";
00044 }
00045
00046
00047 static const char *
00048 i915_get_name( struct pipe_screen *pscreen )
00049 {
00050 static char buffer[128];
00051 const char *chipset;
00052
00053 switch (i915_screen(pscreen)->pci_id) {
00054 case PCI_CHIP_I915_G:
00055 chipset = "915G";
00056 break;
00057 case PCI_CHIP_I915_GM:
00058 chipset = "915GM";
00059 break;
00060 case PCI_CHIP_I945_G:
00061 chipset = "945G";
00062 break;
00063 case PCI_CHIP_I945_GM:
00064 chipset = "945GM";
00065 break;
00066 case PCI_CHIP_I945_GME:
00067 chipset = "945GME";
00068 break;
00069 case PCI_CHIP_G33_G:
00070 chipset = "G33";
00071 break;
00072 case PCI_CHIP_Q35_G:
00073 chipset = "Q35";
00074 break;
00075 case PCI_CHIP_Q33_G:
00076 chipset = "Q33";
00077 break;
00078 default:
00079 chipset = "unknown";
00080 break;
00081 }
00082
00083 util_snprintf(buffer, sizeof(buffer), "i915 (chipset: %s)", chipset);
00084 return buffer;
00085 }
00086
00087
00088 static int
00089 i915_get_param(struct pipe_screen *screen, int param)
00090 {
00091 switch (param) {
00092 case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
00093 return 8;
00094 case PIPE_CAP_NPOT_TEXTURES:
00095 return 1;
00096 case PIPE_CAP_TWO_SIDED_STENCIL:
00097 return 1;
00098 case PIPE_CAP_GLSL:
00099 return 0;
00100 case PIPE_CAP_S3TC:
00101 return 0;
00102 case PIPE_CAP_ANISOTROPIC_FILTER:
00103 return 0;
00104 case PIPE_CAP_POINT_SPRITE:
00105 return 0;
00106 case PIPE_CAP_MAX_RENDER_TARGETS:
00107 return 1;
00108 case PIPE_CAP_OCCLUSION_QUERY:
00109 return 0;
00110 case PIPE_CAP_TEXTURE_SHADOW_MAP:
00111 return 1;
00112 case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
00113 return 11;
00114 case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
00115 return 8;
00116 case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
00117 return 11;
00118 default:
00119 return 0;
00120 }
00121 }
00122
00123
00124 static float
00125 i915_get_paramf(struct pipe_screen *screen, int param)
00126 {
00127 switch (param) {
00128 case PIPE_CAP_MAX_LINE_WIDTH:
00129
00130 case PIPE_CAP_MAX_LINE_WIDTH_AA:
00131 return 7.5;
00132
00133 case PIPE_CAP_MAX_POINT_WIDTH:
00134
00135 case PIPE_CAP_MAX_POINT_WIDTH_AA:
00136 return 255.0;
00137
00138 case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
00139 return 4.0;
00140
00141 case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
00142 return 16.0;
00143
00144 default:
00145 return 0;
00146 }
00147 }
00148
00149
00150 static boolean
00151 i915_is_format_supported( struct pipe_screen *screen,
00152 enum pipe_format format,
00153 enum pipe_texture_target target,
00154 unsigned tex_usage,
00155 unsigned geom_flags )
00156 {
00157 static const enum pipe_format tex_supported[] = {
00158 PIPE_FORMAT_R8G8B8A8_UNORM,
00159 PIPE_FORMAT_A8R8G8B8_UNORM,
00160 PIPE_FORMAT_R5G6B5_UNORM,
00161 PIPE_FORMAT_L8_UNORM,
00162 PIPE_FORMAT_A8_UNORM,
00163 PIPE_FORMAT_I8_UNORM,
00164 PIPE_FORMAT_A8L8_UNORM,
00165 PIPE_FORMAT_YCBCR,
00166 PIPE_FORMAT_YCBCR_REV,
00167 PIPE_FORMAT_S8Z24_UNORM,
00168 PIPE_FORMAT_NONE
00169 };
00170 static const enum pipe_format surface_supported[] = {
00171 PIPE_FORMAT_A8R8G8B8_UNORM,
00172 PIPE_FORMAT_R5G6B5_UNORM,
00173 PIPE_FORMAT_S8Z24_UNORM,
00174
00175 PIPE_FORMAT_NONE
00176 };
00177 const enum pipe_format *list;
00178 uint i;
00179
00180 if(tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET)
00181 list = surface_supported;
00182 else
00183 list = tex_supported;
00184
00185 for (i = 0; list[i] != PIPE_FORMAT_NONE; i++) {
00186 if (list[i] == format)
00187 return TRUE;
00188 }
00189
00190 return FALSE;
00191 }
00192
00193
00194 static void
00195 i915_destroy_screen( struct pipe_screen *screen )
00196 {
00197 struct pipe_winsys *winsys = screen->winsys;
00198
00199 if(winsys->destroy)
00200 winsys->destroy(winsys);
00201
00202 FREE(screen);
00203 }
00204
00205
00206 static void *
00207 i915_surface_map( struct pipe_screen *screen,
00208 struct pipe_surface *surface,
00209 unsigned flags )
00210 {
00211 char *map = pipe_buffer_map( screen, surface->buffer, flags );
00212 if (map == NULL)
00213 return NULL;
00214
00215 if (surface->texture &&
00216 (flags & PIPE_BUFFER_USAGE_CPU_WRITE))
00217 {
00218
00219
00220
00221 }
00222
00223 return map + surface->offset;
00224 }
00225
00226 static void
00227 i915_surface_unmap(struct pipe_screen *screen,
00228 struct pipe_surface *surface)
00229 {
00230 pipe_buffer_unmap( screen, surface->buffer );
00231 }
00232
00233
00234
00238 struct pipe_screen *
00239 i915_create_screen(struct pipe_winsys *winsys, uint pci_id)
00240 {
00241 struct i915_screen *i915screen = CALLOC_STRUCT(i915_screen);
00242
00243 if (!i915screen)
00244 return NULL;
00245
00246 switch (pci_id) {
00247 case PCI_CHIP_I915_G:
00248 case PCI_CHIP_I915_GM:
00249 i915screen->is_i945 = FALSE;
00250 break;
00251
00252 case PCI_CHIP_I945_G:
00253 case PCI_CHIP_I945_GM:
00254 case PCI_CHIP_I945_GME:
00255 case PCI_CHIP_G33_G:
00256 case PCI_CHIP_Q33_G:
00257 case PCI_CHIP_Q35_G:
00258 i915screen->is_i945 = TRUE;
00259 break;
00260
00261 default:
00262 debug_printf("%s: unknown pci id 0x%x, cannot create screen\n",
00263 __FUNCTION__, pci_id);
00264 return NULL;
00265 }
00266
00267 i915screen->pci_id = pci_id;
00268
00269 i915screen->screen.winsys = winsys;
00270
00271 i915screen->screen.destroy = i915_destroy_screen;
00272
00273 i915screen->screen.get_name = i915_get_name;
00274 i915screen->screen.get_vendor = i915_get_vendor;
00275 i915screen->screen.get_param = i915_get_param;
00276 i915screen->screen.get_paramf = i915_get_paramf;
00277 i915screen->screen.is_format_supported = i915_is_format_supported;
00278 i915screen->screen.surface_map = i915_surface_map;
00279 i915screen->screen.surface_unmap = i915_surface_unmap;
00280
00281 i915_init_screen_texture_functions(&i915screen->screen);
00282
00283 return &i915screen->screen;
00284 }