1 /**************************************************************************
2 *
3 * Copyright 2008 VMware, Inc.
4 * All Rights Reserved.
5 *
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:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
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.
25 *
26 **************************************************************************/
27
28
29 #include "compiler/nir/nir.h"
30 #include "util/u_memory.h"
31 #include "util/format/u_format.h"
32 #include "util/format/u_format_s3tc.h"
33 #include "util/u_screen.h"
34 #include "util/u_video.h"
35 #include "util/os_misc.h"
36 #include "util/os_time.h"
37 #include "pipe/p_defines.h"
38 #include "pipe/p_screen.h"
39 #include "draw/draw_context.h"
40
41 #include "frontend/sw_winsys.h"
42 #include "tgsi/tgsi_exec.h"
43
44 #include "sp_texture.h"
45 #include "sp_screen.h"
46 #include "sp_context.h"
47 #include "sp_fence.h"
48 #include "sp_public.h"
49
50 static const struct debug_named_value sp_debug_options[] = {
51 {"vs", SP_DBG_VS, "dump vertex shader assembly to stderr"},
52 {"gs", SP_DBG_GS, "dump geometry shader assembly to stderr"},
53 {"fs", SP_DBG_FS, "dump fragment shader assembly to stderr"},
54 {"cs", SP_DBG_CS, "dump compute shader assembly to stderr"},
55 {"no_rast", SP_DBG_NO_RAST, "no-ops rasterization, for profiling purposes"},
56 {"use_llvm", SP_DBG_USE_LLVM, "Use LLVM if available for shaders"},
57 {"use_tgsi", SP_DBG_USE_TGSI, "Request TGSI from the API instead of NIR"},
58 };
59
60 int sp_debug;
61 DEBUG_GET_ONCE_FLAGS_OPTION(sp_debug, "SOFTPIPE_DEBUG", sp_debug_options, 0)
62
63 static const char *
softpipe_get_vendor(struct pipe_screen * screen)64 softpipe_get_vendor(struct pipe_screen *screen)
65 {
66 return "Mesa/X.org";
67 }
68
69
70 static const char *
softpipe_get_name(struct pipe_screen * screen)71 softpipe_get_name(struct pipe_screen *screen)
72 {
73 return "softpipe";
74 }
75
76 static const nir_shader_compiler_options sp_compiler_options = {
77 .fuse_ffma32 = true,
78 .fuse_ffma64 = true,
79 .lower_extract_byte = true,
80 .lower_extract_word = true,
81 .lower_fdph = true,
82 .lower_flrp64 = true,
83 .lower_fmod = true,
84 .lower_rotate = true,
85 .lower_sub = true,
86 .lower_vector_cmp = true,
87 .use_interpolated_input_intrinsics = true,
88 };
89
90 static const void *
softpipe_get_compiler_options(struct pipe_screen * pscreen,enum pipe_shader_ir ir,enum pipe_shader_type shader)91 softpipe_get_compiler_options(struct pipe_screen *pscreen,
92 enum pipe_shader_ir ir,
93 enum pipe_shader_type shader)
94 {
95 assert(ir == PIPE_SHADER_IR_NIR);
96 return &sp_compiler_options;
97 }
98
99 static int
softpipe_get_param(struct pipe_screen * screen,enum pipe_cap param)100 softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
101 {
102 struct softpipe_screen *sp_screen = softpipe_screen(screen);
103 switch (param) {
104 case PIPE_CAP_NPOT_TEXTURES:
105 case PIPE_CAP_MIXED_FRAMEBUFFER_SIZES:
106 case PIPE_CAP_MIXED_COLOR_DEPTH_BITS:
107 return 1;
108 case PIPE_CAP_FRAGMENT_SHADER_TEXTURE_LOD:
109 case PIPE_CAP_FRAGMENT_SHADER_DERIVATIVES:
110 case PIPE_CAP_VERTEX_SHADER_SATURATE:
111 return 1;
112 case PIPE_CAP_ANISOTROPIC_FILTER:
113 return 1;
114 case PIPE_CAP_POINT_SPRITE:
115 return 1;
116 case PIPE_CAP_MAX_RENDER_TARGETS:
117 return PIPE_MAX_COLOR_BUFS;
118 case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS:
119 return 1;
120 case PIPE_CAP_OCCLUSION_QUERY:
121 return 1;
122 case PIPE_CAP_QUERY_TIME_ELAPSED:
123 return 1;
124 case PIPE_CAP_QUERY_PIPELINE_STATISTICS:
125 return 1;
126 case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
127 case PIPE_CAP_TEXTURE_MIRROR_CLAMP_TO_EDGE:
128 return 1;
129 case PIPE_CAP_TEXTURE_SWIZZLE:
130 return 1;
131 case PIPE_CAP_MAX_TEXTURE_2D_SIZE:
132 return 1 << (SP_MAX_TEXTURE_2D_LEVELS - 1);
133 case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
134 return SP_MAX_TEXTURE_3D_LEVELS;
135 case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
136 return SP_MAX_TEXTURE_CUBE_LEVELS;
137 case PIPE_CAP_BLEND_EQUATION_SEPARATE:
138 return 1;
139 case PIPE_CAP_INDEP_BLEND_ENABLE:
140 return 1;
141 case PIPE_CAP_INDEP_BLEND_FUNC:
142 return 1;
143 case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT:
144 case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:
145 case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
146 case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
147 return 1;
148 case PIPE_CAP_DEPTH_CLIP_DISABLE:
149 return 1;
150 case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS:
151 return PIPE_MAX_SO_BUFFERS;
152 case PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS:
153 case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS:
154 return 16*4;
155 case PIPE_CAP_MAX_GEOMETRY_OUTPUT_VERTICES:
156 case PIPE_CAP_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS:
157 return 1024;
158 case PIPE_CAP_MAX_VERTEX_STREAMS:
159 if (sp_screen->use_llvm)
160 return 1;
161 else
162 return PIPE_MAX_VERTEX_STREAMS;
163 case PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE:
164 return 2048;
165 case PIPE_CAP_PRIMITIVE_RESTART:
166 case PIPE_CAP_PRIMITIVE_RESTART_FIXED_INDEX:
167 return 1;
168 case PIPE_CAP_SHADER_STENCIL_EXPORT:
169 return 1;
170 case PIPE_CAP_TGSI_ATOMFADD:
171 case PIPE_CAP_TGSI_INSTANCEID:
172 case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR:
173 case PIPE_CAP_START_INSTANCE:
174 return 1;
175 case PIPE_CAP_SEAMLESS_CUBE_MAP:
176 case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE:
177 return 1;
178 case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS:
179 return 256; /* for GL3 */
180 case PIPE_CAP_MIN_TEXEL_OFFSET:
181 return -8;
182 case PIPE_CAP_MAX_TEXEL_OFFSET:
183 return 7;
184 case PIPE_CAP_CONDITIONAL_RENDER:
185 case PIPE_CAP_FRAGMENT_COLOR_CLAMPED:
186 case PIPE_CAP_VERTEX_COLOR_UNCLAMPED: /* draw module */
187 case PIPE_CAP_VERTEX_COLOR_CLAMPED: /* draw module */
188 return 1;
189 case PIPE_CAP_MIXED_COLORBUFFER_FORMATS:
190 return 1;
191 case PIPE_CAP_GLSL_FEATURE_LEVEL:
192 return 400;
193 case PIPE_CAP_GLSL_FEATURE_LEVEL_COMPATIBILITY:
194 return 140;
195 case PIPE_CAP_COMPUTE:
196 return 1;
197 case PIPE_CAP_USER_VERTEX_BUFFERS:
198 case PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME:
199 case PIPE_CAP_STREAM_OUTPUT_INTERLEAVE_BUFFERS:
200 case PIPE_CAP_TGSI_VS_LAYER_VIEWPORT:
201 case PIPE_CAP_DOUBLES:
202 case PIPE_CAP_INT64:
203 case PIPE_CAP_INT64_DIVMOD:
204 case PIPE_CAP_TGSI_DIV:
205 return 1;
206 case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT:
207 return 16;
208 case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
209 return 64;
210 case PIPE_CAP_QUERY_TIMESTAMP:
211 case PIPE_CAP_CUBE_MAP_ARRAY:
212 return 1;
213 case PIPE_CAP_TEXTURE_BUFFER_OBJECTS:
214 return 1;
215 case PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE:
216 return 65536;
217 case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT:
218 return 16;
219 case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER:
220 return 0;
221 case PIPE_CAP_MAX_VIEWPORTS:
222 return PIPE_MAX_VIEWPORTS;
223 case PIPE_CAP_ENDIANNESS:
224 return PIPE_ENDIAN_NATIVE;
225 case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS:
226 return 4;
227 case PIPE_CAP_TEXTURE_GATHER_SM5:
228 case PIPE_CAP_TEXTURE_QUERY_LOD:
229 return 1;
230 case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
231 return 1;
232 case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
233 return 1;
234 case PIPE_CAP_SAMPLER_VIEW_TARGET:
235 return 1;
236 case PIPE_CAP_FAKE_SW_MSAA:
237 return 1;
238 case PIPE_CAP_MIN_TEXTURE_GATHER_OFFSET:
239 return -32;
240 case PIPE_CAP_MAX_TEXTURE_GATHER_OFFSET:
241 return 31;
242 case PIPE_CAP_DRAW_INDIRECT:
243 return 1;
244 case PIPE_CAP_QUERY_SO_OVERFLOW:
245 return 1;
246 case PIPE_CAP_NIR_IMAGES_AS_DEREF:
247 return 0;
248
249 case PIPE_CAP_VENDOR_ID:
250 return 0xFFFFFFFF;
251 case PIPE_CAP_DEVICE_ID:
252 return 0xFFFFFFFF;
253 case PIPE_CAP_ACCELERATED:
254 return 0;
255 case PIPE_CAP_VIDEO_MEMORY: {
256 /* XXX: Do we want to return the full amount fo system memory ? */
257 uint64_t system_memory;
258
259 if (!os_get_total_physical_memory(&system_memory))
260 return 0;
261
262 if (sizeof(void *) == 4)
263 /* Cap to 2 GB on 32 bits system. We do this because softpipe does
264 * eat application memory, which is quite limited on 32 bits. App
265 * shouldn't expect too much available memory. */
266 system_memory = MIN2(system_memory, 2048 << 20);
267
268 return (int)(system_memory >> 20);
269 }
270 case PIPE_CAP_UMA:
271 return 0;
272 case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
273 return 1;
274 case PIPE_CAP_CLIP_HALFZ:
275 case PIPE_CAP_TEXTURE_FLOAT_LINEAR:
276 case PIPE_CAP_TEXTURE_HALF_FLOAT_LINEAR:
277 return 1;
278 case PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT:
279 case PIPE_CAP_CULL_DISTANCE:
280 case PIPE_CAP_COPY_BETWEEN_COMPRESSED_AND_PLAIN_FORMATS:
281 case PIPE_CAP_TGSI_ARRAY_COMPONENTS:
282 case PIPE_CAP_TGSI_TEXCOORD:
283 case PIPE_CAP_TGSI_ANY_REG_AS_ADDRESS:
284 return 1;
285 case PIPE_CAP_CLEAR_TEXTURE:
286 return 1;
287 case PIPE_CAP_MAX_VARYINGS:
288 return TGSI_EXEC_MAX_INPUT_ATTRIBS;
289 case PIPE_CAP_PCI_GROUP:
290 case PIPE_CAP_PCI_BUS:
291 case PIPE_CAP_PCI_DEVICE:
292 case PIPE_CAP_PCI_FUNCTION:
293 return 0;
294 case PIPE_CAP_MAX_GS_INVOCATIONS:
295 return 32;
296 case PIPE_CAP_MAX_SHADER_BUFFER_SIZE:
297 return 1 << 27;
298 case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT:
299 return 4;
300 default:
301 return u_pipe_screen_get_param_defaults(screen, param);
302 }
303 }
304
305 static int
softpipe_get_shader_param(struct pipe_screen * screen,enum pipe_shader_type shader,enum pipe_shader_cap param)306 softpipe_get_shader_param(struct pipe_screen *screen,
307 enum pipe_shader_type shader,
308 enum pipe_shader_cap param)
309 {
310 struct softpipe_screen *sp_screen = softpipe_screen(screen);
311
312 switch (param) {
313 case PIPE_SHADER_CAP_PREFERRED_IR:
314 return (sp_debug & SP_DBG_USE_TGSI) ? PIPE_SHADER_IR_TGSI : PIPE_SHADER_IR_NIR;
315 case PIPE_SHADER_CAP_SUPPORTED_IRS:
316 return (1 << PIPE_SHADER_IR_NIR) | (1 << PIPE_SHADER_IR_TGSI);
317 default:
318 break;
319 }
320
321 switch(shader)
322 {
323 case PIPE_SHADER_FRAGMENT:
324 return tgsi_exec_get_shader_param(param);
325 case PIPE_SHADER_COMPUTE:
326 return tgsi_exec_get_shader_param(param);
327 case PIPE_SHADER_VERTEX:
328 case PIPE_SHADER_GEOMETRY:
329 if (sp_screen->use_llvm)
330 return draw_get_shader_param(shader, param);
331 else
332 return draw_get_shader_param_no_llvm(shader, param);
333 default:
334 return 0;
335 }
336 }
337
338 static float
softpipe_get_paramf(struct pipe_screen * screen,enum pipe_capf param)339 softpipe_get_paramf(struct pipe_screen *screen, enum pipe_capf param)
340 {
341 switch (param) {
342 case PIPE_CAPF_MAX_LINE_WIDTH:
343 /* fall-through */
344 case PIPE_CAPF_MAX_LINE_WIDTH_AA:
345 return 255.0; /* arbitrary */
346 case PIPE_CAPF_MAX_POINT_WIDTH:
347 /* fall-through */
348 case PIPE_CAPF_MAX_POINT_WIDTH_AA:
349 return 255.0; /* arbitrary */
350 case PIPE_CAPF_MAX_TEXTURE_ANISOTROPY:
351 return 16.0;
352 case PIPE_CAPF_MAX_TEXTURE_LOD_BIAS:
353 return 16.0; /* arbitrary */
354 case PIPE_CAPF_MIN_CONSERVATIVE_RASTER_DILATE:
355 return 0.0;
356 case PIPE_CAPF_MAX_CONSERVATIVE_RASTER_DILATE:
357 return 0.0;
358 case PIPE_CAPF_CONSERVATIVE_RASTER_DILATE_GRANULARITY:
359 return 0.0;
360 }
361 /* should only get here on unhandled cases */
362 debug_printf("Unexpected PIPE_CAPF %d query\n", param);
363 return 0.0;
364 }
365
366 /**
367 * Query format support for creating a texture, drawing surface, etc.
368 * \param format the format to test
369 * \param type one of PIPE_TEXTURE, PIPE_SURFACE
370 */
371 static bool
softpipe_is_format_supported(struct pipe_screen * screen,enum pipe_format format,enum pipe_texture_target target,unsigned sample_count,unsigned storage_sample_count,unsigned bind)372 softpipe_is_format_supported( struct pipe_screen *screen,
373 enum pipe_format format,
374 enum pipe_texture_target target,
375 unsigned sample_count,
376 unsigned storage_sample_count,
377 unsigned bind)
378 {
379 struct sw_winsys *winsys = softpipe_screen(screen)->winsys;
380 const struct util_format_description *format_desc;
381
382 assert(target == PIPE_BUFFER ||
383 target == PIPE_TEXTURE_1D ||
384 target == PIPE_TEXTURE_1D_ARRAY ||
385 target == PIPE_TEXTURE_2D ||
386 target == PIPE_TEXTURE_2D_ARRAY ||
387 target == PIPE_TEXTURE_RECT ||
388 target == PIPE_TEXTURE_3D ||
389 target == PIPE_TEXTURE_CUBE ||
390 target == PIPE_TEXTURE_CUBE_ARRAY);
391
392 if (MAX2(1, sample_count) != MAX2(1, storage_sample_count))
393 return false;
394
395 format_desc = util_format_description(format);
396 if (!format_desc)
397 return false;
398
399 if (sample_count > 1)
400 return false;
401
402 if (bind & (PIPE_BIND_DISPLAY_TARGET |
403 PIPE_BIND_SCANOUT |
404 PIPE_BIND_SHARED)) {
405 if(!winsys->is_displaytarget_format_supported(winsys, bind, format))
406 return false;
407 }
408
409 if (bind & PIPE_BIND_RENDER_TARGET) {
410 if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS)
411 return false;
412
413 /*
414 * Although possible, it is unnatural to render into compressed or YUV
415 * surfaces. So disable these here to avoid going into weird paths
416 * inside gallium frontends.
417 */
418 if (format_desc->block.width != 1 ||
419 format_desc->block.height != 1)
420 return false;
421 }
422
423 if (bind & PIPE_BIND_DEPTH_STENCIL) {
424 if (format_desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS)
425 return false;
426 }
427
428 if (format_desc->layout == UTIL_FORMAT_LAYOUT_ASTC ||
429 format_desc->layout == UTIL_FORMAT_LAYOUT_ATC) {
430 /* Software decoding is not hooked up. */
431 return false;
432 }
433
434 if ((bind & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW)) &&
435 ((bind & PIPE_BIND_DISPLAY_TARGET) == 0) &&
436 target != PIPE_BUFFER) {
437 const struct util_format_description *desc =
438 util_format_description(format);
439 if (desc->nr_channels == 3 && desc->is_array) {
440 /* Don't support any 3-component formats for rendering/texturing
441 * since we don't support the corresponding 8-bit 3 channel UNORM
442 * formats. This allows us to support GL_ARB_copy_image between
443 * GL_RGB8 and GL_RGB8UI, for example. Otherwise, we may be asked to
444 * do a resource copy between PIPE_FORMAT_R8G8B8_UINT and
445 * PIPE_FORMAT_R8G8B8X8_UNORM, for example, which will not work
446 * (different bpp).
447 */
448 return false;
449 }
450 }
451
452 if (format_desc->layout == UTIL_FORMAT_LAYOUT_ETC &&
453 format != PIPE_FORMAT_ETC1_RGB8)
454 return false;
455
456 /*
457 * All other operations (sampling, transfer, etc).
458 */
459
460 /*
461 * Everything else should be supported by u_format.
462 */
463 return true;
464 }
465
466
467 static void
softpipe_destroy_screen(struct pipe_screen * screen)468 softpipe_destroy_screen( struct pipe_screen *screen )
469 {
470 struct softpipe_screen *sp_screen = softpipe_screen(screen);
471 struct sw_winsys *winsys = sp_screen->winsys;
472
473 if(winsys->destroy)
474 winsys->destroy(winsys);
475
476 FREE(screen);
477 }
478
479
480 /* This is often overriden by the co-state tracker.
481 */
482 static void
softpipe_flush_frontbuffer(struct pipe_screen * _screen,struct pipe_resource * resource,unsigned level,unsigned layer,void * context_private,struct pipe_box * sub_box)483 softpipe_flush_frontbuffer(struct pipe_screen *_screen,
484 struct pipe_resource *resource,
485 unsigned level, unsigned layer,
486 void *context_private,
487 struct pipe_box *sub_box)
488 {
489 struct softpipe_screen *screen = softpipe_screen(_screen);
490 struct sw_winsys *winsys = screen->winsys;
491 struct softpipe_resource *texture = softpipe_resource(resource);
492
493 assert(texture->dt);
494 if (texture->dt)
495 winsys->displaytarget_display(winsys, texture->dt, context_private, sub_box);
496 }
497
498 static uint64_t
softpipe_get_timestamp(struct pipe_screen * _screen)499 softpipe_get_timestamp(struct pipe_screen *_screen)
500 {
501 return os_time_get_nano();
502 }
503
504 static int
softpipe_get_compute_param(struct pipe_screen * _screen,enum pipe_shader_ir ir_type,enum pipe_compute_cap param,void * ret)505 softpipe_get_compute_param(struct pipe_screen *_screen,
506 enum pipe_shader_ir ir_type,
507 enum pipe_compute_cap param,
508 void *ret)
509 {
510 switch (param) {
511 case PIPE_COMPUTE_CAP_IR_TARGET:
512 return 0;
513 case PIPE_COMPUTE_CAP_MAX_GRID_SIZE:
514 if (ret) {
515 uint64_t *grid_size = ret;
516 grid_size[0] = 65535;
517 grid_size[1] = 65535;
518 grid_size[2] = 65535;
519 }
520 return 3 * sizeof(uint64_t) ;
521 case PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE:
522 if (ret) {
523 uint64_t *block_size = ret;
524 block_size[0] = 1024;
525 block_size[1] = 1024;
526 block_size[2] = 1024;
527 }
528 return 3 * sizeof(uint64_t);
529 case PIPE_COMPUTE_CAP_MAX_THREADS_PER_BLOCK:
530 if (ret) {
531 uint64_t *max_threads_per_block = ret;
532 *max_threads_per_block = 1024;
533 }
534 return sizeof(uint64_t);
535 case PIPE_COMPUTE_CAP_MAX_LOCAL_SIZE:
536 if (ret) {
537 uint64_t *max_local_size = ret;
538 *max_local_size = 32768;
539 }
540 return sizeof(uint64_t);
541 case PIPE_COMPUTE_CAP_GRID_DIMENSION:
542 case PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE:
543 case PIPE_COMPUTE_CAP_MAX_PRIVATE_SIZE:
544 case PIPE_COMPUTE_CAP_MAX_INPUT_SIZE:
545 case PIPE_COMPUTE_CAP_MAX_MEM_ALLOC_SIZE:
546 case PIPE_COMPUTE_CAP_MAX_CLOCK_FREQUENCY:
547 case PIPE_COMPUTE_CAP_MAX_COMPUTE_UNITS:
548 case PIPE_COMPUTE_CAP_IMAGES_SUPPORTED:
549 case PIPE_COMPUTE_CAP_SUBGROUP_SIZE:
550 case PIPE_COMPUTE_CAP_ADDRESS_BITS:
551 case PIPE_COMPUTE_CAP_MAX_VARIABLE_THREADS_PER_BLOCK:
552 break;
553 }
554 return 0;
555 }
556
557 /**
558 * Create a new pipe_screen object
559 * Note: we're not presently subclassing pipe_screen (no softpipe_screen).
560 */
561 struct pipe_screen *
softpipe_create_screen(struct sw_winsys * winsys)562 softpipe_create_screen(struct sw_winsys *winsys)
563 {
564 struct softpipe_screen *screen = CALLOC_STRUCT(softpipe_screen);
565
566 if (!screen)
567 return NULL;
568
569 sp_debug = debug_get_option_sp_debug();
570
571 screen->winsys = winsys;
572
573 screen->base.destroy = softpipe_destroy_screen;
574
575 screen->base.get_name = softpipe_get_name;
576 screen->base.get_vendor = softpipe_get_vendor;
577 screen->base.get_device_vendor = softpipe_get_vendor; // TODO should be the CPU vendor
578 screen->base.get_param = softpipe_get_param;
579 screen->base.get_shader_param = softpipe_get_shader_param;
580 screen->base.get_paramf = softpipe_get_paramf;
581 screen->base.get_timestamp = softpipe_get_timestamp;
582 screen->base.is_format_supported = softpipe_is_format_supported;
583 screen->base.context_create = softpipe_create_context;
584 screen->base.flush_frontbuffer = softpipe_flush_frontbuffer;
585 screen->base.get_compute_param = softpipe_get_compute_param;
586 screen->base.get_compiler_options = softpipe_get_compiler_options;
587 screen->use_llvm = sp_debug & SP_DBG_USE_LLVM;
588
589 softpipe_init_screen_texture_funcs(&screen->base);
590 softpipe_init_screen_fence_funcs(&screen->base);
591
592 return &screen->base;
593 }
594