mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 07:14:10 +08:00
Helper method to check if allocation is compressed
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
7b55d38e34
commit
55959d4d1d
@@ -387,9 +387,8 @@ Buffer *Buffer::create(Context *context,
|
||||
pBuffer->setHostPtrMinSize(size);
|
||||
|
||||
if (allocationInfo[rootDeviceIndex].copyMemoryFromHostPtr && !copyExecuted) {
|
||||
auto gmm = allocationInfo[rootDeviceIndex].memory->getDefaultGmm();
|
||||
auto isLocalMemory = !MemoryPool::isSystemMemoryPool(allocationInfo[rootDeviceIndex].memory->getMemoryPool());
|
||||
bool gpuCopyRequired = (gmm && gmm->isCompressionEnabled) || isLocalMemory;
|
||||
bool gpuCopyRequired = (allocationInfo[rootDeviceIndex].memory->isCompressionEnabled()) || isLocalMemory;
|
||||
|
||||
if (gpuCopyRequired) {
|
||||
auto &device = pBuffer->getContext()->getDevice(0u)->getDevice();
|
||||
|
||||
@@ -387,12 +387,10 @@ Image *Image::create(Context *context,
|
||||
auto &hwInfo = *memoryManager->peekExecutionEnvironment().rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo();
|
||||
|
||||
if (context->isProvidingPerformanceHints() && HwHelper::renderCompressedImagesSupported(hwInfo)) {
|
||||
if (allocationInfo[rootDeviceIndex].memory->getDefaultGmm()) {
|
||||
if (allocationInfo[rootDeviceIndex].memory->getDefaultGmm()->isCompressionEnabled) {
|
||||
context->providePerformanceHint(CL_CONTEXT_DIAGNOSTICS_LEVEL_NEUTRAL_INTEL, IMAGE_IS_COMPRESSED, image);
|
||||
} else {
|
||||
context->providePerformanceHint(CL_CONTEXT_DIAGNOSTICS_LEVEL_NEUTRAL_INTEL, IMAGE_IS_NOT_COMPRESSED, image);
|
||||
}
|
||||
if (allocationInfo[rootDeviceIndex].memory->isCompressionEnabled()) {
|
||||
context->providePerformanceHint(CL_CONTEXT_DIAGNOSTICS_LEVEL_NEUTRAL_INTEL, IMAGE_IS_COMPRESSED, image);
|
||||
} else {
|
||||
context->providePerformanceHint(CL_CONTEXT_DIAGNOSTICS_LEVEL_NEUTRAL_INTEL, IMAGE_IS_NOT_COMPRESSED, image);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ void ImageHw<GfxFamily>::setImageArg(void *memory, bool setAsMediaBlockImage, ui
|
||||
|
||||
if (imageDesc.num_samples > 1) {
|
||||
setAuxParamsForMultisamples(surfaceState);
|
||||
} else if (gmm && gmm->isCompressionEnabled) {
|
||||
} else if (graphicsAllocation->isCompressionEnabled()) {
|
||||
EncodeSurfaceState<GfxFamily>::setImageAuxParamsForCCS(surfaceState, gmm);
|
||||
} else {
|
||||
EncodeSurfaceState<GfxFamily>::disableCompressionFlags(surfaceState);
|
||||
|
||||
@@ -418,8 +418,7 @@ bool MemObj::isTiledAllocation() const {
|
||||
bool MemObj::mappingOnCpuAllowed() const {
|
||||
auto graphicsAllocation = multiGraphicsAllocation.getDefaultGraphicsAllocation();
|
||||
return !isTiledAllocation() && !peekSharingHandler() && !isMipMapped(this) && !DebugManager.flags.DisableZeroCopyForBuffers.get() &&
|
||||
!(graphicsAllocation->getDefaultGmm() && graphicsAllocation->getDefaultGmm()->isCompressionEnabled) &&
|
||||
MemoryPool::isSystemMemoryPool(graphicsAllocation->getMemoryPool());
|
||||
!graphicsAllocation->isCompressionEnabled() && MemoryPool::isSystemMemoryPool(graphicsAllocation->getMemoryPool());
|
||||
}
|
||||
|
||||
void MemObj::storeProperties(const cl_mem_properties *properties) {
|
||||
|
||||
@@ -774,63 +774,6 @@ TEST_F(PerformanceHintTest, givenCompressedImageWhenItsCreatedThenProperPerforma
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(PerformanceHintTest, givenImageWithNoGmmWhenItsCreatedThenNoPerformanceHintIsProvided) {
|
||||
HardwareInfo hwInfo = context->getDevice(0)->getHardwareInfo();
|
||||
hwInfo.capabilityTable.ftrRenderCompressedImages = true;
|
||||
|
||||
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo));
|
||||
cl_device_id deviceId = device.get();
|
||||
|
||||
cl_context_properties validProperties[3] = {CL_CONTEXT_SHOW_DIAGNOSTICS_INTEL, CL_CONTEXT_DIAGNOSTICS_LEVEL_ALL_INTEL, 0};
|
||||
auto context = std::unique_ptr<MockContext>(Context::create<NEO::MockContext>(validProperties, ClDeviceVector(&deviceId, 1), callbackFunction, static_cast<void *>(userData), retVal));
|
||||
|
||||
const size_t width = 5;
|
||||
const size_t height = 3;
|
||||
const size_t depth = 2;
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
auto const elementSize = 4;
|
||||
char *hostPtr = static_cast<char *>(alignedMalloc(width * height * depth * elementSize * 2, 64));
|
||||
|
||||
cl_image_format imageFormat;
|
||||
cl_image_desc imageDesc;
|
||||
|
||||
auto mockBuffer = std::unique_ptr<MockBuffer>(new MockBuffer());
|
||||
cl_mem mem = mockBuffer.get();
|
||||
|
||||
imageFormat.image_channel_data_type = CL_UNORM_INT8;
|
||||
imageFormat.image_channel_order = CL_RGBA;
|
||||
imageDesc.num_mip_levels = 0;
|
||||
imageDesc.num_samples = 0;
|
||||
imageDesc.mem_object = mem;
|
||||
imageDesc.image_type = CL_MEM_OBJECT_IMAGE1D_BUFFER;
|
||||
imageDesc.image_width = width;
|
||||
imageDesc.image_height = 0;
|
||||
imageDesc.image_depth = 0;
|
||||
imageDesc.image_array_size = 0;
|
||||
imageDesc.image_row_pitch = 0;
|
||||
imageDesc.image_slice_pitch = 0;
|
||||
|
||||
cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR;
|
||||
auto surfaceFormat = Image::getSurfaceFormatFromTable(flags, &imageFormat, context->getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features);
|
||||
|
||||
auto image = std::unique_ptr<Image>(Image::create(
|
||||
context.get(),
|
||||
ClMemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context->getDevice(0)->getDevice()),
|
||||
flags,
|
||||
0,
|
||||
surfaceFormat,
|
||||
&imageDesc,
|
||||
hostPtr,
|
||||
retVal));
|
||||
|
||||
snprintf(expectedHint, DriverDiagnostics::maxHintStringSize, DriverDiagnostics::hintFormat[IMAGE_IS_COMPRESSED], image.get());
|
||||
EXPECT_FALSE(containsHint(expectedHint, userData));
|
||||
snprintf(expectedHint, DriverDiagnostics::maxHintStringSize, DriverDiagnostics::hintFormat[IMAGE_IS_NOT_COMPRESSED], image.get());
|
||||
EXPECT_FALSE(containsHint(expectedHint, userData));
|
||||
|
||||
alignedFree(hostPtr);
|
||||
}
|
||||
|
||||
TEST_F(PerformanceHintTest, givenUncompressedImageWhenItsCreatedThenProperPerformanceHintIsProvided) {
|
||||
HardwareInfo hwInfo = context->getDevice(0)->getHardwareInfo();
|
||||
hwInfo.capabilityTable.ftrRenderCompressedImages = true;
|
||||
|
||||
Reference in New Issue
Block a user