mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-26 23:33:20 +08:00
Make EXTERNAL_HOST_PTR one time aub writable
Change-Id: Ib8ac51ebad8997a0b10431d8c78239dc38beb616 Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
@@ -5,12 +5,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/unit_tests/helpers/debug_manager_state_restore.h"
|
||||
#include "runtime/command_stream/command_stream_receiver.h"
|
||||
#include "runtime/event/event.h"
|
||||
#include "test.h"
|
||||
#include "unit_tests/command_queue/command_queue_fixture.h"
|
||||
#include "unit_tests/fixtures/buffer_fixture.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/fixtures/image_fixture.h"
|
||||
#include "unit_tests/mocks/mock_command_queue.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -210,3 +213,52 @@ HWTEST_F(EnqueueUnmapMemObjTest, givenEnqueueUnmapMemObjectWhenNonAubWritableBuf
|
||||
EXPECT_TRUE(buffer->getGraphicsAllocation()->isAubWritable(GraphicsAllocation::defaultBank));
|
||||
EXPECT_TRUE(buffer->getGraphicsAllocation()->isTbxWritable(GraphicsAllocation::defaultBank));
|
||||
}
|
||||
|
||||
HWTEST_F(EnqueueUnmapMemObjTest, givenMemObjWhenUnmappingThenSetAubWritableBeforeEnqueueWrite) {
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.DisableZeroCopyForBuffers.set(true);
|
||||
auto buffer = std::unique_ptr<Buffer>(BufferHelper<>::create());
|
||||
auto image = std::unique_ptr<Image>(Image2dHelper<>::create(BufferDefaults::context));
|
||||
|
||||
class MyMockCommandQueue : public MockCommandQueue {
|
||||
public:
|
||||
using MockCommandQueue::MockCommandQueue;
|
||||
cl_int enqueueWriteBuffer(Buffer *buffer, cl_bool blockingWrite, size_t offset, size_t cb, const void *ptr, GraphicsAllocation *mapAllocation,
|
||||
cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) override {
|
||||
EXPECT_TRUE(buffer->getMapAllocation()->isAubWritable(GraphicsAllocation::defaultBank));
|
||||
EXPECT_TRUE(buffer->getMapAllocation()->isTbxWritable(GraphicsAllocation::defaultBank));
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
cl_int enqueueWriteImage(Image *dstImage, cl_bool blockingWrite, const size_t *origin, const size_t *region,
|
||||
size_t inputRowPitch, size_t inputSlicePitch, const void *ptr, GraphicsAllocation *mapAllocation,
|
||||
cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) override {
|
||||
EXPECT_TRUE(dstImage->getMapAllocation()->isAubWritable(GraphicsAllocation::defaultBank));
|
||||
EXPECT_TRUE(dstImage->getMapAllocation()->isTbxWritable(GraphicsAllocation::defaultBank));
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
};
|
||||
|
||||
MyMockCommandQueue myMockCmdQ(BufferDefaults::context, pDevice, nullptr);
|
||||
|
||||
{
|
||||
auto mapPtr = myMockCmdQ.enqueueMapBuffer(buffer.get(), CL_TRUE, CL_MAP_WRITE, 0, 8, 0, nullptr, nullptr, retVal);
|
||||
|
||||
buffer->getMapAllocation()->setAubWritable(false, GraphicsAllocation::defaultBank);
|
||||
buffer->getMapAllocation()->setTbxWritable(false, GraphicsAllocation::defaultBank);
|
||||
|
||||
myMockCmdQ.enqueueUnmapMemObject(buffer.get(), mapPtr, 0, nullptr, nullptr);
|
||||
}
|
||||
|
||||
{
|
||||
size_t region[] = {1, 0, 0};
|
||||
size_t origin[] = {0, 0, 0};
|
||||
auto mapPtr = myMockCmdQ.enqueueMapImage(image.get(), CL_TRUE, CL_MAP_WRITE, origin, region, nullptr, nullptr, 0,
|
||||
nullptr, nullptr, retVal);
|
||||
|
||||
image->getMapAllocation()->setAubWritable(false, GraphicsAllocation::defaultBank);
|
||||
image->getMapAllocation()->setTbxWritable(false, GraphicsAllocation::defaultBank);
|
||||
|
||||
myMockCmdQ.enqueueUnmapMemObject(image.get(), mapPtr, 0, nullptr, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user