@@ -232,3 +232,188 @@ CONST_VTBL struct ID3D12DeviceExtVtbl d3d12_device_vkd3d_ext_vtbl =
232
232
d3d12_device_vkd3d_ext_CaptureUAVInfo
233
233
};
234
234
235
+
236
+ static inline struct d3d12_device * d3d12_device_from_ID3D12DXVKInteropDevice (ID3D12DXVKInteropDevice * iface )
237
+ {
238
+ return CONTAINING_RECORD (iface , struct d3d12_device , ID3D12DXVKInteropDevice_iface );
239
+ }
240
+
241
+ ULONG STDMETHODCALLTYPE d3d12_dxvk_interop_device_AddRef (ID3D12DXVKInteropDevice * iface )
242
+ {
243
+ struct d3d12_device * device = d3d12_device_from_ID3D12DXVKInteropDevice (iface );
244
+ return d3d12_device_add_ref (device );
245
+ }
246
+
247
+ static ULONG STDMETHODCALLTYPE d3d12_dxvk_interop_device_Release (ID3D12DXVKInteropDevice * iface )
248
+ {
249
+ struct d3d12_device * device = d3d12_device_from_ID3D12DXVKInteropDevice (iface );
250
+ return d3d12_device_release (device );
251
+ }
252
+
253
+ extern HRESULT STDMETHODCALLTYPE d3d12_device_QueryInterface (d3d12_device_iface * iface ,
254
+ REFIID riid , void * * object );
255
+
256
+ static HRESULT STDMETHODCALLTYPE d3d12_dxvk_interop_device_QueryInterface (ID3D12DXVKInteropDevice * iface ,
257
+ REFIID iid , void * * out )
258
+ {
259
+ struct d3d12_device * device = d3d12_device_from_ID3D12DXVKInteropDevice (iface );
260
+ TRACE ("iface %p, iid %s, out %p.\n" , iface , debugstr_guid (iid ), out );
261
+ return d3d12_device_QueryInterface (& device -> ID3D12Device_iface , iid , out );
262
+ }
263
+
264
+ static HRESULT STDMETHODCALLTYPE d3d12_dxvk_interop_device_GetDXGIAdapter (ID3D12DXVKInteropDevice * iface ,
265
+ REFIID iid , void * * object )
266
+ {
267
+ struct d3d12_device * device = d3d12_device_from_ID3D12DXVKInteropDevice (iface );
268
+ TRACE ("iface %p, iid %s, object %p.\n" , iface , debugstr_guid (iid ), object );
269
+ return IUnknown_QueryInterface (device -> parent , iid , object );
270
+ }
271
+
272
+ static HRESULT STDMETHODCALLTYPE d3d12_dxvk_interop_device_GetVulkanHandles (ID3D12DXVKInteropDevice * iface ,
273
+ VkInstance * vk_instance , VkPhysicalDevice * vk_physical_device , VkDevice * vk_device )
274
+ {
275
+ struct d3d12_device * device = d3d12_device_from_ID3D12DXVKInteropDevice (iface );
276
+ TRACE ("iface %p, vk_instance %p, vk_physical_device %p, vk_device %p \n" , iface , vk_instance , vk_physical_device , vk_device );
277
+ if (!vk_device || !vk_instance || !vk_physical_device )
278
+ return E_INVALIDARG ;
279
+
280
+ * vk_instance = device -> vkd3d_instance -> vk_instance ;
281
+ * vk_physical_device = device -> vk_physical_device ;
282
+ * vk_device = device -> vk_device ;
283
+ return S_OK ;
284
+ }
285
+
286
+ static HRESULT STDMETHODCALLTYPE d3d12_dxvk_interop_device_GetInstanceExtensions (ID3D12DXVKInteropDevice * iface , UINT * extension_count , const char * * extensions )
287
+ {
288
+ struct d3d12_device * device = d3d12_device_from_ID3D12DXVKInteropDevice (iface );
289
+ struct vkd3d_instance * instance = device -> vkd3d_instance ;
290
+
291
+ TRACE ("iface %p, extension_count %u, extensions %p.\n" , iface , extension_count , extensions );
292
+
293
+ if (extensions && (* extension_count < instance -> vk_info .extension_count ))
294
+ return E_INVALIDARG ;
295
+
296
+ * extension_count = instance -> vk_info .extension_count ;
297
+
298
+ if (!extensions )
299
+ return S_OK ;
300
+
301
+ memcpy (extensions , instance -> vk_info .extension_names ,
302
+ sizeof (* extensions ) * instance -> vk_info .extension_count );
303
+ return S_OK ;
304
+ }
305
+
306
+ static HRESULT STDMETHODCALLTYPE d3d12_dxvk_interop_device_GetDeviceExtensions (ID3D12DXVKInteropDevice * iface , UINT * extension_count , const char * * extensions )
307
+ {
308
+ struct d3d12_device * device = d3d12_device_from_ID3D12DXVKInteropDevice (iface );
309
+
310
+ TRACE ("iface %p, extension_count %u, extensions %p.\n" , iface , extension_count , extensions );
311
+
312
+ if (extensions && (* extension_count < device -> vk_info .extension_count ))
313
+ return E_INVALIDARG ;
314
+
315
+ * extension_count = device -> vk_info .extension_count ;
316
+
317
+ if (!extensions )
318
+ return S_OK ;
319
+
320
+ memcpy (extensions , device -> vk_info .extension_names ,
321
+ sizeof (* extensions ) * device -> vk_info .extension_count );
322
+ return S_OK ;
323
+ }
324
+
325
+ static HRESULT STDMETHODCALLTYPE d3d12_dxvk_interop_device_GetDeviceFeatures (ID3D12DXVKInteropDevice * iface , const VkPhysicalDeviceFeatures2 * * features )
326
+ {
327
+ struct d3d12_device * device = d3d12_device_from_ID3D12DXVKInteropDevice (iface );
328
+
329
+ TRACE ("iface %p, features %p.\n" , iface , features );
330
+
331
+ * features = & device -> device_info .features2 ;
332
+ return S_OK ;
333
+ }
334
+
335
+ static HRESULT STDMETHODCALLTYPE d3d12_dxvk_interop_device_GetVulkanQueueInfo (ID3D12DXVKInteropDevice * iface ,
336
+ ID3D12CommandQueue * queue , VkQueue * vk_queue , UINT32 * vk_queue_family )
337
+ {
338
+ TRACE ("iface %p, queue %p, vk_queue %p, vk_queue_family %p.\n" , iface , queue , vk_queue , vk_queue_family );
339
+
340
+ /* This only gets called during D3D11 device creation */
341
+ * vk_queue = vkd3d_acquire_vk_queue (queue );
342
+ vkd3d_release_vk_queue (queue );
343
+
344
+ * vk_queue_family = vkd3d_get_vk_queue_family_index (queue );
345
+ return S_OK ;
346
+ }
347
+
348
+ static void STDMETHODCALLTYPE d3d12_dxvk_interop_device_GetVulkanImageLayout (ID3D12DXVKInteropDevice * iface ,
349
+ ID3D12Resource * resource , D3D12_RESOURCE_STATES state , VkImageLayout * vk_layout )
350
+ {
351
+ struct d3d12_resource * resource_impl = impl_from_ID3D12Resource (resource );
352
+
353
+ TRACE ("iface %p, resource %p, state %#x.\n" , iface , resource , state );
354
+
355
+ * vk_layout = vk_image_layout_from_d3d12_resource_state (NULL , resource_impl , state );
356
+ }
357
+
358
+ static HRESULT STDMETHODCALLTYPE d3d12_dxvk_interop_device_GetVulkanResourceInfo (ID3D12DXVKInteropDevice * iface ,
359
+ ID3D12Resource * resource , UINT64 * vk_handle , UINT64 * buffer_offset )
360
+ {
361
+ struct d3d12_resource * resource_impl = impl_from_ID3D12Resource (resource );
362
+
363
+ TRACE ("iface %p, resource %p, vk_handle %p.\n" , iface , resource , vk_handle );
364
+
365
+ if (resource_impl -> desc .Dimension == D3D12_RESOURCE_DIMENSION_BUFFER )
366
+ {
367
+ * vk_handle = (UINT64 )resource_impl -> res .vk_buffer ;
368
+ * buffer_offset = (UINT64 )resource_impl -> mem .offset ;
369
+ }
370
+ else
371
+ {
372
+ * vk_handle = (UINT64 )resource_impl -> res .vk_image ;
373
+ * buffer_offset = 0 ;
374
+ }
375
+
376
+ return S_OK ;
377
+ }
378
+
379
+ static HRESULT STDMETHODCALLTYPE d3d12_dxvk_interop_device_LockCommandQueue (ID3D12DXVKInteropDevice * iface , ID3D12CommandQueue * queue )
380
+ {
381
+ struct d3d12_device * device = d3d12_device_from_ID3D12DXVKInteropDevice (iface );
382
+
383
+ TRACE ("iface %p, queue %p.\n" , iface , queue );
384
+
385
+ /* Flushing the transfer queue adds a wait to all other queues, and the
386
+ * acquire operation will drain the queue, ensuring that any pending clear
387
+ * or upload happens before D3D11 submissions on the GPU timeline. */
388
+ vkd3d_memory_transfer_queue_flush (& device -> memory_transfers );
389
+ vkd3d_acquire_vk_queue (queue );
390
+ return S_OK ;
391
+ }
392
+
393
+ static HRESULT STDMETHODCALLTYPE d3d12_dxvk_interop_device_UnlockCommandQueue (ID3D12DXVKInteropDevice * iface , ID3D12CommandQueue * queue )
394
+ {
395
+ TRACE ("iface %p, queue %p.\n" , iface , queue );
396
+
397
+ vkd3d_release_vk_queue (queue );
398
+ return S_OK ;
399
+ }
400
+
401
+ CONST_VTBL struct ID3D12DXVKInteropDeviceVtbl d3d12_dxvk_interop_device_vtbl =
402
+ {
403
+ /* IUnknown methods */
404
+ d3d12_dxvk_interop_device_QueryInterface ,
405
+ d3d12_dxvk_interop_device_AddRef ,
406
+ d3d12_dxvk_interop_device_Release ,
407
+
408
+ /* ID3D12DXVKInteropDevice methods */
409
+ d3d12_dxvk_interop_device_GetDXGIAdapter ,
410
+ d3d12_dxvk_interop_device_GetInstanceExtensions ,
411
+ d3d12_dxvk_interop_device_GetDeviceExtensions ,
412
+ d3d12_dxvk_interop_device_GetDeviceFeatures ,
413
+ d3d12_dxvk_interop_device_GetVulkanHandles ,
414
+ d3d12_dxvk_interop_device_GetVulkanQueueInfo ,
415
+ d3d12_dxvk_interop_device_GetVulkanImageLayout ,
416
+ d3d12_dxvk_interop_device_GetVulkanResourceInfo ,
417
+ d3d12_dxvk_interop_device_LockCommandQueue ,
418
+ d3d12_dxvk_interop_device_UnlockCommandQueue ,
419
+ };
0 commit comments