Skip to content

Commit

Permalink
quick fix + sse/avx detection in setup
Browse files Browse the repository at this point in the history
  • Loading branch information
JHRobotics committed Apr 11, 2023
1 parent f3dd123 commit 51432dc
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 50 deletions.
78 changes: 40 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ This is ready-to-use compilation of my 4 projects:

## Requirements
1) Virtual machine with one of these VGA adapter support:
a) Bochs VBE (Bochs, VirtualBox, Qemu)
b) VMware SVGA-II (VMware, VirtualBox, Qemu)
- A) Bochs VBE (Bochs, VirtualBox, Qemu)
- B) VMware SVGA-II (VMware, VirtualBox, Qemu)
2) Windows 95/98/Me as VM guest system
a) Windows 98/Me - required is last version of DirectX 9 (included in package)
b) Windows 95
- A) Windows 98/Me - required is last version of DirectX 9 (included in package)
- B) Windows 95
- Last version of DirectX 8 (included in package)
- Visual C runtime (version 6 included in package)
- OpenGL 95 for versions without `opengl32.dll` (included in package)
Expand Down Expand Up @@ -79,54 +79,56 @@ There are many bugs in individual components, please post them to individual rep
But still, please be patient. SoftGPU compatibility target is about a decade of intensive HW and SW development (from DOS direct VGA/VESA access, SW rendering through GDI, DirectDraw, OpenGL, Glide, DirectX, OpenGL again). After all, there will still applications that cannot be run anyway because there are written for very individual SW/HW combinations.

