summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorJason Sams <rjsams@android.com>2010-12-15 02:11:26 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-12-15 02:11:26 -0800
commit1eb9f161a6f03cc8fc3a464a71a36e92bc79bd01 (patch)
tree21f71a19faa0e03134ee7c66e1b3507e0fcd7c8a /libs
parentee02d83e4963848efa0375ccfcde0455d47bb2ad (diff)
parent6d8eb266dd398abf0511685fdaf98abba3396174 (diff)
downloadframeworks_base-1eb9f161a6f03cc8fc3a464a71a36e92bc79bd01.zip
frameworks_base-1eb9f161a6f03cc8fc3a464a71a36e92bc79bd01.tar.gz
frameworks_base-1eb9f161a6f03cc8fc3a464a71a36e92bc79bd01.tar.bz2
Merge "Fix mipmap bug introduced with Allocation cleanup. Add syncAll to rsg headers."
Diffstat (limited to 'libs')
-rw-r--r--libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java6
-rw-r--r--libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java6
-rw-r--r--libs/rs/java/Samples/src/com/android/samples/RsBenchRS.java17
-rw-r--r--libs/rs/java/Samples/src/com/android/samples/RsRenderStatesRS.java16
-rw-r--r--libs/rs/rsAllocation.cpp19
-rw-r--r--libs/rs/rsFont.cpp4
-rw-r--r--libs/rs/rsScriptC_LibGL.cpp14
-rw-r--r--libs/rs/scriptc/rs_graphics.rsh3
8 files changed, 52 insertions, 33 deletions
diff --git a/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java
index f61cf25..6cb50b8 100644
--- a/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java
+++ b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java
@@ -128,9 +128,9 @@ public class SceneGraphRS {
}
private void loadImage() {
- mGridImage = Allocation.createFromBitmapResource(mRS, mRes, R.drawable.robot, Element.RGB_565(mRS), true);
- mGridImage.uploadToTexture(0);
-
+ mGridImage = Allocation.createFromBitmapResource(mRS, mRes, R.drawable.robot,
+ Allocation.MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
+ Allocation.USAGE_GRAPHICS_TEXTURE);
mScript.set_gTGrid(mGridImage);
}
diff --git a/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java
index 22b3fff..747463a 100644
--- a/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java
+++ b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java
@@ -124,9 +124,9 @@ public class SimpleModelRS {
}
private void loadImage() {
- mGridImage = Allocation.createFromBitmapResource(mRS, mRes, R.drawable.robot, Element.RGB_565(mRS), true);
- mGridImage.uploadToTexture(0);
-
+ mGridImage = Allocation.createFromBitmapResource(mRS, mRes, R.drawable.robot,
+ Allocation.MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
+ Allocation.USAGE_GRAPHICS_TEXTURE);
mScript.set_gTGrid(mGridImage);
}
diff --git a/libs/rs/java/Samples/src/com/android/samples/RsBenchRS.java b/libs/rs/java/Samples/src/com/android/samples/RsBenchRS.java
index 212e7a8..a47c308 100644
--- a/libs/rs/java/Samples/src/com/android/samples/RsBenchRS.java
+++ b/libs/rs/java/Samples/src/com/android/samples/RsBenchRS.java
@@ -23,6 +23,7 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.renderscript.*;
import android.renderscript.Allocation.CubemapLayout;
+import android.renderscript.Allocation.MipmapControl;
import android.renderscript.Program.TextureType;
import android.renderscript.ProgramStore.DepthFunc;
import android.renderscript.Sampler.Value;
@@ -284,17 +285,16 @@ public class RsBenchRS {
}
private Allocation loadTextureRGB(int id) {
- final Allocation allocation = Allocation.createFromBitmapResource(mRS, mRes,
- id, Element.RGB_565(mRS), true);
- allocation.uploadToTexture(0);
- return allocation;
+ return Allocation.createFromBitmapResource(mRS, mRes, id,
+ Allocation.MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
+ Allocation.USAGE_GRAPHICS_TEXTURE);
}
private Allocation loadTextureARGB(int id) {
Bitmap b = BitmapFactory.decodeResource(mRes, id, mOptionsARGB);
- final Allocation allocation = Allocation.createFromBitmap(mRS, b, Element.RGBA_8888(mRS), true);
- allocation.uploadToTexture(0);
- return allocation;
+ return Allocation.createFromBitmap(mRS, b,
+ Allocation.MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
+ Allocation.USAGE_GRAPHICS_TEXTURE);
}
private void loadImages() {
@@ -303,9 +303,8 @@ public class RsBenchRS {
mTexTransparent = loadTextureARGB(R.drawable.leaf);
mTexChecker = loadTextureRGB(R.drawable.checker);
Bitmap b = BitmapFactory.decodeResource(mRes, R.drawable.cubemap_test);
- mTexCube = Allocation.createCubemapFromBitmap(mRS, b, Element.RGB_565(mRS), false,
+ mTexCube = Allocation.createCubemapFromBitmap(mRS, b,
Allocation.CubemapLayout.VERTICAL_FACE_LIST);
- mTexCube.uploadToTexture(0);
mScript.set_gTexTorus(mTexTorus);
mScript.set_gTexOpaque(mTexOpaque);
diff --git a/libs/rs/java/Samples/src/com/android/samples/RsRenderStatesRS.java b/libs/rs/java/Samples/src/com/android/samples/RsRenderStatesRS.java
index 6258c9b..75e8d99 100644
--- a/libs/rs/java/Samples/src/com/android/samples/RsRenderStatesRS.java
+++ b/libs/rs/java/Samples/src/com/android/samples/RsRenderStatesRS.java
@@ -274,17 +274,16 @@ public class RsRenderStatesRS {
}
private Allocation loadTextureRGB(int id) {
- final Allocation allocation = Allocation.createFromBitmapResource(mRS, mRes,
- id, Element.RGB_565(mRS), true);
- allocation.uploadToTexture(0);
- return allocation;
+ return Allocation.createFromBitmapResource(mRS, mRes, id,
+ Allocation.MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
+ Allocation.USAGE_GRAPHICS_TEXTURE);
}
private Allocation loadTextureARGB(int id) {
Bitmap b = BitmapFactory.decodeResource(mRes, id, mOptionsARGB);
- final Allocation allocation = Allocation.createFromBitmap(mRS, b, Element.RGBA_8888(mRS), true);
- allocation.uploadToTexture(0);
- return allocation;
+ return Allocation.createFromBitmap(mRS, b,
+ Allocation.MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
+ Allocation.USAGE_GRAPHICS_TEXTURE);
}
private void loadImages() {
@@ -293,9 +292,8 @@ public class RsRenderStatesRS {
mTexTransparent = loadTextureARGB(R.drawable.leaf);
mTexChecker = loadTextureRGB(R.drawable.checker);
Bitmap b = BitmapFactory.decodeResource(mRes, R.drawable.cubemap_test);
- mTexCube = Allocation.createCubemapFromBitmap(mRS, b, Element.RGB_565(mRS), false,
+ mTexCube = Allocation.createCubemapFromBitmap(mRS, b,
Allocation.CubemapLayout.VERTICAL_FACE_LIST);
- mTexCube.uploadToTexture(0);
mScript.set_gTexTorus(mTexTorus);
mScript.set_gTexOpaque(mTexOpaque);
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp
index 78b570a..cb00223 100644
--- a/libs/rs/rsAllocation.cpp
+++ b/libs/rs/rsAllocation.cpp
@@ -191,13 +191,6 @@ void Allocation::uploadToTexture(const Context *rsc) {
uploadCubeTexture(isFirstUpload);
}
- if (mMipmapControl == RS_ALLOCATION_MIPMAP_ON_SYNC_TO_TEXTURE) {
-#ifndef ANDROID_RS_BUILD_FOR_HOST
- glGenerateMipmap(target);
-#endif //ANDROID_RS_BUILD_FOR_HOST
- }
-
-
if (!(mUsageFlags & RS_ALLOCATION_USAGE_SCRIPT)) {
freeScriptMemory();
}
@@ -227,6 +220,12 @@ void Allocation::upload2DTexture(bool isFirstUpload, const void *ptr) {
format, type, p);
}
}
+
+ if (mMipmapControl == RS_ALLOCATION_MIPMAP_ON_SYNC_TO_TEXTURE) {
+#ifndef ANDROID_RS_BUILD_FOR_HOST
+ glGenerateMipmap(target);
+#endif //ANDROID_RS_BUILD_FOR_HOST
+ }
}
void Allocation::uploadCubeTexture(bool isFirstUpload) {
@@ -266,6 +265,12 @@ void Allocation::uploadCubeTexture(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
+ }
}
void Allocation::deferedUploadToBufferObject(const Context *rsc) {
diff --git a/libs/rs/rsFont.cpp b/libs/rs/rsFont.cpp
index 3f9a9d6..2fa1f0a 100644
--- a/libs/rs/rsFont.cpp
+++ b/libs/rs/rsFont.cpp
@@ -463,7 +463,7 @@ bool FontState::cacheBitmap(FT_Bitmap *bitmap, uint32_t *retOriginX, uint32_t *r
// This will dirty the texture and the shader so next time
// we draw it will upload the data
- mTextTexture->deferedUploadToTexture(mRSC);
+ mTextTexture->syncAll(mRSC, RS_ALLOCATION_USAGE_SCRIPT);
mFontShaderF->bindTexture(mRSC, 0, mTextTexture.get());
// Some debug code
@@ -529,7 +529,7 @@ void FontState::initTextTexture() {
Allocation *cacheAlloc = new Allocation(mRSC, texType, RS_ALLOCATION_USAGE_SCRIPT | RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE);
mTextTexture.set(cacheAlloc);
- mTextTexture->deferedUploadToTexture(mRSC);
+ mTextTexture->syncAll(mRSC, RS_ALLOCATION_USAGE_SCRIPT);
// Split up our cache texture into lines of certain widths
int32_t nextLine = 0;
diff --git a/libs/rs/rsScriptC_LibGL.cpp b/libs/rs/rsScriptC_LibGL.cpp
index 0f84e4b..fb5980a 100644
--- a/libs/rs/rsScriptC_LibGL.cpp
+++ b/libs/rs/rsScriptC_LibGL.cpp
@@ -275,6 +275,18 @@ static void SC_color(float r, float g, float b, float a) {
pf->setConstantColor(rsc, r, g, b, a);
}
+static void SC_allocationSyncAll(RsAllocation va) {
+ CHECK_OBJ(va);
+ GET_TLS();
+ static_cast<Allocation *>(va)->syncAll(rsc, RS_ALLOCATION_USAGE_SCRIPT);
+}
+
+static void SC_allocationSyncAll2(RsAllocation va, RsAllocationUsageType source) {
+ CHECK_OBJ(va);
+ GET_TLS();
+ static_cast<Allocation *>(va)->syncAll(rsc, source);
+}
+
static void SC_uploadToTexture2(RsAllocation va, uint32_t baseMipLevel) {
CHECK_OBJ(va);
GET_TLS();
@@ -425,6 +437,8 @@ static ScriptCState::SymbolTable_t gSyms[] = {
{ "_Z11rsgGetWidthv", (void *)&SC_getWidth, false },
{ "_Z12rsgGetHeightv", (void *)&SC_getHeight, false },
+ { "_Z20rsgAllocationSyncAll13rs_allocation", (void *)&SC_allocationSyncAll, false },
+
{ "_Z18rsgUploadToTexture13rs_allocationj", (void *)&SC_uploadToTexture2, false },
{ "_Z18rsgUploadToTexture13rs_allocation", (void *)&SC_uploadToTexture, false },
{ "_Z23rsgUploadToBufferObject13rs_allocation", (void *)&SC_uploadToBufferObject, false },
diff --git a/libs/rs/scriptc/rs_graphics.rsh b/libs/rs/scriptc/rs_graphics.rsh
index 54e6328..3e708aa 100644
--- a/libs/rs/scriptc/rs_graphics.rsh
+++ b/libs/rs/scriptc/rs_graphics.rsh
@@ -35,6 +35,9 @@ extern uint __attribute__((overloadable))
rsgGetHeight(void);
extern void __attribute__((overloadable))
+ rsgAllocationSyncAll(rs_allocation);
+
+extern void __attribute__((overloadable))
rsgUploadToTexture(rs_allocation);
extern void __attribute__((overloadable))
rsgUploadToTexture(rs_allocation, uint mipLevel);