Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1 | /* |
Alex Sakhartchouk | 4a36b45 | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 2 | * Copyright (C) 2011 The Android Open Source Project |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [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 | |
| 17 | #include "rsContext.h" |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 18 | #include "rsProgramVertex.h" |
Jason Sams | 4b962e5 | 2009-06-22 17:15:15 -0700 | [diff] [blame] | 19 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 20 | using namespace android; |
| 21 | using namespace android::renderscript; |
| 22 | |
| 23 | |
Jason Sams | 0011bcf | 2009-12-15 12:58:36 -0800 | [diff] [blame] | 24 | ProgramVertex::ProgramVertex(Context *rsc, const char * shaderText, |
| 25 | uint32_t shaderLength, const uint32_t * params, |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 26 | uint32_t paramLength) |
| 27 | : Program(rsc, shaderText, shaderLength, params, paramLength) { |
Alex Sakhartchouk | 4a36b45 | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 28 | mRSC->mHal.funcs.vertex.init(mRSC, this, mUserShader.string(), mUserShader.length()); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 29 | } |
| 30 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 31 | ProgramVertex::~ProgramVertex() { |
Alex Sakhartchouk | 4a36b45 | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 32 | mRSC->mHal.funcs.vertex.destroy(mRSC, this); |
Jason Sams | b37c0a5 | 2009-06-16 17:49:58 -0700 | [diff] [blame] | 33 | } |
| 34 | |
Alex Sakhartchouk | 407cae9 | 2011-05-06 14:59:45 -0700 | [diff] [blame] | 35 | void ProgramVertex::setup(Context *rsc, ProgramVertexState *state) { |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 36 | if ((state->mLast.get() == this) && !mDirty) { |
Jason Sams | 7c1f4c3 | 2010-06-22 17:22:13 -0700 | [diff] [blame] | 37 | return; |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 38 | } |
| 39 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 40 | if (!isUserProgram()) { |
Alex Sakhartchouk | 4a36b45 | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 41 | if (mHal.state.constants[0].get() == NULL) { |
Jason Sams | add9d96 | 2010-11-22 16:20:16 -0800 | [diff] [blame] | 42 | rsc->setError(RS_ERROR_FATAL_UNKNOWN, |
| 43 | "Unable to set fixed function emulation matrices because allocation is missing"); |
Alex Sakhartchouk | 7215b51 | 2010-09-27 10:29:47 -0700 | [diff] [blame] | 44 | return; |
| 45 | } |
Alex Sakhartchouk | 4a36b45 | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 46 | float *f = static_cast<float *>(mHal.state.constants[0]->getPtr()); |
Jason Sams | fcf7231 | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 47 | Matrix4x4 mvp; |
Alex Sakhartchouk | c984dd7 | 2010-09-14 09:50:43 -0700 | [diff] [blame] | 48 | mvp.load(&f[RS_PROGRAM_VERTEX_PROJECTION_OFFSET]); |
Jason Sams | fcf7231 | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 49 | Matrix4x4 t; |
Alex Sakhartchouk | c984dd7 | 2010-09-14 09:50:43 -0700 | [diff] [blame] | 50 | t.load(&f[RS_PROGRAM_VERTEX_MODELVIEW_OFFSET]); |
| 51 | mvp.multiply(&t); |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 52 | for (uint32_t i = 0; i < 16; i ++) { |
Alex Sakhartchouk | c984dd7 | 2010-09-14 09:50:43 -0700 | [diff] [blame] | 53 | f[RS_PROGRAM_VERTEX_MVP_OFFSET + i] = mvp.m[i]; |
| 54 | } |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | state->mLast.set(this); |
Alex Sakhartchouk | 4a36b45 | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 58 | |
| 59 | rsc->mHal.funcs.vertex.setActive(rsc, this); |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 60 | } |
| 61 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 62 | void ProgramVertex::setProjectionMatrix(Context *rsc, const rsc_Matrix *m) const { |
| 63 | if (isUserProgram()) { |
Jason Sams | add9d96 | 2010-11-22 16:20:16 -0800 | [diff] [blame] | 64 | rsc->setError(RS_ERROR_FATAL_UNKNOWN, |
| 65 | "Attempting to set fixed function emulation matrix projection on user program"); |
Alex Sakhartchouk | b89aaac | 2010-09-23 16:16:33 -0700 | [diff] [blame] | 66 | return; |
| 67 | } |
Alex Sakhartchouk | 4a36b45 | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 68 | if (mHal.state.constants[0].get() == NULL) { |
Jason Sams | add9d96 | 2010-11-22 16:20:16 -0800 | [diff] [blame] | 69 | rsc->setError(RS_ERROR_FATAL_UNKNOWN, |
| 70 | "Unable to set fixed function emulation matrix projection because allocation is missing"); |
Alex Sakhartchouk | c984dd7 | 2010-09-14 09:50:43 -0700 | [diff] [blame] | 71 | return; |
| 72 | } |
Alex Sakhartchouk | 4a36b45 | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 73 | float *f = static_cast<float *>(mHal.state.constants[0]->getPtr()); |
Jason Sams | b0ec1b4 | 2009-07-28 12:02:16 -0700 | [diff] [blame] | 74 | memcpy(&f[RS_PROGRAM_VERTEX_PROJECTION_OFFSET], m, sizeof(rsc_Matrix)); |
Jason Sams | 9bee51c | 2009-08-05 13:57:03 -0700 | [diff] [blame] | 75 | mDirty = true; |
Jason Sams | b0ec1b4 | 2009-07-28 12:02:16 -0700 | [diff] [blame] | 76 | } |
| 77 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 78 | void ProgramVertex::setModelviewMatrix(Context *rsc, const rsc_Matrix *m) const { |
| 79 | if (isUserProgram()) { |
Jason Sams | add9d96 | 2010-11-22 16:20:16 -0800 | [diff] [blame] | 80 | rsc->setError(RS_ERROR_FATAL_UNKNOWN, |
| 81 | "Attempting to set fixed function emulation matrix modelview on user program"); |
Alex Sakhartchouk | b89aaac | 2010-09-23 16:16:33 -0700 | [diff] [blame] | 82 | return; |
| 83 | } |
Alex Sakhartchouk | 4a36b45 | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 84 | if (mHal.state.constants[0].get() == NULL) { |
Jason Sams | add9d96 | 2010-11-22 16:20:16 -0800 | [diff] [blame] | 85 | rsc->setError(RS_ERROR_FATAL_UNKNOWN, |
| 86 | "Unable to set fixed function emulation matrix modelview because allocation is missing"); |
Alex Sakhartchouk | c984dd7 | 2010-09-14 09:50:43 -0700 | [diff] [blame] | 87 | return; |
| 88 | } |
Alex Sakhartchouk | 4a36b45 | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 89 | float *f = static_cast<float *>(mHal.state.constants[0]->getPtr()); |
Jason Sams | b0ec1b4 | 2009-07-28 12:02:16 -0700 | [diff] [blame] | 90 | memcpy(&f[RS_PROGRAM_VERTEX_MODELVIEW_OFFSET], m, sizeof(rsc_Matrix)); |
Jason Sams | 9bee51c | 2009-08-05 13:57:03 -0700 | [diff] [blame] | 91 | mDirty = true; |
Jason Sams | b0ec1b4 | 2009-07-28 12:02:16 -0700 | [diff] [blame] | 92 | } |
| 93 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 94 | void ProgramVertex::setTextureMatrix(Context *rsc, const rsc_Matrix *m) const { |
| 95 | if (isUserProgram()) { |
Jason Sams | add9d96 | 2010-11-22 16:20:16 -0800 | [diff] [blame] | 96 | rsc->setError(RS_ERROR_FATAL_UNKNOWN, |
| 97 | "Attempting to set fixed function emulation matrix texture on user program"); |
Alex Sakhartchouk | b89aaac | 2010-09-23 16:16:33 -0700 | [diff] [blame] | 98 | return; |
| 99 | } |
Alex Sakhartchouk | 4a36b45 | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 100 | if (mHal.state.constants[0].get() == NULL) { |
Jason Sams | add9d96 | 2010-11-22 16:20:16 -0800 | [diff] [blame] | 101 | rsc->setError(RS_ERROR_FATAL_UNKNOWN, |
| 102 | "Unable to set fixed function emulation matrix texture because allocation is missing"); |
Alex Sakhartchouk | c984dd7 | 2010-09-14 09:50:43 -0700 | [diff] [blame] | 103 | return; |
| 104 | } |
Alex Sakhartchouk | 4a36b45 | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 105 | float *f = static_cast<float *>(mHal.state.constants[0]->getPtr()); |
Jason Sams | b0ec1b4 | 2009-07-28 12:02:16 -0700 | [diff] [blame] | 106 | memcpy(&f[RS_PROGRAM_VERTEX_TEXTURE_OFFSET], m, sizeof(rsc_Matrix)); |
Jason Sams | 9bee51c | 2009-08-05 13:57:03 -0700 | [diff] [blame] | 107 | mDirty = true; |
Jason Sams | b0ec1b4 | 2009-07-28 12:02:16 -0700 | [diff] [blame] | 108 | } |
| 109 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 110 | void ProgramVertex::getProjectionMatrix(Context *rsc, rsc_Matrix *m) const { |
| 111 | if (isUserProgram()) { |
Jason Sams | add9d96 | 2010-11-22 16:20:16 -0800 | [diff] [blame] | 112 | rsc->setError(RS_ERROR_FATAL_UNKNOWN, |
| 113 | "Attempting to get fixed function emulation matrix projection on user program"); |
Alex Sakhartchouk | b89aaac | 2010-09-23 16:16:33 -0700 | [diff] [blame] | 114 | return; |
| 115 | } |
Alex Sakhartchouk | 4a36b45 | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 116 | if (mHal.state.constants[0].get() == NULL) { |
Jason Sams | add9d96 | 2010-11-22 16:20:16 -0800 | [diff] [blame] | 117 | rsc->setError(RS_ERROR_FATAL_UNKNOWN, |
| 118 | "Unable to get fixed function emulation matrix projection because allocation is missing"); |
Alex Sakhartchouk | c984dd7 | 2010-09-14 09:50:43 -0700 | [diff] [blame] | 119 | return; |
| 120 | } |
Alex Sakhartchouk | 4a36b45 | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 121 | float *f = static_cast<float *>(mHal.state.constants[0]->getPtr()); |
Alex Sakhartchouk | cbed752 | 2010-08-16 17:40:10 -0700 | [diff] [blame] | 122 | memcpy(m, &f[RS_PROGRAM_VERTEX_PROJECTION_OFFSET], sizeof(rsc_Matrix)); |
| 123 | } |
| 124 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 125 | void ProgramVertex::transformToScreen(Context *rsc, float *v4out, const float *v3in) const { |
| 126 | if (isUserProgram()) { |
Alex Sakhartchouk | c984dd7 | 2010-09-14 09:50:43 -0700 | [diff] [blame] | 127 | return; |
| 128 | } |
Alex Sakhartchouk | 4a36b45 | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 129 | float *f = static_cast<float *>(mHal.state.constants[0]->getPtr()); |
Jason Sams | fcf7231 | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 130 | Matrix4x4 mvp; |
| 131 | mvp.loadMultiply((Matrix4x4 *)&f[RS_PROGRAM_VERTEX_MODELVIEW_OFFSET], |
| 132 | (Matrix4x4 *)&f[RS_PROGRAM_VERTEX_PROJECTION_OFFSET]); |
Jason Sams | e9ad9a7 | 2009-09-30 17:36:20 -0700 | [diff] [blame] | 133 | mvp.vectorMultiply(v4out, v3in); |
| 134 | } |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 135 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 136 | void ProgramVertex::serialize(OStream *stream) const { |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 137 | } |
| 138 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 139 | ProgramVertex *ProgramVertex::createFromStream(Context *rsc, IStream *stream) { |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 140 | return NULL; |
| 141 | } |
| 142 | |
Jason Sams | 0011bcf | 2009-12-15 12:58:36 -0800 | [diff] [blame] | 143 | |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 144 | /////////////////////////////////////////////////////////////////////// |
| 145 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 146 | ProgramVertexState::ProgramVertexState() { |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 147 | } |
| 148 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 149 | ProgramVertexState::~ProgramVertexState() { |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 150 | } |
| 151 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 152 | void ProgramVertexState::init(Context *rsc) { |
Alex Sakhartchouk | 117abdb | 2011-08-16 13:09:46 -0700 | [diff] [blame] | 153 | ObjectBaseRef<const Element> matrixElem = Element::createRef(rsc, RS_TYPE_MATRIX_4X4, |
| 154 | RS_KIND_USER, false, 1); |
| 155 | ObjectBaseRef<const Element> f2Elem = Element::createRef(rsc, RS_TYPE_FLOAT_32, |
| 156 | RS_KIND_USER, false, 2); |
| 157 | ObjectBaseRef<const Element> f3Elem = Element::createRef(rsc, RS_TYPE_FLOAT_32, |
| 158 | RS_KIND_USER, false, 3); |
| 159 | ObjectBaseRef<const Element> f4Elem = Element::createRef(rsc, RS_TYPE_FLOAT_32, |
| 160 | RS_KIND_USER, false, 4); |
Jason Sams | b6f2b13 | 2009-09-24 12:33:45 -0700 | [diff] [blame] | 161 | |
Alex Sakhartchouk | 117abdb | 2011-08-16 13:09:46 -0700 | [diff] [blame] | 162 | Element::Builder constBuilder; |
| 163 | constBuilder.add(matrixElem.get(), "MV", 1); |
| 164 | constBuilder.add(matrixElem.get(), "P", 1); |
| 165 | constBuilder.add(matrixElem.get(), "TexMatrix", 1); |
| 166 | constBuilder.add(matrixElem.get(), "MVP", 1); |
| 167 | ObjectBaseRef<const Element> constInput = constBuilder.create(rsc); |
Jason Sams | b6f2b13 | 2009-09-24 12:33:45 -0700 | [diff] [blame] | 168 | |
Alex Sakhartchouk | 117abdb | 2011-08-16 13:09:46 -0700 | [diff] [blame] | 169 | Element::Builder inputBuilder; |
| 170 | inputBuilder.add(f4Elem.get(), "position", 1); |
| 171 | inputBuilder.add(f4Elem.get(), "color", 1); |
| 172 | inputBuilder.add(f3Elem.get(), "normal", 1); |
| 173 | inputBuilder.add(f2Elem.get(), "texture0", 1); |
| 174 | ObjectBaseRef<const Element> attrElem = inputBuilder.create(rsc); |
Alex Sakhartchouk | c984dd7 | 2010-09-14 09:50:43 -0700 | [diff] [blame] | 175 | |
Alex Sakhartchouk | 117abdb | 2011-08-16 13:09:46 -0700 | [diff] [blame] | 176 | ObjectBaseRef<Type> inputType = Type::getTypeRef(rsc, constInput.get(), 1, 0, 0, false, false); |
Alex Sakhartchouk | c984dd7 | 2010-09-14 09:50:43 -0700 | [diff] [blame] | 177 | |
| 178 | String8 shaderString(RS_SHADER_INTERNAL); |
| 179 | shaderString.append("varying vec4 varColor;\n"); |
Alex Sakhartchouk | d209163 | 2010-10-06 11:15:01 -0700 | [diff] [blame] | 180 | shaderString.append("varying vec2 varTex0;\n"); |
Alex Sakhartchouk | c984dd7 | 2010-09-14 09:50:43 -0700 | [diff] [blame] | 181 | shaderString.append("void main() {\n"); |
| 182 | shaderString.append(" gl_Position = UNI_MVP * ATTRIB_position;\n"); |
| 183 | shaderString.append(" gl_PointSize = 1.0;\n"); |
| 184 | shaderString.append(" varColor = ATTRIB_color;\n"); |
| 185 | shaderString.append(" varTex0 = ATTRIB_texture0;\n"); |
| 186 | shaderString.append("}\n"); |
| 187 | |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 188 | uint32_t tmp[4]; |
Alex Sakhartchouk | c984dd7 | 2010-09-14 09:50:43 -0700 | [diff] [blame] | 189 | tmp[0] = RS_PROGRAM_PARAM_CONSTANT; |
Alex Sakhartchouk | 117abdb | 2011-08-16 13:09:46 -0700 | [diff] [blame] | 190 | tmp[1] = (uint32_t)inputType.get(); |
Alex Sakhartchouk | c984dd7 | 2010-09-14 09:50:43 -0700 | [diff] [blame] | 191 | tmp[2] = RS_PROGRAM_PARAM_INPUT; |
Alex Sakhartchouk | 117abdb | 2011-08-16 13:09:46 -0700 | [diff] [blame] | 192 | tmp[3] = (uint32_t)attrElem.get(); |
Alex Sakhartchouk | c984dd7 | 2010-09-14 09:50:43 -0700 | [diff] [blame] | 193 | |
| 194 | ProgramVertex *pv = new ProgramVertex(rsc, shaderString.string(), |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 195 | shaderString.length(), tmp, 4); |
Alex Sakhartchouk | 117abdb | 2011-08-16 13:09:46 -0700 | [diff] [blame] | 196 | Allocation *alloc = Allocation::createAllocation(rsc, inputType.get(), |
Jason Sams | 7e8aae7 | 2011-05-26 16:33:01 -0700 | [diff] [blame] | 197 | RS_ALLOCATION_USAGE_SCRIPT | RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS); |
Alex Sakhartchouk | b89aaac | 2010-09-23 16:16:33 -0700 | [diff] [blame] | 198 | pv->bindAllocation(rsc, alloc, 0); |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 199 | |
Jason Sams | 9c54bdb | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 200 | mDefaultAlloc.set(alloc); |
| 201 | mDefault.set(pv); |
Jason Sams | 9bee51c | 2009-08-05 13:57:03 -0700 | [diff] [blame] | 202 | |
Jason Sams | f603d21 | 2010-05-14 15:30:29 -0700 | [diff] [blame] | 203 | updateSize(rsc); |
Jason Sams | eb4b031 | 2009-11-12 16:09:45 -0800 | [diff] [blame] | 204 | } |
| 205 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 206 | void ProgramVertexState::updateSize(Context *rsc) { |
Alex Sakhartchouk | c984dd7 | 2010-09-14 09:50:43 -0700 | [diff] [blame] | 207 | float *f = static_cast<float *>(mDefaultAlloc->getPtr()); |
| 208 | |
Jason Sams | fcf7231 | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 209 | Matrix4x4 m; |
Jason Sams | f603d21 | 2010-05-14 15:30:29 -0700 | [diff] [blame] | 210 | m.loadOrtho(0,rsc->getWidth(), rsc->getHeight(),0, -1,1); |
Alex Sakhartchouk | c984dd7 | 2010-09-14 09:50:43 -0700 | [diff] [blame] | 211 | memcpy(&f[RS_PROGRAM_VERTEX_PROJECTION_OFFSET], m.m, sizeof(m)); |
| 212 | memcpy(&f[RS_PROGRAM_VERTEX_MVP_OFFSET], m.m, sizeof(m)); |
Jason Sams | 9c54bdb | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 213 | |
| 214 | m.loadIdentity(); |
Alex Sakhartchouk | c984dd7 | 2010-09-14 09:50:43 -0700 | [diff] [blame] | 215 | memcpy(&f[RS_PROGRAM_VERTEX_MODELVIEW_OFFSET], m.m, sizeof(m)); |
| 216 | memcpy(&f[RS_PROGRAM_VERTEX_TEXTURE_OFFSET], m.m, sizeof(m)); |
Jason Sams | 9c54bdb | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 217 | } |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 218 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 219 | void ProgramVertexState::deinit(Context *rsc) { |
Jason Sams | 61f08d6 | 2009-09-25 16:37:33 -0700 | [diff] [blame] | 220 | mDefaultAlloc.clear(); |
| 221 | mDefault.clear(); |
Jason Sams | 61f08d6 | 2009-09-25 16:37:33 -0700 | [diff] [blame] | 222 | mLast.clear(); |
Jason Sams | 61f08d6 | 2009-09-25 16:37:33 -0700 | [diff] [blame] | 223 | } |
| 224 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 225 | |
| 226 | namespace android { |
| 227 | namespace renderscript { |
| 228 | |
Alex Sakhartchouk | b89aaac | 2010-09-23 16:16:33 -0700 | [diff] [blame] | 229 | RsProgramVertex rsi_ProgramVertexCreate(Context *rsc, const char * shaderText, |
Alex Sakhartchouk | 17a8a19 | 2011-06-03 10:18:01 -0700 | [diff] [blame] | 230 | size_t shaderLength, const uint32_t * params, |
| 231 | size_t paramLength) { |
Jason Sams | 0011bcf | 2009-12-15 12:58:36 -0800 | [diff] [blame] | 232 | ProgramVertex *pv = new ProgramVertex(rsc, shaderText, shaderLength, params, paramLength); |
| 233 | pv->incUserRef(); |
| 234 | return pv; |
Jason Sams | ee41112 | 2009-07-21 12:20:54 -0700 | [diff] [blame] | 235 | } |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 236 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 237 | } |
| 238 | } |