1 /**************************************************************************
3 * Copyright 2008 VMware, Inc.
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 VMWARE 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_math.h"
31 #include "util/u_cpu_detect.h"
32 #include "util/u_format.h"
33 #include "util/u_string.h"
34 #include "util/u_format_s3tc.h"
35 #include "pipe/p_defines.h"
36 #include "pipe/p_screen.h"
37 #include "draw/draw_context.h"
38 #include "gallivm/lp_bld_type.h"
40 #include "os/os_misc.h"
41 #include "util/os_time.h"
42 #include "lp_texture.h"
45 #include "lp_screen.h"
46 #include "lp_context.h"
48 #include "lp_public.h"
49 #include "lp_limits.h"
52 #include "state_tracker/sw_winsys.h"
57 static const struct debug_named_value lp_debug_flags[] = {
58 { "pipe", DEBUG_PIPE, NULL },
59 { "tgsi", DEBUG_TGSI, NULL },
60 { "tex", DEBUG_TEX, NULL },
61 { "setup", DEBUG_SETUP, NULL },
62 { "rast", DEBUG_RAST, NULL },
63 { "query", DEBUG_QUERY, NULL },
64 { "screen", DEBUG_SCREEN, NULL },
65 { "counters", DEBUG_COUNTERS, NULL },
66 { "scene", DEBUG_SCENE, NULL },
67 { "fence", DEBUG_FENCE, NULL },
68 { "mem", DEBUG_MEM, NULL },
69 { "fs", DEBUG_FS, NULL },
75 static const struct debug_named_value lp_perf_flags[] = {
76 { "texmem", PERF_TEX_MEM, NULL },
77 { "no_mipmap", PERF_NO_MIPMAPS, NULL },
78 { "no_linear", PERF_NO_LINEAR, NULL },
79 { "no_mip_linear", PERF_NO_MIP_LINEAR, NULL },
80 { "no_tex", PERF_NO_TEX, NULL },
81 { "no_blend", PERF_NO_BLEND, NULL },
82 { "no_depth", PERF_NO_DEPTH, NULL },
83 { "no_alphatest", PERF_NO_ALPHATEST, NULL },
89 llvmpipe_get_vendor(struct pipe_screen *screen)
91 return "VMware, Inc.";
96 llvmpipe_get_name(struct pipe_screen *screen)
99 util_snprintf(buf, sizeof(buf), "llvmpipe (LLVM %u.%u, %u bits)",
100 HAVE_LLVM >> 8, HAVE_LLVM & 0xff,
101 lp_native_vector_width );
107 llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
110 case PIPE_CAP_NPOT_TEXTURES:
111 case PIPE_CAP_MIXED_FRAMEBUFFER_SIZES:
112 case PIPE_CAP_MIXED_COLOR_DEPTH_BITS:
116 case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS:
118 case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS:
119 return PIPE_MAX_SO_BUFFERS;
120 case PIPE_CAP_ANISOTROPIC_FILTER:
122 case PIPE_CAP_POINT_SPRITE:
124 case PIPE_CAP_MAX_RENDER_TARGETS:
125 return PIPE_MAX_COLOR_BUFS;
126 case PIPE_CAP_OCCLUSION_QUERY:
128 case PIPE_CAP_QUERY_TIME_ELAPSED:
130 case PIPE_CAP_QUERY_TIMESTAMP:
132 case PIPE_CAP_QUERY_PIPELINE_STATISTICS:
134 case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
136 case PIPE_CAP_TEXTURE_SWIZZLE:
138 case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK:
140 case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
141 return LP_MAX_TEXTURE_2D_LEVELS;
142 case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
143 return LP_MAX_TEXTURE_3D_LEVELS;
144 case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
145 return LP_MAX_TEXTURE_CUBE_LEVELS;
146 case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS:
147 return LP_MAX_TEXTURE_ARRAY_LAYERS;
148 case PIPE_CAP_BLEND_EQUATION_SEPARATE:
150 case PIPE_CAP_INDEP_BLEND_ENABLE:
152 case PIPE_CAP_INDEP_BLEND_FUNC:
154 case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT:
155 case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
156 case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
158 case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:
160 case PIPE_CAP_PRIMITIVE_RESTART:
162 case PIPE_CAP_DEPTH_CLIP_DISABLE:
164 case PIPE_CAP_SHADER_STENCIL_EXPORT:
166 case PIPE_CAP_TGSI_INSTANCEID:
167 case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR:
168 case PIPE_CAP_START_INSTANCE:
170 case PIPE_CAP_FRAGMENT_COLOR_CLAMPED:
172 case PIPE_CAP_MIXED_COLORBUFFER_FORMATS:
174 case PIPE_CAP_SEAMLESS_CUBE_MAP:
175 case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE:
177 /* this is a lie could support arbitrary large offsets */
178 case PIPE_CAP_MIN_TEXTURE_GATHER_OFFSET:
179 case PIPE_CAP_MIN_TEXEL_OFFSET:
181 case PIPE_CAP_MAX_TEXTURE_GATHER_OFFSET:
182 case PIPE_CAP_MAX_TEXEL_OFFSET:
184 case PIPE_CAP_CONDITIONAL_RENDER:
186 case PIPE_CAP_TEXTURE_BARRIER:
188 case PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS:
189 case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS:
191 case PIPE_CAP_MAX_GEOMETRY_OUTPUT_VERTICES:
192 case PIPE_CAP_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS:
194 case PIPE_CAP_MAX_VERTEX_STREAMS:
196 case PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE:
198 case PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME:
199 case PIPE_CAP_STREAM_OUTPUT_INTERLEAVE_BUFFERS:
201 case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS:
203 case PIPE_CAP_VERTEX_COLOR_UNCLAMPED:
204 case PIPE_CAP_VERTEX_COLOR_CLAMPED:
206 case PIPE_CAP_GLSL_FEATURE_LEVEL:
208 case PIPE_CAP_GLSL_FEATURE_LEVEL_COMPATIBILITY:
210 case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION:
212 case PIPE_CAP_COMPUTE:
214 case PIPE_CAP_USER_VERTEX_BUFFERS:
216 case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY:
217 case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY:
218 case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY:
219 case PIPE_CAP_TGSI_TEXCOORD:
221 case PIPE_CAP_DRAW_INDIRECT:
224 case PIPE_CAP_CUBE_MAP_ARRAY:
226 case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT:
228 case PIPE_CAP_TEXTURE_MULTISAMPLE:
230 case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
232 case PIPE_CAP_TEXTURE_BUFFER_OBJECTS:
234 case PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE:
236 case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT:
238 case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER:
240 case PIPE_CAP_MAX_VIEWPORTS:
241 return PIPE_MAX_VIEWPORTS;
242 case PIPE_CAP_ENDIANNESS:
243 return PIPE_ENDIAN_NATIVE;
244 case PIPE_CAP_TGSI_VS_LAYER_VIEWPORT:
246 case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
248 case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS:
250 case PIPE_CAP_TEXTURE_GATHER_SM5:
251 case PIPE_CAP_SAMPLE_SHADING:
252 case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
254 case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
256 case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
257 case PIPE_CAP_TGSI_TEX_TXF_LZ:
259 case PIPE_CAP_SAMPLER_VIEW_TARGET:
261 case PIPE_CAP_FAKE_SW_MSAA:
263 case PIPE_CAP_TEXTURE_QUERY_LOD:
264 case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
265 case PIPE_CAP_TGSI_ARRAY_COMPONENTS:
266 case PIPE_CAP_DOUBLES:
268 case PIPE_CAP_INT64_DIVMOD:
269 case PIPE_CAP_QUERY_SO_OVERFLOW:
272 case PIPE_CAP_VENDOR_ID:
274 case PIPE_CAP_DEVICE_ID:
276 case PIPE_CAP_ACCELERATED:
278 case PIPE_CAP_VIDEO_MEMORY: {
279 /* XXX: Do we want to return the full amount fo system memory ? */
280 uint64_t system_memory;
282 if (!os_get_total_physical_memory(&system_memory))
285 if (sizeof(void *) == 4)
286 /* Cap to 2 GB on 32 bits system. We do this because llvmpipe does
287 * eat application memory, which is quite limited on 32 bits. App
288 * shouldn't expect too much available memory. */
289 system_memory = MIN2(system_memory, 2048 << 20);
291 return (int)(system_memory >> 20);
295 case PIPE_CAP_CLIP_HALFZ:
297 case PIPE_CAP_VERTEXID_NOBASE:
299 case PIPE_CAP_POLYGON_OFFSET_CLAMP:
300 case PIPE_CAP_TEXTURE_FLOAT_LINEAR:
301 case PIPE_CAP_TEXTURE_HALF_FLOAT_LINEAR:
303 case PIPE_CAP_CULL_DISTANCE:
305 case PIPE_CAP_COPY_BETWEEN_COMPRESSED_AND_PLAIN_FORMATS:
307 case PIPE_CAP_CLEAR_TEXTURE:
309 case PIPE_CAP_MULTISAMPLE_Z_RESOLVE:
310 case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
311 case PIPE_CAP_DEVICE_RESET_STATUS_QUERY:
312 case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS:
313 case PIPE_CAP_DEPTH_BOUNDS_TEST:
314 case PIPE_CAP_TGSI_TXQS:
315 case PIPE_CAP_FORCE_PERSAMPLE_INTERP:
316 case PIPE_CAP_SHAREABLE_SHADERS:
317 case PIPE_CAP_DRAW_PARAMETERS:
318 case PIPE_CAP_TGSI_PACK_HALF_FLOAT:
319 case PIPE_CAP_MULTI_DRAW_INDIRECT:
320 case PIPE_CAP_MULTI_DRAW_INDIRECT_PARAMS:
321 case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL:
322 case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL:
323 case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT:
324 case PIPE_CAP_INVALIDATE_BUFFER:
325 case PIPE_CAP_GENERATE_MIPMAP:
326 case PIPE_CAP_STRING_MARKER:
327 case PIPE_CAP_BUFFER_SAMPLER_VIEW_RGBA_ONLY:
328 case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS:
329 case PIPE_CAP_QUERY_BUFFER_OBJECT:
330 case PIPE_CAP_QUERY_MEMORY_INFO:
331 case PIPE_CAP_PCI_GROUP:
332 case PIPE_CAP_PCI_BUS:
333 case PIPE_CAP_PCI_DEVICE:
334 case PIPE_CAP_PCI_FUNCTION:
335 case PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT:
336 case PIPE_CAP_ROBUST_BUFFER_ACCESS_BEHAVIOR:
337 case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES:
338 case PIPE_CAP_TGSI_VOTE:
339 case PIPE_CAP_MAX_WINDOW_RECTANGLES:
340 case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
341 case PIPE_CAP_VIEWPORT_SUBPIXEL_BITS:
342 case PIPE_CAP_TGSI_CAN_READ_OUTPUTS:
343 case PIPE_CAP_NATIVE_FENCE_FD:
344 case PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY:
345 case PIPE_CAP_TGSI_FS_FBFETCH:
346 case PIPE_CAP_TGSI_MUL_ZERO_WINS:
347 case PIPE_CAP_TGSI_CLOCK:
348 case PIPE_CAP_POLYGON_MODE_FILL_RECTANGLE:
349 case PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE:
350 case PIPE_CAP_TGSI_BALLOT:
351 case PIPE_CAP_TGSI_TES_LAYER_VIEWPORT:
352 case PIPE_CAP_CAN_BIND_CONST_BUFFER_AS_VERTEX:
353 case PIPE_CAP_ALLOW_MAPPED_BUFFERS_DURING_EXECUTION:
354 case PIPE_CAP_POST_DEPTH_COVERAGE:
355 case PIPE_CAP_BINDLESS_TEXTURE:
356 case PIPE_CAP_NIR_SAMPLERS_AS_DEREF:
357 case PIPE_CAP_MEMOBJ:
358 case PIPE_CAP_LOAD_CONSTBUF:
359 case PIPE_CAP_TGSI_ANY_REG_AS_ADDRESS:
360 case PIPE_CAP_TILE_RASTER_ORDER:
361 case PIPE_CAP_MAX_COMBINED_SHADER_OUTPUT_RESOURCES:
362 case PIPE_CAP_FRAMEBUFFER_MSAA_CONSTRAINTS:
363 case PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET:
364 case PIPE_CAP_CONTEXT_PRIORITY_MASK:
365 case PIPE_CAP_FENCE_SIGNAL:
366 case PIPE_CAP_CONSTBUF0_FLAGS:
367 case PIPE_CAP_PACKED_UNIFORMS:
368 case PIPE_CAP_CONSERVATIVE_RASTER_POST_SNAP_TRIANGLES:
369 case PIPE_CAP_CONSERVATIVE_RASTER_POST_SNAP_POINTS_LINES:
370 case PIPE_CAP_CONSERVATIVE_RASTER_PRE_SNAP_TRIANGLES:
371 case PIPE_CAP_CONSERVATIVE_RASTER_PRE_SNAP_POINTS_LINES:
372 case PIPE_CAP_CONSERVATIVE_RASTER_POST_DEPTH_COVERAGE:
373 case PIPE_CAP_MAX_CONSERVATIVE_RASTER_SUBPIXEL_PRECISION_BIAS:
374 case PIPE_CAP_PROGRAMMABLE_SAMPLE_LOCATIONS:
376 case PIPE_CAP_MAX_GS_INVOCATIONS:
379 /* should only get here on unhandled cases */
380 debug_printf("Unexpected PIPE_CAP %d query\n", param);
385 llvmpipe_get_shader_param(struct pipe_screen *screen,
386 enum pipe_shader_type shader,
387 enum pipe_shader_cap param)
391 case PIPE_SHADER_FRAGMENT:
394 return gallivm_get_shader_param(param);
396 case PIPE_SHADER_VERTEX:
397 case PIPE_SHADER_GEOMETRY:
399 case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
400 /* At this time, the draw module and llvmpipe driver only
401 * support vertex shader texture lookups when LLVM is enabled in
404 if (debug_get_bool_option("DRAW_USE_LLVM", TRUE))
405 return PIPE_MAX_SAMPLERS;
408 case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS:
409 if (debug_get_bool_option("DRAW_USE_LLVM", TRUE))
410 return PIPE_MAX_SHADER_SAMPLER_VIEWS;
414 return draw_get_shader_param(shader, param);
422 llvmpipe_get_paramf(struct pipe_screen *screen, enum pipe_capf param)
425 case PIPE_CAPF_MAX_LINE_WIDTH:
427 case PIPE_CAPF_MAX_LINE_WIDTH_AA:
428 return 255.0; /* arbitrary */
429 case PIPE_CAPF_MAX_POINT_WIDTH:
431 case PIPE_CAPF_MAX_POINT_WIDTH_AA:
432 return 255.0; /* arbitrary */
433 case PIPE_CAPF_MAX_TEXTURE_ANISOTROPY:
434 return 16.0; /* not actually signficant at this time */
435 case PIPE_CAPF_MAX_TEXTURE_LOD_BIAS:
436 return 16.0; /* arbitrary */
437 case PIPE_CAPF_MIN_CONSERVATIVE_RASTER_DILATE:
439 case PIPE_CAPF_MAX_CONSERVATIVE_RASTER_DILATE:
441 case PIPE_CAPF_CONSERVATIVE_RASTER_DILATE_GRANULARITY:
444 /* should only get here on unhandled cases */
445 debug_printf("Unexpected PIPE_CAP %d query\n", param);
451 * Query format support for creating a texture, drawing surface, etc.
452 * \param format the format to test
453 * \param type one of PIPE_TEXTURE, PIPE_SURFACE
456 llvmpipe_is_format_supported( struct pipe_screen *_screen,
457 enum pipe_format format,
458 enum pipe_texture_target target,
459 unsigned sample_count,
460 unsigned storage_sample_count,
463 struct llvmpipe_screen *screen = llvmpipe_screen(_screen);
464 struct sw_winsys *winsys = screen->winsys;
465 const struct util_format_description *format_desc;
467 format_desc = util_format_description(format);
471 assert(target == PIPE_BUFFER ||
472 target == PIPE_TEXTURE_1D ||
473 target == PIPE_TEXTURE_1D_ARRAY ||
474 target == PIPE_TEXTURE_2D ||
475 target == PIPE_TEXTURE_2D_ARRAY ||
476 target == PIPE_TEXTURE_RECT ||
477 target == PIPE_TEXTURE_3D ||
478 target == PIPE_TEXTURE_CUBE ||
479 target == PIPE_TEXTURE_CUBE_ARRAY);
481 if (sample_count > 1)
484 if (MAX2(1, sample_count) != MAX2(1, storage_sample_count))
487 if (bind & PIPE_BIND_RENDER_TARGET) {
488 if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) {
489 /* this is a lie actually other formats COULD exist where we would fail */
490 if (format_desc->nr_channels < 3)
493 else if (format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB)
496 if (format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN &&
497 format != PIPE_FORMAT_R11G11B10_FLOAT)
500 assert(format_desc->block.width == 1);
501 assert(format_desc->block.height == 1);
503 if (format_desc->is_mixed)
506 if (!format_desc->is_array && !format_desc->is_bitmask &&
507 format != PIPE_FORMAT_R11G11B10_FLOAT)
511 if ((bind & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW)) &&
512 ((bind & PIPE_BIND_DISPLAY_TARGET) == 0)) {
513 /* Disable all 3-channel formats, where channel size != 32 bits.
514 * In some cases we run into crashes (in generate_unswizzled_blend()),
515 * for 3-channel RGB16 variants, there was an apparent LLVM bug.
516 * In any case, disabling the shallower 3-channel formats avoids a
517 * number of issues with GL_ARB_copy_image support.
519 if (format_desc->is_array &&
520 format_desc->nr_channels == 3 &&
521 format_desc->block.bits != 96) {
526 if (bind & PIPE_BIND_DISPLAY_TARGET) {
527 if(!winsys->is_displaytarget_format_supported(winsys, bind, format))
531 if (bind & PIPE_BIND_DEPTH_STENCIL) {
532 if (format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN)
535 if (format_desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS)
538 /* TODO: Support stencil-only formats */
539 if (format_desc->swizzle[0] == PIPE_SWIZZLE_NONE) {
544 if (format_desc->layout == UTIL_FORMAT_LAYOUT_ASTC) {
545 /* Software decoding is not hooked up. */
549 if (format_desc->layout == UTIL_FORMAT_LAYOUT_ETC &&
550 format != PIPE_FORMAT_ETC1_RGB8)
554 * Everything can be supported by u_format
555 * (those without fetch_rgba_float might be not but shouldn't hit that)
565 llvmpipe_flush_frontbuffer(struct pipe_screen *_screen,
566 struct pipe_resource *resource,
567 unsigned level, unsigned layer,
568 void *context_private,
569 struct pipe_box *sub_box)
571 struct llvmpipe_screen *screen = llvmpipe_screen(_screen);
572 struct sw_winsys *winsys = screen->winsys;
573 struct llvmpipe_resource *texture = llvmpipe_resource(resource);
577 winsys->displaytarget_display(winsys, texture->dt, context_private, sub_box);
581 llvmpipe_destroy_screen( struct pipe_screen *_screen )
583 struct llvmpipe_screen *screen = llvmpipe_screen(_screen);
584 struct sw_winsys *winsys = screen->winsys;
587 lp_rast_destroy(screen->rast);
589 lp_jit_screen_cleanup(screen);
592 winsys->destroy(winsys);
594 mtx_destroy(&screen->rast_mutex);
603 * Fence reference counting.
606 llvmpipe_fence_reference(struct pipe_screen *screen,
607 struct pipe_fence_handle **ptr,
608 struct pipe_fence_handle *fence)
610 struct lp_fence **old = (struct lp_fence **) ptr;
611 struct lp_fence *f = (struct lp_fence *) fence;
613 lp_fence_reference(old, f);
618 * Wait for the fence to finish.
621 llvmpipe_fence_finish(struct pipe_screen *screen,
622 struct pipe_context *ctx,
623 struct pipe_fence_handle *fence_handle,
626 struct lp_fence *f = (struct lp_fence *) fence_handle;
629 return lp_fence_signalled(f);
636 llvmpipe_get_timestamp(struct pipe_screen *_screen)
638 return os_time_get_nano();
642 * Create a new pipe_screen object
643 * Note: we're not presently subclassing pipe_screen (no llvmpipe_screen).
646 llvmpipe_create_screen(struct sw_winsys *winsys)
648 struct llvmpipe_screen *screen;
653 LP_DEBUG = debug_get_flags_option("LP_DEBUG", lp_debug_flags, 0 );
656 LP_PERF = debug_get_flags_option("LP_PERF", lp_perf_flags, 0 );
658 screen = CALLOC_STRUCT(llvmpipe_screen);
662 if (!lp_jit_screen_init(screen)) {
667 screen->winsys = winsys;
669 screen->base.destroy = llvmpipe_destroy_screen;
671 screen->base.get_name = llvmpipe_get_name;
672 screen->base.get_vendor = llvmpipe_get_vendor;
673 screen->base.get_device_vendor = llvmpipe_get_vendor; // TODO should be the CPU vendor
674 screen->base.get_param = llvmpipe_get_param;
675 screen->base.get_shader_param = llvmpipe_get_shader_param;
676 screen->base.get_paramf = llvmpipe_get_paramf;
677 screen->base.is_format_supported = llvmpipe_is_format_supported;
679 screen->base.context_create = llvmpipe_create_context;
680 screen->base.flush_frontbuffer = llvmpipe_flush_frontbuffer;
681 screen->base.fence_reference = llvmpipe_fence_reference;
682 screen->base.fence_finish = llvmpipe_fence_finish;
684 screen->base.get_timestamp = llvmpipe_get_timestamp;
686 llvmpipe_init_screen_resource_funcs(&screen->base);
688 screen->num_threads = util_cpu_caps.nr_cpus > 1 ? util_cpu_caps.nr_cpus : 0;
689 #ifdef PIPE_SUBSYSTEM_EMBEDDED
690 screen->num_threads = 0;
692 screen->num_threads = debug_get_num_option("LP_NUM_THREADS", screen->num_threads);
693 screen->num_threads = MIN2(screen->num_threads, LP_MAX_THREADS);
695 screen->rast = lp_rast_create(screen->num_threads);
697 lp_jit_screen_cleanup(screen);
701 (void) mtx_init(&screen->rast_mutex, mtx_plain);
703 return &screen->base;