gfx/angle/src/libGLESv2/renderer/InputLayoutCache.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 //
     2 // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
     3 // Use of this source code is governed by a BSD-style license that can be
     4 // found in the LICENSE file.
     5 //
     7 // InputLayoutCache.h: Defines InputLayoutCache, a class that builds and caches
     8 // D3D11 input layouts.
    10 #ifndef LIBGLESV2_RENDERER_INPUTLAYOUTCACHE_H_
    11 #define LIBGLESV2_RENDERER_INPUTLAYOUTCACHE_H_
    13 #include "libGLESv2/Constants.h"
    14 #include "common/angleutils.h"
    16 namespace gl
    17 {
    18 class ProgramBinary;
    19 }
    21 namespace rx
    22 {
    23 struct TranslatedAttribute;
    25 class InputLayoutCache
    26 {
    27   public:
    28     InputLayoutCache();
    29     virtual ~InputLayoutCache();
    31     void initialize(ID3D11Device *device, ID3D11DeviceContext *context);
    32     void clear();
    33     void markDirty();
    35     GLenum applyVertexBuffers(TranslatedAttribute attributes[gl::MAX_VERTEX_ATTRIBS],
    36                               gl::ProgramBinary *programBinary);
    38   private:
    39     DISALLOW_COPY_AND_ASSIGN(InputLayoutCache);
    41     struct InputLayoutKey
    42     {
    43         unsigned int elementCount;
    44         D3D11_INPUT_ELEMENT_DESC elements[gl::MAX_VERTEX_ATTRIBS];
    45         GLenum glslElementType[gl::MAX_VERTEX_ATTRIBS];
    46     };
    48     struct InputLayoutCounterPair
    49     {
    50         ID3D11InputLayout *inputLayout;
    51         unsigned long long lastUsedTime;
    52     };
    54     ID3D11InputLayout *mCurrentIL;
    55     unsigned int mCurrentBuffers[gl::MAX_VERTEX_ATTRIBS];
    56     UINT mCurrentVertexStrides[gl::MAX_VERTEX_ATTRIBS];
    57     UINT mCurrentVertexOffsets[gl::MAX_VERTEX_ATTRIBS];
    59     static std::size_t hashInputLayout(const InputLayoutKey &inputLayout);
    60     static bool compareInputLayouts(const InputLayoutKey &a, const InputLayoutKey &b);
    62     typedef std::size_t (*InputLayoutHashFunction)(const InputLayoutKey &);
    63     typedef bool (*InputLayoutEqualityFunction)(const InputLayoutKey &, const InputLayoutKey &);
    64     typedef std::unordered_map<InputLayoutKey,
    65                                InputLayoutCounterPair,
    66                                InputLayoutHashFunction,
    67                                InputLayoutEqualityFunction> InputLayoutMap;
    68     InputLayoutMap mInputLayoutMap;
    70     static const unsigned int kMaxInputLayouts;
    72     unsigned long long mCounter;
    74     ID3D11Device *mDevice;
    75     ID3D11DeviceContext *mDeviceContext;
    76 };
    78 }
    80 #endif // LIBGLESV2_RENDERER_INPUTLAYOUTCACHE_H_

mercurial