From 5541f6a307cd1fbe8bdfee65b2074a6f8108bf97 Mon Sep 17 00:00:00 2001
From: foreman
Date: Thu, 14 Jul 2016 18:10:35 -0400
Subject: [PATCH] P4 to Git Change 1291732 by gandryey@gera-w8 on 2016/07/14
17:33:57
SWDEV-95911 - OpenCL on PAL - Mipmaps
- Fix failures with mipmaps
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#14 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palresource.cpp#7 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palresource.hpp#5 edit
---
rocclr/runtime/device/pal/paldevice.cpp | 1 +
rocclr/runtime/device/pal/palresource.cpp | 9 +++++++--
rocclr/runtime/device/pal/palresource.hpp | 1 +
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/rocclr/runtime/device/pal/paldevice.cpp b/rocclr/runtime/device/pal/paldevice.cpp
index 608f676088..f778072da9 100644
--- a/rocclr/runtime/device/pal/paldevice.cpp
+++ b/rocclr/runtime/device/pal/paldevice.cpp
@@ -1890,6 +1890,7 @@ Device::fillHwSampler(
samplerInfo.filter.zFilter = Pal::XyFilterPoint;
samplerInfo.flags.unnormalizedCoords = !(state & amd::Sampler::StateNormalizedCoordsMask);
+ samplerInfo.maxLod = 4096.0f;
state &= ~amd::Sampler::StateNormalizedCoordsMask;
diff --git a/rocclr/runtime/device/pal/palresource.cpp b/rocclr/runtime/device/pal/palresource.cpp
index b6f47d0f0e..ba57a7f1c8 100644
--- a/rocclr/runtime/device/pal/palresource.cpp
+++ b/rocclr/runtime/device/pal/palresource.cpp
@@ -190,6 +190,7 @@ Resource::Resource(
desc_.SVMRes_ = false;
desc_.scratch_ = false;
desc_.isAllocExecute_ = false;
+ desc_.baseLevel_ = 0;
}
Resource::Resource(
@@ -231,6 +232,7 @@ Resource::Resource(
desc_.SVMRes_ = false;
desc_.scratch_ = false;
desc_.isAllocExecute_ = false;
+ desc_.baseLevel_ = 0;
switch (imageType) {
case CL_MEM_OBJECT_IMAGE2D:
@@ -682,6 +684,7 @@ Resource::create(MemoryType memType, CreateParams* params)
if (desc().topology_ == CL_MEM_OBJECT_IMAGE2D_ARRAY) {
ImgSubresRange.numSlices = desc_.depth_;
}
+ ImgSubresRange.numMips = desc().mipLevels_;
viewInfo.subresRange = ImgSubresRange;
dev().iDev()->CreateImageViewSrds(1, &viewInfo, hwState_);
@@ -777,6 +780,7 @@ Resource::create(MemoryType memType, CreateParams* params)
if (memoryType() == ImageView) {
ImageViewParams* imageView = reinterpret_cast(params);
ImgSubresRange.startSubres.mipLevel = imageView->level_;
+ desc_.baseLevel_ = imageView->level_;
ImgSubresRange.startSubres.arraySlice = imageView->layer_;
viewOwner_ = imageView->resource_;
image_ = viewOwner_->image_;
@@ -786,6 +790,7 @@ Resource::create(MemoryType memType, CreateParams* params)
ImageBufferParams* imageBuffer = reinterpret_cast(params);
viewOwner_ = imageBuffer->resource_;
}
+ ImgSubresRange.numMips = desc().mipLevels_;
if ((memoryType() != ImageView) ||
//! @todo PAL doesn't allow an SRD view creation with different pixel size
@@ -1126,8 +1131,6 @@ Resource::partialMemCopyTo(
bool flushDMA,
uint bytesPerElement) const
{
- Pal::SubresId ImgSubresId = { Pal::ImageAspect::Color, 0, 0 };
- Pal::SubresRange ImgSubresRange = { ImgSubresId, 1, 1 };
GpuEvent event;
bool result = true;
EngineType activeEngineID = gpu.engineID_;
@@ -1170,6 +1173,7 @@ Resource::partialMemCopyTo(
gpu.queue(gpu.engineID_).addCmdMemRef(iMem());
gpu.queue(gpu.engineID_).addCmdMemRef(dstResource.iMem());
if (desc().buffer_ && !dstResource.desc().buffer_) {
+ Pal::SubresId ImgSubresId = { Pal::ImageAspect::Color, dstResource.desc().baseLevel_, 0 };
Pal::MemoryImageCopyRegion copyRegion = {};
copyRegion.imageSubres = ImgSubresId;
copyRegion.imageOffset.x = calDstOrigin[0];
@@ -1199,6 +1203,7 @@ Resource::partialMemCopyTo(
}
else if (!desc().buffer_ && dstResource.desc().buffer_) {
Pal::MemoryImageCopyRegion copyRegion = {};
+ Pal::SubresId ImgSubresId = { Pal::ImageAspect::Color, desc().baseLevel_, 0 };
copyRegion.imageSubres = ImgSubresId;
copyRegion.imageOffset.x = calSrcOrigin[0];
copyRegion.imageOffset.y = calSrcOrigin[1];
diff --git a/rocclr/runtime/device/pal/palresource.hpp b/rocclr/runtime/device/pal/palresource.hpp
index 9687674c6b..bb953b5a0d 100644
--- a/rocclr/runtime/device/pal/palresource.hpp
+++ b/rocclr/runtime/device/pal/palresource.hpp
@@ -164,6 +164,7 @@ public:
size_t width_; //!< Resource width
size_t height_; //!< Resource height
size_t depth_; //!< Resource depth
+ uint baseLevel_; //!< The base level for the view
uint mipLevels_; //!< Number of mip levels
uint flags_; //!< Resource flags, used in creation
size_t pitch_; //!< Resource pitch, valid if locked