mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
AUB capture with AubStream to support image dumps
Related-To: NEO-2717 Change-Id: I448627cc40776eadacaefaa321500a3cf5ff3593 Signed-off-by: Milczarek, Slawomir <slawomir.milczarek@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
2393aceca6
commit
381ccfc0aa
@@ -14,6 +14,7 @@
|
||||
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
||||
#include "unit_tests/mocks/mock_gmm.h"
|
||||
#include "unit_tests/mocks/mock_gmm_resource_info.h"
|
||||
#include "unit_tests/mocks/mock_memory_manager.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
@@ -372,3 +373,100 @@ HWTEST_F(AubAllocDumpTests, givenMultisampleImageWritableWhenDumpAllocationIsCal
|
||||
|
||||
EXPECT_EQ(0u, mockAubFileStream->getSize());
|
||||
}
|
||||
|
||||
HWTEST_F(AubAllocDumpTests, givenMultisampleImageWritableWheGetDumpSurfaceIsCalledAndDumpFormatIsSpecifiedThenNullSurfaceInfoIsReturned) {
|
||||
MockContext context;
|
||||
std::unique_ptr<Image> image(ImageHelper<Image2dDefaults>::create(&context));
|
||||
ASSERT_NE(nullptr, image);
|
||||
|
||||
auto gfxAllocation = image->getGraphicsAllocation();
|
||||
auto mockGmmResourceInfo = reinterpret_cast<MockGmmResourceInfo *>(gfxAllocation->getDefaultGmm()->gmmResourceInfo.get());
|
||||
mockGmmResourceInfo->mockResourceCreateParams.MSAA.NumSamples = 2;
|
||||
|
||||
EXPECT_EQ(nullptr, AubAllocDump::getDumpSurfaceInfo<FamilyType>(*gfxAllocation, AubAllocDump::DumpFormat::IMAGE_BMP));
|
||||
EXPECT_EQ(nullptr, AubAllocDump::getDumpSurfaceInfo<FamilyType>(*gfxAllocation, AubAllocDump::DumpFormat::IMAGE_TRE));
|
||||
}
|
||||
|
||||
struct AubSurfaceDumpTests : public AubAllocDumpTests,
|
||||
public ::testing::WithParamInterface<std::tuple<bool /*isCompressed*/, AubAllocDump::DumpFormat>> {
|
||||
void SetUp() override {
|
||||
AubAllocDumpTests::SetUp();
|
||||
isCompressed = std::get<0>(GetParam());
|
||||
dumpFormat = std::get<1>(GetParam());
|
||||
}
|
||||
void TearDown() override {
|
||||
AubAllocDumpTests::TearDown();
|
||||
}
|
||||
|
||||
bool isCompressed = false;
|
||||
AubAllocDump::DumpFormat dumpFormat = AubAllocDump::DumpFormat::NONE;
|
||||
};
|
||||
|
||||
HWTEST_P(AubSurfaceDumpTests, givenGraphicsAllocationWhenGetDumpSurfaceIsCalledAndDumpFormatIsSpecifiedThenSurfaceInfoIsReturned) {
|
||||
ExecutionEnvironment *executionEnvironment = pDevice->executionEnvironment;
|
||||
MockMemoryManager memoryManager(*executionEnvironment);
|
||||
|
||||
if (AubAllocDump::isBufferDumpFormat(dumpFormat)) {
|
||||
auto bufferAllocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
||||
ASSERT_NE(nullptr, bufferAllocation);
|
||||
|
||||
bufferAllocation->setAllocationType(isCompressed ? GraphicsAllocation::AllocationType::BUFFER_COMPRESSED : GraphicsAllocation::AllocationType::BUFFER);
|
||||
|
||||
std::unique_ptr<aub_stream::SurfaceInfo> surfaceInfo(AubAllocDump::getDumpSurfaceInfo<FamilyType>(*bufferAllocation, dumpFormat));
|
||||
if (nullptr != surfaceInfo) {
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
using SURFACE_FORMAT = typename RENDER_SURFACE_STATE::SURFACE_FORMAT;
|
||||
EXPECT_EQ(GmmHelper::decanonize(bufferAllocation->getGpuAddress()), surfaceInfo->address);
|
||||
EXPECT_EQ(static_cast<uint32_t>(bufferAllocation->getUnderlyingBufferSize()), surfaceInfo->width);
|
||||
EXPECT_EQ(1u, surfaceInfo->height);
|
||||
EXPECT_EQ(static_cast<uint32_t>(bufferAllocation->getUnderlyingBufferSize()), surfaceInfo->pitch);
|
||||
EXPECT_EQ(SURFACE_FORMAT::SURFACE_FORMAT_RAW, surfaceInfo->format);
|
||||
EXPECT_EQ(RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER, surfaceInfo->surftype);
|
||||
EXPECT_EQ(RENDER_SURFACE_STATE::TILE_MODE_LINEAR, surfaceInfo->tilingType);
|
||||
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED == bufferAllocation->getAllocationType(), surfaceInfo->compressed);
|
||||
EXPECT_EQ((AubAllocDump::DumpFormat::BUFFER_TRE == dumpFormat) ? aub_stream::dumpType::tre : aub_stream::dumpType::bin, surfaceInfo->dumpType);
|
||||
}
|
||||
memoryManager.freeGraphicsMemory(bufferAllocation);
|
||||
}
|
||||
|
||||
if (AubAllocDump::isImageDumpFormat(dumpFormat)) {
|
||||
cl_image_desc imgDesc = {};
|
||||
imgDesc.image_width = 512;
|
||||
imgDesc.image_height = 1;
|
||||
imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
|
||||
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
|
||||
MockGmm::queryImgParams(imgInfo);
|
||||
MockMemoryManager::AllocationData allocationData;
|
||||
allocationData.imgInfo = &imgInfo;
|
||||
auto imageAllocation = memoryManager.allocateGraphicsMemoryForImage(allocationData);
|
||||
ASSERT_NE(nullptr, imageAllocation);
|
||||
|
||||
auto gmm = imageAllocation->getDefaultGmm();
|
||||
gmm->isRenderCompressed = isCompressed;
|
||||
|
||||
std::unique_ptr<aub_stream::SurfaceInfo> surfaceInfo(AubAllocDump::getDumpSurfaceInfo<FamilyType>(*imageAllocation, dumpFormat));
|
||||
if (nullptr != surfaceInfo) {
|
||||
EXPECT_EQ(GmmHelper::decanonize(imageAllocation->getGpuAddress()), surfaceInfo->address);
|
||||
EXPECT_EQ(static_cast<uint32_t>(gmm->gmmResourceInfo->getBaseWidth()), surfaceInfo->width);
|
||||
EXPECT_EQ(static_cast<uint32_t>(gmm->gmmResourceInfo->getBaseHeight()), surfaceInfo->height);
|
||||
EXPECT_EQ(static_cast<uint32_t>(gmm->gmmResourceInfo->getRenderPitch()), surfaceInfo->pitch);
|
||||
EXPECT_EQ(static_cast<uint32_t>(gmm->gmmResourceInfo->getResourceFormatSurfaceState()), surfaceInfo->format);
|
||||
EXPECT_EQ(AubAllocDump::getImageSurfaceTypeFromGmmResourceType<FamilyType>(gmm->gmmResourceInfo->getResourceType()), surfaceInfo->surftype);
|
||||
EXPECT_EQ(gmm->gmmResourceInfo->getTileModeSurfaceState(), surfaceInfo->tilingType);
|
||||
EXPECT_EQ(gmm->isRenderCompressed, surfaceInfo->compressed);
|
||||
EXPECT_EQ((AubAllocDump::DumpFormat::IMAGE_TRE == dumpFormat) ? aub_stream::dumpType::tre : aub_stream::dumpType::bmp, surfaceInfo->dumpType);
|
||||
}
|
||||
memoryManager.freeGraphicsMemory(imageAllocation);
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GetDumpSurfaceTest,
|
||||
AubSurfaceDumpTests,
|
||||
::testing::Combine(
|
||||
::testing::Bool(), // isCompressed
|
||||
::testing::Values( // dumpFormat
|
||||
AubAllocDump::DumpFormat::NONE,
|
||||
AubAllocDump::DumpFormat::BUFFER_BIN,
|
||||
AubAllocDump::DumpFormat::BUFFER_TRE,
|
||||
AubAllocDump::DumpFormat::IMAGE_BMP,
|
||||
AubAllocDump::DumpFormat::IMAGE_TRE)));
|
||||
|
||||
@@ -1169,19 +1169,19 @@ TEST_F(HardwareContextContainerTests, givenMultipleHwContextWhenSingleMethodIsCa
|
||||
|
||||
EXPECT_FALSE(mockHwContext0->dumpBufferBINCalled);
|
||||
EXPECT_FALSE(mockHwContext1->dumpBufferBINCalled);
|
||||
EXPECT_FALSE(mockHwContext0->dumpBufferCalled);
|
||||
EXPECT_FALSE(mockHwContext1->dumpBufferCalled);
|
||||
EXPECT_FALSE(mockHwContext0->dumpSurfaceCalled);
|
||||
EXPECT_FALSE(mockHwContext1->dumpSurfaceCalled);
|
||||
EXPECT_FALSE(mockHwContext0->readMemoryCalled);
|
||||
EXPECT_FALSE(mockHwContext1->readMemoryCalled);
|
||||
|
||||
hwContextContainer.dumpBufferBIN(1, 2);
|
||||
hwContextContainer.dumpBuffer(1, 2, AubAllocDump::DumpFormat::BUFFER_BIN, false);
|
||||
hwContextContainer.dumpSurface({1, 2, 3, 4, 5, 6, 7, false, 0});
|
||||
hwContextContainer.readMemory(1, reinterpret_cast<void *>(0x123), 1, 2, 0);
|
||||
|
||||
EXPECT_TRUE(mockHwContext0->dumpBufferBINCalled);
|
||||
EXPECT_FALSE(mockHwContext1->dumpBufferBINCalled);
|
||||
EXPECT_TRUE(mockHwContext0->dumpBufferCalled);
|
||||
EXPECT_FALSE(mockHwContext1->dumpBufferCalled);
|
||||
EXPECT_TRUE(mockHwContext0->dumpSurfaceCalled);
|
||||
EXPECT_FALSE(mockHwContext1->dumpSurfaceCalled);
|
||||
EXPECT_TRUE(mockHwContext0->readMemoryCalled);
|
||||
EXPECT_FALSE(mockHwContext1->readMemoryCalled);
|
||||
}
|
||||
|
||||
@@ -901,7 +901,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWritableWhenDumpA
|
||||
|
||||
aubCsr.dumpAllocation(*gfxAllocation);
|
||||
|
||||
EXPECT_TRUE(mockHardwareContext->dumpBufferCalled);
|
||||
EXPECT_TRUE(mockHardwareContext->dumpSurfaceCalled);
|
||||
|
||||
memoryManager->freeGraphicsMemory(gfxAllocation);
|
||||
}
|
||||
@@ -927,7 +927,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenCompressedGraphicsAllocationWritabl
|
||||
|
||||
aubCsr.dumpAllocation(*gfxAllocation);
|
||||
|
||||
EXPECT_TRUE(mockHardwareContext->dumpBufferCalled);
|
||||
EXPECT_TRUE(mockHardwareContext->dumpSurfaceCalled);
|
||||
|
||||
memoryManager->freeGraphicsMemory(gfxAllocation);
|
||||
}
|
||||
@@ -949,7 +949,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWritableWhenDumpA
|
||||
|
||||
aubCsr.dumpAllocation(*gfxAllocation);
|
||||
|
||||
EXPECT_FALSE(mockHardwareContext->dumpBufferCalled);
|
||||
EXPECT_FALSE(mockHardwareContext->dumpSurfaceCalled);
|
||||
|
||||
memoryManager->freeGraphicsMemory(gfxAllocation);
|
||||
}
|
||||
@@ -972,7 +972,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationNonWritableWhenDu
|
||||
|
||||
aubCsr.dumpAllocation(*gfxAllocation);
|
||||
|
||||
EXPECT_FALSE(mockHardwareContext->dumpBufferCalled);
|
||||
EXPECT_FALSE(mockHardwareContext->dumpSurfaceCalled);
|
||||
|
||||
memoryManager->freeGraphicsMemory(gfxAllocation);
|
||||
}
|
||||
@@ -997,7 +997,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationNotDumpableWhenDu
|
||||
aubCsr.dumpAllocation(*gfxAllocation);
|
||||
|
||||
EXPECT_FALSE(gfxAllocation->isAllocDumpable());
|
||||
EXPECT_FALSE(mockHardwareContext->dumpBufferCalled);
|
||||
EXPECT_FALSE(mockHardwareContext->dumpSurfaceCalled);
|
||||
|
||||
memoryManager->freeGraphicsMemory(gfxAllocation);
|
||||
}
|
||||
@@ -1022,7 +1022,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationDumpableWhenDumpA
|
||||
aubCsr.dumpAllocation(*gfxAllocation);
|
||||
|
||||
EXPECT_FALSE(gfxAllocation->isAllocDumpable());
|
||||
EXPECT_TRUE(mockHardwareContext->dumpBufferCalled);
|
||||
EXPECT_TRUE(mockHardwareContext->dumpSurfaceCalled);
|
||||
|
||||
memoryManager->freeGraphicsMemory(gfxAllocation);
|
||||
}
|
||||
|
||||
@@ -8,9 +8,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "third_party/aub_stream/headers/aub_manager.h"
|
||||
#include "third_party/aub_stream/headers/aubstream.h"
|
||||
#include "third_party/aub_stream/headers/hardware_context.h"
|
||||
|
||||
struct MockHardwareContext : public aub_stream::HardwareContext {
|
||||
using SurfaceInfo = aub_stream::SurfaceInfo;
|
||||
|
||||
MockHardwareContext(uint32_t deviceIndex) : deviceIndex(deviceIndex) {}
|
||||
~MockHardwareContext() override {}
|
||||
|
||||
@@ -22,7 +25,7 @@ struct MockHardwareContext : public aub_stream::HardwareContext {
|
||||
void expectMemory(uint64_t gfxAddress, const void *memory, size_t size, uint32_t compareOperation) override { expectMemoryCalled = true; }
|
||||
void readMemory(uint64_t gfxAddress, void *memory, size_t size, uint32_t memoryBank, size_t pageSize) override { readMemoryCalled = true; }
|
||||
void dumpBufferBIN(uint64_t gfxAddress, size_t size) override { dumpBufferBINCalled = true; }
|
||||
void dumpBuffer(uint64_t gfxAddress, size_t size, uint32_t format, bool compressed) override { dumpBufferCalled = true; }
|
||||
void dumpSurface(const SurfaceInfo &surfaceInfo) override { dumpSurfaceCalled = true; }
|
||||
|
||||
bool initializeCalled = false;
|
||||
bool pollForCompletionCalled = false;
|
||||
@@ -32,7 +35,7 @@ struct MockHardwareContext : public aub_stream::HardwareContext {
|
||||
bool expectMemoryCalled = false;
|
||||
bool readMemoryCalled = false;
|
||||
bool dumpBufferBINCalled = false;
|
||||
bool dumpBufferCalled = false;
|
||||
bool dumpSurfaceCalled = false;
|
||||
|
||||
const uint32_t deviceIndex;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user