diff --git a/libs/rs/java/Fountain/res/raw/fountain.c b/libs/rs/java/Fountain/res/raw/fountain.c index 8a55406aeb779..69195654732a5 100644 --- a/libs/rs/java/Fountain/res/raw/fountain.c +++ b/libs/rs/java/Fountain/res/raw/fountain.c @@ -3,7 +3,7 @@ #pragma version(1) #pragma stateVertex(default) #pragma stateFragment(PgmFragBackground) -#pragma stateFragmentStore(parent) +#pragma stateFragmentStore(PFSReplace) int main(int launchID) { @@ -36,6 +36,7 @@ int main(int launchID) { drawRect(0, 256, 0, 512); contextBindProgramFragment(NAMED_PgmFragParts); + contextBindProgramFragmentStore(NAMED_PFSBlend); if (touch) { newPart = loadI32(2, 0); diff --git a/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java b/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java index 467115a5eea27..745635fb1269a 100644 --- a/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java +++ b/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java @@ -56,6 +56,7 @@ public class FountainRS { private RenderScript.Allocation mVertAlloc; private RenderScript.Script mScript; private RenderScript.ProgramFragmentStore mPFS; + private RenderScript.ProgramFragmentStore mPFS2; private RenderScript.ProgramFragment mPF; private RenderScript.ProgramFragment mPF2; private RenderScript.Allocation mTexture; @@ -79,20 +80,29 @@ public class FountainRS { Bitmap b = bd.getBitmap(); mTexture = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, - true); + false); mTexture.uploadToTexture(0); } mRS.programFragmentStoreBegin(null, null); mRS.programFragmentStoreBlendFunc(RenderScript.BlendSrcFunc.SRC_ALPHA, RenderScript.BlendDstFunc.ONE); mRS.programFragmentStoreDepthFunc(RenderScript.DepthFunc.ALWAYS); + mRS.programFragmentStoreDepthMask(false); + mRS.programFragmentStoreDitherEnable(false); mPFS = mRS.programFragmentStoreCreate(); - mPFS.setName("MyBlend"); - mRS.contextBindProgramFragmentStore(mPFS); + mPFS.setName("PFSBlend"); + + mRS.programFragmentStoreBegin(null, null); + mRS.programFragmentStoreDepthFunc(RenderScript.DepthFunc.ALWAYS); + mRS.programFragmentStoreDepthMask(false); + mRS.programFragmentStoreDitherEnable(false); + mPFS2 = mRS.programFragmentStoreCreate(); + mPFS2.setName("PFSReplace"); + mRS.contextBindProgramFragmentStore(mPFS2); mRS.samplerBegin(); - mRS.samplerSet(RenderScript.SamplerParam.FILTER_MAG, RenderScript.SamplerValue.LINEAR); - mRS.samplerSet(RenderScript.SamplerParam.FILTER_MIN, RenderScript.SamplerValue.LINEAR); + mRS.samplerSet(RenderScript.SamplerParam.FILTER_MAG, RenderScript.SamplerValue.NEAREST); + mRS.samplerSet(RenderScript.SamplerParam.FILTER_MIN, RenderScript.SamplerValue.NEAREST); mSampler = mRS.samplerCreate(); diff --git a/libs/rs/rsType.cpp b/libs/rs/rsType.cpp index 6b9982052d640..5bb4d6095ad5d 100644 --- a/libs/rs/rsType.cpp +++ b/libs/rs/rsType.cpp @@ -94,9 +94,9 @@ void Type::compute() mLODs[lod].mOffset = offset; //LOGE("txyz %i %i %i", tx, ty, tz); offset += tx * rsMax(ty, 1u) * rsMax(tz, 1u) * mElement->getSizeBytes(); - tx >>= 1; - ty >>= 1; - tz >>= 1; + tx = (tx + 1) >> 1; + ty = (ty + 1) >> 1; + tz = (tz + 1) >> 1; } //LOGE("size %i", offset);