1 /**************************************************************************
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
29 #include "util/u_memory.h"
30 #include "util/u_format_s3tc.h"
31 #include "pipe/p_defines.h"
32 #include "pipe/p_screen.h"
34 #include "state_tracker/sw_winsys.h"
36 #include "sp_texture.h"
37 #include "sp_screen.h"
38 #include "sp_context.h"
39 #include "sp_buffer.h"
41 #include "sp_public.h"
45 softpipe_get_vendor(struct pipe_screen *screen)
47 return "VMware, Inc.";
52 softpipe_get_name(struct pipe_screen *screen)
59 softpipe_get_param(struct pipe_screen *screen, int param)
62 case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
63 return PIPE_MAX_SAMPLERS;
64 case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
65 return PIPE_MAX_VERTEX_SAMPLERS;
66 case PIPE_CAP_MAX_COMBINED_SAMPLERS:
67 return PIPE_MAX_SAMPLERS + PIPE_MAX_VERTEX_SAMPLERS;
68 case PIPE_CAP_NPOT_TEXTURES:
70 case PIPE_CAP_TWO_SIDED_STENCIL:
74 case PIPE_CAP_ANISOTROPIC_FILTER:
76 case PIPE_CAP_POINT_SPRITE:
78 case PIPE_CAP_MAX_RENDER_TARGETS:
79 return PIPE_MAX_COLOR_BUFS;
80 case PIPE_CAP_OCCLUSION_QUERY:
82 case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
84 case PIPE_CAP_TEXTURE_MIRROR_REPEAT:
86 case PIPE_CAP_TEXTURE_SHADOW_MAP:
88 case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
89 return SP_MAX_TEXTURE_2D_LEVELS;
90 case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
91 return SP_MAX_TEXTURE_3D_LEVELS;
92 case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
93 return SP_MAX_TEXTURE_2D_LEVELS;
94 case PIPE_CAP_TGSI_CONT_SUPPORTED:
96 case PIPE_CAP_BLEND_EQUATION_SEPARATE:
98 case PIPE_CAP_MAX_CONST_BUFFERS:
99 return PIPE_MAX_CONSTANT_BUFFERS;
100 case PIPE_CAP_MAX_CONST_BUFFER_SIZE:
101 return 4096 * 4 * sizeof(float);
102 case PIPE_CAP_INDEP_BLEND_ENABLE:
104 case PIPE_CAP_INDEP_BLEND_FUNC:
106 case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT:
107 case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:
108 case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
109 case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
118 softpipe_get_paramf(struct pipe_screen *screen, int param)
121 case PIPE_CAP_MAX_LINE_WIDTH:
123 case PIPE_CAP_MAX_LINE_WIDTH_AA:
124 return 255.0; /* arbitrary */
125 case PIPE_CAP_MAX_POINT_WIDTH:
127 case PIPE_CAP_MAX_POINT_WIDTH_AA:
128 return 255.0; /* arbitrary */
129 case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
130 return 16.0; /* not actually signficant at this time */
131 case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
132 return 16.0; /* arbitrary */
140 * Query format support for creating a texture, drawing surface, etc.
141 * \param format the format to test
142 * \param type one of PIPE_TEXTURE, PIPE_SURFACE
145 softpipe_is_format_supported( struct pipe_screen *screen,
146 enum pipe_format format,
147 enum pipe_texture_target target,
149 unsigned geom_flags )
151 struct sw_winsys *winsys = softpipe_screen(screen)->winsys;
153 assert(target == PIPE_TEXTURE_1D ||
154 target == PIPE_TEXTURE_2D ||
155 target == PIPE_TEXTURE_3D ||
156 target == PIPE_TEXTURE_CUBE);
159 case PIPE_FORMAT_YUYV:
160 case PIPE_FORMAT_UYVY:
163 case PIPE_FORMAT_DXT1_RGB:
164 case PIPE_FORMAT_DXT1_RGBA:
165 case PIPE_FORMAT_DXT3_RGBA:
166 case PIPE_FORMAT_DXT5_RGBA:
167 return util_format_s3tc_enabled;
169 case PIPE_FORMAT_Z32_FLOAT:
170 case PIPE_FORMAT_NONE:
177 if(tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
178 PIPE_TEXTURE_USAGE_SCANOUT |
179 PIPE_TEXTURE_USAGE_SHARED)) {
180 if(!winsys->is_displaytarget_format_supported(winsys, tex_usage, format))
184 /* XXX: this is often a lie. Pull in logic from llvmpipe to fix.
191 softpipe_destroy_screen( struct pipe_screen *screen )
193 struct softpipe_screen *sp_screen = softpipe_screen(screen);
194 struct sw_winsys *winsys = sp_screen->winsys;
197 winsys->destroy(winsys);
203 /* This is often overriden by the co-state tracker.
206 softpipe_flush_frontbuffer(struct pipe_screen *_screen,
207 struct pipe_surface *surface,
208 void *context_private)
210 struct softpipe_screen *screen = softpipe_screen(_screen);
211 struct sw_winsys *winsys = screen->winsys;
212 struct softpipe_texture *texture = softpipe_texture(surface->texture);
216 winsys->displaytarget_display(winsys, texture->dt, context_private);
220 * Create a new pipe_screen object
221 * Note: we're not presently subclassing pipe_screen (no softpipe_screen).
224 softpipe_create_screen(struct sw_winsys *winsys)
226 struct softpipe_screen *screen = CALLOC_STRUCT(softpipe_screen);
231 screen->winsys = winsys;
233 screen->base.winsys = NULL;
234 screen->base.destroy = softpipe_destroy_screen;
236 screen->base.get_name = softpipe_get_name;
237 screen->base.get_vendor = softpipe_get_vendor;
238 screen->base.get_param = softpipe_get_param;
239 screen->base.get_paramf = softpipe_get_paramf;
240 screen->base.is_format_supported = softpipe_is_format_supported;
241 screen->base.context_create = softpipe_create_context;
242 screen->base.flush_frontbuffer = softpipe_flush_frontbuffer;
244 util_format_s3tc_init();
246 softpipe_init_screen_texture_funcs(&screen->base);
247 softpipe_init_screen_buffer_funcs(&screen->base);
248 softpipe_init_screen_fence_funcs(&screen->base);
250 return &screen->base;