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.h"
31 #include "pipe/p_defines.h"
32 #include "pipe/p_screen.h"
34 #include "lp_texture.h"
35 #include "lp_buffer.h"
36 #include "lp_winsys.h"
38 #include "lp_screen.h"
44 static const struct debug_named_value lp_debug_flags
[] = {
45 { "pipe", DEBUG_PIPE
},
46 { "tgsi", DEBUG_TGSI
},
49 { "setup", DEBUG_SETUP
},
50 { "rast", DEBUG_RAST
},
51 { "query", DEBUG_QUERY
},
52 { "screen", DEBUG_SCREEN
},
60 llvmpipe_get_vendor(struct pipe_screen
*screen
)
62 return "VMware, Inc.";
67 llvmpipe_get_name(struct pipe_screen
*screen
)
74 llvmpipe_get_param(struct pipe_screen
*screen
, int param
)
77 case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS
:
78 return PIPE_MAX_SAMPLERS
;
79 case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS
:
80 return PIPE_MAX_VERTEX_SAMPLERS
;
81 case PIPE_CAP_MAX_COMBINED_SAMPLERS
:
82 return PIPE_MAX_SAMPLERS
+ PIPE_MAX_VERTEX_SAMPLERS
;
83 case PIPE_CAP_NPOT_TEXTURES
:
85 case PIPE_CAP_TWO_SIDED_STENCIL
:
89 case PIPE_CAP_ANISOTROPIC_FILTER
:
91 case PIPE_CAP_POINT_SPRITE
:
93 case PIPE_CAP_MAX_RENDER_TARGETS
:
94 return PIPE_MAX_COLOR_BUFS
;
95 case PIPE_CAP_OCCLUSION_QUERY
:
97 case PIPE_CAP_TEXTURE_MIRROR_CLAMP
:
99 case PIPE_CAP_TEXTURE_MIRROR_REPEAT
:
101 case PIPE_CAP_TEXTURE_SHADOW_MAP
:
103 case PIPE_CAP_MAX_TEXTURE_2D_LEVELS
:
104 return 13; /* max 4Kx4K */
105 case PIPE_CAP_MAX_TEXTURE_3D_LEVELS
:
106 return 9; /* max 256x256x256 */
107 case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS
:
108 return 13; /* max 4Kx4K */
109 case PIPE_CAP_TGSI_CONT_SUPPORTED
:
111 case PIPE_CAP_BLEND_EQUATION_SEPARATE
:
120 llvmpipe_get_paramf(struct pipe_screen
*screen
, int param
)
123 case PIPE_CAP_MAX_LINE_WIDTH
:
125 case PIPE_CAP_MAX_LINE_WIDTH_AA
:
126 return 255.0; /* arbitrary */
127 case PIPE_CAP_MAX_POINT_WIDTH
:
129 case PIPE_CAP_MAX_POINT_WIDTH_AA
:
130 return 255.0; /* arbitrary */
131 case PIPE_CAP_MAX_TEXTURE_ANISOTROPY
:
132 return 16.0; /* not actually signficant at this time */
133 case PIPE_CAP_MAX_TEXTURE_LOD_BIAS
:
134 return 16.0; /* arbitrary */
142 * Query format support for creating a texture, drawing surface, etc.
143 * \param format the format to test
144 * \param type one of PIPE_TEXTURE, PIPE_SURFACE
147 llvmpipe_is_format_supported( struct pipe_screen
*_screen
,
148 enum pipe_format format
,
149 enum pipe_texture_target target
,
151 unsigned geom_flags
)
153 struct llvmpipe_screen
*screen
= llvmpipe_screen(_screen
);
154 struct llvmpipe_winsys
*winsys
= screen
->winsys
;
155 const struct util_format_description
*format_desc
;
157 format_desc
= util_format_description(format
);
161 assert(target
== PIPE_TEXTURE_1D
||
162 target
== PIPE_TEXTURE_2D
||
163 target
== PIPE_TEXTURE_3D
||
164 target
== PIPE_TEXTURE_CUBE
);
167 case PIPE_FORMAT_DXT1_RGB
:
168 case PIPE_FORMAT_DXT1_RGBA
:
169 case PIPE_FORMAT_DXT3_RGBA
:
170 case PIPE_FORMAT_DXT5_RGBA
:
176 if(tex_usage
& PIPE_TEXTURE_USAGE_RENDER_TARGET
) {
177 if(format_desc
->block
.width
!= 1 ||
178 format_desc
->block
.height
!= 1)
181 if(format_desc
->layout
!= UTIL_FORMAT_LAYOUT_SCALAR
&&
182 format_desc
->layout
!= UTIL_FORMAT_LAYOUT_ARITH
&&
183 format_desc
->layout
!= UTIL_FORMAT_LAYOUT_ARRAY
)
186 if(format_desc
->colorspace
!= UTIL_FORMAT_COLORSPACE_RGB
&&
187 format_desc
->colorspace
!= UTIL_FORMAT_COLORSPACE_SRGB
)
191 if(tex_usage
& PIPE_TEXTURE_USAGE_DISPLAY_TARGET
) {
192 if(!winsys
->is_displaytarget_format_supported(winsys
, format
))
196 if(tex_usage
& PIPE_TEXTURE_USAGE_DEPTH_STENCIL
) {
197 if(format_desc
->colorspace
!= UTIL_FORMAT_COLORSPACE_ZS
)
200 /* FIXME: Temporary restriction. See lp_state_fs.c. */
201 if(format_desc
->block
.bits
!= 32)
205 /* FIXME: Temporary restrictions. See lp_bld_sample_soa.c */
206 if(tex_usage
& PIPE_TEXTURE_USAGE_SAMPLER
) {
207 if(format_desc
->block
.width
!= 1 ||
208 format_desc
->block
.height
!= 1)
211 if(format_desc
->layout
!= UTIL_FORMAT_LAYOUT_SCALAR
&&
212 format_desc
->layout
!= UTIL_FORMAT_LAYOUT_ARITH
&&
213 format_desc
->layout
!= UTIL_FORMAT_LAYOUT_ARRAY
)
216 if(format_desc
->colorspace
!= UTIL_FORMAT_COLORSPACE_RGB
&&
217 format_desc
->colorspace
!= UTIL_FORMAT_COLORSPACE_SRGB
&&
218 format_desc
->colorspace
!= UTIL_FORMAT_COLORSPACE_ZS
)
226 static struct pipe_buffer
*
227 llvmpipe_surface_buffer_create(struct pipe_screen
*screen
,
228 unsigned width
, unsigned height
,
229 enum pipe_format format
,
234 /* This function should never be used */
241 llvmpipe_flush_frontbuffer(struct pipe_screen
*_screen
,
242 struct pipe_surface
*surface
,
243 void *context_private
)
245 struct llvmpipe_screen
*screen
= llvmpipe_screen(_screen
);
246 struct llvmpipe_winsys
*winsys
= screen
->winsys
;
247 struct llvmpipe_texture
*texture
= llvmpipe_texture(surface
->texture
);
251 winsys
->displaytarget_display(winsys
, texture
->dt
, context_private
);
256 llvmpipe_destroy_screen( struct pipe_screen
*_screen
)
258 struct llvmpipe_screen
*screen
= llvmpipe_screen(_screen
);
259 struct llvmpipe_winsys
*winsys
= screen
->winsys
;
261 lp_jit_screen_cleanup(screen
);
264 winsys
->destroy(winsys
);
272 * Create a new pipe_screen object
273 * Note: we're not presently subclassing pipe_screen (no llvmpipe_screen).
276 llvmpipe_create_screen(struct llvmpipe_winsys
*winsys
)
278 struct llvmpipe_screen
*screen
= CALLOC_STRUCT(llvmpipe_screen
);
281 LP_DEBUG
= debug_get_flags_option("LP_DEBUG", lp_debug_flags
, 0 );
287 screen
->winsys
= winsys
;
289 screen
->base
.destroy
= llvmpipe_destroy_screen
;
291 screen
->base
.get_name
= llvmpipe_get_name
;
292 screen
->base
.get_vendor
= llvmpipe_get_vendor
;
293 screen
->base
.get_param
= llvmpipe_get_param
;
294 screen
->base
.get_paramf
= llvmpipe_get_paramf
;
295 screen
->base
.is_format_supported
= llvmpipe_is_format_supported
;
297 screen
->base
.surface_buffer_create
= llvmpipe_surface_buffer_create
;
298 screen
->base
.flush_frontbuffer
= llvmpipe_flush_frontbuffer
;
300 llvmpipe_init_screen_texture_funcs(&screen
->base
);
301 llvmpipe_init_screen_buffer_funcs(&screen
->base
);
303 lp_jit_screen_init(screen
);
305 return &screen
->base
;