1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/angle/src/libGLESv2/renderer/InputLayoutCache.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,80 @@ 1.4 +// 1.5 +// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. 1.6 +// Use of this source code is governed by a BSD-style license that can be 1.7 +// found in the LICENSE file. 1.8 +// 1.9 + 1.10 +// InputLayoutCache.h: Defines InputLayoutCache, a class that builds and caches 1.11 +// D3D11 input layouts. 1.12 + 1.13 +#ifndef LIBGLESV2_RENDERER_INPUTLAYOUTCACHE_H_ 1.14 +#define LIBGLESV2_RENDERER_INPUTLAYOUTCACHE_H_ 1.15 + 1.16 +#include "libGLESv2/Constants.h" 1.17 +#include "common/angleutils.h" 1.18 + 1.19 +namespace gl 1.20 +{ 1.21 +class ProgramBinary; 1.22 +} 1.23 + 1.24 +namespace rx 1.25 +{ 1.26 +struct TranslatedAttribute; 1.27 + 1.28 +class InputLayoutCache 1.29 +{ 1.30 + public: 1.31 + InputLayoutCache(); 1.32 + virtual ~InputLayoutCache(); 1.33 + 1.34 + void initialize(ID3D11Device *device, ID3D11DeviceContext *context); 1.35 + void clear(); 1.36 + void markDirty(); 1.37 + 1.38 + GLenum applyVertexBuffers(TranslatedAttribute attributes[gl::MAX_VERTEX_ATTRIBS], 1.39 + gl::ProgramBinary *programBinary); 1.40 + 1.41 + private: 1.42 + DISALLOW_COPY_AND_ASSIGN(InputLayoutCache); 1.43 + 1.44 + struct InputLayoutKey 1.45 + { 1.46 + unsigned int elementCount; 1.47 + D3D11_INPUT_ELEMENT_DESC elements[gl::MAX_VERTEX_ATTRIBS]; 1.48 + GLenum glslElementType[gl::MAX_VERTEX_ATTRIBS]; 1.49 + }; 1.50 + 1.51 + struct InputLayoutCounterPair 1.52 + { 1.53 + ID3D11InputLayout *inputLayout; 1.54 + unsigned long long lastUsedTime; 1.55 + }; 1.56 + 1.57 + ID3D11InputLayout *mCurrentIL; 1.58 + unsigned int mCurrentBuffers[gl::MAX_VERTEX_ATTRIBS]; 1.59 + UINT mCurrentVertexStrides[gl::MAX_VERTEX_ATTRIBS]; 1.60 + UINT mCurrentVertexOffsets[gl::MAX_VERTEX_ATTRIBS]; 1.61 + 1.62 + static std::size_t hashInputLayout(const InputLayoutKey &inputLayout); 1.63 + static bool compareInputLayouts(const InputLayoutKey &a, const InputLayoutKey &b); 1.64 + 1.65 + typedef std::size_t (*InputLayoutHashFunction)(const InputLayoutKey &); 1.66 + typedef bool (*InputLayoutEqualityFunction)(const InputLayoutKey &, const InputLayoutKey &); 1.67 + typedef std::unordered_map<InputLayoutKey, 1.68 + InputLayoutCounterPair, 1.69 + InputLayoutHashFunction, 1.70 + InputLayoutEqualityFunction> InputLayoutMap; 1.71 + InputLayoutMap mInputLayoutMap; 1.72 + 1.73 + static const unsigned int kMaxInputLayouts; 1.74 + 1.75 + unsigned long long mCounter; 1.76 + 1.77 + ID3D11Device *mDevice; 1.78 + ID3D11DeviceContext *mDeviceContext; 1.79 +}; 1.80 + 1.81 +} 1.82 + 1.83 +#endif // LIBGLESV2_RENDERER_INPUTLAYOUTCACHE_H_