Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 1 | /* |
| 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 | // --------------------------------------------------------------------------- |
| 24 | namespace android { |
| 25 | namespace renderscript { |
| 26 | |
| 27 | class ShaderCache; |
| 28 | |
| 29 | // An element is a group of Components that occupies one cell in a structure. |
| 30 | class VertexArray |
| 31 | { |
| 32 | public: |
| 33 | VertexArray(); |
| 34 | virtual ~VertexArray(); |
| 35 | |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 36 | |
Jason Sams | a09a6e1 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 37 | class Attrib { |
| 38 | public: |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 39 | uint32_t buffer; |
| 40 | uint32_t offset; |
| 41 | uint32_t type; |
| 42 | uint32_t size; |
| 43 | uint32_t stride; |
| 44 | bool normalized; |
Jason Sams | a09a6e1 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 45 | String8 name; |
Jason Sams | df48b57 | 2010-01-25 12:31:24 -0800 | [diff] [blame] | 46 | RsDataKind kind; |
Jason Sams | a09a6e1 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 47 | |
| 48 | Attrib(); |
| 49 | void set(const Attrib &); |
| 50 | void clear(); |
| 51 | }; |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 52 | |
| 53 | |
| 54 | void clearAll(); |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 55 | void setActiveBuffer(uint32_t id) {mActiveBuffer = id;} |
Jason Sams | df48b57 | 2010-01-25 12:31:24 -0800 | [diff] [blame] | 56 | 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 Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 58 | |
Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 59 | void setupGL(const Context *rsc, class VertexArrayState *) const; |
| 60 | void setupGL2(const Context *rsc, class VertexArrayState *, ShaderCache *) const; |
Jason Sams | a09a6e1 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 61 | void logAttrib(uint32_t idx, uint32_t slot) const; |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 62 | |
| 63 | protected: |
Jason Sams | df48b57 | 2010-01-25 12:31:24 -0800 | [diff] [blame] | 64 | void clear(uint32_t index); |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 65 | uint32_t mActiveBuffer; |
Jason Sams | df48b57 | 2010-01-25 12:31:24 -0800 | [diff] [blame] | 66 | uint32_t mCount; |
| 67 | |
Jason Sams | a09a6e1 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 68 | Attrib mAttribs[RS_MAX_ATTRIBS]; |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 69 | }; |
| 70 | |
| 71 | |
| 72 | class VertexArrayState { |
| 73 | public: |
| 74 | void init(Context *); |
| 75 | |
Jason Sams | 5dbfe93 | 2010-01-27 14:41:43 -0800 | [diff] [blame] | 76 | uint32_t mLastEnableCount; |
Jason Sams | a09a6e1 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 77 | //VertexArray::Attrib mAttribs[VertexArray::_LAST]; |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | |
| 81 | } |
| 82 | } |
| 83 | #endif //ANDROID_LIGHT_H |
| 84 | |
| 85 | |
| 86 | |