2 * Copyright © 2017 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
26 * Screen related driver hooks and capability lists.
28 * A program may use multiple rendering contexts (iris_context), but
29 * they all share a common screen (iris_screen). Global driver state
30 * can be stored in the screen; it may be accessed by multiple threads.
35 #include <sys/ioctl.h>
36 #include "pipe/p_defines.h"
37 #include "pipe/p_state.h"
38 #include "pipe/p_context.h"
39 #include "pipe/p_screen.h"
40 #include "util/debug.h"
41 #include "util/u_inlines.h"
42 #include "util/format/u_format.h"
43 #include "util/u_transfer_helper.h"
44 #include "util/u_upload_mgr.h"
45 #include "util/ralloc.h"
46 #include "util/xmlconfig.h"
47 #include "drm-uapi/i915_drm.h"
48 #include "iris_context.h"
49 #include "iris_defines.h"
50 #include "iris_fence.h"
51 #include "iris_pipe.h"
52 #include "iris_resource.h"
53 #include "iris_screen.h"
54 #include "intel/compiler/brw_compiler.h"
55 #include "intel/common/gen_gem.h"
56 #include "intel/common/gen_l3_config.h"
57 #include "iris_monitor.h"
60 iris_flush_frontbuffer(struct pipe_screen
*_screen
,
61 struct pipe_resource
*resource
,
62 unsigned level
, unsigned layer
,
63 void *context_private
, struct pipe_box
*box
)
68 iris_get_vendor(struct pipe_screen
*pscreen
)
74 iris_get_device_vendor(struct pipe_screen
*pscreen
)
80 iris_get_name(struct pipe_screen
*pscreen
)
82 struct iris_screen
*screen
= (struct iris_screen
*)pscreen
;
84 const char *name
= gen_get_device_name(screen
->pci_id
);
87 name
= "Intel Unknown";
89 snprintf(buf
, sizeof(buf
), "Mesa %s", name
);
94 iris_get_param(struct pipe_screen
*pscreen
, enum pipe_cap param
)
96 struct iris_screen
*screen
= (struct iris_screen
*)pscreen
;
97 const struct gen_device_info
*devinfo
= &screen
->devinfo
;
100 case PIPE_CAP_NPOT_TEXTURES
:
101 case PIPE_CAP_ANISOTROPIC_FILTER
:
102 case PIPE_CAP_POINT_SPRITE
:
103 case PIPE_CAP_OCCLUSION_QUERY
:
104 case PIPE_CAP_QUERY_TIME_ELAPSED
:
105 case PIPE_CAP_TEXTURE_SWIZZLE
:
106 case PIPE_CAP_TEXTURE_MIRROR_CLAMP_TO_EDGE
:
107 case PIPE_CAP_BLEND_EQUATION_SEPARATE
:
108 case PIPE_CAP_FRAGMENT_SHADER_TEXTURE_LOD
:
109 case PIPE_CAP_FRAGMENT_SHADER_DERIVATIVES
:
110 case PIPE_CAP_VERTEX_SHADER_SATURATE
:
111 case PIPE_CAP_PRIMITIVE_RESTART
:
112 case PIPE_CAP_PRIMITIVE_RESTART_FIXED_INDEX
:
113 case PIPE_CAP_INDEP_BLEND_ENABLE
:
114 case PIPE_CAP_INDEP_BLEND_FUNC
:
115 case PIPE_CAP_RGB_OVERRIDE_DST_ALPHA_BLEND
:
116 case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT
:
117 case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER
:
118 case PIPE_CAP_DEPTH_CLIP_DISABLE
:
119 case PIPE_CAP_TGSI_INSTANCEID
:
120 case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR
:
121 case PIPE_CAP_MIXED_COLORBUFFER_FORMATS
:
122 case PIPE_CAP_SEAMLESS_CUBE_MAP
:
123 case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE
:
124 case PIPE_CAP_CONDITIONAL_RENDER
:
125 case PIPE_CAP_TEXTURE_BARRIER
:
126 case PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME
:
127 case PIPE_CAP_VERTEX_COLOR_UNCLAMPED
:
128 case PIPE_CAP_COMPUTE
:
129 case PIPE_CAP_START_INSTANCE
:
130 case PIPE_CAP_QUERY_TIMESTAMP
:
131 case PIPE_CAP_TEXTURE_MULTISAMPLE
:
132 case PIPE_CAP_CUBE_MAP_ARRAY
:
133 case PIPE_CAP_TEXTURE_BUFFER_OBJECTS
:
134 case PIPE_CAP_QUERY_PIPELINE_STATISTICS_SINGLE
:
135 case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT
:
136 case PIPE_CAP_TEXTURE_QUERY_LOD
:
137 case PIPE_CAP_SAMPLE_SHADING
:
138 case PIPE_CAP_FORCE_PERSAMPLE_INTERP
:
139 case PIPE_CAP_DRAW_INDIRECT
:
140 case PIPE_CAP_MULTI_DRAW_INDIRECT
:
141 case PIPE_CAP_MULTI_DRAW_INDIRECT_PARAMS
:
142 case PIPE_CAP_MIXED_FRAMEBUFFER_SIZES
:
143 case PIPE_CAP_TGSI_VS_LAYER_VIEWPORT
:
144 case PIPE_CAP_TGSI_TES_LAYER_VIEWPORT
:
145 case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE
:
146 case PIPE_CAP_TGSI_PACK_HALF_FLOAT
:
147 case PIPE_CAP_ACCELERATED
:
149 case PIPE_CAP_CONDITIONAL_RENDER_INVERTED
:
150 case PIPE_CAP_CLIP_HALFZ
:
151 case PIPE_CAP_TGSI_TEXCOORD
:
152 case PIPE_CAP_STREAM_OUTPUT_INTERLEAVE_BUFFERS
:
153 case PIPE_CAP_DOUBLES
:
155 case PIPE_CAP_INT64_DIVMOD
:
156 case PIPE_CAP_SAMPLER_VIEW_TARGET
:
157 case PIPE_CAP_ROBUST_BUFFER_ACCESS_BEHAVIOR
:
158 case PIPE_CAP_DEVICE_RESET_STATUS_QUERY
:
159 case PIPE_CAP_COPY_BETWEEN_COMPRESSED_AND_PLAIN_FORMATS
:
160 case PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT
:
161 case PIPE_CAP_CULL_DISTANCE
:
162 case PIPE_CAP_PACKED_UNIFORMS
:
163 case PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET
:
164 case PIPE_CAP_TEXTURE_FLOAT_LINEAR
:
165 case PIPE_CAP_TEXTURE_HALF_FLOAT_LINEAR
:
166 case PIPE_CAP_POLYGON_OFFSET_CLAMP
:
167 case PIPE_CAP_QUERY_SO_OVERFLOW
:
168 case PIPE_CAP_QUERY_BUFFER_OBJECT
:
169 case PIPE_CAP_TGSI_TEX_TXF_LZ
:
170 case PIPE_CAP_TGSI_TXQS
:
171 case PIPE_CAP_TGSI_CLOCK
:
172 case PIPE_CAP_TGSI_BALLOT
:
173 case PIPE_CAP_MULTISAMPLE_Z_RESOLVE
:
174 case PIPE_CAP_CLEAR_TEXTURE
:
175 case PIPE_CAP_CLEAR_SCISSORED
:
176 case PIPE_CAP_TGSI_VOTE
:
177 case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION
:
178 case PIPE_CAP_TEXTURE_GATHER_SM5
:
179 case PIPE_CAP_TGSI_ARRAY_COMPONENTS
:
180 case PIPE_CAP_GLSL_TESS_LEVELS_AS_INPUTS
:
181 case PIPE_CAP_LOAD_CONSTBUF
:
182 case PIPE_CAP_NIR_COMPACT_ARRAYS
:
183 case PIPE_CAP_DRAW_PARAMETERS
:
184 case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL
:
185 case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL
:
186 case PIPE_CAP_COMPUTE_SHADER_DERIVATIVES
:
187 case PIPE_CAP_INVALIDATE_BUFFER
:
188 case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS
:
189 case PIPE_CAP_CS_DERIVED_SYSTEM_VALUES_SUPPORTED
:
190 case PIPE_CAP_TEXTURE_SHADOW_LOD
:
191 case PIPE_CAP_SHADER_SAMPLES_IDENTICAL
:
192 case PIPE_CAP_GL_SPIRV
:
193 case PIPE_CAP_GL_SPIRV_VARIABLE_POINTERS
:
194 case PIPE_CAP_DEMOTE_TO_HELPER_INVOCATION
:
195 case PIPE_CAP_NATIVE_FENCE_FD
:
196 case PIPE_CAP_MIXED_COLOR_DEPTH_BITS
:
198 case PIPE_CAP_FBFETCH
:
199 return BRW_MAX_DRAW_BUFFERS
;
200 case PIPE_CAP_FBFETCH_COHERENT
:
201 case PIPE_CAP_CONSERVATIVE_RASTER_INNER_COVERAGE
:
202 case PIPE_CAP_POST_DEPTH_COVERAGE
:
203 case PIPE_CAP_SHADER_STENCIL_EXPORT
:
204 case PIPE_CAP_DEPTH_CLIP_DISABLE_SEPARATE
:
205 case PIPE_CAP_FRAGMENT_SHADER_INTERLOCK
:
206 case PIPE_CAP_ATOMIC_FLOAT_MINMAX
:
207 return devinfo
->gen
>= 9;
208 case PIPE_CAP_DEPTH_BOUNDS_TEST
:
209 return devinfo
->gen
>= 12;
210 case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS
:
212 case PIPE_CAP_MAX_RENDER_TARGETS
:
213 return BRW_MAX_DRAW_BUFFERS
;
214 case PIPE_CAP_MAX_TEXTURE_2D_SIZE
:
216 case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS
:
217 return IRIS_MAX_MIPLEVELS
; /* 16384x16384 */
218 case PIPE_CAP_MAX_TEXTURE_3D_LEVELS
:
219 return 12; /* 2048x2048 */
220 case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS
:
222 case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS
:
224 case PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS
:
225 return BRW_MAX_SOL_BINDINGS
/ IRIS_MAX_SOL_BUFFERS
;
226 case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS
:
227 return BRW_MAX_SOL_BINDINGS
;
228 case PIPE_CAP_GLSL_FEATURE_LEVEL
:
229 case PIPE_CAP_GLSL_FEATURE_LEVEL_COMPATIBILITY
:
231 case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT
:
232 /* 3DSTATE_CONSTANT_XS requires the start of UBOs to be 32B aligned */
234 case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT
:
235 return IRIS_MAP_BUFFER_ALIGNMENT
;
236 case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT
:
237 /* Choose a cacheline (64 bytes) so that we can safely have the CPU and
238 * GPU writing the same SSBO on non-coherent systems (Atom CPUs). With
239 * UBOs, the GPU never writes, so there's no problem. For an SSBO, the
240 * GPU and the CPU can be updating disjoint regions of the buffer
241 * simultaneously and that will break if the regions overlap the same
245 case PIPE_CAP_MAX_SHADER_BUFFER_SIZE
:
247 case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT
:
248 return 16; // XXX: u_screen says 256 is the minimum value...
249 case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER
:
251 case PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE
:
252 return IRIS_MAX_TEXTURE_BUFFER_SIZE
;
253 case PIPE_CAP_MAX_VIEWPORTS
:
255 case PIPE_CAP_MAX_GEOMETRY_OUTPUT_VERTICES
:
257 case PIPE_CAP_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS
:
259 case PIPE_CAP_MAX_GS_INVOCATIONS
:
261 case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS
:
263 case PIPE_CAP_MIN_TEXTURE_GATHER_OFFSET
:
265 case PIPE_CAP_MAX_TEXTURE_GATHER_OFFSET
:
267 case PIPE_CAP_MAX_VERTEX_STREAMS
:
269 case PIPE_CAP_VENDOR_ID
:
271 case PIPE_CAP_DEVICE_ID
:
272 return screen
->pci_id
;
273 case PIPE_CAP_VIDEO_MEMORY
: {
274 /* Once a batch uses more than 75% of the maximum mappable size, we
275 * assume that there's some fragmentation, and we start doing extra
276 * flushing, etc. That's the big cliff apps will care about.
278 const unsigned gpu_mappable_megabytes
=
279 (devinfo
->aperture_bytes
* 3 / 4) / (1024 * 1024);
281 const long system_memory_pages
= sysconf(_SC_PHYS_PAGES
);
282 const long system_page_size
= sysconf(_SC_PAGE_SIZE
);
284 if (system_memory_pages
<= 0 || system_page_size
<= 0)
287 const uint64_t system_memory_bytes
=
288 (uint64_t) system_memory_pages
* (uint64_t) system_page_size
;
290 const unsigned system_memory_megabytes
=
291 (unsigned) (system_memory_bytes
/ (1024 * 1024));
293 return MIN2(system_memory_megabytes
, gpu_mappable_megabytes
);
295 case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS
:
296 case PIPE_CAP_MAX_VARYINGS
:
298 case PIPE_CAP_RESOURCE_FROM_USER_MEMORY
:
299 /* AMD_pinned_memory assumes the flexibility of using client memory
300 * for any buffer (incl. vertex buffers) which rules out the prospect
301 * of using snooped buffers, as using snooped buffers without
302 * cogniscience is likely to be detrimental to performance and require
303 * extensive checking in the driver for correctness, e.g. to prevent
304 * illegal snoop <-> snoop transfers.
306 return devinfo
->has_llc
;
307 case PIPE_CAP_THROTTLE
:
308 return screen
->driconf
.disable_throttling
? 0 : 1;
310 case PIPE_CAP_CONTEXT_PRIORITY_MASK
:
311 return PIPE_CONTEXT_PRIORITY_LOW
|
312 PIPE_CONTEXT_PRIORITY_MEDIUM
|
313 PIPE_CONTEXT_PRIORITY_HIGH
;
315 case PIPE_CAP_FRONTEND_NOOP
:
318 // XXX: don't hardcode 00:00:02.0 PCI here
319 case PIPE_CAP_PCI_GROUP
:
321 case PIPE_CAP_PCI_BUS
:
323 case PIPE_CAP_PCI_DEVICE
:
325 case PIPE_CAP_PCI_FUNCTION
:
328 case PIPE_CAP_OPENCL_INTEGER_FUNCTIONS
:
329 case PIPE_CAP_INTEGER_MULTIPLY_32X16
:
333 return u_pipe_screen_get_param_defaults(pscreen
, param
);
339 iris_get_paramf(struct pipe_screen
*pscreen
, enum pipe_capf param
)
342 case PIPE_CAPF_MAX_LINE_WIDTH
:
343 case PIPE_CAPF_MAX_LINE_WIDTH_AA
:
346 case PIPE_CAPF_MAX_POINT_WIDTH
:
347 case PIPE_CAPF_MAX_POINT_WIDTH_AA
:
350 case PIPE_CAPF_MAX_TEXTURE_ANISOTROPY
:
352 case PIPE_CAPF_MAX_TEXTURE_LOD_BIAS
:
354 case PIPE_CAPF_MIN_CONSERVATIVE_RASTER_DILATE
:
355 case PIPE_CAPF_MAX_CONSERVATIVE_RASTER_DILATE
:
356 case PIPE_CAPF_CONSERVATIVE_RASTER_DILATE_GRANULARITY
:
359 unreachable("unknown param");
364 iris_get_shader_param(struct pipe_screen
*pscreen
,
365 enum pipe_shader_type p_stage
,
366 enum pipe_shader_cap param
)
368 gl_shader_stage stage
= stage_from_pipe(p_stage
);
370 /* this is probably not totally correct.. but it's a start: */
372 case PIPE_SHADER_CAP_MAX_INSTRUCTIONS
:
373 return stage
== MESA_SHADER_FRAGMENT
? 1024 : 16384;
374 case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS
:
375 case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS
:
376 case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS
:
377 return stage
== MESA_SHADER_FRAGMENT
? 1024 : 0;
379 case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
:
382 case PIPE_SHADER_CAP_MAX_INPUTS
:
383 return stage
== MESA_SHADER_VERTEX
? 16 : 32;
384 case PIPE_SHADER_CAP_MAX_OUTPUTS
:
386 case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE
:
387 return 16 * 1024 * sizeof(float);
388 case PIPE_SHADER_CAP_MAX_CONST_BUFFERS
:
390 case PIPE_SHADER_CAP_MAX_TEMPS
:
391 return 256; /* GL_MAX_PROGRAM_TEMPORARIES_ARB */
392 case PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED
:
394 case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR
:
395 case PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR
:
396 case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR
:
397 case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR
:
398 /* Lie about these to avoid st/mesa's GLSL IR lowering of indirects,
399 * which we don't want. Our compiler backend will check brw_compiler's
400 * options and call nir_lower_indirect_derefs appropriately anyway.
403 case PIPE_SHADER_CAP_SUBROUTINES
:
405 case PIPE_SHADER_CAP_INTEGERS
:
407 case PIPE_SHADER_CAP_INT64_ATOMICS
:
408 case PIPE_SHADER_CAP_FP16
:
409 case PIPE_SHADER_CAP_FP16_DERIVATIVES
:
410 case PIPE_SHADER_CAP_INT16
:
412 case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS
:
413 case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS
:
414 case PIPE_SHADER_CAP_MAX_SHADER_IMAGES
:
415 return IRIS_MAX_TEXTURE_SAMPLERS
;
416 case PIPE_SHADER_CAP_MAX_SHADER_BUFFERS
:
417 return IRIS_MAX_ABOS
+ IRIS_MAX_SSBOS
;
418 case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTERS
:
419 case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTER_BUFFERS
:
421 case PIPE_SHADER_CAP_PREFERRED_IR
:
422 return PIPE_SHADER_IR_NIR
;
423 case PIPE_SHADER_CAP_SUPPORTED_IRS
:
424 return 1 << PIPE_SHADER_IR_NIR
;
425 case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED
:
426 case PIPE_SHADER_CAP_TGSI_LDEXP_SUPPORTED
:
428 case PIPE_SHADER_CAP_LOWER_IF_THRESHOLD
:
429 case PIPE_SHADER_CAP_TGSI_SKIP_MERGE_REGISTERS
:
430 case PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED
:
431 case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED
:
432 case PIPE_SHADER_CAP_TGSI_ANY_INOUT_DECL_RANGE
:
433 case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED
:
434 case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS_HINT
:
437 unreachable("unknown shader param");
442 iris_get_compute_param(struct pipe_screen
*pscreen
,
443 enum pipe_shader_ir ir_type
,
444 enum pipe_compute_cap param
,
447 struct iris_screen
*screen
= (struct iris_screen
*)pscreen
;
448 const struct gen_device_info
*devinfo
= &screen
->devinfo
;
450 /* Limit max_threads to 64 for the GPGPU_WALKER command. */
451 const unsigned max_threads
= MIN2(64, devinfo
->max_cs_threads
);
452 const uint32_t max_invocations
= 32 * max_threads
;
454 #define RET(x) do { \
456 memcpy(ret, x, sizeof(x)); \
461 case PIPE_COMPUTE_CAP_ADDRESS_BITS
:
462 RET((uint32_t []){ 32 });
464 case PIPE_COMPUTE_CAP_IR_TARGET
:
469 case PIPE_COMPUTE_CAP_GRID_DIMENSION
:
470 RET((uint64_t []) { 3 });
472 case PIPE_COMPUTE_CAP_MAX_GRID_SIZE
:
473 RET(((uint64_t []) { 65535, 65535, 65535 }));
475 case PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE
:
476 /* MaxComputeWorkGroupSize[0..2] */
477 RET(((uint64_t []) {max_invocations
, max_invocations
, max_invocations
}));
479 case PIPE_COMPUTE_CAP_MAX_THREADS_PER_BLOCK
:
480 /* MaxComputeWorkGroupInvocations */
481 case PIPE_COMPUTE_CAP_MAX_VARIABLE_THREADS_PER_BLOCK
:
482 /* MaxComputeVariableGroupInvocations */
483 RET((uint64_t []) { max_invocations
});
485 case PIPE_COMPUTE_CAP_MAX_LOCAL_SIZE
:
486 /* MaxComputeSharedMemorySize */
487 RET((uint64_t []) { 64 * 1024 });
489 case PIPE_COMPUTE_CAP_IMAGES_SUPPORTED
:
490 RET((uint32_t []) { 1 });
492 case PIPE_COMPUTE_CAP_SUBGROUP_SIZE
:
493 RET((uint32_t []) { BRW_SUBGROUP_SIZE
});
495 case PIPE_COMPUTE_CAP_MAX_MEM_ALLOC_SIZE
:
496 case PIPE_COMPUTE_CAP_MAX_CLOCK_FREQUENCY
:
497 case PIPE_COMPUTE_CAP_MAX_COMPUTE_UNITS
:
498 case PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE
:
499 case PIPE_COMPUTE_CAP_MAX_PRIVATE_SIZE
:
500 case PIPE_COMPUTE_CAP_MAX_INPUT_SIZE
:
501 // XXX: I think these are for Clover...
505 unreachable("unknown compute param");
510 iris_get_timestamp(struct pipe_screen
*pscreen
)
512 struct iris_screen
*screen
= (struct iris_screen
*) pscreen
;
513 const unsigned TIMESTAMP
= 0x2358;
516 iris_reg_read(screen
->bufmgr
, TIMESTAMP
| 1, &result
);
518 result
= gen_device_info_timebase_scale(&screen
->devinfo
, result
);
519 result
&= (1ull << TIMESTAMP_BITS
) - 1;
525 iris_screen_destroy(struct iris_screen
*screen
)
527 iris_bo_unreference(screen
->workaround_bo
);
528 u_transfer_helper_destroy(screen
->base
.transfer_helper
);
529 iris_bufmgr_unref(screen
->bufmgr
);
530 disk_cache_destroy(screen
->disk_cache
);
531 close(screen
->winsys_fd
);
536 iris_screen_unref(struct pipe_screen
*pscreen
)
538 iris_pscreen_unref(pscreen
);
542 iris_query_memory_info(struct pipe_screen
*pscreen
,
543 struct pipe_memory_info
*info
)
548 iris_get_compiler_options(struct pipe_screen
*pscreen
,
549 enum pipe_shader_ir ir
,
550 enum pipe_shader_type pstage
)
552 struct iris_screen
*screen
= (struct iris_screen
*) pscreen
;
553 gl_shader_stage stage
= stage_from_pipe(pstage
);
554 assert(ir
== PIPE_SHADER_IR_NIR
);
556 return screen
->compiler
->glsl_compiler_options
[stage
].NirOptions
;
559 static struct disk_cache
*
560 iris_get_disk_shader_cache(struct pipe_screen
*pscreen
)
562 struct iris_screen
*screen
= (struct iris_screen
*) pscreen
;
563 return screen
->disk_cache
;
567 iris_getparam(int fd
, int param
, int *value
)
569 struct drm_i915_getparam gp
= { .param
= param
, .value
= value
};
571 if (ioctl(fd
, DRM_IOCTL_I915_GETPARAM
, &gp
) == -1)
578 iris_getparam_integer(int fd
, int param
)
582 if (iris_getparam(fd
, param
, &value
) == 0)
588 static const struct gen_l3_config
*
589 iris_get_default_l3_config(const struct gen_device_info
*devinfo
,
592 bool wants_dc_cache
= true;
593 bool has_slm
= compute
;
594 const struct gen_l3_weights w
=
595 gen_get_default_l3_weights(devinfo
, wants_dc_cache
, has_slm
);
596 return gen_get_l3_config(devinfo
, w
);
600 iris_shader_debug_log(void *data
, const char *fmt
, ...)
602 struct pipe_debug_callback
*dbg
= data
;
606 if (!dbg
->debug_message
)
610 dbg
->debug_message(dbg
->data
, &id
, PIPE_DEBUG_TYPE_SHADER_INFO
, fmt
, args
);
615 iris_shader_perf_log(void *data
, const char *fmt
, ...)
617 struct pipe_debug_callback
*dbg
= data
;
622 if (unlikely(INTEL_DEBUG
& DEBUG_PERF
)) {
624 va_copy(args_copy
, args
);
625 vfprintf(stderr
, fmt
, args_copy
);
629 if (dbg
->debug_message
) {
630 dbg
->debug_message(dbg
->data
, &id
, PIPE_DEBUG_TYPE_PERF_INFO
, fmt
, args
);
637 iris_detect_kernel_features(struct iris_screen
*screen
)
640 if (gen_gem_supports_syncobj_wait(screen
->fd
))
641 screen
->kernel_features
|= KERNEL_HAS_WAIT_FOR_SUBMIT
;
645 iris_init_identifier_bo(struct iris_screen
*screen
)
649 bo_map
= iris_bo_map(NULL
, screen
->workaround_bo
, MAP_READ
| MAP_WRITE
);
653 screen
->workaround_bo
->kflags
|= EXEC_OBJECT_CAPTURE
;
654 screen
->workaround_address
= (struct iris_address
) {
655 .bo
= screen
->workaround_bo
,
657 intel_debug_write_identifiers(bo_map
, 4096, "Iris") + 8, 8),
660 iris_bo_unmap(screen
->workaround_bo
);
666 iris_screen_create(int fd
, const struct pipe_screen_config
*config
)
668 /* Here are the i915 features we need for Iris (in chronoligical order) :
669 * - I915_PARAM_HAS_EXEC_NO_RELOC (3.10)
670 * - I915_PARAM_HAS_EXEC_HANDLE_LUT (3.10)
671 * - I915_PARAM_HAS_EXEC_BATCH_FIRST (4.13)
672 * - I915_PARAM_HAS_EXEC_FENCE_ARRAY (4.14)
673 * - I915_PARAM_HAS_CONTEXT_ISOLATION (4.16)
675 * Checking the last feature availability will include all previous ones.
677 if (!iris_getparam_integer(fd
, I915_PARAM_HAS_CONTEXT_ISOLATION
)) {
678 debug_error("Kernel is too old for Iris. Consider upgrading to kernel v4.16.\n");
682 struct iris_screen
*screen
= rzalloc(NULL
, struct iris_screen
);
686 if (!gen_get_device_info_from_fd(fd
, &screen
->devinfo
))
688 screen
->pci_id
= screen
->devinfo
.chipset_id
;
689 screen
->no_hw
= screen
->devinfo
.no_hw
;
691 p_atomic_set(&screen
->refcount
, 1);
693 if (screen
->devinfo
.gen
< 8 || screen
->devinfo
.is_cherryview
)
696 bool bo_reuse
= false;
697 int bo_reuse_mode
= driQueryOptioni(config
->options
, "bo_reuse");
698 switch (bo_reuse_mode
) {
699 case DRI_CONF_BO_REUSE_DISABLED
:
701 case DRI_CONF_BO_REUSE_ALL
:
706 screen
->bufmgr
= iris_bufmgr_get_for_fd(&screen
->devinfo
, fd
, bo_reuse
);
710 screen
->fd
= iris_bufmgr_get_fd(screen
->bufmgr
);
711 screen
->winsys_fd
= fd
;
713 if (getenv("INTEL_NO_HW") != NULL
)
714 screen
->no_hw
= true;
716 screen
->workaround_bo
=
717 iris_bo_alloc(screen
->bufmgr
, "workaround", 4096, IRIS_MEMZONE_OTHER
);
718 if (!screen
->workaround_bo
)
721 if (!iris_init_identifier_bo(screen
))
724 brw_process_intel_debug_variable();
726 screen
->driconf
.dual_color_blend_by_location
=
727 driQueryOptionb(config
->options
, "dual_color_blend_by_location");
728 screen
->driconf
.disable_throttling
=
729 driQueryOptionb(config
->options
, "disable_throttling");
730 screen
->driconf
.always_flush_cache
=
731 driQueryOptionb(config
->options
, "always_flush_cache");
733 screen
->precompile
= env_var_as_boolean("shader_precompile", true);
735 isl_device_init(&screen
->isl_dev
, &screen
->devinfo
, false);
737 screen
->compiler
= brw_compiler_create(screen
, &screen
->devinfo
);
738 screen
->compiler
->shader_debug_log
= iris_shader_debug_log
;
739 screen
->compiler
->shader_perf_log
= iris_shader_perf_log
;
740 screen
->compiler
->supports_pull_constants
= false;
741 screen
->compiler
->supports_shader_constants
= true;
742 screen
->compiler
->compact_params
= false;
744 screen
->l3_config_3d
= iris_get_default_l3_config(&screen
->devinfo
, false);
745 screen
->l3_config_cs
= iris_get_default_l3_config(&screen
->devinfo
, true);
747 iris_disk_cache_init(screen
);
749 slab_create_parent(&screen
->transfer_pool
,
750 sizeof(struct iris_transfer
), 64);
752 screen
->subslice_total
=
753 iris_getparam_integer(screen
->fd
, I915_PARAM_SUBSLICE_TOTAL
);
754 assert(screen
->subslice_total
>= 1);
756 iris_detect_kernel_features(screen
);
758 struct pipe_screen
*pscreen
= &screen
->base
;
760 iris_init_screen_fence_functions(pscreen
);
761 iris_init_screen_resource_functions(pscreen
);
763 pscreen
->destroy
= iris_screen_unref
;
764 pscreen
->get_name
= iris_get_name
;
765 pscreen
->get_vendor
= iris_get_vendor
;
766 pscreen
->get_device_vendor
= iris_get_device_vendor
;
767 pscreen
->get_param
= iris_get_param
;
768 pscreen
->get_shader_param
= iris_get_shader_param
;
769 pscreen
->get_compute_param
= iris_get_compute_param
;
770 pscreen
->get_paramf
= iris_get_paramf
;
771 pscreen
->get_compiler_options
= iris_get_compiler_options
;
772 pscreen
->get_disk_shader_cache
= iris_get_disk_shader_cache
;
773 pscreen
->is_format_supported
= iris_is_format_supported
;
774 pscreen
->context_create
= iris_create_context
;
775 pscreen
->flush_frontbuffer
= iris_flush_frontbuffer
;
776 pscreen
->get_timestamp
= iris_get_timestamp
;
777 pscreen
->query_memory_info
= iris_query_memory_info
;
778 pscreen
->get_driver_query_group_info
= iris_get_monitor_group_info
;
779 pscreen
->get_driver_query_info
= iris_get_monitor_info
;