P4 to Git Change 1133818 by gandryey@gera-w8 on 2015/03/24 11:30:12
ECR #304775 - Mipmaps support in OCL - Add support for clEnqueueMapImage/Unmap functionality Affected files ... ... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_memobj.cpp#76 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#175 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#241 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.cpp#503 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.hpp#140 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpumemory.cpp#120 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuresource.cpp#212 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuvirtual.cpp#356 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa/hsadevice.cpp#89 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa/hsadevice.hpp#46 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsadevice.cpp#27 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsadevice.hpp#13 edit ... //depot/stg/opencl/drivers/opencl/runtime/platform/commandqueue.hpp#14 edit
This commit is contained in:
@@ -1669,6 +1669,7 @@ Device::createBuffer(
|
||||
!internalAlloc) {
|
||||
Resource::CreateParams params;
|
||||
params.owner_ = &owner;
|
||||
params.gpu_ = static_cast<VirtualGPU*>(owner.getVirtualDevice());
|
||||
|
||||
// Create memory object
|
||||
result = gpuMemory->create(type, ¶ms);
|
||||
@@ -2145,26 +2146,6 @@ Device::unbindExternalDevice(intptr_t type, void* pDevice, void* pContext, bool
|
||||
return true;
|
||||
}
|
||||
|
||||
void*
|
||||
Device::allocMapTarget(
|
||||
amd::Memory& mem,
|
||||
const amd::Coord3D& origin,
|
||||
const amd::Coord3D& region,
|
||||
uint mapFlags,
|
||||
size_t* rowPitch,
|
||||
size_t* slicePitch)
|
||||
{
|
||||
// Translate memory references
|
||||
gpu::Memory* memory = getGpuMemory(&mem);
|
||||
if (memory == NULL) {
|
||||
LogError("allocMapTarget failed. Can't allocate video memory");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Pass request over to memory
|
||||
return memory->allocMapTarget(origin, region, mapFlags, rowPitch, slicePitch);
|
||||
}
|
||||
|
||||
bool
|
||||
Device::globalFreeMemory(size_t* freeMemory) const
|
||||
{
|
||||
|
||||
@@ -105,17 +105,6 @@ public:
|
||||
virtual bool unbindExternalDevice(
|
||||
intptr_t type, void* pDevice, void* pContext, bool validateOnly) { return true; }
|
||||
|
||||
//! Gets a pointer to a region of host-visible memory for use as the target
|
||||
//! of a non-blocking map for a given memory object
|
||||
virtual void* allocMapTarget(
|
||||
amd::Memory& mem, //!< Abstraction layer memory object
|
||||
const amd::Coord3D& origin, //!< The map location in memory
|
||||
const amd::Coord3D& region, //!< The map region in memory
|
||||
uint mapFlags, //!< Map flags
|
||||
size_t* rowPitch = NULL, //!< Row pitch for the mapped memory
|
||||
size_t* slicePitch = NULL //!< Slice for the mapped memory
|
||||
) { return NULL; }
|
||||
|
||||
//! Releases non-blocking map target memory
|
||||
virtual void freeMapTarget(amd::Memory& mem, void* target) {}
|
||||
|
||||
@@ -432,17 +421,6 @@ public:
|
||||
const device::VirtualDevice* vdev
|
||||
);
|
||||
|
||||
//! Gets a pointer to a region of host-visible memory for use as the target
|
||||
//! of a non-blocking map for a given memory object
|
||||
virtual void* allocMapTarget(
|
||||
amd::Memory& mem, //!< Abstraction layer memory object
|
||||
const amd::Coord3D& origin, //!< The map location in memory
|
||||
const amd::Coord3D& region, //!< The map region in memory
|
||||
uint mapFlags, //!< Map flags
|
||||
size_t* rowPitch = NULL, //!< Row pitch for the mapped memory
|
||||
size_t* slicePitch = NULL //!< Slice for the mapped memory
|
||||
);
|
||||
|
||||
//! Retrieves information about free memory on a GPU device
|
||||
virtual bool globalFreeMemory(size_t* freeMemory) const;
|
||||
|
||||
|
||||
@@ -1324,8 +1324,9 @@ Image::allocMapTarget(
|
||||
memory = new (owner()->getContext())
|
||||
amd::Buffer(owner()->getContext(), 0,
|
||||
cal()->width_ * height * depth * elementSize());
|
||||
Memory* gpuMemory;
|
||||
memory->setVirtualDevice(owner()->getVirtualDevice());
|
||||
|
||||
Memory* gpuMemory;
|
||||
do {
|
||||
if ((memory == NULL) || !memory->create(NULL, SysMem)) {
|
||||
failed = true;
|
||||
|
||||
@@ -664,6 +664,9 @@ Resource::create(MemoryType memType, CreateParams* params, bool heap)
|
||||
viewLevel = imageView->level_;
|
||||
gslResource = imageView->resource_->gslResource();
|
||||
viewOwner_ = imageView->resource_;
|
||||
if (viewLevel != 0) {
|
||||
viewFlags |= CAL_RESALLOCSLICEVIEW_LEVEL;
|
||||
}
|
||||
if (viewLayer != 0) {
|
||||
viewFlags |= CAL_RESALLOCSLICEVIEW_LEVEL_AND_LAYER;
|
||||
}
|
||||
@@ -1662,7 +1665,7 @@ Resource::mapLayers(VirtualGPU* gpu, CALuint flags)
|
||||
sliceResource = dev().resAllocView(
|
||||
gslResource(), gslSize,
|
||||
calOffset, cal()->format_, cal()->channelOrder_, gslDim,
|
||||
0, i, CAL_RESALLOCSLICEVIEW_LAYER);
|
||||
0, i, CAL_RESALLOCSLICEVIEW_LEVEL_AND_LAYER);
|
||||
if (0 == sliceResource) {
|
||||
LogError("Map layer. resAllocSliceView failed!");
|
||||
return NULL;
|
||||
@@ -1772,7 +1775,7 @@ Resource::unmapLayers(VirtualGPU* gpu)
|
||||
sliceResource = dev().resAllocView(
|
||||
gslResource(), gslSize,
|
||||
calOffset, cal()->format_, cal()->channelOrder_, gslDim,
|
||||
0, i, CAL_RESALLOCSLICEVIEW_LAYER);
|
||||
0, i, CAL_RESALLOCSLICEVIEW_LEVEL_AND_LAYER);
|
||||
if (0 == sliceResource) {
|
||||
LogError("Unmap layer. resAllocSliceView failed!");
|
||||
return;
|
||||
|
||||
@@ -1150,6 +1150,17 @@ VirtualGPU::submitMapMemory(amd::MapMemoryCommand& vcmd)
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Validate if it's a view for a map of mip level
|
||||
if (memory->isUnmapWrite() && (vcmd.memory().parent() != NULL)) {
|
||||
amd::Image* amdImage = vcmd.memory().parent()->asImage();
|
||||
if ((amdImage != NULL) && (amdImage->getMipLevels() > 1)) {
|
||||
// Save map write info in the parent object
|
||||
dev().getGpuMemory(amdImage)->saveMapInfo(
|
||||
vcmd.origin(), vcmd.size(),
|
||||
vcmd.mapFlags(), vcmd.isEntireMemory(),
|
||||
vcmd.memory().asImage());
|
||||
}
|
||||
}
|
||||
if (!blitMgr().copyImageToBuffer(*memory,
|
||||
*memory->mapMemory(), vcmd.origin(), dstOrigin,
|
||||
vcmd.size(), vcmd.isEntireMemory())) {
|
||||
@@ -1175,6 +1186,20 @@ VirtualGPU::submitUnmapMemory(amd::UnmapMemoryCommand& vcmd)
|
||||
profilingBegin(vcmd, true);
|
||||
gpu::Memory* memory = dev().getGpuMemory(&vcmd.memory());
|
||||
amd::Memory* owner = memory->owner();
|
||||
bool unmapMip = false;
|
||||
|
||||
// Check if image is a mipmap and assign a saved view
|
||||
amd::Image* amdImage = owner->asImage();
|
||||
if ((amdImage != NULL) && (amdImage->getMipLevels() > 1) &&
|
||||
memory->isUnmapWrite() &&
|
||||
(memory->writeMapInfo()->baseMip_ != NULL)) {
|
||||
// Clear unmap flags from the parent image
|
||||
memory->clearUnmapFlags();
|
||||
// Assign mip level view
|
||||
amdImage = memory->writeMapInfo()->baseMip_;
|
||||
memory = dev().getGpuMemory(amdImage);
|
||||
unmapMip = true;
|
||||
}
|
||||
|
||||
// We used host memory
|
||||
if ((owner->getHostMem() != NULL) && memory->isDirectMap()) {
|
||||
@@ -1249,6 +1274,11 @@ VirtualGPU::submitUnmapMemory(amd::UnmapMemoryCommand& vcmd)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((amdImage != NULL) && (amdImage->getMipLevels() > 1) &&
|
||||
(!memory->isUnmapWrite())) {
|
||||
// Release a view for a mipmap map
|
||||
amdImage->release();
|
||||
}
|
||||
else {
|
||||
LogError("Unhandled unmap!");
|
||||
vcmd.setStatus(CL_INVALID_VALUE);
|
||||
@@ -1257,6 +1287,10 @@ VirtualGPU::submitUnmapMemory(amd::UnmapMemoryCommand& vcmd)
|
||||
// Clear unmap flags
|
||||
memory->clearUnmapFlags();
|
||||
|
||||
// Release a view for a mipmap map
|
||||
if (unmapMip) {
|
||||
amdImage->release();
|
||||
}
|
||||
profilingEnd(vcmd);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user