Ejemplo n.º 1
0
/* ------------------------------------------------------------------------- */
void primitives_init_add_opt(
	primitives_t *prims)
{
#ifdef WITH_IPP
	prims->add_16s = (__add_16s_t) ippsAdd_16s;
#elif defined(WITH_SSE2)
	if (IsProcessorFeaturePresent(PF_SSE2_INSTRUCTIONS_AVAILABLE)
			&& IsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE))	/* for LDDQU */
	{
		prims->add_16s = sse3_add_16s;
	}
#endif
}
Ejemplo n.º 2
0
HRESULT CGraphics::UninitializeDisplay(void)
{
	Invalidate();

	SAFERELEASE(m_Device);
	SAFERELEASE(m_Direct3D);

	if(IsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE))
	{
		_aligned_free(m_Levels);
		_aligned_free(m_LevelsBuffer);
		_aligned_free(m_Waveform);
		_aligned_free(m_WaveformBuffer);
	}
	else
	{
		free(m_Levels);
		free(m_LevelsBuffer);
		free(m_Waveform);
		free(m_WaveformBuffer);
	}

	m_Levels = NULL;
	m_LevelsBuffer = NULL;
	m_Waveform = NULL;
	m_WaveformBuffer = NULL;

	m_Hwnd = NULL;

	return S_OK;
}
Ejemplo n.º 3
0
/* ------------------------------------------------------------------------- */
void primitives_init_alphaComp_opt(primitives_t* prims)
{
	generic = primitives_get_generic();
	primitives_init_alphaComp(prims);
#ifdef WITH_IPP
	prims->alphaComp_argb = ipp_alphaComp_argb;
#elif defined(WITH_SSE2)

	if (IsProcessorFeaturePresent(PF_SSE2_INSTRUCTIONS_AVAILABLE)
	    && IsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE))    /* for LDDQU */
	{
		prims->alphaComp_argb = sse2_alphaComp_argb;
	}

#endif
}
Ejemplo n.º 4
0
bool iware::cpu::instruction_set_supported(iware::cpu::instruction_set_t set) {
	std::vector<iware::cpu::instruction_set_t> ises = supported_instruction_sets();
	if (std::find(ises.cbegin(), ises.cend(), set) != ises.cend()) {
		return true;
	}

	// TODO: is this necessary if we detect things with xgetbv and cpuid ?
	// That is, AVX usually needs to have both OS support alongside 
	DWORD feature;
	switch (set) {
	case iware::cpu::instruction_set_t::s3d_now:
		feature = PF_3DNOW_INSTRUCTIONS_AVAILABLE;
		break;
		case iware::cpu::instruction_set_t::mmx:
			feature = PF_MMX_INSTRUCTIONS_AVAILABLE;
			break;
		case iware::cpu::instruction_set_t::sse:
			feature = PF_XMMI_INSTRUCTIONS_AVAILABLE;
			break;
		case iware::cpu::instruction_set_t::sse2:
			feature = PF_XMMI64_INSTRUCTIONS_AVAILABLE;
			break;
		case iware::cpu::instruction_set_t::sse3:
			feature = PF_SSE3_INSTRUCTIONS_AVAILABLE;
			break;
		case iware::cpu::instruction_set_t::avx:
			feature = PF_XMMI64_INSTRUCTIONS_AVAILABLE;
			break;
		default:
			return false;
	}

	return IsProcessorFeaturePresent(feature) != 0;
}
Ejemplo n.º 5
0
/* ========================================================================= */
int test_add16s_func(void)
{
	INT16 ALIGN(src1[FUNC_TEST_SIZE+3]), ALIGN(src2[FUNC_TEST_SIZE+3]), 
		ALIGN(d1[FUNC_TEST_SIZE+3]), ALIGN(d2[FUNC_TEST_SIZE+3]);
	int failed = 0;
#if defined(WITH_SSE2) || defined(WITH_IPP)
	int i;
#endif
	char testStr[256];

	testStr[0] = '\0';
	get_random_data(src1, sizeof(src1));
	get_random_data(src2, sizeof(src2));
	memset(d1, 0, sizeof(d1));
	memset(d2, 0, sizeof(d2));
	general_add_16s(src1+1, src2+1, d1+1, FUNC_TEST_SIZE);
#ifdef WITH_SSE2
	if(IsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE))
	{
		strcat(testStr, " SSE3");
		/* Aligned */
		sse3_add_16s(src1+1, src2+1, d2+1, FUNC_TEST_SIZE);
		for (i=1; i<FUNC_TEST_SIZE; ++i)
		{
			if (d1[i] != d2[i])
			{ 
				printf("ADD16S-SSE-aligned FAIL[%d] %d+%d=%d, got %d\n", 
					i, src1[i], src2[i], d1[i], d2[i]); 
				++failed;
			}
		}
		/* Unaligned */
		sse3_add_16s(src1+1, src2+1, d2+2, FUNC_TEST_SIZE);
		for (i=1; i<FUNC_TEST_SIZE; ++i)
		{
			if (d1[i] != d2[i+1])
			{ 
				printf("ADD16S-SSE-unaligned FAIL[%d] %d+%d=%d, got %d\n", 
					i, src1[i], src2[i], d1[i], d2[i+1]); 
				++failed;
			}
		}
	}
#endif
#ifdef WITH_IPP
	strcat(testStr, " IPP");
	ippsAdd_16s(src1+1, src2+1, d2+1, FUNC_TEST_SIZE);
	for (i=1; i<FUNC_TEST_SIZE; ++i)
	{
		if (d1[i] != d2[i])
		{ 
			printf("ADD16S-IPP FAIL[%d] %d+%d=%d, got %d\n", 
				i, src1[i], src2[i], d1[i], d2[i]); 
			++failed;
		}
	}
#endif /* WITH_IPP */
	if (!failed) printf("All add16s tests passed (%s).\n", testStr);
	return (failed > 0) ? FAILURE : SUCCESS;
}
Ejemplo n.º 6
0
bool SupportsSSE()
{
#if defined(USE_SSE)
    return IsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE) ? true : false;
#else
    return false;
