diff options
Diffstat (limited to 'driver')
-rw-r--r-- | driver/rsdBcc.cpp | 3 | ||||
-rw-r--r-- | driver/rsdMeshObj.cpp | 4 | ||||
-rw-r--r-- | driver/rsdShader.cpp | 9 | ||||
-rw-r--r-- | driver/rsdShader.h | 10 | ||||
-rw-r--r-- | driver/rsdShaderCache.cpp | 49 | ||||
-rw-r--r-- | driver/rsdShaderCache.h | 17 | ||||
-rw-r--r-- | driver/rsdVertexArray.cpp | 7 | ||||
-rw-r--r-- | driver/rsdVertexArray.h | 7 |
8 files changed, 58 insertions, 48 deletions
diff --git a/driver/rsdBcc.cpp b/driver/rsdBcc.cpp index 811fa3e3..a57409d9 100644 --- a/driver/rsdBcc.cpp +++ b/driver/rsdBcc.cpp @@ -14,8 +14,6 @@ * limitations under the License. */ -#include <vector> - #include "../cpu_ref/rsd_cpu.h" #include "rsdCore.h" @@ -28,6 +26,7 @@ #include "rsScriptC.h" #if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB) +#include "utils/Vector.h" #include "utils/Timers.h" #include "utils/StopWatch.h" #endif diff --git a/driver/rsdMeshObj.cpp b/driver/rsdMeshObj.cpp index ac1780cf..974b41d1 100644 --- a/driver/rsdMeshObj.cpp +++ b/driver/rsdMeshObj.cpp @@ -112,9 +112,9 @@ bool RsdMeshObj::init(const Context *rsc) { mAttribs[userNum].type = rsdTypeToGLType(f->mHal.state.dataType); mAttribs[userNum].normalized = f->mHal.state.dataType != RS_TYPE_FLOAT_32; mAttribs[userNum].stride = stride; - std::string tmp(RS_SHADER_ATTR); + String8 tmp(RS_SHADER_ATTR); tmp.append(elem->mHal.state.fieldNames[fieldI]); - mAttribs[userNum].name = tmp.c_str(); + mAttribs[userNum].name = tmp.string(); // Remember which allocation this attribute came from mAttribAllocationIndex[userNum] = ct; diff --git a/driver/rsdShader.cpp b/driver/rsdShader.cpp index 7511883e..eaf679a5 100644 --- a/driver/rsdShader.cpp +++ b/driver/rsdShader.cpp @@ -41,14 +41,13 @@ RsdShader::RsdShader(const Program *p, uint32_t type, init(textureNames, textureNamesCount, textureNamesLength); for(size_t i=0; i < textureNamesCount; i++) { - mTextureNames.push_back(std::string(textureNames[i], - textureNamesLength[i])); + mTextureNames.push(String8(textureNames[i], textureNamesLength[i])); } } RsdShader::~RsdShader() { for (uint32_t i = 0; i < mStateBasedShaders.size(); i ++) { - StateBasedKey *state = mStateBasedShaders[i]; + StateBasedKey *state = mStateBasedShaders.itemAt(i); if (state->mShaderID) { glDeleteShader(state->mShaderID); } @@ -77,7 +76,7 @@ RsdShader::StateBasedKey *RsdShader::getExistingState() { RsdShader::StateBasedKey *returnKey = nullptr; for (uint32_t i = 0; i < mStateBasedShaders.size(); i ++) { - returnKey = mStateBasedShaders[i]; + returnKey = mStateBasedShaders.itemAt(i); for (uint32_t ct = 0; ct < mRSProgram->mHal.state.texturesCount; ct ++) { uint32_t texType = 0; @@ -109,7 +108,7 @@ uint32_t RsdShader::getStateBasedShaderID(const Context *rsc) { // We have not created a shader for this particular state yet state = new StateBasedKey(mTextureCount); mCurrentState = state; - mStateBasedShaders.push_back(state); + mStateBasedShaders.add(state); createShader(); loadShader(rsc); return mCurrentState->mShaderID; diff --git a/driver/rsdShader.h b/driver/rsdShader.h index 0dc5102d..caccc099 100644 --- a/driver/rsdShader.h +++ b/driver/rsdShader.h @@ -49,7 +49,7 @@ public: // 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[index]->mShaderID; + return mStateBasedShaders.itemAt(index)->mShaderID; } uint32_t getAttribCount() const {return mAttribCount;} @@ -116,9 +116,9 @@ protected: std::string *mUniformNames; uint32_t *mUniformArraySizes; - std::vector<std::string> mTextureNames; + android::Vector<android::String8> mTextureNames; - std::vector<StateBasedKey*> mStateBasedShaders; + android::Vector<StateBasedKey*> mStateBasedShaders; int32_t mTextureUniformIndexStart; @@ -133,3 +133,7 @@ protected: }; #endif //ANDROID_RSD_SHADER_H + + + + diff --git a/driver/rsdShaderCache.cpp b/driver/rsdShaderCache.cpp index 608922ce..c6052e2f 100644 --- a/driver/rsdShaderCache.cpp +++ b/driver/rsdShaderCache.cpp @@ -29,7 +29,7 @@ using namespace android::renderscript; RsdShaderCache::RsdShaderCache() { - mEntries.reserve(16); + mEntries.setCapacity(16); mVertexDirty = true; mFragmentDirty = true; } @@ -139,7 +139,7 @@ bool RsdShaderCache::link(const Context *rsc) { ProgramEntry *e = new ProgramEntry(vtx->getAttribCount(), vtx->getUniformCount(), frag->getUniformCount()); - mEntries.push_back(e); + mEntries.push(e); mCurrent = e; e->vtx = vID; e->frag = fID; @@ -237,7 +237,7 @@ bool RsdShaderCache::link(const Context *rsc) { return true; } -int32_t RsdShaderCache::vtxAttribSlot(const std::string &attrName) const { +int32_t RsdShaderCache::vtxAttribSlot(const String8 &attrName) const { for (uint32_t ct=0; ct < mCurrent->vtxAttrCount; ct++) { if (attrName == mCurrent->vtxAttrs[ct].name) { return mCurrent->vtxAttrs[ct].slot; @@ -247,45 +247,46 @@ int32_t RsdShaderCache::vtxAttribSlot(const std::string &attrName) const { } void RsdShaderCache::cleanupVertex(RsdShader *s) { + int32_t numEntries = (int32_t)mEntries.size(); uint32_t numShaderIDs = s->getStateBasedIDCount(); for (uint32_t sId = 0; sId < numShaderIDs; sId ++) { uint32_t id = s->getStateBasedID(sId); - - for (auto entry = mEntries.begin(); entry != mEntries.end();) { - if ((*entry)->vtx == id) { - glDeleteProgram((*entry)->program); - - delete *entry; - entry = mEntries.erase(entry); - } else { - entry++; + for (int32_t ct = 0; ct < numEntries; ct ++) { + if (mEntries[ct]->vtx == id) { + glDeleteProgram(mEntries[ct]->program); + + delete mEntries[ct]; + mEntries.removeAt(ct); + numEntries = (int32_t)mEntries.size(); + ct --; } } } } void RsdShaderCache::cleanupFragment(RsdShader *s) { + int32_t numEntries = (int32_t)mEntries.size(); uint32_t numShaderIDs = s->getStateBasedIDCount(); for (uint32_t sId = 0; sId < numShaderIDs; sId ++) { uint32_t id = s->getStateBasedID(sId); - - for (auto entry = mEntries.begin(); entry != mEntries.end();) { - if ((*entry)->frag == id) { - glDeleteProgram((*entry)->program); - - delete *entry; - entry = mEntries.erase(entry); - } else { - entry++; + for (int32_t ct = 0; ct < numEntries; ct ++) { + if (mEntries[ct]->frag == id) { + glDeleteProgram(mEntries[ct]->program); + + delete mEntries[ct]; + mEntries.removeAt(ct); + numEntries = (int32_t)mEntries.size(); + ct --; } } } } void RsdShaderCache::cleanupAll() { - for (auto entry : mEntries) { - glDeleteProgram(entry->program); - delete entry; + for (uint32_t ct=0; ct < mEntries.size(); ct++) { + glDeleteProgram(mEntries[ct]->program); + free(mEntries[ct]); } mEntries.clear(); } + diff --git a/driver/rsdShaderCache.h b/driver/rsdShaderCache.h index de195e60..29f91bb6 100644 --- a/driver/rsdShaderCache.h +++ b/driver/rsdShaderCache.h @@ -17,9 +17,6 @@ #ifndef ANDROID_RSD_SHADER_CACHE_H #define ANDROID_RSD_SHADER_CACHE_H -#include <string> -#include <vector> - namespace android { namespace renderscript { @@ -28,7 +25,11 @@ class Context; } } -#if defined(RS_SERVER) || defined(RS_COMPATIBILITY_LIB) + +#if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB) +#include <utils/String8.h> +#include <utils/Vector.h> +#else #include "rsUtils.h" #endif class RsdShader; @@ -58,7 +59,7 @@ public: void cleanupAll(); - int32_t vtxAttribSlot(const std::string &attrName) const; + int32_t vtxAttribSlot(const android::String8 &attrName) const; int32_t vtxUniformSlot(uint32_t a) const {return mCurrent->vtxUniforms[a].slot;} uint32_t vtxUniformSize(uint32_t a) const {return mCurrent->vtxUniforms[a].arraySize;} int32_t fragUniformSlot(uint32_t a) const {return mCurrent->fragUniforms[a].slot;} @@ -143,7 +144,7 @@ protected: UniformData *fragUniforms; bool *fragUniformIsSTO; }; - std::vector<ProgramEntry*> mEntries; + android::Vector<ProgramEntry*> mEntries; ProgramEntry *mCurrent; bool hasArrayUniforms(RsdShader *vtx, RsdShader *frag); @@ -156,3 +157,7 @@ protected: #endif //ANDROID_RSD_SHADER_CACHE_H + + + + diff --git a/driver/rsdVertexArray.cpp b/driver/rsdVertexArray.cpp index c18a062f..64fc3aa2 100644 --- a/driver/rsdVertexArray.cpp +++ b/driver/rsdVertexArray.cpp @@ -48,7 +48,7 @@ void RsdVertexArray::Attrib::clear() { stride = 0; ptr = nullptr; normalized = false; - name = ""; + name.setTo(""); } void RsdVertexArray::Attrib::set(uint32_t type, uint32_t size, uint32_t stride, @@ -60,7 +60,7 @@ void RsdVertexArray::Attrib::set(uint32_t type, uint32_t size, uint32_t stride, this->offset = offset; this->normalized = normalized; this->stride = stride; - this->name = name; + this->name.setTo(name); } void RsdVertexArray::logAttrib(uint32_t idx, uint32_t slot) const { @@ -69,7 +69,7 @@ void RsdVertexArray::logAttrib(uint32_t idx, uint32_t slot) const { } ALOGV("va %i: slot=%i name=%s buf=%i ptr=%p size=%i type=0x%x stride=0x%x norm=%i offset=0x%p", idx, slot, - mAttribs[idx].name.c_str(), + mAttribs[idx].name.string(), mAttribs[idx].buffer, mAttribs[idx].ptr, mAttribs[idx].size, @@ -135,3 +135,4 @@ void RsdVertexArrayState::init(uint32_t maxAttrs) { mAttrsEnabled[ct] = false; } } + diff --git a/driver/rsdVertexArray.h b/driver/rsdVertexArray.h index 1bafe3bc..975121b8 100644 --- a/driver/rsdVertexArray.h +++ b/driver/rsdVertexArray.h @@ -17,8 +17,6 @@ #ifndef ANDROID_RSD_VERTEX_ARRAY_H #define ANDROID_RSD_VERTEX_ARRAY_H -#include <string> - #include "rsUtils.h" namespace android { @@ -41,7 +39,7 @@ public: uint32_t size; uint32_t stride; bool normalized; - std::string name; + android::String8 name; Attrib(); void clear(); @@ -76,3 +74,6 @@ public: #endif //ANDROID_RSD_VERTEX_ARRAY_H + + + |