diff options
author | 2011-01-28 09:31:47 -0800 | |
---|---|---|
committer | 2011-01-31 12:38:34 -0800 | |
commit | a3b5960f6f28a81cd63abd69adcdfb5dcc05aa30 (patch) | |
tree | ced261c0c614263d9f8acb5bdc483324f6b25311 | |
parent | bd07f8e864120c183d6ef6dded1fb286a004b2a5 (diff) |
Making sure we can build libRS on the host for serialization.
Change-Id: If0a5d77b20c0e1e2d124fa0737643a5dd1d4409a
-rw-r--r-- | libs/rs/Android.mk | 22 | ||||
-rw-r--r-- | libs/rs/RenderScript.h | 3 | ||||
-rw-r--r-- | libs/rs/rsAllocation.cpp | 43 | ||||
-rw-r--r-- | libs/rs/rsComponent.cpp | 7 | ||||
-rw-r--r-- | libs/rs/rsContextHostStub.h | 48 | ||||
-rw-r--r-- | libs/rs/rsElement.cpp | 4 | ||||
-rw-r--r-- | libs/rs/rsFileA3D.cpp | 18 | ||||
-rw-r--r-- | libs/rs/rsMesh.cpp | 180 | ||||
-rw-r--r-- | libs/rs/rsMesh.h | 16 | ||||
-rw-r--r-- | libs/rs/rsType.cpp | 4 |
10 files changed, 173 insertions, 172 deletions
diff --git a/libs/rs/Android.mk b/libs/rs/Android.mk index 38358525c61a..2d0b6c4e2f1e 100644 --- a/libs/rs/Android.mk +++ b/libs/rs/Android.mk @@ -130,6 +130,28 @@ LOCAL_MODULE_TAGS := optional include $(BUILD_SHARED_LIBRARY) +# Now build a host version for serialization +include $(CLEAR_VARS) +LOCAL_CFLAGS += -DANDROID_RS_BUILD_FOR_HOST + +LOCAL_SRC_FILES:= \ + rsAllocation.cpp \ + rsComponent.cpp \ + rsElement.cpp \ + rsFileA3D.cpp \ + rsObjectBase.cpp \ + rsMesh.cpp \ + rsStream.cpp \ + rsType.cpp + +LOCAL_STATIC_LIBRARIES := libcutils libutils + +LOCAL_LDLIBS := -lpthread +LOCAL_MODULE:= libRSserialize +LOCAL_MODULE_TAGS := optional + +include $(BUILD_HOST_STATIC_LIBRARY) + # include the java examples include $(addprefix $(LOCAL_PATH)/,$(addsuffix /Android.mk,\ java \ diff --git a/libs/rs/RenderScript.h b/libs/rs/RenderScript.h index f160ef1a7b40..882a0b0777bb 100644 --- a/libs/rs/RenderScript.h +++ b/libs/rs/RenderScript.h @@ -365,6 +365,9 @@ RsAllocation rsaAllocationCreateFromBitmap(RsContext con, RsType vtype, RsAllocation rsaAllocationCubeCreateFromBitmap(RsContext con, RsType vtype, RsAllocationMipmapControl mips, const void *data, uint32_t usages); +#ifdef ANDROID_RS_BUILD_FOR_HOST +#define NO_RS_FUNCS +#endif #ifndef NO_RS_FUNCS #include "rsgApiFuncDecl.h" diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp index c598f0395362..2839b76cdeb2 100644 --- a/libs/rs/rsAllocation.cpp +++ b/libs/rs/rsAllocation.cpp @@ -21,12 +21,7 @@ #include <GLES/glext.h> #else #include "rsContextHostStub.h" - -#include <OpenGL/gl.h> -#include <OpenGl/glext.h> -#endif - -#include "utils/StopWatch.h" +#endif //ANDROID_RS_BUILD_FOR_HOST static void rsaAllocationGenerateScriptMips(RsContext con, RsAllocation va); @@ -83,7 +78,7 @@ Allocation::~Allocation() { mPtr = NULL; } freeScriptMemory(); - +#ifndef ANDROID_RS_BUILD_FOR_HOST if (mBufferID) { // Causes a SW crash.... //LOGV(" mBufferID %i", mBufferID); @@ -94,6 +89,7 @@ Allocation::~Allocation() { glDeleteTextures(1, &mTextureID); mTextureID = 0; } +#endif //ANDROID_RS_BUILD_FOR_HOST } void Allocation::setCpuWritable(bool) { @@ -118,6 +114,7 @@ void Allocation::deferedUploadToTexture(const Context *rsc) { } uint32_t Allocation::getGLTarget() const { +#ifndef ANDROID_RS_BUILD_FOR_HOST if (getIsTexture()) { if (mType->getDimFaces()) { return GL_TEXTURE_CUBE_MAP; @@ -128,6 +125,7 @@ uint32_t Allocation::getGLTarget() const { if (getIsBufferObject()) { return GL_ARRAY_BUFFER; } +#endif //ANDROID_RS_BUILD_FOR_HOST return 0; } @@ -158,7 +156,7 @@ void Allocation::syncAll(Context *rsc, RsAllocationUsageType src) { } void Allocation::uploadToTexture(const Context *rsc) { - +#ifndef ANDROID_RS_BUILD_FOR_HOST mUsageFlags |= RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE; GLenum type = mType->getElement()->getComponent().getGLType(); GLenum format = mType->getElement()->getComponent().getGLFormat(); @@ -195,8 +193,10 @@ void Allocation::uploadToTexture(const Context *rsc) { } rsc->checkError("Allocation::uploadToTexture"); +#endif //ANDROID_RS_BUILD_FOR_HOST } +#ifndef ANDROID_RS_BUILD_FOR_HOST const static GLenum gFaceOrder[] = { GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, @@ -205,10 +205,12 @@ const static GLenum gFaceOrder[] = { GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z }; +#endif //ANDROID_RS_BUILD_FOR_HOST void Allocation::update2DTexture(const void *ptr, uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face, uint32_t w, uint32_t h) { +#ifndef ANDROID_RS_BUILD_FOR_HOST GLenum type = mType->getElement()->getComponent().getGLType(); GLenum format = mType->getElement()->getComponent().getGLFormat(); GLenum target = (GLenum)getGLTarget(); @@ -220,9 +222,11 @@ void Allocation::update2DTexture(const void *ptr, uint32_t xoff, uint32_t yoff, t = gFaceOrder[face]; } glTexSubImage2D(t, lod, xoff, yoff, w, h, format, type, ptr); +#endif //ANDROID_RS_BUILD_FOR_HOST } void Allocation::upload2DTexture(bool isFirstUpload) { +#ifndef ANDROID_RS_BUILD_FOR_HOST GLenum type = mType->getElement()->getComponent().getGLType(); GLenum format = mType->getElement()->getComponent().getGLFormat(); @@ -258,10 +262,9 @@ void Allocation::upload2DTexture(bool isFirstUpload) { } if (mMipmapControl == RS_ALLOCATION_MIPMAP_ON_SYNC_TO_TEXTURE) { -#ifndef ANDROID_RS_BUILD_FOR_HOST glGenerateMipmap(target); -#endif //ANDROID_RS_BUILD_FOR_HOST } +#endif //ANDROID_RS_BUILD_FOR_HOST } void Allocation::deferedUploadToBufferObject(const Context *rsc) { @@ -270,6 +273,7 @@ void Allocation::deferedUploadToBufferObject(const Context *rsc) { } void Allocation::uploadToBufferObject(const Context *rsc) { +#ifndef ANDROID_RS_BUILD_FOR_HOST rsAssert(!mType->getDimY()); rsAssert(!mType->getDimZ()); @@ -288,6 +292,7 @@ void Allocation::uploadToBufferObject(const Context *rsc) { glBufferData(target, mType->getSizeBytes(), getPtr(), GL_DYNAMIC_DRAW); glBindBuffer(target, 0); rsc->checkError("Allocation::uploadToBufferObject"); +#endif //ANDROID_RS_BUILD_FOR_HOST } void Allocation::uploadCheck(Context *rsc) { @@ -386,7 +391,7 @@ void Allocation::elementData(Context *rsc, uint32_t x, const void *data, ptr += mType->getElement()->getFieldOffsetBytes(cIdx); if (sizeBytes != e->getSizeBytes()) { - LOGE("Error Allocation::subElementData data size %i does not match field size %i.", sizeBytes, e->getSizeBytes()); + LOGE("Error Allocation::subElementData data size %i does not match field size %zu.", sizeBytes, e->getSizeBytes()); rsc->setError(RS_ERROR_BAD_VALUE, "subElementData bad size."); return; } @@ -429,7 +434,7 @@ void Allocation::elementData(Context *rsc, uint32_t x, uint32_t y, ptr += mType->getElement()->getFieldOffsetBytes(cIdx); if (sizeBytes != e->getSizeBytes()) { - LOGE("Error Allocation::subElementData data size %i does not match field size %i.", sizeBytes, e->getSizeBytes()); + LOGE("Error Allocation::subElementData data size %i does not match field size %zu.", sizeBytes, e->getSizeBytes()); rsc->setError(RS_ERROR_BAD_VALUE, "subElementData bad size."); return; } @@ -445,10 +450,13 @@ void Allocation::elementData(Context *rsc, uint32_t x, uint32_t y, } void Allocation::addProgramToDirty(const Program *p) { +#ifndef ANDROID_RS_BUILD_FOR_HOST mToDirtyList.push(p); +#endif //ANDROID_RS_BUILD_FOR_HOST } void Allocation::removeProgramToDirty(const Program *p) { +#ifndef ANDROID_RS_BUILD_FOR_HOST for (size_t ct=0; ct < mToDirtyList.size(); ct++) { if (mToDirtyList[ct] == p) { mToDirtyList.removeAt(ct); @@ -456,6 +464,7 @@ void Allocation::removeProgramToDirty(const Program *p) { } } rsAssert(0); +#endif //ANDROID_RS_BUILD_FOR_HOST } void Allocation::dumpLOGV(const char *prefix) const { @@ -530,9 +539,11 @@ Allocation *Allocation::createFromStream(Context *rsc, IStream *stream) { } void Allocation::sendDirty() const { +#ifndef ANDROID_RS_BUILD_FOR_HOST for (size_t ct=0; ct < mToDirtyList.size(); ct++) { mToDirtyList[ct]->forceDirty(); } +#endif //ANDROID_RS_BUILD_FOR_HOST } void Allocation::incRefs(const void *ptr, size_t ct, size_t startOff) const { @@ -591,7 +602,7 @@ void Allocation::resize2D(Context *rsc, uint32_t dimX, uint32_t dimY) { ///////////////// // - +#ifndef ANDROID_RS_BUILD_FOR_HOST namespace android { namespace renderscript { @@ -674,8 +685,6 @@ static void mip(const Adapter2D &out, const Adapter2D &in) { } } -#ifndef ANDROID_RS_BUILD_FOR_HOST - void rsi_AllocationSyncAll(Context *rsc, RsAllocation va, RsAllocationUsageType src) { Allocation *a = static_cast<Allocation *>(va); a->syncAll(rsc, src); @@ -739,8 +748,6 @@ void rsi_AllocationResize2D(Context *rsc, RsAllocation va, uint32_t dimX, uint32 a->resize2D(rsc, dimX, dimY); } -#endif //ANDROID_RS_BUILD_FOR_HOST - } } @@ -840,3 +847,5 @@ RsAllocation rsaAllocationCubeCreateFromBitmap(RsContext con, RsType vtype, texAlloc->deferedUploadToTexture(rsc); return texAlloc; } + +#endif //ANDROID_RS_BUILD_FOR_HOST diff --git a/libs/rs/rsComponent.cpp b/libs/rs/rsComponent.cpp index 81ade5d4f60f..cb3caf805c5a 100644 --- a/libs/rs/rsComponent.cpp +++ b/libs/rs/rsComponent.cpp @@ -18,8 +18,6 @@ #ifndef ANDROID_RS_BUILD_FOR_HOST #include <GLES/gl.h> -#else -#include <OpenGL/gl.h> #endif using namespace android; @@ -183,6 +181,7 @@ bool Component::isReference() const { } uint32_t Component::getGLType() const { +#ifndef ANDROID_RS_BUILD_FOR_HOST switch (mType) { case RS_TYPE_UNSIGNED_5_6_5: return GL_UNSIGNED_SHORT_5_6_5; case RS_TYPE_UNSIGNED_5_5_5_1: return GL_UNSIGNED_SHORT_5_5_5_1; @@ -196,11 +195,12 @@ uint32_t Component::getGLType() const { case RS_TYPE_SIGNED_16: return GL_SHORT; default: break; } - +#endif //ANDROID_RS_BUILD_FOR_HOST return 0; } uint32_t Component::getGLFormat() const { +#ifndef ANDROID_RS_BUILD_FOR_HOST switch (mKind) { case RS_KIND_PIXEL_L: return GL_LUMINANCE; case RS_KIND_PIXEL_A: return GL_ALPHA; @@ -209,6 +209,7 @@ uint32_t Component::getGLFormat() const { case RS_KIND_PIXEL_RGBA: return GL_RGBA; default: break; } +#endif //ANDROID_RS_BUILD_FOR_HOST return 0; } diff --git a/libs/rs/rsContextHostStub.h b/libs/rs/rsContextHostStub.h index 8cfb38bd5b18..7e8ec3972696 100644 --- a/libs/rs/rsContextHostStub.h +++ b/libs/rs/rsContextHostStub.h @@ -18,34 +18,18 @@ #define ANDROID_RS_CONTEXT_HOST_STUB_H #include "rsUtils.h" -//#include "rsMutex.h" - -//#include "rsThreadIO.h" #include "rsType.h" -#include "rsMatrix.h" #include "rsAllocation.h" #include "rsMesh.h" -//#include "rsDevice.h" -#include "rsScriptC.h" #include "rsAllocation.h" -#include "rsAdapter.h" -#include "rsSampler.h" -#include "rsProgramFragment.h" -#include "rsProgramStore.h" -#include "rsProgramRaster.h" -#include "rsProgramVertex.h" -#include "rsShaderCache.h" -#include "rsVertexArray.h" - -//#include "rsgApiStructs.h" -//#include "rsLocklessFifo.h" - -//#include <ui/egl/android_natives.h> // --------------------------------------------------------------------------- namespace android { namespace renderscript { +#define CHECK_OBJ(o) +#define CHECK_OBJ_OR_NULL(o) + class Device; class Context { @@ -56,36 +40,13 @@ public: ~Context() { } - //StructuredAllocationContext mStateAllocation; ElementState mStateElement; TypeState mStateType; - SamplerState mStateSampler; - //ProgramFragmentState mStateFragment; - ProgramStoreState mStateFragmentStore; - //ProgramRasterState mStateRaster; - //ProgramVertexState mStateVertex; - VertexArrayState mStateVertexArray; - - //ScriptCState mScriptC; - ShaderCache mShaderCache; - RsSurfaceConfig mUserSurfaceConfig; //bool setupCheck(); - ProgramFragment * getDefaultProgramFragment() const { - return NULL; - } - ProgramVertex * getDefaultProgramVertex() const { - return NULL; - } - ProgramStore * getDefaultProgramStore() const { - return NULL; - } - ProgramRaster * getDefaultProgramRaster() const { - return NULL; - } uint32_t getWidth() const {return 0;} uint32_t getHeight() const {return 0;} @@ -99,6 +60,8 @@ public: _RS_TIMER_TOTAL }; + void timerSet(Timers) { } + bool checkVersion1_1() const {return false; } bool checkVersion2_0() const {return false; } @@ -157,3 +120,4 @@ protected: } } #endif + diff --git a/libs/rs/rsElement.cpp b/libs/rs/rsElement.cpp index 6ae8bb8f640e..7c3b9e8dc42d 100644 --- a/libs/rs/rsElement.cpp +++ b/libs/rs/rsElement.cpp @@ -17,10 +17,8 @@ #ifndef ANDROID_RS_BUILD_FOR_HOST #include "rsContext.h" -#include <GLES/gl.h> #else #include "rsContextHostStub.h" -#include <OpenGL/gl.h> #endif using namespace android; @@ -65,7 +63,7 @@ size_t Element::getSizeBits() const { void Element::dumpLOGV(const char *prefix) const { ObjectBase::dumpLOGV(prefix); - LOGV("%s Element: fieldCount: %i, size bytes: %i", prefix, mFieldCount, getSizeBytes()); + LOGV("%s Element: fieldCount: %zu, size bytes: %zu", prefix, mFieldCount, getSizeBytes()); for (uint32_t ct = 0; ct < mFieldCount; ct++) { LOGV("%s Element field index: %u ------------------", prefix, ct); LOGV("%s name: %s, offsetBits: %u, arraySize: %u", diff --git a/libs/rs/rsFileA3D.cpp b/libs/rs/rsFileA3D.cpp index d34ddd68b77e..97ce8c8affa4 100644 --- a/libs/rs/rsFileA3D.cpp +++ b/libs/rs/rsFileA3D.cpp @@ -249,31 +249,31 @@ ObjectBase *FileA3D::initializeFromEntry(size_t index) { entry->mRsObj = Allocation::createFromStream(mRSC, mReadStream); break; case RS_A3D_CLASS_ID_PROGRAM_VERTEX: - entry->mRsObj = ProgramVertex::createFromStream(mRSC, mReadStream); + //entry->mRsObj = ProgramVertex::createFromStream(mRSC, mReadStream); break; case RS_A3D_CLASS_ID_PROGRAM_RASTER: - entry->mRsObj = ProgramRaster::createFromStream(mRSC, mReadStream); + //entry->mRsObj = ProgramRaster::createFromStream(mRSC, mReadStream); break; case RS_A3D_CLASS_ID_PROGRAM_FRAGMENT: - entry->mRsObj = ProgramFragment::createFromStream(mRSC, mReadStream); + //entry->mRsObj = ProgramFragment::createFromStream(mRSC, mReadStream); break; case RS_A3D_CLASS_ID_PROGRAM_STORE: - entry->mRsObj = ProgramStore::createFromStream(mRSC, mReadStream); + //entry->mRsObj = ProgramStore::createFromStream(mRSC, mReadStream); break; case RS_A3D_CLASS_ID_SAMPLER: - entry->mRsObj = Sampler::createFromStream(mRSC, mReadStream); + //entry->mRsObj = Sampler::createFromStream(mRSC, mReadStream); break; case RS_A3D_CLASS_ID_ANIMATION: - entry->mRsObj = Animation::createFromStream(mRSC, mReadStream); + //entry->mRsObj = Animation::createFromStream(mRSC, mReadStream); break; case RS_A3D_CLASS_ID_ADAPTER_1D: - entry->mRsObj = Adapter1D::createFromStream(mRSC, mReadStream); + //entry->mRsObj = Adapter1D::createFromStream(mRSC, mReadStream); break; case RS_A3D_CLASS_ID_ADAPTER_2D: - entry->mRsObj = Adapter2D::createFromStream(mRSC, mReadStream); + //entry->mRsObj = Adapter2D::createFromStream(mRSC, mReadStream); break; case RS_A3D_CLASS_ID_SCRIPT_C: - return NULL; + break; } if (entry->mRsObj) { entry->mRsObj->incUserRef(); diff --git a/libs/rs/rsMesh.cpp b/libs/rs/rsMesh.cpp index baf4c5319074..8cf76e5f64a1 100644 --- a/libs/rs/rsMesh.cpp +++ b/libs/rs/rsMesh.cpp @@ -22,9 +22,6 @@ #include <GLES/glext.h> #else #include "rsContextHostStub.h" - -#include <OpenGL/gl.h> -#include <OpenGl/glext.h> #endif using namespace android; @@ -35,10 +32,13 @@ Mesh::Mesh(Context *rsc) : ObjectBase(rsc) { mPrimitivesCount = 0; mVertexBuffers = NULL; mVertexBufferCount = 0; + +#ifndef ANDROID_RS_BUILD_FOR_HOST mAttribs = NULL; mAttribAllocationIndex = NULL; mAttribCount = 0; +#endif } Mesh::~Mesh() { @@ -53,12 +53,97 @@ Mesh::~Mesh() { delete[] mPrimitives; } +#ifndef ANDROID_RS_BUILD_FOR_HOST if (mAttribs) { delete[] mAttribs; delete[] mAttribAllocationIndex; } +#endif +} + +void Mesh::serialize(OStream *stream) const { + // Need to identify ourselves + stream->addU32((uint32_t)getClassId()); + + String8 name(getName()); + stream->addString(&name); + + // Store number of vertex streams + stream->addU32(mVertexBufferCount); + for (uint32_t vCount = 0; vCount < mVertexBufferCount; vCount ++) { + mVertexBuffers[vCount]->serialize(stream); + } + + stream->addU32(mPrimitivesCount); + // Store the primitives + for (uint32_t pCount = 0; pCount < mPrimitivesCount; pCount ++) { + Primitive_t * prim = mPrimitives[pCount]; + + stream->addU8((uint8_t)prim->mPrimitive); + + if (prim->mIndexBuffer.get()) { + stream->addU32(1); + prim->mIndexBuffer->serialize(stream); + } else { + stream->addU32(0); + } + } +} + +Mesh *Mesh::createFromStream(Context *rsc, IStream *stream) { + // First make sure we are reading the correct object + RsA3DClassID classID = (RsA3DClassID)stream->loadU32(); + if (classID != RS_A3D_CLASS_ID_MESH) { + LOGE("mesh loading skipped due to invalid class id"); + return NULL; + } + + Mesh * mesh = new Mesh(rsc); + + String8 name; + stream->loadString(&name); + mesh->setName(name.string(), name.size()); + + mesh->mVertexBufferCount = stream->loadU32(); + if (mesh->mVertexBufferCount) { + mesh->mVertexBuffers = new ObjectBaseRef<Allocation>[mesh->mVertexBufferCount]; + + for (uint32_t vCount = 0; vCount < mesh->mVertexBufferCount; vCount ++) { + Allocation *vertexAlloc = Allocation::createFromStream(rsc, stream); + mesh->mVertexBuffers[vCount].set(vertexAlloc); + } + } + + mesh->mPrimitivesCount = stream->loadU32(); + if (mesh->mPrimitivesCount) { + mesh->mPrimitives = new Primitive_t *[mesh->mPrimitivesCount]; + + // load all primitives + for (uint32_t pCount = 0; pCount < mesh->mPrimitivesCount; pCount ++) { + Primitive_t * prim = new Primitive_t; + mesh->mPrimitives[pCount] = prim; + + prim->mPrimitive = (RsPrimitive)stream->loadU8(); + + // Check to see if the index buffer was stored + uint32_t isIndexPresent = stream->loadU32(); + if (isIndexPresent) { + Allocation *indexAlloc = Allocation::createFromStream(rsc, stream); + prim->mIndexBuffer.set(indexAlloc); + } + } + } + +#ifndef ANDROID_RS_BUILD_FOR_HOST + mesh->updateGLPrimitives(); + mesh->initVertexAttribs(); + mesh->uploadAll(rsc); +#endif + return mesh; } +#ifndef ANDROID_RS_BUILD_FOR_HOST + bool Mesh::isValidGLComponent(const Element *elem, uint32_t fieldIdx) { // Do not create attribs for padding if (elem->getFieldName(fieldIdx)[0] == '#') { @@ -224,86 +309,6 @@ void Mesh::updateGLPrimitives() { } } -void Mesh::serialize(OStream *stream) const { - // Need to identify ourselves - stream->addU32((uint32_t)getClassId()); - - String8 name(getName()); - stream->addString(&name); - - // Store number of vertex streams - stream->addU32(mVertexBufferCount); - for (uint32_t vCount = 0; vCount < mVertexBufferCount; vCount ++) { - mVertexBuffers[vCount]->serialize(stream); - } - - stream->addU32(mPrimitivesCount); - // Store the primitives - for (uint32_t pCount = 0; pCount < mPrimitivesCount; pCount ++) { - Primitive_t * prim = mPrimitives[pCount]; - - stream->addU8((uint8_t)prim->mPrimitive); - - if (prim->mIndexBuffer.get()) { - stream->addU32(1); - prim->mIndexBuffer->serialize(stream); - } else { - stream->addU32(0); - } - } -} - -Mesh *Mesh::createFromStream(Context *rsc, IStream *stream) { - // First make sure we are reading the correct object - RsA3DClassID classID = (RsA3DClassID)stream->loadU32(); - if (classID != RS_A3D_CLASS_ID_MESH) { - LOGE("mesh loading skipped due to invalid class id"); - return NULL; - } - - Mesh * mesh = new Mesh(rsc); - - String8 name; - stream->loadString(&name); - mesh->setName(name.string(), name.size()); - - mesh->mVertexBufferCount = stream->loadU32(); - if (mesh->mVertexBufferCount) { - mesh->mVertexBuffers = new ObjectBaseRef<Allocation>[mesh->mVertexBufferCount]; - - for (uint32_t vCount = 0; vCount < mesh->mVertexBufferCount; vCount ++) { - Allocation *vertexAlloc = Allocation::createFromStream(rsc, stream); - mesh->mVertexBuffers[vCount].set(vertexAlloc); - } - } - - mesh->mPrimitivesCount = stream->loadU32(); - if (mesh->mPrimitivesCount) { - mesh->mPrimitives = new Primitive_t *[mesh->mPrimitivesCount]; - - // load all primitives - for (uint32_t pCount = 0; pCount < mesh->mPrimitivesCount; pCount ++) { - Primitive_t * prim = new Primitive_t; - mesh->mPrimitives[pCount] = prim; - - prim->mPrimitive = (RsPrimitive)stream->loadU8(); - - // Check to see if the index buffer was stored - uint32_t isIndexPresent = stream->loadU32(); - if (isIndexPresent) { - Allocation *indexAlloc = Allocation::createFromStream(rsc, stream); - prim->mIndexBuffer.set(indexAlloc); - } - } - } - - mesh->updateGLPrimitives(); - mesh->initVertexAttribs(); - mesh->uploadAll(rsc); - - return mesh; -} - void Mesh::computeBBox() { float *posPtr = NULL; uint32_t vectorSize = 0; @@ -347,13 +352,6 @@ void Mesh::computeBBox() { } } - -MeshContext::MeshContext() { -} - -MeshContext::~MeshContext() { -} - namespace android { namespace renderscript { @@ -428,3 +426,5 @@ void rsaMeshGetIndices(RsContext con, RsMesh mv, RsAllocation *va, uint32_t *pri } } } + +#endif diff --git a/libs/rs/rsMesh.h b/libs/rs/rsMesh.h index 410b70bc5632..e44f90d226e6 100644 --- a/libs/rs/rsMesh.h +++ b/libs/rs/rsMesh.h @@ -50,15 +50,18 @@ public: Primitive_t ** mPrimitives; uint32_t mPrimitivesCount; + virtual void serialize(OStream *stream) const; + virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_MESH; } + static Mesh *createFromStream(Context *rsc, IStream *stream); + +#ifndef ANDROID_RS_BUILD_FOR_HOST void render(Context *) const; void renderPrimitive(Context *, uint32_t primIndex) const; void renderPrimitiveRange(Context *, uint32_t primIndex, uint32_t start, uint32_t len) const; void uploadAll(Context *); void updateGLPrimitives(); - virtual void serialize(OStream *stream) const; - virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_MESH; } - static Mesh *createFromStream(Context *rsc, IStream *stream); + // Bounding volumes float mBBoxMin[3]; @@ -76,12 +79,15 @@ protected: // buffer, it lets us properly map it uint32_t *mAttribAllocationIndex; uint32_t mAttribCount; +#endif }; class MeshContext { public: - MeshContext(); - ~MeshContext(); + MeshContext() { + } + ~MeshContext() { + } }; } diff --git a/libs/rs/rsType.cpp b/libs/rs/rsType.cpp index d7b5f1204361..b94c2f8eaf44 100644 --- a/libs/rs/rsType.cpp +++ b/libs/rs/rsType.cpp @@ -16,10 +16,8 @@ #ifndef ANDROID_RS_BUILD_FOR_HOST #include "rsContext.h" -#include <GLES/gl.h> #else #include "rsContextHostStub.h" -#include <OpenGL/gl.h> #endif using namespace android; @@ -146,7 +144,7 @@ uint32_t Type::getLODFaceOffset(uint32_t lod, RsAllocationCubemapFace face, uint void Type::dumpLOGV(const char *prefix) const { char buf[1024]; ObjectBase::dumpLOGV(prefix); - LOGV("%s Type: x=%i y=%i z=%i mip=%i face=%i", prefix, mDimX, mDimY, mDimZ, mDimLOD, mFaces); + LOGV("%s Type: x=%zu y=%zu z=%zu mip=%i face=%i", prefix, mDimX, mDimY, mDimZ, mDimLOD, mFaces); snprintf(buf, sizeof(buf), "%s element: ", prefix); mElement->dumpLOGV(buf); } |