Skip to content

Commit d58b984

Browse files
Fix surfaceState for multisample images
Change-Id: I2d4b17e162f61892ca1a86c241a722ef0c51ee42 Signed-off-by: Maciej Plewka <[email protected]>
1 parent fe85c1d commit d58b984

File tree

16 files changed

+183
-11
lines changed

16 files changed

+183
-11
lines changed

runtime/gen10/image_gen10.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2018 Intel Corporation
2+
* Copyright (C) 2017-2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -8,6 +8,7 @@
88
#include "hw_cmds.h"
99
#include "runtime/mem_obj/image.h"
1010
#include "runtime/mem_obj/image.inl"
11+
#include "runtime/mem_obj/image_base.inl"
1112
#include <map>
1213

1314
namespace OCLRT {

runtime/gen8/image_gen8.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2018 Intel Corporation
2+
* Copyright (C) 2017-2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -8,6 +8,7 @@
88
#include "hw_cmds.h"
99
#include "runtime/mem_obj/image.h"
1010
#include "runtime/mem_obj/image.inl"
11+
#include "runtime/mem_obj/image_base.inl"
1112
#include <map>
1213

1314
namespace OCLRT {

runtime/gen9/image_gen9.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2018 Intel Corporation
2+
* Copyright (C) 2017-2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -8,6 +8,7 @@
88
#include "hw_cmds.h"
99
#include "runtime/mem_obj/image.h"
1010
#include "runtime/mem_obj/image.inl"
11+
#include "runtime/mem_obj/image_base.inl"
1112
#include <map>
1213

1314
namespace OCLRT {

runtime/gmm_helper/gmm.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,4 +249,7 @@ bool Gmm::unifiedAuxTranslationCapable() const {
249249
return gmmFlags->Gpu.CCS && gmmFlags->Gpu.UnifiedAuxSurface && gmmFlags->Info.RenderCompressed;
250250
}
251251

252+
bool Gmm::hasMultisampleControlSurface() const {
253+
return this->gmmResourceInfo->getResourceFlags()->Gpu.MCS;
254+
}
252255
} // namespace OCLRT

runtime/gmm_helper/gmm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class Gmm {
3737
void applyMemoryFlags(bool systemMemoryPool);
3838

3939
bool unifiedAuxTranslationCapable() const;
40+
bool hasMultisampleControlSurface() const;
4041

4142
uint32_t queryQPitch(GMM_RESOURCE_TYPE resType);
4243
void updateImgInfo(ImageInfo &imgInfo, cl_image_desc &imgDesc, cl_uint arrayIndex);

runtime/mem_obj/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (C) 2018 Intel Corporation
2+
# Copyright (C) 2018-2019 Intel Corporation
33
#
44
# SPDX-License-Identifier: MIT
55
#
@@ -13,6 +13,7 @@ set(RUNTIME_SRCS_MEM_OBJ
1313
${CMAKE_CURRENT_SOURCE_DIR}/image.cpp
1414
${CMAKE_CURRENT_SOURCE_DIR}/image.h
1515
${CMAKE_CURRENT_SOURCE_DIR}/image.inl
16+
${CMAKE_CURRENT_SOURCE_DIR}/image_base.inl
1617
${CMAKE_CURRENT_SOURCE_DIR}/image_factory_init.inl
1718
${CMAKE_CURRENT_SOURCE_DIR}/map_operations_handler.cpp
1819
${CMAKE_CURRENT_SOURCE_DIR}/map_operations_handler.h

runtime/mem_obj/image.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018 Intel Corporation
2+
* Copyright (C) 2018-2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -264,7 +264,9 @@ class ImageHw : public Image {
264264
void setImageArg(void *memory, bool setAsMediaBlockImage, uint32_t mipLevel) override;
265265
void setAuxParamsForMultisamples(RENDER_SURFACE_STATE *surfaceState);
266266
void setAuxParamsForCCS(RENDER_SURFACE_STATE *surfaceState, Gmm *gmm);
267+
void setUnifiedAuxBaseAddress(RENDER_SURFACE_STATE *surfaceState, const Gmm *gmm);
267268
MOCKABLE_VIRTUAL void setClearColorParams(RENDER_SURFACE_STATE *surfaceState, const Gmm *gmm);
269+
MOCKABLE_VIRTUAL void setAuxParamsForMCSCCS(RENDER_SURFACE_STATE *surfaceState, Gmm *gmm);
268270
void setMediaImageArg(void *memory) override;
269271
void setMediaSurfaceRotation(void *memory) override;
270272
void setSurfaceMemoryObjectControlStateIndexToMocsTable(void *memory, uint32_t value) override;

runtime/mem_obj/image.inl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,11 @@ void ImageHw<GfxFamily>::setAuxParamsForMultisamples(RENDER_SURFACE_STATE *surfa
165165
if (getMcsAllocation()) {
166166
auto mcsGmm = getMcsAllocation()->gmm;
167167

168-
if (mcsGmm->unifiedAuxTranslationCapable()) { // Ignore MCS allocation when Color Control Surface is available
168+
if (mcsGmm->unifiedAuxTranslationCapable() && mcsGmm->hasMultisampleControlSurface()) {
169+
setAuxParamsForMCSCCS(surfaceState, mcsGmm);
170+
setClearColorParams(surfaceState, mcsGmm);
171+
setUnifiedAuxBaseAddress(surfaceState, mcsGmm);
172+
} else if (mcsGmm->unifiedAuxTranslationCapable()) {
169173
setAuxParamsForCCS(surfaceState, mcsGmm);
170174
} else {
171175
surfaceState->setAuxiliarySurfaceMode((typename RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE)1);
@@ -183,10 +187,14 @@ void ImageHw<GfxFamily>::setAuxParamsForCCS(RENDER_SURFACE_STATE *surfaceState,
183187
// Its expected to not program pitch/qpitch/baseAddress for Aux surface in CCS scenarios
184188
surfaceState->setAuxiliarySurfaceMode(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E);
185189
setClearColorParams(surfaceState, gmm);
190+
setUnifiedAuxBaseAddress(surfaceState, gmm);
186191
}
187192

188193
template <typename GfxFamily>
189-
void ImageHw<GfxFamily>::setClearColorParams(RENDER_SURFACE_STATE *surfaceState, const Gmm *gmm) {
194+
void ImageHw<GfxFamily>::setUnifiedAuxBaseAddress(RENDER_SURFACE_STATE *surfaceState, const Gmm *gmm) {
195+
uint64_t baseAddress = surfaceState->getSurfaceBaseAddress() +
196+
gmm->gmmResourceInfo->getUnifiedAuxSurfaceOffset(GMM_UNIFIED_AUX_TYPE::GMM_AUX_SURF);
197+
surfaceState->setAuxiliarySurfaceBaseAddress(baseAddress);
190198
}
191199

192200
template <typename GfxFamily>

runtime/mem_obj/image_base.inl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (C) 2019 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
namespace OCLRT {
9+
10+
template <typename GfxFamily>
11+
void ImageHw<GfxFamily>::setClearColorParams(RENDER_SURFACE_STATE *surfaceState, const Gmm *gmm) {
12+
}
13+
14+
template <typename GfxFamily>
15+
void ImageHw<GfxFamily>::setAuxParamsForMCSCCS(RENDER_SURFACE_STATE *surfaceState, Gmm *gmm) {
16+
}
17+
} // namespace OCLRT

runtime/sharings/gl/gl_texture.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018 Intel Corporation
2+
* Copyright (C) 2018-2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -130,6 +130,10 @@ Image *GlTexture::createSharedGlTexture(Context *context, cl_mem_flags flags, cl
130130
}
131131

132132
auto glTexture = new GlTexture(sharingFunctions, getClGlObjectType(target), texture, texInfo, target, std::max(miplevel, 0));
133+
134+
if (alloc->gmm->unifiedAuxTranslationCapable()) {
135+
alloc->gmm->isRenderCompressed = context->getMemoryManager()->mapAuxGpuVA(alloc);
136+
}
133137
return Image::createSharedImage(context, glTexture, mcsSurfaceInfo, alloc, mcsAlloc, flags, imgInfo, cubeFaceIndex,
134138
std::max(miplevel, 0), imgDesc.num_mip_levels);
135139
}

0 commit comments

Comments
 (0)