Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6d8eb266 authored by Jason Sams's avatar Jason Sams
Browse files

Fix mipmap bug introduced with Allocation cleanup.

Add syncAll to rsg headers.

Change-Id: I02c953f3fddab3c6f4e98570cdad45a59711bbde
parent 7dddf275
Loading
Loading
Loading
Loading
+15 −15
Original line number Diff line number Diff line
@@ -452,13 +452,9 @@ public class Allocation extends BaseObj {
        return new Allocation(id, rs, t, usage);
    }

    static public Allocation createFromBitmap(RenderScript rs, Bitmap b,
                                              Element dstFmt, boolean genMips) {
        MipmapControl mc = MipmapControl.MIPMAP_NONE;
        if (genMips) {
            mc = MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE;
        }
        return createFromBitmap(rs, b, mc, USAGE_GRAPHICS_TEXTURE);
    static public Allocation createFromBitmap(RenderScript rs, Bitmap b) {
        return createFromBitmap(rs, b, MipmapControl.MIPMAP_NONE,
                                USAGE_GRAPHICS_TEXTURE);
    }

    static public Allocation createCubemapFromBitmap(RenderScript rs, Bitmap b,
@@ -500,14 +496,9 @@ public class Allocation extends BaseObj {
    }

    static public Allocation createCubemapFromBitmap(RenderScript rs, Bitmap b,
                                                     Element dstFmt,
                                                     boolean genMips,
                                                     CubemapLayout layout) {
        MipmapControl mc = MipmapControl.MIPMAP_NONE;
        if (genMips) {
            mc = MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE;
        }
        return createCubemapFromBitmap(rs, b, mc, layout, USAGE_GRAPHICS_TEXTURE);
        return createCubemapFromBitmap(rs, b, MipmapControl.MIPMAP_NONE,
                                       layout, USAGE_GRAPHICS_TEXTURE);
    }

    static public Allocation createFromBitmapResource(RenderScript rs,
@@ -523,6 +514,15 @@ public class Allocation extends BaseObj {
        return alloc;
    }

    static public Allocation createFromBitmapResource(RenderScript rs,
                                                      Resources res,
                                                      int id) {
        return createFromBitmapResource(rs, res, id,
                                        MipmapControl.MIPMAP_NONE,
                                        USAGE_GRAPHICS_TEXTURE);
    }

/*
    static public Allocation createFromBitmapResource(RenderScript rs,
                                                      Resources res,
                                                      int id,
@@ -534,7 +534,7 @@ public class Allocation extends BaseObj {
        }
        return createFromBitmapResource(rs, res, id, mc, USAGE_GRAPHICS_TEXTURE);
    }

*/
    static public Allocation createFromString(RenderScript rs,
                                              String str,
                                              int usage) {
+3 −3
Original line number Diff line number Diff line
@@ -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);
    }

+3 −3
Original line number Diff line number Diff line
@@ -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);
    }

+8 −9
Original line number Diff line number Diff line
@@ -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);
+7 −9
Original line number Diff line number Diff line
@@ -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);
Loading