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: |
Jason Sams | a09a6e1 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 33 | class Attrib { |
| 34 | public: |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 35 | uint32_t buffer; |
Jason Sams | eeeaccc | 2010-06-25 12:45:41 -0700 | [diff] [blame] | 36 | const uint8_t * ptr; |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 37 | uint32_t offset; |
| 38 | uint32_t type; |
| 39 | uint32_t size; |
| 40 | uint32_t stride; |
| 41 | bool normalized; |
Jason Sams | a09a6e1 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 42 | String8 name; |
| 43 | |
| 44 | Attrib(); |
Jason Sams | a09a6e1 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 45 | void clear(); |
Alex Sakhartchouk | 9d71e21 | 2010-11-08 15:10:52 -0800 | [diff] [blame] | 46 | void set(uint32_t type, uint32_t size, uint32_t stride, bool normalized, uint32_t offset, const char *name); |
Jason Sams | a09a6e1 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 47 | }; |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 48 | |
Alex Sakhartchouk | 9d71e21 | 2010-11-08 15:10:52 -0800 | [diff] [blame] | 49 | VertexArray(const Attrib *attribs, uint32_t numAttribs); |
| 50 | virtual ~VertexArray(); |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 51 | |
Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 52 | void setupGL2(const Context *rsc, class VertexArrayState *, ShaderCache *) const; |
Jason Sams | a09a6e1 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 53 | void logAttrib(uint32_t idx, uint32_t slot) const; |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 54 | |
| 55 | protected: |
Jason Sams | df48b57 | 2010-01-25 12:31:24 -0800 | [diff] [blame] | 56 | void clear(uint32_t index); |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 57 | uint32_t mActiveBuffer; |
Jason Sams | eeeaccc | 2010-06-25 12:45:41 -0700 | [diff] [blame] | 58 | const uint8_t * mActivePointer; |
Jason Sams | df48b57 | 2010-01-25 12:31:24 -0800 | [diff] [blame] | 59 | uint32_t mCount; |
| 60 | |
Alex Sakhartchouk | 9d71e21 | 2010-11-08 15:10:52 -0800 | [diff] [blame] | 61 | const Attrib *mAttribs; |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | |
| 65 | class VertexArrayState { |
| 66 | public: |
| 67 | void init(Context *); |
| 68 | |
Jason Sams | 5dbfe93 | 2010-01-27 14:41:43 -0800 | [diff] [blame] | 69 | uint32_t mLastEnableCount; |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | |
| 73 | } |
| 74 | } |
Alex Sakhartchouk | 76322af | 2010-10-05 13:23:55 -0700 | [diff] [blame] | 75 | #endif //ANDROID_VERTEX_ARRAY_H |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 76 | |
| 77 | |
| 78 | |