Commit 9842d74f authored by Sam Lantinga's avatar Sam Lantinga

Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40740
parent ccba9fd0
......@@ -3,6 +3,9 @@ This is a list of API changes in SDL's version history.
Version 1.0:
1.2.7:
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE()
1.2.6:
Added SDL_LoadObject(), SDL_LoadFunction(), and SDL_UnloadObject()
......
......@@ -503,6 +503,7 @@ CheckNASM()
CFLAGS="$CFLAGS -I\$(top_srcdir)/src/hermes"
SDL_EXTRADIRS="$SDL_EXTRADIRS hermes"
SDL_EXTRALIBS="$SDL_EXTRALIBS hermes/libhermes.la"
use_nasm=yes
fi
fi
}
......@@ -2569,6 +2570,7 @@ AM_CONDITIONAL(TARGET_MINT, test $ARCH = mint)
# More automake conditionals
AM_CONDITIONAL(USE_DIRECTX, test x$use_directx = xyes)
AM_CONDITIONAL(USE_CLONE, test x$use_clone = xyes)
AM_CONDITIONAL(HAVE_NASM, test x$use_nasm = xyes)
# Set conditional variables for shared and static library selection.
# These are not used in any Makefile.am but in sdl-config.in.
......@@ -2774,6 +2776,7 @@ src/thread/Makefile
src/timer/Makefile
src/endian/Makefile
src/file/Makefile
src/cpuinfo/Makefile
src/hermes/Makefile
sdl-config
SDL.spec
......
......@@ -11,6 +11,7 @@ libSDLinclude_HEADERS = \
SDL_byteorder.h \
SDL_cdrom.h \
SDL_copying.h \
SDL_cpuinfo.h \
SDL_endian.h \
SDL_error.h \
SDL_events.h \
......
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* CPU feature detection for SDL */
#ifndef _SDL_cpuinfo_h
#define _SDL_cpuinfo_h
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
/* This function returns true if the CPU has MMX features
*/
extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX();
/* This function returns true if the CPU has 3DNow features
*/
extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow();
/* This function returns true if the CPU has SSE features
*/
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE();
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif /* _SDL_cpuinfo_h */
......@@ -34,28 +34,13 @@ static char rcsid =
#include "SDL_audio.h"
#include "SDL_mutex.h"
#include "SDL_timer.h"
#include "SDL_cpuinfo.h"
#include "SDL_sysaudio.h"
#include "SDL_cpuinfo.h"
#include "SDL_mixer_MMX.h"
#include "SDL_mixer_MMX_VC.h"
#include "SDL_mixer_m68k.h"
/* Function to check the CPU flags */
#define MMX_CPU 0x800000
#ifdef USE_ASMBLIT
#define CPU_Flags() Hermes_X86_CPU()
#else
#define CPU_Flags() 0L
#endif
#ifdef USE_ASMBLIT
#define X86_ASSEMBLER
#define HermesConverterInterface void
#define HermesClearInterface void
#define STACKCALL
#include "HeadX86.h"
#endif
/* This table is used to add two sound values together and pin
* the value to avoid overflow. (used with permission from ARDI)
* Changed to use 0xFE instead of 0xFF for better sound quality.
......@@ -154,7 +139,7 @@ void SDL_MixAudio (Uint8 *dst, const Uint8 *src, Uint32 len, int volume)
case AUDIO_S8: {
#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
if (CPU_Flags() & MMX_CPU)
if (SDL_HasMMX())
{
SDL_MixAudio_MMX_S8((char*)dst,(char*)src,(unsigned int)len,(int)volume);
}
......@@ -201,7 +186,7 @@ void SDL_MixAudio (Uint8 *dst, const Uint8 *src, Uint32 len, int volume)
case AUDIO_S16LSB: {
#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
if (CPU_Flags() & MMX_CPU)
if (SDL_HasMMX())
{
SDL_MixAudio_MMX_S16((char*)dst,(char*)src,(unsigned int)len,(int)volume);
}
......
This diff is collapsed.
###########################################################################
#
# Some consistent rules for building asm files:
STRIP_FPIC = sh $(top_srcdir)/strip_fPIC.sh
SUFFIXES = .asm
.asm.lo:
$(LIBTOOL) --tag=CC --mode=compile $(STRIP_FPIC) $(NASM) -t -D __FLAT__ -D __NOU__ @NASMFLAGS@ $< -o $*.o
###########################################################################
# The cpuinfo library target
noinst_LTLIBRARIES = libcpuinfo.la
if HAVE_NASM
ARCH_SRCS = \
gcpuinfo.c \
_cpuinfo.asm \
_pcihelp.asm
else
ARCH_SRCS =
endif
COMMON_SRCS = \
SDL_cpuinfo.c
libcpuinfo_la_SOURCES = $(ARCH_SRCS) $(COMMON_SRCS)
EXTRA_DIST = \
COPYING.LIB \
README
This is a stripped down version of the portable CPU detection code included
in the SciTech SNAP Graphics SDK. It is redistributed under the LGPL license,
which can be found in COPYING.LIB.
You can visit SciTech Software Inc. at: http://www.scitechsoft.com/
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/* CPU feature detection for SDL */
#include "SDL.h"
//#include "SDL_cpuinfo.h"
#define CPU_HAS_MMX 0x00000001
#define CPU_HAS_3DNOW 0x00000002
#define CPU_HAS_SSE 0x00000004
/* These functions come from SciTech's PM library */
extern int CPU_haveMMX();
extern int CPU_have3DNow();
extern int CPU_haveSSE();
static Uint32 SDL_CPUFeatures = 0xFFFFFFFF;
static Uint32 SDL_GetCPUFeatures()
{
if ( SDL_CPUFeatures == 0xFFFFFFFF ) {
SDL_CPUFeatures = 0;
if ( CPU_haveMMX() ) {
SDL_CPUFeatures |= CPU_HAS_MMX;
}
if ( CPU_have3DNow() ) {
SDL_CPUFeatures |= CPU_HAS_3DNOW;
}
if ( CPU_haveSSE() ) {
SDL_CPUFeatures |= CPU_HAS_SSE;
}
}
return SDL_CPUFeatures;
}
SDL_bool SDL_HasMMX()
{
if ( SDL_GetCPUFeatures() & CPU_HAS_MMX ) {
return SDL_TRUE;
}
return SDL_FALSE;
}
SDL_bool SDL_Has3DNow()
{
if ( SDL_GetCPUFeatures() & CPU_HAS_3DNOW ) {
return SDL_TRUE;
}
return SDL_FALSE;
}
SDL_bool SDL_HasSSE()
{
if ( SDL_GetCPUFeatures() & CPU_HAS_SSE ) {
return SDL_TRUE;
}
return SDL_FALSE;
}
#ifdef TEST_MAIN
#include <stdio.h>
int main()
{
printf("MMX: %d\n", SDL_HasMMX());
printf("3DNow: %d\n", SDL_Has3DNow());
printf("SSE: %d\n", SDL_HasSSE());
}
#endif /* TEST_MAIN */
This diff is collapsed.
;****************************************************************************
;*
;* SciTech OS Portability Manager Library
;*
;* ========================================================================
;*
;* Copyright (C) 1991-2002 SciTech Software, Inc. All rights reserved.
;*
;* This file may be distributed and/or modified under the terms of the
;* GNU Lesser General Public License version 2.1 as published by the Free
;* Software Foundation and appearing in the file LICENSE.LGPL included
;* in the packaging of this file.
;*
;* Licensees holding a valid Commercial License for this product from
;* SciTech Software, Inc. may use this file in accordance with the
;* Commercial License Agreement provided with the Software.
;*
;* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
;* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
;* PURPOSE.
;*
;* See http://www.scitechsoft.com/license/ for information about
;* the licensing options available and how to purchase a Commercial
;* License Agreement.
;*
;* Contact license@scitechsoft.com if any conditions of this licensing
;* are not clear to you, or you have questions about licensing options.
;*
;* ========================================================================
;*
;* Language: NASM
;* Environment: Any
;*
;* Description: Helper assembler functions for PCI access module.
;*
;****************************************************************************
include "scitech.mac" ; Memory model macros
header _pcilib
begcodeseg _pcilib
ifdef flatmodel
;----------------------------------------------------------------------------
; uchar _ASMAPI _BIOS32_service(
; ulong service,
; ulong func,
; ulong *physBase,
; ulong *length,
; ulong *serviceOffset,
; PCIBIOS_entry entry);
;----------------------------------------------------------------------------
; Call the BIOS32 services directory
;----------------------------------------------------------------------------
cprocstart _BIOS32_service
ARG service:ULONG, func:ULONG, physBase:DPTR, len:DPTR, off:DPTR, entry:QWORD
enter_c
mov eax,[service]
mov ebx,[func]
call far dword [entry]
mov esi,[physBase]
mov [esi],ebx
mov esi,[len]
mov [esi],ecx
mov esi,[off]
mov [esi],edx
leave_c
ret
cprocend
endif
;----------------------------------------------------------------------------
; ushort _ASMAPI _PCIBIOS_isPresent(ulong i_eax,ulong *o_edx,ushort *oeax,
; uchar *o_cl,PCIBIOS_entry entry)
;----------------------------------------------------------------------------
; Call the PCI BIOS to determine if it is present.
;----------------------------------------------------------------------------
cprocstart _PCIBIOS_isPresent
ARG i_eax:ULONG, o_edx:DPTR, oeax:DPTR, o_cl:DPTR, entry:QWORD
enter_c
mov eax,[i_eax]
ifdef flatmodel
call far dword [entry]
else
int 1Ah
endif
_les _si,[o_edx]
mov [_ES _si],edx
_les _si,[oeax]
mov [_ES _si],ax
_les _si,[o_cl]
mov [_ES _si],cl
mov ax,bx
leave_c
ret
cprocend
;----------------------------------------------------------------------------
; ulong _PCIBIOS_service(ulong r_eax,ulong r_ebx,ulong r_edi,ulong r_ecx,
; PCIBIOS_entry entry)
;----------------------------------------------------------------------------
; Call the PCI BIOS services, either via the 32-bit protected mode entry
; point or via the Int 1Ah 16-bit interrupt.
;----------------------------------------------------------------------------
cprocstart _PCIBIOS_service
ARG r_eax:ULONG, r_ebx:ULONG, r_edi:ULONG, r_ecx:ULONG, entry:QWORD
enter_c
mov eax,[r_eax]
mov ebx,[r_ebx]
mov edi,[r_edi]
mov ecx,[r_ecx]
ifdef flatmodel
call far dword [entry]
else
int 1Ah
endif
mov eax,ecx
ifndef flatmodel
shld edx,eax,16 ; Return result in DX:AX
endif
leave_c
ret
cprocend
;----------------------------------------------------------------------------
; int _PCIBIOS_getRouting(PCIRoutingOptionsBuffer *buf,PCIBIOS_entry entry);
;----------------------------------------------------------------------------
; Get the routing options for PCI devices
;----------------------------------------------------------------------------
cprocstart _PCIBIOS_getRouting
ARG buf:DPTR, entry:QWORD
enter_c
mov eax,0B10Eh
mov bx,0
_les _di,[buf]
ifdef flatmodel
call far dword [entry]
else
int 1Ah
endif
movzx eax,ah
leave_c
ret
cprocend
;----------------------------------------------------------------------------
; ibool _PCIBIOS_setIRQ(int busDev,int intPin,int IRQ,PCIBIOS_entry entry);
;----------------------------------------------------------------------------
; Change the IRQ routing for the PCI device
;----------------------------------------------------------------------------
cprocstart _PCIBIOS_setIRQ
ARG busDev:UINT, intPin:UINT, IRQ:UINT, entry:QWORD
enter_c
mov eax,0B10Fh
mov bx,[USHORT busDev]
mov cl,[BYTE intPin]
mov ch,[BYTE IRQ]
ifdef flatmodel
call far dword [entry]
else
int 1Ah
endif
mov eax,1
jnc @@1
xor eax,eax ; Function failed!
@@1: leave_c
ret
cprocend
;----------------------------------------------------------------------------
; ulong _PCIBIOS_specialCycle(int bus,ulong data,PCIBIOS_entry entry);
;----------------------------------------------------------------------------
; Generate a special cycle via the PCI BIOS.
;----------------------------------------------------------------------------
cprocstart _PCIBIOS_specialCycle
ARG bus:UINT, data:ULONG, entry:QWORD
enter_c
mov eax,0B106h
mov bh,[BYTE bus]
mov ecx,[data]
ifdef flatmodel
call far dword [entry]
else
int 1Ah
endif
leave_c
ret
cprocend
;----------------------------------------------------------------------------
; ushort _PCI_getCS(void)
;----------------------------------------------------------------------------
cprocstart _PCI_getCS
mov ax,cs
ret
cprocend
;----------------------------------------------------------------------------
; int PM_inpb(int port)
;----------------------------------------------------------------------------
; Reads a byte from the specified port
;----------------------------------------------------------------------------
cprocstart PM_inpb
ARG port:UINT
push _bp
mov _bp,_sp
xor _ax,_ax
mov _dx,[port]
in al,dx
pop _bp
ret
cprocend
;----------------------------------------------------------------------------
; int PM_inpw(int port)
;----------------------------------------------------------------------------
; Reads a word from the specified port
;----------------------------------------------------------------------------
cprocstart PM_inpw
ARG port:UINT
push _bp
mov _bp,_sp
xor _ax,_ax
mov _dx,[port]
in ax,dx
pop _bp
ret
cprocend
;----------------------------------------------------------------------------
; ulong PM_inpd(int port)
;----------------------------------------------------------------------------
; Reads a word from the specified port
;----------------------------------------------------------------------------
cprocstart PM_inpd
ARG port:UINT
push _bp
mov _bp,_sp
mov _dx,[port]
in eax,dx
ifndef flatmodel
shld edx,eax,16 ; DX:AX = result
endif
pop _bp
ret
cprocend
;----------------------------------------------------------------------------
; void PM_outpb(int port,int value)
;----------------------------------------------------------------------------
; Write a byte to the specified port.
;----------------------------------------------------------------------------
cprocstart PM_outpb
ARG port:UINT, value:UINT
push _bp
mov _bp,_sp
mov _dx,[port]
mov _ax,[value]
out dx,al
pop _bp
ret
cprocend
;----------------------------------------------------------------------------
; void PM_outpw(int port,int value)
;----------------------------------------------------------------------------
; Write a word to the specified port.
;----------------------------------------------------------------------------
cprocstart PM_outpw
ARG port:UINT, value:UINT
push _bp
mov _bp,_sp
mov _dx,[port]
mov _ax,[value]
out dx,ax
pop _bp
ret
cprocend
;----------------------------------------------------------------------------
; void PM_outpd(int port,ulong value)
;----------------------------------------------------------------------------
; Write a word to the specified port.
;----------------------------------------------------------------------------
cprocstart PM_outpd
ARG port:UINT, value:ULONG
push _bp
mov _bp,_sp
mov _dx,[port]
mov eax,[value]
out dx,eax
pop _bp
ret
cprocend
endcodeseg _pcilib
END
/****************************************************************************
*
* SciTech OS Portability Manager Library
*
* ========================================================================
*
* Copyright (C) 1991-2002 SciTech Software, Inc. All rights reserved.
*
* This file may be distributed and/or modified under the terms of the
* GNU Lesser General Public License version 2.1 as published by the Free
* Software Foundation and appearing in the file LICENSE.LGPL included
* in the packaging of this file.
*
* Licensees holding a valid Commercial License for this product from
* SciTech Software, Inc. may use this file in accordance with the
* Commercial License Agreement provided with the Software.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE.
*
* See http://www.scitechsoft.com/license/ for information about
* the licensing options available and how to purchase a Commercial
* License Agreement.
*
* Contact license@scitechsoft.com if any conditions of this licensing
* are not clear to you, or you have questions about licensing options.
*
* ========================================================================
*
* Language: ANSI C
* Environment: Any
*
* Description: Header file for PM library functions for querying the CPU
* type, CPU speed and CPU features. Includes support for
* high precision timing on Pentium based systems using the
* Read Time Stamp Counter.
*
****************************************************************************/
#ifndef __CPUINFO_H
#define __CPUINFO_H
//#include "scitech.h"
#include "SDL.h"
#ifdef USE_ASMBLIT
#define __INTEL__
#endif
typedef enum {
false,
true
} ibool;
typedef Uint8 uchar;
typedef Uint16 ushort;
typedef Uint32 uint;
typedef Uint32 ulong;
typedef Uint64 u64;
#define _ASMAPI SDLCALL
/*--------------------- Macros and type definitions -----------------------*/
/* Define the calling conventions - C always */
#define ZAPI _ASMAPI
/****************************************************************************
REMARKS:
Defines the types of processors returned by CPU_getProcessorType.
HEADER:
cpuinfo.h
MEMBERS:
CPU_i386 - Intel 80386 processor
CPU_i486 - Intel 80486 processor
CPU_Pentium - Intel Pentium(R) processor
CPU_PentiumPro - Intel PentiumPro(R) processor
CPU_PentiumII - Intel PentiumII(R) processor
CPU_Celeron - Intel Celeron(R) processor
CPU_PentiumIII - Intel PentiumIII(R) processor
CPU_Pentium4 - Intel Pentium4(R) processor
CPU_UnkIntel - Unknown Intel processor
CPU_Cyrix6x86 - Cyrix 6x86 processor
CPU_Cyrix6x86MX - Cyrix 6x86MX processor
CPU_CyrixMediaGX - Cyrix MediaGX processor
CPU_CyrixMediaGXm - Cyrix MediaGXm processor
CPU_UnkCyrix - Unknown Cyrix processor
CPU_AMDAm486 - AMD Am486 processor
CPU_AMDAm5x86 - AMD Am5x86 processor
CPU_AMDK5 - AMD K5 processor
CPU_AMDK6 - AMD K6 processor
CPU_AMDK6_2 - AMD K6-2 processor
CPU_AMDK6_2plus - AMD K6-2+ processor
CPU_AMDK6_III - AMD K6-III processor
CPU_AMDK6_IIIplus - AMD K6-III+ processor
CPU_AMDAthlon - AMD Athlon processor
CPU_AMDDuron - AMD Duron processor
CPU_UnkAMD - Unknown AMD processor
CPU_WinChipC6 - IDT WinChip C6 processor
CPU_WinChip2 - IDT WinChip 2 processor
CPU_UnkIDT - Unknown IDT processor
CPU_ViaCyrixIII - Via Cyrix III
CPU_UnkVIA - Unknown Via processor
CPU_Alpha - DEC Alpha processor
CPU_Mips - MIPS processor
CPU_PowerPC - PowerPC processor
CPU_mask - Mask to remove flags and get CPU type
CPU_IDT - This bit is set if the processor vendor is IDT
CPU_Cyrix - This bit is set if the processor vendor is Cyrix
CPU_AMD - This bit is set if the processor vendor is AMD
CPU_Intel - This bit is set if the processor vendor is Intel
CPU_VIA - This bit is set if the processor vendor is Via
CPU_familyMask - Mask to isolate CPU family
CPU_steppingMask - Mask to isolate CPU stepping
CPU_steppingShift - Shift factor for CPU stepping
****************************************************************************/
typedef enum {
CPU_i386 = 0,
CPU_i486 = 1,
CPU_Pentium = 2,
CPU_PentiumPro = 3,
CPU_PentiumII = 4,
CPU_Celeron = 5,
CPU_PentiumIII = 6,
CPU_Pentium4 = 7,
CPU_UnkIntel = 8,
CPU_Cyrix6x86 = 100,
CPU_Cyrix6x86MX = 101,
CPU_CyrixMediaGX = 102,
CPU_CyrixMediaGXm = 104,
CPU_UnkCyrix = 105,
CPU_AMDAm486 = 200,
CPU_AMDAm5x86 = 201,
CPU_AMDK5 = 202,
CPU_AMDK6 = 203,
CPU_AMDK6_2 = 204,
CPU_AMDK6_2plus = 205,
CPU_AMDK6_III = 206,
CPU_AMDK6_IIIplus = 207,
CPU_UnkAMD = 208,
CPU_AMDAthlon = 250,
CPU_AMDDuron = 251,
CPU_WinChipC6 = 300,
CPU_WinChip2 = 301,
CPU_UnkIDT = 302,
CPU_ViaCyrixIII = 400,
CPU_UnkVIA = 401,
CPU_Alpha = 500,
CPU_Mips = 600,
CPU_PowerPC = 700,
CPU_mask = 0x00000FFF,
CPU_IDT = 0x00001000,
CPU_Cyrix = 0x00002000,
CPU_AMD = 0x00004000,
CPU_Intel = 0x00008000,
CPU_VIA = 0x00010000,
CPU_familyMask = 0x00FFF000,
CPU_steppingMask = 0x0F000000,
CPU_steppingShift = 24
} CPU_processorType;
#pragma pack(1)
/****************************************************************************
REMARKS:
Defines the structure for holding 64-bit integers used for storing the values
returned by the Intel RDTSC instruction.
HEADER:
cpuinfo.h
MEMBERS:
low - Low 32-bits of the 64-bit integer
high - High 32-bits of the 64-bit integer
****************************************************************************/
typedef struct {
ulong low;
ulong high;
} CPU_largeInteger;
#pragma pack()
/*-------------------------- Function Prototypes --------------------------*/
#ifdef __cplusplus
extern "C" { /* Use "C" linkage when in C++ mode */
#endif
/* Routines to obtain CPU information */
uint ZAPI CPU_getProcessorType(void);
ibool ZAPI CPU_haveMMX(void);
ibool ZAPI CPU_have3DNow(void);
ibool ZAPI CPU_haveSSE(void);
ibool ZAPI CPU_haveRDTSC(void);
ulong ZAPI CPU_getProcessorSpeed(ibool accurate);
void ZAPI CPU_getProcessorSpeedInHZ(ibool accurate,CPU_largeInteger *speed);
char * ZAPI CPU_getProcessorName(void);
#ifdef __cplusplus
} /* End of "C" linkage for C++ */
#endif
#endif /* __CPUINFO_H */
This diff is collapsed.
This diff is collapsed.
......@@ -104,14 +104,7 @@ static char rcsid =
#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
#include "mmx.h"
/* Function to check the CPU flags */
#define MMX_CPU 0x800000
#define CPU_Flags() Hermes_X86_CPU()
#define X86_ASSEMBLER
#define HermesConverterInterface void
#define HermesClearInterface void
#define STACKCALL
#include "HeadX86.h"
#include "SDL_cpuinfo.h"
#endif
#ifndef MAX
......@@ -657,7 +650,7 @@ do { \
if(alpha == 128) \
blitter(2, Uint8, ALPHA_BLIT16_565_50); \
else { \
if((CPU_Flags()&MMX_CPU)!=0) \
if(SDL_HasMMX()) \
blitter(2, Uint8, ALPHA_BLIT16_565MMX); \
else \
blitter(2, Uint8, ALPHA_BLIT16_565); \
......@@ -673,7 +666,7 @@ do { \
if(alpha == 128) \
blitter(2, Uint8, ALPHA_BLIT16_555_50); \
else { \
if((CPU_Flags()&MMX_CPU)!=0) \
if(SDL_HasMMX()) \
blitter(2, Uint8, ALPHA_BLIT16_555MMX); \
else \
blitter(2, Uint8, ALPHA_BLIT16_555); \
......@@ -698,14 +691,14 @@ do { \
|| fmt->Bmask == 0xff00)) { \
if(alpha == 128) \
{ \
if((CPU_Flags()&MMX_CPU)!=0) \
if(SDL_HasMMX()) \
blitter(4, Uint16, ALPHA_BLIT32_888_50MMX);\
else \
blitter(4, Uint16, ALPHA_BLIT32_888_50);\
} \
else \
{ \
if((CPU_Flags()&MMX_CPU)!=0) \
if(SDL_HasMMX()) \
blitter(4, Uint16, ALPHA_BLIT32_888MMX);\
else \
blitter(4, Uint16, ALPHA_BLIT32_888); \
......
......@@ -38,16 +38,8 @@ static char rcsid =
#include "SDL_memops.h"
#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
#include "SDL_cpuinfo.h"
#include "mmx.h"
/* Function to check the CPU flags */
#define MMX_CPU 0x800000
#define SSE_CPU 0x2000000
#define CPU_Flags() Hermes_X86_CPU()
#define X86_ASSEMBLER
#define HermesConverterInterface void
#define HermesClearInterface void
#define STACKCALL
#include "HeadX86.h"
#endif
/* The general purpose software blit routine */
......@@ -166,9 +158,6 @@ static void SDL_BlitCopy(SDL_BlitInfo *info)
Uint8 *src, *dst;
int w, h;
int srcskip, dstskip;
#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
Uint32 f;
#endif
w = info->d_width*info->dst->BytesPerPixel;
h = info->d_height;
......@@ -177,8 +166,7 @@ static void SDL_BlitCopy(SDL_BlitInfo *info)
srcskip = w+info->s_skip;
dstskip = w+info->d_skip;
#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
f=CPU_Flags();
if((f&(MMX_CPU|SSE_CPU))==(MMX_CPU|SSE_CPU))
if(SDL_HasSSE())
{
while ( h-- ) {
SDL_memcpySSE(dst, src, w);
......@@ -190,7 +178,7 @@ static void SDL_BlitCopy(SDL_BlitInfo *info)
::);
}
else
if((f&(MMX_CPU))!=0)
if(SDL_HasMMX())
{
while ( h-- ) {
SDL_memcpyMMX(dst, src, w);
......
......@@ -32,16 +32,9 @@ static char rcsid =
#include "SDL_blit.h"
#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
#include "mmx.h"
/* Function to check the CPU flags */
#define MMX_CPU 0x800000
#define TDNOW_CPU 0x80000000
#define CPU_Flags() Hermes_X86_CPU()
#define X86_ASSEMBLER
#define HermesConverterInterface void
#define HermesClearInterface void
#define STACKCALL
#include "HeadX86.h"
#include "SDL_cpuinfo.h"
#include "mmx.h"
#endif
/* Functions to perform alpha blended blitting */
......@@ -1387,7 +1380,7 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index)
if(df->Gmask == 0x7e0)
{
#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
if((CPU_Flags()&MMX_CPU)!=0)
if(SDL_HasMMX())
return Blit565to565SurfaceAlphaMMX;
else
#endif
......@@ -1396,7 +1389,7 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index)
else if(df->Gmask == 0x3e0)
{
#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
if((CPU_Flags()&MMX_CPU)!=0)
if(SDL_HasMMX())
return Blit555to555SurfaceAlphaMMX;
else
#endif
......@@ -1413,7 +1406,7 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index)
&& sf->BytesPerPixel == 4)
{
#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
if((CPU_Flags()&MMX_CPU)!=0)
if(SDL_HasMMX())
return BlitRGBtoRGBSurfaceAlphaMMX;
else
#endif
......@@ -1453,12 +1446,10 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index)
&& sf->BytesPerPixel == 4)
{
#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
Uint32 f;
f=CPU_Flags();
if((f&(TDNOW_CPU|MMX_CPU))==(TDNOW_CPU|MMX_CPU))
if(SDL_Has3DNow())
return BlitRGBtoRGBPixelAlphaMMX3DNOW;
else
if((f&MMX_CPU)!=0)
if(SDL_HasMMX())
return BlitRGBtoRGBPixelAlphaMMX;
else
#endif
......
......@@ -31,14 +31,7 @@ static char rcsid =
#include "SDL_video.h"
#include "SDL_blit.h"
#include "SDL_byteorder.h"
/* Function to check the CPU flags */
#define MMX_CPU 0x800000
#ifdef USE_ASMBLIT
#define CPU_Flags() Hermes_X86_CPU()
#else
#define CPU_Flags() 0L
#endif
#include "SDL_cpuinfo.h"
/* Functions to blit from N-bit surfaces to other surfaces */
......@@ -1429,7 +1422,7 @@ struct blit_table {
Uint32 srcR, srcG, srcB;
int dstbpp;
Uint32 dstR, dstG, dstB;
Uint32 cpu_flags;
SDL_bool cpu_mmx;
void *aux_data;
SDL_loblit blitfunc;
enum { NO_ALPHA, SET_ALPHA, COPY_ALPHA } alpha;
......@@ -1466,19 +1459,19 @@ static const struct blit_table normal_blit_3[] = {
static const struct blit_table normal_blit_4[] = {
#ifdef USE_ASMBLIT
{ 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000F800,0x000007E0,0x0000001F,
MMX_CPU, ConvertMMXpII32_16RGB565, ConvertMMX, NO_ALPHA },
1, ConvertMMXpII32_16RGB565, ConvertMMX, NO_ALPHA },
{ 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000F800,0x000007E0,0x0000001F,
0, ConvertX86p32_16RGB565, ConvertX86, NO_ALPHA },
{ 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000001F,0x000007E0,0x0000F800,
MMX_CPU, ConvertMMXpII32_16BGR565, ConvertMMX, NO_ALPHA },
1, ConvertMMXpII32_16BGR565, ConvertMMX, NO_ALPHA },
{ 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000001F,0x000007E0,0x0000F800,
0, ConvertX86p32_16BGR565, ConvertX86, NO_ALPHA },
{ 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x00007C00,0x000003E0,0x0000001F,
MMX_CPU, ConvertMMXpII32_16RGB555, ConvertMMX, NO_ALPHA },
1, ConvertMMXpII32_16RGB555, ConvertMMX, NO_ALPHA },
{ 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x00007C00,0x000003E0,0x0000001F,
0, ConvertX86p32_16RGB555, ConvertX86, NO_ALPHA },
{ 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000001F,0x000003E0,0x00007C00,
MMX_CPU, ConvertMMXpII32_16BGR555, ConvertMMX, NO_ALPHA },
1, ConvertMMXpII32_16BGR555, ConvertMMX, NO_ALPHA },
{ 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000001F,0x000003E0,0x00007C00,
0, ConvertX86p32_16BGR555, ConvertX86, NO_ALPHA },
{ 0x00FF0000,0x0000FF00,0x000000FF, 3, 0x00FF0000,0x0000FF00,0x000000FF,
......@@ -1581,8 +1574,7 @@ SDL_loblit SDL_CalculateBlitN(SDL_Surface *surface, int blit_index)
dstfmt->Gmask == table[which].dstG &&
dstfmt->Bmask == table[which].dstB &&
(a_need & table[which].alpha) == a_need &&
(CPU_Flags()&table[which].cpu_flags) ==
table[which].cpu_flags )
(table[which].cpu_mmx == SDL_HasMMX()))
break;
}
sdata->aux_data = table[which].aux_data;
......
......@@ -92,27 +92,11 @@ static char rcsid =
#include "SDL_error.h"
#include "SDL_video.h"
#include "SDL_cpuinfo.h"
#include "SDL_stretch_c.h"
#include "SDL_yuvfuncs.h"
#include "SDL_yuv_sw_c.h"
/* Function to check the CPU flags */
#define MMX_CPU 0x800000
#ifdef USE_ASMBLIT
#define CPU_Flags() Hermes_X86_CPU()
#else
#define CPU_Flags() 0L
#endif
#ifdef USE_ASMBLIT
#define X86_ASSEMBLER
#define HermesConverterInterface void
#define HermesClearInterface void
#define STACKCALL
#include "HeadX86.h"
#endif
/* The functions used to manipulate software video overlays */
static struct private_yuvhwfuncs sw_yuvfuncs = {
SDL_LockYUV_SW,
......@@ -956,7 +940,7 @@ SDL_Overlay *SDL_CreateYUV_SW(_THIS, int width, int height, Uint32 format, SDL_S
Uint32 *r_2_pix_alloc;
Uint32 *g_2_pix_alloc;
Uint32 *b_2_pix_alloc;
int i, cpu_mmx;
int i;
int CR, CB;
Uint32 Rmask, Gmask, Bmask;
......@@ -1082,14 +1066,13 @@ SDL_Overlay *SDL_CreateYUV_SW(_THIS, int width, int height, Uint32 format, SDL_S
switch (format) {
case SDL_YV12_OVERLAY:
case SDL_IYUV_OVERLAY:
cpu_mmx = CPU_Flags() & MMX_CPU;
if ( display->format->BytesPerPixel == 2 ) {
#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
/* inline assembly functions */
if ( cpu_mmx && (Rmask == 0xF800) &&
(Gmask == 0x07E0) &&
(Bmask == 0x001F) &&
(width & 15) == 0) {
if ( SDL_HasMMX() && (Rmask == 0xF800) &&
(Gmask == 0x07E0) &&
(Bmask == 0x001F) &&
(width & 15) == 0) {
/*printf("Using MMX 16-bit 565 dither\n");*/
swdata->Display1X = Color565DitherYV12MMX1X;
} else {
......@@ -1108,10 +1091,10 @@ SDL_Overlay *SDL_CreateYUV_SW(_THIS, int width, int height, Uint32 format, SDL_S
if ( display->format->BytesPerPixel == 4 ) {
#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
/* inline assembly functions */
if ( cpu_mmx && (Rmask == 0x00FF0000) &&
(Gmask == 0x0000FF00) &&
(Bmask == 0x000000FF) &&
(width & 15) == 0) {
if ( SDL_HasMMX() && (Rmask == 0x00FF0000) &&
(Gmask == 0x0000FF00) &&
(Bmask == 0x000000FF) &&
(width & 15) == 0) {
/*printf("Using MMX 32-bit dither\n");*/
swdata->Display1X = ColorRGBDitherYV12MMX1X;
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment