D3D11: Make several format tables constexpr.
This should guarantee the best memory access patterns.
It introduces some indirections for some format queries,
but most of these should be direct array lookups, or used
infrequently. We can optimize this later if necessary.
BUG=angleproject:1389
Change-Id: I5e2c8c530a07798494afd3ea36b6164d7564c02c
Reviewed-on: https://chromium-review.googlesource.com/403314
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
diff --git a/src/libANGLE/renderer/renderer_utils.cpp b/src/libANGLE/renderer/renderer_utils.cpp
index b93a1ff..cc04dbb 100644
--- a/src/libANGLE/renderer/renderer_utils.cpp
+++ b/src/libANGLE/renderer/renderer_utils.cpp
@@ -268,8 +268,25 @@
ColorCopyFunction GetFastCopyFunction(const FastCopyFunctionMap &fastCopyFunctions,
const gl::FormatType &formatType)
{
- auto iter = fastCopyFunctions.find(formatType);
- return (iter != fastCopyFunctions.end()) ? iter->second : nullptr;
+ return fastCopyFunctions.get(formatType);
+}
+
+bool FastCopyFunctionMap::has(const gl::FormatType &formatType) const
+{
+ return (get(formatType) != nullptr);
+}
+
+ColorCopyFunction FastCopyFunctionMap::get(const gl::FormatType &formatType) const
+{
+ for (size_t index = 0; index < mSize; ++index)
+ {
+ if (mData[index].format == formatType.format && mData[index].type == formatType.type)
+ {
+ return mData[index].func;
+ }
+ }
+
+ return nullptr;
}
} // namespace rx