summaryrefslogtreecommitdiff
path: root/libs/rs
diff options
context:
space:
mode:
Diffstat (limited to 'libs/rs')
-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 f61cf250c21a..6cb50b8122fd 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 22b3fff024fe..747463a051d6 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 212e7a80a5b5..a47c308a8c93 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 6258c9b3da54..75e8d998d60f 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 78b570a02f8b..cb0022377bc5 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 3f9a9d6675ed..2fa1f0aabf9f 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 0f84e4bb87b3..fb5980affa27 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 54e63283cbb7..3e708aae5618 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);