#endif
}
Ejemplo n.º 7
0
HRESULT CGraphics::Update(void)
{
	AUTO_SECTION(m_UpdateSection);

	FLOAT factor = min(GetElapsedTime() * m_Speed,1.0f);

	if(IsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE))
	{
		// Update the levels
		for(UINT i = 0; i < VISUALIZATION_BARCOUNT; i += 4)
		{
			//SSELerpArr(m_Levels + i,m_Levels + i,m_LevelsBuffer + i,factor);

			_mm_store_ps(m_Levels + i,_mm_add_ps(_mm_mul_ps(_mm_sub_ps(_mm_load_ps(m_LevelsBuffer + i),_mm_load_ps(m_Levels + i)),_mm_load_ps1(&factor)),_mm_load_ps(m_Levels + i)));
		}

		// Update the waveform
		for(UINT i = 0; i < SA_BUFFER_SIZE; i += 4)
		{
			//SSELerpArr(m_Waveform + i,m_Waveform + i,m_WaveformBuffer + i,factor);

			_mm_store_ps(m_Waveform + i,_mm_add_ps(_mm_mul_ps(_mm_sub_ps(_mm_load_ps(m_WaveformBuffer + i),_mm_load_ps(m_Waveform + i)),_mm_load_ps1(&factor)),_mm_load_ps(m_Waveform + i)));
		}
	}
	else
	{
		// Update the levels
		for(UINT i = 0; i < VISUALIZATION_BARCOUNT; ++i)
			m_Levels[i] = m_Levels[i] + min(GetElapsedTime() * m_Speed,1.0f) * (m_LevelsBuffer[i] - m_Levels[i]);

		// Update the waveform
		for(UINT i = 0; i < SA_BUFFER_SIZE; ++i)
			m_Waveform[i] = m_Waveform[i] + min(GetElapsedTime() * m_Speed,1.0f) * (m_WaveformBuffer[i] - m_Waveform[i]);
	}
	
	// Go through all the peaks and update each
	for(UINT i = 0; i < VISUALIZATION_BARCOUNT; ++i)
	{
		// Update the position and velocity
		if(m_Peaks[i].timeout <= 0.0f)
		{
			m_Peaks[i].position += m_Peaks[i].velocity * min(GetElapsedTime(),1.0f);
			m_Peaks[i].velocity += m_PeakGravity * min(GetElapsedTime(),1.0f);
		}
		else
			m_Peaks[i].timeout -= min(GetElapsedTime(),1.0f);

		// Check if it has collided with a bar
		if(m_Peaks[i].position < m_Levels[i])
		{
			m_Peaks[i].position = m_Levels[i];
			m_Peaks[i].velocity = 0.0f;
			m_Peaks[i].timeout = m_PeakTimeout;
		}
	}
	
	return S_OK;
}
Ejemplo n.º 8
0
void
AutoSystemInfo::Initialize()
{
    Assert(!initialized);
#ifndef _WIN32
    PAL_InitializeDLL();
    majorVersion = CHAKRA_CORE_MAJOR_VERSION;
    minorVersion = CHAKRA_CORE_MINOR_VERSION;
#endif

    processHandle = GetCurrentProcess();
    GetSystemInfo(this);

    // Make the page size constant so calculation are faster.
    Assert(this->dwPageSize == AutoSystemInfo::PageSize);
#if defined(_M_IX86) || defined(_M_X64)
    get_cpuid(CPUInfo, 1);
    isAtom = CheckForAtom();
#endif
#if defined(_M_ARM32_OR_ARM64)
    armDivAvailable = IsProcessorFeaturePresent(PF_ARM_DIVIDE_INSTRUCTION_AVAILABLE) ? true : false;
#endif
    allocationGranularityPageCount = dwAllocationGranularity / dwPageSize;

    isWindows8OrGreater = IsWindows8OrGreater();

    binaryName[0] = _u('\0');

#if SYSINFO_IMAGE_BASE_AVAILABLE
    dllLoadAddress = (UINT_PTR)&__ImageBase;
    dllHighAddress = (UINT_PTR)&__ImageBase +
        ((PIMAGE_NT_HEADERS)(((char *)&__ImageBase) + __ImageBase.e_lfanew))->OptionalHeader.SizeOfImage;
#endif

    InitPhysicalProcessorCount();
#if DBG
    initialized = true;
#endif

    WCHAR DisableDebugScopeCaptureFlag[MAX_PATH];
    if (::GetEnvironmentVariable(_u("JS_DEBUG_SCOPE"), DisableDebugScopeCaptureFlag, _countof(DisableDebugScopeCaptureFlag)) != 0)
    {
        disableDebugScopeCapture = true;
    }
    else
    {
        disableDebugScopeCapture = false;
    }

    this->shouldQCMoreFrequently = false;
    this->supportsOnlyMultiThreadedCOM = false;
    this->isLowMemoryDevice = false;

    // 0 indicates we haven't retrieved the available commit. We get it lazily.
    this->availableCommit = 0;

    ChakraBinaryAutoSystemInfoInit(this);
}
Ejemplo n.º 9
0
INT_PTR
CALLBACK
ProcessorDlgProc (HWND hDlg, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
    switch (uMessage) {
        case WM_INITDIALOG:
        {
            WCHAR szFeatures[MAX_PATH] = L"";
            WCHAR szModel[3];
            WCHAR szStepping[3];
            WCHAR szCurrentMhz[10];
            BOOL bFirst = TRUE;
            SYSTEM_INFO SystemInfo;
            PROCESSOR_POWER_INFORMATION PowerInfo;

            if (IsProcessorFeaturePresent(PF_MMX_INSTRUCTIONS_AVAILABLE))
                AddFeature(szFeatures, sizeof(szFeatures), L"MMX", &bFirst);
            if (IsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE))
                AddFeature(szFeatures, sizeof(szFeatures), L"SSE", &bFirst);
            if (IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE))
                AddFeature(szFeatures, sizeof(szFeatures), L"SSE2", &bFirst);
            /*if (IsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE))
                AddFeature(szFeatures, sizeof(szFeatures), L"SSE3", &bFirst); */
            if (IsProcessorFeaturePresent(PF_3DNOW_INSTRUCTIONS_AVAILABLE))
                AddFeature(szFeatures, sizeof(szFeatures), L"3DNOW", &bFirst);

            SetDlgItemTextW(hDlg, IDC_FEATURES, szFeatures);

            GetSystemInfo(&SystemInfo);

            StringCbPrintfW(szModel, sizeof(szModel), L"%x", HIBYTE(SystemInfo.wProcessorRevision));
            StringCbPrintfW(szStepping, sizeof(szStepping), L"%d", LOBYTE(SystemInfo.wProcessorRevision));

            SetDlgItemTextW(hDlg, IDC_MODEL, szModel);
            SetDlgItemTextW(hDlg, IDC_STEPPING, szStepping);

            CallNtPowerInformation(11, NULL, 0, &PowerInfo, sizeof(PowerInfo));
            StringCbPrintfW(szCurrentMhz, sizeof(szCurrentMhz), L"%ld %s", PowerInfo.CurrentMhz, L"MHz");
            SetDlgItemTextW(hDlg, IDC_CORESPEED, szCurrentMhz);

            return TRUE;
        }
    }
    return FALSE;
}
Ejemplo n.º 10
0
/* ------------------------------------------------------------------------- */
void primitives_init_shift_opt(primitives_t *prims)
{
#if defined(WITH_IPP)
	prims->lShiftC_16s = (__lShiftC_16s_t) ippsLShiftC_16s;
	prims->rShiftC_16s = (__rShiftC_16s_t) ippsRShiftC_16s;
	prims->lShiftC_16u = (__lShiftC_16u_t) ippsLShiftC_16u;
	prims->rShiftC_16u = (__rShiftC_16u_t) ippsRShiftC_16u;
#elif defined(WITH_SSE2)
	if (IsProcessorFeaturePresent(PF_SSE2_INSTRUCTIONS_AVAILABLE)
			&& IsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE))
	{
		prims->lShiftC_16s = sse2_lShiftC_16s;
		prims->rShiftC_16s = sse2_rShiftC_16s;
		prims->lShiftC_16u = sse2_lShiftC_16u;
		prims->rShiftC_16u = sse2_rShiftC_16u;
	}
