@@ -140,6 +140,8 @@ struct mos_bufmgr_gem {
140
140
int exec_size ;
141
141
int exec_count ;
142
142
143
+ struct mos_exec_fences exec_fences ;
144
+
143
145
/** Array of lists of cached gem objects of power-of-two sizes */
144
146
struct mos_gem_bo_bucket cache_bucket [64 ];
145
147
int num_buckets ;
@@ -5221,6 +5223,61 @@ mos_bufmgr_enable_turbo_boost(struct mos_bufmgr *bufmgr)
5221
5223
DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM , & ctxParam );
5222
5224
}
5223
5225
5226
+ int
5227
+ mos_bufmgr_set_fences (struct mos_bufmgr * bufmgr , struct mos_exec_fences * exec_fences )
5228
+ {
5229
+ if (!bufmgr || !exec_fences || exec_fences -> count > FENCES_MAX )
5230
+ {
5231
+ return - EINVAL ;
5232
+ }
5233
+
5234
+ struct mos_bufmgr_gem * bufmgr_gem = (struct mos_bufmgr_gem * )bufmgr ;
5235
+
5236
+ if (bufmgr_gem -> exec_fences .fences == nullptr )
5237
+ {
5238
+ //fences[0] reserved for fence out
5239
+ bufmgr_gem -> exec_fences .fences = (int32_t * )malloc ((FENCES_MAX + 1 ) * sizeof (int32_t ));
5240
+
5241
+ if (bufmgr_gem -> exec_fences .fences == nullptr )
5242
+ {
5243
+ return - ENOMEM ;
5244
+ }
5245
+
5246
+ bufmgr_gem -> exec_fences .count = 0 ;
5247
+ }
5248
+
5249
+ if (exec_fences -> count > 0 )
5250
+ {
5251
+ memcpy (bufmgr_gem -> exec_fences .fences , exec_fences -> fences , (exec_fences -> count + 1 ) * sizeof (int32_t ));
5252
+ bufmgr_gem -> exec_fences .fences [0 ] = 0 ;
5253
+ bufmgr_gem -> exec_fences .count = exec_fences -> count ;
5254
+ }
5255
+
5256
+ return 0 ;
5257
+ }
5258
+
5259
+ int
5260
+ mos_bufmgr_get_fence (struct mos_bufmgr * bufmgr , int32_t * fence_out )
5261
+ {
5262
+ if (!bufmgr || !fence_out )
5263
+ {
5264
+ return - EINVAL ;
5265
+ }
5266
+
5267
+ struct mos_bufmgr_gem * bufmgr_gem = (struct mos_bufmgr_gem * )bufmgr ;
5268
+
5269
+ if (bufmgr_gem -> exec_fences .fences )
5270
+ {
5271
+ * fence_out = bufmgr_gem -> exec_fences .fences [0 ];
5272
+ }
5273
+ else
5274
+ {
5275
+ * fence_out = 0 ;
5276
+ }
5277
+
5278
+ return 0 ;
5279
+ }
5280
+
5224
5281
/**
5225
5282
* Initializes the GEM buffer manager, which uses the kernel to allocate, map,
5226
5283
* and manage map buffer objections.
@@ -5333,6 +5390,8 @@ mos_bufmgr_gem_init_i915(int fd, int batch_size)
5333
5390
bufmgr_gem -> bufmgr .get_ts_frequency = mos_bufmgr_get_ts_frequency ;
5334
5391
bufmgr_gem -> bufmgr .has_bsd2 = mos_bufmgr_has_bsd2 ;
5335
5392
bufmgr_gem -> bufmgr .enable_turbo_boost = mos_bufmgr_enable_turbo_boost ;
5393
+ bufmgr_gem -> bufmgr .set_fences = mos_bufmgr_set_fences ;
5394
+ bufmgr_gem -> bufmgr .get_fence = mos_bufmgr_get_fence ;
5336
5395
5337
5396
bufmgr_gem -> mem_profiler_path = getenv ("MEDIA_MEMORY_PROFILER_LOG" );
5338
5397
if (bufmgr_gem -> mem_profiler_path != nullptr )
0 commit comments