Commit 5f7eeb93 by Jamie Madill Committed by Commit Bot

Add isSRGB flag to angle::Format.

Bug: angleproject:5176 Change-Id: I85fc78206456439ba7dab55c093187fb94364823 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2482290 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarMohan Maiya <m.maiya@samsung.com> Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com>
parent 6d3d381e
......@@ -2,7 +2,7 @@
"src/libANGLE/renderer/FormatID_autogen.h":
"ce83c2449cc723131e4681ff380b59a2",
"src/libANGLE/renderer/Format_table_autogen.cpp":
"046f4c311e45f0ee32a6fe42f0928854",
"b50d9c578bda1a859e61832d96860296",
"src/libANGLE/renderer/angle_format.py":
"32ba71942c0fd00e6807104f1bb80a3c",
"src/libANGLE/renderer/angle_format_data.json":
......@@ -10,5 +10,5 @@
"src/libANGLE/renderer/angle_format_map.json":
"aa4a0d3463b76858a75787b9cdec8e98",
"src/libANGLE/renderer/gen_angle_format_table.py":
"34ab57bb88958e320f509bd5fbd04495"
"a9b364f5dc971890351e2ef8e5700cb7"
}
\ No newline at end of file
......@@ -4,7 +4,7 @@
"src/libANGLE/renderer/angle_format_map.json":
"aa4a0d3463b76858a75787b9cdec8e98",
"src/libANGLE/renderer/gen_angle_format_table.py":
"34ab57bb88958e320f509bd5fbd04495",
"a9b364f5dc971890351e2ef8e5700cb7",
"src/libANGLE/renderer/metal/shaders/blit.metal":
"2f6286729703039d41d0f6a109a23ac2",
"src/libANGLE/renderer/metal/shaders/clear.metal":
......
......@@ -43,6 +43,7 @@ struct Format final : private angle::NonCopyable
bool isBlock,
bool isFixed,
bool isScaled,
bool isSRGB,
gl::VertexAttribType vertexAttribType);
static const Format &Get(FormatID id) { return gFormatInfoTable[static_cast<int>(id)]; }
......@@ -51,7 +52,6 @@ struct Format final : private angle::NonCopyable
constexpr bool hasDepthOrStencilBits() const;
constexpr bool isLUMA() const;
constexpr bool isSRGB() const;
constexpr bool isSint() const;
constexpr bool isUint() const;
......@@ -105,6 +105,7 @@ struct Format final : private angle::NonCopyable
bool isBlock;
bool isFixed;
bool isScaled;
bool isSRGB;
// For vertex formats only. Returns the "type" value for glVertexAttribPointer etc.
gl::VertexAttribType vertexAttribType;
......@@ -143,6 +144,7 @@ constexpr Format::Format(FormatID id,
bool isBlock,
bool isFixed,
bool isScaled,
bool isSRGB,
gl::VertexAttribType vertexAttribType)
: id(id),
glInternalFormat(glFormat),
......@@ -171,6 +173,7 @@ constexpr Format::Format(FormatID id,
isBlock(isBlock),
isFixed(isFixed),
isScaled(isScaled),
isSRGB(isSRGB),
vertexAttribType(vertexAttribType)
{}
......@@ -186,40 +189,6 @@ constexpr bool Format::isLUMA() const
return redBits == 0 && (luminanceBits > 0 || alphaBits > 0);
}
constexpr bool Format::isSRGB() const
{
// R8G8_UNORM_SRGB and B8G8R8_UNORM_SRGB are not yet supported by ANGLE
// clang-format off
return
id == FormatID::R8_UNORM_SRGB ||
id == FormatID::R8G8B8_UNORM_SRGB ||
id == FormatID::R8G8B8A8_UNORM_SRGB ||
id == FormatID::B8G8R8A8_UNORM_SRGB ||
id == FormatID::BC1_RGB_UNORM_SRGB_BLOCK ||
id == FormatID::BC1_RGBA_UNORM_SRGB_BLOCK ||
id == FormatID::BC2_RGBA_UNORM_SRGB_BLOCK ||
id == FormatID::BC3_RGBA_UNORM_SRGB_BLOCK ||
id == FormatID::BPTC_SRGB_ALPHA_UNORM_BLOCK ||
id == FormatID::ETC2_R8G8B8_SRGB_BLOCK ||
id == FormatID::ETC2_R8G8B8A1_SRGB_BLOCK ||
id == FormatID::ETC2_R8G8B8A8_SRGB_BLOCK ||
id == FormatID::ASTC_4x4_SRGB_BLOCK ||
id == FormatID::ASTC_5x4_SRGB_BLOCK ||
id == FormatID::ASTC_5x5_SRGB_BLOCK ||
id == FormatID::ASTC_6x5_SRGB_BLOCK ||
id == FormatID::ASTC_6x6_SRGB_BLOCK ||
id == FormatID::ASTC_8x5_SRGB_BLOCK ||
id == FormatID::ASTC_8x6_SRGB_BLOCK ||
id == FormatID::ASTC_8x8_SRGB_BLOCK ||
id == FormatID::ASTC_10x5_SRGB_BLOCK ||
id == FormatID::ASTC_10x6_SRGB_BLOCK ||
id == FormatID::ASTC_10x8_SRGB_BLOCK ||
id == FormatID::ASTC_10x10_SRGB_BLOCK ||
id == FormatID::ASTC_12x10_SRGB_BLOCK ||
id == FormatID::ASTC_12x12_SRGB_BLOCK;
// clang-format on
}
constexpr bool Format::isSint() const
{
return componentType == GL_INT;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -71,7 +71,7 @@ static constexpr rx::FastCopyFunctionMap NoCopyFunctions;
const Format gFormatInfoTable[] = {{
// clang-format off
{{ FormatID::NONE, GL_NONE, GL_NONE, nullptr, NoCopyFunctions, nullptr, nullptr, GL_NONE, 0, 0, 0, 0, 0, 0, 0, 0, 0, false, false, false, gl::VertexAttribType::InvalidEnum }},
{{ FormatID::NONE, GL_NONE, GL_NONE, nullptr, NoCopyFunctions, nullptr, nullptr, GL_NONE, 0, 0, 0, 0, 0, 0, 0, 0, 0, false, false, false, false, gl::VertexAttribType::InvalidEnum }},
{angle_format_info_cases} // clang-format on
}};
......@@ -194,7 +194,7 @@ def get_color_write_function(angle_format):
return 'WriteColor<' + channel_struct + ', ' + write_component_type + '>'
format_entry_template = """ {{ FormatID::{id}, {glInternalFormat}, {fboImplementationInternalFormat}, {mipGenerationFunction}, {fastCopyFunctions}, {colorReadFunction}, {colorWriteFunction}, {namedComponentType}, {R}, {G}, {B}, {A}, {L}, {D}, {S}, {pixelBytes}, {componentAlignmentMask}, {isBlock}, {isFixed}, {isScaled}, {vertexAttribType} }},
format_entry_template = """ {{ FormatID::{id}, {glInternalFormat}, {fboImplementationInternalFormat}, {mipGenerationFunction}, {fastCopyFunctions}, {colorReadFunction}, {colorWriteFunction}, {namedComponentType}, {R}, {G}, {B}, {A}, {L}, {D}, {S}, {pixelBytes}, {componentAlignmentMask}, {isBlock}, {isFixed}, {isScaled}, {isSRGB}, {vertexAttribType} }},
"""
......@@ -275,6 +275,10 @@ def get_vertex_attrib_type(format_id):
return "InvalidEnum"
def bool_str(cond):
return "true" if cond else "false"
def json_to_table_data(format_id, json, angle_to_gl):
table_data = ""
......@@ -334,9 +338,10 @@ def json_to_table_data(format_id, json, angle_to_gl):
parsed["pixelBytes"] = pixel_bytes
parsed["componentAlignmentMask"] = get_component_alignment_mask(parsed["channels"],
parsed["bits"])
parsed["isBlock"] = "true" if is_block else "false"
parsed["isFixed"] = "true" if "FIXED" in format_id else "false"
parsed["isScaled"] = "true" if "SCALED" in format_id else "false"
parsed["isBlock"] = bool_str(is_block)
parsed["isFixed"] = bool_str("FIXED" in format_id)
parsed["isScaled"] = bool_str("SCALED" in format_id)
parsed["isSRGB"] = bool_str("SRGB" in format_id)
parsed["vertexAttribType"] = "gl::VertexAttribType::" + get_vertex_attrib_type(format_id)
......
......@@ -2281,10 +2281,10 @@ bool TextureVk::shouldUseLinearColorspaceWithSampler(const SamplerVk *samplerVk)
}
else
{
ASSERT(mImage->getFormat().actualImageFormat().isSRGB() ==
ASSERT(mImage->getFormat().actualImageFormat().isSRGB ==
(vk::ConvertToLinear(mImage->getFormat().vkImageFormat) !=
VK_FORMAT_UNDEFINED));
return !mImage->getFormat().actualImageFormat().isSRGB();
return !mImage->getFormat().actualImageFormat().isSRGB;
}
default:
// sRGB_decode texture state takes precedence over sRGB_override texture state
......@@ -2298,10 +2298,10 @@ bool TextureVk::shouldUseLinearColorspaceWithSampler(const SamplerVk *samplerVk)
}
else
{
ASSERT(mImage->getFormat().actualImageFormat().isSRGB() ==
ASSERT(mImage->getFormat().actualImageFormat().isSRGB ==
(vk::ConvertToLinear(mImage->getFormat().vkImageFormat) !=
VK_FORMAT_UNDEFINED));
return !mImage->getFormat().actualImageFormat().isSRGB();
return !mImage->getFormat().actualImageFormat().isSRGB;
}
}
}
......@@ -2336,9 +2336,9 @@ bool TextureVk::shouldUseLinearColorspaceWithTexelFetch(bool colorspaceWithSampl
}
else
{
ASSERT(mImage->getFormat().actualImageFormat().isSRGB() ==
ASSERT(mImage->getFormat().actualImageFormat().isSRGB ==
(vk::ConvertToLinear(mImage->getFormat().vkImageFormat) != VK_FORMAT_UNDEFINED));
return !mImage->getFormat().actualImageFormat().isSRGB();
return !mImage->getFormat().actualImageFormat().isSRGB;
}
}
else
......@@ -2402,9 +2402,9 @@ const vk::ImageView &TextureVk::getCopyImageViewAndRecordUse(ContextVk *contextV
const vk::ImageViewHelper &imageViews = getImageViews();
imageViews.retain(&contextVk->getResourceUseList());
ASSERT(mImage->getFormat().actualImageFormat().isSRGB() ==
ASSERT(mImage->getFormat().actualImageFormat().isSRGB ==
(vk::ConvertToLinear(mImage->getFormat().vkImageFormat) != VK_FORMAT_UNDEFINED));
if (!mImage->getFormat().actualImageFormat().isSRGB())
if (!mImage->getFormat().actualImageFormat().isSRGB)
{
return imageViews.getLinearCopyImageView();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment