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