1/* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#include "shared.rsh" 18#include "rs_graphics.rsh" 19rs_sampler minification; 20rs_sampler magnification; 21rs_sampler wrapS; 22rs_sampler wrapT; 23rs_sampler anisotropy; 24 25static bool test_sampler_getters() { 26 bool failed = false; 27 28 _RS_ASSERT(rsSamplerGetMagnification(minification) == RS_SAMPLER_NEAREST); 29 _RS_ASSERT(rsSamplerGetMinification(minification) == RS_SAMPLER_LINEAR_MIP_LINEAR); 30 _RS_ASSERT(rsSamplerGetWrapS(minification) == RS_SAMPLER_CLAMP); 31 _RS_ASSERT(rsSamplerGetWrapT(minification) == RS_SAMPLER_CLAMP); 32 _RS_ASSERT(rsSamplerGetAnisotropy(minification) == 1.0f); 33 34 _RS_ASSERT(rsSamplerGetMagnification(magnification) == RS_SAMPLER_LINEAR); 35 _RS_ASSERT(rsSamplerGetMinification(magnification) == RS_SAMPLER_NEAREST); 36 _RS_ASSERT(rsSamplerGetWrapS(magnification) == RS_SAMPLER_CLAMP); 37 _RS_ASSERT(rsSamplerGetWrapT(magnification) == RS_SAMPLER_CLAMP); 38 _RS_ASSERT(rsSamplerGetAnisotropy(magnification) == 1.0f); 39 40 _RS_ASSERT(rsSamplerGetMagnification(wrapS) == RS_SAMPLER_NEAREST); 41 _RS_ASSERT(rsSamplerGetMinification(wrapS) == RS_SAMPLER_NEAREST); 42 _RS_ASSERT(rsSamplerGetWrapS(wrapS) == RS_SAMPLER_WRAP); 43 _RS_ASSERT(rsSamplerGetWrapT(wrapS) == RS_SAMPLER_CLAMP); 44 _RS_ASSERT(rsSamplerGetAnisotropy(wrapS) == 1.0f); 45 46 _RS_ASSERT(rsSamplerGetMagnification(wrapT) == RS_SAMPLER_NEAREST); 47 _RS_ASSERT(rsSamplerGetMinification(wrapT) == RS_SAMPLER_NEAREST); 48 _RS_ASSERT(rsSamplerGetWrapS(wrapT) == RS_SAMPLER_CLAMP); 49 _RS_ASSERT(rsSamplerGetWrapT(wrapT) == RS_SAMPLER_WRAP); 50 _RS_ASSERT(rsSamplerGetAnisotropy(wrapT) == 1.0f); 51 52 _RS_ASSERT(rsSamplerGetMagnification(anisotropy) == RS_SAMPLER_NEAREST); 53 _RS_ASSERT(rsSamplerGetMinification(anisotropy) == RS_SAMPLER_NEAREST); 54 _RS_ASSERT(rsSamplerGetWrapS(anisotropy) == RS_SAMPLER_CLAMP); 55 _RS_ASSERT(rsSamplerGetWrapT(anisotropy) == RS_SAMPLER_CLAMP); 56 _RS_ASSERT(rsSamplerGetAnisotropy(anisotropy) == 8.0f); 57 58 if (failed) { 59 rsDebug("test_sampler_getters FAILED", 0); 60 } 61 else { 62 rsDebug("test_sampler_getters PASSED", 0); 63 } 64 65 return failed; 66} 67 68void sampler_test() { 69 bool failed = false; 70 failed |= test_sampler_getters(); 71 72 if (failed) { 73 rsSendToClientBlocking(RS_MSG_TEST_FAILED); 74 } 75 else { 76 rsSendToClientBlocking(RS_MSG_TEST_PASSED); 77 } 78} 79 80