Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 1 | /* |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 2 | * Copyright (C) 2011 The Android Open Source Project |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 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 | |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 17 | #ifndef ANDROID_RSD_VERTEX_ARRAY_H |
| 18 | #define ANDROID_RSD_VERTEX_ARRAY_H |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 19 | |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 20 | namespace android { |
| 21 | namespace renderscript { |
| 22 | |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 23 | class Context; |
| 24 | |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | #include <utils/String8.h> |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 29 | |
| 30 | // An element is a group of Components that occupies one cell in a structure. |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 31 | class RsdVertexArray { |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 32 | public: |
Jason Sams | 433eca3 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 33 | class Attrib { |
| 34 | public: |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 35 | uint32_t buffer; |
Jason Sams | 760f1f7 | 2010-06-25 12:45:41 -0700 | [diff] [blame] | 36 | const uint8_t * ptr; |
Jason Sams | c460e55 | 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; |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 42 | android::String8 name; |
Jason Sams | 433eca3 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 43 | |
| 44 | Attrib(); |
Jason Sams | 433eca3 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 45 | void clear(); |
Alex Sakhartchouk | 54929cc | 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 | 433eca3 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 47 | }; |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 48 | |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 49 | RsdVertexArray(const Attrib *attribs, uint32_t numAttribs); |
| 50 | virtual ~RsdVertexArray(); |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 51 | |
Alex Sakhartchouk | c19ff01 | 2011-05-06 14:59:45 -0700 | [diff] [blame^] | 52 | void setup(const android::renderscript::Context *rsc) const; |
Jason Sams | 433eca3 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 53 | void logAttrib(uint32_t idx, uint32_t slot) const; |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 54 | |
| 55 | protected: |
Jason Sams | be504f2 | 2010-01-25 12:31:24 -0800 | [diff] [blame] | 56 | void clear(uint32_t index); |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 57 | uint32_t mActiveBuffer; |
Jason Sams | 760f1f7 | 2010-06-25 12:45:41 -0700 | [diff] [blame] | 58 | const uint8_t * mActivePointer; |
Jason Sams | be504f2 | 2010-01-25 12:31:24 -0800 | [diff] [blame] | 59 | uint32_t mCount; |
| 60 | |
Alex Sakhartchouk | 54929cc | 2010-11-08 15:10:52 -0800 | [diff] [blame] | 61 | const Attrib *mAttribs; |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 65 | class RsdVertexArrayState { |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 66 | public: |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 67 | RsdVertexArrayState(); |
| 68 | ~RsdVertexArrayState(); |
| 69 | void init(uint32_t maxAttrs); |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 70 | |
Alex Sakhartchouk | 2d79197 | 2010-12-13 14:48:21 -0800 | [diff] [blame] | 71 | bool *mAttrsEnabled; |
| 72 | uint32_t mAttrsEnabledSize; |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 76 | #endif //ANDROID_RSD_VERTEX_ARRAY_H |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 77 | |
| 78 | |
| 79 | |