#endif
}
Ejemplo n.º 11
0
//------------------------------------------------------------------------------
// Name: has_extension(quint64 ext) const
// Desc:
//------------------------------------------------------------------------------
bool DebuggerCore::has_extension(quint64 ext) const {
#if !defined(EDB_X86_64)
	switch(ext) {
	case edb::string_hash<'M', 'M', 'X'>::value:
		return IsProcessorFeaturePresent(PF_MMX_INSTRUCTIONS_AVAILABLE);
	case edb::string_hash<'X', 'M', 'M'>::value:
		return IsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE);
	default:
		return false;
	}
#else
	switch(ext) {
	case edb::string_hash<'M', 'M', 'X'>::value:
	case edb::string_hash<'X', 'M', 'M'>::value:
		return true;
	default:
		return false;
	}
#endif
}
Ejemplo n.º 12
0
ErrorCode Thread::readCPUState(Architecture::CPUState &state) {
  CONTEXT context;

  std::memset(&context, 0, sizeof(context));
  // TODO(sas): Handle AVX.
  context.ContextFlags = CONTEXT_INTEGER |            // GP registers.
                         CONTEXT_CONTROL |            // Some more GP + cs/ss.
                         CONTEXT_SEGMENTS |           // Data segment selectors.
                         CONTEXT_FLOATING_POINT |     // FP registers.
                         CONTEXT_EXTENDED_REGISTERS | // SSE registers.
                         CONTEXT_DEBUG_REGISTERS;     // Debug registers.

  BOOL result = GetThreadContext(_handle, &context);
  if (!result) {
    return Platform::TranslateError();
  }

  user_to_state32(state, context);

  // x87 state
  state.x87.fstw = context.FloatSave.StatusWord;
  state.x87.fctw = context.FloatSave.ControlWord;
  state.x87.ftag = context.FloatSave.TagWord;
  state.x87.fiseg = context.FloatSave.ErrorSelector;
  state.x87.fioff = context.FloatSave.ErrorOffset;
  state.x87.foseg = context.FloatSave.DataSelector;
  state.x87.fooff = context.FloatSave.DataOffset;
  // TODO(sas): Figure out where this is stored.
  // state.x87.fop = ???;

  uint8_t const *st_space =
      reinterpret_cast<uint8_t const *>(context.FloatSave.RegisterArea);
  for (size_t n = 0; n < 8; n++) {
    static const int reg_size = sizeof(state.x87.regs[0].bytes);
    memcpy(state.x87.regs[n].bytes, st_space + n * reg_size, reg_size);
  }

  // SSE state
  if (IsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE)) {
    // SSE registers are located at offset 160 and MXCSR is at offset 24 in the
    // ExtendedRegisters block.
    uint8_t const *xmm_space =
        reinterpret_cast<uint8_t const *>(context.ExtendedRegisters);

    memcpy(&state.sse.mxcsr, xmm_space + 24, sizeof(state.sse.mxcsr));
    memcpy(&state.sse.mxcsrmask, xmm_space + 28, sizeof(state.sse.mxcsrmask));
    for (size_t n = 0; n < 8; n++) {
      static const int reg_size = sizeof(state.sse.regs[0]);
      memcpy(&state.sse.regs[n], xmm_space + 160 + n * reg_size, reg_size);
    }
  }

  return kSuccess;
}
Ejemplo n.º 13
0
 // Update memcpy function pointers:
 static void __cdecl init_memcpy_functions()
 {
     if (IsProcessorFeaturePresent(PF_ARM_EXTERNAL_CACHE_AVAILABLE))
     {
         /*
          * Set memcpy() to use the integer functions; overriding
          * the defaults, which are the NEON functions.
          */
         __memcpy_forward_large_func = &__memcpy_forward_large_integer;
         __memcpy_reverse_large_func = &__memcpy_reverse_large_integer;
     }
 }
Ejemplo n.º 14
0
/*--------------------------------------------------------------------------*/
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow)
{
    int iExitCode = 0;
    HINSTANCE hinstLib = NULL;
    BOOL fFreeResult = FALSE, fRunTimeLinkSuccess = FALSE;

    if (GetWindowsVersion() == OS_ERROR	)
    {
        MessageBox(NULL, TEXT(MSG_DETECT_UNKNOW), TEXT(MSG_WARNING), MB_ICONWARNING);
        return -1;
    }

    if (GetWindowsVersion() < OS_WIN32_WINDOWS_XP	)
    {
        MessageBox(NULL, TEXT(MSG_DETECT_XP_OR_MORE), TEXT(MSG_WARNING), MB_ICONWARNING);
        return -1;
    }

    /* http://msdn.microsoft.com/en-us/library/ms724482(VS.85).aspx */
    if (!IsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE))
    {
        MessageBox(NULL, TEXT(MSG_DETECT_SSE_OR_MORE), TEXT(MSG_WARNING), MB_ICONWARNING);
        return -1;
    }

    hinstLib = LoadLibrary(TEXT(SCILAB_LIBRARY));
    if (hinstLib != NULL)
    {
        MYPROC1 Windows_Main = NULL;

        /* launch main */
        Windows_Main = (MYPROC1) GetProcAddress(hinstLib, MAIN_FUNCTION);
        if (NULL != Windows_Main)
        {

#ifndef _DEBUG
            /* catch system errors msgbox (release mode only) */
            /* http://msdn.microsoft.com/en-us/library/ms680621(VS.85).aspx */
            UINT LastErrorMode = SetErrorMode( SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT | SEM_NOGPFAULTERRORBOX );
            _try
            {
#endif
                fRunTimeLinkSuccess = TRUE;
                /* launch main */
                iExitCode = (Windows_Main)(hInstance, hPrevInstance, szCmdLine, iCmdShow);

#ifndef _DEBUG
            }
            _except (EXCEPTION_EXECUTE_HANDLER)
            {
            }
#endif
        }
Ejemplo n.º 15
0
/* ========================================================================= */
int test_and_32u_func(void)
{
	UINT32 ALIGN(src[FUNC_TEST_SIZE+3]), ALIGN(dst[FUNC_TEST_SIZE+3]);
	int failed = 0;
	int i;
	char testStr[256];

	testStr[0] = '\0';
	get_random_data(src, sizeof(src));
	general_andC_32u(src+1, VALUE, dst+1, FUNC_TEST_SIZE);
	strcat(testStr, " general");
	for (i=1; i<=FUNC_TEST_SIZE; ++i)
	{
		if (dst[i] != (src[i] & VALUE))
		{ 
			printf("AND-general FAIL[%d] 0x%08x&0x%08x=0x%08x, got 0x%08x\n", 
				i, src[i], VALUE, src[i] & VALUE, dst[i]); 
			++failed;
		}
	}
#ifdef WITH_SSE2
	if (IsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE))
	{
		strcat(testStr, " SSE3");
		/* Aligned */
		memset(dst, 0, sizeof(dst));
		sse3_andC_32u(src+1, VALUE, dst+1, FUNC_TEST_SIZE);
		for (i=1; i<=FUNC_TEST_SIZE; ++i)
		{
			if (dst[i] != (src[i] & VALUE))
			{ 
				printf("AND-SSE-aligned FAIL[%d] 0x%08x&0x%08x=0x%08x, got 0x%08x\n", 
					i, src[i], VALUE, src[i] & VALUE, dst[i]); 
				++failed;
			}
		}
		/* Unaligned */
		memset(dst, 0, sizeof(dst));
		sse3_andC_32u(src+1, VALUE, dst+2, FUNC_TEST_SIZE);
		for (i=1; i<=FUNC_TEST_SIZE; ++i)
		{
			if (dst[i+1] != (src[i] & VALUE))
			{ 
				printf("AND-SSE-unaligned FAIL[%d] 0x%08x&0x%08x=0x%08x, got 0x%08x\n", 
					i, src[i], VALUE, src[i] & VALUE, dst[i+1]); 
				++failed;
			}
		}
	}
#endif /* i386 */
	if (!failed) printf("All and_32u tests passed (%s).\n", testStr);
	return (failed > 0) ? FAILURE : SUCCESS;
}
Ejemplo n.º 16
0
/* ------------------------------------------------------------------------- */
void primitives_init_sign_opt(primitives_t *prims)
{
	/* Pick tuned versions if possible. */
	/* I didn't spot an IPP version of this. */
#if defined(WITH_SSE2)
	if (IsProcessorFeaturePresentEx(PF_EX_SSSE3)
			&& IsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE))
	{
		prims->sign_16s  = ssse3_sign_16s;
	}
