From c218022296f0a33ad7e735737057841077ccc175 Mon Sep 17 00:00:00 2001 From: Sarbojit Sarkar Date: Thu, 21 Oct 2021 10:08:38 +0000 Subject: [PATCH] SWDEV-306773 - Pal fix for 2D/3D memset Change-Id: Id705e9292e17621ea70e283d7494212809456e27 --- rocclr/device/pal/palvirtual.cpp | 35 ++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/rocclr/device/pal/palvirtual.cpp b/rocclr/device/pal/palvirtual.cpp index 355fc5df5c..8df146c5bd 100644 --- a/rocclr/device/pal/palvirtual.cpp +++ b/rocclr/device/pal/palvirtual.cpp @@ -1850,18 +1850,37 @@ bool VirtualGPU::fillMemory(cl_command_type type, amd::Memory* amdMemory, const return true; } -void VirtualGPU::submitFillMemory(amd::FillMemoryCommand& vcmd) { +void VirtualGPU::submitFillMemory(amd::FillMemoryCommand& cmd) { // Make sure VirtualGPU has an exclusive access to the resources amd::ScopedLock lock(execution()); - profilingBegin(vcmd, true); - - if (!fillMemory(vcmd.type(), &vcmd.memory(), vcmd.pattern(), vcmd.patternSize(), vcmd.origin(), - vcmd.size())) { - vcmd.setStatus(CL_INVALID_OPERATION); + profilingBegin(cmd, true); + if (cmd.type() == CL_COMMAND_FILL_IMAGE) { + if (!fillMemory(cmd.type(), &cmd.memory(), cmd.pattern(), cmd.patternSize(), + cmd.origin(), cmd.size())) { + cmd.setStatus(CL_INVALID_OPERATION); + } + } else { + size_t width = cmd.size().c[0]; + size_t height = cmd.size().c[1]; + size_t depth = cmd.size().c[2]; + size_t pitch = cmd.surface().c[0]; + amd::Coord3D origin = cmd.origin(); + amd::Coord3D region{cmd.surface().c[1], cmd.surface().c[2], depth}; + amd::BufferRect rect; + rect.create(static_cast(origin), static_cast(region), + pitch, 0); + for (size_t slice = 0; slice < depth; slice++) { + for (size_t row = 0; row < height; row++) { + const size_t rowOffset = rect.offset(0, row, slice); + if (!fillMemory(cmd.type(), &cmd.memory(), cmd.pattern(), cmd.patternSize(), + amd::Coord3D{rowOffset, 0, 0}, amd::Coord3D{width, 1, 1})) { + cmd.setStatus(CL_INVALID_OPERATION); + } + } + } } - - profilingEnd(vcmd); + profilingEnd(cmd); } void VirtualGPU::submitCopyMemoryP2P(amd::CopyMemoryP2PCommand& cmd) {