## Compilation from source
1) You need MINGW and MAKE to create GUI setup
1) You need MINGW and *GNU make* to build *softgpu.exe*
2) You need all development tool to compile all other component (see README.md in individual repositories)
3) Compile softgpu.exe by type make (GNU make required)
4) Compile VMDisp9x and copy files boxvmini.drv, vmwsmini.drv, vmwsmini.vxd, vmdisp9x.inf and place them to driver/win95 and driver/win98me folder
3) Compile softgpu.exe by type `make`
4) Compile VMDisp9x and copy files `boxvmini.drv`, `vmwsmini.drv`, `vmwsmini.vxd`, `vmdisp9x.inf` and place them to `driver/win95` and `driver/win98me` folder
5) Compile Mesa9x for Windows 95 (e.g., without SSE) and copy and rename files to following schema
- vmwsgl32.dll => driver/win95/vmwsgl32.dll
- opengl32.w98me.dll => driver/win95/extra/opengl32.dll
- mesa3d.w98me.dll => driver/win95/mesa3d.dll
- glchecker.exe => tools/glchecker.exe
- icdtest.exe => tools/icdtest.exe
- wgltest.exe => tools/wgltest.exe
- [folder] glchecker => tools/glchecker
- `vmwsgl32.dll` => `driver/win95/vmwsgl32.dll`
- `opengl32.w98me.dll` => `driver/win95/extra/opengl32.dll`
- `mesa3d.w98me.dll` => `driver/win95/mesa3d.dll`
- `glchecker.exe` => `tools/glchecker.exe`
- `icdtest.exe` => `tools/icdtest.exe`
- `wgltest.exe` => `tools/wgltest.exe`
- [folder] `glchecker` => `tools/glchecker`
6) Compile Mesa9x for Windows 98 and Me (eq. with SSE, optimized for Core2 or Westmere) and copy these files
- vmwsgl32.dll => driver/win98me/vmwsgl32.dll
- opengl32.w98me.dll => driver/win98me/extra/opengl32.dll
- mesa3d.w98me.dll => driver/win98me/mesa3d.dll
- `vmwsgl32.dll` => `driver/win98me/vmwsgl32.dll`
- `opengl32.w98me.dll` => `driver/win98me/extra/opengl32.dll`
- `mesa3d.w98me.dll` => `driver/win98me/mesa3d.dll`
7) Compile Wine9x for Windows 95 and copy
- ddraw.dll => driver/win95/ddraw.dll
- d3d8.dll => driver/win95/d3d8.dll
- d3d9.dll => driver/win95/d3d9.dll
- dwine.dll => driver/win95/dwine.dll
- wined3d.dll => driver/win95/wined3d.dll
- `ddraw.dll` => `driver/win95/ddraw.dll`
- `ddrawme.dll` => `driver/win95/ddrawme.dll`
- `d3d8.dll` => `driver/win95/d3d8.dll`
- `d3d9.dll` => `driver/win95/d3d9.dll`
- `dwine.dll` => `driver/win95/dwine.dll`
- `wined3d.dll` => `driver/win95/wined3d.dll`
8) Compile Wine9x for Windows 98+Me and copy
- ddraw.dll => driver/win98me/ddraw.dll
- d3d8.dll => driver/win98me/d3d8.dll
- d3d9.dll => driver/win98me/d3d9.dll
- dwine.dll => driver/win98me/dwine.dll
- wined3d.dll => driver/win98me/wined3d.dll
9) make ddreplacer.exe (by typing make ddreplacer.exe in Wine9x)
- `ddraw.dll` => `driver/win98me/ddraw.dll`
- `ddrawme.dll` => `driver/win95/ddrawme.dll`
- `d3d8.dll` => `driver/win98me/d3d8.dll`
- `d3d9.dll` => `driver/win98me/d3d9.dll`
- `dwine.dll` => `driver/win98me/dwine.dll`
- `wined3d.dll` => `driver/win98me/wined3d.dll`
9) make `ddreplacer.exe` (by typing make ddreplacer.exe in Wine9x)
10) Extract original ddraw.dll from DX8 redistributable for W95 and type
```
ddreplacer path/to/extracted/ddraw.dll ddr95.dll
ddreplacer `path/to/extracted/ddraw.dll` `ddr95.dll`
```
- copy ddr95.dll => driver/win95/dx/ddr95.dll
- copy ddr95.dll => driver/win98me/dx/ddr95.dll
- copy `ddr95.dll` => `driver/win95/dx/ddr95.dll`
- copy `ddr95.dll` => `driver/win98me/dx/ddr95.dll`
11) Extract original ddraw.dll from newer DX9 redistributable (doesn't matter if it's final one, this file doesn't seem to change often) and type
```
ddreplacer path/to/extracted/ddraw.dll ddr95.dll
```
- copy ddr98.dll => driver/win95/dx/ddr98.dll
- copy ddr98.dll => driver/win98me/dx/ddr98.dll
- copy `ddr98.dll` => `driver/win95/dx/ddr98.dll`
- copy `ddr98.dll` => `driver/win98me/dx/ddr98.dll`
12) Compile OpenGlide9x for Windows 95 and copy
- glide2x.dll => driver/win95/glide2x.dll
- glide3x.dll => driver/win95/glide3x.dll
- `glide2x.dll` => `driver/win95/glide2x.dll`
- `glide3x.dll` => `driver/win95/glide3x.dll`
13) Compile OpenGlide9x for Windows 98 and copy
- glide2x.dll => driver/win98me/glide2x.dll
- glide3x.dll => driver/win98me/glide3x.dll
14) Edit both driver/win95/vmdisp9x.inf and driver/win98me/vmdisp9x.inf and uncomment files and that you added. CopyFiles options have to look like:
- `glide2x.dll` => `driver/win98me/glide2x.dll`
- `glide3x.dll` => `driver/win98me/glide3x.dll`
14) Edit both `driver/win95/vmdisp9x.inf` and `driver/win98me/vmdisp9x.inf` and uncomment files and that you added. CopyFiles options have to look like:
```
CopyFiles=VBox.Copy,Dx.Copy,DX.CopyBackup,Voodoo.Copy
```
Expand Down
4 changes: 2 additions & 2 deletions actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,9 +579,9 @@ BOOL simd95(HWND hwnd)
if(CopyFileA("C:\\autoexec.bat", "C:\\autoexec.bak", FALSE))
{
//liner("C:\\autoexec.bak", "C:\\autoexec.new", simd95rules);

addLine("C:\\autoexec.bat", "C:\\simd95.com\r\n");
}

addLine("C:\\autoexec.bat", "C:\\simd95.com\r\n");
}

return TRUE;
Expand Down
95 changes: 87 additions & 8 deletions softgpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void about(HWND hwnd)
#define BTN_EXIT 12
#define BTN_INSTALL 13
#define CHBX_GL95 14
#define BTN_ABOUT 14
#define BTN_ABOUT 15

static float rdpiX = 1.0;
static float rdpiY = 1.0;
Expand All @@ -124,14 +124,89 @@ version_t WINVER2K = {5,0,0,0};
static BOOL isNT = FALSE;
version_t sysver = {0};
static version_t dxver = {0};
static BOOL hasCRT = FALSE;
static BOOL hasSETUPAPI = FALSE;
static BOOL hasSSE2 = FALSE;
static BOOL hasAVX = FALSE;
static BOOL hasOpengl = FALSE;
static BOOL hasCRT = FALSE;
static BOOL hasSETUPAPI = FALSE;
static uint32_t hasSSE2 = 0;
static uint32_t hasAVX = 0;
static BOOL hasOpengl = FALSE;

