diff options
7 files changed, 138 insertions, 8 deletions
diff --git a/libs/rs/java/Balls/src/com/android/balls/balls.rs b/libs/rs/java/Balls/src/com/android/balls/balls.rs index 9d3f30b822b3..493633b4776b 100644 --- a/libs/rs/java/Balls/src/com/android/balls/balls.rs +++ b/libs/rs/java/Balls/src/com/android/balls/balls.rs @@ -56,16 +56,16 @@ void initParts(int w, int h) int root() { rsgClearColor(0.f, 0.f, 0.f, 1.f); - BallControl_t bc; + BallControl_t bc = {0}; Ball_t *bout; if (frame & 1) { - bc.ain = rsGetAllocation(balls2); - bc.aout = rsGetAllocation(balls1); + rsSetObject(&bc.ain, rsGetAllocation(balls2)); + rsSetObject(&bc.aout, rsGetAllocation(balls1)); bout = balls2; } else { - bc.ain = rsGetAllocation(balls1); - bc.aout = rsGetAllocation(balls2); + rsSetObject(&bc.ain, rsGetAllocation(balls1)); + rsSetObject(&bc.aout, rsGetAllocation(balls2)); bout = balls1; } @@ -99,6 +99,8 @@ int root() { rsgBindProgramStore(gPS); rsgDrawMesh(arcMesh, 0, 0, arcIdx); rsgDrawMesh(partMesh); + rsClearObject(&bc.ain); + rsClearObject(&bc.aout); return 1; } diff --git a/libs/rs/java/ImageProcessing/src/com/android/rs/image/threshold.rs b/libs/rs/java/ImageProcessing/src/com/android/rs/image/threshold.rs index 4f4681052cc5..d05ed6fabc38 100644 --- a/libs/rs/java/ImageProcessing/src/com/android/rs/image/threshold.rs +++ b/libs/rs/java/ImageProcessing/src/com/android/rs/image/threshold.rs @@ -64,7 +64,8 @@ static void computeGaussianWeights() { static void copyInput() { - rs_allocation ain = rsGetAllocation(InPixel); + rs_allocation ain = {0}; + rsSetObject(&ain,rsGetAllocation(InPixel)); uint32_t dimx = rsAllocationGetDimX(ain); uint32_t dimy = rsAllocationGetDimY(ain); for(uint32_t y = 0; y < dimy; y++) { @@ -72,6 +73,7 @@ static void copyInput() { ScratchPixel1[x + y * dimx] = convert_float4(InPixel[x + y * dimx]); } } + rsClearObject(&ain); } void filter() { diff --git a/libs/rs/java/Samples/src/com/android/samples/rslist.rs b/libs/rs/java/Samples/src/com/android/samples/rslist.rs index f760ad0b2ac9..01b37ab0a3a4 100644 --- a/libs/rs/java/Samples/src/com/android/samples/rslist.rs +++ b/libs/rs/java/Samples/src/com/android/samples/rslist.rs @@ -46,7 +46,8 @@ int root(int launchID) { rsgBindFont(gItalic); color(0.2, 0.2, 0.2, 0); - rs_allocation listAlloc = rsGetAllocation(gList); + rs_allocation listAlloc = {0}; + rsSetObject(&listAlloc, rsGetAllocation(gList)); int allocSize = rsAllocationGetDimX(listAlloc); int width = rsgGetWidth(); @@ -66,6 +67,7 @@ int root(int launchID) { } currentYPos += itemHeight; } + rsClearObject(&listAlloc); return 10; } diff --git a/libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java b/libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java index 789fa4decad6..acce88650732 100644 --- a/libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java +++ b/libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java @@ -63,6 +63,7 @@ public class RSTestCore { unitTests.add(new UT_primitives(this, mRes)); unitTests.add(new UT_rsdebug(this, mRes)); + unitTests.add(new UT_rstypes(this, mRes)); unitTests.add(new UT_fp_mad(this, mRes)); /* unitTests.add(new UnitTest(null, "<Pass>", 1)); diff --git a/libs/rs/java/tests/src/com/android/rs/test/UT_rstypes.java b/libs/rs/java/tests/src/com/android/rs/test/UT_rstypes.java new file mode 100644 index 000000000000..55f374684fc8 --- /dev/null +++ b/libs/rs/java/tests/src/com/android/rs/test/UT_rstypes.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.rs.test; + +import android.content.res.Resources; +import android.renderscript.*; + +public class UT_rstypes extends UnitTest { + private Resources mRes; + + protected UT_rstypes(RSTestCore rstc, Resources res) { + super(rstc, "rsTypes"); + mRes = res; + } + + public void run() { + RenderScript pRS = RenderScript.create(); + ScriptC_rstypes s = new ScriptC_rstypes(pRS, mRes, R.raw.rstypes, true); + pRS.mMessageCallback = mRsMessage; + s.invoke_test_rstypes(0, 0); + pRS.finish(); + waitForMessage(); + pRS.destroy(); + } +} + diff --git a/libs/rs/java/tests/src/com/android/rs/test/rslist.rs b/libs/rs/java/tests/src/com/android/rs/test/rslist.rs index b2d06fef5438..d1fde570691d 100644 --- a/libs/rs/java/tests/src/com/android/rs/test/rslist.rs +++ b/libs/rs/java/tests/src/com/android/rs/test/rslist.rs @@ -47,7 +47,8 @@ int root(int launchID) { rsgBindFont(gFont); color(0.2, 0.2, 0.2, 0); - rs_allocation listAlloc = rsGetAllocation(gList); + rs_allocation listAlloc = {0}; + rsSetObject(&listAlloc, rsGetAllocation(gList)); int allocSize = rsAllocationGetDimX(listAlloc); int width = rsgGetWidth(); @@ -102,6 +103,7 @@ int root(int launchID) { } currentYPos += itemHeight; } + rsClearObject(&listAlloc); return 10; } diff --git a/libs/rs/java/tests/src/com/android/rs/test/rstypes.rs b/libs/rs/java/tests/src/com/android/rs/test/rstypes.rs new file mode 100644 index 000000000000..cb0c57761ab1 --- /dev/null +++ b/libs/rs/java/tests/src/com/android/rs/test/rstypes.rs @@ -0,0 +1,81 @@ +#include "shared.rsh" +#include "rs_graphics.rsh" + +#pragma rs export_func(test_rstypes) + +rs_element elementTest; +rs_type typeTest; +rs_allocation allocationTest; +rs_sampler samplerTest; +rs_script scriptTest; +rs_mesh meshTest; +rs_program_fragment program_fragmentTest; +rs_program_vertex program_vertexTest; +rs_program_raster program_rasterTest; +rs_program_store program_storeTest; +rs_font fontTest; + +rs_matrix4x4 matrix4x4Test; +rs_matrix3x3 matrix3x3Test; +rs_matrix2x2 matrix2x2Test; + +struct my_struct { + int i; + rs_font fontTestStruct; +}; + +static bool basic_test(uint32_t index) { + bool failed = false; + + rs_matrix4x4 matrix4x4TestLocal; + rs_matrix3x3 matrix3x3TestLocal; + rs_matrix2x2 matrix2x2TestLocal; + + // This test focuses primarily on compilation-time, not run-time. + rs_element elementTestLocal; + rs_type typeTestLocal; + rs_allocation allocationTestLocal; + rs_sampler samplerTestLocal; + rs_script scriptTestLocal; + rs_mesh meshTestLocal; + rs_program_fragment program_fragmentTestLocal; + rs_program_vertex program_vertexTestLocal; + rs_program_raster program_rasterTestLocal; + rs_program_store program_storeTestLocal; + rs_font fontTestLocal; + + rs_font fontTestLocalArray[4]; + + rs_font fontTestLocalPreInit = fontTest; + + struct my_struct structTest; + + rsSetObject(&fontTestLocal, fontTest); + //allocationTestLocal = allocationTest; + + rsSetObject(&fontTest, fontTestLocal); + //allocationTest = allocationTestLocal; + + /*for (int i = 0; i < 4; i++) { + rsSetObject(&fontTestLocalArray[i], fontTestLocal); + }*/ + + /*rsSetObject(&fontTest, fontTestLocalArray[3]);*/ + + return failed; +} + +void test_rstypes(uint32_t index, int test_num) { + bool failed = false; + failed |= basic_test(index); + + if (failed) { + rsSendToClientBlocking(RS_MSG_TEST_FAILED); + rsDebug("rstypes_test FAILED", -1); + } + else { + rsSendToClientBlocking(RS_MSG_TEST_PASSED); + rsDebug("rstypes_test PASSED", 0); + } +} + |