Skip to content

Commit 1518774

Browse files
Use stateful args programming for aux translation kernels.
Set valid mocs values Change-Id: I8de2bbdd72b102a1623b9e397485ef52ecca8306 Signed-off-by: Dunajski, Bartosz <[email protected]>
1 parent d35c20f commit 1518774

File tree

14 files changed

+196
-49
lines changed

14 files changed

+196
-49
lines changed

runtime/built_ins/aux_translation_builtin.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ class BuiltInOp<EBuiltInOps::AuxTranslation> : public BuiltinDispatchInfoBuilder
2727

2828
for (auto &memObj : *operationParams.memObjsForAuxTranslation) {
2929
DispatchInfoBuilder<SplitDispatch::Dim::d1D, SplitDispatch::SplitMode::NoSplit> builder;
30-
auto graphicsAllocation = memObj->getGraphicsAllocation();
3130
size_t allocationSize = alignUp(memObj->getSize(), 512);
3231

3332
UNRECOVERABLE_IF(builder.getMaxNumDispatches() != 1);
@@ -43,15 +42,14 @@ class BuiltInOp<EBuiltInOps::AuxTranslation> : public BuiltinDispatchInfoBuilder
4342

4443
if (AuxTranslationDirection::AuxToNonAux == operationParams.auxTranslationDirection) {
4544
builder.setKernel(convertToNonAuxKernel[kernelInstanceNumber++].get());
46-
builder.setArg(0, memObj);
47-
builder.setArgSvm(1, allocationSize, reinterpret_cast<void *>(graphicsAllocation->getGpuAddress()), nullptr, 0u);
4845
} else {
4946
UNRECOVERABLE_IF(AuxTranslationDirection::NonAuxToAux != operationParams.auxTranslationDirection);
5047
builder.setKernel(convertToAuxKernel[kernelInstanceNumber++].get());
51-
builder.setArgSvm(0, allocationSize, reinterpret_cast<void *>(graphicsAllocation->getGpuAddress()), nullptr, 0u);
52-
builder.setArg(1, memObj);
5348
}
5449

50+
builder.setArg(0, memObj);
51+
builder.setArg(1, memObj);
52+
5553
size_t xGws = allocationSize / 16;
5654

5755
builder.setDispatchGeometry(Vec3<size_t>{xGws, 0, 0}, Vec3<size_t>{0, 0, 0}, Vec3<size_t>{0, 0, 0});

runtime/built_ins/built_ins.inl

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ void BuiltinDispatchInfoBuilder::populate(Context &context, Device &device, EBui
2020

2121
BuiltInOp<EBuiltInOps::AuxTranslation>::BuiltInOp(BuiltIns &kernelsLib, Context &context, Device &device) : BuiltinDispatchInfoBuilder(kernelsLib) {
2222
BuiltinDispatchInfoBuilder::populate(context, device, EBuiltInOps::AuxTranslation, "", "fullCopy", baseKernel);
23+
2324
resizeKernelInstances(5);
2425
}
2526

@@ -28,15 +29,17 @@ void BuiltInOp<EBuiltInOps::AuxTranslation>::resizeKernelInstances(size_t size)
2829
convertToAuxKernel.reserve(size);
2930

3031
for (size_t i = convertToNonAuxKernel.size(); i < size; i++) {
31-
auto clonedKernel1 = Kernel::create(baseKernel->getProgram(), baseKernel->getKernelInfo(), nullptr);
32-
clonedKernel1->setAuxTranslationFlag(true);
33-
auto clonedKernel2 = Kernel::create(baseKernel->getProgram(), baseKernel->getKernelInfo(), nullptr);
34-
clonedKernel2->setAuxTranslationFlag(true);
35-
clonedKernel1->cloneKernel(baseKernel);
36-
clonedKernel2->cloneKernel(baseKernel);
37-
38-
convertToNonAuxKernel.emplace_back(clonedKernel1);
39-
convertToAuxKernel.emplace_back(clonedKernel2);
32+
auto clonedNonAuxToAuxKernel = Kernel::create(baseKernel->getProgram(), baseKernel->getKernelInfo(), nullptr);
33+
clonedNonAuxToAuxKernel->setAuxTranslationDirection(AuxTranslationDirection::NonAuxToAux);
34+
35+
auto clonedAuxToNonAuxKernel = Kernel::create(baseKernel->getProgram(), baseKernel->getKernelInfo(), nullptr);
36+
clonedAuxToNonAuxKernel->setAuxTranslationDirection(AuxTranslationDirection::AuxToNonAux);
37+
38+
clonedNonAuxToAuxKernel->cloneKernel(baseKernel);
39+
clonedAuxToNonAuxKernel->cloneKernel(baseKernel);
40+
41+
convertToAuxKernel.emplace_back(clonedNonAuxToAuxKernel);
42+
convertToNonAuxKernel.emplace_back(clonedAuxToNonAuxKernel);
4043
}
4144
}
4245

runtime/gtpin/gtpin_callbacks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ void gtpinNotifyKernelSubmit(cl_kernel kernel, void *pCmdQueue) {
138138
void *pSurfaceState = gtpinHelper.getSurfaceState(pKernel, gtpinBTI);
139139
cl_mem buffer = (cl_mem)resource;
140140
auto pBuffer = castToObjectOrAbort<Buffer>(buffer);
141-
pBuffer->setArgStateful(pSurfaceState, false, false, false);
141+
pBuffer->setArgStateful(pSurfaceState, false, false, false, false);
142142
}
143143
}
144144

