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 | 84e4027f83b20af59f5b1fc52be6e45f159d3970 (patch) | |
| tree | 9126523f29e77a6d8aaadc6b6784e9d091a7c520 /rsProgram.cpp | |
| parent | 1a2b9b5f19e0f47b22b66b98aafd5cf1045601d7 (diff) | |
Support for cubemaps.
Change-Id: Iaf6087f614451a8e233b3e5bc49c834ab0ad08ee
Diffstat (limited to 'rsProgram.cpp')
| -rw-r--r-- | rsProgram.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/rsProgram.cpp b/rsProgram.cpp index 1c44e710..39b85e39 100644 --- a/rsProgram.cpp +++ b/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; |
