Extended format support in VA sharing

- enabled with Debug Variable
- allow P010 surface sharing

Related-To: NEO-3049

Change-Id: I837d9f2e31a4ea2a9cf763430021929222cf3001
Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2019-04-18 20:01:05 +02:00
committed by sys_ocldev
parent 445ee08ace
commit 4733e51770
9 changed files with 115 additions and 10 deletions

View File

@@ -179,7 +179,7 @@ void Gmm::queryImageParams(ImageInfo &imgInfo) {
imgInfo.offset = reqOffsetInfo.Render.Offset;
}
if (imgInfo.surfaceFormat->GMMSurfaceFormat == GMM_FORMAT_NV12) {
if (imgInfo.surfaceFormat->GMMSurfaceFormat == GMM_RESOURCE_FORMAT::GMM_FORMAT_NV12 || imgInfo.surfaceFormat->GMMSurfaceFormat == GMM_RESOURCE_FORMAT::GMM_FORMAT_P010) {
GMM_REQ_OFFSET_INFO reqOffsetInfo = {};
reqOffsetInfo.ReqLock = 1;
reqOffsetInfo.Slice = 1;

View File

@@ -182,7 +182,6 @@ const SurfaceFormatInfo SurfaceFormats::planarYuvSurfaceFormats[] = {
{{CL_NV12_INTEL, CL_UNORM_INT8}, GMM_FORMAT_NV12, GFX3DSTATE_SURFACEFORMAT_NV12 , 0, 1, 1, 1}
};
#endif
const SurfaceFormatInfo SurfaceFormats::readOnlyDepthSurfaceFormats[] = {

View File

@@ -96,6 +96,7 @@ DECLARE_DEBUG_VARIABLE(bool, EnableForcePin, true, "Enables early pinning for me
DECLARE_DEBUG_VARIABLE(bool, EnableComputeWorkSizeND, true, "Enables diffrent algorithm to compute local work size")
DECLARE_DEBUG_VARIABLE(bool, EnableComputeWorkSizeSquared, false, "Enables algorithm to compute the most squared work group as possible")
DECLARE_DEBUG_VARIABLE(bool, EnableVaLibCalls, true, "Enable cl-va sharing lib calls")
DECLARE_DEBUG_VARIABLE(bool, EnableExtendedVaFormats, false, "Enable more formats in cl-va sharing")
DECLARE_DEBUG_VARIABLE(bool, AddClGlSharing, false, "Add cl-gl extension")
DECLARE_DEBUG_VARIABLE(bool, EnablePassInlineData, false, "Enable passing of inline data")
DECLARE_DEBUG_VARIABLE(int32_t, EnableCacheFlushAfterWalker, 0, "-1: platform behavior, 0: disabled, 1: enabled. Adds dedicated cache flush command after WALKER command when surfaces used by kernel require to flush the cache")

View File

@@ -26,9 +26,8 @@ Image *VASurface::createSharedVaSurface(Context *context, VASharingFunctions *sh
VAImage vaImage = {};
cl_image_desc imgDesc = {};
cl_image_format gmmImgFormat = {CL_NV12_INTEL, CL_UNORM_INT8};
cl_image_format imgFormat = {};
const SurfaceFormatInfo *gmmSurfaceFormat = nullptr;
const SurfaceFormatInfo *imgSurfaceFormat = nullptr;
cl_channel_order channelOrder = CL_RG;
cl_channel_type channelType = CL_UNORM_INT8;
ImageInfo imgInfo = {0};
VAImageID imageId = 0;
McsSurfaceInfo mcsSurfaceInfo = {};
@@ -40,20 +39,27 @@ Image *VASurface::createSharedVaSurface(Context *context, VASharingFunctions *sh
imgDesc.image_width = vaImage.width;
imgDesc.image_height = vaImage.height;
imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
gmmSurfaceFormat = Image::getSurfaceFormatFromTable(flags, &gmmImgFormat);
imgInfo.surfaceFormat = gmmSurfaceFormat;
if (plane == 0) {
imgInfo.plane = GMM_PLANE_Y;
imgFormat = {CL_R, CL_UNORM_INT8};
channelOrder = CL_R;
} else if (plane == 1) {
imgInfo.plane = GMM_PLANE_U;
imgFormat = {CL_RG, CL_UNORM_INT8};
channelOrder = CL_RG;
} else {
UNRECOVERABLE_IF(true);
}
imgSurfaceFormat = Image::getSurfaceFormatFromTable(flags, &imgFormat);
auto gmmSurfaceFormat = Image::getSurfaceFormatFromTable(flags, &gmmImgFormat); //vaImage.format.fourcc == VA_FOURCC_NV12
if (DebugManager.flags.EnableExtendedVaFormats.get() && vaImage.format.fourcc == VA_FOURCC_P010) {
channelType = CL_UNORM_INT16;
gmmSurfaceFormat = getExtendedSurfaceFormatInfo(vaImage.format.fourcc);
}
imgInfo.surfaceFormat = gmmSurfaceFormat;
cl_image_format imgFormat = {channelOrder, channelType};
auto imgSurfaceFormat = Image::getSurfaceFormatFromTable(flags, &imgFormat);
sharingFunctions->extGetSurfaceHandle(surface, &sharedHandle);
AllocationProperties properties(false, imgInfo, GraphicsAllocation::AllocationType::SHARED_IMAGE);
@@ -107,4 +113,18 @@ bool VASurface::validate(cl_mem_flags flags, cl_uint plane) {
}
return true;
}
const SurfaceFormatInfo *VASurface::getExtendedSurfaceFormatInfo(uint32_t formatFourCC) {
if (formatFourCC == VA_FOURCC_P010) {
static const SurfaceFormatInfo formatInfo = {{CL_NV12_INTEL, CL_UNORM_INT16},
GMM_RESOURCE_FORMAT::GMM_FORMAT_P010,
static_cast<GFX3DSTATE_SURFACEFORMAT>(NUM_GFX3DSTATE_SURFACEFORMATS), // not used for plane images
0,
1,
2,
2};
return &formatInfo;
}
return nullptr;
}
} // namespace NEO

View File

@@ -24,6 +24,7 @@ class VASurface : VASharing {
void getMemObjectInfo(size_t &paramValueSize, void *&paramValue) override;
static bool validate(cl_mem_flags flags, cl_uint plane);
static const SurfaceFormatInfo *getExtendedSurfaceFormatInfo(uint32_t formatFourCC);
protected:
VASurface(VASharingFunctions *sharingFunctions, VAImageID imageId,