Permalink
Browse files

Merge pull request #1457 from PatrickvL/xqemu_port

Ported xqemu nv2a changes
  • Loading branch information...
LukeUsher committed Oct 7, 2018
2 parents 16e094b + c281b99 commit 81d52e50b6cd8e4cac46a43094923af27eed4e1a
Showing with 3,388 additions and 3,255 deletions.
  1. +1 −0 build/win32/Cxbx.vcxproj
  2. +5 −0 build/win32/Cxbx.vcxproj.filters
  3. +3 −3 src/core/HLE/D3D8/Direct3D9/Direct3D9.cpp
  4. +2 −1 src/core/HLE/D3D8/XbPushBuffer.cpp
  5. +1 −1 src/core/HLE/D3D8/XbVertexShader.cpp
  6. +1 −1 src/core/HLE/DSOUND/DirectSound/DirectSound.cpp
  7. +4 −4 src/core/HLE/XAPI/Xapi.cpp
  8. +37 −6 src/devices/video/EmuNV2A_DEBUG.cpp
  9. +9 −6 src/devices/video/EmuNV2A_PBUS.cpp
  10. +9 −6 src/devices/video/EmuNV2A_PCOUNTER.cpp
  11. +9 −6 src/devices/video/EmuNV2A_PCRTC.cpp
  12. +9 −6 src/devices/video/EmuNV2A_PFB.cpp
  13. +360 −403 src/devices/video/EmuNV2A_PFIFO.cpp
  14. +267 −266 src/devices/video/EmuNV2A_PGRAPH.cpp
  15. +9 −6 src/devices/video/EmuNV2A_PMC.cpp
  16. +9 −6 src/devices/video/EmuNV2A_PRAMDAC.cpp
  17. +9 −6 src/devices/video/EmuNV2A_PRAMIN.cpp
  18. +9 −6 src/devices/video/EmuNV2A_PRMA.cpp
  19. +9 −6 src/devices/video/EmuNV2A_PRMCIO.cpp
  20. +9 −6 src/devices/video/EmuNV2A_PRMDIO.cpp
  21. +9 −6 src/devices/video/EmuNV2A_PRMFB.cpp
  22. +9 −6 src/devices/video/EmuNV2A_PRMVIO.cpp
  23. +9 −6 src/devices/video/EmuNV2A_PSTRAPS.cpp
  24. +10 −7 src/devices/video/EmuNV2A_PTIMER.cpp
  25. +9 −6 src/devices/video/EmuNV2A_PTV.cpp
  26. +9 −6 src/devices/video/EmuNV2A_PVIDEO.cpp
  27. +9 −6 src/devices/video/EmuNV2A_PVPE.cpp
  28. +67 −41 src/devices/video/EmuNV2A_USER.cpp
  29. +28 −15 src/devices/video/nv2a.cpp
  30. +1 −606 src/devices/video/nv2a.h
  31. +1 −0 src/devices/video/nv2a_debug.cpp
  32. +3 −3 src/devices/video/nv2a_debug.h
  33. +505 −1,752 src/devices/video/nv2a_int.h
  34. +67 −30 src/devices/video/nv2a_psh.cpp
  35. +3 −0 src/devices/video/nv2a_psh.h
  36. +1,833 −0 src/devices/video/nv2a_regs.h
  37. +8 −4 src/devices/video/nv2a_shaders.cpp
  38. +3 −3 src/devices/video/nv2a_shaders.h
  39. +32 −11 src/devices/video/nv2a_vsh.cpp
  40. +2 −2 src/devices/video/qstring.h
