mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-27 15:53:13 +08:00
Move programming image surface state to core folder [3/n]
Change-Id: I383ce0797dfae1a5ee2bc49e6d9b885ef6787379
This commit is contained in:
@@ -39,7 +39,6 @@ void setImageSurfaceState(typename GfxFamily::RENDER_SURFACE_STATE *surfaceState
|
||||
|
||||
if (cubeFaceIndex != __GMM_NO_CUBE_MAP) {
|
||||
isImageArray = true;
|
||||
imageCount = __GMM_MAX_CUBE_FACE - cubeFaceIndex;
|
||||
renderTargetViewExtent = 1;
|
||||
minimumArrayElement = cubeFaceIndex;
|
||||
}
|
||||
@@ -86,4 +85,27 @@ void setImageSurfaceState(typename GfxFamily::RENDER_SURFACE_STATE *surfaceState
|
||||
|
||||
surfaceState->setSurfaceFormat(static_cast<SURFACE_FORMAT>(imageInfo.surfaceFormat->GenxSurfaceFormat));
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
void setImageSurfaceStateDimensions(typename GfxFamily::RENDER_SURFACE_STATE *surfaceState, const ImageInfo &imageInfo, uint32_t cubeFaceIndex, typename GfxFamily::RENDER_SURFACE_STATE::SURFACE_TYPE surfaceType) {
|
||||
auto imageCount = std::max(imageInfo.imgDesc.imageDepth, imageInfo.imgDesc.imageArraySize);
|
||||
if (imageCount == 0) {
|
||||
imageCount = 1;
|
||||
}
|
||||
|
||||
auto imageHeight = imageInfo.imgDesc.imageHeight;
|
||||
if (imageHeight == 0) {
|
||||
imageHeight = 1;
|
||||
}
|
||||
|
||||
if (cubeFaceIndex != __GMM_NO_CUBE_MAP) {
|
||||
imageCount = __GMM_MAX_CUBE_FACE - cubeFaceIndex;
|
||||
}
|
||||
|
||||
surfaceState->setWidth(static_cast<uint32_t>(imageInfo.imgDesc.imageWidth));
|
||||
surfaceState->setHeight(static_cast<uint32_t>(imageHeight));
|
||||
surfaceState->setDepth(static_cast<uint32_t>(imageCount));
|
||||
surfaceState->setSurfacePitch(static_cast<uint32_t>(imageInfo.imgDesc.imageRowPitch));
|
||||
surfaceState->setSurfaceType(surfaceType);
|
||||
}
|
||||
} // namespace NEO
|
||||
|
||||
@@ -115,4 +115,16 @@ HWTEST_F(ImageSurfaceStateTests, givenImageInfoWhenSetImageSurfaceStateThenPrope
|
||||
EXPECT_EQ(castSurfaceState->getAuxiliarySurfacePitch(), 1u);
|
||||
EXPECT_EQ(castSurfaceState->getAuxiliarySurfaceQpitch(), 0u);
|
||||
EXPECT_EQ(castSurfaceState->getAuxiliarySurfaceBaseAddress(), 0u);
|
||||
|
||||
surfaceState = std::make_unique<char[]>(size);
|
||||
castSurfaceState = reinterpret_cast<typename FamilyType::RENDER_SURFACE_STATE *>(surfaceState.get());
|
||||
typename FamilyType::RENDER_SURFACE_STATE::SURFACE_TYPE surfaceType = RENDER_SURFACE_STATE::SURFACE_TYPE::SURFACE_TYPE_SURFTYPE_3D;
|
||||
|
||||
setImageSurfaceStateDimensions<FamilyType>(castSurfaceState, imageInfo, cubeFaceIndex, surfaceType);
|
||||
|
||||
EXPECT_EQ(castSurfaceState->getWidth(), static_cast<uint32_t>(imageInfo.imgDesc.imageWidth));
|
||||
EXPECT_EQ(castSurfaceState->getHeight(), static_cast<uint32_t>(imageInfo.imgDesc.imageHeight));
|
||||
EXPECT_EQ(castSurfaceState->getDepth(), __GMM_MAX_CUBE_FACE - cubeFaceIndex);
|
||||
EXPECT_EQ(castSurfaceState->getSurfacePitch(), static_cast<uint32_t>(imageInfo.imgDesc.imageRowPitch));
|
||||
EXPECT_EQ(castSurfaceState->getSurfaceType(), surfaceType);
|
||||
}
|
||||
|
||||
@@ -42,20 +42,6 @@ void ImageHw<GfxFamily>::setImageArg(void *memory, bool setAsMediaBlockImage, ui
|
||||
imgInfo.qPitch = qPitch;
|
||||
imgInfo.surfaceFormat = &getSurfaceFormatInfo().surfaceFormat;
|
||||
|
||||
auto imageHeight = getImageDesc().image_height;
|
||||
if (imageHeight == 0) {
|
||||
imageHeight = 1;
|
||||
}
|
||||
|
||||
auto imageCount = std::max(getImageDesc().image_depth, getImageDesc().image_array_size);
|
||||
if (imageCount == 0) {
|
||||
imageCount = 1;
|
||||
}
|
||||
|
||||
if (cubeFaceIndex != __GMM_NO_CUBE_MAP) {
|
||||
imageCount = __GMM_MAX_CUBE_FACE - cubeFaceIndex;
|
||||
}
|
||||
|
||||
setImageSurfaceState<GfxFamily>(surfaceState, imgInfo, getGraphicsAllocation()->getDefaultGmm(), *gmmHelper, cubeFaceIndex, getGraphicsAllocation()->getGpuAddress(), surfaceOffsets, IsNV12Image(&this->getImageFormat()));
|
||||
|
||||
if (getImageDesc().image_type == CL_MEM_OBJECT_IMAGE1D_BUFFER) {
|
||||
@@ -70,16 +56,11 @@ void ImageHw<GfxFamily>::setImageArg(void *memory, bool setAsMediaBlockImage, ui
|
||||
surfaceState->setSurfacePitch(static_cast<uint32_t>(getSurfaceFormatInfo().surfaceFormat.ImageElementSizeInBytes));
|
||||
surfaceState->setSurfaceType(RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER);
|
||||
} else {
|
||||
setImageSurfaceStateDimensions<GfxFamily>(surfaceState, imgInfo, cubeFaceIndex, surfaceType);
|
||||
if (setAsMediaBlockImage) {
|
||||
uint32_t elSize = static_cast<uint32_t>(getSurfaceFormatInfo().surfaceFormat.ImageElementSizeInBytes);
|
||||
surfaceState->setWidth(static_cast<uint32_t>((getImageDesc().image_width * elSize) / sizeof(uint32_t)));
|
||||
} else {
|
||||
surfaceState->setWidth(static_cast<uint32_t>(getImageDesc().image_width));
|
||||
}
|
||||
surfaceState->setHeight(static_cast<uint32_t>(imageHeight));
|
||||
surfaceState->setDepth(static_cast<uint32_t>(imageCount));
|
||||
surfaceState->setSurfacePitch(static_cast<uint32_t>(getImageDesc().image_row_pitch));
|
||||
surfaceState->setSurfaceType(surfaceType);
|
||||
}
|
||||
|
||||
surfaceState->setSurfaceMinLod(this->baseMipLevel + mipLevel);
|
||||
|
||||
Reference in New Issue
Block a user