Loading libs/rs/driver/rsdGL.cpp +24 −3 Original line number Diff line number Diff line Loading @@ -30,11 +30,8 @@ #include <GLES2/gl2.h> #include <GLES2/gl2ext.h> //#include <cutils/sched_policy.h> //#include <sys/syscall.h> #include <string.h> #include "rsdCore.h" #include "rsdGL.h" Loading Loading @@ -346,3 +343,27 @@ void rsdGLSwap(const android::renderscript::Context *rsc) { eglSwapBuffers(dc->gl.egl.display, dc->gl.egl.surface); } void rsdGLCheckError(const android::renderscript::Context *rsc, const char *msg, bool isFatal) { GLenum err = glGetError(); if (err != GL_NO_ERROR) { char buf[1024]; snprintf(buf, sizeof(buf), "GL Error = 0x%08x, from: %s", err, msg); if (isFatal) { rsc->setError(RS_ERROR_FATAL_DRIVER, buf); } else { switch (err) { case GL_OUT_OF_MEMORY: rsc->setError(RS_ERROR_OUT_OF_MEMORY, buf); break; default: rsc->setError(RS_ERROR_DRIVER, buf); break; } } LOGE("%p, %s", rsc, buf); } } libs/rs/driver/rsdGL.h +2 −0 Original line number Diff line number Diff line Loading @@ -76,6 +76,8 @@ void rsdGLShutdown(const android::renderscript::Context *rsc); bool rsdGLSetSurface(const android::renderscript::Context *rsc, uint32_t w, uint32_t h, ANativeWindow *sur); void rsdGLSwap(const android::renderscript::Context *rsc); void rsdGLCheckError(const android::renderscript::Context *rsc, const char *msg, bool isFatal = false); #endif libs/rs/driver/rsdMeshObj.cpp +5 −4 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include <rsMesh.h> #include "rsdMeshObj.h" #include "rsdGL.h" using namespace android; using namespace android::renderscript; Loading Loading @@ -134,7 +135,7 @@ void RsdMeshObj::renderPrimitiveRange(const Context *rsc, uint32_t primIndex, ui return; } rsc->checkError("Mesh::renderPrimitiveRange 1"); rsdGLCheckError(rsc, "Mesh::renderPrimitiveRange 1"); // update attributes with either buffer information or data ptr based on their current state for (uint32_t ct=0; ct < mAttribCount; ct++) { uint32_t allocIndex = mAttribAllocationIndex[ct]; Loading @@ -149,9 +150,9 @@ void RsdMeshObj::renderPrimitiveRange(const Context *rsc, uint32_t primIndex, ui } RsdVertexArray va(mAttribs, mAttribCount); va.setupGL2(rsc); va.setup(rsc); rsc->checkError("Mesh::renderPrimitiveRange 2"); rsdGLCheckError(rsc, "Mesh::renderPrimitiveRange 2"); Mesh::Primitive_t *prim = mRSMesh->mHal.state.primitives[primIndex]; if (prim->mIndexBuffer.get()) { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, prim->mIndexBuffer->getBufferObjectID()); Loading @@ -160,7 +161,7 @@ void RsdMeshObj::renderPrimitiveRange(const Context *rsc, uint32_t primIndex, ui glDrawArrays(mGLPrimitives[primIndex], start, len); } rsc->checkError("Mesh::renderPrimitiveRange"); rsdGLCheckError(rsc, "Mesh::renderPrimitiveRange"); } void RsdMeshObj::updateGLPrimitives() { Loading libs/rs/driver/rsdShader.cpp +8 −6 Original line number Diff line number Diff line Loading @@ -377,7 +377,7 @@ void RsdShader::setupSampler(const Context *rsc, const Sampler *s, const Allocat glTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisoValue); } rsc->checkError("Sampler::setupGL2 tex env"); rsdGLCheckError(rsc, "Sampler::setup tex env"); } void RsdShader::setupTextures(const Context *rsc, RsdShaderCache *sc) { Loading @@ -385,8 +385,10 @@ void RsdShader::setupTextures(const Context *rsc, RsdShaderCache *sc) { return; } RsdHal *dc = (RsdHal *)rsc->mHal.drv; uint32_t numTexturesToBind = mRSProgram->mHal.state.texturesCount; uint32_t numTexturesAvailable = rsc->getMaxFragmentTextures(); uint32_t numTexturesAvailable = dc->gl.gl.maxFragmentTextureImageUnits; if (numTexturesToBind >= numTexturesAvailable) { LOGE("Attempting to bind %u textures on shader id %u, but only %u are available", mRSProgram->mHal.state.texturesCount, (uint32_t)this, numTexturesAvailable); Loading @@ -408,7 +410,7 @@ void RsdShader::setupTextures(const Context *rsc, RsdShaderCache *sc) { rsc->setError(RS_ERROR_BAD_SHADER, "Non-texture allocation bound to a shader"); } glBindTexture(target, mRSProgram->mHal.state.textures[ct]->getTextureID()); rsc->checkError("ProgramFragment::setupGL2 tex bind"); rsdGLCheckError(rsc, "ProgramFragment::setup tex bind"); if (mRSProgram->mHal.state.samplers[ct].get()) { setupSampler(rsc, mRSProgram->mHal.state.samplers[ct].get(), mRSProgram->mHal.state.textures[ct].get()); } else { Loading @@ -416,16 +418,16 @@ void RsdShader::setupTextures(const Context *rsc, RsdShaderCache *sc) { glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); rsc->checkError("ProgramFragment::setupGL2 tex env"); rsdGLCheckError(rsc, "ProgramFragment::setup tex env"); } glUniform1i(sc->fragUniformSlot(mTextureUniformIndexStart + ct), ct); rsc->checkError("ProgramFragment::setupGL2 uniforms"); rsdGLCheckError(rsc, "ProgramFragment::setup uniforms"); } glActiveTexture(GL_TEXTURE0); mDirty = false; rsc->checkError("ProgramFragment::setupGL2"); rsdGLCheckError(rsc, "ProgramFragment::setup"); } void RsdShader::setupUserConstants(const Context *rsc, RsdShaderCache *sc, bool isFragment) { Loading libs/rs/driver/rsdShaderCache.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include "rsdShader.h" #include "rsdShaderCache.h" #include "rsdGL.h" #include <GLES/gl.h> #include <GLES2/gl2.h> Loading Loading @@ -128,7 +129,7 @@ bool RsdShaderCache::link(const Context *rsc) { glUseProgram(mEntries[ct]->program); mCurrent = mEntries[ct]; //LOGV("RsdShaderCache hit, using %i", ct); rsc->checkError("RsdShaderCache::link (hit)"); rsdGLCheckError(rsc, "RsdShaderCache::link (hit)"); return true; } } Loading Loading @@ -230,7 +231,7 @@ bool RsdShaderCache::link(const Context *rsc) { //LOGV("SC made program %i", e->program); glUseProgram(e->program); rsc->checkError("RsdShaderCache::link (miss)"); rsdGLCheckError(rsc, "RsdShaderCache::link (miss)"); return true; } Loading Loading
libs/rs/driver/rsdGL.cpp +24 −3 Original line number Diff line number Diff line Loading @@ -30,11 +30,8 @@ #include <GLES2/gl2.h> #include <GLES2/gl2ext.h> //#include <cutils/sched_policy.h> //#include <sys/syscall.h> #include <string.h> #include "rsdCore.h" #include "rsdGL.h" Loading Loading @@ -346,3 +343,27 @@ void rsdGLSwap(const android::renderscript::Context *rsc) { eglSwapBuffers(dc->gl.egl.display, dc->gl.egl.surface); } void rsdGLCheckError(const android::renderscript::Context *rsc, const char *msg, bool isFatal) { GLenum err = glGetError(); if (err != GL_NO_ERROR) { char buf[1024]; snprintf(buf, sizeof(buf), "GL Error = 0x%08x, from: %s", err, msg); if (isFatal) { rsc->setError(RS_ERROR_FATAL_DRIVER, buf); } else { switch (err) { case GL_OUT_OF_MEMORY: rsc->setError(RS_ERROR_OUT_OF_MEMORY, buf); break; default: rsc->setError(RS_ERROR_DRIVER, buf); break; } } LOGE("%p, %s", rsc, buf); } }
libs/rs/driver/rsdGL.h +2 −0 Original line number Diff line number Diff line Loading @@ -76,6 +76,8 @@ void rsdGLShutdown(const android::renderscript::Context *rsc); bool rsdGLSetSurface(const android::renderscript::Context *rsc, uint32_t w, uint32_t h, ANativeWindow *sur); void rsdGLSwap(const android::renderscript::Context *rsc); void rsdGLCheckError(const android::renderscript::Context *rsc, const char *msg, bool isFatal = false); #endif
libs/rs/driver/rsdMeshObj.cpp +5 −4 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include <rsMesh.h> #include "rsdMeshObj.h" #include "rsdGL.h" using namespace android; using namespace android::renderscript; Loading Loading @@ -134,7 +135,7 @@ void RsdMeshObj::renderPrimitiveRange(const Context *rsc, uint32_t primIndex, ui return; } rsc->checkError("Mesh::renderPrimitiveRange 1"); rsdGLCheckError(rsc, "Mesh::renderPrimitiveRange 1"); // update attributes with either buffer information or data ptr based on their current state for (uint32_t ct=0; ct < mAttribCount; ct++) { uint32_t allocIndex = mAttribAllocationIndex[ct]; Loading @@ -149,9 +150,9 @@ void RsdMeshObj::renderPrimitiveRange(const Context *rsc, uint32_t primIndex, ui } RsdVertexArray va(mAttribs, mAttribCount); va.setupGL2(rsc); va.setup(rsc); rsc->checkError("Mesh::renderPrimitiveRange 2"); rsdGLCheckError(rsc, "Mesh::renderPrimitiveRange 2"); Mesh::Primitive_t *prim = mRSMesh->mHal.state.primitives[primIndex]; if (prim->mIndexBuffer.get()) { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, prim->mIndexBuffer->getBufferObjectID()); Loading @@ -160,7 +161,7 @@ void RsdMeshObj::renderPrimitiveRange(const Context *rsc, uint32_t primIndex, ui glDrawArrays(mGLPrimitives[primIndex], start, len); } rsc->checkError("Mesh::renderPrimitiveRange"); rsdGLCheckError(rsc, "Mesh::renderPrimitiveRange"); } void RsdMeshObj::updateGLPrimitives() { Loading
libs/rs/driver/rsdShader.cpp +8 −6 Original line number Diff line number Diff line Loading @@ -377,7 +377,7 @@ void RsdShader::setupSampler(const Context *rsc, const Sampler *s, const Allocat glTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisoValue); } rsc->checkError("Sampler::setupGL2 tex env"); rsdGLCheckError(rsc, "Sampler::setup tex env"); } void RsdShader::setupTextures(const Context *rsc, RsdShaderCache *sc) { Loading @@ -385,8 +385,10 @@ void RsdShader::setupTextures(const Context *rsc, RsdShaderCache *sc) { return; } RsdHal *dc = (RsdHal *)rsc->mHal.drv; uint32_t numTexturesToBind = mRSProgram->mHal.state.texturesCount; uint32_t numTexturesAvailable = rsc->getMaxFragmentTextures(); uint32_t numTexturesAvailable = dc->gl.gl.maxFragmentTextureImageUnits; if (numTexturesToBind >= numTexturesAvailable) { LOGE("Attempting to bind %u textures on shader id %u, but only %u are available", mRSProgram->mHal.state.texturesCount, (uint32_t)this, numTexturesAvailable); Loading @@ -408,7 +410,7 @@ void RsdShader::setupTextures(const Context *rsc, RsdShaderCache *sc) { rsc->setError(RS_ERROR_BAD_SHADER, "Non-texture allocation bound to a shader"); } glBindTexture(target, mRSProgram->mHal.state.textures[ct]->getTextureID()); rsc->checkError("ProgramFragment::setupGL2 tex bind"); rsdGLCheckError(rsc, "ProgramFragment::setup tex bind"); if (mRSProgram->mHal.state.samplers[ct].get()) { setupSampler(rsc, mRSProgram->mHal.state.samplers[ct].get(), mRSProgram->mHal.state.textures[ct].get()); } else { Loading @@ -416,16 +418,16 @@ void RsdShader::setupTextures(const Context *rsc, RsdShaderCache *sc) { glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); rsc->checkError("ProgramFragment::setupGL2 tex env"); rsdGLCheckError(rsc, "ProgramFragment::setup tex env"); } glUniform1i(sc->fragUniformSlot(mTextureUniformIndexStart + ct), ct); rsc->checkError("ProgramFragment::setupGL2 uniforms"); rsdGLCheckError(rsc, "ProgramFragment::setup uniforms"); } glActiveTexture(GL_TEXTURE0); mDirty = false; rsc->checkError("ProgramFragment::setupGL2"); rsdGLCheckError(rsc, "ProgramFragment::setup"); } void RsdShader::setupUserConstants(const Context *rsc, RsdShaderCache *sc, bool isFragment) { Loading
libs/rs/driver/rsdShaderCache.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include "rsdShader.h" #include "rsdShaderCache.h" #include "rsdGL.h" #include <GLES/gl.h> #include <GLES2/gl2.h> Loading Loading @@ -128,7 +129,7 @@ bool RsdShaderCache::link(const Context *rsc) { glUseProgram(mEntries[ct]->program); mCurrent = mEntries[ct]; //LOGV("RsdShaderCache hit, using %i", ct); rsc->checkError("RsdShaderCache::link (hit)"); rsdGLCheckError(rsc, "RsdShaderCache::link (hit)"); return true; } } Loading Loading @@ -230,7 +231,7 @@ bool RsdShaderCache::link(const Context *rsc) { //LOGV("SC made program %i", e->program); glUseProgram(e->program); rsc->checkError("RsdShaderCache::link (miss)"); rsdGLCheckError(rsc, "RsdShaderCache::link (miss)"); return true; } Loading