runtime/kernel/kernel.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,12 +1186,24 @@ cl_int Kernel::setArgBuffer(uint32_t argIndex,
11861186
this->patchInfoDataList.push_back(patchInfoData);
11871187
}
11881188

1189-
bool forceNonAuxMode = buffer->getGraphicsAllocation()->getAllocationType() == GraphicsAllocation::AllocationType::BUFFER_COMPRESSED &&
1190-
!kernelArgInfo.pureStatefulBufferAccess;
1189+
bool disableL3 = false;
1190+
bool forceNonAuxMode = false;
1191+
bool isAuxTranslationKernel = (AuxTranslationDirection::None != auxTranslationDirection);
1192+
1193+
if (isAuxTranslationKernel) {
1194+
if (((AuxTranslationDirection::AuxToNonAux == auxTranslationDirection) && argIndex == 1) ||
1195+
((AuxTranslationDirection::NonAuxToAux == auxTranslationDirection) && argIndex == 0)) {
1196+
forceNonAuxMode = true;
1197+
}
1198+
disableL3 = (argIndex == 0);
1199+
} else if (buffer->getGraphicsAllocation()->getAllocationType() == GraphicsAllocation::AllocationType::BUFFER_COMPRESSED &&
1200+
!kernelArgInfo.pureStatefulBufferAccess) {
1201+
forceNonAuxMode = true;
1202+
}
11911203

11921204
if (requiresSshForBuffers()) {
11931205
auto surfaceState = ptrOffset(getSurfaceStateHeap(), kernelArgInfo.offsetHeap);
1194-
buffer->setArgStateful(surfaceState, forceNonAuxMode, auxTranslationKernel, kernelArgInfo.isReadOnly);
1206+
buffer->setArgStateful(surfaceState, forceNonAuxMode, disableL3, isAuxTranslationKernel, kernelArgInfo.isReadOnly);
11951207
kernelArguments[argIndex].isUncacheable = buffer->isMemObjUncacheable();
11961208
}
11971209
addAllocationToCacheFlushVector(argIndex, buffer->getGraphicsAllocation());