#endif
}
Ejemplo n.º 17
0
void __cdecl abort (
        void
        )
{
    _PHNDLR sigabrt_act = SIG_DFL;

#ifdef _DEBUG
    if (__abort_behavior & _WRITE_ABORT_MSG)
    {
        /* write the abort message */
        _NMSG_WRITE(_RT_ABORT);
    }
#endif  /* _DEBUG */


    /* Check if the user installed a handler for SIGABRT.
     * We need to read the user handler atomically in the case
     * another thread is aborting while we change the signal
     * handler.
     */
    sigabrt_act = __get_sigabrt();
    if (sigabrt_act != SIG_DFL)
    {
        raise(SIGABRT);
    }

    /* If there is no user handler for SIGABRT or if the user
     * handler returns, then exit from the program anyway
     */

    if (__abort_behavior & _CALL_REPORTFAULT)
    {
#if defined (_M_ARM) || defined (_CRT_APP)
        __fastfail(FAST_FAIL_FATAL_APP_EXIT);
#else  /* defined (_M_ARM) || defined (_CRT_APP) */
        if (IsProcessorFeaturePresent(PF_FASTFAIL_AVAILABLE))
            __fastfail(FAST_FAIL_FATAL_APP_EXIT);

        _call_reportfault(_CRT_DEBUGGER_ABORT, STATUS_FATAL_APP_EXIT, EXCEPTION_NONCONTINUABLE);
#endif  /* defined (_M_ARM) || defined (_CRT_APP) */
    }


    /* If we don't want to call ReportFault, then we call _exit(3), which is the
     * same as invoking the default handler for SIGABRT
     */


    _exit(3);
}
Ejemplo n.º 18
0
void rfx_init_neon(RFX_CONTEXT * context)
{
	if (IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE))
	{
		DEBUG_RFX("Using NEON optimizations");

		IF_PROFILER(context->priv->prof_rfx_ycbcr_to_rgb->name = "rfx_decode_YCbCr_to_RGB_NEON");
		IF_PROFILER(context->priv->prof_rfx_quantization_decode->name = "rfx_quantization_decode_NEON");
		IF_PROFILER(context->priv->prof_rfx_dwt_2d_decode->name = "rfx_dwt_2d_decode_NEON");

		context->quantization_decode = rfx_quantization_decode_NEON;
		context->dwt_2d_decode = rfx_dwt_2d_decode_NEON;
	}
}
Ejemplo n.º 19
0
void rfx_init_sse2(RFX_CONTEXT* context)
{
	if (!IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE))
		return;

	IF_PROFILER(context->priv->prof_rfx_quantization_decode->name = "rfx_quantization_decode_sse2");
	IF_PROFILER(context->priv->prof_rfx_quantization_encode->name = "rfx_quantization_encode_sse2");
	IF_PROFILER(context->priv->prof_rfx_dwt_2d_decode->name = "rfx_dwt_2d_decode_sse2");
	IF_PROFILER(context->priv->prof_rfx_dwt_2d_encode->name = "rfx_dwt_2d_encode_sse2");

	context->quantization_decode = rfx_quantization_decode_sse2;
	context->quantization_encode = rfx_quantization_encode_sse2;
	context->dwt_2d_decode = rfx_dwt_2d_decode_sse2;
	context->dwt_2d_encode = rfx_dwt_2d_encode_sse2;
}
Ejemplo n.º 20
0
void rfx_init_sse2(RFX_CONTEXT* context)
{

	if (!IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE))
		return;

	printf("\n\nIs this causing crashes???\n\n");
	DEBUG_RFX("Using SSE2 optimizations");

	IF_PROFILER(context->priv->prof_rfx_quantization_decode->name = "rfx_quantization_decode_sse2");
	IF_PROFILER(context->priv->prof_rfx_quantization_encode->name = "rfx_quantization_encode_sse2");
	IF_PROFILER(context->priv->prof_rfx_dwt_2d_decode->name = "rfx_dwt_2d_decode_sse2");
	IF_PROFILER(context->priv->prof_rfx_dwt_2d_encode->name = "rfx_dwt_2d_encode_sse2");

	context->quantization_decode = rfx_quantization_decode_sse2;
	context->quantization_encode = rfx_quantization_encode_sse2;
	context->dwt_2d_decode = rfx_dwt_2d_decode_sse2;
	context->dwt_2d_encode = rfx_dwt_2d_encode_sse2;
}
Ejemplo n.º 21
0
/* ------------------------------------------------------------------------- */
void primitives_init_set_opt(primitives_t* prims)
{
	generic = primitives_get_generic();
	primitives_init_set(prims);
	/* Pick tuned versions if possible. */
#ifdef WITH_IPP
	prims->set_8u  = (__set_8u_t)  ippsSet_8u;
	prims->set_32s = (__set_32s_t) ippsSet_32s;
	prims->set_32u = (__set_32u_t) ipp_wrapper_set_32u;
	prims->zero = (__zero_t) ippsZero_8u;
#elif defined(WITH_SSE2)

	if (IsProcessorFeaturePresent(PF_SSE2_INSTRUCTIONS_AVAILABLE))
	{
		prims->set_8u  = sse2_set_8u;
		prims->set_32s = sse2_set_32s;
		prims->set_32u = sse2_set_32u;
	}

#endif
}
Ejemplo n.º 22
0
void primitives_flags_str(char* str, size_t len)
{
	int i;

	*str = '\0';
	--len;	/* for the '/0' */

	for (i = 0; i < sizeof(flags) / sizeof(flagpair_t); ++i)
	{
		if (IsProcessorFeaturePresent(flags[i].flag))
		{
			int slen = strlen(flags[i].str) + 1;

			if (len < slen)
				break;

			if (*str != '\0')
				strcat(str, " ");

			strcat(str, flags[i].str);
			len -= slen;
		}
	}
	for (i = 0; i < sizeof(flags_extended) / sizeof(flagpair_t); ++i)
	{
		if (IsProcessorFeaturePresentEx(flags_extended[i].flag))
		{
			int slen = strlen(flags_extended[i].str) + 1;

			if (len < slen)
				break;

			if (*str != '\0')
				strcat(str, " ");

			strcat(str, flags_extended[i].str);
			len -= slen;
		}
	}
}
Ejemplo n.º 23
0
static BOOL DS_Init(void)
{
	DSBUFFERDESC soundBufferFormat;
	WAVEFORMATEX pcmwf;
	DSBPOSITIONNOTIFY positionNotifications[2];
	DWORD updateBufferThreadID;

	if (DirectSoundCreate(NULL,&pSoundCard,NULL)!=DS_OK) {
		_mm_errno=MMERR_OPENING_AUDIO;
		return 1;
	}

	if (pSoundCard->lpVtbl->SetCooperativeLevel
				(pSoundCard,GetForegroundWindow(),DSSCL_PRIORITY)!=DS_OK) {
		_mm_errno=MMERR_DS_PRIORITY;
		return 1;
	}

	memset(&soundBufferFormat,0,sizeof(DSBUFFERDESC));
    soundBufferFormat.dwSize       =sizeof(DSBUFFERDESC);
    soundBufferFormat.dwFlags      =DSBCAPS_PRIMARYBUFFER;
    soundBufferFormat.dwBufferBytes=0;
    soundBufferFormat.lpwfxFormat  =NULL;

	if (pSoundCard->lpVtbl->CreateSoundBuffer
				(pSoundCard,&soundBufferFormat,&pPrimarySoundBuffer,NULL)!=DS_OK) {
		_mm_errno=MMERR_DS_BUFFER;
		return 1;
	}

	memset(&pcmwf,0,sizeof(WAVEFORMATEX));
	pcmwf.wFormatTag     =WAVE_FORMAT_PCM;
	pcmwf.nChannels      =(md_mode&DMODE_STEREO)?2:1;
	pcmwf.nSamplesPerSec =md_mixfreq;
	pcmwf.wBitsPerSample =(md_mode&DMODE_16BITS)?16:8;
	pcmwf.nBlockAlign    =(pcmwf.wBitsPerSample * pcmwf.nChannels) / 8;
	pcmwf.nAvgBytesPerSec=pcmwf.nSamplesPerSec*pcmwf.nBlockAlign;

    if (pPrimarySoundBuffer->lpVtbl->SetFormat
				(pPrimarySoundBuffer,&pcmwf)!=DS_OK) {
		_mm_errno=MMERR_DS_FORMAT;
		return 1;
	}
    pPrimarySoundBuffer->lpVtbl->Play(pPrimarySoundBuffer,0,0,DSBPLAY_LOOPING);

	memset(&soundBufferFormat,0,sizeof(DSBUFFERDESC));
    soundBufferFormat.dwSize       =sizeof(DSBUFFERDESC);
    soundBufferFormat.dwFlags      =controlflags|DSBCAPS_GETCURRENTPOSITION2 ;
    soundBufferFormat.dwBufferBytes=fragsize*UPDATES;
    soundBufferFormat.lpwfxFormat  =&pcmwf;
	
	if (pSoundCard->lpVtbl->CreateSoundBuffer
				(pSoundCard,&soundBufferFormat,&pSoundBuffer,NULL)!=DS_OK) {
		_mm_errno=MMERR_DS_BUFFER;
		return 1;
	}

	pSoundBuffer->lpVtbl->QueryInterface
				(pSoundBuffer,&IID_IDirectSoundNotify,(LPVOID*)&pSoundBufferNotify);
	if (!pSoundBufferNotify) {
		_mm_errno=MMERR_DS_NOTIFY;
		return 1;
	}

	notifyUpdateHandle=CreateEvent
				(NULL,FALSE,FALSE,"libmikmod DirectSound Driver positionNotify Event");
	if (!notifyUpdateHandle) {
		_mm_errno=MMERR_DS_EVENT;
		return 1;
	}

	updateBufferHandle=CreateThread
				(NULL,0,updateBufferProc,NULL,CREATE_SUSPENDED,&updateBufferThreadID);
	if (!updateBufferHandle) {
		_mm_errno=MMERR_DS_THREAD;
		return 1;
	}

	memset(positionNotifications,0,2*sizeof(DSBPOSITIONNOTIFY));
	positionNotifications[0].dwOffset    =0;
	positionNotifications[0].hEventNotify=notifyUpdateHandle;
	positionNotifications[1].dwOffset    =fragsize;
	positionNotifications[1].hEventNotify=notifyUpdateHandle;
	if (pSoundBufferNotify->lpVtbl->SetNotificationPositions
				(pSoundBufferNotify,2,positionNotifications) != DS_OK) {
		_mm_errno=MMERR_DS_UPDATE;
		return 1;
	}

	if (IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE))
	{
		md_mode|=DMODE_SIMDMIXER;
	}
	return VC_Init();
}
Ejemplo n.º 24
0
bool Application::GetSysInfo()
{
// ===[ Видео акселератор ]===================================================================================
	glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT,&SysInfo.video.MaxAnisotropy);
	SysInfo.video.RendererName	= (char *)glGetString(GL_RENDERER);					// Выводим имя карты
	LF.Logf("GetSysInfo","Render            %s",SysInfo.video.RendererName);
	SysInfo.video.VendorName	= (char *)glGetString(GL_VENDOR);					// Выводим имя поставщика
	LF.Logf("GetSysInfo","Vendor            %s",SysInfo.video.VendorName);
	SysInfo.video.OpenGL_Version= (char *)glGetString(GL_VERSION);					// Выводим версию
	LF.Logf("GetSysInfo","OpenGL version is %s",SysInfo.video.OpenGL_Version);
	SysInfo.video.SupportedGlExtentions = (char *)glGetString(GL_EXTENSIONS);
	//LF.Msg("Найденые расширения видеокарты"); LF.Msg(SysInfo.video.SupportedGlExtentions);
