summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
Diffstat (limited to 'libs')
-rw-r--r--libs/rs/driver/rsdProgram.cpp3
-rw-r--r--libs/rs/driver/rsdShader.cpp18
-rw-r--r--libs/rs/driver/rsdShader.h1
3 files changed, 18 insertions, 4 deletions
diff --git a/libs/rs/driver/rsdProgram.cpp b/libs/rs/driver/rsdProgram.cpp
index 39b3805..27a6663 100644
--- a/libs/rs/driver/rsdProgram.cpp
+++ b/libs/rs/driver/rsdProgram.cpp
@@ -44,6 +44,9 @@ bool rsdProgramVertexInit(const Context *rsc, const ProgramVertex *pv,
static void SyncProgramConstants(const Context *rsc, const Program *p) {
for (uint32_t ct=0; ct < p->mHal.state.texturesCount; ct++) {
const Allocation *a = p->mHal.state.textures[ct].get();
+ if (!a) {
+ continue;
+ }
DrvAllocation *drvAlloc = (DrvAllocation *)a->mHal.drv;
if (drvAlloc->uploadDeferred) {
rsdAllocationSyncAll(rsc, a, RS_ALLOCATION_USAGE_SCRIPT);
diff --git a/libs/rs/driver/rsdShader.cpp b/libs/rs/driver/rsdShader.cpp
index 15cc417..90fe4b2 100644
--- a/libs/rs/driver/rsdShader.cpp
+++ b/libs/rs/driver/rsdShader.cpp
@@ -48,6 +48,7 @@ RsdShader::~RsdShader() {
delete[] mAttribNames;
delete[] mUniformNames;
delete[] mUniformArraySizes;
+ delete[] mTextureTargets;
}
void RsdShader::initMemberVars() {
@@ -59,6 +60,7 @@ void RsdShader::initMemberVars() {
mAttribNames = NULL;
mUniformNames = NULL;
mUniformArraySizes = NULL;
+ mTextureTargets = NULL;
mIsValid = false;
}
@@ -81,6 +83,7 @@ void RsdShader::init() {
mUniformArraySizes[uniformCount] = 1;
uniformCount++;
}
+
}
String8 RsdShader::getGLSLInputString() const {
@@ -141,8 +144,10 @@ void RsdShader::appendTextures() {
for (uint32_t ct=0; ct < mRSProgram->mHal.state.texturesCount; ct++) {
if (mRSProgram->mHal.state.textureTargets[ct] == RS_TEXTURE_2D) {
snprintf(buf, sizeof(buf), "uniform sampler2D UNI_Tex%i;\n", ct);
+ mTextureTargets[ct] = GL_TEXTURE_2D;
} else {
snprintf(buf, sizeof(buf), "uniform samplerCube UNI_Tex%i;\n", ct);
+ mTextureTargets[ct] = GL_TEXTURE_CUBE_MAP;
}
mShader.append(buf);
}
@@ -400,9 +405,11 @@ void RsdShader::setupTextures(const Context *rsc, RsdShaderCache *sc) {
for (uint32_t ct=0; ct < numTexturesToBind; ct++) {
glActiveTexture(GL_TEXTURE0 + ct);
+ glUniform1i(sc->fragUniformSlot(mTextureUniformIndexStart + ct), ct);
+
if (!mRSProgram->mHal.state.textures[ct].get()) {
- LOGE("No texture bound for shader id %u, texture unit %u", (uint)this, ct);
- rsc->setError(RS_ERROR_BAD_SHADER, "No texture bound");
+ // if nothing is bound, reset to default GL texture
+ glBindTexture(mTextureTargets[ct], 0);
continue;
}
@@ -422,8 +429,6 @@ void RsdShader::setupTextures(const Context *rsc, RsdShaderCache *sc) {
glTexParameteri(drvTex->glTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
rsdGLCheckError(rsc, "ProgramFragment::setup tex env");
}
-
- glUniform1i(sc->fragUniformSlot(mTextureUniformIndexStart + ct), ct);
rsdGLCheckError(rsc, "ProgramFragment::setup uniforms");
}
@@ -516,6 +521,11 @@ void RsdShader::initAttribAndUniformArray() {
mUniformNames = new String8[mUniformCount];
mUniformArraySizes = new uint32_t[mUniformCount];
}
+
+ mTextureCount = mRSProgram->mHal.state.texturesCount;
+ if (mTextureCount) {
+ mTextureTargets = new uint32_t[mTextureCount];
+ }
}
void RsdShader::initAddUserElement(const Element *e, String8 *names, uint32_t *arrayLengths, uint32_t *count, const char *prefix) {
diff --git a/libs/rs/driver/rsdShader.h b/libs/rs/driver/rsdShader.h
index 63c4231..3f0d6ea 100644
--- a/libs/rs/driver/rsdShader.h
+++ b/libs/rs/driver/rsdShader.h
@@ -84,6 +84,7 @@ protected:
uint32_t mType;
uint32_t mTextureCount;
+ uint32_t *mTextureTargets;
uint32_t mAttribCount;
uint32_t mUniformCount;
android::String8 *mAttribNames;