daniel@transgaming.com | 2c4d070 | 2012-12-20 21:08:51 +0000 | [diff] [blame] | 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 | // |
| 6 | |
| 7 | // VertexBuffer11.h: Defines the D3D11 VertexBuffer implementation. |
| 8 | |
| 9 | #ifndef LIBGLESV2_RENDERER_VERTEXBUFFER11_H_ |
| 10 | #define LIBGLESV2_RENDERER_VERTEXBUFFER11_H_ |
| 11 | |
| 12 | #include "libGLESv2/renderer/VertexBuffer.h" |
daniel@transgaming.com | 2c4d070 | 2012-12-20 21:08:51 +0000 | [diff] [blame] | 13 | |
daniel@transgaming.com | 2c4d070 | 2012-12-20 21:08:51 +0000 | [diff] [blame] | 14 | namespace rx |
| 15 | { |
shannon.woods@transgaming.com | 486d9e9 | 2013-02-28 23:15:41 +0000 | [diff] [blame] | 16 | class Renderer11; |
daniel@transgaming.com | 2c4d070 | 2012-12-20 21:08:51 +0000 | [diff] [blame] | 17 | |
| 18 | class VertexBuffer11 : public VertexBuffer |
| 19 | { |
| 20 | public: |
| 21 | explicit VertexBuffer11(rx::Renderer11 *const renderer); |
| 22 | virtual ~VertexBuffer11(); |
| 23 | |
| 24 | virtual bool initialize(unsigned int size, bool dynamicUsage); |
| 25 | |
| 26 | static VertexBuffer11 *makeVertexBuffer11(VertexBuffer *vetexBuffer); |
| 27 | |
| 28 | virtual bool storeVertexAttributes(const gl::VertexAttribute &attrib, GLint start, GLsizei count, GLsizei instances, |
| 29 | unsigned int offset); |
| 30 | virtual bool storeRawData(const void* data, unsigned int size, unsigned int offset); |
| 31 | |
| 32 | virtual unsigned int getSpaceRequired(const gl::VertexAttribute &attrib, GLsizei count, GLsizei instances) const; |
| 33 | |
shannon.woods@transgaming.com | d212e62 | 2013-02-28 23:08:25 +0000 | [diff] [blame] | 34 | virtual bool requiresConversion(const gl::VertexAttribute &attrib) const; |
| 35 | |
daniel@transgaming.com | 2c4d070 | 2012-12-20 21:08:51 +0000 | [diff] [blame] | 36 | virtual unsigned int getBufferSize() const; |
| 37 | virtual bool setBufferSize(unsigned int size); |
| 38 | virtual bool discard(); |
| 39 | |
| 40 | unsigned int getVertexSize(const gl::VertexAttribute &attrib) const; |
| 41 | DXGI_FORMAT getDXGIFormat(const gl::VertexAttribute &attrib) const; |
| 42 | |
| 43 | ID3D11Buffer *getBuffer() const; |
| 44 | |
| 45 | private: |
| 46 | DISALLOW_COPY_AND_ASSIGN(VertexBuffer11); |
| 47 | |
| 48 | rx::Renderer11 *const mRenderer; |
| 49 | |
| 50 | ID3D11Buffer *mBuffer; |
| 51 | unsigned int mBufferSize; |
| 52 | bool mDynamicUsage; |
| 53 | |
| 54 | typedef void (*VertexConversionFunction)(const void *, unsigned int, unsigned int, void *); |
| 55 | struct VertexConverter |
| 56 | { |
| 57 | VertexConversionFunction conversionFunc; |
shannon.woods@transgaming.com | 4587fee | 2013-02-28 23:08:18 +0000 | [diff] [blame] | 58 | bool identity; |
daniel@transgaming.com | 2c4d070 | 2012-12-20 21:08:51 +0000 | [diff] [blame] | 59 | DXGI_FORMAT dxgiFormat; |
| 60 | unsigned int outputElementSize; |
| 61 | }; |
| 62 | |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 63 | enum { NUM_GL_VERTEX_ATTRIB_TYPES = 7 }; |
daniel@transgaming.com | 2c4d070 | 2012-12-20 21:08:51 +0000 | [diff] [blame] | 64 | |
| 65 | // This table is used to generate mAttributeTypes. |
| 66 | static const VertexConverter mPossibleTranslations[NUM_GL_VERTEX_ATTRIB_TYPES][2][4]; // [GL types as enumerated by typeIndex()][normalized][size - 1] |
| 67 | |
| 68 | static const VertexConverter &getVertexConversion(const gl::VertexAttribute &attribute); |
| 69 | }; |
| 70 | |
| 71 | } |
| 72 | |
| 73 | #endif // LIBGLESV2_RENDERER_VERTEXBUFFER11_H_ |