Skip to content

Commit e5eba8b

Browse files
Add setters and getters for coherency type in render surface state
Signed-off-by: Milczarek, Slawomir <[email protected]>
1 parent fd9fb3e commit e5eba8b

File tree

11 files changed

+32
-12
lines changed

11 files changed

+32
-12
lines changed

level_zero/core/test/unit_tests/sources/debugger/test_module_with_debug.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "opencl/source/program/kernel_info.h"
1313
#include "opencl/source/program/kernel_info_from_patchtokens.h"
14+
#include "opencl/test/unit_test/helpers/unit_test_helper.h"
1415
#include "opencl/test/unit_test/mocks/mock_compilers.h"
1516
#include "test.h"
1617

@@ -310,7 +311,6 @@ HWTEST_F(KernelDebugSurfaceTest, givenDebuggerAndBindfulKernelWhenAppendingKerne
310311
EXPECT_EQ(debugSurface->getGpuAddress(), debugSurfaceState->getSurfaceBaseAddress());
311312

312313
EXPECT_EQ(RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER, debugSurfaceState->getSurfaceType());
313-
EXPECT_EQ(RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT, debugSurfaceState->getCoherencyType());
314314
}
315315

316316
using ModuleWithDebuggerL0Test = Test<L0DebuggerHwFixture>;

opencl/test/unit_test/command_queue/enqueue_debug_kernel_tests.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "opencl/test/unit_test/fixtures/enqueue_handler_fixture.h"
1414
#include "opencl/test/unit_test/helpers/kernel_binary_helper.h"
1515
#include "opencl/test/unit_test/helpers/kernel_filename_helper.h"
16+
#include "opencl/test/unit_test/helpers/unit_test_helper.h"
1617
#include "opencl/test/unit_test/mocks/mock_buffer.h"
1718
#include "opencl/test/unit_test/mocks/mock_command_queue.h"
1819
#include "opencl/test/unit_test/mocks/mock_kernel.h"
@@ -138,7 +139,7 @@ HWTEST_F(EnqueueDebugKernelTest, givenDebugKernelWhenEnqueuedThenSurfaceStateFor
138139
EXPECT_EQ(debugSurface->getGpuAddress(), debugSurfaceState->getSurfaceBaseAddress());
139140

140141
EXPECT_EQ(RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER, debugSurfaceState->getSurfaceType());
141-
EXPECT_EQ(RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT, debugSurfaceState->getCoherencyType());
142+
EXPECT_EQ(UnitTestHelper<FamilyType>::getCoherencyTypeSupported(RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT), debugSurfaceState->getCoherencyType());
142143
}
143144
}
144145

opencl/test/unit_test/helpers/hw_helper_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenAllocationProvidedThenU
443443
EXPECT_EQ(pitch, state->getSurfacePitch() - 1u);
444444
EXPECT_EQ(gpuAddr, state->getSurfaceBaseAddress());
445445

446-
EXPECT_EQ(RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT, state->getCoherencyType());
446+
EXPECT_EQ(UnitTestHelper<FamilyType>::getCoherencyTypeSupported(RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT), state->getCoherencyType());
447447
EXPECT_EQ(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE, state->getAuxiliarySurfaceMode());
448448

449449
delete allocation.getDefaultGmm();
@@ -506,7 +506,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenGmmCompressionDisabledA
506506
allocation.setDefaultGmm(new Gmm(rootDeviceEnvironment.getGmmClientContext(), allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), 0, false));
507507
SURFACE_TYPE type = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER;
508508
helper.setRenderSurfaceStateForBuffer(rootDeviceEnvironment, stateBuffer, size, addr, 0, pitch, &allocation, false, type, false, false);
509-
EXPECT_EQ(RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT, state->getCoherencyType());
509+
EXPECT_EQ(UnitTestHelper<FamilyType>::getCoherencyTypeSupported(RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT), state->getCoherencyType());
510510
EXPECT_EQ(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE, state->getAuxiliarySurfaceMode());
511511

