blob: 3904cb69c231d1a0f2cb751f2729bf0c51d47a2b [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.
30class VertexArray
31{
32public:
33 VertexArray();
34 virtual ~VertexArray();
35
Jason Samsc460e552009-11-25 13:22:07 -080036
Jason Sams433eca32010-01-06 11:57:52 -080037 class Attrib {
38 public:
Jason Samsc460e552009-11-25 13:22:07 -080039 uint32_t buffer;
40 uint32_t offset;
41 uint32_t type;
42 uint32_t size;
43 uint32_t stride;
44 bool normalized;
Jason Sams433eca32010-01-06 11:57:52 -080045 String8 name;
Jason Samsbe504f22010-01-25 12:31:24 -080046 RsDataKind kind;
Jason Sams433eca32010-01-06 11:57:52 -080047
48 Attrib();
49 void set(const Attrib &);
50 void clear();
51 };
Jason Samsc460e552009-11-25 13:22:07 -080052
53
54 void clearAll();
Jason Samsc460e552009-11-25 13:22:07 -080055 void setActiveBuffer(uint32_t id) {mActiveBuffer = id;}
Jason Samsbe504f22010-01-25 12:31:24 -080056 void addUser(const Attrib &, uint32_t stride);
57 void addLegacy(uint32_t type, uint32_t size, uint32_t stride, RsDataKind kind, bool normalized, uint32_t offset);
Jason Samsc460e552009-11-25 13:22:07 -080058
Jason Samsd01d9702009-12-23 14:35:29 -080059 void setupGL(const Context *rsc, class VertexArrayState *) const;
60 void setupGL2(const Context *rsc, class VertexArrayState *, ShaderCache *) const;
Jason Sams433eca32010-01-06 11:57:52 -080061 void logAttrib(uint32_t idx, uint32_t slot) const;
Jason Samsc460e552009-11-25 13:22:07 -080062
63protected:
Jason Samsbe504f22010-01-25 12:31:24 -080064 void clear(uint32_t index);
Jason Samsc460e552009-11-25 13:22:07 -080065 uint32_t mActiveBuffer;
Jason Samsbe504f22010-01-25 12:31:24 -080066 uint32_t mCount;
67
Jason Sams433eca32010-01-06 11:57:52 -080068 Attrib mAttribs[RS_MAX_ATTRIBS];
Jason Samsc460e552009-11-25 13:22:07 -080069};
70
71
72class VertexArrayState {
73public:
74 void init(Context *);
75
Jason Sams3eb28f02010-01-27 14:41:43 -080076 uint32_t mLastEnableCount;
Jason Sams433eca32010-01-06 11:57:52 -080077 //VertexArray::Attrib mAttribs[VertexArray::_LAST];
Jason Samsc460e552009-11-25 13:22:07 -080078};
79
80
81}
82}
83#endif //ANDROID_LIGHT_H
84
85
86