Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [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 | #include "rsContext.h" |
| 18 | #include "rsProgramFragment.h" |
| 19 | |
Jason Sams | 4b962e5 | 2009-06-22 17:15:15 -0700 | [diff] [blame] | 20 | #include <GLES/gl.h> |
| 21 | #include <GLES/glext.h> |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 22 | #include <GLES2/gl2.h> |
| 23 | #include <GLES2/gl2ext.h> |
Jason Sams | 4b962e5 | 2009-06-22 17:15:15 -0700 | [diff] [blame] | 24 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 25 | using namespace android; |
| 26 | using namespace android::renderscript; |
| 27 | |
| 28 | |
Jason Sams | 68afd01 | 2009-12-17 16:55:08 -0800 | [diff] [blame] | 29 | ProgramFragment::ProgramFragment(Context *rsc, const uint32_t * params, |
| 30 | uint32_t paramLength) : |
Jason Sams | 0011bcf | 2009-12-15 12:58:36 -0800 | [diff] [blame] | 31 | Program(rsc) |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 32 | { |
Jason Sams | 61f08d6 | 2009-09-25 16:37:33 -0700 | [diff] [blame] | 33 | mAllocFile = __FILE__; |
| 34 | mAllocLine = __LINE__; |
Jason Sams | 68afd01 | 2009-12-17 16:55:08 -0800 | [diff] [blame] | 35 | rsAssert(paramLength = 5); |
| 36 | |
| 37 | mEnvModes[0] = (RsTexEnvMode)params[0]; |
| 38 | mTextureFormats[0] = params[1]; |
| 39 | mEnvModes[1] = (RsTexEnvMode)params[2]; |
| 40 | mTextureFormats[1] = params[3]; |
| 41 | mPointSpriteEnable = params[4] != 0; |
| 42 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 43 | mTextureEnableMask = 0; |
Jason Sams | 68afd01 | 2009-12-17 16:55:08 -0800 | [diff] [blame] | 44 | if (mEnvModes[0]) { |
| 45 | mTextureEnableMask |= 1; |
| 46 | } |
| 47 | if (mEnvModes[1]) { |
| 48 | mTextureEnableMask |= 2; |
| 49 | } |
| 50 | init(rsc); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 51 | } |
| 52 | |
Jason Sams | 7e5ab3b | 2009-12-15 13:27:04 -0800 | [diff] [blame] | 53 | ProgramFragment::ProgramFragment(Context *rsc, const char * shaderText, |
| 54 | uint32_t shaderLength, const uint32_t * params, |
| 55 | uint32_t paramLength) : |
| 56 | Program(rsc, shaderText, shaderLength, params, paramLength) |
| 57 | { |
| 58 | mAllocFile = __FILE__; |
| 59 | mAllocLine = __LINE__; |
| 60 | |
| 61 | init(rsc); |
| 62 | mTextureEnableMask = (1 << mTextureCount) -1; |
| 63 | } |
| 64 | |
| 65 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 66 | ProgramFragment::~ProgramFragment() |
| 67 | { |
| 68 | } |
| 69 | |
Jason Sams | b13ada5 | 2009-08-25 11:34:49 -0700 | [diff] [blame] | 70 | void ProgramFragment::setupGL(const Context *rsc, ProgramFragmentState *state) |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 71 | { |
Jason Sams | 9bee51c | 2009-08-05 13:57:03 -0700 | [diff] [blame] | 72 | if ((state->mLast.get() == this) && !mDirty) { |
| 73 | return; |
| 74 | } |
| 75 | state->mLast.set(this); |
| 76 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 77 | for (uint32_t ct=0; ct < MAX_TEXTURE; ct++) { |
| 78 | glActiveTexture(GL_TEXTURE0 + ct); |
Jason Sams | 4244afa | 2009-07-02 15:09:27 -0700 | [diff] [blame] | 79 | if (!(mTextureEnableMask & (1 << ct)) || !mTextures[ct].get()) { |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 80 | glDisable(GL_TEXTURE_2D); |
| 81 | continue; |
| 82 | } |
| 83 | |
| 84 | glEnable(GL_TEXTURE_2D); |
Jason Sams | b13ada5 | 2009-08-25 11:34:49 -0700 | [diff] [blame] | 85 | if (rsc->checkVersion1_1()) { |
Romain Guy | 2d496bf | 2009-09-04 17:55:41 -0700 | [diff] [blame] | 86 | if (mPointSpriteEnable) { |
| 87 | glEnable(GL_POINT_SPRITE_OES); |
| 88 | } else { |
| 89 | glDisable(GL_POINT_SPRITE_OES); |
| 90 | } |
Jason Sams | b13ada5 | 2009-08-25 11:34:49 -0700 | [diff] [blame] | 91 | glTexEnvi(GL_POINT_SPRITE_OES, GL_COORD_REPLACE_OES, mPointSpriteEnable); |
| 92 | } |
Jason Sams | 3b7d39b | 2009-12-14 12:57:40 -0800 | [diff] [blame] | 93 | mTextures[ct]->uploadCheck(rsc); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 94 | glBindTexture(GL_TEXTURE_2D, mTextures[ct]->getTextureID()); |
| 95 | |
| 96 | switch(mEnvModes[ct]) { |
Jason Sams | 68afd01 | 2009-12-17 16:55:08 -0800 | [diff] [blame] | 97 | case RS_TEX_ENV_MODE_NONE: |
| 98 | rsAssert(0); |
| 99 | break; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 100 | case RS_TEX_ENV_MODE_REPLACE: |
Jason Sams | 4244afa | 2009-07-02 15:09:27 -0700 | [diff] [blame] | 101 | glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 102 | break; |
| 103 | case RS_TEX_ENV_MODE_MODULATE: |
Jason Sams | 4244afa | 2009-07-02 15:09:27 -0700 | [diff] [blame] | 104 | glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 105 | break; |
| 106 | case RS_TEX_ENV_MODE_DECAL: |
Jason Sams | 4244afa | 2009-07-02 15:09:27 -0700 | [diff] [blame] | 107 | glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 108 | break; |
| 109 | } |
| 110 | |
Jason Sams | 02fb2cb | 2009-05-28 15:37:57 -0700 | [diff] [blame] | 111 | if (mSamplers[ct].get()) { |
| 112 | mSamplers[ct]->setupGL(); |
| 113 | } else { |
Jason Sams | fe08d99 | 2009-05-27 14:45:32 -0700 | [diff] [blame] | 114 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 115 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
Jason Sams | 4244afa | 2009-07-02 15:09:27 -0700 | [diff] [blame] | 116 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); |
Jason Sams | fe08d99 | 2009-05-27 14:45:32 -0700 | [diff] [blame] | 117 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); |
Jason Sams | 02fb2cb | 2009-05-28 15:37:57 -0700 | [diff] [blame] | 118 | } |
Jason Sams | 4244afa | 2009-07-02 15:09:27 -0700 | [diff] [blame] | 119 | |
| 120 | // Gross hack. |
| 121 | if (ct == 2) { |
| 122 | glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); |
| 123 | |
| 124 | glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_ADD); |
| 125 | glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PREVIOUS); |
| 126 | glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_TEXTURE); |
| 127 | glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); |
| 128 | glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); |
| 129 | |
| 130 | glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_ADD); |
| 131 | glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_PREVIOUS); |
| 132 | glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_ALPHA, GL_TEXTURE); |
| 133 | glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); |
| 134 | glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); |
| 135 | } |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 136 | } |
| 137 | glActiveTexture(GL_TEXTURE0); |
Jason Sams | 9bee51c | 2009-08-05 13:57:03 -0700 | [diff] [blame] | 138 | mDirty = false; |
Jason Sams | a09a6e1 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 139 | rsc->checkError("ProgramFragment::setupGL"); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 140 | } |
| 141 | |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 142 | void ProgramFragment::setupGL2(const Context *rsc, ProgramFragmentState *state, ShaderCache *sc) |
| 143 | { |
| 144 | //LOGE("sgl2 frag1 %x", glGetError()); |
| 145 | if ((state->mLast.get() == this) && !mDirty) { |
| 146 | //return; |
| 147 | } |
| 148 | state->mLast.set(this); |
| 149 | |
| 150 | for (uint32_t ct=0; ct < MAX_TEXTURE; ct++) { |
| 151 | glActiveTexture(GL_TEXTURE0 + ct); |
| 152 | if (!(mTextureEnableMask & (1 << ct)) || !mTextures[ct].get()) { |
| 153 | glDisable(GL_TEXTURE_2D); |
| 154 | continue; |
| 155 | } |
| 156 | |
Jason Sams | 3b7d39b | 2009-12-14 12:57:40 -0800 | [diff] [blame] | 157 | mTextures[ct]->uploadCheck(rsc); |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 158 | glBindTexture(GL_TEXTURE_2D, mTextures[ct]->getTextureID()); |
| 159 | if (mSamplers[ct].get()) { |
| 160 | mSamplers[ct]->setupGL(); |
| 161 | } else { |
| 162 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 163 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 164 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); |
| 165 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); |
| 166 | } |
| 167 | |
| 168 | glEnable(GL_TEXTURE_2D); |
| 169 | glUniform1i(sc->fragUniformSlot(ct), ct); |
| 170 | } |
| 171 | |
| 172 | glActiveTexture(GL_TEXTURE0); |
| 173 | mDirty = false; |
Jason Sams | a09a6e1 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 174 | rsc->checkError("ProgramFragment::setupGL2"); |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 175 | } |
| 176 | |
Jason Sams | 5dad8b4 | 2009-12-15 19:10:11 -0800 | [diff] [blame] | 177 | void ProgramFragment::loadShader(Context *rsc) { |
| 178 | Program::loadShader(rsc, GL_FRAGMENT_SHADER); |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | void ProgramFragment::createShader() |
| 182 | { |
| 183 | mShader.setTo("precision mediump float;\n"); |
| 184 | mShader.append("varying vec4 varColor;\n"); |
| 185 | mShader.append("varying vec4 varTex0;\n"); |
| 186 | |
Jason Sams | 7e5ab3b | 2009-12-15 13:27:04 -0800 | [diff] [blame] | 187 | if (mUserShader.length() > 1) { |
| 188 | for (uint32_t ct=0; ct < mTextureCount; ct++) { |
| 189 | char buf[256]; |
| 190 | sprintf(buf, "uniform sampler2D uni_Tex%i;\n", ct); |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 191 | mShader.append(buf); |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 192 | } |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 193 | |
Jason Sams | 7e5ab3b | 2009-12-15 13:27:04 -0800 | [diff] [blame] | 194 | mShader.append(mUserShader); |
| 195 | } else { |
| 196 | uint32_t mask = mTextureEnableMask; |
| 197 | uint32_t texNum = 0; |
| 198 | while (mask) { |
| 199 | if (mask & 1) { |
| 200 | char buf[64]; |
| 201 | mShader.append("uniform sampler2D uni_Tex"); |
| 202 | sprintf(buf, "%i", texNum); |
| 203 | mShader.append(buf); |
| 204 | mShader.append(";\n"); |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 205 | } |
Jason Sams | 7e5ab3b | 2009-12-15 13:27:04 -0800 | [diff] [blame] | 206 | mask >>= 1; |
| 207 | texNum++; |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 208 | } |
Jason Sams | 7e5ab3b | 2009-12-15 13:27:04 -0800 | [diff] [blame] | 209 | |
| 210 | |
| 211 | mShader.append("void main() {\n"); |
| 212 | mShader.append(" vec4 col = varColor;\n"); |
| 213 | |
| 214 | if (mTextureEnableMask) { |
| 215 | if (mPointSpriteEnable) { |
Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 216 | mShader.append(" vec2 t0 = gl_PointCoord;\n"); |
Jason Sams | 7e5ab3b | 2009-12-15 13:27:04 -0800 | [diff] [blame] | 217 | } else { |
Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 218 | mShader.append(" vec2 t0 = varTex0.xy;\n"); |
Jason Sams | 7e5ab3b | 2009-12-15 13:27:04 -0800 | [diff] [blame] | 219 | } |
| 220 | } |
| 221 | |
| 222 | mask = mTextureEnableMask; |
| 223 | texNum = 0; |
| 224 | while (mask) { |
| 225 | if (mask & 1) { |
| 226 | switch(mEnvModes[texNum]) { |
Jason Sams | 68afd01 | 2009-12-17 16:55:08 -0800 | [diff] [blame] | 227 | case RS_TEX_ENV_MODE_NONE: |
| 228 | rsAssert(0); |
| 229 | break; |
Jason Sams | 7e5ab3b | 2009-12-15 13:27:04 -0800 | [diff] [blame] | 230 | case RS_TEX_ENV_MODE_REPLACE: |
Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 231 | switch(mTextureFormats[texNum]) { |
| 232 | case 1: |
| 233 | mShader.append(" col.a = texture2D(uni_Tex0, t0).a;\n"); |
| 234 | break; |
| 235 | case 2: |
| 236 | mShader.append(" col.rgba = texture2D(uni_Tex0, t0).rgba;\n"); |
| 237 | break; |
| 238 | case 3: |
| 239 | mShader.append(" col.rgb = texture2D(uni_Tex0, t0).rgb;\n"); |
| 240 | break; |
| 241 | case 4: |
| 242 | mShader.append(" col.rgba = texture2D(uni_Tex0, t0).rgba;\n"); |
| 243 | break; |
| 244 | } |
Jason Sams | 7e5ab3b | 2009-12-15 13:27:04 -0800 | [diff] [blame] | 245 | break; |
| 246 | case RS_TEX_ENV_MODE_MODULATE: |
Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 247 | switch(mTextureFormats[texNum]) { |
| 248 | case 1: |
| 249 | mShader.append(" col.a *= texture2D(uni_Tex0, t0).a;\n"); |
| 250 | break; |
| 251 | case 2: |
| 252 | mShader.append(" col.rgba *= texture2D(uni_Tex0, t0).rgba;\n"); |
| 253 | break; |
| 254 | case 3: |
| 255 | mShader.append(" col.rgb *= texture2D(uni_Tex0, t0).rgb;\n"); |
| 256 | break; |
| 257 | case 4: |
| 258 | mShader.append(" col.rgba *= texture2D(uni_Tex0, t0).rgba;\n"); |
| 259 | break; |
| 260 | } |
Jason Sams | 7e5ab3b | 2009-12-15 13:27:04 -0800 | [diff] [blame] | 261 | break; |
| 262 | case RS_TEX_ENV_MODE_DECAL: |
Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 263 | mShader.append(" col = texture2D(uni_Tex0, t0);\n"); |
Jason Sams | 7e5ab3b | 2009-12-15 13:27:04 -0800 | [diff] [blame] | 264 | break; |
| 265 | } |
| 266 | |
| 267 | } |
| 268 | mask >>= 1; |
| 269 | texNum++; |
| 270 | } |
| 271 | |
| 272 | //mShader.append(" col.a = 1.0;\n"); |
| 273 | //mShader.append(" col.r = 0.5;\n"); |
| 274 | |
| 275 | mShader.append(" gl_FragColor = col;\n"); |
| 276 | mShader.append("}\n"); |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 277 | } |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 278 | } |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 279 | |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 280 | void ProgramFragment::init(Context *rsc) |
| 281 | { |
| 282 | mUniformCount = 2; |
| 283 | mUniformNames[0].setTo("uni_Tex0"); |
| 284 | mUniformNames[1].setTo("uni_Tex1"); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 285 | |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 286 | createShader(); |
| 287 | } |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 288 | |
| 289 | ProgramFragmentState::ProgramFragmentState() |
| 290 | { |
| 291 | mPF = NULL; |
| 292 | } |
| 293 | |
| 294 | ProgramFragmentState::~ProgramFragmentState() |
| 295 | { |
| 296 | delete mPF; |
| 297 | |
| 298 | } |
| 299 | |
Jason Sams | 9c54bdb | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 300 | void ProgramFragmentState::init(Context *rsc, int32_t w, int32_t h) |
| 301 | { |
Jason Sams | 68afd01 | 2009-12-17 16:55:08 -0800 | [diff] [blame] | 302 | uint32_t tmp[5] = { |
| 303 | RS_TEX_ENV_MODE_NONE, 0, |
| 304 | RS_TEX_ENV_MODE_NONE, 0, |
| 305 | 0 |
| 306 | }; |
| 307 | ProgramFragment *pf = new ProgramFragment(rsc, tmp, 5); |
Jason Sams | 9c54bdb | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 308 | mDefault.set(pf); |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 309 | pf->init(rsc); |
Jason Sams | 9c54bdb | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 310 | } |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 311 | |
Jason Sams | 61f08d6 | 2009-09-25 16:37:33 -0700 | [diff] [blame] | 312 | void ProgramFragmentState::deinit(Context *rsc) |
| 313 | { |
| 314 | mDefault.clear(); |
| 315 | mLast.clear(); |
| 316 | } |
| 317 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 318 | |
| 319 | namespace android { |
| 320 | namespace renderscript { |
| 321 | |
Jason Sams | 68afd01 | 2009-12-17 16:55:08 -0800 | [diff] [blame] | 322 | RsProgramFragment rsi_ProgramFragmentCreate(Context *rsc, |
| 323 | const uint32_t * params, |
| 324 | uint32_t paramLength) |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 325 | { |
Jason Sams | 68afd01 | 2009-12-17 16:55:08 -0800 | [diff] [blame] | 326 | ProgramFragment *pf = new ProgramFragment(rsc, params, paramLength); |
Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 327 | pf->incUserRef(); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 328 | return pf; |
| 329 | } |
| 330 | |
Jason Sams | 7e5ab3b | 2009-12-15 13:27:04 -0800 | [diff] [blame] | 331 | RsProgramFragment rsi_ProgramFragmentCreate2(Context *rsc, const char * shaderText, |
| 332 | uint32_t shaderLength, const uint32_t * params, |
| 333 | uint32_t paramLength) |
| 334 | { |
| 335 | ProgramFragment *pf = new ProgramFragment(rsc, shaderText, shaderLength, params, paramLength); |
| 336 | pf->incUserRef(); |
| 337 | return pf; |
| 338 | } |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 339 | |
| 340 | } |
| 341 | } |
| 342 | |