Y
Y
Yudzhin_NSK2020-05-25 18:03:49
C++ / C#
Yudzhin_NSK, 2020-05-25 18:03:49

How to write from register to pointer?

I need to get rid of memcpy and MUint64 variable and write directly from register to pixDstWrite variable.
Can it be done at all?

here is the code:

void Mix::colorMixFast2(
                        MUint32 *pixDstWrite,
                        const MUint32 valSrcA, const MUint32 valDstA,
                        const MUint32 valSrcB, const MUint32 valDstB,
                        const int colorRatio256, const int colorRat256Neg
                      )
{
  // TODO: write __asm code here with 2 pixels blending simultaneously
    
    MUint64 a;
    __asm {
        movd xmm0, valSrcA
        movd xmm3, valDstA
        movd xmm1, valSrcB
        movd xmm4, valDstB

        pmovzxbw xmm0, xmm0
        pmovzxbw xmm3, xmm3
        pmovzxbw xmm1, xmm1
        pmovzxbw xmm4, xmm4

        pslldq xmm0, 8
        pslldq xmm3, 8

        paddd xmm0, xmm1
        paddd xmm3, xmm4

        vpbroadcastw xmm2, colorRat256Neg
        vpbroadcastw xmm5, colorRatio256

        pmullw xmm0, xmm2
        pmullw xmm3, xmm5

        paddd xmm0, xmm3
        psrlw xmm0, 8
        packuswb xmm0, xmm1
        movd a, xmm0
    }
    memcpy(pixDstWrite, &a, sizeof(MUint64));
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question