512512
delete allocation.getDefaultGmm();
@@ -538,7 +538,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenGmmAndAllocationCompres
538538
allocation.getDefaultGmm()->isRenderCompressed = true;
539539
SURFACE_TYPE type = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER;
540540
helper.setRenderSurfaceStateForBuffer(rootDeviceEnvironment, stateBuffer, size, addr, 0, pitch, &allocation, false, type, true, false);
541-
EXPECT_EQ(RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT, state->getCoherencyType());
541+
EXPECT_EQ(UnitTestHelper<FamilyType>::getCoherencyTypeSupported(RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT), state->getCoherencyType());
542542
EXPECT_EQ(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE, state->getAuxiliarySurfaceMode());
543543

544544
delete allocation.getDefaultGmm();

opencl/test/unit_test/helpers/unit_test_helper.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ struct HardwareInfo;
1717

1818
template <typename GfxFamily>
1919
struct UnitTestHelper {
20+
using COHERENCY_TYPE = typename GfxFamily::RENDER_SURFACE_STATE::COHERENCY_TYPE;
21+
2022
static bool isL3ConfigProgrammable();
2123

2224
static bool evaluateDshUsage(size_t sizeBeforeEnqueue, size_t sizeAfterEnqueue, const KernelDescriptor *kernelDescriptor, uint32_t rootDeviceIndex);
@@ -31,6 +33,8 @@ struct UnitTestHelper {
3133

3234
static uint32_t getAppropriateThreadArbitrationPolicy(uint32_t policy);
3335

36+
static auto getCoherencyTypeSupported(COHERENCY_TYPE coherencyType) -> decltype(coherencyType);
37+
3438
static bool evaluateGshAddressForScratchSpace(uint64_t usedScratchGpuAddress, uint64_t retrievedGshAddress);
3539

3640
static bool isPipeControlWArequired(const HardwareInfo &hwInfo);

opencl/test/unit_test/helpers/unit_test_helper.inl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ inline bool UnitTestHelper<GfxFamily>::requiresTimestampPacketsInSystemMemory()
8080
return true;
8181
}
8282

83+
template <typename GfxFamily>
84+
auto UnitTestHelper<GfxFamily>::getCoherencyTypeSupported(COHERENCY_TYPE coherencyType) -> decltype(coherencyType) {
85+
return coherencyType;
86+
}
87+
8388
template <typename GfxFamily>
8489
const bool UnitTestHelper<GfxFamily>::tiledImagesSupported = true;
8590

opencl/test/unit_test/mem_obj/buffer_tests.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "opencl/test/unit_test/fixtures/memory_management_fixture.h"
2121
#include "opencl/test/unit_test/fixtures/multi_root_device_fixture.h"
2222
#include "opencl/test/unit_test/gen_common/matchers.h"
23+
#include "opencl/test/unit_test/helpers/unit_test_helper.h"
2324
#include "opencl/test/unit_test/mocks/mock_allocation_properties.h"
2425
#include "opencl/test/unit_test/mocks/mock_buffer.h"
2526
#include "opencl/test/unit_test/mocks/mock_command_queue.h"
@@ -1672,7 +1673,7 @@ HWTEST_F(BufferSetSurfaceTests, givenNonRenderCompressedGmmResourceWhenSurfaceSt
16721673

16731674
EXPECT_EQ(0u, surfaceState.getAuxiliarySurfaceBaseAddress());
16741675
EXPECT_TRUE(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE == surfaceState.getAuxiliarySurfaceMode());
1675-
EXPECT_TRUE(RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT == surfaceState.getCoherencyType());
1676+
EXPECT_TRUE(UnitTestHelper<FamilyType>::getCoherencyTypeSupported(RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT) == surfaceState.getCoherencyType());
16761677
}
16771678

16781679
HWTEST_F(BufferSetSurfaceTests, givenMisalignedPointerWhenSurfaceStateIsProgrammedThenBaseAddressAndLengthAreAlignedToDword) {

shared/source/command_container/command_encoder.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ struct EncodeSurfaceState {
230230
using R_SURFACE_STATE = typename GfxFamily::RENDER_SURFACE_STATE;
231231
using SURFACE_FORMAT = typename R_SURFACE_STATE::SURFACE_FORMAT;
232232
using AUXILIARY_SURFACE_MODE = typename R_SURFACE_STATE::AUXILIARY_SURFACE_MODE;
233+
using COHERENCY_TYPE = typename R_SURFACE_STATE::COHERENCY_TYPE;
233234

234235
static void encodeBuffer(void *dst, uint64_t address, size_t size, uint32_t mocs,
235236
bool cpuCoherent, bool forceNonAuxMode, bool isReadOnly, uint32_t numAvailableDevices,
@@ -254,6 +255,7 @@ struct EncodeSurfaceState {
254255
size_t numberOfBindingTableStates, size_t offsetOfBindingTable);
255256

256257
static void appendImageCompressionParams(R_SURFACE_STATE *surfaceState, GraphicsAllocation *allocation, GmmHelper *gmmHelper, bool imageFromBuffer);
258+
static void setCoherencyType(R_SURFACE_STATE *surfaceState, COHERENCY_TYPE coherencyType);
257259
static void setBufferAuxParamsForCCS(R_SURFACE_STATE *surfaceState);
258260
static void setImageAuxParamsForCCS(R_SURFACE_STATE *surfaceState, Gmm *gmm);
259261
static bool isAuxModeEnabled(R_SURFACE_STATE *surfaceState, Gmm *gmm);

shared/source/command_container/command_encoder.inl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,14 +341,14 @@ void EncodeSurfaceState<Family>::encodeBuffer(void *dst, uint64_t address, size_
341341
surfaceState->setMemoryObjectControlState(mocs);
342342
surfaceState->setSurfaceBaseAddress(address);
343343

344-
surfaceState->setCoherencyType(cpuCoherent ? R_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT
345-
: R_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT);
346344
surfaceState->setAuxiliarySurfaceMode(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE);
347345

346+
setCoherencyType(surfaceState, cpuCoherent ? R_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT : R_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT);
347+
348348
Gmm *gmm = allocation ? allocation->getDefaultGmm() : nullptr;
349349
if (gmm && gmm->isRenderCompressed && !forceNonAuxMode) {
350350
// Its expected to not program pitch/qpitch/baseAddress for Aux surface in CCS scenarios
351-
surfaceState->setCoherencyType(R_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT);
351+
setCoherencyType(surfaceState, R_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT);
352352
setBufferAuxParamsForCCS(surfaceState);
353353
}
354354

shared/source/command_container/command_encoder_bdw_plus.inl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,11 @@ bool EncodeSurfaceState<GfxFamily>::doBindingTablePrefetch() {
419419
return true;
420420
}
421421

422+
template <typename Family>
423+
void EncodeSurfaceState<Family>::setCoherencyType(R_SURFACE_STATE *surfaceState, COHERENCY_TYPE coherencyType) {
424+
surfaceState->setCoherencyType(coherencyType);
425+
}
426+
422427
template <typename Family>
423428
void EncodeSempahore<Family>::programMiSemaphoreWait(MI_SEMAPHORE_WAIT *cmd,
424429
uint64_t compareAddress,

shared/source/helpers/hw_helper_base.inl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ void HwHelperHw<Family>::setRenderSurfaceStateForBuffer(const RootDeviceEnvironm
147147
Gmm *gmm = gfxAlloc ? gfxAlloc->getDefaultGmm() : nullptr;
148148
if (gmm && gmm->isRenderCompressed && !forceNonAuxMode) {
149149
// Its expected to not program pitch/qpitch/baseAddress for Aux surface in CCS scenarios
150-
state.setCoherencyType(RENDER_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT);
150+
EncodeSurfaceState<Family>::setCoherencyType(&state, RENDER_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT);
151151
EncodeSurfaceState<Family>::setBufferAuxParamsForCCS(&state);
152152
} else {
153-
state.setCoherencyType(RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT);
153+
EncodeSurfaceState<Family>::setCoherencyType(&state, RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT);
154154
state.setAuxiliarySurfaceMode(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE);
155155
}
156156
*surfaceState = state;

0 commit comments

Comments
 (0)