| /* |
| * Copyright (C) 2014 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. |
| */ |
| |
| // Don't edit this file! It is auto-generated by frameworks/rs/api/gen_runtime. |
| |
| package android.renderscript.cts; |
| |
| import android.renderscript.Allocation; |
| import android.renderscript.RSRuntimeException; |
| import android.renderscript.Element; |
| |
| public class TestMix extends RSBaseCompute { |
| |
| private ScriptC_TestMix script; |
| private ScriptC_TestMixRelaxed scriptRelaxed; |
| |
| @Override |
| protected void setUp() throws Exception { |
| super.setUp(); |
| script = new ScriptC_TestMix(mRS); |
| scriptRelaxed = new ScriptC_TestMixRelaxed(mRS); |
| } |
| |
| public class ArgumentsFloatFloatFloatFloat { |
| public float inStart; |
| public float inStop; |
| public float inAmount; |
| public Target.Floaty out; |
| } |
| |
| private void checkMixFloatFloatFloatFloat() { |
| Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x9f4beff6471d6db1l, false); |
| Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x6ede0b88b4422e8fl, false); |
| Allocation inAmount = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xc1c14e5d52dc3fe5l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE); |
| script.set_gAllocInStop(inStop); |
| script.set_gAllocInAmount(inAmount); |
| script.forEach_testMixFloatFloatFloatFloat(inStart, out); |
| verifyResultsMixFloatFloatFloatFloat(inStart, inStop, inAmount, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloatFloatFloatFloat: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE); |
| scriptRelaxed.set_gAllocInStop(inStop); |
| scriptRelaxed.set_gAllocInAmount(inAmount); |
| scriptRelaxed.forEach_testMixFloatFloatFloatFloat(inStart, out); |
| verifyResultsMixFloatFloatFloatFloat(inStart, inStop, inAmount, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloatFloatFloatFloat: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMixFloatFloatFloatFloat(Allocation inStart, Allocation inStop, Allocation inAmount, Allocation out, boolean relaxed) { |
| float[] arrayInStart = new float[INPUTSIZE * 1]; |
| inStart.copyTo(arrayInStart); |
| float[] arrayInStop = new float[INPUTSIZE * 1]; |
| inStop.copyTo(arrayInStop); |
| float[] arrayInAmount = new float[INPUTSIZE * 1]; |
| inAmount.copyTo(arrayInAmount); |
| float[] arrayOut = new float[INPUTSIZE * 1]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 1 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatFloatFloatFloat args = new ArgumentsFloatFloatFloatFloat(); |
| args.inStart = arrayInStart[i]; |
| args.inStop = arrayInStop[i]; |
| args.inAmount = arrayInAmount[i]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeMix(args, target); |
| // Validate the outputs. |
| boolean valid = true; |
| if (!args.out.couldBe(arrayOut[i * 1 + j])) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inStart: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| args.inStart, Float.floatToRawIntBits(args.inStart), args.inStart)); |
| message.append("\n"); |
| message.append("Input inStop: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| args.inStop, Float.floatToRawIntBits(args.inStop), args.inStop)); |
| message.append("\n"); |
| message.append("Input inAmount: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| args.inAmount, Float.floatToRawIntBits(args.inAmount), args.inAmount)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(args.out.toString()); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j])); |
| if (!args.out.couldBe(arrayOut[i * 1 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMixFloatFloatFloatFloat" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMixFloat2Float2Float2Float2() { |
| Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x45502e8f0a2d9ce9l, false); |
| Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xba2b8a035395e837l, false); |
| Allocation inAmount = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xa477d20616942e4dl, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); |
| script.set_gAllocInStop(inStop); |
| script.set_gAllocInAmount(inAmount); |
| script.forEach_testMixFloat2Float2Float2Float2(inStart, out); |
| verifyResultsMixFloat2Float2Float2Float2(inStart, inStop, inAmount, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloat2Float2Float2Float2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); |
| scriptRelaxed.set_gAllocInStop(inStop); |
| scriptRelaxed.set_gAllocInAmount(inAmount); |
| scriptRelaxed.forEach_testMixFloat2Float2Float2Float2(inStart, out); |
| verifyResultsMixFloat2Float2Float2Float2(inStart, inStop, inAmount, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloat2Float2Float2Float2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMixFloat2Float2Float2Float2(Allocation inStart, Allocation inStop, Allocation inAmount, Allocation out, boolean relaxed) { |
| float[] arrayInStart = new float[INPUTSIZE * 2]; |
| inStart.copyTo(arrayInStart); |
| float[] arrayInStop = new float[INPUTSIZE * 2]; |
| inStop.copyTo(arrayInStop); |
| float[] arrayInAmount = new float[INPUTSIZE * 2]; |
| inAmount.copyTo(arrayInAmount); |
| float[] arrayOut = new float[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatFloatFloatFloat args = new ArgumentsFloatFloatFloatFloat(); |
| args.inStart = arrayInStart[i * 2 + j]; |
| args.inStop = arrayInStop[i * 2 + j]; |
| args.inAmount = arrayInAmount[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeMix(args, target); |
| // Validate the outputs. |
| boolean valid = true; |
| if (!args.out.couldBe(arrayOut[i * 2 + j])) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inStart: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| args.inStart, Float.floatToRawIntBits(args.inStart), args.inStart)); |
| message.append("\n"); |
| message.append("Input inStop: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| args.inStop, Float.floatToRawIntBits(args.inStop), args.inStop)); |
| message.append("\n"); |
| message.append("Input inAmount: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| args.inAmount, Float.floatToRawIntBits(args.inAmount), args.inAmount)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(args.out.toString()); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j])); |
| if (!args.out.couldBe(arrayOut[i * 2 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMixFloat2Float2Float2Float2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMixFloat3Float3Float3Float3() { |
| Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xeb4701726b009c5l, false); |
| Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x9b21f6b3249ee4cbl, false); |
| Allocation inAmount = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x784ed3e2e07c7741l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); |
| script.set_gAllocInStop(inStop); |
| script.set_gAllocInAmount(inAmount); |
| script.forEach_testMixFloat3Float3Float3Float3(inStart, out); |
| verifyResultsMixFloat3Float3Float3Float3(inStart, inStop, inAmount, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloat3Float3Float3Float3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); |
| scriptRelaxed.set_gAllocInStop(inStop); |
| scriptRelaxed.set_gAllocInAmount(inAmount); |
| scriptRelaxed.forEach_testMixFloat3Float3Float3Float3(inStart, out); |
| verifyResultsMixFloat3Float3Float3Float3(inStart, inStop, inAmount, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloat3Float3Float3Float3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMixFloat3Float3Float3Float3(Allocation inStart, Allocation inStop, Allocation inAmount, Allocation out, boolean relaxed) { |
| float[] arrayInStart = new float[INPUTSIZE * 4]; |
| inStart.copyTo(arrayInStart); |
| float[] arrayInStop = new float[INPUTSIZE * 4]; |
| inStop.copyTo(arrayInStop); |
| float[] arrayInAmount = new float[INPUTSIZE * 4]; |
| inAmount.copyTo(arrayInAmount); |
| float[] arrayOut = new float[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatFloatFloatFloat args = new ArgumentsFloatFloatFloatFloat(); |
| args.inStart = arrayInStart[i * 4 + j]; |
| args.inStop = arrayInStop[i * 4 + j]; |
| args.inAmount = arrayInAmount[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeMix(args, target); |
| // Validate the outputs. |
| boolean valid = true; |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inStart: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| args.inStart, Float.floatToRawIntBits(args.inStart), args.inStart)); |
| message.append("\n"); |
| message.append("Input inStop: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| args.inStop, Float.floatToRawIntBits(args.inStop), args.inStop)); |
| message.append("\n"); |
| message.append("Input inAmount: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| args.inAmount, Float.floatToRawIntBits(args.inAmount), args.inAmount)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(args.out.toString()); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j])); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMixFloat3Float3Float3Float3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMixFloat4Float4Float4Float4() { |
| Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd818b19f433276a1l, false); |
| Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x7c186362f5a7e15fl, false); |
| Allocation inAmount = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x4c25d5bfaa64c035l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); |
| script.set_gAllocInStop(inStop); |
| script.set_gAllocInAmount(inAmount); |
| script.forEach_testMixFloat4Float4Float4Float4(inStart, out); |
| verifyResultsMixFloat4Float4Float4Float4(inStart, inStop, inAmount, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloat4Float4Float4Float4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); |
| scriptRelaxed.set_gAllocInStop(inStop); |
| scriptRelaxed.set_gAllocInAmount(inAmount); |
| scriptRelaxed.forEach_testMixFloat4Float4Float4Float4(inStart, out); |
| verifyResultsMixFloat4Float4Float4Float4(inStart, inStop, inAmount, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloat4Float4Float4Float4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMixFloat4Float4Float4Float4(Allocation inStart, Allocation inStop, Allocation inAmount, Allocation out, boolean relaxed) { |
| float[] arrayInStart = new float[INPUTSIZE * 4]; |
| inStart.copyTo(arrayInStart); |
| float[] arrayInStop = new float[INPUTSIZE * 4]; |
| inStop.copyTo(arrayInStop); |
| float[] arrayInAmount = new float[INPUTSIZE * 4]; |
| inAmount.copyTo(arrayInAmount); |
| float[] arrayOut = new float[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatFloatFloatFloat args = new ArgumentsFloatFloatFloatFloat(); |
| args.inStart = arrayInStart[i * 4 + j]; |
| args.inStop = arrayInStop[i * 4 + j]; |
| args.inAmount = arrayInAmount[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeMix(args, target); |
| // Validate the outputs. |
| boolean valid = true; |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inStart: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| args.inStart, Float.floatToRawIntBits(args.inStart), args.inStart)); |
| message.append("\n"); |
| message.append("Input inStop: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| args.inStop, Float.floatToRawIntBits(args.inStop), args.inStop)); |
| message.append("\n"); |
| message.append("Input inAmount: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| args.inAmount, Float.floatToRawIntBits(args.inAmount), args.inAmount)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(args.out.toString()); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j])); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMixFloat4Float4Float4Float4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMixFloat2Float2FloatFloat2() { |
| Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xf811b2d52bd1d7c3l, false); |
| Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x17a127e13c8dd1c5l, false); |
| Allocation inAmount = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xaaf909cdbd2a10ebl, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); |
| script.set_gAllocInStop(inStop); |
| script.set_gAllocInAmount(inAmount); |
| script.forEach_testMixFloat2Float2FloatFloat2(inStart, out); |
| verifyResultsMixFloat2Float2FloatFloat2(inStart, inStop, inAmount, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloat2Float2FloatFloat2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); |
| scriptRelaxed.set_gAllocInStop(inStop); |
| scriptRelaxed.set_gAllocInAmount(inAmount); |
| scriptRelaxed.forEach_testMixFloat2Float2FloatFloat2(inStart, out); |
| verifyResultsMixFloat2Float2FloatFloat2(inStart, inStop, inAmount, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloat2Float2FloatFloat2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMixFloat2Float2FloatFloat2(Allocation inStart, Allocation inStop, Allocation inAmount, Allocation out, boolean relaxed) { |
| float[] arrayInStart = new float[INPUTSIZE * 2]; |
| inStart.copyTo(arrayInStart); |
| float[] arrayInStop = new float[INPUTSIZE * 2]; |
| inStop.copyTo(arrayInStop); |
| float[] arrayInAmount = new float[INPUTSIZE * 1]; |
| inAmount.copyTo(arrayInAmount); |
| float[] arrayOut = new float[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatFloatFloatFloat args = new ArgumentsFloatFloatFloatFloat(); |
| args.inStart = arrayInStart[i * 2 + j]; |
| args.inStop = arrayInStop[i * 2 + j]; |
| args.inAmount = arrayInAmount[i]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeMix(args, target); |
| // Validate the outputs. |
| boolean valid = true; |
| if (!args.out.couldBe(arrayOut[i * 2 + j])) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inStart: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| args.inStart, Float.floatToRawIntBits(args.inStart), args.inStart)); |
| message.append("\n"); |
| message.append("Input inStop: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| args.inStop, Float.floatToRawIntBits(args.inStop), args.inStop)); |
| message.append("\n"); |
| message.append("Input inAmount: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| args.inAmount, Float.floatToRawIntBits(args.inAmount), args.inAmount)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(args.out.toString()); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j])); |
| if (!args.out.couldBe(arrayOut[i * 2 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMixFloat2Float2FloatFloat2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMixFloat3Float3FloatFloat3() { |
| Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xae7aff441b20fa80l, false); |
| Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xe64a4d60d6f4de7cl, false); |
| Allocation inAmount = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x4ea8e06fef74e6aal, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); |
| script.set_gAllocInStop(inStop); |
| script.set_gAllocInAmount(inAmount); |
| script.forEach_testMixFloat3Float3FloatFloat3(inStart, out); |
| verifyResultsMixFloat3Float3FloatFloat3(inStart, inStop, inAmount, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloat3Float3FloatFloat3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); |
| scriptRelaxed.set_gAllocInStop(inStop); |
| scriptRelaxed.set_gAllocInAmount(inAmount); |
| scriptRelaxed.forEach_testMixFloat3Float3FloatFloat3(inStart, out); |
| verifyResultsMixFloat3Float3FloatFloat3(inStart, inStop, inAmount, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloat3Float3FloatFloat3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMixFloat3Float3FloatFloat3(Allocation inStart, Allocation inStop, Allocation inAmount, Allocation out, boolean relaxed) { |
| float[] arrayInStart = new float[INPUTSIZE * 4]; |
| inStart.copyTo(arrayInStart); |
| float[] arrayInStop = new float[INPUTSIZE * 4]; |
| inStop.copyTo(arrayInStop); |
| float[] arrayInAmount = new float[INPUTSIZE * 1]; |
| inAmount.copyTo(arrayInAmount); |
| float[] arrayOut = new float[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatFloatFloatFloat args = new ArgumentsFloatFloatFloatFloat(); |
| args.inStart = arrayInStart[i * 4 + j]; |
| args.inStop = arrayInStop[i * 4 + j]; |
| args.inAmount = arrayInAmount[i]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeMix(args, target); |
| // Validate the outputs. |
| boolean valid = true; |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inStart: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| args.inStart, Float.floatToRawIntBits(args.inStart), args.inStart)); |
| message.append("\n"); |
| message.append("Input inStop: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| args.inStop, Float.floatToRawIntBits(args.inStop), args.inStop)); |
| message.append("\n"); |
| message.append("Input inAmount: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| args.inAmount, Float.floatToRawIntBits(args.inAmount), args.inAmount)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(args.out.toString()); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j])); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMixFloat3Float3FloatFloat3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkMixFloat4Float4FloatFloat4() { |
| Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x64e44bb30a701d3dl, false); |
| Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xb4f372e0715beb33l, false); |
| Allocation inAmount = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xf258b71221bfbc69l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); |
| script.set_gAllocInStop(inStop); |
| script.set_gAllocInAmount(inAmount); |
| script.forEach_testMixFloat4Float4FloatFloat4(inStart, out); |
| verifyResultsMixFloat4Float4FloatFloat4(inStart, inStop, inAmount, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloat4Float4FloatFloat4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); |
| scriptRelaxed.set_gAllocInStop(inStop); |
| scriptRelaxed.set_gAllocInAmount(inAmount); |
| scriptRelaxed.forEach_testMixFloat4Float4FloatFloat4(inStart, out); |
| verifyResultsMixFloat4Float4FloatFloat4(inStart, inStop, inAmount, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloat4Float4FloatFloat4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsMixFloat4Float4FloatFloat4(Allocation inStart, Allocation inStop, Allocation inAmount, Allocation out, boolean relaxed) { |
| float[] arrayInStart = new float[INPUTSIZE * 4]; |
| inStart.copyTo(arrayInStart); |
| float[] arrayInStop = new float[INPUTSIZE * 4]; |
| inStop.copyTo(arrayInStop); |
| float[] arrayInAmount = new float[INPUTSIZE * 1]; |
| inAmount.copyTo(arrayInAmount); |
| float[] arrayOut = new float[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatFloatFloatFloat args = new ArgumentsFloatFloatFloatFloat(); |
| args.inStart = arrayInStart[i * 4 + j]; |
| args.inStop = arrayInStop[i * 4 + j]; |
| args.inAmount = arrayInAmount[i]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeMix(args, target); |
| // Validate the outputs. |
| boolean valid = true; |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inStart: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| args.inStart, Float.floatToRawIntBits(args.inStart), args.inStart)); |
| message.append("\n"); |
| message.append("Input inStop: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| args.inStop, Float.floatToRawIntBits(args.inStop), args.inStop)); |
| message.append("\n"); |
| message.append("Input inAmount: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| args.inAmount, Float.floatToRawIntBits(args.inAmount), args.inAmount)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(args.out.toString()); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%14.8g {%8x} %15a", |
| arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j])); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkMixFloat4Float4FloatFloat4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public void testMix() { |
| checkMixFloatFloatFloatFloat(); |
| checkMixFloat2Float2Float2Float2(); |
| checkMixFloat3Float3Float3Float3(); |
| checkMixFloat4Float4Float4Float4(); |
| checkMixFloat2Float2FloatFloat2(); |
| checkMixFloat3Float3FloatFloat3(); |
| checkMixFloat4Float4FloatFloat4(); |
| } |
| } |