blob: a369a6482147434a28a0b4b170879223138754e9 [file] [log] [blame]
daniel@transgaming.com2c4d0702012-12-20 21:08:51 +00001//
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.com2c4d0702012-12-20 21:08:51 +000013
daniel@transgaming.com2c4d0702012-12-20 21:08:51 +000014namespace rx
15{
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000016class Renderer11;
daniel@transgaming.com2c4d0702012-12-20 21:08:51 +000017
18class 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.comd212e622013-02-28 23:08:25 +000034 virtual bool requiresConversion(const gl::VertexAttribute &attrib) const;
35
daniel@transgaming.com2c4d0702012-12-20 21:08:51 +000036 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.com4587fee2013-02-28 23:08:18 +000058 bool identity;
daniel@transgaming.com2c4d0702012-12-20 21:08:51 +000059 DXGI_FORMAT dxgiFormat;
60 unsigned int outputElementSize;
61 };
62
shannon.woods%transgaming.com@gtempaccount.com1a4e09a2013-04-13 03:33:30 +000063 enum { NUM_GL_VERTEX_ATTRIB_TYPES = 7 };
daniel@transgaming.com2c4d0702012-12-20 21:08:51 +000064
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_