Skip to content

Commit 4ddf5a1

Browse files
Add debug flag to control RenderCompressed value in HardwareInfo
Change-Id: I733125fbd8596f24cdeb636b69a9198c44bd899b Signed-off-by: Dunajski, Bartosz <[email protected]>
1 parent 6b8d8cb commit 4ddf5a1

File tree

9 files changed

+92
-2
lines changed

9 files changed

+92
-2
lines changed

runtime/helpers/hw_helper.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,27 @@
66
*/
77

88
#include "runtime/helpers/hw_helper.h"
9+
#include "runtime/os_interface/debug_settings_manager.h"
910

1011
namespace OCLRT {
1112
HwHelper *hwHelperFactory[IGFX_MAX_CORE] = {};
1213

1314
HwHelper &HwHelper::get(GFXCORE_FAMILY gfxCore) {
1415
return *hwHelperFactory[gfxCore];
1516
}
17+
18+
bool HwHelper::renderCompressedBuffersSupported(const HardwareInfo &hwInfo) {
19+
if (DebugManager.flags.RenderCompressedBuffersEnabled.get() != -1) {
20+
return !!DebugManager.flags.RenderCompressedBuffersEnabled.get();
21+
}
22+
return hwInfo.capabilityTable.ftrRenderCompressedBuffers;
23+
}
24+
25+
bool HwHelper::renderCompressedImagesSupported(const HardwareInfo &hwInfo) {
26+
if (DebugManager.flags.RenderCompressedImagesEnabled.get() != -1) {
27+
return !!DebugManager.flags.RenderCompressedImagesEnabled.get();
28+
}
29+
return hwInfo.capabilityTable.ftrRenderCompressedImages;
30+
}
31+
1632
} // namespace OCLRT