// ===[ Процессор::реестр ]=======================================================================================
#ifdef WIN32
	HKEY CPinfo;
	FASSERT(!RegOpenKeyEx(HKEY_LOCAL_MACHINE,"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0",NULL,KEY_QUERY_VALUE,&CPinfo));
	DWORD bufsize = sizeof(SysInfo.cpu.speed);
	RegQueryValueEx(CPinfo,"~MHz",NULL,NULL,(LPBYTE)&SysInfo.cpu.speed,&bufsize);
	LF.Logf("GetSysInfo","CPU speed is %d (by M$ Windows)",SysInfo.cpu.speed);
	bufsize = sizeof(SysInfo.cpu.id);
	RegQueryValueEx(CPinfo,"Identifier",NULL,NULL,(LPBYTE)&SysInfo.cpu.id,&bufsize);
	LF.Logf("GetSysInfo","CPU identifier \"%s\"",SysInfo.cpu.id);
	bufsize = sizeof(SysInfo.cpu.name);
	RegQueryValueEx(CPinfo,"ProcessorNameString",NULL,NULL,(LPBYTE)&SysInfo.cpu.name,&bufsize);
	LF.Logf("GetSysInfo","CPU name  \"%s\" ",SysInfo.cpu.name);
	bufsize = sizeof(SysInfo.cpu.vendor_id);
	RegQueryValueEx(CPinfo,"VendorIdentifier",NULL,NULL,(LPBYTE)&SysInfo.cpu.vendor_id,&bufsize);
	LF.Logf("GetSysInfo","Vendor ID \"%s\"",SysInfo.cpu.vendor_id);
	RegCloseKey(CPinfo);
		// Расширения процессора
	char fichi[128];
	sprintf(fichi,"Supported extentions: ");
	SysInfo.cpu.MMX			= (char)IsProcessorFeaturePresent (PF_MMX_INSTRUCTIONS_AVAILABLE)	;
	if (SysInfo.cpu.MMX) strcat(fichi," MMX");
	SysInfo.cpu.AMD_3DNow	= (char)IsProcessorFeaturePresent (PF_3DNOW_INSTRUCTIONS_AVAILABLE)	;
	if (SysInfo.cpu.AMD_3DNow) strcat(fichi," AMD_3DNow");
	SysInfo.cpu.RDTSC		= (char)IsProcessorFeaturePresent (PF_RDTSC_INSTRUCTION_AVAILABLE)	;
	if (SysInfo.cpu.RDTSC) strcat(fichi," RDTSC");
	SysInfo.cpu.SSE			= (char)IsProcessorFeaturePresent (PF_XMMI_INSTRUCTIONS_AVAILABLE)	;
	if (SysInfo.cpu.SSE) strcat(fichi," SSE");
	SysInfo.cpu.SSE2		= (char)IsProcessorFeaturePresent (PF_XMMI64_INSTRUCTIONS_AVAILABLE);
	if (SysInfo.cpu.SSE2) strcat(fichi," SSE2");
	LF.Logf("GetSysInfo","%s",fichi);
