diff options
Diffstat (limited to 'libs/rs/driver/rsdShader.h')
| -rw-r--r-- | libs/rs/driver/rsdShader.h | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/libs/rs/driver/rsdShader.h b/libs/rs/driver/rsdShader.h index e32145f..2680b3e 100644 --- a/libs/rs/driver/rsdShader.h +++ b/libs/rs/driver/rsdShader.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 The Android Open Source Project + * Copyright (C) 2011-2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,9 +44,13 @@ public: const size_t *textureNamesLength); virtual ~RsdShader(); - bool createShader(); + uint32_t getStateBasedShaderID(const android::renderscript::Context *); - uint32_t getShaderID() const {return mShaderID;} + // Add ability to get all ID's to clean up the cached program objects + uint32_t getStateBasedIDCount() const { return mStateBasedShaders.size(); } + uint32_t getStateBasedID(uint32_t index) const { + return mStateBasedShaders.itemAt(index)->mShaderID; + } uint32_t getAttribCount() const {return mAttribCount;} uint32_t getUniformCount() const {return mUniformCount;} @@ -64,6 +68,21 @@ public: protected: + class StateBasedKey { + public: + StateBasedKey(uint32_t texCount) : mShaderID(0) { + mTextureTargets = new uint32_t[texCount]; + } + ~StateBasedKey() { + delete[] mTextureTargets; + } + uint32_t mShaderID; + uint32_t *mTextureTargets; + }; + + bool createShader(); + StateBasedKey *getExistingState(); + const android::renderscript::Program *mRSProgram; bool mIsValid; @@ -81,26 +100,26 @@ protected: void appendAttributes(); void appendTextures(); - void createTexturesString(const char** textureNames, size_t textureNamesCount, - const size_t *textureNamesLength); void initAttribAndUniformArray(); mutable bool mDirty; android::String8 mShader; android::String8 mUserShader; - android::String8 mShaderTextures; - uint32_t mShaderID; uint32_t mType; uint32_t mTextureCount; - uint32_t *mTextureTargets; + StateBasedKey *mCurrentState; uint32_t mAttribCount; uint32_t mUniformCount; android::String8 *mAttribNames; android::String8 *mUniformNames; uint32_t *mUniformArraySizes; + android::Vector<android::String8> mTextureNames; + + android::Vector<StateBasedKey*> mStateBasedShaders; + int32_t mTextureUniformIndexStart; void logUniform(const android::renderscript::Element *field, |