runtime/kernel/kernel.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,8 @@ class Kernel : public BaseObject<_cl_kernel> {
386386
using CacheFlushAllocationsVec = StackVec<GraphicsAllocation *, 32>;
387387
void getAllocationsForCacheFlush(CacheFlushAllocationsVec &out) const;
388388

389-
void setAuxTranslationFlag(bool auxTranslationFlag) {
390-
this->auxTranslationKernel = auxTranslationFlag;
389+
void setAuxTranslationDirection(AuxTranslationDirection auxTranslationDirection) {
390+
this->auxTranslationDirection = auxTranslationDirection;
391391
}
392392
void setUnifiedMemoryProperty(cl_kernel_exec_info infoType, bool infoValue);
393393
void setUnifiedMemoryExecInfo(GraphicsAllocation *argValue);
@@ -492,7 +492,7 @@ class Kernel : public BaseObject<_cl_kernel> {
492492
std::vector<GraphicsAllocation *> kernelSvmGfxAllocations;
493493
std::vector<GraphicsAllocation *> kernelUnifiedMemoryGfxAllocations;
494494

495-
bool auxTranslationKernel = false;
495+
AuxTranslationDirection auxTranslationDirection = AuxTranslationDirection::None;
496496

497497
size_t numberOfBindingTableStates;
498498
size_t localBindingTableOffset;

runtime/mem_obj/buffer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ void Buffer::setSurfaceState(const Device *device,
563563
GraphicsAllocation *gfxAlloc,
564564
cl_mem_flags flags) {
565565
auto buffer = Buffer::createBufferHwFromDevice(device, flags, svmSize, svmPtr, svmPtr, gfxAlloc, true, false, false);
566-
buffer->setArgStateful(surfaceState, false, false, false);
566+
buffer->setArgStateful(surfaceState, false, false, false, false);
567567
buffer->graphicsAllocation = nullptr;
568568
delete buffer;
569569
}

runtime/mem_obj/buffer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class Buffer : public MemObj {
110110
bool isValidSubBufferOffset(size_t offset);
111111
uint64_t setArgStateless(void *memory, uint32_t patchSize) { return setArgStateless(memory, patchSize, false); }
112112
uint64_t setArgStateless(void *memory, uint32_t patchSize, bool set32BitAddressing);
113-
virtual void setArgStateful(void *memory, bool forceNonAuxMode, bool programForAuxTranslation, bool isReadOnly) = 0;
113+
virtual void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly) = 0;
114114
bool bufferRectPitchSet(const size_t *bufferOrigin,
115115
const size_t *region,
116116
size_t &bufferRowPitch,
@@ -170,7 +170,7 @@ class BufferHw : public Buffer {
170170
: Buffer(context, properties, size, memoryStorage, hostPtr, gfxAllocation,
171171
zeroCopy, isHostPtrSVM, isObjectRedescribed) {}
172172

173-
void setArgStateful(void *memory, bool forceNonAuxMode, bool programForAuxTranslation, bool isReadOnlyArgument) override;
173+
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnlyArgument) override;
174174
void appendBufferState(void *memory, Context *context, GraphicsAllocation *gfxAllocation, bool isReadOnlyArgument);
175175

176176
static Buffer *create(Context *context,

runtime/mem_obj/buffer_base.inl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ union SURFACE_STATE_BUFFER_LENGTH {
2828
};
2929

3030
template <typename GfxFamily>
31-
void BufferHw<GfxFamily>::setArgStateful(void *memory, bool forceNonAuxMode, bool programForAuxTranslation, bool isReadOnlyArgument) {
31+
void BufferHw<GfxFamily>::setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnlyArgument) {
3232
using RENDER_SURFACE_STATE = typename GfxFamily::RENDER_SURFACE_STATE;
3333
using SURFACE_FORMAT = typename RENDER_SURFACE_STATE::SURFACE_FORMAT;
3434
using AUXILIARY_SURFACE_MODE = typename RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE;
@@ -41,7 +41,7 @@ void BufferHw<GfxFamily>::setArgStateful(void *memory, bool forceNonAuxMode, boo
4141
auto bufferAddressAligned = alignDown(bufferAddress, 4);
4242
auto bufferOffset = ptrDiff(bufferAddress, bufferAddressAligned);
4343

44-
auto surfaceSize = alignUp(getSize() + bufferOffset, programForAuxTranslation ? 512 : 4);
44+
auto surfaceSize = alignUp(getSize() + bufferOffset, alignSizeForAuxTranslation ? 512 : 4);
4545

4646
SURFACE_STATE_BUFFER_LENGTH Length = {0};
4747
Length.Length = static_cast<uint32_t>(surfaceSize - 1);
@@ -62,7 +62,8 @@ void BufferHw<GfxFamily>::setArgStateful(void *memory, bool forceNonAuxMode, boo
6262
surfaceState->setTileMode(RENDER_SURFACE_STATE::TILE_MODE_LINEAR);
6363
surfaceState->setVerticalLineStride(0);
6464
surfaceState->setVerticalLineStrideOffset(0);
65-
surfaceState->setMemoryObjectControlState(getMocsValue(programForAuxTranslation, isReadOnlyArgument));
65+
66+
surfaceState->setMemoryObjectControlState(getMocsValue(disableL3, isReadOnlyArgument));
6667
surfaceState->setSurfaceBaseAddress(bufferAddressAligned);
6768

6869
Gmm *gmm = graphicsAllocation ? graphicsAllocation->getDefaultGmm() : nullptr;

unit_tests/built_ins/built_in_tests.cpp

Lines changed: 139 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "runtime/built_ins/built_ins.h"
1212
#include "runtime/built_ins/builtins_dispatch_builder.h"
1313
#include "runtime/built_ins/vme_dispatch_builder.h"
14+
#include "runtime/gmm_helper/gmm.h"
1415
#include "runtime/helpers/dispatch_info_builder.h"
1516
#include "runtime/helpers/file_io.h"
1617
#include "runtime/helpers/hash.h"
@@ -286,10 +287,8 @@ HWTEST_F(BuiltInTests, givenInputBufferWhenBuildingNonAuxDispatchInfoForAuxTrans
286287
memObjsForAuxTranslation.erase(buffer);
287288

288289
cl_mem clMem = buffer;
289-
void *gpuAddress = reinterpret_cast<void *>(buffer->getGraphicsAllocation()->getGpuAddress());
290290
EXPECT_EQ(clMem, kernel->getKernelArguments().at(0).object);
291-
EXPECT_EQ(gpuAddress, kernel->getKernelArguments().at(1).value);
292-
EXPECT_EQ(nullptr, kernel->getKernelArguments().at(1).object);
291+
EXPECT_EQ(clMem, kernel->getKernelArguments().at(1).object);
293292

294293
EXPECT_EQ(1u, dispatchInfo.getDim());
295294
size_t xGws = alignUp(buffer->getSize(), 512) / 16;
@@ -335,9 +334,7 @@ HWTEST_F(BuiltInTests, givenInputBufferWhenBuildingAuxDispatchInfoForAuxTranslat
335334
memObjsForAuxTranslation.erase(buffer);
336335

337336
cl_mem clMem = buffer;
338-
void *gpuAddress = reinterpret_cast<void *>(buffer->getGraphicsAllocation()->getGpuAddress());
339-
EXPECT_EQ(gpuAddress, kernel->getKernelArguments().at(0).value);
340-
EXPECT_EQ(nullptr, kernel->getKernelArguments().at(0).object);
337+
EXPECT_EQ(clMem, kernel->getKernelArguments().at(0).object);
341338
EXPECT_EQ(clMem, kernel->getKernelArguments().at(1).object);
342339

343340
EXPECT_EQ(1u, dispatchInfo.getDim());
@@ -495,6 +492,142 @@ HWTEST_F(BuiltInTests, givenKernelWithAuxTranslationRequiredWhenEnqueueCalledThe
495492
EXPECT_EQ(1u, mockBuiltinKernel->releaseOwnershipCalls);
496493
}
497494

495+
HWTEST_F(BuiltInTests, givenAuxTranslationKernelWhenSettingKernelArgsThenSetValidMocs) {
496+
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
497+
498+
MockAuxBuilInOp mockAuxBuiltInOp(*pBuiltIns, *pContext, *pDevice);
499+
MultiDispatchInfo multiDispatchInfo;
500+
MemObjsForAuxTranslation memObjsForAuxTranslation;
501+
502+
BuiltinOpParams builtinOpParamsToAux;
503+
builtinOpParamsToAux.memObjsForAuxTranslation = &memObjsForAuxTranslation;
504+
builtinOpParamsToAux.auxTranslationDirection = AuxTranslationDirection::NonAuxToAux;
505+
506+
BuiltinOpParams builtinOpParamsToNonAux;
507+
builtinOpParamsToNonAux.memObjsForAuxTranslation = &memObjsForAuxTranslation;
508+
builtinOpParamsToNonAux.auxTranslationDirection = AuxTranslationDirection::AuxToNonAux;
509+
510+
cl_int retVal = CL_SUCCESS;
511+
auto buffer = std::unique_ptr<Buffer>(Buffer::create(pContext, 0, MemoryConstants::pageSize, nullptr, retVal));
512+
memObjsForAuxTranslation.insert(buffer.get());
513+
514+
mockAuxBuiltInOp.buildDispatchInfosForAuxTranslation<FamilyType>(multiDispatchInfo, builtinOpParamsToAux);
515+
mockAuxBuiltInOp.buildDispatchInfosForAuxTranslation<FamilyType>(multiDispatchInfo, builtinOpParamsToNonAux);
516+
517+
{
518+
// read args
519+
auto argNum = 0;
520+
auto expectedMocs = pDevice->getExecutionEnvironment()->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED);
521+
auto sshBase = mockAuxBuiltInOp.convertToAuxKernel[0]->getSurfaceStateHeap();
522+
auto sshOffset = mockAuxBuiltInOp.convertToAuxKernel[0]->getKernelInfo().kernelArgInfo[argNum].offsetHeap;
523+
auto surfaceState = reinterpret_cast<RENDER_SURFACE_STATE *>(ptrOffset(sshBase, sshOffset));
524+
EXPECT_EQ(expectedMocs, surfaceState->getMemoryObjectControlState());
525+
526+
sshBase = mockAuxBuiltInOp.convertToNonAuxKernel[0]->getSurfaceStateHeap();
527+
sshOffset = mockAuxBuiltInOp.convertToNonAuxKernel[0]->getKernelInfo().kernelArgInfo[argNum].offsetHeap;
528+
surfaceState = reinterpret_cast<RENDER_SURFACE_STATE *>(ptrOffset(sshBase, sshOffset));
529+
EXPECT_EQ(expectedMocs, surfaceState->getMemoryObjectControlState());
530+
}
531+
532+
{
533+
// write args
534+
auto argNum = 1;
535+
auto expectedMocs = pDevice->getExecutionEnvironment()->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER);
536+
auto sshBase = mockAuxBuiltInOp.convertToAuxKernel[0]->getSurfaceStateHeap();
537+
auto sshOffset = mockAuxBuiltInOp.convertToAuxKernel[0]->getKernelInfo().kernelArgInfo[argNum].offsetHeap;
538+
auto surfaceState = reinterpret_cast<RENDER_SURFACE_STATE *>(ptrOffset(sshBase, sshOffset));
539+
EXPECT_EQ(expectedMocs, surfaceState->getMemoryObjectControlState());
540+
541+
sshBase = mockAuxBuiltInOp.convertToNonAuxKernel[0]->getSurfaceStateHeap();
542+
sshOffset = mockAuxBuiltInOp.convertToNonAuxKernel[0]->getKernelInfo().kernelArgInfo[argNum].offsetHeap;
543+
surfaceState = reinterpret_cast<RENDER_SURFACE_STATE *>(ptrOffset(sshBase, sshOffset));
544+
EXPECT_EQ(expectedMocs, surfaceState->getMemoryObjectControlState());
545+
}
546+
}
547+
548+
HWTEST_F(BuiltInTests, givenAuxToNonAuxTranslationWhenSettingSurfaceStateThenSetValidAuxMode) {
549+
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
550+
using AUXILIARY_SURFACE_MODE = typename RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE;
551+
552+
MockAuxBuilInOp mockAuxBuiltInOp(*pBuiltIns, *pContext, *pDevice);
553+
MultiDispatchInfo multiDispatchInfo;
554+
MemObjsForAuxTranslation memObjsForAuxTranslation;
555+
556+
BuiltinOpParams builtinOpParams;
557+
builtinOpParams.memObjsForAuxTranslation = &memObjsForAuxTranslation;
558+
builtinOpParams.auxTranslationDirection = AuxTranslationDirection::AuxToNonAux;
559+
560+
cl_int retVal = CL_SUCCESS;
561+
auto buffer = std::unique_ptr<Buffer>(Buffer::create(pContext, 0, MemoryConstants::pageSize, nullptr, retVal));
562+
buffer->getGraphicsAllocation()->setAllocationType(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
563+
auto gmm = new Gmm(nullptr, 1, false);
564+
gmm->isRenderCompressed = true;
565+
buffer->getGraphicsAllocation()->setDefaultGmm(gmm);
566+
567+
memObjsForAuxTranslation.insert(buffer.get());
568+
569+
mockAuxBuiltInOp.buildDispatchInfosForAuxTranslation<FamilyType>(multiDispatchInfo, builtinOpParams);
570+
571+
{
572+
// read arg
573+
auto argNum = 0;
574+
auto sshBase = mockAuxBuiltInOp.convertToNonAuxKernel[0]->getSurfaceStateHeap();
575+
auto sshOffset = mockAuxBuiltInOp.convertToNonAuxKernel[0]->getKernelInfo().kernelArgInfo[argNum].offsetHeap;
576+
auto surfaceState = reinterpret_cast<RENDER_SURFACE_STATE *>(ptrOffset(sshBase, sshOffset));
577+
EXPECT_EQ(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E, surfaceState->getAuxiliarySurfaceMode());
578+
}
579+
580+
{
581+
// write arg
582+
auto argNum = 1;
583+
auto sshBase = mockAuxBuiltInOp.convertToNonAuxKernel[0]->getSurfaceStateHeap();
584+
auto sshOffset = mockAuxBuiltInOp.convertToNonAuxKernel[0]->getKernelInfo().kernelArgInfo[argNum].offsetHeap;
585+
auto surfaceState = reinterpret_cast<RENDER_SURFACE_STATE *>(ptrOffset(sshBase, sshOffset));
586+
EXPECT_EQ(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE, surfaceState->getAuxiliarySurfaceMode());
587+
}
588+
}
589+
590+
HWTEST_F(BuiltInTests, givenNonAuxToAuxTranslationWhenSettingSurfaceStateThenSetValidAuxMode) {
591+
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
592+
using AUXILIARY_SURFACE_MODE = typename RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE;
593+
594+
MockAuxBuilInOp mockAuxBuiltInOp(*pBuiltIns, *pContext, *pDevice);
595+
MultiDispatchInfo multiDispatchInfo;
596+
MemObjsForAuxTranslation memObjsForAuxTranslation;
597+
598+
BuiltinOpParams builtinOpParams;
599+
builtinOpParams.memObjsForAuxTranslation = &memObjsForAuxTranslation;
600+
builtinOpParams.auxTranslationDirection = AuxTranslationDirection::NonAuxToAux;
601+
602+
cl_int retVal = CL_SUCCESS;
603+
auto buffer = std::unique_ptr<Buffer>(Buffer::create(pContext, 0, MemoryConstants::pageSize, nullptr, retVal));
604+
buffer->getGraphicsAllocation()->setAllocationType(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
605+
auto gmm = new Gmm(nullptr, 1, false);
606+
gmm->isRenderCompressed = true;
607+
buffer->getGraphicsAllocation()->setDefaultGmm(gmm);
608+
memObjsForAuxTranslation.insert(buffer.get());
609+
610+
mockAuxBuiltInOp.buildDispatchInfosForAuxTranslation<FamilyType>(multiDispatchInfo, builtinOpParams);
611+
612+
{
613+
// read arg
614+
auto argNum = 0;
615+
auto sshBase = mockAuxBuiltInOp.convertToAuxKernel[0]->getSurfaceStateHeap();
616+
auto sshOffset = mockAuxBuiltInOp.convertToAuxKernel[0]->getKernelInfo().kernelArgInfo[argNum].offsetHeap;
617+
auto surfaceState = reinterpret_cast<RENDER_SURFACE_STATE *>(ptrOffset(sshBase, sshOffset));
618+
EXPECT_EQ(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE, surfaceState->getAuxiliarySurfaceMode());
619+
}
620+
621+
{
622+
// write arg
623+
auto argNum = 1;
624+
auto sshBase = mockAuxBuiltInOp.convertToAuxKernel[0]->getSurfaceStateHeap();
625+
auto sshOffset = mockAuxBuiltInOp.convertToAuxKernel[0]->getKernelInfo().kernelArgInfo[argNum].offsetHeap;
626+
auto surfaceState = reinterpret_cast<RENDER_SURFACE_STATE *>(ptrOffset(sshBase, sshOffset));
627+
EXPECT_EQ(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E, surfaceState->getAuxiliarySurfaceMode());
628+
}
629+
}
630+
498631
TEST_F(BuiltInTests, BuiltinDispatchInfoBuilderCopyBufferToBufferAligned) {
499632
BuiltinDispatchInfoBuilder &builder = pBuiltIns->getBuiltinDispatchInfoBuilder(EBuiltInOps::CopyBufferToBuffer, *pContext, *pDevice);
500633

unit_tests/gen9/kernel_tests_gen9.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ GEN9TEST_F(Gen9HardwareCommandsTest, givenBufferThatIsNotZeroCopyWhenSurfaceStat
4646
auto gmmHelper = context.getDevice(0)->getExecutionEnvironment()->getGmmHelper();
4747
gmmHelper->setSimplifiedMocsTableUsage(true);
4848

49-
buffer->setArgStateful(&surfaceState, false, false, false);
49+
buffer->setArgStateful(&surfaceState, false, false, false, false);
5050
//make sure proper mocs is selected
5151
constexpr uint32_t expectedMocs = GmmHelper::cacheEnabledIndex;
5252
EXPECT_EQ(expectedMocs, surfaceState.getMemoryObjectControlStateIndexToMocsTables());

0 commit comments

Comments
 (0)