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 "pipe/p_defines.h"
31 #include "pipe/p_screen.h"
33 #include "state_tracker/sw_winsys.h"
35 #include "sp_texture.h"
36 #include "sp_screen.h"
37 #include "sp_context.h"
38 #include "sp_buffer.h"
40 #include "sp_public.h"
44 softpipe_get_vendor(struct pipe_screen
*screen
)
46 return "VMware, Inc.";
51 softpipe_get_name(struct pipe_screen
*screen
)
58 softpipe_get_param(struct pipe_screen
*screen
, int param
)
61 case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS
:
62 return PIPE_MAX_SAMPLERS
;
63 case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS
:
64 return PIPE_MAX_VERTEX_SAMPLERS
;
65 case PIPE_CAP_MAX_COMBINED_SAMPLERS
:
66 return PIPE_MAX_SAMPLERS
+ PIPE_MAX_VERTEX_SAMPLERS
;
67 case PIPE_CAP_NPOT_TEXTURES
:
69 case PIPE_CAP_TWO_SIDED_STENCIL
:
73 case PIPE_CAP_ANISOTROPIC_FILTER
:
75 case PIPE_CAP_POINT_SPRITE
:
77 case PIPE_CAP_MAX_RENDER_TARGETS
:
78 return PIPE_MAX_COLOR_BUFS
;
79 case PIPE_CAP_OCCLUSION_QUERY
:
81 case PIPE_CAP_TEXTURE_MIRROR_CLAMP
:
83 case PIPE_CAP_TEXTURE_MIRROR_REPEAT
:
85 case PIPE_CAP_TEXTURE_SHADOW_MAP
:
87 case PIPE_CAP_MAX_TEXTURE_2D_LEVELS
:
88 return SP_MAX_TEXTURE_2D_LEVELS
;
89 case PIPE_CAP_MAX_TEXTURE_3D_LEVELS
:
90 return SP_MAX_TEXTURE_3D_LEVELS
;
91 case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS
:
92 return SP_MAX_TEXTURE_2D_LEVELS
;
93 case PIPE_CAP_TGSI_CONT_SUPPORTED
:
95 case PIPE_CAP_BLEND_EQUATION_SEPARATE
:
97 case PIPE_CAP_MAX_CONST_BUFFERS
:
98 return PIPE_MAX_CONSTANT_BUFFERS
;
99 case PIPE_CAP_MAX_CONST_BUFFER_SIZE
:
100 return 4096 * 4 * sizeof(float);
101 case PIPE_CAP_INDEP_BLEND_ENABLE
:
103 case PIPE_CAP_INDEP_BLEND_FUNC
:
105 case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT
:
106 case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT
:
107 case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER
:
108 case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER
:
117 softpipe_get_paramf(struct pipe_screen
*screen
, int param
)
120 case PIPE_CAP_MAX_LINE_WIDTH
:
122 case PIPE_CAP_MAX_LINE_WIDTH_AA
:
123 return 255.0; /* arbitrary */
124 case PIPE_CAP_MAX_POINT_WIDTH
:
126 case PIPE_CAP_MAX_POINT_WIDTH_AA
:
127 return 255.0; /* arbitrary */
128 case PIPE_CAP_MAX_TEXTURE_ANISOTROPY
:
129 return 16.0; /* not actually signficant at this time */
130 case PIPE_CAP_MAX_TEXTURE_LOD_BIAS
:
131 return 16.0; /* arbitrary */
139 * Query format support for creating a texture, drawing surface, etc.
140 * \param format the format to test
141 * \param type one of PIPE_TEXTURE, PIPE_SURFACE
144 softpipe_is_format_supported( struct pipe_screen
*screen
,
145 enum pipe_format format
,
146 enum pipe_texture_target target
,
148 unsigned geom_flags
)
150 struct sw_winsys
*winsys
= softpipe_screen(screen
)->winsys
;
152 assert(target
== PIPE_TEXTURE_1D
||
153 target
== PIPE_TEXTURE_2D
||
154 target
== PIPE_TEXTURE_3D
||
155 target
== PIPE_TEXTURE_CUBE
);
158 case PIPE_FORMAT_L16_UNORM
:
159 case PIPE_FORMAT_YUYV
:
160 case PIPE_FORMAT_UYVY
:
161 case PIPE_FORMAT_DXT1_RGB
:
162 case PIPE_FORMAT_DXT1_RGBA
:
163 case PIPE_FORMAT_DXT3_RGBA
:
164 case PIPE_FORMAT_DXT5_RGBA
:
165 case PIPE_FORMAT_Z32_FLOAT
:
166 case PIPE_FORMAT_R8G8_SNORM
:
167 case PIPE_FORMAT_R5SG5SB6U_NORM
:
168 case PIPE_FORMAT_R8SG8SB8UX8U_NORM
:
169 case PIPE_FORMAT_R8G8B8A8_SNORM
:
170 case PIPE_FORMAT_NONE
:
176 if(tex_usage
& (PIPE_TEXTURE_USAGE_DISPLAY_TARGET
|
177 PIPE_TEXTURE_USAGE_SCANOUT
|
178 PIPE_TEXTURE_USAGE_SHARED
)) {
179 if(!winsys
->is_displaytarget_format_supported(winsys
, tex_usage
, format
))
183 /* XXX: this is often a lie. Pull in logic from llvmpipe to fix.
190 softpipe_destroy_screen( struct pipe_screen
*screen
)
192 struct softpipe_screen
*sp_screen
= softpipe_screen(screen
);
193 struct sw_winsys
*winsys
= sp_screen
->winsys
;
196 winsys
->destroy(winsys
);
202 /* This is often overriden by the co-state tracker.
205 softpipe_flush_frontbuffer(struct pipe_screen
*_screen
,
206 struct pipe_surface
*surface
,
207 void *context_private
)
209 struct softpipe_screen
*screen
= softpipe_screen(_screen
);
210 struct sw_winsys
*winsys
= screen
->winsys
;
211 struct softpipe_texture
*texture
= softpipe_texture(surface
->texture
);
215 winsys
->displaytarget_display(winsys
, texture
->dt
, context_private
);
219 * Create a new pipe_screen object
220 * Note: we're not presently subclassing pipe_screen (no softpipe_screen).
223 softpipe_create_screen(struct sw_winsys
*winsys
)
225 struct softpipe_screen
*screen
= CALLOC_STRUCT(softpipe_screen
);
230 screen
->winsys
= winsys
;
232 screen
->base
.winsys
= NULL
;
233 screen
->base
.destroy
= softpipe_destroy_screen
;
235 screen
->base
.get_name
= softpipe_get_name
;
236 screen
->base
.get_vendor
= softpipe_get_vendor
;
237 screen
->base
.get_param
= softpipe_get_param
;
238 screen
->base
.get_paramf
= softpipe_get_paramf
;
239 screen
->base
.is_format_supported
= softpipe_is_format_supported
;
240 screen
->base
.context_create
= softpipe_create_context
;
241 screen
->base
.flush_frontbuffer
= softpipe_flush_frontbuffer
;
243 softpipe_init_screen_texture_funcs(&screen
->base
);
244 softpipe_init_screen_buffer_funcs(&screen
->base
);
245 softpipe_init_screen_fence_funcs(&screen
->base
);
247 return &screen
->base
;