mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-10 07:08:04 +08:00
Refactor ImageInfo 1/n
Change-Id: I1de1a4cca2b089a3cca54ffb1c0488e4c073b904 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
804efc644c
commit
b8c5b2df55
@@ -68,34 +68,34 @@ Gmm::Gmm(GmmClientContext *clientContext, ImageInfo &inputOutputImgInfo, Storage
|
||||
}
|
||||
|
||||
void Gmm::setupImageResourceParams(ImageInfo &imgInfo) {
|
||||
uint64_t imageWidth = static_cast<uint64_t>(imgInfo.imgDesc->image_width);
|
||||
uint64_t imageWidth = static_cast<uint64_t>(imgInfo.imgDesc.image_width);
|
||||
uint32_t imageHeight = 1;
|
||||
uint32_t imageDepth = 1;
|
||||
uint32_t imageCount = 1;
|
||||
|
||||
switch (imgInfo.imgDesc->image_type) {
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
|
||||
switch (imgInfo.imgDesc.image_type) {
|
||||
case ImageType::Image1D:
|
||||
case ImageType::Image1DArray:
|
||||
case ImageType::Image1DBuffer:
|
||||
resourceParams.Type = GMM_RESOURCE_TYPE::RESOURCE_1D;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
case ImageType::Image2D:
|
||||
case ImageType::Image2DArray:
|
||||
resourceParams.Type = GMM_RESOURCE_TYPE::RESOURCE_2D;
|
||||
imageHeight = static_cast<uint32_t>(imgInfo.imgDesc->image_height);
|
||||
imageHeight = static_cast<uint32_t>(imgInfo.imgDesc.image_height);
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
case ImageType::Image3D:
|
||||
resourceParams.Type = GMM_RESOURCE_TYPE::RESOURCE_3D;
|
||||
imageHeight = static_cast<uint32_t>(imgInfo.imgDesc->image_height);
|
||||
imageDepth = static_cast<uint32_t>(imgInfo.imgDesc->image_depth);
|
||||
imageHeight = static_cast<uint32_t>(imgInfo.imgDesc.image_height);
|
||||
imageDepth = static_cast<uint32_t>(imgInfo.imgDesc.image_depth);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (imgInfo.imgDesc->image_type == CL_MEM_OBJECT_IMAGE1D_ARRAY ||
|
||||
imgInfo.imgDesc->image_type == CL_MEM_OBJECT_IMAGE2D_ARRAY) {
|
||||
imageCount = static_cast<uint32_t>(imgInfo.imgDesc->image_array_size);
|
||||
if (imgInfo.imgDesc.image_type == ImageType::Image1DArray ||
|
||||
imgInfo.imgDesc.image_type == ImageType::Image2DArray) {
|
||||
imageCount = static_cast<uint32_t>(imgInfo.imgDesc.image_array_size);
|
||||
}
|
||||
|
||||
resourceParams.Flags.Info.Linear = imgInfo.linearStorage;
|
||||
@@ -113,8 +113,8 @@ void Gmm::setupImageResourceParams(ImageInfo &imgInfo) {
|
||||
resourceParams.ArraySize = imageCount;
|
||||
resourceParams.Flags.Wa.__ForceOtherHVALIGN4 = hwHelper.hvAlign4Required();
|
||||
resourceParams.MaxLod = imgInfo.baseMipLevel + imgInfo.mipCount;
|
||||
if (imgInfo.imgDesc->image_row_pitch && imgInfo.imgDesc->mem_object) {
|
||||
resourceParams.OverridePitch = (uint32_t)imgInfo.imgDesc->image_row_pitch;
|
||||
if (imgInfo.imgDesc.image_row_pitch && imgInfo.imgDesc.from_parent) {
|
||||
resourceParams.OverridePitch = (uint32_t)imgInfo.imgDesc.image_row_pitch;
|
||||
resourceParams.Flags.Info.AllowVirtualPadding = true;
|
||||
}
|
||||
|
||||
@@ -183,25 +183,25 @@ uint32_t Gmm::queryQPitch(GMM_RESOURCE_TYPE resType) {
|
||||
return gmmResourceInfo->getQPitch();
|
||||
}
|
||||
|
||||
void Gmm::updateImgInfoAndDesc(ImageInfo &imgInfo, cl_image_desc &imgDesc, cl_uint arrayIndex) {
|
||||
imgDesc.image_width = gmmResourceInfo->getBaseWidth();
|
||||
imgDesc.image_row_pitch = gmmResourceInfo->getRenderPitch();
|
||||
if (imgDesc.image_row_pitch == 0) {
|
||||
size_t width = alignUp(imgDesc.image_width, gmmResourceInfo->getHAlign());
|
||||
imgDesc.image_row_pitch = width * (gmmResourceInfo->getBitsPerPixel() >> 3);
|
||||
void Gmm::updateImgInfoAndDesc(ImageInfo &imgInfo, cl_uint arrayIndex) {
|
||||
imgInfo.imgDesc.image_width = gmmResourceInfo->getBaseWidth();
|
||||
imgInfo.imgDesc.image_row_pitch = gmmResourceInfo->getRenderPitch();
|
||||
if (imgInfo.imgDesc.image_row_pitch == 0) {
|
||||
size_t width = alignUp(imgInfo.imgDesc.image_width, gmmResourceInfo->getHAlign());
|
||||
imgInfo.imgDesc.image_row_pitch = width * (gmmResourceInfo->getBitsPerPixel() >> 3);
|
||||
}
|
||||
imgDesc.image_height = gmmResourceInfo->getBaseHeight();
|
||||
imgDesc.image_depth = gmmResourceInfo->getBaseDepth();
|
||||
imgDesc.image_array_size = gmmResourceInfo->getArraySize();
|
||||
if (imgDesc.image_depth > 1 || imgDesc.image_array_size > 1) {
|
||||
imgInfo.imgDesc.image_height = gmmResourceInfo->getBaseHeight();
|
||||
imgInfo.imgDesc.image_depth = gmmResourceInfo->getBaseDepth();
|
||||
imgInfo.imgDesc.image_array_size = gmmResourceInfo->getArraySize();
|
||||
if (imgInfo.imgDesc.image_depth > 1 || imgInfo.imgDesc.image_array_size > 1) {
|
||||
GMM_REQ_OFFSET_INFO reqOffsetInfo = {};
|
||||
reqOffsetInfo.Slice = imgDesc.image_depth > 1 ? 1 : 0;
|
||||
reqOffsetInfo.ArrayIndex = imgDesc.image_array_size > 1 ? 1 : 0;
|
||||
reqOffsetInfo.Slice = imgInfo.imgDesc.image_depth > 1 ? 1 : 0;
|
||||
reqOffsetInfo.ArrayIndex = imgInfo.imgDesc.image_array_size > 1 ? 1 : 0;
|
||||
reqOffsetInfo.ReqLock = 1;
|
||||
gmmResourceInfo->getOffset(reqOffsetInfo);
|
||||
imgDesc.image_slice_pitch = static_cast<size_t>(reqOffsetInfo.Lock.Offset);
|
||||
imgInfo.imgDesc.image_slice_pitch = static_cast<size_t>(reqOffsetInfo.Lock.Offset);
|
||||
} else {
|
||||
imgDesc.image_slice_pitch = gmmResourceInfo->getSizeAllocation();
|
||||
imgInfo.imgDesc.image_slice_pitch = gmmResourceInfo->getSizeAllocation();
|
||||
}
|
||||
|
||||
updateOffsetsInImgInfo(imgInfo, arrayIndex);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2019 Intel Corporation
|
||||
* Copyright (C) 2018-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -40,7 +40,7 @@ class Gmm {
|
||||
bool hasMultisampleControlSurface() const;
|
||||
|
||||
uint32_t queryQPitch(GMM_RESOURCE_TYPE resType);
|
||||
void updateImgInfoAndDesc(ImageInfo &imgInfo, cl_image_desc &imgDesc, cl_uint arrayIndex);
|
||||
void updateImgInfoAndDesc(ImageInfo &imgInfo, cl_uint arrayIndex);
|
||||
void updateOffsetsInImgInfo(ImageInfo &imgInfo, cl_uint arrayIndex);
|
||||
uint8_t resourceCopyBlt(void *sys, void *gpu, uint32_t pitch, uint32_t height, unsigned char upload, OCLPlane plane);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -18,12 +18,12 @@ using namespace NEO;
|
||||
|
||||
void GmmTypesConverter::queryImgFromBufferParams(ImageInfo &imgInfo, GraphicsAllocation *gfxAlloc) {
|
||||
// 1D or 2D from buffer
|
||||
if (imgInfo.imgDesc->image_row_pitch > 0) {
|
||||
imgInfo.rowPitch = imgInfo.imgDesc->image_row_pitch;
|
||||
if (imgInfo.imgDesc.image_row_pitch > 0) {
|
||||
imgInfo.rowPitch = imgInfo.imgDesc.image_row_pitch;
|
||||
} else {
|
||||
imgInfo.rowPitch = getValidParam(imgInfo.imgDesc->image_width) * imgInfo.surfaceFormat->ImageElementSizeInBytes;
|
||||
imgInfo.rowPitch = getValidParam(imgInfo.imgDesc.image_width) * imgInfo.surfaceFormat->ImageElementSizeInBytes;
|
||||
}
|
||||
imgInfo.slicePitch = imgInfo.rowPitch * getValidParam(imgInfo.imgDesc->image_height);
|
||||
imgInfo.slicePitch = imgInfo.rowPitch * getValidParam(imgInfo.imgDesc.image_height);
|
||||
imgInfo.size = gfxAlloc->getUnderlyingBufferSize();
|
||||
imgInfo.qPitch = 0;
|
||||
}
|
||||
|
||||
@@ -200,8 +200,31 @@ struct SurfaceFormatInfo {
|
||||
size_t ImageElementSizeInBytes;
|
||||
};
|
||||
|
||||
enum class ImageType {
|
||||
Invalid,
|
||||
Image1D,
|
||||
Image2D,
|
||||
Image3D,
|
||||
Image1DArray,
|
||||
Image2DArray,
|
||||
Image1DBuffer
|
||||
};
|
||||
|
||||
struct ImageDescriptor {
|
||||
ImageType image_type;
|
||||
size_t image_width;
|
||||
size_t image_height;
|
||||
size_t image_depth;
|
||||
size_t image_array_size;
|
||||
size_t image_row_pitch;
|
||||
size_t image_slice_pitch;
|
||||
uint32_t num_mip_levels;
|
||||
uint32_t num_samples;
|
||||
bool from_parent;
|
||||
};
|
||||
|
||||
struct ImageInfo {
|
||||
const cl_image_desc *imgDesc;
|
||||
ImageDescriptor imgDesc;
|
||||
const SurfaceFormatInfo *surfaceFormat;
|
||||
size_t size;
|
||||
size_t rowPitch;
|
||||
|
||||
@@ -137,14 +137,14 @@ Image *Image::create(Context *context,
|
||||
size_t hostPtrMinSize = 0;
|
||||
|
||||
cl_image_desc imageDescriptor = *imageDesc;
|
||||
ImageInfo imgInfo = {0};
|
||||
ImageInfo imgInfo = {};
|
||||
void *hostPtrToSet = nullptr;
|
||||
|
||||
if (memoryProperties.flags.useHostPtr) {
|
||||
hostPtrToSet = const_cast<void *>(hostPtr);
|
||||
}
|
||||
|
||||
imgInfo.imgDesc = &imageDescriptor;
|
||||
imgInfo.imgDesc = Image::convertDescriptor(imageDescriptor);
|
||||
imgInfo.surfaceFormat = surfaceFormat;
|
||||
imgInfo.mipCount = imageDesc->num_mip_levels;
|
||||
Gmm *gmm = nullptr;
|
||||
@@ -321,6 +321,7 @@ Image *Image::create(Context *context,
|
||||
imageDescriptor.image_slice_pitch = 0;
|
||||
imageDescriptor.mem_object = imageDesc->mem_object;
|
||||
parentImage->incRefInternal();
|
||||
imgInfo.imgDesc = Image::convertDescriptor(imageDescriptor);
|
||||
}
|
||||
|
||||
image = createImageHw(context, memoryProperties, flags, flagsIntel, imgInfo.size, hostPtrToSet, surfaceFormat->OCLImageFormat,
|
||||
@@ -424,12 +425,12 @@ Image *Image::createSharedImage(Context *context, SharingHandler *sharingHandler
|
||||
GraphicsAllocation *graphicsAllocation, GraphicsAllocation *mcsAllocation,
|
||||
cl_mem_flags flags, ImageInfo &imgInfo, uint32_t cubeFaceIndex, uint32_t baseMipLevel, uint32_t mipCount) {
|
||||
auto sharedImage = createImageHw(context, MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(flags, 0, 0), flags, 0, graphicsAllocation->getUnderlyingBufferSize(),
|
||||
nullptr, imgInfo.surfaceFormat->OCLImageFormat, *imgInfo.imgDesc, false, graphicsAllocation, false, baseMipLevel, mipCount, imgInfo.surfaceFormat);
|
||||
nullptr, imgInfo.surfaceFormat->OCLImageFormat, Image::convertDescriptor(imgInfo.imgDesc), false, graphicsAllocation, false, baseMipLevel, mipCount, imgInfo.surfaceFormat);
|
||||
sharedImage->setSharingHandler(sharingHandler);
|
||||
sharedImage->setMcsAllocation(mcsAllocation);
|
||||
sharedImage->setQPitch(imgInfo.qPitch);
|
||||
sharedImage->setHostPtrRowPitch(imgInfo.imgDesc->image_row_pitch);
|
||||
sharedImage->setHostPtrSlicePitch(imgInfo.imgDesc->image_slice_pitch);
|
||||
sharedImage->setHostPtrRowPitch(imgInfo.imgDesc.image_row_pitch);
|
||||
sharedImage->setHostPtrSlicePitch(imgInfo.imgDesc.image_slice_pitch);
|
||||
sharedImage->setCubeFaceIndex(cubeFaceIndex);
|
||||
sharedImage->setSurfaceOffsets(imgInfo.offset, imgInfo.xOffset, imgInfo.yOffset, imgInfo.yOffsetForUVPlane);
|
||||
sharedImage->setMcsSurfaceInfo(mcsSurfaceInfo);
|
||||
@@ -672,9 +673,9 @@ cl_int Image::getImageParams(Context *context,
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
auto clientContext = context->getDevice(0)->getExecutionEnvironment()->getGmmClientContext();
|
||||
|
||||
ImageInfo imgInfo = {0};
|
||||
ImageInfo imgInfo = {};
|
||||
cl_image_desc imageDescriptor = *imageDesc;
|
||||
imgInfo.imgDesc = &imageDescriptor;
|
||||
imgInfo.imgDesc = Image::convertDescriptor(imageDescriptor);
|
||||
imgInfo.surfaceFormat = surfaceFormat;
|
||||
|
||||
auto gmm = std::make_unique<Gmm>(clientContext, imgInfo, StorageInfo{});
|
||||
@@ -702,25 +703,25 @@ bool Image::isCopyRequired(ImageInfo &imgInfo, const void *hostPtr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t imageWidth = imgInfo.imgDesc->image_width;
|
||||
size_t imageWidth = imgInfo.imgDesc.image_width;
|
||||
size_t imageHeight = 1;
|
||||
size_t imageDepth = 1;
|
||||
size_t imageCount = 1;
|
||||
|
||||
switch (imgInfo.imgDesc->image_type) {
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
imageDepth = imgInfo.imgDesc->image_depth;
|
||||
switch (imgInfo.imgDesc.image_type) {
|
||||
case ImageType::Image3D:
|
||||
imageDepth = imgInfo.imgDesc.image_depth;
|
||||
CPP_ATTRIBUTE_FALLTHROUGH;
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
imageHeight = imgInfo.imgDesc->image_height;
|
||||
case ImageType::Image2D:
|
||||
case ImageType::Image2DArray:
|
||||
imageHeight = imgInfo.imgDesc.image_height;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
auto hostPtrRowPitch = imgInfo.imgDesc->image_row_pitch ? imgInfo.imgDesc->image_row_pitch : imageWidth * imgInfo.surfaceFormat->ImageElementSizeInBytes;
|
||||
auto hostPtrSlicePitch = imgInfo.imgDesc->image_slice_pitch ? imgInfo.imgDesc->image_slice_pitch : hostPtrRowPitch * imgInfo.imgDesc->image_height;
|
||||
auto hostPtrRowPitch = imgInfo.imgDesc.image_row_pitch ? imgInfo.imgDesc.image_row_pitch : imageWidth * imgInfo.surfaceFormat->ImageElementSizeInBytes;
|
||||
auto hostPtrSlicePitch = imgInfo.imgDesc.image_slice_pitch ? imgInfo.imgDesc.image_slice_pitch : hostPtrRowPitch * imgInfo.imgDesc.image_height;
|
||||
|
||||
size_t pointerPassedSize = hostPtrRowPitch * imageHeight * imageDepth * imageCount;
|
||||
auto alignedSizePassedPointer = alignSizeWholePage(const_cast<void *>(hostPtr), pointerPassedSize);
|
||||
@@ -736,6 +737,76 @@ bool Image::isCopyRequired(ImageInfo &imgInfo, const void *hostPtr) {
|
||||
return copyRequired;
|
||||
}
|
||||
|
||||
cl_mem_object_type Image::convertType(const ImageType type) {
|
||||
switch (type) {
|
||||
case ImageType::Image2D:
|
||||
return CL_MEM_OBJECT_IMAGE2D;
|
||||
case ImageType::Image3D:
|
||||
return CL_MEM_OBJECT_IMAGE3D;
|
||||
case ImageType::Image2DArray:
|
||||
return CL_MEM_OBJECT_IMAGE2D_ARRAY;
|
||||
case ImageType::Image1D:
|
||||
return CL_MEM_OBJECT_IMAGE1D;
|
||||
case ImageType::Image1DArray:
|
||||
return CL_MEM_OBJECT_IMAGE1D_ARRAY;
|
||||
case ImageType::Image1DBuffer:
|
||||
return CL_MEM_OBJECT_IMAGE1D_BUFFER;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ImageType Image::convertType(const cl_mem_object_type type) {
|
||||
switch (type) {
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
return ImageType::Image2D;
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
return ImageType::Image3D;
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
return ImageType::Image2DArray;
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
return ImageType::Image1D;
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
return ImageType::Image1DArray;
|
||||
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
|
||||
return ImageType::Image1DBuffer;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ImageType::Invalid;
|
||||
}
|
||||
|
||||
ImageDescriptor Image::convertDescriptor(const cl_image_desc &imageDesc) {
|
||||
ImageDescriptor desc = {};
|
||||
desc.from_parent = imageDesc.mem_object != nullptr;
|
||||
desc.image_array_size = imageDesc.image_array_size;
|
||||
desc.image_depth = imageDesc.image_depth;
|
||||
desc.image_height = imageDesc.image_height;
|
||||
desc.image_row_pitch = imageDesc.image_row_pitch;
|
||||
desc.image_slice_pitch = imageDesc.image_slice_pitch;
|
||||
desc.image_type = convertType(imageDesc.image_type);
|
||||
desc.image_width = imageDesc.image_width;
|
||||
desc.num_mip_levels = imageDesc.num_mip_levels;
|
||||
desc.num_samples = imageDesc.num_samples;
|
||||
return desc;
|
||||
}
|
||||
|
||||
cl_image_desc Image::convertDescriptor(const ImageDescriptor &imageDesc) {
|
||||
cl_image_desc desc = {};
|
||||
desc.mem_object = nullptr;
|
||||
desc.image_array_size = imageDesc.image_array_size;
|
||||
desc.image_depth = imageDesc.image_depth;
|
||||
desc.image_height = imageDesc.image_height;
|
||||
desc.image_row_pitch = imageDesc.image_row_pitch;
|
||||
desc.image_slice_pitch = imageDesc.image_slice_pitch;
|
||||
desc.image_type = convertType(imageDesc.image_type);
|
||||
desc.image_width = imageDesc.image_width;
|
||||
desc.num_mip_levels = imageDesc.num_mip_levels;
|
||||
desc.num_samples = imageDesc.num_samples;
|
||||
return desc;
|
||||
}
|
||||
|
||||
cl_int Image::getImageInfo(cl_image_info paramName,
|
||||
size_t paramValueSize,
|
||||
void *paramValue,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2019 Intel Corporation
|
||||
* Copyright (C) 2018-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -120,6 +120,11 @@ class Image : public MemObj {
|
||||
|
||||
static bool isCopyRequired(ImageInfo &imgInfo, const void *hostPtr);
|
||||
|
||||
static ImageType convertType(const cl_mem_object_type type);
|
||||
static cl_mem_object_type convertType(const ImageType type);
|
||||
static ImageDescriptor convertDescriptor(const cl_image_desc &imageDesc);
|
||||
static cl_image_desc convertDescriptor(const ImageDescriptor &imageDesc);
|
||||
|
||||
cl_int getImageInfo(cl_image_info paramName,
|
||||
size_t paramValueSize,
|
||||
void *paramValue,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -67,15 +67,15 @@ void D3DSharing<D3D>::releaseResource(MemObj *memObject) {
|
||||
}
|
||||
|
||||
template <typename D3D>
|
||||
void D3DSharing<D3D>::updateImgInfoAndDesc(Gmm *gmm, ImageInfo &imgInfo, cl_image_desc &imgDesc, OCLPlane oclPlane, cl_uint arrayIndex) {
|
||||
void D3DSharing<D3D>::updateImgInfoAndDesc(Gmm *gmm, ImageInfo &imgInfo, OCLPlane oclPlane, cl_uint arrayIndex) {
|
||||
|
||||
gmm->updateImgInfoAndDesc(imgInfo, imgDesc, arrayIndex);
|
||||
gmm->updateImgInfoAndDesc(imgInfo, arrayIndex);
|
||||
|
||||
if (oclPlane == OCLPlane::PLANE_U || oclPlane == OCLPlane::PLANE_V || oclPlane == OCLPlane::PLANE_UV) {
|
||||
imgDesc.image_width /= 2;
|
||||
imgDesc.image_height /= 2;
|
||||
imgInfo.imgDesc.image_width /= 2;
|
||||
imgInfo.imgDesc.image_height /= 2;
|
||||
if (oclPlane != OCLPlane::PLANE_UV) {
|
||||
imgDesc.image_row_pitch /= 2;
|
||||
imgInfo.imgDesc.image_row_pitch /= 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -40,7 +40,7 @@ class D3DSharing : public SharingHandler {
|
||||
static bool isFormatWithPlane1(DXGI_FORMAT format);
|
||||
|
||||
protected:
|
||||
static void updateImgInfoAndDesc(Gmm *gmm, ImageInfo &imgInfo, cl_image_desc &imgDesc, OCLPlane oclPlane, cl_uint arrayIndex);
|
||||
static void updateImgInfoAndDesc(Gmm *gmm, ImageInfo &imgInfo, OCLPlane oclPlane, cl_uint arrayIndex);
|
||||
|
||||
Context *context;
|
||||
D3DSharingFunctions<D3D> *sharingFunctions = nullptr;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -35,7 +35,6 @@ Image *D3DSurface::create(Context *context, cl_dx9_surface_info_khr *surfaceInfo
|
||||
cl_dx9_media_adapter_type_khr adapterType, cl_uint plane, cl_int *retCode) {
|
||||
ErrorCodeHelper err(retCode, CL_SUCCESS);
|
||||
D3D9Surface *surfaceStaging = nullptr;
|
||||
cl_image_desc imgDesc = {};
|
||||
ImageInfo imgInfo = {};
|
||||
cl_image_format imgFormat = {};
|
||||
McsSurfaceInfo mcsSurfaceInfo = {};
|
||||
@@ -53,13 +52,12 @@ Image *D3DSurface::create(Context *context, cl_dx9_surface_info_khr *surfaceInfo
|
||||
|
||||
sharingFcns->updateDevice(surfaceInfo->resource);
|
||||
|
||||
imgInfo.imgDesc = &imgDesc;
|
||||
imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
|
||||
imgInfo.imgDesc.image_type = ImageType::Image2D;
|
||||
|
||||
D3D9SurfaceDesc surfaceDesc = {};
|
||||
sharingFcns->getTexture2dDesc(&surfaceDesc, surfaceInfo->resource);
|
||||
imgDesc.image_width = surfaceDesc.Width;
|
||||
imgDesc.image_height = surfaceDesc.Height;
|
||||
imgInfo.imgDesc.image_width = surfaceDesc.Width;
|
||||
imgInfo.imgDesc.image_height = surfaceDesc.Height;
|
||||
|
||||
if (surfaceDesc.Pool != D3DPOOL_DEFAULT) {
|
||||
err.set(CL_INVALID_DX9_RESOURCE_INTEL);
|
||||
@@ -84,15 +82,15 @@ Image *D3DSurface::create(Context *context, cl_dx9_surface_info_khr *surfaceInfo
|
||||
AllocationProperties allocProperties(rootDeviceIndex, false, 0u, GraphicsAllocation::AllocationType::SHARED_IMAGE, false);
|
||||
alloc = context->getMemoryManager()->createGraphicsAllocationFromSharedHandle((osHandle)((UINT_PTR)surfaceInfo->shared_handle), allocProperties,
|
||||
false);
|
||||
updateImgInfoAndDesc(alloc->getDefaultGmm(), imgInfo, imgDesc, oclPlane, 0u);
|
||||
updateImgInfoAndDesc(alloc->getDefaultGmm(), imgInfo, oclPlane, 0u);
|
||||
} else {
|
||||
lockable = !(surfaceDesc.Usage & D3DResourceFlags::USAGE_RENDERTARGET) || oclPlane != OCLPlane::NO_PLANE;
|
||||
if (!lockable) {
|
||||
sharingFcns->createTexture2d(&surfaceStaging, &surfaceDesc, 0u);
|
||||
}
|
||||
if (oclPlane == OCLPlane::PLANE_U || oclPlane == OCLPlane::PLANE_V || oclPlane == OCLPlane::PLANE_UV) {
|
||||
imgDesc.image_width /= 2;
|
||||
imgDesc.image_height /= 2;
|
||||
imgInfo.imgDesc.image_width /= 2;
|
||||
imgInfo.imgDesc.image_height /= 2;
|
||||
}
|
||||
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(flags, 0, 0);
|
||||
AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(rootDeviceIndex, imgInfo, true, memoryProperties);
|
||||
@@ -100,8 +98,8 @@ Image *D3DSurface::create(Context *context, cl_dx9_surface_info_khr *surfaceInfo
|
||||
|
||||
alloc = context->getMemoryManager()->allocateGraphicsMemoryInPreferredPool(allocProperties, nullptr);
|
||||
|
||||
imgDesc.image_row_pitch = imgInfo.rowPitch;
|
||||
imgDesc.image_slice_pitch = imgInfo.slicePitch;
|
||||
imgInfo.imgDesc.image_row_pitch = imgInfo.rowPitch;
|
||||
imgInfo.imgDesc.image_slice_pitch = imgInfo.slicePitch;
|
||||
}
|
||||
DEBUG_BREAK_IF(!alloc);
|
||||
|
||||
|
||||
@@ -29,12 +29,10 @@ Image *D3DTexture<D3D>::create2d(Context *context, D3DTexture2d *d3dTexture, cl_
|
||||
OCLPlane oclPlane = OCLPlane::NO_PLANE;
|
||||
void *sharedHandle = nullptr;
|
||||
cl_uint arrayIndex = 0u;
|
||||
cl_image_desc imgDesc = {};
|
||||
cl_image_format imgFormat = {};
|
||||
McsSurfaceInfo mcsSurfaceInfo = {};
|
||||
ImageInfo imgInfo = {};
|
||||
imgInfo.imgDesc = &imgDesc;
|
||||
imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
|
||||
imgInfo.imgDesc.image_type = ImageType::Image2D;
|
||||
|
||||
D3DTexture2dDesc textureDesc = {};
|
||||
sharingFcns->getTexture2dDesc(&textureDesc, d3dTexture);
|
||||
@@ -77,7 +75,7 @@ Image *D3DTexture<D3D>::create2d(Context *context, D3DTexture2d *d3dTexture, cl_
|
||||
}
|
||||
DEBUG_BREAK_IF(!alloc);
|
||||
|
||||
updateImgInfoAndDesc(alloc->getDefaultGmm(), imgInfo, imgDesc, oclPlane, arrayIndex);
|
||||
updateImgInfoAndDesc(alloc->getDefaultGmm(), imgInfo, oclPlane, arrayIndex);
|
||||
|
||||
auto d3dTextureObj = new D3DTexture<D3D>(context, d3dTexture, subresource, textureStaging, sharedResource);
|
||||
|
||||
@@ -102,12 +100,10 @@ Image *D3DTexture<D3D>::create3d(Context *context, D3DTexture3d *d3dTexture, cl_
|
||||
ErrorCodeHelper err(retCode, CL_SUCCESS);
|
||||
auto sharingFcns = context->getSharing<D3DSharingFunctions<D3D>>();
|
||||
void *sharedHandle = nullptr;
|
||||
cl_image_desc imgDesc = {};
|
||||
cl_image_format imgFormat = {};
|
||||
McsSurfaceInfo mcsSurfaceInfo = {};
|
||||
ImageInfo imgInfo = {};
|
||||
imgInfo.imgDesc = &imgDesc;
|
||||
imgDesc.image_type = CL_MEM_OBJECT_IMAGE3D;
|
||||
imgInfo.imgDesc.image_type = ImageType::Image3D;
|
||||
|
||||
D3DTexture3dDesc textureDesc = {};
|
||||
sharingFcns->getTexture3dDesc(&textureDesc, d3dTexture);
|
||||
@@ -141,7 +137,7 @@ Image *D3DTexture<D3D>::create3d(Context *context, D3DTexture3d *d3dTexture, cl_
|
||||
}
|
||||
DEBUG_BREAK_IF(!alloc);
|
||||
|
||||
updateImgInfoAndDesc(alloc->getDefaultGmm(), imgInfo, imgDesc, OCLPlane::NO_PLANE, 0u);
|
||||
updateImgInfoAndDesc(alloc->getDefaultGmm(), imgInfo, OCLPlane::NO_PLANE, 0u);
|
||||
|
||||
auto d3dTextureObj = new D3DTexture<D3D>(context, d3dTexture, subresource, textureStaging, sharedResource);
|
||||
|
||||
|
||||
@@ -128,15 +128,15 @@ Image *GlTexture::createSharedGlTexture(Context *context, cl_mem_flags flags, cl
|
||||
}
|
||||
mcsSurfaceInfo.multisampleCount = GmmTypesConverter::getRenderMultisamplesCount(static_cast<uint32_t>(imgDesc.num_samples));
|
||||
|
||||
ImageInfo imgInfo = {0};
|
||||
imgInfo.imgDesc = &imgDesc;
|
||||
imgInfo.surfaceFormat = &surfaceFormatInfo;
|
||||
imgInfo.qPitch = qPitch;
|
||||
|
||||
if (miplevel < 0) {
|
||||
imgDesc.num_mip_levels = gmm->gmmResourceInfo->getMaxLod() + 1;
|
||||
}
|
||||
|
||||
ImageInfo imgInfo = {};
|
||||
imgInfo.imgDesc = Image::convertDescriptor(imgDesc);
|
||||
imgInfo.surfaceFormat = &surfaceFormatInfo;
|
||||
imgInfo.qPitch = qPitch;
|
||||
|
||||
auto glTexture = new GlTexture(sharingFunctions, getClGlObjectType(target), texture, texInfo, target, std::max(miplevel, 0));
|
||||
|
||||
auto hwInfo = memoryManager->peekExecutionEnvironment().getHardwareInfo();
|
||||
@@ -147,7 +147,7 @@ Image *GlTexture::createSharedGlTexture(Context *context, cl_mem_flags flags, cl
|
||||
}
|
||||
|
||||
return Image::createSharedImage(context, glTexture, mcsSurfaceInfo, alloc, mcsAlloc, flags, imgInfo, cubeFaceIndex,
|
||||
std::max(miplevel, 0), imgDesc.num_mip_levels);
|
||||
std::max(miplevel, 0), imgInfo.imgDesc.num_mip_levels);
|
||||
} // namespace NEO
|
||||
|
||||
void GlTexture::synchronizeObject(UpdateData &updateData) {
|
||||
|
||||
@@ -25,7 +25,7 @@ Image *UnifiedImage::createSharedUnifiedImage(Context *context, cl_mem_flags fla
|
||||
UnifiedSharingFunctions *sharingFunctions = context->getSharing<UnifiedSharingFunctions>();
|
||||
|
||||
ImageInfo imgInfo = {};
|
||||
imgInfo.imgDesc = imageDesc;
|
||||
imgInfo.imgDesc = Image::convertDescriptor(*imageDesc);
|
||||
imgInfo.surfaceFormat = Image::getSurfaceFormatFromTable(flags, imageFormat);
|
||||
|
||||
GraphicsAllocation *graphicsAllocation = createGraphicsAllocation(context, description);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -27,17 +27,18 @@ Image *VASurface::createSharedVaSurface(Context *context, VASharingFunctions *sh
|
||||
cl_image_format gmmImgFormat = {CL_NV12_INTEL, CL_UNORM_INT8};
|
||||
cl_channel_order channelOrder = CL_RG;
|
||||
cl_channel_type channelType = CL_UNORM_INT8;
|
||||
ImageInfo imgInfo = {0};
|
||||
ImageInfo imgInfo = {};
|
||||
VAImageID imageId = 0;
|
||||
McsSurfaceInfo mcsSurfaceInfo = {};
|
||||
|
||||
sharingFunctions->deriveImage(*surface, &vaImage);
|
||||
|
||||
imageId = vaImage.image_id;
|
||||
imgInfo.imgDesc = &imgDesc;
|
||||
|
||||
imgDesc.image_width = vaImage.width;
|
||||
imgDesc.image_height = vaImage.height;
|
||||
imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
|
||||
imgInfo.imgDesc = Image::convertDescriptor(imgDesc);
|
||||
|
||||
if (plane == 0) {
|
||||
imgInfo.plane = GMM_PLANE_Y;
|
||||
@@ -77,6 +78,7 @@ Image *VASurface::createSharedVaSurface(Context *context, VASharingFunctions *sh
|
||||
imgInfo.xOffset = 0;
|
||||
imgInfo.yOffsetForUVPlane = static_cast<uint32_t>(imgInfo.offset / vaImage.pitches[0]);
|
||||
}
|
||||
imgInfo.imgDesc = Image::convertDescriptor(imgDesc);
|
||||
sharingFunctions->destroyImage(vaImage.image_id);
|
||||
|
||||
auto vaSurface = new VASurface(sharingFunctions, imageId, plane, surface, context->getInteropUserSyncEnabled());
|
||||
|
||||
Reference in New Issue
Block a user