blob: 45d9e82ab108335cb8906d7eccc42de739b19f60 [file] [log] [blame]
Jason Samsc460e552009-11-25 13:22:07 -08001/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_VERTEX_ARRAY_H
18#define ANDROID_VERTEX_ARRAY_H
19
20
21#include "rsObjectBase.h"
22
23// ---------------------------------------------------------------------------
24namespace android {
25namespace renderscript {
26
27class ShaderCache;
28
29// An element is a group of Components that occupies one cell in a structure.
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080030class VertexArray {
Jason Samsc460e552009-11-25 13:22:07 -080031public:
Jason Sams433eca32010-01-06 11:57:52 -080032 class Attrib {
33 public:
Jason Samsc460e552009-11-25 13:22:07 -080034 uint32_t buffer;
Jason Sams760f1f72010-06-25 12:45:41 -070035 const uint8_t * ptr;
Jason Samsc460e552009-11-25 13:22:07 -080036 uint32_t offset;
37 uint32_t type;
38 uint32_t size;
39 uint32_t stride;
40 bool normalized;
Jason Sams433eca32010-01-06 11:57:52 -080041 String8 name;
42
43 Attrib();
Jason Sams433eca32010-01-06 11:57:52 -080044 void clear();
Alex Sakhartchouk54929cc2010-11-08 15:10:52 -080045 void set(uint32_t type, uint32_t size, uint32_t stride, bool normalized, uint32_t offset, const char *name);
Jason Sams433eca32010-01-06 11:57:52 -080046 };
Jason Samsc460e552009-11-25 13:22:07 -080047
Alex Sakhartchouk54929cc2010-11-08 15:10:52 -080048 VertexArray(const Attrib *attribs, uint32_t numAttribs);
49 virtual ~VertexArray();
Jason Samsc460e552009-11-25 13:22:07 -080050
Jason Samsd01d9702009-12-23 14:35:29 -080051 void setupGL2(const Context *rsc, class VertexArrayState *, ShaderCache *) const;
Jason Sams433eca32010-01-06 11:57:52 -080052 void logAttrib(uint32_t idx, uint32_t slot) const;
Jason Samsc460e552009-11-25 13:22:07 -080053
54protected:
Jason Samsbe504f22010-01-25 12:31:24 -080055 void clear(uint32_t index);
Jason Samsc460e552009-11-25 13:22:07 -080056 uint32_t mActiveBuffer;
Jason Sams760f1f72010-06-25 12:45:41 -070057 const uint8_t * mActivePointer;
Jason Samsbe504f22010-01-25 12:31:24 -080058 uint32_t mCount;
59
Alex Sakhartchouk54929cc2010-11-08 15:10:52 -080060 const Attrib *mAttribs;
Jason Samsc460e552009-11-25 13:22:07 -080061};
62
63
64class VertexArrayState {
65public:
Alex Sakhartchouk2d791972010-12-13 14:48:21 -080066 VertexArrayState();
67 ~VertexArrayState();
Jason Samsc460e552009-11-25 13:22:07 -080068 void init(Context *);
69
Alex Sakhartchouk2d791972010-12-13 14:48:21 -080070 bool *mAttrsEnabled;
71 uint32_t mAttrsEnabledSize;
Jason Samsc460e552009-11-25 13:22:07 -080072};
73
74
75}
76}
Alex Sakhartchoukc8fb69e2010-10-05 13:23:55 -070077#endif //ANDROID_VERTEX_ARRAY_H
Jason Samsc460e552009-11-25 13:22:07 -080078
79
80