#else
// ===[ Процессор::ассемблер ]====================================================================================
	unsigned __int64 ticks;
	ticks = GetCycleCount();
	Sleep (TIME_TO_CALCULATE_CPU_SPEED);
	ticks = GetCycleCount() - ticks;
	SysInfo.cpu.speed = int ((float)ticks /(TIME_TO_CALCULATE_CPU_SPEED * 1000.0f));
	LF.Logf("GetSysInfo","CPU speed is %d (by ASM)",SysInfo.cpu.speed);
	union CPUID_string_union_type{
		char name [16];
		struct{
			DWORD a,b,c,zero;
		};
	}			CPU_name;
	DWORD a,b,c;								// Временные переменные для доставания имени процессора
	memset (&CPU_name,0,sizeof(CPU_name));
	DWORD	CPU_features,						// Возможности процессора 32 бита
			CPU_data_1,							// Данные о прецессоре первые 32 бита
			CPU_data_2;							// Данные о прецессоре вторые 32 бита
	__asm {
		mov EAX, 00000000h						// Имя вендора процессора
		CPUID
		mov a,EBX
		mov b,EDX
		mov c,ECX

		mov EAX, 00000001h
		CPUID
		mov CPU_features,	EDX
		mov CPU_data_1,		EBX
		mov CPU_data_2,		ECX
	};	CPU_name.a = a;	CPU_name.b = b;	CPU_name.c = c;
	LF.Logf("GetSysInfo","CPU_name            %s",CPU_name.name);

#define SOPROCESSOR_ENABLED		0x1			//	00000000000000000000000000000001
#define RDTSC_ENABLED			0x8			//	00000000000000000000000000001000
#define MMX_ENABLED				0x400000	//	00000000010000000000000000000000
#define SSE_ENABLED				0x800000	//	00000000100000000000000000000000
#define SSE2_ENABLED			0x1000000	//	00000001000000000000000000000000
#define AMD_3D_NOW_ENABLED		0x40000000	//	01000000000000000000000000000000
#define AMD_3D_NOW_Ex_ENABLED	0x80000000	//	10000000000000000000000000000000
#pragma warning (disable:4127)
	if (CPU_features & RDTSC_ENABLED)			SysInfo.cpu.RDTSC		= true;
	if (CPU_features & MMX_ENABLED)				SysInfo.cpu.MMX			= true;
	if (CPU_features & SSE_ENABLED)				SysInfo.cpu.SSE			= true;
	if (CPU_features & SSE2_ENABLED)			SysInfo.cpu.SSE2		= true;
	if (CPU_features & AMD_3D_NOW_ENABLED)		SysInfo.cpu.AMD_3DNow	= true;
	if (CPU_features & AMD_3D_NOW_Ex_ENABLED)	SysInfo.cpu.AMD_3DNow_Ex= true;
#pragma warning (default:4127)
	char fichi[128];
	sprintf(fichi,"Supported extentions: ");
	if (SysInfo.cpu.SSE)				strcat(fichi," SSE");
	if (SysInfo.cpu.SSE2)				strcat(fichi," SSE2");
	if (SysInfo.cpu.MMX)				strcat(fichi," MMX");
	if (SysInfo.cpu.AMD_3DNow)			strcat(fichi," AMD_3DNow");
	if (SysInfo.cpu.AMD_3DNow_Ex)		strcat(fichi," AMD_3DNow_Ex");
	if (SysInfo.cpu.RDTSC)				strcat(fichi," RDTSC");
	LF.Logf("GetSysInfo","%s",fichi);
