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 | |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 20 | #include "rsUtils.h" |
| 21 | |
Miao Wang | 82e135c | 2017-02-27 23:35:35 -0800 | [diff] [blame] | 22 | #include <string> |
| 23 | |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 24 | namespace android { |
| 25 | namespace renderscript { |
| 26 | |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 27 | class Context; |
| 28 | |
Rahul Chaudhry | 7974fc0 | 2017-02-09 12:33:28 -0800 | [diff] [blame] | 29 | } // namespace renderscript |
| 30 | } // namespace android |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 31 | |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 32 | // 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] | 33 | class RsdVertexArray { |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 34 | public: |
Jason Sams | 433eca3 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 35 | class Attrib { |
| 36 | public: |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 37 | uint32_t buffer; |
Jason Sams | 760f1f7 | 2010-06-25 12:45:41 -0700 | [diff] [blame] | 38 | const uint8_t * ptr; |
Tim Murray | e195a3f | 2014-03-13 15:04:58 -0700 | [diff] [blame] | 39 | size_t offset; |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 40 | uint32_t type; |
| 41 | uint32_t size; |
| 42 | uint32_t stride; |
| 43 | bool normalized; |
Miao Wang | 82e135c | 2017-02-27 23:35:35 -0800 | [diff] [blame] | 44 | std::string name; |
Jason Sams | 433eca3 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 45 | |
| 46 | Attrib(); |
Jason Sams | 433eca3 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 47 | void clear(); |
Tim Murray | e195a3f | 2014-03-13 15:04:58 -0700 | [diff] [blame] | 48 | void set(uint32_t type, uint32_t size, uint32_t stride, bool normalized, size_t offset, const char *name); |
Jason Sams | 433eca3 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 49 | }; |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 50 | |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 51 | RsdVertexArray(const Attrib *attribs, uint32_t numAttribs); |
| 52 | virtual ~RsdVertexArray(); |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 53 | |
Alex Sakhartchouk | c19ff01 | 2011-05-06 14:59:45 -0700 | [diff] [blame] | 54 | void setup(const android::renderscript::Context *rsc) const; |
Jason Sams | 433eca3 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 55 | void logAttrib(uint32_t idx, uint32_t slot) const; |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 56 | |
| 57 | protected: |
Jason Sams | be504f2 | 2010-01-25 12:31:24 -0800 | [diff] [blame] | 58 | void clear(uint32_t index); |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 59 | uint32_t mActiveBuffer; |
Jason Sams | 760f1f7 | 2010-06-25 12:45:41 -0700 | [diff] [blame] | 60 | const uint8_t * mActivePointer; |
Jason Sams | be504f2 | 2010-01-25 12:31:24 -0800 | [diff] [blame] | 61 | uint32_t mCount; |
| 62 | |
Alex Sakhartchouk | 54929cc | 2010-11-08 15:10:52 -0800 | [diff] [blame] | 63 | const Attrib *mAttribs; |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 67 | class RsdVertexArrayState { |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 68 | public: |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 69 | RsdVertexArrayState(); |
| 70 | ~RsdVertexArrayState(); |
| 71 | void init(uint32_t maxAttrs); |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 72 | |
Alex Sakhartchouk | 2d79197 | 2010-12-13 14:48:21 -0800 | [diff] [blame] | 73 | bool *mAttrsEnabled; |
| 74 | uint32_t mAttrsEnabledSize; |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 78 | #endif //ANDROID_RSD_VERTEX_ARRAY_H |
Yang Ni | b8353c5 | 2015-02-14 18:00:59 -0800 | [diff] [blame] | 79 | |
| 80 | |
| 81 | |