Skip to content

Commit

Permalink
[VP] Enable bindless suface state mode
Browse files Browse the repository at this point in the history
Enable bindless suface state mode for perf
  • Loading branch information
kchen1024 authored and intel-mediadev committed Jul 15, 2024
1 parent 00848c9 commit 3919a5b
Show file tree
Hide file tree
Showing 9 changed files with 560 additions and 72 deletions.
1 change: 1 addition & 0 deletions media_common/agnostic/common/renderhal/media_srcs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
set(TMP_HEADERS_
${CMAKE_CURRENT_LIST_DIR}/renderhal.h
${CMAKE_CURRENT_LIST_DIR}/renderhal_platform_interface.h
${CMAKE_CURRENT_LIST_DIR}/surface_state_heap_mgr.h
)

set(SOFTLET_COMMON_HEADERS_
Expand Down
10 changes: 9 additions & 1 deletion media_common/agnostic/common/renderhal/renderhal.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "media_perf_profiler.h"
#include "frame_tracker.h"
#include "media_common_defs.h"
#include "surface_state_heap_mgr.h"

class XRenderHal_Platform_Interface;

Expand Down Expand Up @@ -966,7 +967,7 @@ typedef struct _RENDERHAL_STATE_HEAP
RENDERHAL_KRN_ALLOC_LIST KernelAllocationPool; // Pool of kernel allocation objects
RENDERHAL_KRN_ALLOC_LIST KernelsSubmitted; // Kernel submission list
RENDERHAL_KRN_ALLOC_LIST KernelsAllocated; // kernel allocation list (kernels in ISH not currently being executed)

SurfaceStateHeapManager *surfaceStateMgr; // Surface state manager
} RENDERHAL_STATE_HEAP, *PRENDERHAL_STATE_HEAP;

typedef struct _RENDERHAL_DYNAMIC_MEDIA_STATE_PARAMS
Expand Down Expand Up @@ -1371,6 +1372,13 @@ typedef struct _RENDERHAL_INTERFACE
PRENDERHAL_INTERFACE pRenderHal,
int32_t *piBindingTable);

MOS_STATUS (* pfnAssignBindlessSurfaceStates) (
PRENDERHAL_INTERFACE pRenderHal);

MOS_STATUS (*pfnSendBindlessSurfaceStates) (
PRENDERHAL_INTERFACE pRenderHal,
bool bNeedNullPatch);

MOS_STATUS (* pfnBindSurfaceState) (
PRENDERHAL_INTERFACE pRenderHal,
int32_t iBindingTableIndex,
Expand Down
97 changes: 97 additions & 0 deletions media_common/agnostic/common/renderhal/surface_state_heap_mgr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* Copyright (c) 2024, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
//!
//! \file surface_state_heap_mgr.h
//! \brief Render Engine Interfaces shared across platforms
//! \details Platform Independent Hardware Interfaces
//!
#ifndef __SURFACE_STATE_HEAP_MGR_H__
#define __SURFACE_STATE_HEAP_MGR_H__

#include <iostream>
#include "mos_os.h"
#include "mhw_utilities.h"
#include "mos_os_specific.h"
#include "mos_interface.h"
#include<vector>

#define MAX_SURFACE_STATES 512
using SURF_STATES_LIST = std::vector<int32_t>;
//!
//! \brief Default size of area for sync, debugging, performance collecting
//!
#define SYNC_SIZE 128 // range: (128 ... 4096)

//!
//! \brief VEBOX Heap State Structure
//!
typedef struct _SURFACE_STATES_OBJ
{
bool bBusy; // true if the state is in use (must sync before use)
uint32_t dwSyncTag; // surface heap state sync tag
} SURFACE_STATES_OBJ, *PSURFACE_STATES_OBJ;

typedef struct _SURFACE_STATES_HEAP_OBJ
{
uint32_t uiCurState; // Current surface State
uint32_t uiNextState; // Next surface State
uint32_t uiOffsetSync; // Offset of sync data in Heap
uint32_t uiInstanceSize; // Size of single instance
uint32_t uiStateHeapSize; // Total size of Surface States heap
PSURFACE_STATES_OBJ pSurfStateObj; // Array of SURFACE_STATES_SYNC_OBJ
MOS_RESOURCE osResource; // Graphics memory
uint8_t *pLockedOsResourceMem; // Locked resource memory

// Synchronization
volatile uint32_t *pSync; // Pointer to sync area (when locked)
uint32_t dwNextTag; // Next sync tag value to use
uint32_t dwSyncTag; // Last sync tag completed
} SURFACE_STATES_HEAP_OBJ, *PSURFACE_STATES_HEAP_OBJ;

class SurfaceStateHeapManager
{
public:
SurfaceStateHeapManager(PMOS_INTERFACE pOsInterface);
MOS_STATUS CreateHeap(size_t surfStateSize);

void RefreshSync();

MOS_STATUS DestroyHeap();

MOS_STATUS AssignSurfaceState();

MOS_STATUS AssignUsedSurfaceState(int32_t index)
{
m_usedStates.push_back(index);
return MOS_STATUS_SUCCESS;
}

~SurfaceStateHeapManager();

public:
PMOS_INTERFACE m_osInterface = nullptr;
SURFACE_STATES_HEAP_OBJ *m_surfStateHeap = nullptr;
int m_surfHeapInUse = 0;
SURF_STATES_LIST m_usedStates = {};
};

#endif // __SURFACE_STATE_HEAP_MGR_H__
7 changes: 7 additions & 0 deletions media_driver/linux/common/renderhal/renderhal_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ MOS_STATUS RenderHal_SendSurfaces_PatchList(
pOsInterface = pRenderHal->pOsInterface;
iSurfacesPerBT = pRenderHal->StateHeapSettings.iSurfacesPerBT;

if (pRenderHal->isBindlessHeapInUse)
{
bool bNeedNullPatch = MEDIA_IS_SKU(pOsInterface->pfnGetSkuTable(pOsInterface), FtrMediaPatchless);
MHW_RENDERHAL_CHK_STATUS_RETURN(pRenderHal->pfnSendBindlessSurfaceStates(pRenderHal, bNeedNullPatch));
return MOS_STATUS_SUCCESS;
}

// Get offset and size of indirect state in command buffer
MHW_RENDERHAL_CHK_STATUS(pOsInterface->pfnGetIndirectState(pOsInterface, &IndirectStateBase, &IndirectStateSize));
pIndirectState = (uint8_t*)pCmdBuffer->pCmdBase + IndirectStateBase;
Expand Down
2 changes: 1 addition & 1 deletion media_softlet/agnostic/common/renderhal/media_srcs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
set(TMP_SOURCES_
${CMAKE_CURRENT_LIST_DIR}/renderhal.cpp
${CMAKE_CURRENT_LIST_DIR}/renderhal_platform_interface_next.cpp
${CMAKE_CURRENT_LIST_DIR}/surface_state_heap_mgr.cpp
)

set(TMP_HEADERS
${CMAKE_CURRENT_LIST_DIR}/renderhal_platform_interface_next.h
${CMAKE_CURRENT_LIST_DIR}/hal_oca_interface_next.h

)


Expand Down
Loading

0 comments on commit 3919a5b

Please sign in to comment.