Exportar (0) Imprimir
Expandir todo
Expandir Minimizar

_mm_blendv_ps

Microsoft Specific

Emits the Streaming SIMD Extensions 4 (SSE4) instruction blendvps. This function blends packed single precision floating point values.

__m128 _mm_blendv_ps( 
   __m128 a,
   __m128 b,
   __m128 mask 
);

[in] a

A 128-bit parameter that contains four 32-bit floating point values to be blended.

[in] b

A 128-bit parameter that contains four 32-bit floating point values to be blended.

[in] mask

A 128-bit mask that selects components for the blend operation.

r0 := (mask0 & 0x80000000) ? b0 : a0
r1 := (mask1 & 0x80000000) ? b1 : a1
r2 := (mask2 & 0x80000000) ? b2 : a2
r3 := (mask3 & 0x80000000) ? b3 : a3

Intrinsic

Architecture

_mm_blendv_ps

x86, x64

Header file <smmintrin.h>

The return value r and parameters a, b, and mask each consist of 128 bits. r0-r3, a0-a3, b0-b3, and mask0-mask3 are the sequentially ordered 32-bit components of these parameters, where r0, a0, b0, and mask0 indicate the least significant 32 bits.

Before using this intrinsic, software must ensure that the processor supports the instruction.

#include <stdio.h>
#include <smmintrin.h>

int main () {
    __m128 a, b, mask;
    unsigned __int64 maskValue[4];

    maskValue[3] = 0x80000000;
    maskValue[2] = 0x80000000;
    maskValue[1] = 0x00000000;
    maskValue[0] = 0x00000000;

    mask.m128_f32[3] = *reinterpret_cast<float *>(&maskValue[3]);
    mask.m128_f32[2] = *reinterpret_cast<float *>(&maskValue[2]);
    mask.m128_f32[1] = *reinterpret_cast<float *>(&maskValue[1]);
    mask.m128_f32[0] = *reinterpret_cast<float *>(&maskValue[0]);

    a.m128_f32[3] = -10.25;
    a.m128_f32[2] = -20;
    a.m128_f32[1] = -900;
    a.m128_f32[0] = -32786;
    b.m128_f32[3] = 36;
    b.m128_f32[2] = 0;
    b.m128_f32[1] = 3.25;
    b.m128_f32[0] = 78.75;

    __m128 res = _mm_blendv_ps( a, b, mask );

    printf_s("Original a: %14f %14f %14f %14f\nOriginal b: %14f %14f %14f %14f\n",
                a.m128_f32[3], a.m128_f32[2], a.m128_f32[1], a.m128_f32[0],
                b.m128_f32[3], b.m128_f32[2], b.m128_f32[1], b.m128_f32[0]);

    printf_s("Result res: %14f %14f %14f %14f\n",
                res.m128_f32[3], res.m128_f32[2], res.m128_f32[1], res.m128_f32[0]);

    return 0;
}
Original a:     -10.250000     -20.000000    -900.000000  -32786.000000
Original b:      36.000000       0.000000       3.250000      78.750000
Result res:      36.000000       0.000000    -900.000000  -32786.000000

Adiciones de comunidad

AGREGAR
Mostrar:
© 2014 Microsoft