blob: 1bafe3bc1e5b44edf1b0f640a2b03c96df377596 [file] [log] [blame]
Jason Samsc460e552009-11-25 13:22:07 -08001/*
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -07002 * Copyright (C) 2011 The Android Open Source Project
Jason Samsc460e552009-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 Sakhartchouka04e30d2011-04-29 16:49:08 -070017#ifndef ANDROID_RSD_VERTEX_ARRAY_H
18#define ANDROID_RSD_VERTEX_ARRAY_H
Jason Samsc460e552009-11-25 13:22:07 -080019
Chris Wailes93d6bc82014-07-28 16:54:38 -070020#include <string>
21
Tim Murray0b575de2013-03-15 15:56:43 -070022#include "rsUtils.h"
23
Jason Samsc460e552009-11-25 13:22:07 -080024namespace android {
25namespace renderscript {
26
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -070027class Context;
28
29}
30}
31
Jason Samsc460e552009-11-25 13:22:07 -080032// An element is a group of Components that occupies one cell in a structure.
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -070033class RsdVertexArray {
Jason Samsc460e552009-11-25 13:22:07 -080034public:
Jason Sams433eca32010-01-06 11:57:52 -080035 class Attrib {
36 public:
Jason Samsc460e552009-11-25 13:22:07 -080037 uint32_t buffer;
Jason Sams760f1f72010-06-25 12:45:41 -070038 const uint8_t * ptr;
Tim Murraye195a3f2014-03-13 15:04:58 -070039 size_t offset;
Jason Samsc460e552009-11-25 13:22:07 -080040 uint32_t type;
41 uint32_t size;
42 uint32_t stride;
43 bool normalized;
Chris Wailes93d6bc82014-07-28 16:54:38 -070044 std::string name;
Jason Sams433eca32010-01-06 11:57:52 -080045
46 Attrib();
Jason Sams433eca32010-01-06 11:57:52 -080047 void clear();
Tim Murraye195a3f2014-03-13 15:04:58 -070048 void set(uint32_t type, uint32_t size, uint32_t stride, bool normalized, size_t offset, const char *name);
Jason Sams433eca32010-01-06 11:57:52 -080049 };
Jason Samsc460e552009-11-25 13:22:07 -080050
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -070051 RsdVertexArray(const Attrib *attribs, uint32_t numAttribs);
52 virtual ~RsdVertexArray();
Jason Samsc460e552009-11-25 13:22:07 -080053
Alex Sakhartchoukc19ff012011-05-06 14:59:45 -070054 void setup(const android::renderscript::Context *rsc) const;
Jason Sams433eca32010-01-06 11:57:52 -080055 void logAttrib(uint32_t idx, uint32_t slot) const;
Jason Samsc460e552009-11-25 13:22:07 -080056
57protected:
Jason Samsbe504f22010-01-25 12:31:24 -080058 void clear(uint32_t index);
Jason Samsc460e552009-11-25 13:22:07 -080059 uint32_t mActiveBuffer;
Jason Sams760f1f72010-06-25 12:45:41 -070060 const uint8_t * mActivePointer;
Jason Samsbe504f22010-01-25 12:31:24 -080061 uint32_t mCount;
62
Alex Sakhartchouk54929cc2010-11-08 15:10:52 -080063 const Attrib *mAttribs;
Jason Samsc460e552009-11-25 13:22:07 -080064};
65
66
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -070067class RsdVertexArrayState {
Jason Samsc460e552009-11-25 13:22:07 -080068public:
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -070069 RsdVertexArrayState();
70 ~RsdVertexArrayState();
71 void init(uint32_t maxAttrs);
Jason Samsc460e552009-11-25 13:22:07 -080072
Alex Sakhartchouk2d791972010-12-13 14:48:21 -080073 bool *mAttrsEnabled;
74 uint32_t mAttrsEnabledSize;
Jason Samsc460e552009-11-25 13:22:07 -080075};
76
77
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -070078#endif //ANDROID_RSD_VERTEX_ARRAY_H