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; |
Jason Sams | eeeaccc | 2010-06-25 12:45:41 -0700 | [diff] [blame] | 40 | const uint8_t * ptr; |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 41 | uint32_t offset; |
| 42 | uint32_t type; |
| 43 | uint32_t size; |
| 44 | uint32_t stride; |
| 45 | bool normalized; |
Jason Sams | a09a6e1 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 46 | String8 name; |
| 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 | eeeaccc | 2010-06-25 12:45:41 -0700 | [diff] [blame] | 55 | void setActiveBuffer(uint32_t id) { |
| 56 | mActiveBuffer = id; |
| 57 | mActivePointer = NULL; |
| 58 | } |
| 59 | void setActiveBuffer(const void *ptr) { |
| 60 | mActiveBuffer = 0; |
| 61 | mActivePointer = (const uint8_t *)ptr; |
| 62 | } |
| 63 | |
Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 64 | void add(const Attrib &, uint32_t stride); |
| 65 | //void addLegacy(uint32_t type, uint32_t size, uint32_t stride, bool normalized, uint32_t offset); |
| 66 | void add(uint32_t type, uint32_t size, uint32_t stride, bool normalized, uint32_t offset, const char *name); |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 67 | |
Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 68 | void setupGL2(const Context *rsc, class VertexArrayState *, ShaderCache *) const; |
Jason Sams | a09a6e1 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 69 | void logAttrib(uint32_t idx, uint32_t slot) const; |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 70 | |
| 71 | protected: |
Jason Sams | df48b57 | 2010-01-25 12:31:24 -0800 | [diff] [blame] | 72 | void clear(uint32_t index); |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 73 | uint32_t mActiveBuffer; |
Jason Sams | eeeaccc | 2010-06-25 12:45:41 -0700 | [diff] [blame] | 74 | const uint8_t * mActivePointer; |
Jason Sams | df48b57 | 2010-01-25 12:31:24 -0800 | [diff] [blame] | 75 | uint32_t mCount; |
| 76 | |
Jason Sams | a09a6e1 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 77 | Attrib mAttribs[RS_MAX_ATTRIBS]; |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | |
| 81 | class VertexArrayState { |
| 82 | public: |
| 83 | void init(Context *); |
| 84 | |
Jason Sams | 5dbfe93 | 2010-01-27 14:41:43 -0800 | [diff] [blame] | 85 | uint32_t mLastEnableCount; |
Jason Sams | a09a6e1 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 86 | //VertexArray::Attrib mAttribs[VertexArray::_LAST]; |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 87 | }; |
| 88 | |
| 89 | |
| 90 | } |
| 91 | } |
| 92 | #endif //ANDROID_LIGHT_H |
| 93 | |
| 94 | |
| 95 | |