зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 3054f69fb5a1 (bug 1123383) for sm cgc failures
This commit is contained in:
Родитель
c9ced9516e
Коммит
36bf5282d7
|
@ -1038,6 +1038,31 @@ Bool(JSContext* cx, unsigned argc, Value* vp)
|
|||
return StoreResult<V>(cx, args, result);
|
||||
}
|
||||
|
||||
template<typename In>
|
||||
static bool
|
||||
Clamp(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
typedef typename In::Elem InElem;
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
if (args.length() != 3 || !IsVectorObject<In>(args[0]) ||
|
||||
!IsVectorObject<In>(args[1]) || !IsVectorObject<In>(args[2]))
|
||||
{
|
||||
return ErrorBadArgs(cx);
|
||||
}
|
||||
|
||||
InElem* val = TypedObjectMemory<InElem*>(args[0]);
|
||||
InElem* lowerLimit = TypedObjectMemory<InElem*>(args[1]);
|
||||
InElem* upperLimit = TypedObjectMemory<InElem*>(args[2]);
|
||||
|
||||
InElem result[In::lanes];
|
||||
for (unsigned i = 0; i < In::lanes; i++) {
|
||||
result[i] = val[i] < lowerLimit[i] ? lowerLimit[i] : val[i];
|
||||
result[i] = result[i] > upperLimit[i] ? upperLimit[i] : result[i];
|
||||
}
|
||||
|
||||
return StoreResult<In>(cx, args, result);
|
||||
}
|
||||
|
||||
template<typename V, typename MaskType>
|
||||
static bool
|
||||
SelectBits(JSContext* cx, unsigned argc, Value* vp)
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
V(xor, (CoercedBinaryFunc<Float32x4, Int32x4, Xor, Float32x4>), 2)
|
||||
|
||||
#define FLOAT32X4_TERNARY_FUNCTION_LIST(V) \
|
||||
V(clamp, Clamp<Float32x4>, 3) \
|
||||
V(replaceLane, (ReplaceLane<Float32x4>), 3) \
|
||||
V(select, (Select<Float32x4, Int32x4>), 3) \
|
||||
V(store, (Store<Float32x4, 4>), 3) \
|
||||
|
@ -113,6 +114,7 @@
|
|||
V(sub, (BinaryFunc<Float64x2, Sub, Float64x2>), 2)
|
||||
|
||||
#define FLOAT64X2_TERNARY_FUNCTION_LIST(V) \
|
||||
V(clamp, Clamp<Float64x2>, 3) \
|
||||
V(replaceLane, (ReplaceLane<Float64x2>), 3) \
|
||||
V(select, (Select<Float64x2, Int32x4>), 3) \
|
||||
V(store, (Store<Float64x2, 2>), 3) \
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
|
||||
var Float32x4 = SIMD.Float32x4;
|
||||
var Float64x2 = SIMD.Float64x2;
|
||||
|
||||
function test() {
|
||||
// FIXME -- Bug 1068028: Amend to check for correctness of NaN/-0 border
|
||||
// cases once the semantics are defined.
|
||||
|
||||
var a = Float32x4(-20, 10, 30, 0.5);
|
||||
var lower = Float32x4(2, 1, 50, 0);
|
||||
var upper = Float32x4(2.5, 5, 55, 1);
|
||||
var c = SIMD.Float32x4.clamp(a, lower, upper);
|
||||
assertEqX4(c, [2, 5, 50, .5])
|
||||
|
||||
var d = Float32x4(-13.37, 10.46, 31.79, 0.54);
|
||||
var lower1 = Float32x4(2.1, 1.1, 50.13, 0.0);
|
||||
var upper1 = Float32x4(2.56, 5.55, 55.93, 1.1);
|
||||
var f = SIMD.Float32x4.clamp(d, lower1, upper1);
|
||||
assertEqX4(f, [2.1, 5.55, 50.13, 0.54].map(Math.fround));
|
||||
|
||||
var g = Float32x4(4, -Infinity, 10, -10);
|
||||
var lower2 = Float32x4(5, -Infinity, -Infinity, -Infinity);
|
||||
var upper2 = Float32x4(Infinity, 5, Infinity, Infinity);
|
||||
var i = SIMD.Float32x4.clamp(g, lower2, upper2);
|
||||
assertEqX4(i, [5, -Infinity, 10, -10].map(Math.fround));
|
||||
|
||||
var j = Float64x2(-20, 10);
|
||||
var k = Float64x2(2.125, 3);
|
||||
var lower3 = Float64x2(2, 1);
|
||||
var upper3 = Float64x2(2.5, 5);
|
||||
var l = Float64x2.clamp(j, lower3, upper3);
|
||||
assertEqX2(l, [2, 5]);
|
||||
var m = Float64x2.clamp(k, lower3, upper3);
|
||||
assertEqX2(m, [2.125, 3]);
|
||||
|
||||
var n = Float64x2(-5, 5);
|
||||
var lower4 = Float64x2(-Infinity, 0);
|
||||
var upper4 = Float64x2(+Infinity, +Infinity);
|
||||
var p = Float64x2.clamp(n, lower4, upper4);
|
||||
assertEqX2(p, [-5, 5]);
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
}
|
||||
|
||||
test();
|
||||
|
Загрузка…
Ссылка в новой задаче