1 /* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
4 * Copyright (C) 2012 Rob Clark <robclark@freedesktop.org>
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 * Rob Clark <robclark@freedesktop.org>
30 #include "pipe/p_defines.h"
31 #include "pipe/p_screen.h"
32 #include "pipe/p_state.h"
34 #include "util/u_memory.h"
35 #include "util/u_inlines.h"
36 #include "util/u_format.h"
37 #include "util/u_format_s3tc.h"
38 #include "util/u_string.h"
39 #include "util/u_debug.h"
41 #include "os/os_time.h"
47 #include "freedreno_screen.h"
48 #include "freedreno_resource.h"
49 #include "freedreno_fence.h"
50 #include "freedreno_query.h"
51 #include "freedreno_util.h"
53 #include "a2xx/fd2_screen.h"
54 #include "a3xx/fd3_screen.h"
55 #include "a4xx/fd4_screen.h"
56 #include "a5xx/fd5_screen.h"
58 #include "ir3/ir3_nir.h"
60 /* XXX this should go away */
61 #include "state_tracker/drm_driver.h"
63 static const struct debug_named_value debug_options
[] = {
64 {"msgs", FD_DBG_MSGS
, "Print debug messages"},
65 {"disasm", FD_DBG_DISASM
, "Dump TGSI and adreno shader disassembly"},
66 {"dclear", FD_DBG_DCLEAR
, "Mark all state dirty after clear"},
67 {"ddraw", FD_DBG_DDRAW
, "Mark all state dirty after draw"},
68 {"noscis", FD_DBG_NOSCIS
, "Disable scissor optimization"},
69 {"direct", FD_DBG_DIRECT
, "Force inline (SS_DIRECT) state loads"},
70 {"nobypass", FD_DBG_NOBYPASS
, "Disable GMEM bypass"},
71 {"fraghalf", FD_DBG_FRAGHALF
, "Use half-precision in fragment shader"},
72 {"nobin", FD_DBG_NOBIN
, "Disable hw binning"},
73 {"optmsgs", FD_DBG_OPTMSGS
,"Enable optimizer debug messages"},
74 {"glsl120", FD_DBG_GLSL120
,"Temporary flag to force GLSL 1.20 (rather than 1.30) on a3xx+"},
75 {"shaderdb", FD_DBG_SHADERDB
, "Enable shaderdb output"},
76 {"flush", FD_DBG_FLUSH
, "Force flush after every draw"},
77 {"deqp", FD_DBG_DEQP
, "Enable dEQP hacks"},
78 {"nir", FD_DBG_NIR
, "Prefer NIR as native IR"},
79 {"inorder", FD_DBG_INORDER
,"Disable reordering for draws/blits"},
80 {"bstat", FD_DBG_BSTAT
, "Print batch stats at context destroy"},
81 {"nogrow", FD_DBG_NOGROW
, "Disable \"growable\" cmdstream buffers, even if kernel supports it"},
85 DEBUG_GET_ONCE_FLAGS_OPTION(fd_mesa_debug
, "FD_MESA_DEBUG", debug_options
, 0)
87 int fd_mesa_debug
= 0;
88 bool fd_binning_enabled
= true;
89 static bool glsl120
= false;
92 fd_screen_get_name(struct pipe_screen
*pscreen
)
94 static char buffer
[128];
95 util_snprintf(buffer
, sizeof(buffer
), "FD%03d",
96 fd_screen(pscreen
)->device_id
);
101 fd_screen_get_vendor(struct pipe_screen
*pscreen
)
107 fd_screen_get_device_vendor(struct pipe_screen
*pscreen
)
114 fd_screen_get_timestamp(struct pipe_screen
*pscreen
)
116 struct fd_screen
*screen
= fd_screen(pscreen
);
118 if (screen
->has_timestamp
) {
120 fd_pipe_get_param(screen
->pipe
, FD_TIMESTAMP
, &n
);
121 debug_assert(screen
->max_freq
> 0);
122 return n
* 1000000000 / screen
->max_freq
;
124 int64_t cpu_time
= os_time_get() * 1000;
125 return cpu_time
+ screen
->cpu_gpu_time_delta
;
131 fd_screen_destroy(struct pipe_screen
*pscreen
)
133 struct fd_screen
*screen
= fd_screen(pscreen
);
136 fd_pipe_del(screen
->pipe
);
139 fd_device_del(screen
->dev
);
141 fd_bc_fini(&screen
->batch_cache
);
143 slab_destroy_parent(&screen
->transfer_pool
);
145 mtx_destroy(&screen
->lock
);
147 ralloc_free(screen
->compiler
);
153 TODO either move caps to a2xx/a3xx specific code, or maybe have some
154 tables for things that differ if the delta is not too much..
157 fd_screen_get_param(struct pipe_screen
*pscreen
, enum pipe_cap param
)
159 struct fd_screen
*screen
= fd_screen(pscreen
);
161 /* this is probably not totally correct.. but it's a start: */
163 /* Supported features (boolean caps). */
164 case PIPE_CAP_NPOT_TEXTURES
:
165 case PIPE_CAP_MIXED_FRAMEBUFFER_SIZES
:
166 case PIPE_CAP_TWO_SIDED_STENCIL
:
167 case PIPE_CAP_ANISOTROPIC_FILTER
:
168 case PIPE_CAP_POINT_SPRITE
:
169 case PIPE_CAP_TEXTURE_SHADOW_MAP
:
170 case PIPE_CAP_BLEND_EQUATION_SEPARATE
:
171 case PIPE_CAP_TEXTURE_SWIZZLE
:
172 case PIPE_CAP_MIXED_COLORBUFFER_FORMATS
:
173 case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT
:
174 case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER
:
175 case PIPE_CAP_SEAMLESS_CUBE_MAP
:
176 case PIPE_CAP_VERTEX_COLOR_UNCLAMPED
:
177 case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION
:
178 case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY
:
179 case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY
:
180 case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY
:
181 case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT
:
182 case PIPE_CAP_STRING_MARKER
:
183 case PIPE_CAP_MIXED_COLOR_DEPTH_BITS
:
186 case PIPE_CAP_VERTEXID_NOBASE
:
187 return is_a3xx(screen
) || is_a4xx(screen
);
189 case PIPE_CAP_USER_CONSTANT_BUFFERS
:
190 return is_a4xx(screen
) ? 0 : 1;
192 case PIPE_CAP_SHADER_STENCIL_EXPORT
:
193 case PIPE_CAP_TGSI_TEXCOORD
:
194 case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER
:
195 case PIPE_CAP_TEXTURE_MULTISAMPLE
:
196 case PIPE_CAP_TEXTURE_BARRIER
:
197 case PIPE_CAP_TEXTURE_MIRROR_CLAMP
:
198 case PIPE_CAP_COMPUTE
:
199 case PIPE_CAP_QUERY_MEMORY_INFO
:
200 case PIPE_CAP_PCI_GROUP
:
201 case PIPE_CAP_PCI_BUS
:
202 case PIPE_CAP_PCI_DEVICE
:
203 case PIPE_CAP_PCI_FUNCTION
:
207 case PIPE_CAP_PRIMITIVE_RESTART
:
208 case PIPE_CAP_TGSI_INSTANCEID
:
209 case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR
:
210 case PIPE_CAP_INDEP_BLEND_ENABLE
:
211 case PIPE_CAP_INDEP_BLEND_FUNC
:
212 case PIPE_CAP_TEXTURE_BUFFER_OBJECTS
:
213 case PIPE_CAP_TEXTURE_HALF_FLOAT_LINEAR
:
214 case PIPE_CAP_CONDITIONAL_RENDER
:
215 case PIPE_CAP_CONDITIONAL_RENDER_INVERTED
:
216 case PIPE_CAP_FAKE_SW_MSAA
:
217 case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE
:
218 case PIPE_CAP_DEPTH_CLIP_DISABLE
:
219 case PIPE_CAP_CLIP_HALFZ
:
220 return is_a3xx(screen
) || is_a4xx(screen
) || is_a5xx(screen
);
222 case PIPE_CAP_BUFFER_SAMPLER_VIEW_RGBA_ONLY
:
224 case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT
:
225 if (is_a3xx(screen
)) return 16;
226 if (is_a4xx(screen
)) return 32;
227 if (is_a5xx(screen
)) return 32;
229 case PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE
:
230 /* We could possibly emulate more by pretending 2d/rect textures and
231 * splitting high bits of index into 2nd dimension..
233 if (is_a3xx(screen
)) return 8192;
234 if (is_a4xx(screen
)) return 16384;
235 if (is_a5xx(screen
)) return 16384;
238 case PIPE_CAP_TEXTURE_FLOAT_LINEAR
:
239 case PIPE_CAP_CUBE_MAP_ARRAY
:
240 case PIPE_CAP_START_INSTANCE
:
241 case PIPE_CAP_SAMPLER_VIEW_TARGET
:
242 case PIPE_CAP_TEXTURE_QUERY_LOD
:
243 return is_a4xx(screen
) || is_a5xx(screen
);
245 case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT
:
248 case PIPE_CAP_GLSL_FEATURE_LEVEL
:
251 return is_ir3(screen
) ? 140 : 120;
253 case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT
:
258 /* Unsupported features. */
259 case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT
:
260 case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER
:
261 case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS
:
262 case PIPE_CAP_USER_VERTEX_BUFFERS
:
263 case PIPE_CAP_QUERY_PIPELINE_STATISTICS
:
264 case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK
:
265 case PIPE_CAP_TGSI_VS_LAYER_VIEWPORT
:
266 case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS
:
267 case PIPE_CAP_TEXTURE_GATHER_SM5
:
268 case PIPE_CAP_SAMPLE_SHADING
:
269 case PIPE_CAP_TEXTURE_GATHER_OFFSETS
:
270 case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION
:
271 case PIPE_CAP_DRAW_INDIRECT
:
272 case PIPE_CAP_MULTI_DRAW_INDIRECT
:
273 case PIPE_CAP_MULTI_DRAW_INDIRECT_PARAMS
:
274 case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE
:
275 case PIPE_CAP_POLYGON_OFFSET_CLAMP
:
276 case PIPE_CAP_MULTISAMPLE_Z_RESOLVE
:
277 case PIPE_CAP_RESOURCE_FROM_USER_MEMORY
:
278 case PIPE_CAP_DEVICE_RESET_STATUS_QUERY
:
279 case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS
:
280 case PIPE_CAP_DEPTH_BOUNDS_TEST
:
281 case PIPE_CAP_TGSI_TXQS
:
282 /* TODO if we need this, do it in nir/ir3 backend to avoid breaking precompile: */
283 case PIPE_CAP_FORCE_PERSAMPLE_INTERP
:
284 case PIPE_CAP_COPY_BETWEEN_COMPRESSED_AND_PLAIN_FORMATS
:
285 case PIPE_CAP_CLEAR_TEXTURE
:
286 case PIPE_CAP_DRAW_PARAMETERS
:
287 case PIPE_CAP_TGSI_PACK_HALF_FLOAT
:
288 case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL
:
289 case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL
:
290 case PIPE_CAP_INVALIDATE_BUFFER
:
291 case PIPE_CAP_GENERATE_MIPMAP
:
292 case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS
:
293 case PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT
:
294 case PIPE_CAP_ROBUST_BUFFER_ACCESS_BEHAVIOR
:
295 case PIPE_CAP_CULL_DISTANCE
:
296 case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES
:
297 case PIPE_CAP_TGSI_VOTE
:
298 case PIPE_CAP_MAX_WINDOW_RECTANGLES
:
299 case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED
:
300 case PIPE_CAP_VIEWPORT_SUBPIXEL_BITS
:
301 case PIPE_CAP_TGSI_ARRAY_COMPONENTS
:
302 case PIPE_CAP_TGSI_CAN_READ_OUTPUTS
:
303 case PIPE_CAP_TGSI_FS_FBFETCH
:
304 case PIPE_CAP_TGSI_MUL_ZERO_WINS
:
305 case PIPE_CAP_DOUBLES
:
307 case PIPE_CAP_INT64_DIVMOD
:
308 case PIPE_CAP_TGSI_TEX_TXF_LZ
:
309 case PIPE_CAP_TGSI_CLOCK
:
310 case PIPE_CAP_POLYGON_MODE_FILL_RECTANGLE
:
311 case PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE
:
312 case PIPE_CAP_TGSI_BALLOT
:
313 case PIPE_CAP_TGSI_TES_LAYER_VIEWPORT
:
316 case PIPE_CAP_MAX_VIEWPORTS
:
319 case PIPE_CAP_SHAREABLE_SHADERS
:
320 case PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY
:
321 /* manage the variants for these ourself, to avoid breaking precompile: */
322 case PIPE_CAP_FRAGMENT_COLOR_CLAMPED
:
323 case PIPE_CAP_VERTEX_COLOR_CLAMPED
:
329 case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS
:
331 return PIPE_MAX_SO_BUFFERS
;
333 case PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME
:
334 case PIPE_CAP_STREAM_OUTPUT_INTERLEAVE_BUFFERS
:
338 case PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS
:
339 case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS
:
341 return 16 * 4; /* should only be shader out limit? */
344 /* Geometry shader output, unsupported. */
345 case PIPE_CAP_MAX_GEOMETRY_OUTPUT_VERTICES
:
346 case PIPE_CAP_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS
:
347 case PIPE_CAP_MAX_VERTEX_STREAMS
:
350 case PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE
:
354 case PIPE_CAP_MAX_TEXTURE_2D_LEVELS
:
355 case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS
:
356 return MAX_MIP_LEVELS
;
357 case PIPE_CAP_MAX_TEXTURE_3D_LEVELS
:
360 case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS
:
361 return (is_a3xx(screen
) || is_a4xx(screen
) || is_a5xx(screen
)) ? 256 : 0;
363 /* Render targets. */
364 case PIPE_CAP_MAX_RENDER_TARGETS
:
365 return screen
->max_rts
;
366 case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS
:
367 return is_a3xx(screen
) ? 1 : 0;
370 case PIPE_CAP_QUERY_BUFFER_OBJECT
:
372 case PIPE_CAP_OCCLUSION_QUERY
:
373 return is_a3xx(screen
) || is_a4xx(screen
) || is_a5xx(screen
);
374 case PIPE_CAP_QUERY_TIMESTAMP
:
375 case PIPE_CAP_QUERY_TIME_ELAPSED
:
376 /* only a4xx, requires new enough kernel so we know max_freq: */
377 return (screen
->max_freq
> 0) && is_a4xx(screen
);
379 case PIPE_CAP_MIN_TEXTURE_GATHER_OFFSET
:
380 case PIPE_CAP_MIN_TEXEL_OFFSET
:
383 case PIPE_CAP_MAX_TEXTURE_GATHER_OFFSET
:
384 case PIPE_CAP_MAX_TEXEL_OFFSET
:
387 case PIPE_CAP_ENDIANNESS
:
388 return PIPE_ENDIAN_LITTLE
;
390 case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT
:
393 case PIPE_CAP_VENDOR_ID
:
395 case PIPE_CAP_DEVICE_ID
:
397 case PIPE_CAP_ACCELERATED
:
399 case PIPE_CAP_VIDEO_MEMORY
:
400 DBG("FINISHME: The value returned is incorrect\n");
404 case PIPE_CAP_NATIVE_FENCE_FD
:
405 return fd_device_version(screen
->dev
) >= FD_VERSION_FENCE_FD
;
407 debug_printf("unknown param %d\n", param
);
412 fd_screen_get_paramf(struct pipe_screen
*pscreen
, enum pipe_capf param
)
415 case PIPE_CAPF_MAX_LINE_WIDTH
:
416 case PIPE_CAPF_MAX_LINE_WIDTH_AA
:
417 /* NOTE: actual value is 127.0f, but this is working around a deqp
418 * bug.. dEQP-GLES3.functional.rasterization.primitives.lines_wide
419 * uses too small of a render target size, and gets confused when
420 * the lines start going offscreen.
422 * See: https://code.google.com/p/android/issues/detail?id=206513
424 if (fd_mesa_debug
& FD_DBG_DEQP
)
427 case PIPE_CAPF_MAX_POINT_WIDTH
:
428 case PIPE_CAPF_MAX_POINT_WIDTH_AA
:
430 case PIPE_CAPF_MAX_TEXTURE_ANISOTROPY
:
432 case PIPE_CAPF_MAX_TEXTURE_LOD_BIAS
:
434 case PIPE_CAPF_GUARD_BAND_LEFT
:
435 case PIPE_CAPF_GUARD_BAND_TOP
:
436 case PIPE_CAPF_GUARD_BAND_RIGHT
:
437 case PIPE_CAPF_GUARD_BAND_BOTTOM
:
440 debug_printf("unknown paramf %d\n", param
);
445 fd_screen_get_shader_param(struct pipe_screen
*pscreen
,
446 enum pipe_shader_type shader
,
447 enum pipe_shader_cap param
)
449 struct fd_screen
*screen
= fd_screen(pscreen
);
453 case PIPE_SHADER_FRAGMENT
:
454 case PIPE_SHADER_VERTEX
:
456 case PIPE_SHADER_COMPUTE
:
457 case PIPE_SHADER_GEOMETRY
:
458 /* maye we could emulate.. */
461 DBG("unknown shader type %d", shader
);
465 /* this is probably not totally correct.. but it's a start: */
467 case PIPE_SHADER_CAP_MAX_INSTRUCTIONS
:
468 case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS
:
469 case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS
:
470 case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS
:
472 case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
:
474 case PIPE_SHADER_CAP_MAX_INPUTS
:
475 case PIPE_SHADER_CAP_MAX_OUTPUTS
:
477 case PIPE_SHADER_CAP_MAX_TEMPS
:
478 return 64; /* Max native temporaries. */
479 case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE
:
480 /* NOTE: seems to be limit for a3xx is actually 512 but
481 * split between VS and FS. Use lower limit of 256 to
482 * avoid getting into impossible situations:
484 return ((is_a3xx(screen
) || is_a4xx(screen
) || is_a5xx(screen
)) ? 4096 : 64) * sizeof(float[4]);
485 case PIPE_SHADER_CAP_MAX_CONST_BUFFERS
:
486 return is_ir3(screen
) ? 16 : 1;
487 case PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED
:
489 case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR
:
490 case PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR
:
491 /* Technically this should be the same as for TEMP/CONST, since
492 * everything is just normal registers. This is just temporary
493 * hack until load_input/store_output handle arrays in a similar
494 * way as load_var/store_var..
497 case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR
:
498 case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR
:
499 /* a2xx compiler doesn't handle indirect: */
500 return is_ir3(screen
) ? 1 : 0;
501 case PIPE_SHADER_CAP_SUBROUTINES
:
502 case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED
:
503 case PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED
:
504 case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED
:
505 case PIPE_SHADER_CAP_TGSI_ANY_INOUT_DECL_RANGE
:
507 case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED
:
509 case PIPE_SHADER_CAP_INTEGERS
:
512 return is_ir3(screen
) ? 1 : 0;
513 case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS
:
514 case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS
:
516 case PIPE_SHADER_CAP_PREFERRED_IR
:
517 if ((fd_mesa_debug
& FD_DBG_NIR
) && is_ir3(screen
))
518 return PIPE_SHADER_IR_NIR
;
519 return PIPE_SHADER_IR_TGSI
;
520 case PIPE_SHADER_CAP_SUPPORTED_IRS
:
522 case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS_HINT
:
524 case PIPE_SHADER_CAP_MAX_SHADER_BUFFERS
:
525 if (is_a5xx(screen
)) {
526 /* a5xx (and a4xx for that matter) has one state-block
527 * for compute-shader SSBO's and another that is shared
528 * by VS/HS/DS/GS/FS.. so to simplify things for now
529 * just advertise SSBOs for FS and CS. We could possibly
530 * do what blob does, and partition the space for
531 * VS/HS/DS/GS/FS. The blob advertises:
533 * GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS: 4
534 * GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS: 4
535 * GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS: 4
536 * GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS: 4
537 * GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS: 4
538 * GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS: 24
539 * GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS: 24
541 * I think that way we could avoid having to patch shaders
542 * for actual SSBO indexes by using a static partitioning.
546 case PIPE_SHADER_FRAGMENT
:
547 case PIPE_SHADER_COMPUTE
:
554 case PIPE_SHADER_CAP_MAX_SHADER_IMAGES
:
555 case PIPE_SHADER_CAP_LOWER_IF_THRESHOLD
:
556 case PIPE_SHADER_CAP_TGSI_SKIP_MERGE_REGISTERS
:
559 debug_printf("unknown shader param %d\n", param
);
564 fd_get_compiler_options(struct pipe_screen
*pscreen
,
565 enum pipe_shader_ir ir
, unsigned shader
)
567 struct fd_screen
*screen
= fd_screen(pscreen
);
570 return ir3_get_compiler_options();
576 fd_screen_bo_get_handle(struct pipe_screen
*pscreen
,
579 struct winsys_handle
*whandle
)
581 whandle
->stride
= stride
;
583 if (whandle
->type
== DRM_API_HANDLE_TYPE_SHARED
) {
584 return fd_bo_get_name(bo
, &whandle
->handle
) == 0;
585 } else if (whandle
->type
== DRM_API_HANDLE_TYPE_KMS
) {
586 whandle
->handle
= fd_bo_handle(bo
);
588 } else if (whandle
->type
== DRM_API_HANDLE_TYPE_FD
) {
589 whandle
->handle
= fd_bo_dmabuf(bo
);
597 fd_screen_bo_from_handle(struct pipe_screen
*pscreen
,
598 struct winsys_handle
*whandle
)
600 struct fd_screen
*screen
= fd_screen(pscreen
);
603 if (whandle
->type
== DRM_API_HANDLE_TYPE_SHARED
) {
604 bo
= fd_bo_from_name(screen
->dev
, whandle
->handle
);
605 } else if (whandle
->type
== DRM_API_HANDLE_TYPE_KMS
) {
606 bo
= fd_bo_from_handle(screen
->dev
, whandle
->handle
, 0);
607 } else if (whandle
->type
== DRM_API_HANDLE_TYPE_FD
) {
608 bo
= fd_bo_from_dmabuf(screen
->dev
, whandle
->handle
);
610 DBG("Attempt to import unsupported handle type %d", whandle
->type
);
615 DBG("ref name 0x%08x failed", whandle
->handle
);
623 fd_screen_create(struct fd_device
*dev
)
625 struct fd_screen
*screen
= CALLOC_STRUCT(fd_screen
);
626 struct pipe_screen
*pscreen
;
629 fd_mesa_debug
= debug_get_option_fd_mesa_debug();
631 if (fd_mesa_debug
& FD_DBG_NOBIN
)
632 fd_binning_enabled
= false;
634 glsl120
= !!(fd_mesa_debug
& FD_DBG_GLSL120
);
639 pscreen
= &screen
->base
;
644 // maybe this should be in context?
645 screen
->pipe
= fd_pipe_new(screen
->dev
, FD_PIPE_3D
);
647 DBG("could not create 3d pipe");
651 if (fd_pipe_get_param(screen
->pipe
, FD_GMEM_SIZE
, &val
)) {
652 DBG("could not get GMEM size");
655 screen
->gmemsize_bytes
= val
;
657 if (fd_pipe_get_param(screen
->pipe
, FD_DEVICE_ID
, &val
)) {
658 DBG("could not get device-id");
661 screen
->device_id
= val
;
663 if (fd_pipe_get_param(screen
->pipe
, FD_MAX_FREQ
, &val
)) {
664 DBG("could not get gpu freq");
665 /* this limits what performance related queries are
666 * supported but is not fatal
668 screen
->max_freq
= 0;
670 screen
->max_freq
= val
;
671 if (fd_pipe_get_param(screen
->pipe
, FD_TIMESTAMP
, &val
) == 0)
672 screen
->has_timestamp
= true;
675 if (fd_pipe_get_param(screen
->pipe
, FD_GPU_ID
, &val
)) {
676 DBG("could not get gpu-id");
679 screen
->gpu_id
= val
;
681 if (fd_pipe_get_param(screen
->pipe
, FD_CHIP_ID
, &val
)) {
682 DBG("could not get chip-id");
683 /* older kernels may not have this property: */
684 unsigned core
= screen
->gpu_id
/ 100;
685 unsigned major
= (screen
->gpu_id
% 100) / 10;
686 unsigned minor
= screen
->gpu_id
% 10;
687 unsigned patch
= 0; /* assume the worst */
688 val
= (patch
& 0xff) | ((minor
& 0xff) << 8) |
689 ((major
& 0xff) << 16) | ((core
& 0xff) << 24);
691 screen
->chip_id
= val
;
694 DBG(" GPU-id: %d", screen
->gpu_id
);
695 DBG(" Chip-id: 0x%08x", screen
->chip_id
);
696 DBG(" GMEM size: 0x%08x", screen
->gmemsize_bytes
);
698 /* explicitly checking for GPU revisions that are known to work. This
699 * may be overly conservative for a3xx, where spoofing the gpu_id with
700 * the blob driver seems to generate identical cmdstream dumps. But
701 * on a2xx, there seem to be small differences between the GPU revs
702 * so it is probably better to actually test first on real hardware
705 * If you have a different adreno version, feel free to add it to one
706 * of the cases below and see what happens. And if it works, please
709 switch (screen
->gpu_id
) {
711 fd2_screen_init(pscreen
);
717 fd3_screen_init(pscreen
);
721 fd4_screen_init(pscreen
);
724 fd5_screen_init(pscreen
);
727 debug_printf("unsupported GPU: a%03d\n", screen
->gpu_id
);
731 if (screen
->gpu_id
>= 500) {
732 screen
->gmem_alignw
= 64;
733 screen
->gmem_alignh
= 32;
735 screen
->gmem_alignw
= 32;
736 screen
->gmem_alignh
= 32;
739 /* NOTE: don't enable reordering on a2xx, since completely untested.
740 * Also, don't enable if we have too old of a kernel to support
741 * growable cmdstream buffers, since memory requirement for cmdstream
742 * buffers would be too much otherwise.
744 if ((screen
->gpu_id
>= 300) && (fd_device_version(dev
) >= FD_VERSION_UNLIMITED_CMDS
))
745 screen
->reorder
= !(fd_mesa_debug
& FD_DBG_INORDER
);
747 fd_bc_init(&screen
->batch_cache
);
749 (void) mtx_init(&screen
->lock
, mtx_plain
);
751 pscreen
->destroy
= fd_screen_destroy
;
752 pscreen
->get_param
= fd_screen_get_param
;
753 pscreen
->get_paramf
= fd_screen_get_paramf
;
754 pscreen
->get_shader_param
= fd_screen_get_shader_param
;
755 pscreen
->get_compiler_options
= fd_get_compiler_options
;
757 fd_resource_screen_init(pscreen
);
758 fd_query_screen_init(pscreen
);
760 pscreen
->get_name
= fd_screen_get_name
;
761 pscreen
->get_vendor
= fd_screen_get_vendor
;
762 pscreen
->get_device_vendor
= fd_screen_get_device_vendor
;
764 pscreen
->get_timestamp
= fd_screen_get_timestamp
;
766 pscreen
->fence_reference
= fd_fence_ref
;
767 pscreen
->fence_finish
= fd_fence_finish
;
768 pscreen
->fence_get_fd
= fd_fence_get_fd
;
770 slab_create_parent(&screen
->transfer_pool
, sizeof(struct fd_transfer
), 16);
772 util_format_s3tc_init();
777 fd_screen_destroy(pscreen
);