blob: 3e807a30cbd0d64eed80a939ec7fdb7a3e614907 [file] [log] [blame]
Jason Samsbb51c402009-11-25 13:22:07 -08001/*
Alex Sakhartchouk4a36b452011-04-29 16:49:08 -07002 * Copyright (C) 2011 The Android Open Source Project
Jason Samsbb51c402009-11-25 13:22:07 -08003 *
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
Alex Sakhartchouk4a36b452011-04-29 16:49:08 -070017#ifndef ANDROID_RSD_VERTEX_ARRAY_H
18#define ANDROID_RSD_VERTEX_ARRAY_H
Jason Samsbb51c402009-11-25 13:22:07 -080019
Jason Samsbb51c402009-11-25 13:22:07 -080020namespace android {
21namespace renderscript {
22
Alex Sakhartchouk4a36b452011-04-29 16:49:08 -070023class Context;
24
25}
26}
27
28#include <utils/String8.h>
Jason Samsbb51c402009-11-25 13:22:07 -080029
30// An element is a group of Components that occupies one cell in a structure.
Alex Sakhartchouk4a36b452011-04-29 16:49:08 -070031class RsdVertexArray {
Jason Samsbb51c402009-11-25 13:22:07 -080032public:
Jason Samsa09a6e12010-01-06 11:57:52 -080033 class Attrib {
34 public:
Jason Samsbb51c402009-11-25 13:22:07 -080035 uint32_t buffer;
Jason Samseeeaccc2010-06-25 12:45:41 -070036 const uint8_t * ptr;
Jason Samsbb51c402009-11-25 13:22:07 -080037 uint32_t offset;
38 uint32_t type;
39 uint32_t size;
40 uint32_t stride;
41 bool normalized;
Alex Sakhartchouk4a36b452011-04-29 16:49:08 -070042 android::String8 name;
Jason Samsa09a6e12010-01-06 11:57:52 -080043
44 Attrib();
Jason Samsa09a6e12010-01-06 11:57:52 -080045 void clear();
Alex Sakhartchouk9d71e212010-11-08 15:10:52 -080046 void set(uint32_t type, uint32_t size, uint32_t stride, bool normalized, uint32_t offset, const char *name);
Jason Samsa09a6e12010-01-06 11:57:52 -080047 };
Jason Samsbb51c402009-11-25 13:22:07 -080048
Alex Sakhartchouk4a36b452011-04-29 16:49:08 -070049 RsdVertexArray(const Attrib *attribs, uint32_t numAttribs);
50 virtual ~RsdVertexArray();
Jason Samsbb51c402009-11-25 13:22:07 -080051
Alex Sakhartchouk407cae92011-05-06 14:59:45 -070052 void setup(const android::renderscript::Context *rsc) const;
Jason Samsa09a6e12010-01-06 11:57:52 -080053 void logAttrib(uint32_t idx, uint32_t slot) const;
Jason Samsbb51c402009-11-25 13:22:07 -080054
55protected:
Jason Samsdf48b572010-01-25 12:31:24 -080056 void clear(uint32_t index);
Jason Samsbb51c402009-11-25 13:22:07 -080057 uint32_t mActiveBuffer;
Jason Samseeeaccc2010-06-25 12:45:41 -070058 const uint8_t * mActivePointer;
Jason Samsdf48b572010-01-25 12:31:24 -080059 uint32_t mCount;
60
Alex Sakhartchouk9d71e212010-11-08 15:10:52 -080061 const Attrib *mAttribs;
Jason Samsbb51c402009-11-25 13:22:07 -080062};
63
64
Alex Sakhartchouk4a36b452011-04-29 16:49:08 -070065class RsdVertexArrayState {
Jason Samsbb51c402009-11-25 13:22:07 -080066public:
Alex Sakhartchouk4a36b452011-04-29 16:49:08 -070067 RsdVertexArrayState();
68 ~RsdVertexArrayState();
69 void init(uint32_t maxAttrs);
Jason Samsbb51c402009-11-25 13:22:07 -080070
Alex Sakhartchouk6b5222d2010-12-13 14:48:21 -080071 bool *mAttrsEnabled;
72 uint32_t mAttrsEnabledSize;
Jason Samsbb51c402009-11-25 13:22:07 -080073};
74
75
Alex Sakhartchouk4a36b452011-04-29 16:49:08 -070076#endif //ANDROID_RSD_VERTEX_ARRAY_H
Jason Samsbb51c402009-11-25 13:22:07 -080077
78
79