Loading graphics/java/android/renderscript/Allocation.java +10 −1 Original line number Diff line number Diff line Loading @@ -99,6 +99,14 @@ public class Allocation extends BaseObj { */ public static final int USAGE_GRAPHICS_CONSTANTS = 0x0008; /** * @hide * USAGE_GRAPHICS_RENDER_TARGET The allcation will be used as a * target for offscreen rendering * */ public static final int USAGE_GRAPHICS_RENDER_TARGET = 0x0010; /** * Controls mipmap behavior when using the bitmap creation and Loading Loading @@ -137,7 +145,8 @@ public class Allocation extends BaseObj { if ((usage & ~(USAGE_SCRIPT | USAGE_GRAPHICS_TEXTURE | USAGE_GRAPHICS_VERTEX | USAGE_GRAPHICS_CONSTANTS)) != 0) { USAGE_GRAPHICS_CONSTANTS | USAGE_GRAPHICS_RENDER_TARGET)) != 0) { throw new RSIllegalArgumentException("Unknown usage specified."); } mType = t; Loading graphics/java/android/renderscript/Element.java +19 −7 Original line number Diff line number Diff line Loading @@ -124,7 +124,8 @@ public class Element extends BaseObj { PIXEL_A (8), PIXEL_LA (9), PIXEL_RGB (10), PIXEL_RGBA (11); PIXEL_RGBA (11), PIXEL_DEPTH (12); int mID; DataKind(int id) { Loading Loading @@ -536,10 +537,12 @@ public class Element extends BaseObj { dk == DataKind.PIXEL_A || dk == DataKind.PIXEL_LA || dk == DataKind.PIXEL_RGB || dk == DataKind.PIXEL_RGBA)) { dk == DataKind.PIXEL_RGBA || dk == DataKind.PIXEL_DEPTH)) { throw new RSIllegalArgumentException("Unsupported DataKind"); } if (!(dt == DataType.UNSIGNED_8 || dt == DataType.UNSIGNED_16 || dt == DataType.UNSIGNED_5_6_5 || dt == DataType.UNSIGNED_4_4_4_4 || dt == DataType.UNSIGNED_5_5_5_1)) { Loading @@ -554,16 +557,25 @@ public class Element extends BaseObj { if (dt == DataType.UNSIGNED_4_4_4_4 && dk != DataKind.PIXEL_RGBA) { throw new RSIllegalArgumentException("Bad kind and type combo"); } if (dt == DataType.UNSIGNED_16 && dk != DataKind.PIXEL_DEPTH) { throw new RSIllegalArgumentException("Bad kind and type combo"); } int size = 1; if (dk == DataKind.PIXEL_LA) { switch (dk) { case PIXEL_LA: size = 2; } if (dk == DataKind.PIXEL_RGB) { break; case PIXEL_RGB: size = 3; } if (dk == DataKind.PIXEL_RGBA) { break; case PIXEL_RGBA: size = 4; break; case PIXEL_DEPTH: size = 2; break; } boolean norm = true; Loading libs/rs/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,7 @@ LOCAL_SRC_FILES:= \ rsContext.cpp \ rsDevice.cpp \ rsElement.cpp \ rsFBOCache.cpp \ rsFileA3D.cpp \ rsFont.cpp \ rsLocklessFifo.cpp \ Loading libs/rs/RenderScriptDefines.h +2 −0 Original line number Diff line number Diff line Loading @@ -84,6 +84,7 @@ enum RsAllocationUsageType { RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE = 0x0002, RS_ALLOCATION_USAGE_GRAPHICS_VERTEX = 0x0004, RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS = 0x0008, RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET = 0x0010, RS_ALLOCATION_USAGE_ALL = 0x000F }; Loading Loading @@ -147,6 +148,7 @@ enum RsDataKind { RS_KIND_PIXEL_LA, RS_KIND_PIXEL_RGB, RS_KIND_PIXEL_RGBA, RS_KIND_PIXEL_DEPTH, }; enum RsSamplerParam { Loading libs/rs/rsAllocation.cpp +56 −18 Original line number Diff line number Diff line Loading @@ -56,7 +56,8 @@ void Allocation::init(Context *rsc, const Type *type) { mTextureID = 0; mBufferID = 0; mUploadDefered = false; mRenderTargetID = 0; mUploadDeferred = false; mUserBitmapCallback = NULL; mUserBitmapCallbackData = NULL; Loading Loading @@ -93,6 +94,10 @@ Allocation::~Allocation() { glDeleteTextures(1, &mTextureID); mTextureID = 0; } if (mRenderTargetID) { glDeleteRenderbuffers(1, &mRenderTargetID); mRenderTargetID = 0; } #endif //ANDROID_RS_SERIALIZE } Loading @@ -112,9 +117,14 @@ bool Allocation::fixAllocation() { return false; } void Allocation::deferedUploadToTexture(const Context *rsc) { void Allocation::deferredUploadToTexture(const Context *rsc) { mHal.state.usageFlags |= RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE; mUploadDefered = true; mUploadDeferred = true; } void Allocation::deferredAllocateRenderTarget(const Context *rsc) { mHal.state.usageFlags |= RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET; mUploadDeferred = true; } uint32_t Allocation::getGLTarget() const { Loading Loading @@ -155,8 +165,11 @@ void Allocation::syncAll(Context *rsc, RsAllocationUsageType src) { if (getIsBufferObject()) { uploadToBufferObject(rsc); } if (getIsRenderTarget() && !getIsTexture()) { allocateRenderTarget(rsc); } mUploadDefered = false; mUploadDeferred = false; } void Allocation::uploadToTexture(const Context *rsc) { Loading Loading @@ -184,7 +197,7 @@ void Allocation::uploadToTexture(const Context *rsc) { // Force a crash to 1: restart the app, 2: make sure we get a bugreport. LOGE("Upload to texture failed to gen mTextureID"); rsc->dumpDebug(); mUploadDefered = true; mUploadDeferred = true; return; } isFirstUpload = true; Loading @@ -200,6 +213,32 @@ void Allocation::uploadToTexture(const Context *rsc) { #endif //ANDROID_RS_SERIALIZE } void Allocation::allocateRenderTarget(const Context *rsc) { #ifndef ANDROID_RS_SERIALIZE mHal.state.usageFlags |= RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET; GLenum format = mHal.state.type->getElement()->getComponent().getGLFormat(); if (!format) { return; } if (!mRenderTargetID) { glGenRenderbuffers(1, &mRenderTargetID); if (!mRenderTargetID) { // This should generally not happen LOGE("allocateRenderTarget failed to gen mRenderTargetID"); rsc->dumpDebug(); return; } glBindRenderbuffer(GL_RENDERBUFFER, mRenderTargetID); glRenderbufferStorage(GL_RENDERBUFFER, format, mHal.state.type->getDimX(), mHal.state.type->getDimY()); } #endif //ANDROID_RS_SERIALIZE } #ifndef ANDROID_RS_SERIALIZE const static GLenum gFaceOrder[] = { GL_TEXTURE_CUBE_MAP_POSITIVE_X, Loading Loading @@ -271,9 +310,9 @@ void Allocation::upload2DTexture(bool isFirstUpload) { #endif //ANDROID_RS_SERIALIZE } void Allocation::deferedUploadToBufferObject(const Context *rsc) { void Allocation::deferredUploadToBufferObject(const Context *rsc) { mHal.state.usageFlags |= RS_ALLOCATION_USAGE_GRAPHICS_VERTEX; mUploadDefered = true; mUploadDeferred = true; } void Allocation::uploadToBufferObject(const Context *rsc) { Loading @@ -288,7 +327,7 @@ void Allocation::uploadToBufferObject(const Context *rsc) { } if (!mBufferID) { LOGE("Upload to buffer object failed"); mUploadDefered = true; mUploadDeferred = true; return; } GLenum target = (GLenum)getGLTarget(); Loading @@ -300,7 +339,7 @@ void Allocation::uploadToBufferObject(const Context *rsc) { } void Allocation::uploadCheck(Context *rsc) { if (mUploadDefered) { if (mUploadDeferred) { syncAll(rsc, RS_ALLOCATION_USAGE_SCRIPT); } } Loading Loading @@ -329,7 +368,7 @@ void Allocation::data(Context *rsc, uint32_t xoff, uint32_t lod, memcpy(ptr, data, size); sendDirty(); mUploadDefered = true; mUploadDeferred = true; } void Allocation::data(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face, Loading Loading @@ -362,7 +401,7 @@ void Allocation::data(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t lod, dst += destW * eSize; } sendDirty(); mUploadDefered = true; mUploadDeferred = true; } else { update2DTexture(data, xoff, yoff, lod, face, w, h); } Loading Loading @@ -407,7 +446,7 @@ void Allocation::elementData(Context *rsc, uint32_t x, const void *data, memcpy(ptr, data, sizeBytes); sendDirty(); mUploadDefered = true; mUploadDeferred = true; } void Allocation::elementData(Context *rsc, uint32_t x, uint32_t y, Loading Loading @@ -450,7 +489,7 @@ void Allocation::elementData(Context *rsc, uint32_t x, uint32_t y, memcpy(ptr, data, sizeBytes); sendDirty(); mUploadDefered = true; mUploadDeferred = true; } void Allocation::addProgramToDirty(const Program *p) { Loading Loading @@ -617,12 +656,12 @@ namespace renderscript { void rsi_AllocationUploadToTexture(Context *rsc, RsAllocation va, bool genmip, uint32_t baseMipLevel) { Allocation *alloc = static_cast<Allocation *>(va); alloc->deferedUploadToTexture(rsc); alloc->deferredUploadToTexture(rsc); } void rsi_AllocationUploadToBufferObject(Context *rsc, RsAllocation va) { Allocation *alloc = static_cast<Allocation *>(va); alloc->deferedUploadToBufferObject(rsc); alloc->deferredUploadToBufferObject(rsc); } static void mip565(const Adapter2D &out, const Adapter2D &in) { Loading Loading @@ -792,7 +831,6 @@ RsAllocation rsaAllocationCreateTyped(RsContext con, RsType vtype, return alloc; } RsAllocation rsaAllocationCreateFromBitmap(RsContext con, RsType vtype, RsAllocationMipmapControl mips, const void *data, uint32_t usages) { Loading @@ -811,7 +849,7 @@ RsAllocation rsaAllocationCreateFromBitmap(RsContext con, RsType vtype, rsaAllocationGenerateScriptMips(rsc, texAlloc); } texAlloc->deferedUploadToTexture(rsc); texAlloc->deferredUploadToTexture(rsc); return texAlloc; } Loading Loading @@ -852,7 +890,7 @@ RsAllocation rsaAllocationCubeCreateFromBitmap(RsContext con, RsType vtype, rsaAllocationGenerateScriptMips(rsc, texAlloc); } texAlloc->deferedUploadToTexture(rsc); texAlloc->deferredUploadToTexture(rsc); return texAlloc; } Loading Loading
graphics/java/android/renderscript/Allocation.java +10 −1 Original line number Diff line number Diff line Loading @@ -99,6 +99,14 @@ public class Allocation extends BaseObj { */ public static final int USAGE_GRAPHICS_CONSTANTS = 0x0008; /** * @hide * USAGE_GRAPHICS_RENDER_TARGET The allcation will be used as a * target for offscreen rendering * */ public static final int USAGE_GRAPHICS_RENDER_TARGET = 0x0010; /** * Controls mipmap behavior when using the bitmap creation and Loading Loading @@ -137,7 +145,8 @@ public class Allocation extends BaseObj { if ((usage & ~(USAGE_SCRIPT | USAGE_GRAPHICS_TEXTURE | USAGE_GRAPHICS_VERTEX | USAGE_GRAPHICS_CONSTANTS)) != 0) { USAGE_GRAPHICS_CONSTANTS | USAGE_GRAPHICS_RENDER_TARGET)) != 0) { throw new RSIllegalArgumentException("Unknown usage specified."); } mType = t; Loading
graphics/java/android/renderscript/Element.java +19 −7 Original line number Diff line number Diff line Loading @@ -124,7 +124,8 @@ public class Element extends BaseObj { PIXEL_A (8), PIXEL_LA (9), PIXEL_RGB (10), PIXEL_RGBA (11); PIXEL_RGBA (11), PIXEL_DEPTH (12); int mID; DataKind(int id) { Loading Loading @@ -536,10 +537,12 @@ public class Element extends BaseObj { dk == DataKind.PIXEL_A || dk == DataKind.PIXEL_LA || dk == DataKind.PIXEL_RGB || dk == DataKind.PIXEL_RGBA)) { dk == DataKind.PIXEL_RGBA || dk == DataKind.PIXEL_DEPTH)) { throw new RSIllegalArgumentException("Unsupported DataKind"); } if (!(dt == DataType.UNSIGNED_8 || dt == DataType.UNSIGNED_16 || dt == DataType.UNSIGNED_5_6_5 || dt == DataType.UNSIGNED_4_4_4_4 || dt == DataType.UNSIGNED_5_5_5_1)) { Loading @@ -554,16 +557,25 @@ public class Element extends BaseObj { if (dt == DataType.UNSIGNED_4_4_4_4 && dk != DataKind.PIXEL_RGBA) { throw new RSIllegalArgumentException("Bad kind and type combo"); } if (dt == DataType.UNSIGNED_16 && dk != DataKind.PIXEL_DEPTH) { throw new RSIllegalArgumentException("Bad kind and type combo"); } int size = 1; if (dk == DataKind.PIXEL_LA) { switch (dk) { case PIXEL_LA: size = 2; } if (dk == DataKind.PIXEL_RGB) { break; case PIXEL_RGB: size = 3; } if (dk == DataKind.PIXEL_RGBA) { break; case PIXEL_RGBA: size = 4; break; case PIXEL_DEPTH: size = 2; break; } boolean norm = true; Loading
libs/rs/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,7 @@ LOCAL_SRC_FILES:= \ rsContext.cpp \ rsDevice.cpp \ rsElement.cpp \ rsFBOCache.cpp \ rsFileA3D.cpp \ rsFont.cpp \ rsLocklessFifo.cpp \ Loading
libs/rs/RenderScriptDefines.h +2 −0 Original line number Diff line number Diff line Loading @@ -84,6 +84,7 @@ enum RsAllocationUsageType { RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE = 0x0002, RS_ALLOCATION_USAGE_GRAPHICS_VERTEX = 0x0004, RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS = 0x0008, RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET = 0x0010, RS_ALLOCATION_USAGE_ALL = 0x000F }; Loading Loading @@ -147,6 +148,7 @@ enum RsDataKind { RS_KIND_PIXEL_LA, RS_KIND_PIXEL_RGB, RS_KIND_PIXEL_RGBA, RS_KIND_PIXEL_DEPTH, }; enum RsSamplerParam { Loading
libs/rs/rsAllocation.cpp +56 −18 Original line number Diff line number Diff line Loading @@ -56,7 +56,8 @@ void Allocation::init(Context *rsc, const Type *type) { mTextureID = 0; mBufferID = 0; mUploadDefered = false; mRenderTargetID = 0; mUploadDeferred = false; mUserBitmapCallback = NULL; mUserBitmapCallbackData = NULL; Loading Loading @@ -93,6 +94,10 @@ Allocation::~Allocation() { glDeleteTextures(1, &mTextureID); mTextureID = 0; } if (mRenderTargetID) { glDeleteRenderbuffers(1, &mRenderTargetID); mRenderTargetID = 0; } #endif //ANDROID_RS_SERIALIZE } Loading @@ -112,9 +117,14 @@ bool Allocation::fixAllocation() { return false; } void Allocation::deferedUploadToTexture(const Context *rsc) { void Allocation::deferredUploadToTexture(const Context *rsc) { mHal.state.usageFlags |= RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE; mUploadDefered = true; mUploadDeferred = true; } void Allocation::deferredAllocateRenderTarget(const Context *rsc) { mHal.state.usageFlags |= RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET; mUploadDeferred = true; } uint32_t Allocation::getGLTarget() const { Loading Loading @@ -155,8 +165,11 @@ void Allocation::syncAll(Context *rsc, RsAllocationUsageType src) { if (getIsBufferObject()) { uploadToBufferObject(rsc); } if (getIsRenderTarget() && !getIsTexture()) { allocateRenderTarget(rsc); } mUploadDefered = false; mUploadDeferred = false; } void Allocation::uploadToTexture(const Context *rsc) { Loading Loading @@ -184,7 +197,7 @@ void Allocation::uploadToTexture(const Context *rsc) { // Force a crash to 1: restart the app, 2: make sure we get a bugreport. LOGE("Upload to texture failed to gen mTextureID"); rsc->dumpDebug(); mUploadDefered = true; mUploadDeferred = true; return; } isFirstUpload = true; Loading @@ -200,6 +213,32 @@ void Allocation::uploadToTexture(const Context *rsc) { #endif //ANDROID_RS_SERIALIZE } void Allocation::allocateRenderTarget(const Context *rsc) { #ifndef ANDROID_RS_SERIALIZE mHal.state.usageFlags |= RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET; GLenum format = mHal.state.type->getElement()->getComponent().getGLFormat(); if (!format) { return; } if (!mRenderTargetID) { glGenRenderbuffers(1, &mRenderTargetID); if (!mRenderTargetID) { // This should generally not happen LOGE("allocateRenderTarget failed to gen mRenderTargetID"); rsc->dumpDebug(); return; } glBindRenderbuffer(GL_RENDERBUFFER, mRenderTargetID); glRenderbufferStorage(GL_RENDERBUFFER, format, mHal.state.type->getDimX(), mHal.state.type->getDimY()); } #endif //ANDROID_RS_SERIALIZE } #ifndef ANDROID_RS_SERIALIZE const static GLenum gFaceOrder[] = { GL_TEXTURE_CUBE_MAP_POSITIVE_X, Loading Loading @@ -271,9 +310,9 @@ void Allocation::upload2DTexture(bool isFirstUpload) { #endif //ANDROID_RS_SERIALIZE } void Allocation::deferedUploadToBufferObject(const Context *rsc) { void Allocation::deferredUploadToBufferObject(const Context *rsc) { mHal.state.usageFlags |= RS_ALLOCATION_USAGE_GRAPHICS_VERTEX; mUploadDefered = true; mUploadDeferred = true; } void Allocation::uploadToBufferObject(const Context *rsc) { Loading @@ -288,7 +327,7 @@ void Allocation::uploadToBufferObject(const Context *rsc) { } if (!mBufferID) { LOGE("Upload to buffer object failed"); mUploadDefered = true; mUploadDeferred = true; return; } GLenum target = (GLenum)getGLTarget(); Loading @@ -300,7 +339,7 @@ void Allocation::uploadToBufferObject(const Context *rsc) { } void Allocation::uploadCheck(Context *rsc) { if (mUploadDefered) { if (mUploadDeferred) { syncAll(rsc, RS_ALLOCATION_USAGE_SCRIPT); } } Loading Loading @@ -329,7 +368,7 @@ void Allocation::data(Context *rsc, uint32_t xoff, uint32_t lod, memcpy(ptr, data, size); sendDirty(); mUploadDefered = true; mUploadDeferred = true; } void Allocation::data(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face, Loading Loading @@ -362,7 +401,7 @@ void Allocation::data(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t lod, dst += destW * eSize; } sendDirty(); mUploadDefered = true; mUploadDeferred = true; } else { update2DTexture(data, xoff, yoff, lod, face, w, h); } Loading Loading @@ -407,7 +446,7 @@ void Allocation::elementData(Context *rsc, uint32_t x, const void *data, memcpy(ptr, data, sizeBytes); sendDirty(); mUploadDefered = true; mUploadDeferred = true; } void Allocation::elementData(Context *rsc, uint32_t x, uint32_t y, Loading Loading @@ -450,7 +489,7 @@ void Allocation::elementData(Context *rsc, uint32_t x, uint32_t y, memcpy(ptr, data, sizeBytes); sendDirty(); mUploadDefered = true; mUploadDeferred = true; } void Allocation::addProgramToDirty(const Program *p) { Loading Loading @@ -617,12 +656,12 @@ namespace renderscript { void rsi_AllocationUploadToTexture(Context *rsc, RsAllocation va, bool genmip, uint32_t baseMipLevel) { Allocation *alloc = static_cast<Allocation *>(va); alloc->deferedUploadToTexture(rsc); alloc->deferredUploadToTexture(rsc); } void rsi_AllocationUploadToBufferObject(Context *rsc, RsAllocation va) { Allocation *alloc = static_cast<Allocation *>(va); alloc->deferedUploadToBufferObject(rsc); alloc->deferredUploadToBufferObject(rsc); } static void mip565(const Adapter2D &out, const Adapter2D &in) { Loading Loading @@ -792,7 +831,6 @@ RsAllocation rsaAllocationCreateTyped(RsContext con, RsType vtype, return alloc; } RsAllocation rsaAllocationCreateFromBitmap(RsContext con, RsType vtype, RsAllocationMipmapControl mips, const void *data, uint32_t usages) { Loading @@ -811,7 +849,7 @@ RsAllocation rsaAllocationCreateFromBitmap(RsContext con, RsType vtype, rsaAllocationGenerateScriptMips(rsc, texAlloc); } texAlloc->deferedUploadToTexture(rsc); texAlloc->deferredUploadToTexture(rsc); return texAlloc; } Loading Loading @@ -852,7 +890,7 @@ RsAllocation rsaAllocationCubeCreateFromBitmap(RsContext con, RsType vtype, rsaAllocationGenerateScriptMips(rsc, texAlloc); } texAlloc->deferedUploadToTexture(rsc); texAlloc->deferredUploadToTexture(rsc); return texAlloc; } Loading