michael@0: // michael@0: // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: // michael@0: michael@0: // VertexBuffer11.h: Defines the D3D11 VertexBuffer implementation. michael@0: michael@0: #ifndef LIBGLESV2_RENDERER_VERTEXBUFFER11_H_ michael@0: #define LIBGLESV2_RENDERER_VERTEXBUFFER11_H_ michael@0: michael@0: #include "libGLESv2/renderer/VertexBuffer.h" michael@0: michael@0: namespace rx michael@0: { michael@0: class Renderer11; michael@0: michael@0: class VertexBuffer11 : public VertexBuffer michael@0: { michael@0: public: michael@0: explicit VertexBuffer11(rx::Renderer11 *const renderer); michael@0: virtual ~VertexBuffer11(); michael@0: michael@0: virtual bool initialize(unsigned int size, bool dynamicUsage); michael@0: michael@0: static VertexBuffer11 *makeVertexBuffer11(VertexBuffer *vetexBuffer); michael@0: michael@0: virtual bool storeVertexAttributes(const gl::VertexAttribute &attrib, GLint start, GLsizei count, GLsizei instances, michael@0: unsigned int offset); michael@0: virtual bool storeRawData(const void* data, unsigned int size, unsigned int offset); michael@0: michael@0: virtual bool getSpaceRequired(const gl::VertexAttribute &attrib, GLsizei count, GLsizei instances, michael@0: unsigned int *outSpaceRequired) const; michael@0: michael@0: virtual bool requiresConversion(const gl::VertexAttribute &attrib) const; michael@0: michael@0: virtual unsigned int getBufferSize() const; michael@0: virtual bool setBufferSize(unsigned int size); michael@0: virtual bool discard(); michael@0: michael@0: unsigned int getVertexSize(const gl::VertexAttribute &attrib) const; michael@0: DXGI_FORMAT getDXGIFormat(const gl::VertexAttribute &attrib) const; michael@0: michael@0: ID3D11Buffer *getBuffer() const; michael@0: michael@0: private: michael@0: DISALLOW_COPY_AND_ASSIGN(VertexBuffer11); michael@0: michael@0: rx::Renderer11 *const mRenderer; michael@0: michael@0: ID3D11Buffer *mBuffer; michael@0: unsigned int mBufferSize; michael@0: bool mDynamicUsage; michael@0: michael@0: typedef void (*VertexConversionFunction)(const void *, unsigned int, unsigned int, void *); michael@0: struct VertexConverter michael@0: { michael@0: VertexConversionFunction conversionFunc; michael@0: bool identity; michael@0: DXGI_FORMAT dxgiFormat; michael@0: unsigned int outputElementSize; michael@0: }; michael@0: michael@0: enum { NUM_GL_VERTEX_ATTRIB_TYPES = 6 }; michael@0: michael@0: // This table is used to generate mAttributeTypes. michael@0: static const VertexConverter mPossibleTranslations[NUM_GL_VERTEX_ATTRIB_TYPES][2][4]; // [GL types as enumerated by typeIndex()][normalized][size - 1] michael@0: michael@0: static const VertexConverter &getVertexConversion(const gl::VertexAttribute &attribute); michael@0: }; michael@0: michael@0: } michael@0: michael@0: #endif // LIBGLESV2_RENDERER_VERTEXBUFFER11_H_