Hash :
7b62cf97
Author :
Date :
2017-11-02T15:20:49
Refactor TextureFormatMap to store an array. std::map lookups are already showing up as a hot spot during some profile trace analysis. We can elimintate these by only doing a single switch at the entry point level to convert the GL internal format to an internal identifier or type info pointer. This change doesn't completely fix the hot spot, since now we are doing multiple switch statements, but it does remove the std::map storage in TextureCapsMap. It replaces it with a flat std::array indexed by angle::Format::ID, and gives us the option in the future to eliminate all by one switch statement. This should allow for a faster texture caps implementation in Vulkan. This also fixes the missing ANGLE format entries for ETC1 compressed formats. BUG=angleproject:2207 Change-Id: I74ea2082e582a6790d5fde90e33246a618a2da0e Reviewed-on: https://chromium-review.googlesource.com/742375 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
//
// Copyright 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Format:
// A universal description of typed GPU storage. Across multiple
// renderer back-ends, there are common formats and some distinct
// permutations, this enum encapsulates them all. Formats apply to
// textures, but could also apply to any typed data.
#ifndef LIBANGLE_RENDERER_FORMAT_H_
#define LIBANGLE_RENDERER_FORMAT_H_
#include "libANGLE/renderer/renderer_utils.h"
namespace angle
{
struct Format final : private angle::NonCopyable
{
enum class ID;
constexpr Format(ID id,
GLenum glFormat,
GLenum fboFormat,
rx::MipGenerationFunction mipGen,
const rx::FastCopyFunctionMap &fastCopyFunctions,
rx::ColorReadFunction colorRead,
rx::ColorWriteFunction colorWrite,
GLenum componentType,
GLuint redBits,
GLuint greenBits,
GLuint blueBits,
GLuint alphaBits,
GLuint depthBits,
GLuint stencilBits);
static const Format &Get(ID id);
static ID InternalFormatToID(GLenum internalFormat);
ID id;
// The closest matching GL internal format for the storage this format uses. Note that this
// may be a different internal format than the one this ANGLE format is used for.
GLenum glInternalFormat;
// The format we should report to the GL layer when querying implementation formats from a FBO.
// This might not be the same as the glInternalFormat, since some DXGI formats don't have
// matching GL format enums, like BGRA4, BGR5A1 and B5G6R6.
GLenum fboImplementationInternalFormat;
rx::MipGenerationFunction mipGenerationFunction;
rx::ColorReadFunction colorReadFunction;
rx::ColorWriteFunction colorWriteFunction;
// A map from a gl::FormatType to a fast pixel copy function for this format.
const rx::FastCopyFunctionMap &fastCopyFunctions;
GLenum componentType;
GLuint redBits;
GLuint greenBits;
GLuint blueBits;
GLuint alphaBits;
GLuint depthBits;
GLuint stencilBits;
};
constexpr Format::Format(ID id,
GLenum glFormat,
GLenum fboFormat,
rx::MipGenerationFunction mipGen,
const rx::FastCopyFunctionMap &fastCopyFunctions,
rx::ColorReadFunction colorRead,
rx::ColorWriteFunction colorWrite,
GLenum componentType,
GLuint redBits,
GLuint greenBits,
GLuint blueBits,
GLuint alphaBits,
GLuint depthBits,
GLuint stencilBits)
: id(id),
glInternalFormat(glFormat),
fboImplementationInternalFormat(fboFormat),
mipGenerationFunction(mipGen),
colorReadFunction(colorRead),
colorWriteFunction(colorWrite),
fastCopyFunctions(fastCopyFunctions),
componentType(componentType),
redBits(redBits),
greenBits(greenBits),
blueBits(blueBits),
alphaBits(alphaBits),
depthBits(depthBits),
stencilBits(stencilBits)
{
}
} // namespace angle
#include "libANGLE/renderer/Format_ID_autogen.inl"
#endif // LIBANGLE_RENDERER_FORMAT_H_