Commit 2bfc4119 by Jamie Madill Committed by Commit Bot

Put angle::Format table in a cpp file.

The best practice is to expose a non-constexpr query function and hide the constexpr table in a cpp, so it won't be included verbatim in multiple other source files. BUG=angleproject:1389 Change-Id: Ic4e19d14c832643be1552c5a14e441826c41970f Reviewed-on: https://chromium-review.googlesource.com/404478Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 20789317
......@@ -15,10 +15,6 @@
#include "libANGLE/formatutils.h"
#include "libANGLE/renderer/renderer_utils.h"
#include "image_util/copyimage.h"
#include "image_util/generatemip.h"
#include "image_util/loadimage.h"
namespace angle
{
......@@ -40,7 +36,7 @@ struct Format final : angle::NonCopyable
GLuint depthBits,
GLuint stencilBits);
constexpr static const Format &Get(ID id);
static const Format &Get(ID id);
ID id;
......@@ -69,11 +65,6 @@ struct Format final : angle::NonCopyable
GLuint stencilBits;
};
static constexpr rx::FastCopyFunctionMap::Entry BGRAEntry = {GL_RGBA, GL_UNSIGNED_BYTE,
CopyBGRA8ToRGBA8};
static constexpr rx::FastCopyFunctionMap BGRACopyFunctions = {&BGRAEntry, 1};
static constexpr rx::FastCopyFunctionMap NoCopyFunctions;
constexpr Format::Format(ID id,
GLenum glFormat,
GLenum fboFormat,
......@@ -106,17 +97,5 @@ constexpr Format::Format(ID id,
} // namespace angle
#include "libANGLE/renderer/Format_ID_autogen.inl"
#include "libANGLE/renderer/Format_table_autogen.inl"
namespace angle
{
// static
constexpr const Format &Format::Get(ID id)
{
return g_formatInfoTable[static_cast<size_t>(id)];
}
} // namespace angle
#endif // LIBANGLE_RENDERER_FORMAT_H_
......@@ -8,11 +8,21 @@
// ANGLE Format table:
// Queries for typed format information from the ANGLE format enum.
#include "libANGLE/renderer/Format.h"
#include "image_util/copyimage.h"
#include "image_util/generatemip.h"
#include "image_util/loadimage.h"
namespace angle
{
constexpr Format g_formatInfoTable[] =
{
static constexpr rx::FastCopyFunctionMap::Entry BGRAEntry = {GL_RGBA, GL_UNSIGNED_BYTE,
CopyBGRA8ToRGBA8};
static constexpr rx::FastCopyFunctionMap BGRACopyFunctions = {&BGRAEntry, 1};
static constexpr rx::FastCopyFunctionMap NoCopyFunctions;
constexpr Format g_formatInfoTable[] = {
// clang-format off
{ Format::ID::NONE, GL_NONE, GL_NONE, nullptr, NoCopyFunctions, nullptr, GL_NONE, 0, 0, 0, 0, 0, 0 },
{ Format::ID::A16_FLOAT, GL_ALPHA16F_EXT, GL_ALPHA16F_EXT, GenerateMip<A16F>, NoCopyFunctions, ReadColor<A16F, GLfloat>, GL_FLOAT, 0, 0, 0, 16, 0, 0 },
......@@ -138,4 +148,10 @@ constexpr Format g_formatInfoTable[] =
// clang-format on
};
// static
const Format &Format::Get(ID id)
{
return g_formatInfoTable[static_cast<size_t>(id)];
}
} // namespace angle
......@@ -1812,7 +1812,7 @@ const Format &Format::Get(GLenum internalFormat, const Renderer11DeviceCaps &dev
// clang-format on
UNREACHABLE();
static const Format defaultInfo;
static constexpr Format defaultInfo;
return defaultInfo;
}
......
......@@ -45,16 +45,32 @@ template_autogen_inl = """// GENERATED FILE - DO NOT EDIT.
// ANGLE Format table:
// Queries for typed format information from the ANGLE format enum.
#include "libANGLE/renderer/Format.h"
#include "image_util/copyimage.h"
#include "image_util/generatemip.h"
#include "image_util/loadimage.h"
namespace angle
{{
constexpr Format g_formatInfoTable[] =
{{
static constexpr rx::FastCopyFunctionMap::Entry BGRAEntry = {{GL_RGBA, GL_UNSIGNED_BYTE,
CopyBGRA8ToRGBA8}};
static constexpr rx::FastCopyFunctionMap BGRACopyFunctions = {{&BGRAEntry, 1}};
static constexpr rx::FastCopyFunctionMap NoCopyFunctions;
constexpr Format g_formatInfoTable[] = {{
// clang-format off
{{ Format::ID::NONE, GL_NONE, GL_NONE, nullptr, NoCopyFunctions, nullptr, GL_NONE, 0, 0, 0, 0, 0, 0 }},
{angle_format_info_cases} // clang-format on
}};
// static
const Format &Format::Get(ID id)
{{
return g_formatInfoTable[static_cast<size_t>(id)];
}}
}} // namespace angle
"""
......@@ -241,7 +257,7 @@ output_cpp = template_autogen_inl.format(
copyright_year = date.today().year,
angle_format_info_cases = angle_format_cases,
data_source_name = data_source_name)
with open('Format_table_autogen.inl', 'wt') as out_file:
with open('Format_table_autogen.cpp', 'wt') as out_file:
out_file.write(output_cpp)
out_file.close()
......
......@@ -175,7 +175,7 @@
'libANGLE/renderer/FenceNVImpl.h',
'libANGLE/renderer/FenceSyncImpl.h',
'libANGLE/renderer/Format_ID_autogen.inl',
'libANGLE/renderer/Format_table_autogen.inl',
'libANGLE/renderer/Format_table_autogen.cpp',
'libANGLE/renderer/Format.h',
'libANGLE/renderer/FramebufferAttachmentObjectImpl.h',
'libANGLE/renderer/FramebufferImpl.h',
......
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