From ca3ba3f924fa81ad8cfabb44212296bb38b575a4 Mon Sep 17 00:00:00 2001 From: Silvio Vilerino Date: Wed, 22 Oct 2025 14:23:48 -0400 Subject: [PATCH] mediafoundation: Remove unused AllocatePipeResourceFromAllocator Reviewed-by: Pohsiang (John) Hsu Part-of: --- .../mediafoundation/mfbufferhelp.cpp | 55 ------------------- .../frontends/mediafoundation/mfbufferhelp.h | 5 -- 2 files changed, 60 deletions(-) diff --git a/src/gallium/frontends/mediafoundation/mfbufferhelp.cpp b/src/gallium/frontends/mediafoundation/mfbufferhelp.cpp index 234c107e5bd..d2cf256322f 100644 --- a/src/gallium/frontends/mediafoundation/mfbufferhelp.cpp +++ b/src/gallium/frontends/mediafoundation/mfbufferhelp.cpp @@ -343,58 +343,3 @@ MFAttachPipeResourceAsSampleExtension( struct pipe_context *pPipeContext, return pSample->SetUnknown( guidExtension, spMediaBuffer.Get() ); } - -// Helper to convert the allocated IMFSample to pipe_resource* -// Returns NULL on failure. -struct pipe_resource * -AllocatePipeResourceFromAllocator( IMFVideoSampleAllocatorEx *pAllocator, - struct pipe_screen *pScreen, - const struct pipe_resource *templ ) -{ - if( !pAllocator || !pScreen || !templ ) - return nullptr; - - // Allocate or get a sample from the pool. - ComPtr spSample; - HRESULT hr = pAllocator->AllocateSample( &spSample ); - if( FAILED( hr ) || !spSample ) - return nullptr; - - // Get the underlying D3D12 resource from the sample - ComPtr spBuffer; - hr = spSample->GetBufferByIndex( 0, &spBuffer ); - if( FAILED( hr ) || !spBuffer ) - return nullptr; - - ComPtr spDXGIBuffer; - hr = spBuffer.As( &spDXGIBuffer ); - if( FAILED( hr ) || !spDXGIBuffer ) - return nullptr; - - ComPtr spResource; - hr = spDXGIBuffer->GetResource( IID_PPV_ARGS( &spResource ) ); - if( FAILED( hr ) || !spResource ) - return nullptr; - - // Build winsys_handle - struct winsys_handle whandle = {}; - whandle.type = WINSYS_HANDLE_TYPE_D3D12_RES; - whandle.com_obj = spResource.Detach(); - // templ->format contains the desired pipe_format - whandle.format = templ->format; - - // Call resource_from_handle with the same templ for resource_create. - struct pipe_resource *pres = pScreen->resource_from_handle( pScreen, templ, &whandle, PIPE_USAGE_DEFAULT ); - - if( !pres ) - { - // Release the detached COM object if resource_from_handle fails - if( whandle.com_obj ) - { - static_cast( whandle.com_obj )->Release(); - } - return nullptr; - } - - return pres; -} diff --git a/src/gallium/frontends/mediafoundation/mfbufferhelp.h b/src/gallium/frontends/mediafoundation/mfbufferhelp.h index e49240e44fe..71a365be949 100644 --- a/src/gallium/frontends/mediafoundation/mfbufferhelp.h +++ b/src/gallium/frontends/mediafoundation/mfbufferhelp.h @@ -54,8 +54,3 @@ MFAttachPipeResourceAsSampleExtension( struct pipe_context *pPipeContext, ID3D12CommandQueue *pSyncObjectQueue, REFGUID guidExtension, IMFSample *pSample ); - -struct pipe_resource * -AllocatePipeResourceFromAllocator( IMFVideoSampleAllocatorEx *pAllocator, - struct pipe_screen *pScreen, - const struct pipe_resource *templ );