Remove MemObj::rootDeviceEnvironment

Pass Device to Buffer::setArgStateful

Related-To: NEO-4672
Change-Id: I0b7ed3ee578139f250c8470532dc0ae2eb2991e1
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2020-06-30 17:42:12 +02:00
committed by sys_ocldev
parent 6ba5fe2e86
commit 5bc511b77d
13 changed files with 37 additions and 40 deletions

View File

@@ -633,7 +633,6 @@ Buffer *Buffer::createBufferHwFromDevice(const Device *device,
}
pBuffer->offset = offset;
pBuffer->executionEnvironment = device->getExecutionEnvironment();
pBuffer->rootDeviceEnvironment = pBuffer->executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()].get();
return pBuffer;
}
@@ -654,7 +653,7 @@ uint32_t Buffer::getMocsValue(bool disableL3Cache, bool isReadOnlyArgument, uint
bool alignedMemObj = isAligned<MemoryConstants::cacheLineSize>(bufferAddress) &&
isAligned<MemoryConstants::cacheLineSize>(bufferSize);
auto gmmHelper = rootDeviceEnvironment->getGmmHelper();
auto gmmHelper = executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->getGmmHelper();
if (!disableL3Cache && !isMemObjUncacheableForSurfaceState() && (alignedMemObj || readOnlyMemObj || !isMemObjZeroCopy())) {
return gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER);
} else {
@@ -700,7 +699,7 @@ void Buffer::setSurfaceState(const Device *device,
cl_mem_flags flags,
cl_mem_flags_intel flagsIntel) {
auto buffer = Buffer::createBufferHwFromDevice(device, flags, flagsIntel, svmSize, svmPtr, svmPtr, gfxAlloc, offset, true, false, false);
buffer->setArgStateful(surfaceState, false, false, false, false, device->getRootDeviceIndex());
buffer->setArgStateful(surfaceState, false, false, false, false, *device);
buffer->graphicsAllocation = nullptr;
delete buffer;
}

View File

@@ -135,7 +135,7 @@ class Buffer : public MemObj {
bool isSubBuffer();
bool isValidSubBufferOffset(size_t offset);
uint64_t setArgStateless(void *memory, uint32_t patchSize, uint32_t rootDeviceIndex, bool set32BitAddressing);
virtual void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly, uint32_t rootDeviceIndex) = 0;
virtual void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly, const Device &device) = 0;
bool bufferRectPitchSet(const size_t *bufferOrigin,
const size_t *region,
size_t &bufferRowPitch,
@@ -204,8 +204,8 @@ class BufferHw : public Buffer {
: Buffer(context, memoryProperties, flags, flagsIntel, size, memoryStorage, hostPtr, gfxAllocation,
zeroCopy, isHostPtrSVM, isObjectRedescribed) {}
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnlyArgument, uint32_t rootDeviceIndex) override;
void appendBufferState(void *memory, Context *context, GraphicsAllocation *gfxAllocation, bool isReadOnlyArgument);
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnlyArgument, const Device &device) override;
void appendBufferState(void *memory, const Device &device, bool isReadOnlyArgument);
void appendSurfaceStateExt(void *memory);
static Buffer *create(Context *context,

View File

@@ -6,6 +6,7 @@
*/
#include "shared/source/command_container/command_encoder.h"
#include "shared/source/device/device.h"
#include "shared/source/execution_environment/execution_environment.h"
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/gmm_helper/gmm.h"
@@ -32,13 +33,16 @@ union SURFACE_STATE_BUFFER_LENGTH {
};
template <typename GfxFamily>
void BufferHw<GfxFamily>::setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnlyArgument, uint32_t rootDeviceIndex) {
void BufferHw<GfxFamily>::setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnlyArgument, const Device &device) {
auto rootDeviceIndex = device.getRootDeviceIndex();
auto graphicsAllocation = multiGraphicsAllocation.getGraphicsAllocation(rootDeviceIndex);
EncodeSurfaceState<GfxFamily>::encodeBuffer(memory, getBufferAddress(rootDeviceIndex), getSurfaceSize(alignSizeForAuxTranslation, rootDeviceIndex), getMocsValue(disableL3, isReadOnlyArgument, rootDeviceIndex), true);
EncodeSurfaceState<GfxFamily>::encodeExtraBufferParams(multiGraphicsAllocation.getGraphicsAllocation(rootDeviceIndex),
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->getGmmHelper(), memory, forceNonAuxMode, isReadOnlyArgument);
EncodeSurfaceState<GfxFamily>::encodeBuffer(memory, getBufferAddress(rootDeviceIndex),
getSurfaceSize(alignSizeForAuxTranslation, rootDeviceIndex),
getMocsValue(disableL3, isReadOnlyArgument, rootDeviceIndex), true);
EncodeSurfaceState<GfxFamily>::encodeExtraBufferParams(graphicsAllocation,
device.getGmmHelper(), memory, forceNonAuxMode, isReadOnlyArgument);
appendBufferState(memory, context, graphicsAllocation, isReadOnlyArgument);
appendBufferState(memory, device, isReadOnlyArgument);
appendSurfaceStateExt(memory);
}
} // namespace NEO

