// ======================================================================== // // Copyright 2009-2014 Intel Corporation // // // // 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. // // ======================================================================== // #pragma once struct Vec4f { float x; float y; float z; float w; }; //////////////////////////////////////////////////////////////////////////////// /// Constructors //////////////////////////////////////////////////////////////////////////////// inline uniform Vec4f make_Vec4f(const uniform float a) { uniform Vec4f v; v.x = a; v.y = a; v.z = a; v.w = a; return v; } inline varying Vec4f make_Vec4f(const varying float a) { varying Vec4f v; v.x = a; v.y = a; v.z = a; v.w = a; return v; } inline uniform Vec4f make_Vec4f(const uniform float x, const uniform float y, const uniform float z, const uniform float w) { uniform Vec4f v; v.x = x; v.y = y; v.z = z; v.w = w; return v; } inline varying Vec4f make_Vec4f(const varying float x, const varying float y, const varying float z, const varying float w) { varying Vec4f v; v.x = x; v.y = y; v.z = z; v.w = w; return v; } inline uniform Vec4f make_Vec4f(const uniform Vec3f a) { uniform Vec4f v; v.x = a.x; v.y = a.y; v.z = a.z; v.w = 0.f; return v; } inline varying Vec4f make_Vec4f(const varying Vec3f a) { varying Vec4f v; v.x = a.x; v.y = a.y; v.z = a.z; v.w = 0.f; return v; } inline uniform Vec3f make_Vec3f(const uniform Vec4f a) { uniform Vec3f v; v.x = a.x; v.y = a.y; v.z = a.z; return v; } inline varying Vec3f make_Vec3f(const varying Vec4f a) { varying Vec3f v; v.x = a.x; v.y = a.y; v.z = a.z; return v; } //////////////////////////////////////////////////////////////////////////////// /// Unary Operators //////////////////////////////////////////////////////////////////////////////// inline uniform Vec4f operator-(const uniform Vec4f a) { return make_Vec4f(-a.x,-a.y,-a.z,-a.w); } inline varying Vec4f operator-(const varying Vec4f a) { return make_Vec4f(-a.x,-a.y,-a.z,-a.w); } inline uniform Vec4f neg(const uniform Vec4f a) { return make_Vec4f(-a.x,-a.y,-a.z,-a.w); } inline varying Vec4f neg(const varying Vec4f a) { return make_Vec4f(-a.x,-a.y,-a.z,-a.w); } inline uniform Vec4f abs(const uniform Vec4f a) { return make_Vec4f(abs(a.x),abs(a.y),abs(a.z),abs(a.w)); } inline varying Vec4f abs(const varying Vec4f a) { return make_Vec4f(abs(a.x),abs(a.y),abs(a.z),abs(a.w)); } inline uniform Vec4f rcp(const uniform Vec4f a) { return make_Vec4f(rcp(a.x),rcp(a.y),rcp(a.z),rcp(a.w)); } inline varying Vec4f rcp(const varying Vec4f a) { return make_Vec4f(rcp(a.x),rcp(a.y),rcp(a.z),rcp(a.w)); } //////////////////////////////////////////////////////////////////////////////// /// Binary Operators //////////////////////////////////////////////////////////////////////////////// inline uniform Vec4f operator+(const uniform Vec4f a, const uniform Vec4f b) { uniform Vec4f v; v.x = a.x+b.x; v.y = a.y+b.y; v.z = a.z+b.z; v.w = a.w+b.w; return v; } inline varying Vec4f operator+(const varying Vec4f a, const varying Vec4f b) { varying Vec4f v; v.x = a.x+b.x; v.y = a.y+b.y; v.z = a.z+b.z; v.w = a.w+b.w; return v; } inline uniform Vec4f operator*(const uniform float a, const uniform Vec4f b) { uniform Vec4f v; v.x = a*b.x; v.y = a*b.y; v.z = a*b.z; v.w = a*b.w; return v; } inline varying Vec4f operator*(const varying float a, const varying Vec4f b) { varying Vec4f v; v.x = a*b.x; v.y = a*b.y; v.z = a*b.z; v.w = a*b.w; return v; } inline uniform Vec4f operator*(const uniform Vec4f a, const uniform float b) { uniform Vec4f v; v.x = a.x*b; v.y = a.y*b; v.z = a.z*b; v.w = a.w*b; return v; } inline varying Vec4f operator*(const varying Vec4f a, const varying float b) { varying Vec4f v; v.x = a.x*b; v.y = a.y*b; v.z = a.z*b; v.w = a.w*b; return v; } inline uniform Vec4f operator*(const uniform Vec4f a, const uniform Vec4f b) { uniform Vec4f v; v.x = a.x*b.x; v.y = a.y*b.y; v.z = a.z*b.z; v.w = a.w*b.w; return v; } inline varying Vec4f operator*(const varying Vec4f a, const varying Vec4f b) { varying Vec4f v; v.x = a.x*b.x; v.y = a.y*b.y; v.z = a.z*b.z; v.w = a.w*b.w; return v; }