static char sysinfomsg[1024];

void readCPUInfo()
{
/* AVX avaibility by intel atricle:
http://software.intel.com/en-us/blogs/2011/04/14/is-avx-enabled/ */
__asm(
"pusha\n"
"xorl %%eax, %%eax\n"
"cpuid\n"
"cmpl $1, %%eax\n" // does CPUID support eax = 1?
"jb not_supported\n"
"movl $1, %%eax\n"
"cpuid\n"
"andl $0x18000000, %%ecx\n" // check 27 bit (OS uses XSAVE/XRSTOR)
"cmpl $0x18000000, %%ecx\n" // and 28 (AVX supported by CPU)
"jne not_supported\n"
"xorl %%ecx, %%ecx\n" // XFEATURE_ENABLED_MASK/XCR0 register number = 0
"xgetbv\n" // XFEATURE_ENABLED_MASK register is in edx:eax
"andl $6, %%eax\n"
"cmpl $6, %%eax\n" // check the AVX registers restore at context switch
"jne not_supported\n"
"movl $1, %0\n"
"jmp end\n"
"not_supported:\n"
"movl $0, %0\n"
"end:\n"
"popa" : "=m" (hasAVX));

if(version_compare(&sysver, &WINVER98) >= 0) /* in 98 SSE supported if they are present */
{
__asm(
"pusha\n"
"xorl %%eax, %%eax\n"
"cpuid\n"
"cmpl $1, %%eax\n" // does CPUID support eax = 1?
"jb not_supported_sse\n"
"movl $1, %%eax\n"
"cpuid\n"
"andl $0x06000000, %%edx\n" // check 25 and 26 - SSE and SSE2
"cmpl $0x06000000, %%edx\n"
"jne not_supported_sse\n"
"movl $1, %0\n"
"jmp end_sse\n"
"not_supported_sse:\n"
"movl $0, %0\n"
"end_sse:\n"
"popa" : "=m" (hasSSE2));
}
else
{
/*
* win 95, if XSAVE is enable, SSE present too, I need write better test
* (probably exec some sse instruction and catch exeption)
*
*/
__asm(
"pusha\n"
"xorl %%eax, %%eax\n"
"cpuid\n"
"cmpl $1, %%eax\n"
"jb not_supported_sse95\n"
"mov $1, %%eax\n"
"cpuid\n"
"andl $0x08000000, %%ecx\n" // we simly check for enable xstore
"cmpl $0x08000000, %%ecx\n" // i still haven't come up with better test
"jne not_supported_sse95\n"
"movl $1, %0\n"
"jmp end_sse95\n"
"not_supported_sse95:\n"
"movl $0, %0\n"
"end_sse95:\n"
"popa" : "=m" (hasSSE2));
}

}

void softgpu_sysinfo()
{
version_win(&sysver);
Expand All @@ -158,8 +233,10 @@ void softgpu_sysinfo()
FreeLibrary(testLib);
}

hasSSE2 = __builtin_cpu_supports("sse2") > 0;
hasAVX = __builtin_cpu_supports("avx") > 0;
readCPUInfo();

//hasSSE2 = __builtin_cpu_supports("sse2") > 0;
//hasAVX = __builtin_cpu_supports("avx") > 0;

sprintf(sysinfomsg, "System informations:\n"
"System version: %d.%d.%d.%d\n"
Expand Down Expand Up @@ -596,6 +673,8 @@ int main(int argc, const char *argv[])
MSG msg;
HINSTANCE hInst = GetModuleHandle(NULL);

//__builtin_cpu_init();

(void)argc;
(void)argv;

Expand Down
4 changes: 2 additions & 2 deletions softgpu.ini
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ glu95=redist\opengl95\DLL\GLU32.DLL
;ie98.ver=Internet Explorer 6.0

[version]
vmdisp9x=1.2023.0.2
vmdisp9x=1.2023.0.3
mesa9x=17.3.9.2
wine9x=1.7.55.2
wine9x=1.7.55.3
openglide9x=0.1.2023.2
simd95=1.0.0.0

Expand Down

0 comments on commit 51432dc

Please sign in to comment.