View File

@@ -10,7 +10,7 @@
namespace NEO {
template <typename GfxFamily>
void BufferHw<GfxFamily>::appendBufferState(void *memory, Context *context, GraphicsAllocation *gfxAllocation, bool isReadOnly) {
void BufferHw<GfxFamily>::appendBufferState(void *memory, const Device &device, bool isReadOnly) {
}
} // namespace NEO

View File

@@ -35,7 +35,7 @@ void ImageHw<GfxFamily>::setImageArg(void *memory, bool setAsMediaBlockImage, ui
auto graphicsAllocation = multiGraphicsAllocation.getGraphicsAllocation(rootDeviceIndex);
auto gmm = graphicsAllocation->getDefaultGmm();
auto gmmHelper = rootDeviceEnvironment->getGmmHelper();
auto gmmHelper = executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->getGmmHelper();
auto imageDescriptor = Image::convertDescriptor(getImageDesc());
ImageInfo imgInfo;
@@ -135,7 +135,7 @@ void ImageHw<GfxFamily>::setMediaImageArg(void *memory, uint32_t rootDeviceIndex
SURFACE_FORMAT surfaceFormat = MEDIA_SURFACE_STATE::SURFACE_FORMAT_Y8_UNORM_VA;
auto graphicsAllocation = multiGraphicsAllocation.getGraphicsAllocation(rootDeviceIndex);
auto gmmHelper = rootDeviceEnvironment->getGmmHelper();
auto gmmHelper = executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->getGmmHelper();
auto surfaceState = reinterpret_cast<MEDIA_SURFACE_STATE *>(memory);
MEDIA_SURFACE_STATE state = GfxFamily::cmdInitMediaSurfaceState;

View File

@@ -49,7 +49,6 @@ MemObj::MemObj(Context *context,
memoryManager = context->getMemoryManager();
auto device = context->getDevice(0);
executionEnvironment = device->getExecutionEnvironment();
rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()].get();
}
if (graphicsAllocation) {
multiGraphicsAllocation.addAllocation(graphicsAllocation);

View File

@@ -24,7 +24,6 @@
namespace NEO {
class ExecutionEnvironment;
struct RootDeviceEnvironment;
class GraphicsAllocation;
struct KernelInfo;
class MemoryManager;
@@ -151,7 +150,6 @@ class MemObj : public BaseObject<_cl_mem> {
MemObj *associatedMemObject = nullptr;
cl_uint refCount = 0;
ExecutionEnvironment *executionEnvironment = nullptr;
RootDeviceEnvironment *rootDeviceEnvironment = nullptr;
bool isZeroCopy;
bool isHostPtrSVM;
bool isObjectRedescribed;