diff options
author | Alex Sakhartchouk <alexst@google.com> | 2010-11-18 15:22:43 -0800 |
---|---|---|
committer | Alex Sakhartchouk <alexst@google.com> | 2010-11-18 15:27:28 -0800 |
commit | 67f2e442a31b8395e3c1951f8e91139ec7f2be99 (patch) | |
tree | 9e3001eb5181faec98ac13fa85c7915fb8c96c1a /libs/rs/rsProgram.cpp | |
parent | 3d019afcdb167a04d9c879285b448f9be1de3c67 (diff) | |
download | frameworks_base-67f2e442a31b8395e3c1951f8e91139ec7f2be99.zip frameworks_base-67f2e442a31b8395e3c1951f8e91139ec7f2be99.tar.gz frameworks_base-67f2e442a31b8395e3c1951f8e91139ec7f2be99.tar.bz2 |
Support for cubemaps.
Change-Id: Iaf6087f614451a8e233b3e5bc49c834ab0ad08ee
Diffstat (limited to 'libs/rs/rsProgram.cpp')
-rw-r--r-- | libs/rs/rsProgram.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/libs/rs/rsProgram.cpp b/libs/rs/rsProgram.cpp index 1c44e71..39b85e3 100644 --- a/libs/rs/rsProgram.cpp +++ b/libs/rs/rsProgram.cpp @@ -48,13 +48,14 @@ Program::Program(Context *rsc, const char * shaderText, uint32_t shaderLength, if (params[ct] == RS_PROGRAM_PARAM_CONSTANT) { mConstantCount++; } - if (params[ct] == RS_PROGRAM_PARAM_TEXTURE_COUNT) { - mTextureCount = params[ct+1]; + if (params[ct] == RS_PROGRAM_PARAM_TEXTURE_TYPE) { + mTextureCount++; } } mTextures = new ObjectBaseRef<Allocation>[mTextureCount]; mSamplers = new ObjectBaseRef<Sampler>[mTextureCount]; + mTextureTargets = new RsTextureTarget[mTextureCount]; mInputElements = new ObjectBaseRef<Element>[mInputCount]; mOutputElements = new ObjectBaseRef<Element>[mOutputCount]; mConstantTypes = new ObjectBaseRef<Type>[mConstantCount]; @@ -63,6 +64,7 @@ Program::Program(Context *rsc, const char * shaderText, uint32_t shaderLength, uint32_t input = 0; uint32_t output = 0; uint32_t constant = 0; + uint32_t texture = 0; for (uint32_t ct=0; ct < paramLength; ct+=2) { if (params[ct] == RS_PROGRAM_PARAM_INPUT) { mInputElements[input++].set(reinterpret_cast<Element *>(params[ct+1])); @@ -73,6 +75,9 @@ Program::Program(Context *rsc, const char * shaderText, uint32_t shaderLength, if (params[ct] == RS_PROGRAM_PARAM_CONSTANT) { mConstantTypes[constant++].set(reinterpret_cast<Type *>(params[ct+1])); } + if (params[ct] == RS_PROGRAM_PARAM_TEXTURE_TYPE) { + mTextureTargets[texture++] = (RsTextureTarget)params[ct+1]; + } } mIsInternal = false; uint32_t internalTokenLen = strlen(RS_SHADER_INTERNAL); @@ -106,6 +111,7 @@ Program::~Program() { } delete[] mTextures; delete[] mSamplers; + delete[] mTextureTargets; delete[] mInputElements; delete[] mOutputElements; delete[] mConstantTypes; @@ -127,6 +133,7 @@ void Program::initMemberVars() { mTextures = NULL; mSamplers = NULL; + mTextureTargets = NULL; mInputElements = NULL; mOutputElements = NULL; mConstantTypes = NULL; @@ -176,6 +183,12 @@ void Program::bindTexture(Context *rsc, uint32_t slot, Allocation *a) { return; } + if (a && a->getType()->getDimFaces() && mTextureTargets[slot] != RS_TEXTURE_CUBE) { + LOGE("Attempt to bind cubemap to slot %u but 2d texture needed", slot); + rsc->setError(RS_ERROR_BAD_SHADER, "Cannot bind cubemap to 2d texture slot"); + return; + } + //LOGE("bindtex %i %p", slot, a); mTextures[slot].set(a); mDirty = true; |