mirror of
https://github.com/intel/compute-runtime.git
synced 2025-11-10 05:49:51 +08:00
Pass MultiGraphicsAllocation in Image
Related-To: NEO-4672 Change-Id: I01c2e7b25cb3448af9520493025569895eb4a155 Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
c05f80643a
commit
47df60c067
@@ -54,7 +54,7 @@ Image::Image(Context *context,
|
||||
cl_image_format imageFormat,
|
||||
const cl_image_desc &imageDesc,
|
||||
bool zeroCopy,
|
||||
GraphicsAllocation *graphicsAllocation,
|
||||
MultiGraphicsAllocation multiGraphicsAllocation,
|
||||
bool isObjectRedescribed,
|
||||
uint32_t baseMipLevel,
|
||||
uint32_t mipCount,
|
||||
@@ -66,9 +66,9 @@ Image::Image(Context *context,
|
||||
flags,
|
||||
flagsIntel,
|
||||
size,
|
||||
graphicsAllocation->getUnderlyingBuffer(),
|
||||
multiGraphicsAllocation.getDefaultGraphicsAllocation()->getUnderlyingBuffer(),
|
||||
hostPtr,
|
||||
graphicsAllocation,
|
||||
multiGraphicsAllocation.getDefaultGraphicsAllocation(),
|
||||
zeroCopy,
|
||||
false,
|
||||
isObjectRedescribed),
|
||||
@@ -347,8 +347,11 @@ Image *Image::create(Context *context,
|
||||
imgInfo.imgDesc = Image::convertDescriptor(imageDescriptor);
|
||||
}
|
||||
|
||||
auto multiGraphicsAllocation = MultiGraphicsAllocation(rootDeviceIndex);
|
||||
multiGraphicsAllocation.addAllocation(memory);
|
||||
|
||||
image = createImageHw(context, memoryProperties, flags, flagsIntel, imgInfo.size, hostPtrToSet, surfaceFormat->OCLImageFormat,
|
||||
imageDescriptor, zeroCopy, memory, false, 0, 0, surfaceFormat);
|
||||
imageDescriptor, zeroCopy, std::move(multiGraphicsAllocation), false, 0, 0, surfaceFormat);
|
||||
|
||||
if (context->isProvidingPerformanceHints() && HwHelper::renderCompressedImagesSupported(context->getDevice(0)->getHardwareInfo())) {
|
||||
if (memory->getDefaultGmm()) {
|
||||
@@ -429,7 +432,7 @@ Image *Image::create(Context *context,
|
||||
|
||||
Image *Image::createImageHw(Context *context, const MemoryProperties &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel, size_t size, void *hostPtr,
|
||||
const cl_image_format &imageFormat, const cl_image_desc &imageDesc,
|
||||
bool zeroCopy, GraphicsAllocation *graphicsAllocation,
|
||||
bool zeroCopy, MultiGraphicsAllocation multiGraphicsAllocation,
|
||||
bool isObjectRedescribed, uint32_t baseMipLevel, uint32_t mipCount,
|
||||
const ClSurfaceFormatInfo *surfaceFormatInfo) {
|
||||
const auto device = context->getDevice(0);
|
||||
@@ -438,21 +441,23 @@ Image *Image::createImageHw(Context *context, const MemoryProperties &memoryProp
|
||||
auto funcCreate = imageFactory[hwInfo.platform.eRenderCoreFamily].createImageFunction;
|
||||
DEBUG_BREAK_IF(nullptr == funcCreate);
|
||||
auto image = funcCreate(context, memoryProperties, flags, flagsIntel, size, hostPtr, imageFormat, imageDesc,
|
||||
zeroCopy, graphicsAllocation, isObjectRedescribed, baseMipLevel, mipCount, surfaceFormatInfo, nullptr);
|
||||
zeroCopy, std::move(multiGraphicsAllocation), isObjectRedescribed, baseMipLevel, mipCount, surfaceFormatInfo, nullptr);
|
||||
DEBUG_BREAK_IF(nullptr == image);
|
||||
image->createFunction = funcCreate;
|
||||
return image;
|
||||
}
|
||||
|
||||
Image *Image::createSharedImage(Context *context, SharingHandler *sharingHandler, const McsSurfaceInfo &mcsSurfaceInfo,
|
||||
GraphicsAllocation *graphicsAllocation, GraphicsAllocation *mcsAllocation,
|
||||
MultiGraphicsAllocation multiGraphicsAllocation, GraphicsAllocation *mcsAllocation,
|
||||
cl_mem_flags flags, cl_mem_flags_intel flagsIntel, const ClSurfaceFormatInfo *surfaceFormat,
|
||||
ImageInfo &imgInfo, uint32_t cubeFaceIndex, uint32_t baseMipLevel, uint32_t mipCount) {
|
||||
auto rootDeviceIndex = context->getDevice(0)->getRootDeviceIndex();
|
||||
auto size = multiGraphicsAllocation.getGraphicsAllocation(rootDeviceIndex)->getUnderlyingBufferSize();
|
||||
auto sharedImage = createImageHw(
|
||||
context, MemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context->getDevice(0)->getDevice()),
|
||||
flags, flagsIntel, graphicsAllocation->getUnderlyingBufferSize(), nullptr,
|
||||
flags, flagsIntel, size, nullptr,
|
||||
surfaceFormat->OCLImageFormat, Image::convertDescriptor(imgInfo.imgDesc), false,
|
||||
graphicsAllocation, false, baseMipLevel, mipCount, surfaceFormat);
|
||||
std::move(multiGraphicsAllocation), false, baseMipLevel, mipCount, surfaceFormat);
|
||||
sharedImage->setSharingHandler(sharingHandler);
|
||||
sharedImage->setMcsAllocation(mcsAllocation);
|
||||
sharedImage->setQPitch(imgInfo.qPitch);
|
||||
@@ -933,7 +938,7 @@ Image *Image::redescribeFillImage() {
|
||||
imageFormatNew,
|
||||
imageDescNew,
|
||||
this->isMemObjZeroCopy(),
|
||||
this->multiGraphicsAllocation.getDefaultGraphicsAllocation(),
|
||||
this->multiGraphicsAllocation,
|
||||
true,
|
||||
this->baseMipLevel,
|
||||
this->mipCount,
|
||||
@@ -990,7 +995,7 @@ Image *Image::redescribe() {
|
||||
imageFormatNew,
|
||||
this->imageDesc,
|
||||
this->isMemObjZeroCopy(),
|
||||
this->multiGraphicsAllocation.getDefaultGraphicsAllocation(),
|
||||
this->multiGraphicsAllocation,
|
||||
true,
|
||||
this->baseMipLevel,
|
||||
this->mipCount,
|
||||
|
||||
@@ -28,7 +28,7 @@ using ImageCreatFunc = Image *(*)(Context *context,
|
||||
const cl_image_format &imageFormat,
|
||||
const cl_image_desc &imageDesc,
|
||||
bool zeroCopy,
|
||||
GraphicsAllocation *graphicsAllocation,
|
||||
MultiGraphicsAllocation multiGraphicsAllocation,
|
||||
bool isImageRedescribed,
|
||||
uint32_t baseMipLevel,
|
||||
uint32_t mipCount,
|
||||
@@ -79,11 +79,11 @@ class Image : public MemObj {
|
||||
static Image *createImageHw(Context *context, const MemoryProperties &memoryProperties, cl_mem_flags flags,
|
||||
cl_mem_flags_intel flagsIntel, size_t size, void *hostPtr,
|
||||
const cl_image_format &imageFormat, const cl_image_desc &imageDesc,
|
||||
bool zeroCopy, GraphicsAllocation *graphicsAllocation,
|
||||
bool zeroCopy, MultiGraphicsAllocation multiGraphicsAllocation,
|
||||
bool isObjectRedescribed, uint32_t baseMipLevel, uint32_t mipCount, const ClSurfaceFormatInfo *surfaceFormatInfo = nullptr);
|
||||
|
||||
static Image *createSharedImage(Context *context, SharingHandler *sharingHandler, const McsSurfaceInfo &mcsSurfaceInfo,
|
||||
GraphicsAllocation *graphicsAllocation, GraphicsAllocation *mcsAllocation,
|
||||
MultiGraphicsAllocation multiGraphicsAllocation, GraphicsAllocation *mcsAllocation,
|
||||
cl_mem_flags flags, cl_mem_flags_intel flagsIntel, const ClSurfaceFormatInfo *surfaceFormat, ImageInfo &imgInfo, uint32_t cubeFaceIndex, uint32_t baseMipLevel, uint32_t mipCount);
|
||||
|
||||
static cl_int validate(Context *context,
|
||||
@@ -209,7 +209,7 @@ class Image : public MemObj {
|
||||
cl_image_format imageFormat,
|
||||
const cl_image_desc &imageDesc,
|
||||
bool zeroCopy,
|
||||
GraphicsAllocation *graphicsAllocation,
|
||||
MultiGraphicsAllocation multiGraphicsAllocation,
|
||||
bool isObjectRedescribed,
|
||||
uint32_t baseMipLevel,
|
||||
uint32_t mipCount,
|
||||
@@ -265,14 +265,14 @@ class ImageHw : public Image {
|
||||
const cl_image_format &imageFormat,
|
||||
const cl_image_desc &imageDesc,
|
||||
bool zeroCopy,
|
||||
GraphicsAllocation *graphicsAllocation,
|
||||
MultiGraphicsAllocation multiGraphicsAllocation,
|
||||
bool isObjectRedescribed,
|
||||
uint32_t baseMipLevel,
|
||||
uint32_t mipCount,
|
||||
const ClSurfaceFormatInfo &surfaceFormatInfo,
|
||||
const SurfaceOffsets *surfaceOffsets = nullptr)
|
||||
: Image(context, memoryProperties, flags, flagsIntel, size, hostPtr, imageFormat, imageDesc,
|
||||
zeroCopy, graphicsAllocation, isObjectRedescribed, baseMipLevel, mipCount, surfaceFormatInfo, surfaceOffsets) {
|
||||
zeroCopy, std::move(multiGraphicsAllocation), isObjectRedescribed, baseMipLevel, mipCount, surfaceFormatInfo, surfaceOffsets) {
|
||||
if (getImageDesc().image_type == CL_MEM_OBJECT_IMAGE1D ||
|
||||
getImageDesc().image_type == CL_MEM_OBJECT_IMAGE1D_BUFFER ||
|
||||
getImageDesc().image_type == CL_MEM_OBJECT_IMAGE2D ||
|
||||
@@ -318,7 +318,7 @@ class ImageHw : public Image {
|
||||
const cl_image_format &imageFormat,
|
||||
const cl_image_desc &imageDesc,
|
||||
bool zeroCopy,
|
||||
GraphicsAllocation *graphicsAllocation,
|
||||
MultiGraphicsAllocation multiGraphicsAllocation,
|
||||
bool isObjectRedescribed,
|
||||
uint32_t baseMipLevel,
|
||||
uint32_t mipCount,
|
||||
@@ -334,7 +334,7 @@ class ImageHw : public Image {
|
||||
imageFormat,
|
||||
imageDesc,
|
||||
zeroCopy,
|
||||
graphicsAllocation,
|
||||
std::move(multiGraphicsAllocation),
|
||||
isObjectRedescribed,
|
||||
baseMipLevel,
|
||||
mipCount,
|
||||
|
||||
@@ -115,8 +115,10 @@ Image *D3DSurface::create(Context *context, cl_dx9_surface_info_khr *surfaceInfo
|
||||
DEBUG_BREAK_IF(!alloc);
|
||||
|
||||
auto surface = new D3DSurface(context, surfaceInfo, surfaceStaging, plane, imagePlane, adapterType, isSharedResource, lockable);
|
||||
auto multiGraphicsAllocation = MultiGraphicsAllocation(rootDeviceIndex);
|
||||
multiGraphicsAllocation.addAllocation(alloc);
|
||||
|
||||
return Image::createSharedImage(context, surface, mcsSurfaceInfo, alloc, nullptr, flags, 0, clSurfaceFormat, imgInfo, __GMM_NO_CUBE_MAP, 0, 0);
|
||||
return Image::createSharedImage(context, surface, mcsSurfaceInfo, std::move(multiGraphicsAllocation), nullptr, flags, 0, clSurfaceFormat, imgInfo, __GMM_NO_CUBE_MAP, 0, 0);
|
||||
}
|
||||
|
||||
void D3DSurface::synchronizeObject(UpdateData &updateData) {
|
||||
|
||||
@@ -101,8 +101,10 @@ Image *D3DTexture<D3D>::create2d(Context *context, D3DTexture2d *d3dTexture, cl_
|
||||
alloc->getDefaultGmm()->isRenderCompressed = hwHelper.isPageTableManagerSupported(*hwInfo) ? memoryManager->mapAuxGpuVA(alloc)
|
||||
: true;
|
||||
}
|
||||
auto multiGraphicsAllocation = MultiGraphicsAllocation(rootDeviceIndex);
|
||||
multiGraphicsAllocation.addAllocation(alloc);
|
||||
|
||||
return Image::createSharedImage(context, d3dTextureObj, mcsSurfaceInfo, alloc, nullptr, flags, 0, clSurfaceFormat, imgInfo, __GMM_NO_CUBE_MAP, 0, 0);
|
||||
return Image::createSharedImage(context, d3dTextureObj, mcsSurfaceInfo, std::move(multiGraphicsAllocation), nullptr, flags, 0, clSurfaceFormat, imgInfo, __GMM_NO_CUBE_MAP, 0, 0);
|
||||
}
|
||||
|
||||
template <typename D3D>
|
||||
@@ -166,8 +168,10 @@ Image *D3DTexture<D3D>::create3d(Context *context, D3DTexture3d *d3dTexture, cl_
|
||||
alloc->getDefaultGmm()->isRenderCompressed = hwHelper.isPageTableManagerSupported(*hwInfo) ? memoryManager->mapAuxGpuVA(alloc)
|
||||
: true;
|
||||
}
|
||||
auto multiGraphicsAllocation = MultiGraphicsAllocation(rootDeviceIndex);
|
||||
multiGraphicsAllocation.addAllocation(alloc);
|
||||
|
||||
return Image::createSharedImage(context, d3dTextureObj, mcsSurfaceInfo, alloc, nullptr, flags, 0, clSurfaceFormat, imgInfo, __GMM_NO_CUBE_MAP, 0, 0);
|
||||
return Image::createSharedImage(context, d3dTextureObj, mcsSurfaceInfo, std::move(multiGraphicsAllocation), nullptr, flags, 0, clSurfaceFormat, imgInfo, __GMM_NO_CUBE_MAP, 0, 0);
|
||||
}
|
||||
|
||||
template <typename D3D>
|
||||
|
||||
@@ -152,8 +152,10 @@ Image *GlTexture::createSharedGlTexture(Context *context, cl_mem_flags flags, cl
|
||||
alloc->getDefaultGmm()->isRenderCompressed = hwHelper.isPageTableManagerSupported(hwInfo) ? memoryManager->mapAuxGpuVA(alloc)
|
||||
: true;
|
||||
}
|
||||
auto multiGraphicsAllocation = MultiGraphicsAllocation(context->getDevice(0)->getRootDeviceIndex());
|
||||
multiGraphicsAllocation.addAllocation(alloc);
|
||||
|
||||
return Image::createSharedImage(context, glTexture, mcsSurfaceInfo, alloc, mcsAlloc, flags, 0, &surfaceFormatInfo, imgInfo, cubeFaceIndex,
|
||||
return Image::createSharedImage(context, glTexture, mcsSurfaceInfo, std::move(multiGraphicsAllocation), mcsAlloc, flags, 0, &surfaceFormatInfo, imgInfo, cubeFaceIndex,
|
||||
std::max(miplevel, 0), imgInfo.imgDesc.numMipLevels);
|
||||
} // namespace NEO
|
||||
|
||||
|
||||
@@ -49,7 +49,10 @@ Image *UnifiedImage::createSharedUnifiedImage(Context *context, cl_mem_flags fla
|
||||
const uint32_t baseMipmapIndex = 0u;
|
||||
const uint32_t sharedMipmapsCount = imageDesc->num_mip_levels;
|
||||
auto sharingHandler = new UnifiedImage(sharingFunctions, description.type);
|
||||
return Image::createSharedImage(context, sharingHandler, McsSurfaceInfo{}, graphicsAllocation, nullptr,
|
||||
auto multiGraphicsAllocation = MultiGraphicsAllocation(context->getDevice(0)->getRootDeviceIndex());
|
||||
multiGraphicsAllocation.addAllocation(graphicsAllocation);
|
||||
|
||||
return Image::createSharedImage(context, sharingHandler, McsSurfaceInfo{}, std::move(multiGraphicsAllocation), nullptr,
|
||||
flags, 0, clSurfaceFormat, imgInfo, __GMM_NO_CUBE_MAP, baseMipmapIndex, sharedMipmapsCount);
|
||||
}
|
||||
|
||||
|
||||
@@ -136,8 +136,10 @@ Image *VASurface::createSharedVaSurface(Context *context, VASharingFunctions *sh
|
||||
}
|
||||
|
||||
auto vaSurface = new VASurface(sharingFunctions, imageId, plane, surface, context->getInteropUserSyncEnabled());
|
||||
auto multiGraphicsAllocation = MultiGraphicsAllocation(context->getDevice(0)->getRootDeviceIndex());
|
||||
multiGraphicsAllocation.addAllocation(alloc);
|
||||
|
||||
auto image = Image::createSharedImage(context, vaSurface, mcsSurfaceInfo, alloc, nullptr, flags, flagsIntel, imgSurfaceFormat, imgInfo, __GMM_NO_CUBE_MAP, 0, 0);
|
||||
auto image = Image::createSharedImage(context, vaSurface, mcsSurfaceInfo, std::move(multiGraphicsAllocation), nullptr, flags, flagsIntel, imgSurfaceFormat, imgInfo, __GMM_NO_CUBE_MAP, 0, 0);
|
||||
image->setMediaPlaneType(plane);
|
||||
return image;
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ HWTEST_F(EnqueueMapImageTest, givenTiledImageWhenMapImageIsCalledThenStorageIsSe
|
||||
imageFormat,
|
||||
imageDesc,
|
||||
false,
|
||||
graphicsAllocation,
|
||||
GraphicsAllocationHelper::toMultiGraphicsAllocation(graphicsAllocation),
|
||||
true,
|
||||
0,
|
||||
0,
|
||||
@@ -927,7 +927,7 @@ TEST_F(EnqueueMapImageTest, givenImage1DArrayWhenEnqueueMapImageIsCalledThenRetu
|
||||
0, nullptr,
|
||||
imageFormat, imageDesc,
|
||||
true,
|
||||
allocation,
|
||||
GraphicsAllocationHelper::toMultiGraphicsAllocation(allocation),
|
||||
false, 0, 0,
|
||||
surfaceFormat, nullptr) {
|
||||
}
|
||||
|
||||
@@ -34,13 +34,13 @@ struct MultipleMapImageTest : public ClDeviceFixture, public ::testing::Test {
|
||||
const cl_image_format &imageFormat,
|
||||
const cl_image_desc &imageDesc,
|
||||
bool zeroCopy,
|
||||
GraphicsAllocation *graphicsAllocation,
|
||||
MultiGraphicsAllocation multiGraphicsAllocation,
|
||||
bool isObjectRedescribed,
|
||||
uint32_t baseMipLevel,
|
||||
uint32_t mipCount,
|
||||
const ClSurfaceFormatInfo *surfaceFormatInfo,
|
||||
const SurfaceOffsets *surfaceOffsets) {
|
||||
return new MockImage<T>(context, memoryProperties, flags, flagsIntel, size, hostPtr, imageFormat, imageDesc, zeroCopy, graphicsAllocation,
|
||||
return new MockImage<T>(context, memoryProperties, flags, flagsIntel, size, hostPtr, imageFormat, imageDesc, zeroCopy, multiGraphicsAllocation,
|
||||
isObjectRedescribed, baseMipLevel, mipCount, *surfaceFormatInfo, surfaceOffsets);
|
||||
};
|
||||
|
||||
|
||||
@@ -280,7 +280,7 @@ HWTEST_F(ImageSetArgTest, givenImageArraySizeGreaterThanOneButTypeIsNotImageArra
|
||||
&context,
|
||||
nullptr,
|
||||
mcsSurfaceInfo,
|
||||
allocation,
|
||||
GraphicsAllocationHelper::toMultiGraphicsAllocation(allocation),
|
||||
nullptr,
|
||||
CL_MEM_READ_WRITE,
|
||||
0,
|
||||
|
||||
@@ -1595,7 +1595,7 @@ HWTEST_F(ImageTransformTest, givenSurfaceBaseAddressAndUnifiedSurfaceWhenSetUnif
|
||||
template <typename FamilyName>
|
||||
class MockImageHw : public ImageHw<FamilyName> {
|
||||
public:
|
||||
MockImageHw(Context *context, const cl_image_format &format, const cl_image_desc &desc, ClSurfaceFormatInfo &surfaceFormatInfo, GraphicsAllocation *graphicsAllocation) : ImageHw<FamilyName>(context, {}, 0, 0, 0, nullptr, format, desc, false, graphicsAllocation, false, 0, 0, surfaceFormatInfo) {
|
||||
MockImageHw(Context *context, const cl_image_format &format, const cl_image_desc &desc, ClSurfaceFormatInfo &surfaceFormatInfo, GraphicsAllocation *graphicsAllocation) : ImageHw<FamilyName>(context, {}, 0, 0, 0, nullptr, format, desc, false, GraphicsAllocationHelper::toMultiGraphicsAllocation(graphicsAllocation), false, 0, 0, surfaceFormatInfo) {
|
||||
}
|
||||
|
||||
void setAuxParamsForMCSCCS(typename FamilyName::RENDER_SURFACE_STATE *surfaceState, Gmm *gmm) override;
|
||||
|
||||
@@ -107,7 +107,7 @@ TEST_P(CreateTiledImageTest, isTiledImageIsSetForSharedImages) {
|
||||
&context,
|
||||
nullptr,
|
||||
msi,
|
||||
alloc,
|
||||
GraphicsAllocationHelper::toMultiGraphicsAllocation(alloc),
|
||||
nullptr,
|
||||
CL_MEM_READ_WRITE,
|
||||
0,
|
||||
@@ -147,7 +147,7 @@ TEST_P(CreateNonTiledImageTest, isTiledImageIsNotSetForNonTiledSharedImage) {
|
||||
&context,
|
||||
nullptr,
|
||||
msi,
|
||||
alloc,
|
||||
GraphicsAllocationHelper::toMultiGraphicsAllocation(alloc),
|
||||
nullptr,
|
||||
CL_MEM_READ_WRITE,
|
||||
0,
|
||||
|
||||
@@ -764,7 +764,7 @@ struct NullImage : public Image {
|
||||
using Image::imageFormat;
|
||||
|
||||
NullImage() : Image(nullptr, MemoryProperties(), cl_mem_flags{}, 0, 0, nullptr, cl_image_format{},
|
||||
cl_image_desc{}, false, new MockGraphicsAllocation(nullptr, 0), false,
|
||||
cl_image_desc{}, false, GraphicsAllocationHelper::toMultiGraphicsAllocation(new MockGraphicsAllocation(nullptr, 0)), false,
|
||||
0, 0, ClSurfaceFormatInfo{}, nullptr) {
|
||||
}
|
||||
~NullImage() override {
|
||||
|
||||
@@ -20,7 +20,7 @@ struct MockImageBase : public Image {
|
||||
|
||||
MockImageBase() : Image(
|
||||
nullptr, MemoryProperties(), cl_mem_flags{}, 0, 0, nullptr, cl_image_format{},
|
||||
cl_image_desc{}, false, new MockGraphicsAllocation(nullptr, 0), false,
|
||||
cl_image_desc{}, false, GraphicsAllocationHelper::toMultiGraphicsAllocation(new MockGraphicsAllocation(nullptr, 0)), false,
|
||||
0, 0, ClSurfaceFormatInfo{}, nullptr),
|
||||
graphicsAllocation(static_cast<MockGraphicsAllocation *>(multiGraphicsAllocation.getGraphicsAllocation(0))) {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user