EMMS

procedure EMMS;

Description

Calls to blending functions must be followed by EMMS procedure. This restores the state of FPU flags, altered by MMX instructions. When CPU does not support MMX or SSE2 is available, the EMMS function does nothing.

This function must be called after Blend, BlendEx or Combine calls, otherwise CPU will not be able to execute floating point instructions.

If you are using color algebra (such as ColorAdd, ColorMax etc.) that use MMX internally you also have to make sure that EMMS is called.

In case SSE2 is available this function becomes a stub with the smallest possible impact on performance. However, for backward compatibility it is mandatory to always keep a call to this procedure in the code.

A typical example of using blending functions:

try
  for i := X1 to X2 do
  begin
    BlendMem(Clr32, P^); // This function uses MMX
    Inc(P);
  end;
finally
   EMMS; // EMMS is called only once, since there is no FPU code inside the loop
end;

See Also

Blend, BlendEx, ColorAdd, ColorMax, Combine