View
@@ -293,6 +293,7 @@
<ClInclude Include="..\..\src\devices\video\nv2a_debug.h" />
<ClInclude Include="..\..\src\devices\video\nv2a_int.h" />
<ClInclude Include="..\..\src\devices\video\nv2a_psh.h" />
<ClInclude Include="..\..\src\devices\video\nv2a_regs.h" />
<ClInclude Include="..\..\src\devices\video\nv2a_shaders.h" />
<ClInclude Include="..\..\src\devices\video\nv2a_shaders_common.h" />
<ClInclude Include="..\..\src\devices\video\nv2a_vsh.h" />
@@ -808,4 +808,9 @@
<Image Include="..\..\resource\Cxbx-R.ico" />
<Image Include="..\..\resource\Logo-License-CC4.bmp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\devices\video\nv2a_regs.h">
<Filter>Hardware\Video</Filter>
</ClInclude>
</ItemGroup>
</Project>
@@ -2377,7 +2377,7 @@ static void EmuVerifyResourceIsRegistered(XTL::X_D3DResource *pResource, DWORD D
typedef struct {
DWORD Hash = 0;
DWORD IndexCount = 0;;
DWORD IndexCount = 0;
XTL::IDirect3DIndexBuffer* pHostIndexBuffer = nullptr;
} ConvertedIndexBuffer;
@@ -4870,7 +4870,7 @@ void CreateHostResource(XTL::X_D3DResource *pResource, DWORD D3DUsage, int iText
// If, and ONLY if this is the default backbuffer, make sure the format matches the host backbuffer
if (pResource == g_XboxBackBufferSurface) {
PCFormat = g_EmuCDPD.HostPresentationParameters.BackBufferFormat;;
PCFormat = g_EmuCDPD.HostPresentationParameters.BackBufferFormat;
}
}
else {
@@ -8541,7 +8541,7 @@ HRESULT WINAPI XTL::EMUPATCH(D3DDevice_SetDepthClipPlanes)
break;
default:
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Unknown SetDepthClipPlanes Flags provided");;
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Unknown SetDepthClipPlanes Flags provided");
}
// TODO
@@ -449,7 +449,8 @@ extern void XTL::EmuExecutePushBufferRaw
// Retrieve NV2AState via the (LLE) NV2A device :
NV2AState *d = g_NV2A->GetDeviceState();
d->pgraph.channel_valid = true; // avoid assert
d->pgraph.regs[NV_PGRAPH_CTX_CONTROL] |= NV_PGRAPH_CTX_CONTROL_CHID; // avoid assert in pgraph_handle_method()
// DMA Pusher state -- see https://envytools.readthedocs.io/en/latest/hw/fifo/dma-pusher.html#pusher-state
#if 0
@@ -905,7 +905,7 @@ static void VshWriteShader(VSH_XBOX_SHADER *pShader,
}
i++;
} while (i < RegVUsage.size());;
} while (i < RegVUsage.size());
}
for (int i = 0; i < pShader->IntermediateCount && (i < VSH_MAX_INSTRUCTION_COUNT || !Truncate); i++)
@@ -1839,7 +1839,7 @@ HRESULT WINAPI XTL::EMUPATCH(IDirectSound_CreateSoundStream)
LOG_FUNC_ARG(pUnknown)
LOG_FUNC_END;
return EMUPATCH(DirectSoundCreateStream)(pdssd, ppStream);;
return EMUPATCH(DirectSoundCreateStream)(pdssd, ppStream);
}
// ******************************************************************
@@ -864,11 +864,11 @@ void EmuSBCGetState(XTL::PX_SBC_GAMEPAD pSBCGamepad, XTL::PX_XINPUT_GAMEPAD pXIG
// Analog Sticks
pSBCGamepad->sAimingX = pXIGamepad->sThumbRX;;
pSBCGamepad->sAimingY = pXIGamepad->sThumbRY;;
pSBCGamepad->sAimingX = pXIGamepad->sThumbRX;
pSBCGamepad->sAimingY = pXIGamepad->sThumbRY;
pSBCGamepad->sRotationLever = 0;//(pXIGamepad->wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER) ? 255 : 0;
pSBCGamepad->sSightChangeX = pXIGamepad->sThumbLX;;
pSBCGamepad->sSightChangeY = pXIGamepad->sThumbLY;;
pSBCGamepad->sSightChangeX = pXIGamepad->sThumbLX;
pSBCGamepad->sSightChangeY = pXIGamepad->sThumbLY;
pSBCGamepad->wLeftPedal = ((SHORT)(pXIGamepad->bAnalogButtons[X_XINPUT_GAMEPAD_LEFT_TRIGGER]))<<8;
pSBCGamepad->wMiddlePedal=0;// = (pXIGamepad->wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER) ? 255 : 0;
pSBCGamepad->wRightPedal = (SHORT)(pXIGamepad->bAnalogButtons[X_XINPUT_GAMEPAD_RIGHT_TRIGGER])<<8;
@@ -28,12 +28,15 @@
// * If not, write to the Free Software Foundation, Inc.,
// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA.
// *
// * nv2a.cpp is heavily based on code from XQEMU
// * Copyright(c) 2012 espes
// * Copyright(c) 2015 Jannik Vogel
// * https://github.com/espes/xqemu/blob/xbox/hw/xbox/nv2a.c
// * (c) 2017-2018 Luke Usher <luke.usher@outlook.com>
// * (c) 2018 Patrick van Logchem <pvanlogchem@gmail.com>
// * This file is heavily based on code from XQEMU
// * https://github.com/xqemu/xqemu/tree/master/hw/xbox/nv2a/nv2a_debug.c
// * Copyright (c) 2012 espes
// * Copyright (c) 2015 Jannik Vogel
// * Copyright (c) 2018 Matt Borgerson
// *
// * Contributions for Cxbx-Reloaded
// * Copyright (c) 2017-2018 Luke Usher <luke.usher@outlook.com>
// * Copyright (c) 2018 Patrick van Logchem <pvanlogchem@gmail.com>
// *
// * All rights reserved
// *
@@ -134,6 +137,8 @@ DEBUG_START(PFIFO)
DEBUG_CASE(NV_PFIFO_CACHE1_DMA_GET_JMP_SHADOW);
DEBUG_CASE(NV_PFIFO_CACHE1_DMA_RSVD_SHADOW);
DEBUG_CASE(NV_PFIFO_CACHE1_DMA_DATA_SHADOW);
DEBUG_CASE(NV_PFIFO_CACHE1_METHOD);
DEBUG_CASE(NV_PFIFO_CACHE1_DATA);
DEBUG_END(PFIFO)
// TODO: Remove disabled warning once case are add to PRMA switch.
@@ -322,6 +327,12 @@ DEBUG_START(PGRAPH)
DEBUG_CASE(NV_PGRAPH_CTX_SWITCH2);
DEBUG_CASE(NV_PGRAPH_CTX_SWITCH3);
DEBUG_CASE(NV_PGRAPH_CTX_SWITCH4);
DEBUG_CASE(NV_PGRAPH_CTX_SWITCH5);
DEBUG_CASE(NV_PGRAPH_CTX_CACHE1);
DEBUG_CASE(NV_PGRAPH_CTX_CACHE2);
DEBUG_CASE(NV_PGRAPH_CTX_CACHE3);
DEBUG_CASE(NV_PGRAPH_CTX_CACHE4);
DEBUG_CASE(NV_PGRAPH_CTX_CACHE5);
DEBUG_CASE(NV_PGRAPH_STATUS);
DEBUG_CASE(NV_PGRAPH_TRAPPED_ADDR);
DEBUG_CASE(NV_PGRAPH_TRAPPED_DATA_LOW);
@@ -378,6 +389,7 @@ DEBUG_START(PGRAPH)
DEBUG_CASE(NV_PGRAPH_ZCOMP_OFFSET);
DEBUG_CASE(NV_PGRAPH_FBCFG0);
DEBUG_CASE(NV_PGRAPH_FBCFG1);
DEBUG_CASE(NV_PGRAPH_PATT_COLOR0);
DEBUG_CASE(NV_PGRAPH_DEBUG_6);
DEBUG_CASE(NV_PGRAPH_DEBUG_7);
DEBUG_CASE(NV_PGRAPH_DEBUG_10);
@@ -386,6 +398,7 @@ DEBUG_START(PGRAPH)
DEBUG_CASE(NV_PGRAPH_CSV1_B);
DEBUG_CASE(NV_PGRAPH_CSV1_A);
DEBUG_CASE(NV_PGRAPH_CHEOPS_OFFSET);
DEBUG_CASE(NV_PGRAPH_DMA_STATE);
DEBUG_CASE(NV_PGRAPH_BLEND);
DEBUG_CASE(NV_PGRAPH_BLENDCOLOR);
DEBUG_CASE(NV_PGRAPH_BORDERCOLOR0);
@@ -407,6 +420,7 @@ DEBUG_START(PGRAPH)
DEBUG_CASE(NV_PGRAPH_COMBINESPECFOG0);
DEBUG_CASE(NV_PGRAPH_COMBINESPECFOG1);
DEBUG_CASE(NV_PGRAPH_CONTROL_0);
DEBUG_CASE(NV_PGRAPH_CONTROL_1);
DEBUG_CASE(NV_PGRAPH_CONTROL_2);
DEBUG_CASE(NV_PGRAPH_CONTROL_3);
DEBUG_CASE(NV_PGRAPH_FOGCOLOR);
@@ -416,6 +430,7 @@ DEBUG_START(PGRAPH)
DEBUG_CASE(NV_PGRAPH_SHADERCLIPMODE);
DEBUG_CASE(NV_PGRAPH_SHADERCTL);
DEBUG_CASE(NV_PGRAPH_SHADERPROG);
DEBUG_CASE(NV_PGRAPH_SEMAPHOREOFFSET);
DEBUG_CASE(NV_PGRAPH_SHADOWZSLOPETHRESHOLD);
DEBUG_CASE(NV_PGRAPH_SPECFOGFACTOR0);
DEBUG_CASE(NV_PGRAPH_SPECFOGFACTOR1);
@@ -453,6 +468,22 @@ DEBUG_START(PGRAPH)
DEBUG_CASE(NV_PGRAPH_TEXPALETTE1);
DEBUG_CASE(NV_PGRAPH_TEXPALETTE2);
DEBUG_CASE(NV_PGRAPH_TEXPALETTE3);
DEBUG_CASE(NV_PGRAPH_WINDOWCLIPX0);
DEBUG_CASE(NV_PGRAPH_WINDOWCLIPX1);
DEBUG_CASE(NV_PGRAPH_WINDOWCLIPX2);
DEBUG_CASE(NV_PGRAPH_WINDOWCLIPX3);
DEBUG_CASE(NV_PGRAPH_WINDOWCLIPX4);
DEBUG_CASE(NV_PGRAPH_WINDOWCLIPX5);
DEBUG_CASE(NV_PGRAPH_WINDOWCLIPX6);
DEBUG_CASE(NV_PGRAPH_WINDOWCLIPX7);
DEBUG_CASE(NV_PGRAPH_WINDOWCLIPY0);
DEBUG_CASE(NV_PGRAPH_WINDOWCLIPY1);
DEBUG_CASE(NV_PGRAPH_WINDOWCLIPY2);
DEBUG_CASE(NV_PGRAPH_WINDOWCLIPY3);
DEBUG_CASE(NV_PGRAPH_WINDOWCLIPY4);
DEBUG_CASE(NV_PGRAPH_WINDOWCLIPY5);
DEBUG_CASE(NV_PGRAPH_WINDOWCLIPY6);
DEBUG_CASE(NV_PGRAPH_WINDOWCLIPY7);
DEBUG_CASE(NV_PGRAPH_ZSTENCILCLEARVALUE);
DEBUG_CASE(NV_PGRAPH_ZCLIPMIN);
DEBUG_CASE(NV_PGRAPH_ZOFFSETBIAS);
@@ -28,12 +28,15 @@
// * If not, write to the Free Software Foundation, Inc.,
// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA.
// *
// * nv2a.cpp is heavily based on code from XQEMU
// * Copyright(c) 2012 espes
// * Copyright(c) 2015 Jannik Vogel
// * https://github.com/espes/xqemu/blob/xbox/hw/xbox/nv2a.c
// * (c) 2017-2018 Luke Usher <luke.usher@outlook.com>
// * (c) 2018 Patrick van Logchem <pvanlogchem@gmail.com>
// * This file is heavily based on code from XQEMU
// * https://github.com/xqemu/xqemu/tree/master/hw/xbox/nv2a/nv2a_pbus.c
// * Copyright (c) 2012 espes
// * Copyright (c) 2015 Jannik Vogel
// * Copyright (c) 2018 Matt Borgerson
// *
// * Contributions for Cxbx-Reloaded
// * Copyright (c) 2017-2018 Luke Usher <luke.usher@outlook.com>
// * Copyright (c) 2018 Patrick van Logchem <pvanlogchem@gmail.com>
// *
// * All rights reserved
// *
@@ -28,12 +28,15 @@
// * If not, write to the Free Software Foundation, Inc.,
// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA.
// *
// * nv2a.cpp is heavily based on code from XQEMU
// * Copyright(c) 2012 espes
// * Copyright(c) 2015 Jannik Vogel
// * https://github.com/espes/xqemu/blob/xbox/hw/xbox/nv2a.c
// * (c) 2017-2018 Luke Usher <luke.usher@outlook.com>
// * (c) 2018 Patrick van Logchem <pvanlogchem@gmail.com>
// * This file is heavily based on code from XQEMU
// * https://github.com/xqemu/xqemu/blob/master/hw/xbox/nv2a/nv2a_stubs.c
// * Copyright (c) 2012 espes
// * Copyright (c) 2015 Jannik Vogel
// * Copyright (c) 2018 Matt Borgerson
// *
// * Contributions for Cxbx-Reloaded
// * Copyright (c) 2017-2018 Luke Usher <luke.usher@outlook.com>
// * Copyright (c) 2018 Patrick van Logchem <pvanlogchem@gmail.com>
// *
// * All rights reserved
// *
@@ -28,12 +28,15 @@
// * If not, write to the Free Software Foundation, Inc.,
// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA.
// *
// * nv2a.cpp is heavily based on code from XQEMU
// * Copyright(c) 2012 espes
// * Copyright(c) 2015 Jannik Vogel
// * https://github.com/espes/xqemu/blob/xbox/hw/xbox/nv2a.c
// * (c) 2017-2018 Luke Usher <luke.usher@outlook.com>
// * (c) 2018 Patrick van Logchem <pvanlogchem@gmail.com>
// * This file is heavily based on code from XQEMU
// * https://github.com/xqemu/xqemu/tree/master/hw/xbox/nv2a/nv2a_pcrtc.c
// * Copyright (c) 2012 espes
// * Copyright (c) 2015 Jannik Vogel
// * Copyright (c) 2018 Matt Borgerson
// *
// * Contributions for Cxbx-Reloaded
// * Copyright (c) 2017-2018 Luke Usher <luke.usher@outlook.com>
// * Copyright (c) 2018 Patrick van Logchem <pvanlogchem@gmail.com>
// *
// * All rights reserved
// *
@@ -28,12 +28,15 @@
// * If not, write to the Free Software Foundation, Inc.,
// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA.
// *
// * nv2a.cpp is heavily based on code from XQEMU
// * Copyright(c) 2012 espes
// * Copyright(c) 2015 Jannik Vogel
// * https://github.com/espes/xqemu/blob/xbox/hw/xbox/nv2a.c
// * (c) 2017-2018 Luke Usher <luke.usher@outlook.com>
// * (c) 2018 Patrick van Logchem <pvanlogchem@gmail.com>
// * This file is heavily based on code from XQEMU
// * https://github.com/xqemu/xqemu/blob/master/hw/xbox/nv2a/nv2a_pfb.c
// * Copyright (c) 2012 espes
// * Copyright (c) 2015 Jannik Vogel
// * Copyright (c) 2018 Matt Borgerson
// *
// * Contributions for Cxbx-Reloaded
// * Copyright (c) 2017-2018 Luke Usher <luke.usher@outlook.com>
// * Copyright (c) 2018 Patrick van Logchem <pvanlogchem@gmail.com>
// *
// * All rights reserved
// *
Oops, something went wrong.

2 comments on commit 81d52e5

@medievil1

This comment has been minimized.

Show comment
Hide comment
@medievil1

medievil1 Oct 8, 2018

just informing, this broke lle... no video output at all and games stall with 0.00 fps

amending this to say SOME games...some show videos whereas HLE doesn't...

also could be xqemu code related though.. games I tried have issues in xqemu with pgraph since their rebase

medievil1 replied Oct 8, 2018

just informing, this broke lle... no video output at all and games stall with 0.00 fps

amending this to say SOME games...some show videos whereas HLE doesn't...

also could be xqemu code related though.. games I tried have issues in xqemu with pgraph since their rebase

@PatrickvL

This comment has been minimized.

Show comment
Hide comment
@PatrickvL

PatrickvL Oct 8, 2018

Member

Thanks for the heads-up. It's strange: for some this pr causes no regressions, others see hangs. The majority of this PR consists of espes's refactoring work, in which he introduced a pusher thread, adds a caching layer, some additional signalling and moved all OpenGL calling code towards the puller thread. Any of those could contribute to the observed hang...

Member

PatrickvL replied Oct 8, 2018

Thanks for the heads-up. It's strange: for some this pr causes no regressions, others see hangs. The majority of this PR consists of espes's refactoring work, in which he introduced a pusher thread, adds a caching layer, some additional signalling and moved all OpenGL calling code towards the puller thread. Any of those could contribute to the observed hang...

Please sign in to comment.