#endif
	//if (!SysInfo.cpu.RDTSC) {MessageBox(NULL,"Your CPU not supported RDTSC instruction\nYou are crazy???","You need new CPU",MB_OK|MB_ICONERROR); ExitProcess(1);}
	return NO_ERROR;
}
Ejemplo n.º 25
0
HRESULT CGraphics::InitializeDisplay(HWND hWnd,UINT width,UINT height,BOOL blur)
{
	// Check if windowed visualization (skin mode not supported)
	if(!hWnd)
		return E_FAIL;

	// Safe to assume that if device is not null display is initialized
	if(m_Device)
		UninitializeDisplay();

	// Get the address of the create function
	if(!m_Direct3DCreate9)
	{
		TRACE(TEXT("Error: Failed to find \"Direct3DCreate9\" in \"%s\".\n"),D3DDLL);
		return E_FAIL;
	}

	// Reset audio data
	if(IsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE))
	{
		TRACE(TEXT("Info: Using SSE instruction set.\n"));

		m_Levels = (PFLOAT)_aligned_malloc(sizeof(FLOAT) * VISUALIZATION_BARCOUNT,16);
		m_LevelsBuffer = (PFLOAT)_aligned_malloc(sizeof(FLOAT) * VISUALIZATION_BARCOUNT,16);
		m_Waveform = (PFLOAT)_aligned_malloc(sizeof(FLOAT) * SA_BUFFER_SIZE,16);
		m_WaveformBuffer = (PFLOAT)_aligned_malloc(sizeof(FLOAT) * SA_BUFFER_SIZE,16);
	}
	else
	{
		m_Levels = (PFLOAT)malloc(sizeof(FLOAT) * VISUALIZATION_BARCOUNT);
		m_LevelsBuffer = (PFLOAT)malloc(sizeof(FLOAT) * VISUALIZATION_BARCOUNT);
		m_Waveform = (PFLOAT)malloc(sizeof(FLOAT) * SA_BUFFER_SIZE);
		m_WaveformBuffer = (PFLOAT)malloc(sizeof(FLOAT) * SA_BUFFER_SIZE);
	}

	ZeroMemory(m_Levels,sizeof(FLOAT) * VISUALIZATION_BARCOUNT);
	ZeroMemory(m_LevelsBuffer,sizeof(FLOAT) * VISUALIZATION_BARCOUNT);
	ZeroMemory(m_Waveform,sizeof(FLOAT) * SA_BUFFER_SIZE);
	ZeroMemory(m_WaveformBuffer,sizeof(FLOAT) * SA_BUFFER_SIZE);
	ZeroMemory(m_Peaks,sizeof(m_Peaks));

	m_Hwnd = hWnd;
	m_Blur = blur;

	m_Direct3D = m_Direct3DCreate9(D3D_SDK_VERSION);
	if(!m_Direct3D)
	{
		TRACE(TEXT("Error: Failed to create direct 3d.\n"));
		return E_FAIL;
	}

	m_Direct3D->GetDeviceCaps(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,&m_Caps);
	m_Direct3D->GetAdapterIdentifier(D3DADAPTER_DEFAULT,NULL,&m_AdapterIdentifier);

	ZeroMemory(&m_PresentParameters,sizeof(m_PresentParameters));
	m_PresentParameters.Windowed					= TRUE;
	m_PresentParameters.SwapEffect					= D3DSWAPEFFECT_DISCARD;
	m_PresentParameters.BackBufferFormat			= D3DFMT_X8R8G8B8;
    //m_PresentParameters.EnableAutoDepthStencil		= TRUE;
	m_PresentParameters.AutoDepthStencilFormat		= D3DFMT_D16;
	m_PresentParameters.PresentationInterval		= D3DPRESENT_INTERVAL_DEFAULT;
	//m_PresentParameters.PresentationInterval		= D3DPRESENT_INTERVAL_IMMEDIATE;
	m_PresentParameters.BackBufferWidth				= width;
	m_PresentParameters.BackBufferHeight			= height;

	//m_PresentParameters.MultiSampleType				= D3DMULTISAMPLE_4_SAMPLES;

	DWORD vp = NULL;

	if(m_Caps.DevCaps & D3DDEVCAPS_PUREDEVICE)
	{
		vp |= D3DCREATE_PUREDEVICE;
		TRACE(TEXT("Info: Using pure device.\n"));
	}
	
	if(m_Caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT)
	{
		vp |= D3DCREATE_HARDWARE_VERTEXPROCESSING;
		TRACE(TEXT("Info: Using hardware vertex processing.\n"));
	}
	else
	{
		vp |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;
		TRACE(TEXT("Info: Using software vertex processing.\n"));
	}

	if(FAILED(m_Direct3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,m_Hwnd,vp|D3DCREATE_MULTITHREADED,&m_PresentParameters,&m_Device)))
	{
		TRACE(TEXT("Error: Failed to create direct 3d device.\n"));
		return E_FAIL;
	}

	if(FAILED(Restore()))
	{
		TRACE(TEXT("Error: Failed to initaly restore device.\n"));
		return E_FAIL;
	}

	return S_OK;
}
Ejemplo n.º 26
0
int TestCPUFeatures(int argc, char* argv[])
{
    printf("Base CPU Flags:\n");
#ifdef _M_IX86_AMD64
    printf("\tPF_MMX_INSTRUCTIONS_AVAILABLE:  %s\n", IsProcessorFeaturePresent(PF_MMX_INSTRUCTIONS_AVAILABLE) ? "yes" : "no");
    printf("\tPF_XMMI_INSTRUCTIONS_AVAILABLE:  %s\n", IsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE) ? "yes" : "no");
    printf("\tPF_XMMI64_INSTRUCTIONS_AVAILABLE:  %s\n", IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE) ? "yes" : "no");
    printf("\tPF_3DNOW_INSTRUCTIONS_AVAILABLE:  %s\n", IsProcessorFeaturePresent(PF_3DNOW_INSTRUCTIONS_AVAILABLE) ? "yes" : "no");
    printf("\tPF_SSE3_INSTRUCTIONS_AVAILABLE:  %s\n", IsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE) ? "yes" : "no");
    printf("\n");
    printf("Extended CPU Flags (not found in windows API):\n");
    printf("\tPF_EX_3DNOW_PREFETCH:  %s\n", IsProcessorFeaturePresentEx(PF_EX_3DNOW_PREFETCH) ? "yes" : "no");
    printf("\tPF_EX_SSSE3:  %s\n", IsProcessorFeaturePresentEx(PF_EX_SSSE3) ? "yes" : "no");
    printf("\tPF_EX_SSE41:  %s\n", IsProcessorFeaturePresentEx(PF_EX_SSE41) ? "yes" : "no");
    printf("\tPF_EX_SSE42:  %s\n", IsProcessorFeaturePresentEx(PF_EX_SSE42) ? "yes" : "no");
    printf("\tPF_EX_AVX:  %s\n", IsProcessorFeaturePresentEx(PF_EX_AVX) ? "yes" : "no");
    printf("\tPF_EX_FMA:  %s\n", IsProcessorFeaturePresentEx(PF_EX_FMA) ? "yes" : "no");
    printf("\tPF_EX_AVX_AES:  %s\n", IsProcessorFeaturePresentEx(PF_EX_AVX_AES) ? "yes" : "no");
#elif defined(_M_ARM)
    printf("\tPF_ARM_NEON_INSTRUCTIONS_AVAILABLE:  %s\n", IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) ? "yes" : "no");
    printf("\tPF_ARM_THUMB:  %s\n", IsProcessorFeaturePresent(PF_ARM_THUMB) ? "yes" : "no");
    printf("\tPF_ARM_VFP_32_REGISTERS_AVAILABLE:  %s\n", IsProcessorFeaturePresent(PF_ARM_VFP_32_REGISTERS_AVAILABLE) ? "yes" : "no");
    printf("\tPF_ARM_DIVIDE_INSTRUCTION_AVAILABLE:  %s\n", IsProcessorFeaturePresent(PF_ARM_DIVIDE_INSTRUCTION_AVAILABLE) ? "yes" : "no");
    printf("\tPF_ARM_VFP3:  %s\n", IsProcessorFeaturePresent(PF_ARM_VFP3) ? "yes" : "no");
    printf("\tPF_ARM_THUMB:  %s\n", IsProcessorFeaturePresent(PF_ARM_THUMB) ? "yes" : "no");
    printf("\tPF_ARM_JAZELLE:  %s\n", IsProcessorFeaturePresent(PF_ARM_JAZELLE) ? "yes" : "no");
    printf("\tPF_ARM_DSP:  %s\n", IsProcessorFeaturePresent(PF_ARM_DSP) ? "yes" : "no");
    printf("\tPF_ARM_THUMB2:  %s\n", IsProcessorFeaturePresent(PF_ARM_THUMB2) ? "yes" : "no");
    printf("\tPF_ARM_T2EE:  %s\n", IsProcessorFeaturePresent(PF_ARM_T2EE) ? "yes" : "no");
    printf("\tPF_ARM_INTEL_WMMX:  %s\n", IsProcessorFeaturePresent(PF_ARM_INTEL_WMMX) ? "yes" : "no");
    printf("Extended CPU Flags (not found in windows API):\n");
    printf("\tPF_EX_ARM_VFP1:  %s\n", IsProcessorFeaturePresentEx(PF_EX_ARM_VFP1) ? "yes" : "no");
    printf("\tPF_EX_ARM_VFP3D16:  %s\n", IsProcessorFeaturePresentEx(PF_EX_ARM_VFP3D16) ? "yes" : "no");
    printf("\tPF_EX_ARM_VFP4:  %s\n", IsProcessorFeaturePresentEx(PF_EX_ARM_VFP4) ? "yes" : "no");
    printf("\tPF_EX_ARM_IDIVA:  %s\n", IsProcessorFeaturePresentEx(PF_EX_ARM_IDIVA) ? "yes" : "no");
    printf("\tPF_EX_ARM_IDIVT:  %s\n", IsProcessorFeaturePresentEx(PF_EX_ARM_IDIVT) ? "yes" : "no");