runtime/helpers/hw_helper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class HwHelper {
3939
virtual bool isPageTableManagerSupported(const HardwareInfo &hwInfo) const = 0;
4040
virtual const AubMemDump::LrcaHelper &getCsTraits(EngineInstanceT engineInstance) const = 0;
4141
virtual bool supportsYTiling() const = 0;
42+
static bool renderCompressedBuffersSupported(const HardwareInfo &hwInfo);
43+
static bool renderCompressedImagesSupported(const HardwareInfo &hwInfo);
4244
virtual bool timestampPacketWriteSupported() const = 0;
4345
virtual size_t getRenderSurfaceStateSize() const = 0;
4446
virtual void setRenderSurfaceStateForBuffer(ExecutionEnvironment &executionEnvironment,

runtime/kernel/kernel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ cl_int Kernel::initialize() {
328328
kernelArguments[i].type = BUFFER_OBJ;
329329
usingBuffers = true;
330330
this->auxTranslationRequired |= !kernelInfo.kernelArgInfo[i].pureStatefulBufferAccess &&
331-
getDevice().getHardwareInfo().capabilityTable.ftrRenderCompressedBuffers;
331+
HwHelper::renderCompressedBuffersSupported(getDevice().getHardwareInfo());
332332
} else if (argInfo.isImage) {
333333
kernelArgHandlers[i] = &Kernel::setArgImage;
334334
kernelArguments[i].type = IMAGE_OBJ;

runtime/mem_obj/buffer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "runtime/gmm_helper/gmm.h"
1414
#include "runtime/gmm_helper/gmm_helper.h"
1515
#include "runtime/helpers/aligned_memory.h"
16+
#include "runtime/helpers/hw_helper.h"
1617
#include "runtime/helpers/hw_info.h"
1718
#include "runtime/helpers/ptr_math.h"
1819
#include "runtime/helpers/string.h"
@@ -129,7 +130,7 @@ Buffer *Buffer::create(Context *context,
129130
GraphicsAllocation::AllocationType allocationType = getGraphicsAllocationType(
130131
properties.flags,
131132
context->isSharedContext,
132-
context->getDevice(0)->getHardwareInfo().capabilityTable.ftrRenderCompressedBuffers);
133+
HwHelper::renderCompressedBuffersSupported(context->getDevice(0)->getHardwareInfo()));
133134

134135
MemoryManager *memoryManager = context->getMemoryManager();
135136
UNRECOVERABLE_IF(!memoryManager);

runtime/os_interface/debug_variables_base.inl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ DECLARE_DEBUG_VARIABLE(int32_t, OverrideDelayQuickKmdSleepForSporadicWaitsMicros
104104
DECLARE_DEBUG_VARIABLE(int32_t, PowerSavingMode, 0, "0: default 1: enable. Whenever driver waits on GPU and its not ready, put waiting thread to sleep and wait for notification.")
105105
DECLARE_DEBUG_VARIABLE(int32_t, CsrDispatchMode, 0, "Chooses DispatchMode for Csr")
106106
DECLARE_DEBUG_VARIABLE(int32_t, OverrideDefaultFP64Settings, -1, "-1: dont override, 0: disable, 1: enable.")
107+
DECLARE_DEBUG_VARIABLE(int32_t, RenderCompressedImagesEnabled, -1, "-1: default, 0: disabled, 1: enabled")
108+
DECLARE_DEBUG_VARIABLE(int32_t, RenderCompressedBuffersEnabled, -1, "-1: default, 0: disabled, 1: enabled")
107109

108110
/*DRIVER TOGGLES*/
109111
DECLARE_DEBUG_VARIABLE(int32_t, ForceOCLVersion, 0, "Force specific OpenCL API version")

unit_tests/helpers/hw_helper_tests.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,37 @@ void HwHelperFixture::TearDown() {
2828
DeviceFixture::TearDown();
2929
}
3030

31+
TEST(HwHelperSimpleTest, givenDebugVariableWhenAskingForRenderCompressionThenReturnCorrectValue) {
32+
DebugManagerStateRestore restore;
33+
HardwareInfo localHwInfo = **platformDevices;
34+
35+
// debug variable not set
36+
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = false;
37+
localHwInfo.capabilityTable.ftrRenderCompressedImages = false;
38+
EXPECT_FALSE(HwHelper::renderCompressedBuffersSupported(localHwInfo));
39+
EXPECT_FALSE(HwHelper::renderCompressedImagesSupported(localHwInfo));
40+
41+
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = true;
42+
localHwInfo.capabilityTable.ftrRenderCompressedImages = true;
43+
EXPECT_TRUE(HwHelper::renderCompressedBuffersSupported(localHwInfo));
44+
EXPECT_TRUE(HwHelper::renderCompressedImagesSupported(localHwInfo));
45+
46+
// debug variable set
47+
DebugManager.flags.RenderCompressedBuffersEnabled.set(1);
48+
DebugManager.flags.RenderCompressedImagesEnabled.set(1);
49+
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = false;
50+
localHwInfo.capabilityTable.ftrRenderCompressedImages = false;
51+
EXPECT_TRUE(HwHelper::renderCompressedBuffersSupported(localHwInfo));
52+
EXPECT_TRUE(HwHelper::renderCompressedImagesSupported(localHwInfo));
53+
54+
DebugManager.flags.RenderCompressedBuffersEnabled.set(0);
55+
DebugManager.flags.RenderCompressedImagesEnabled.set(0);
56+
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = true;
57+
localHwInfo.capabilityTable.ftrRenderCompressedImages = true;
58+
EXPECT_FALSE(HwHelper::renderCompressedBuffersSupported(localHwInfo));
59+
EXPECT_FALSE(HwHelper::renderCompressedImagesSupported(localHwInfo));
60+
}
61+
3162
TEST_F(HwHelperTest, getReturnsValidHwHelperHw) {
3263
auto &helper = HwHelper::get(renderCoreFamily);
3364
EXPECT_NE(nullptr, &helper);

unit_tests/kernel/kernel_tests.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2337,3 +2337,21 @@ TEST(KernelTest, givenFtrRenderCompressedBuffersWhenInitializingArgsWithNonState
23372337
kernel.mockKernel->initialize();
23382338
EXPECT_TRUE(kernel.mockKernel->isAuxTranslationRequired());
23392339
}
2340+
2341+
TEST(KernelTest, givenDebugVariableSetWhenKernelHasStatefulBufferAccessThenMarkKernelForAuxTranslation) {
2342+
DebugManagerStateRestore restore;
2343+
HardwareInfo localHwInfo = *platformDevices[0];
2344+
2345+
DebugManager.flags.RenderCompressedBuffersEnabled.set(1);
2346+
2347+
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&localHwInfo));
2348+
MockKernelWithInternals kernel(*device);
2349+
kernel.kernelInfo.kernelArgInfo.resize(1);
2350+
kernel.kernelInfo.kernelArgInfo.at(0).typeStr = "char *";
2351+
2352+
kernel.kernelInfo.kernelArgInfo.at(0).pureStatefulBufferAccess = false;
2353+
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = false;
2354+
2355+
kernel.mockKernel->initialize();
2356+
EXPECT_TRUE(kernel.mockKernel->isAuxTranslationRequired());
2357+
}

unit_tests/mem_obj/buffer_tests.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,24 @@ TEST_F(RenderCompressedBuffersTests, givenBufferCompressedAllocationWhenSharedCo
473473
EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY);
474474
}
475475

476+
TEST_F(RenderCompressedBuffersTests, givenDebugVariableSetWhenHwFlagIsNotSetThenSelectOptionFromDebugFlag) {
477+
DebugManagerStateRestore restore;
478+
479+
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = false;
480+
481+
DebugManager.flags.RenderCompressedBuffersEnabled.set(1);
482+
buffer.reset(Buffer::create(context.get(), 0, sizeof(uint32_t), nullptr, retVal));
483+
if (is32bit) {
484+
EXPECT_NE(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
485+
} else {
486+
EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
487+
}
488+
489+
DebugManager.flags.RenderCompressedBuffersEnabled.set(0);
490+
buffer.reset(Buffer::create(context.get(), 0, sizeof(uint32_t), nullptr, retVal));
491+
EXPECT_NE(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
492+
}
493+
476494
TEST_F(RenderCompressedBuffersTests, givenSvmAllocationWhenCreatingBufferThenForceDisableCompression) {
477495
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = true;
478496

unit_tests/test_files/igdrcl.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,5 @@ PowerSavingMode = 0
9898
AubDumpAddMmioRegistersList = unk
9999
ForceResourceLockOnTransferCalls = 0
100100
EnableMakeResidentOnMapGpuVa = 0
101+
RenderCompressedImagesEnabled = -1
102+
RenderCompressedBuffersEnabled = -1

0 commit comments

Comments
 (0)