Skip to content

Commit

Permalink
Correct surface format used for CL_LUMINANCE images
Browse files Browse the repository at this point in the history
Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
  • Loading branch information
fhazubski-Intel authored and Compute-Runtime-Automation committed Jun 15, 2022
1 parent 0583413 commit 9c18c02
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
10 changes: 5 additions & 5 deletions opencl/source/helpers/surface_formats.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -50,10 +50,6 @@ namespace NEO {
{{CL_RG, CL_UNSIGNED_INT32}, {GMM_FORMAT_R32G32_UINT_TYPE, GFX3DSTATE_SURFACEFORMAT_R32G32_UINT , 0, 2, 4, 8}}, \
{{CL_RG, CL_HALF_FLOAT}, {GMM_FORMAT_R16G16_FLOAT_TYPE, GFX3DSTATE_SURFACEFORMAT_R16G16_FLOAT , 0, 2, 2, 4}}, \
{{CL_RG, CL_FLOAT}, {GMM_FORMAT_R32G32_FLOAT_TYPE, GFX3DSTATE_SURFACEFORMAT_R32G32_FLOAT , 0, 2, 4, 8}}, \
{{CL_LUMINANCE, CL_UNORM_INT8}, {GMM_FORMAT_GENERIC_8BIT, GFX3DSTATE_SURFACEFORMAT_R8_UNORM , 0, 1, 1, 1}}, \
{{CL_LUMINANCE, CL_UNORM_INT16}, {GMM_FORMAT_GENERIC_16BIT, GFX3DSTATE_SURFACEFORMAT_R16_UNORM , 0, 1, 2, 2}}, \
{{CL_LUMINANCE, CL_HALF_FLOAT}, {GMM_FORMAT_GENERIC_16BIT, GFX3DSTATE_SURFACEFORMAT_R16_FLOAT , 0, 1, 2, 2}}, \
{{CL_LUMINANCE, CL_FLOAT}, {GMM_FORMAT_GENERIC_32BIT, GFX3DSTATE_SURFACEFORMAT_R32_FLOAT , 0, 1, 4, 4}}, \
{{CL_R, CL_SNORM_INT8}, {GMM_FORMAT_R8_SNORM_TYPE, GFX3DSTATE_SURFACEFORMAT_R8_SNORM , 0, 1, 1, 1}}, \
{{CL_R, CL_SNORM_INT16}, {GMM_FORMAT_R16_SNORM_TYPE, GFX3DSTATE_SURFACEFORMAT_R16_SNORM , 0, 1, 2, 2}}, \
{{CL_RG, CL_SNORM_INT8}, {GMM_FORMAT_R8G8_SNORM_TYPE, GFX3DSTATE_SURFACEFORMAT_R8G8_SNORM , 0, 2, 1, 2}}, \
Expand All @@ -66,6 +62,10 @@ namespace NEO {
{{CL_INTENSITY, CL_UNORM_INT16}, {GMM_FORMAT_GENERIC_16BIT, GFX3DSTATE_SURFACEFORMAT_I16_UNORM , 0, 1, 2, 2}}, \
{{CL_INTENSITY, CL_HALF_FLOAT}, {GMM_FORMAT_GENERIC_16BIT, GFX3DSTATE_SURFACEFORMAT_I16_FLOAT , 0, 1, 2, 2}}, \
{{CL_INTENSITY, CL_FLOAT}, {GMM_FORMAT_GENERIC_32BIT, GFX3DSTATE_SURFACEFORMAT_I32_FLOAT , 0, 1, 4, 4}}, \
{{CL_LUMINANCE, CL_UNORM_INT8}, {GMM_FORMAT_GENERIC_8BIT, GFX3DSTATE_SURFACEFORMAT_L8_UNORM , 0, 1, 1, 1}}, \
{{CL_LUMINANCE, CL_UNORM_INT16}, {GMM_FORMAT_GENERIC_16BIT, GFX3DSTATE_SURFACEFORMAT_L16_UNORM , 0, 1, 2, 2}}, \
{{CL_LUMINANCE, CL_HALF_FLOAT}, {GMM_FORMAT_GENERIC_16BIT, GFX3DSTATE_SURFACEFORMAT_L16_FLOAT , 0, 1, 2, 2}}, \
{{CL_LUMINANCE, CL_FLOAT}, {GMM_FORMAT_GENERIC_32BIT, GFX3DSTATE_SURFACEFORMAT_L32_FLOAT , 0, 1, 4, 4}}, \
{{CL_A, CL_UNORM_INT16}, {GMM_FORMAT_GENERIC_16BIT, GFX3DSTATE_SURFACEFORMAT_A16_UNORM , 0, 1, 2, 2}}, \
{{CL_A, CL_HALF_FLOAT}, {GMM_FORMAT_GENERIC_16BIT, GFX3DSTATE_SURFACEFORMAT_A16_FLOAT , 0, 1, 2, 2}}, \
{{CL_A, CL_FLOAT}, {GMM_FORMAT_GENERIC_32BIT, GFX3DSTATE_SURFACEFORMAT_A32_FLOAT , 0, 1, 4, 4}}
Expand Down
10 changes: 5 additions & 5 deletions opencl/test/unit_test/fixtures/image_fixture.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -51,10 +51,6 @@ struct Image1dArrayDefaults : public Image2dDefaults {
static const cl_image_desc imageDesc;
};

struct LuminanceImage : public Image2dDefaults {
static const cl_image_format imageFormat;
};

struct ImageWithoutHostPtr : public Image1dDefaults {
enum { flags = 0 };
static void *hostPtr;
Expand All @@ -75,6 +71,10 @@ struct ImageWriteOnly : public BaseClass {
enum { flags = BaseClass::flags | CL_MEM_WRITE_ONLY };
};

struct LuminanceImage : public ImageReadOnly<Image2dDefaults> {
static const cl_image_format imageFormat;
};

template <typename Traits>
struct ImageHelper {
using Context = NEO::Context;
Expand Down
18 changes: 10 additions & 8 deletions opencl/test/unit_test/mem_obj/image_validate_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -679,13 +679,15 @@ TEST(validateAndCreateImage, givenInvalidImageFormatWhenValidateAndCreateImageIs

TEST(validateAndCreateImage, givenNotSupportedImageFormatWhenValidateAndCreateImageIsCalledThenReturnsNotSupportedFormatError) {
MockContext context;
cl_image_format imageFormat = {CL_INTENSITY, CL_UNORM_INT8};
cl_int retVal = CL_SUCCESS;
cl_mem image;
cl_mem_flags flags = CL_MEM_READ_WRITE;
image = Image::validateAndCreateImage(&context, nullptr, flags, 0, &imageFormat, &Image1dDefaults::imageDesc, nullptr, retVal);
EXPECT_EQ(nullptr, image);
EXPECT_EQ(CL_IMAGE_FORMAT_NOT_SUPPORTED, retVal);
for (cl_channel_order channelOrder : {CL_INTENSITY, CL_LUMINANCE}) {
cl_image_format imageFormat = {channelOrder, CL_UNORM_INT8};
cl_int retVal = CL_SUCCESS;
cl_mem image;
cl_mem_flags flags = CL_MEM_READ_WRITE;
image = Image::validateAndCreateImage(&context, nullptr, flags, 0, &imageFormat, &Image1dDefaults::imageDesc, nullptr, retVal);
EXPECT_EQ(nullptr, image);
EXPECT_EQ(CL_IMAGE_FORMAT_NOT_SUPPORTED, retVal);
}
}

TEST(validateAndCreateImage, givenValidImageParamsWhenValidateAndCreateImageIsCalledThenReturnsSuccess) {
Expand Down

0 comments on commit 9c18c02

Please sign in to comment.