#endif
    printf("\n");
    return 0;
}
Ejemplo n.º 27
0
static int XAudio2_Init(void) {
	UINT32 flags;
	DWORD thread_id;
	WAVEFORMATEX wfmt;

	memset(&wfmt, 0, sizeof(WAVEFORMATEX));
	wfmt.wFormatTag= (md_mode & DMODE_FLOAT)? WAVE_FORMAT_IEEE_FLOAT : WAVE_FORMAT_PCM;
	wfmt.nChannels = (md_mode & DMODE_STEREO)? 2: 1;
	wfmt.nSamplesPerSec = md_mixfreq;
	wfmt.wBitsPerSample = (md_mode & DMODE_FLOAT)? 32: (md_mode & DMODE_16BITS)? 16: 8;
	wfmt.nBlockAlign = (wfmt.wBitsPerSample * wfmt.nChannels) / 8;
	wfmt.nAvgBytesPerSec = wfmt.nSamplesPerSec * wfmt.nBlockAlign;
	if (wfmt.nSamplesPerSec < XAUDIO2_MIN_SAMPLE_RATE ||
	    wfmt.nSamplesPerSec > XAUDIO2_MAX_SAMPLE_RATE ||
	    wfmt.nChannels > XAUDIO2_MAX_AUDIO_CHANNELS) {
		return 1;
	}

	current_buf = 0;
	flags = 0;
#if defined(_DEBUG) && !defined(DRV_XAUDIO28)
/*	flags |= XAUDIO2_DEBUG_ENGINE;*/
#endif
#ifndef _XBOX
	CoInitializeEx(NULL, COINIT_MULTITHREADED);
#endif
	if (FAILED(XAudio2Create(&pXAudio2, flags, XAUDIO2_DEFAULT_PROCESSOR))) {
		goto fail;
	}
#if defined(DRV_XAUDIO28)
	if (FAILED(IXAudio2_CreateMasteringVoice(pXAudio2, &pMasterVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE,
						 0, NULL, NULL, AudioCategory_Other))) {
		goto fail;
	}
#else
	if (FAILED(IXAudio2_CreateMasteringVoice(pXAudio2, &pMasterVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, 0, NULL))) {
		goto fail;
	}
#endif
	if (FAILED(IXAudio2_CreateSourceVoice(pXAudio2, &pSourceVoice, &wfmt, 0, 1.0f, pcbVoice, NULL, NULL))) {
		goto fail;
	}
#ifndef __cplusplus
	if ((hBufferEvent = CreateEvent(NULL, FALSE, FALSE, "libmikmod XAudio2 Driver buffer Event")) == NULL) {
		goto fail;
	}
#endif
	if ((UpdateBufferHandle = CreateThread(NULL, 0, UpdateBufferProc, NULL, CREATE_SUSPENDED, &thread_id)) == NULL) {
		goto fail;
	}
#if defined HAVE_SSE2
	/* this test only works on Windows XP or later */
	if (IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE)) {
		md_mode|=DMODE_SIMDMIXER;
	}
#endif
	return VC_Init();

fail:
	if (pSourceVoice) {
		IXAudio2SourceVoice_DestroyVoice(pSourceVoice);
		pSourceVoice = NULL;
	}
	if (pMasterVoice) {
		IXAudio2MasteringVoice_DestroyVoice(pMasterVoice);
		pMasterVoice = NULL;
	}
	if (pXAudio2) {
		IXAudio2_Release(pXAudio2);
		pXAudio2 = NULL;
	}
#ifndef _XBOX
	CoUninitialize();
#endif
	return 1;
}
Ejemplo n.º 28
0
/* ------------------------------------------------------------------------- */
int test_set8u_func(void)
{
#if defined(WITH_SSE2) || defined(WITH_IPP)
	BYTE ALIGN(dest[48]);
	int off;
#endif
	int failed = 0;
	char testStr[256];
	testStr[0] = '\0';

#ifdef WITH_SSE2
	/* Test SSE under various alignments */
	if (IsProcessorFeaturePresent(PF_SSE2_INSTRUCTIONS_AVAILABLE))
	{
		strcat(testStr, " SSE2");
		for (off=0; off<16; ++off)
		{
			int len;
			for (len=1; len<48-off; ++len)
			{
				int i;
				memset(dest, 0, sizeof(dest));
				sse2_set_8u(0xa5, dest+off, len);
				for (i=0; i<len; ++i)
				{
					if (dest[off+i] != 0xa5)
					{
						printf("SET8U-SSE FAILED: off=%d len=%d dest[%d]=0x%02x\n",
							off, len, i+off, dest[i+off]);
						failed=1;
					}
				}
			}
		}
	}
#endif /* i386 */

#ifdef WITH_IPP
	/* Test IPP under various alignments */
	strcat(testStr, " IPP");
	for (off=0; off<16; ++off)
	{
		int len;
		for (len=1; len<48-off; ++len)
		{
			int i;
			memset(dest, 0, sizeof(dest));
			ippsSet_8u(0xa5, dest+off, len);
			for (i=0; i<len; ++i)
			{
				if (dest[off+i] != 0xa5)
				{
					printf("SET8U-IPP FAILED: off=%d len=%d dest[%d]=0x%02x\n",
						off, len, i+off, dest[i+off]);
					failed=1;
				}
			}
		}
	}
#endif /* WITH_IPP */

	if (!failed) printf("All set8u tests passed (%s).\n", testStr);
	return (failed > 0) ? FAILURE : SUCCESS;
}
Ejemplo n.º 29
0
int main()
{ 	
	int i = IsProcessorFeaturePresent(PF_VIRT_FIRMWARE_ENABLED);
	printf("VTX Enabled: %s", ( i== 1) ? "true" : "false");
}
Ejemplo n.º 30
0
bool IsSupportedCPU()
{
	return IsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE) != 0;
}