Merge branch 'develop' into expp_handling

This commit is contained in:
PatrickvL 2019-11-20 17:02:55 +01:00 committed by GitHub
commit 7cac893aa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 3258 additions and 3174 deletions

View File

@ -225,6 +225,7 @@ file (GLOB CXBXR_SOURCE_COMMON
"${CXBXR_ROOT_DIR}/src/common/xbe/XbePrinter.cpp"
"${CXBXR_ROOT_DIR}/src/common/xdvdfs-tools/buffered_io.cpp"
"${CXBXR_ROOT_DIR}/src/common/xdvdfs-tools/xdvdfs.cpp"
"${CXBXR_ROOT_DIR}/src/CxbxVersion.cpp"
"${CXBXR_ROOT_DIR}/src/gui/DbgConsole.cpp"
"${CXBXR_ROOT_DIR}/src/HighPerformanceGraphicsEnabler.c"
)

View File

@ -1,19 +1,65 @@
Developers:
Luke Usher [SoullessSentinel]
PatrickvL
StrikerX3
blueshogun96
donwayo
hrydgard
jagotu
jarupxx
phire
x1nixmzeng
RadWolfie
Luca D'Amico (Luca1991/Luca91)
ergo720
Contributors
------------
Cxbx-Reloaded has a rich history, with lots of contributors in it's various stages of life.
Cxbx-Reloaded was initiated by Luke Usher, as a fork of the then-dormant Cxbx, and inspired by Dxbx.
Cxbx was initiated by Caustik. Dxbx was initiated by shadowtj.
The following contributors are grouped per project and listed in alphabetical order,
based on sources like https://github.com/Cxbx-Reloaded/Cxbx-Reloaded/graphs/contributors ,
http://www.caustik.com/cxbx/about.htm , http://emulation.gametechwiki.com/index.php/Cxbx ,
and https://github.com/PatrickvL/Dxbx/graphs/contributors .
Cxbx-Reloaded Current Development Team:
ergo720
LukeUsher (Luke Usher) [SoullessSentinel]
NZJenkins
PatrickvL (Patrick van Logchem)
RadWolfie
Cxbx-Reloaded All-Time Contributors:
aav7fl (Kyle Niewiada)
anita999
BenNottelling (Benjamin Aerni)
blueshogun96
CakeLancelot
darrena092 (Darren Anderson)
DiscoStarslayer (Darren Thompson)
donwayo (Wayo)
Ernegien (Mike Davis)
ergo720
faha223 (Fred Hallock)
Fisherman166
gandalfthewhite19890404
gellis713
ggKismet
GXTX (wutno)
hrydgard (Henrik Hydgard)
jackchentwkh
jagotu (JaGoTu)
jarupxx
JayFoxRox (Jannik Vogel)
literalmente-game
Luca1991 (Luca D'Amico) [Luca91]
LukeUsher (Luke Usher) [SoullessSentinel]
Margen67
NZJenkins
PatrickvL (Patrick van Logchem)
phire (Scott Mansell)
RadWolfie
revel8n
StrikerX3 (Ivan Roberto de Oliveira)
TotalCaesar659
Voxel9 (Voxel)
x1nixmzeng
Cxbx-Reloaded Supporters:
Supporters:
Cedric Wilson
Cisco Martinez
Cody Dale Barton
@ -33,5 +79,30 @@ Taylor Stock
Yldri
Yuri Kunde Schlesner
Special Thanks:
Cxbx-Reloaded Special Thanks:
All contributors to the original Cxbx and Dxbx projects, without which Cxbx-Reloaded would not exist.
Cxbx contributors:
_SF_
blueshogun96
Caustic (Aaron Robinson)
donwayo (Wayo)
dstien (Daniel Stien)
Echelon9 (Rhys Kidd)
Kingofc
Koitsu
martin_sw (Martin)
sopskrutt (Sop Skrutt)
Zomby
Dxbx contributors:
donwayo (Wayo)
PatrickvL (Patrick van Logchem)
revel8n
shadowtj (Shadow_tj)

61
COPYING
View File

@ -278,64 +278,3 @@ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

View File

@ -13,11 +13,11 @@
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources
// Language neutral resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
#pragma code_page(65001)
/////////////////////////////////////////////////////////////////////////////
//
@ -661,36 +661,6 @@ BEGIN
MENUITEM " ", ID_LOG,MFT_STRING,MFS_ENABLED
END
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English (United Kingdom) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
#pragma code_page(1252)
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_ABOUT, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 303
TOPMARGIN, 7
BOTTOMMARGIN, 170
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
@ -725,7 +695,8 @@ IDR_CONTRIBUTORS TXT "..\\CONTRIBUTORS"
IDR_COPYING TXT "..\\COPYING"
#endif // English (United Kingdom) resources
#endif // Language neutral resources
/////////////////////////////////////////////////////////////////////////////

26
setup.bat Normal file
View File

@ -0,0 +1,26 @@
@echo off
REM CXbx-Reloaded setup script
REM
REM Depends on git, cmake and Visual Studio being installed.
echo Pulling lastest version from git...
REM git clone --recurse-submodules https://github.com/Cxbx-Reloaded/Cxbx-Reloaded/
git pull --recurse-submodules
REM echo Synchronizing submodules...
REM git submodule update --init --recursive
echo Initializing most recent Visual Studio build environment...
@call "%VS140COMNTOOLS%vsvars32.bat"
echo Generating solution...
mkdir build
cd build
REM cmake .. -G "Visual Studio 16 2019" -A Win32
cmake .. -A Win32
echo Building solution...
cmake --build .
echo Done! Enjoy using Cxbx-Reloaded!

11
src/CxbxVersion.cpp Normal file
View File

@ -0,0 +1,11 @@
// This is an open source non-commercial project. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
#include "Version.h"
#include "CxbxVersion.h"
/*! version string dependent on trace flag */
#ifndef _DEBUG_TRACE
const char* CxbxVersionStr = _GIT_VERSION " (" __DATE__ ")";
#else
const char* CxbxVersionStr = _GIT_VERSION "-Trace (" __DATE__ ")";
#endif

View File

@ -2,9 +2,4 @@
#include "version.h"
/*! version string dependent on trace flag */
#ifndef _DEBUG_TRACE
#define _CXBX_VERSION _GIT_VERSION " (" __DATE__ ")"
#else
#define _CXBX_VERSION _GIT_VERSION "-Trace (" __DATE__ ")"
#endif
extern const char* CxbxVersionStr;

View File

@ -26,7 +26,7 @@
// ******************************************************************
#include "common\xbe\XbePrinter.h"
#include "CxbxVersion.h" // For _CXBX_VERSION
#include "CxbxVersion.h" // For CxbxVersionStr
#include <locale> // For ctime
#include <sstream> // For std::stringstream
@ -170,7 +170,9 @@ std::string XbePrinter::GameRatingToString()
std::string XbePrinter::GenDumpHeader()
{
std::string text;
text.append("XBE information generated by Cxbx-Reloaded (Version " _CXBX_VERSION ")\n\n");
text.append("XBE information generated by Cxbx-Reloaded (Version ");
text.append(CxbxVersionStr);
text.append(")\n\n");
text.append("Title identified as \"");
text.append(Xbe_to_print->m_szAsciiTitle);
text.append("\"\n\n");

View File

@ -141,6 +141,13 @@ static bool g_bHack_DisableHostGPUQueries = false; // TO
static IDirect3DQuery *g_pHostQueryWaitForIdle = nullptr;
static IDirect3DQuery *g_pHostQueryCallbackEvent = nullptr;
// Vertex shader symbols, declared in XbVertexShader.cpp :
extern void CxbxImpl_SelectVertexShaderDirect(XTL::X_VERTEXATTRIBUTEFORMAT* pVAF, DWORD Address);
extern void CxbxImpl_SetVertexShaderInput(DWORD Handle, UINT StreamCount, XTL::X_STREAMINPUT* pStreamInputs);
// Vertex buffer symbols, declared in XbVertexBuffer.cpp
extern void CxbxImpl_SetStreamSource(UINT StreamNumber, XTL::X_D3DVertexBuffer* pStreamData, UINT Stride);
static std::condition_variable g_VBConditionVariable; // Used in BlockUntilVerticalBlank
static std::mutex g_VBConditionMutex; // Used in BlockUntilVerticalBlank
static DWORD g_VBLastSwap = 0;
@ -173,9 +180,6 @@ static XTL::DWORD *g_Xbox_D3DDevice; // TODO: This should be a
static DWORD g_dwVertexShaderUsage = 0; // Unused. If needed, move to XbVertexShader.cpp
*/
// Active D3D Vertex Streams (and strides)
XTL::X_D3DVertexBuffer *g_D3DStreams[16];
XTL::UINT g_D3DStreamStrides[16];
static XTL::DWORD g_VertexShaderSlots[X_VSH_MAX_INSTRUCTION_COUNT];
XTL::DWORD g_Xbox_VertexShader_Handle = 0;
@ -3420,7 +3424,7 @@ XTL::X_D3DSurface* WINAPI XTL::EMUPATCH(D3DDevice_GetBackBuffer2)
/** unsafe, somehow
HRESULT hRet = D3D_OK;
X_D3DSurface *pBackBuffer = EmuNewD3DSurface();
X_D3DSurface *pXboxBackBuffer = EmuNewD3DSurface();
if(BackBuffer == -1) {
static IDirect3DSurface *pCachedPrimarySurface = nullptr;
@ -3432,21 +3436,21 @@ XTL::X_D3DSurface* WINAPI XTL::EMUPATCH(D3DDevice_GetBackBuffer2)
DEBUG_D3DRESULT(hRet, "g_pD3DDevice->CreateOffscreenPlainSurface");
}
SetHostSurface(pBackBuffer, pCachedPrimarySurface);
SetHostSurface(pXboxBackBuffer, pCachedPrimarySurface);
hRet = g_pD3DDevice->GetFrontBuffer(pCachedPrimarySurface);
DEBUG_D3DRESULT(hRet, "g_pD3DDevice->GetFrontBuffer");
if (FAILED(hRet)) {
EmuLog(LOG_LEVEL::WARNING, "Could not retrieve primary surface, using backbuffer");
SetHostSurface(pBackBuffer, nullptr);
SetHostSurface(pXboxBackBuffer, nullptr);
pCachedPrimarySurface->Release();
pCachedPrimarySurface = nullptr;
BackBuffer = 0;
}
// Debug: Save this image temporarily
//D3DXSaveSurfaceToFile("C:\\Aaron\\Textures\\FrontBuffer.bmp", D3DXIFF_BMP, GetHostSurface(pBackBuffer), nullptr, nullptr);
//D3DXSaveSurfaceToFile("C:\\Aaron\\Textures\\FrontBuffer.bmp", D3DXIFF_BMP, GetHostSurface(pXboxBackBuffer), nullptr, nullptr);
}
if(BackBuffer != -1) {
@ -3457,7 +3461,7 @@ XTL::X_D3DSurface* WINAPI XTL::EMUPATCH(D3DDevice_GetBackBuffer2)
}
//*/
static X_D3DSurface *pBackBuffer = EmuNewD3DSurface();
static X_D3DSurface *pXboxBackBuffer = EmuNewD3DSurface();
IDirect3DSurface *pCurrentHostBackBuffer = nullptr;
STATUS_SUCCESS;
@ -3474,12 +3478,12 @@ XTL::X_D3DSurface* WINAPI XTL::EMUPATCH(D3DDevice_GetBackBuffer2)
if (FAILED(hRet))
CxbxKrnlCleanup("Unable to retrieve back buffer");
SetHostSurface(pBackBuffer, pCurrentHostBackBuffer);
SetHostSurface(pXboxBackBuffer, pCurrentHostBackBuffer);
// Increment reference count
pBackBuffer->Common++; // EMUPATCH(D3DResource_AddRef)(pBackBuffer);
pXboxBackBuffer->Common++; // EMUPATCH(D3DResource_AddRef)(pXboxBackBuffer);
return pBackBuffer;
return pXboxBackBuffer;
#else // COPY_BACKBUFFER_TO_XBOX_SURFACE
// Rather than create a new surface, we should forward to the Xbox version of GetBackBuffer,
// This gives us the correct Xbox surface to update.
@ -3626,8 +3630,8 @@ void UpdateViewPortOffsetAndScaleConstants()
float vScale[] = { (2.0f / ViewPort.Width) * g_RenderScaleFactor, (-2.0f / ViewPort.Height) * g_RenderScaleFactor, 0.0f, 0.0f };
static float vOffset[] = { -1.0f, 1.0f, 0.0f, 1.0f };
g_pD3DDevice->SetVertexShaderConstantF(58, vScale, 1);
g_pD3DDevice->SetVertexShaderConstantF(59, vOffset, 1);
g_pD3DDevice->SetVertexShaderConstantF(X_D3DVS_RESERVED_CONSTANT1_CORRECTED, vScale, 1);
g_pD3DDevice->SetVertexShaderConstantF(X_D3DVS_RESERVED_CONSTANT2_CORRECTED, vOffset, 1);
}
}
@ -4368,7 +4372,7 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetVertexData2s)
float fa, fb;
// Test case: Halo
// Note : XQEMU recently verified that the int16_t arguments
// Note : XQEMU verified that the int16_t arguments
// must be mapped to floats in the range [-32768.0, 32767.0]
// (See https://github.com/xqemu/xqemu/pull/176)
fa = (float)a;
@ -4377,16 +4381,6 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetVertexData2s)
EMUPATCH(D3DDevice_SetVertexData4f)(Register, fa, fb, 0.0f, 1.0f);
}
DWORD FloatsToDWORD(FLOAT d, FLOAT a, FLOAT b, FLOAT c)
{
DWORD ca = (FtoDW(d) << 24);
DWORD cr = (FtoDW(a) << 16) & 0x00FF0000;
DWORD cg = (FtoDW(b) << 8) & 0x0000FF00;
DWORD cb = (FtoDW(c) << 0) & 0x000000FF;
return ca | cr | cg | cb;
}
extern uint32_t HLE_read_NV2A_pgraph_register(const int reg); // Declared in PushBuffer.cpp
extern void HLE_write_NV2A_vertex_attribute_slot(unsigned slot, uint32_t parameter); // Declared in PushBuffer.cpp
extern uint32_t HLE_read_NV2A_vertex_attribute_slot(unsigned VertexSlot); // Declared in PushBuffer.cpp
@ -4410,6 +4404,8 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetVertexData4f_16)
mov Register, edi
}
LOG_FORWARD("D3DDevice_SetVertexData4f");
EMUPATCH(D3DDevice_SetVertexData4f)(Register, a, b, c, d);
}
@ -4727,7 +4723,9 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetVertexData4s)
float fa, fb, fc, fd;
// Test case: Halo
// See comment note in D3DDevice_SetVertexData2s
// Note : XQEMU verified that the int16_t arguments
// must be mapped to floats in the range [-32768.0, 32767.0]
// (See https://github.com/xqemu/xqemu/pull/176)
fa = (float)a;
fb = (float)b;
fc = (float)c;
@ -4747,12 +4745,9 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetVertexDataColor)
{
LOG_FORWARD("D3DDevice_SetVertexData4f");
FLOAT a = ((Color & 0xFF000000) >> 24) / 255.0f;
FLOAT r = ((Color & 0x00FF0000) >> 16) / 255.0f;
FLOAT g = ((Color & 0x0000FF00) >> 8) / 255.0f;
FLOAT b = ((Color & 0x000000FF) >> 0) / 255.0f;
D3DXCOLOR XColor = Color;
EMUPATCH(D3DDevice_SetVertexData4f)(Register, r, g, b, a);
EMUPATCH(D3DDevice_SetVertexData4f)(Register, XColor.r, XColor.g, XColor.b, XColor.a);
}
// ******************************************************************
@ -6201,8 +6196,8 @@ VOID __fastcall XTL::EMUPATCH(D3DDevice_SetRenderState_Simple)
// Fetch the RenderState conversion info for the given input
int XboxRenderStateIndex = -1;
for (int i = 0; i <= X_D3DRS_DONOTCULLUNCOMPRESSED; i++) {
if (DxbxRenderStateInfo[i].M == PUSH_METHOD(Method)) {
for (int i = X_D3DRS_FIRST; i <= X_D3DRS_LAST; i++) {
if (GetDxbxRenderStateInfo(i).M == PUSH_METHOD(Method)) {
XboxRenderStateIndex = i;
break;
}
@ -6210,11 +6205,11 @@ VOID __fastcall XTL::EMUPATCH(D3DDevice_SetRenderState_Simple)
// If we could not map it, log and return
if (XboxRenderStateIndex == -1) {
EmuLog(LOG_LEVEL::WARNING, "RenderState_Simple(0x%.08X (%s), 0x%.08X) could not be found in RenderState table", Method, DxbxRenderStateInfo[XboxRenderStateIndex].S, Value);
EmuLog(LOG_LEVEL::WARNING, "RenderState_Simple(0x%.08X (%s), 0x%.08X) could not be found in RenderState table", Method, GetDxbxRenderStateInfo(XboxRenderStateIndex).S, Value);
return;
}
EmuLog(LOG_LEVEL::DEBUG, "RenderState_Simple: %s = 0x%08X", DxbxRenderStateInfo[XboxRenderStateIndex].S, Value);
EmuLog(LOG_LEVEL::DEBUG, "RenderState_Simple: %s = 0x%08X", GetDxbxRenderStateInfo(XboxRenderStateIndex).S, Value);
XboxRenderStates.SetXboxRenderState(XboxRenderStateIndex, Value);
}
@ -6405,15 +6400,12 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetStreamSource_4)
// LOG_FUNC_END;
EmuLog(LOG_LEVEL::DEBUG, "D3DDevice_SetStreamSource_4(StreamNumber : %08X pStreamData : %08X Stride : %08X);", StreamNumber, pStreamData, Stride);
// Forward to Xbox implementation
CxbxImpl_SetStreamSource(StreamNumber, pStreamData, Stride);
// TODO : Forward to Xbox implementation
// This should stop us having to patch GetStreamSource!
//XB_trampoline(VOID, WINAPI, D3DDevice_SetStreamSource_4, (UINT, X_D3DVertexBuffer*, UINT));
//XB_D3DDevice_SetStreamSource_4(StreamNumber, pStreamData, Stride);
if (StreamNumber < 16) {
g_D3DStreams[StreamNumber] = pStreamData;
g_D3DStreamStrides[StreamNumber] = Stride;
}
}
// This uses a custom calling convention where parameter is passed in EAX
@ -6438,15 +6430,12 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetStreamSource_8)
// LOG_FUNC_END;
EmuLog(LOG_LEVEL::DEBUG, "D3DDevice_SetStreamSource_8(StreamNumber : %08X pStreamData : %08X Stride : %08X);", StreamNumber, pStreamData, Stride);
CxbxImpl_SetStreamSource(StreamNumber, pStreamData, Stride);
// TODO : Forward to Xbox implementation
// This should stop us having to patch GetStreamSource!
//XB_trampoline(VOID, WINAPI, D3DDevice_SetStreamSource_8, (X_D3DVertexBuffer*, UINT));
//XB_D3DDevice_SetStreamSource_8(pStreamData, Stride);
if (StreamNumber < 16) {
g_D3DStreams[StreamNumber] = pStreamData;
g_D3DStreamStrides[StreamNumber] = Stride;
}
}
// ******************************************************************
@ -6465,19 +6454,12 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetStreamSource)
LOG_FUNC_ARG(Stride)
LOG_FUNC_END;
CxbxImpl_SetStreamSource(StreamNumber, pStreamData, Stride);
// Forward to Xbox implementation
// This should stop us having to patch GetStreamSource!
XB_trampoline(VOID, WINAPI, D3DDevice_SetStreamSource, (UINT, X_D3DVertexBuffer*, UINT));
XB_D3DDevice_SetStreamSource(StreamNumber, pStreamData, Stride);
if(pStreamData != xbnullptr && Stride == 0){
LOG_TEST_CASE("Stream stride set to 0");
}
if (StreamNumber < 16) {
g_D3DStreams[StreamNumber] = pStreamData;
g_D3DStreamStrides[StreamNumber] = Stride;
}
}
// ******************************************************************
@ -7808,7 +7790,7 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SelectVertexShaderDirect)
LOG_FUNC_ARG(Address)
LOG_FUNC_END;
LOG_UNIMPLEMENTED();
CxbxImpl_SelectVertexShaderDirect(pVAF, Address);
}
// ******************************************************************
@ -7933,16 +7915,19 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetVertexShaderInput)
LOG_FUNC_ARG(pStreamInputs)
LOG_FUNC_END;
// If Handle is NULL, all VertexShader input state is cleared.
// When this API is in effect, VertexBuffers as set by Xbox SetStreamSource are disregarded,
// instead, the pStreamInputs[].VertexBuffer streams are used.
// If Handle is NULL, all VertexShader input state is cleared (after which the VertexBuffers as set by SetStreamSource are used once again).
// Otherwise, Handle is the address of an Xbox VertexShader struct, or-ed with 1 (X_D3DFVF_RESERVED0)
// The given pStreamInputs are stored in a global array, and the NV2A is programmed to read
// each vertex attribute (as defined in the given VertexShader.VertexAttribute.Slots[]) to read
// the attribute data from the pStreamInputs[slot].VertexBuffer + pStreamInputs[slot].Offset + VertexShader.VertexAttribute.Slots[slot].Offset
LOG_UNIMPLEMENTED();
return;
CxbxImpl_SetVertexShaderInput(Handle, StreamCount, pStreamInputs);
}
// ******************************************************************
// * patch: D3DDevice_RunVertexStateShader
// ******************************************************************
@ -7957,6 +7942,9 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_RunVertexStateShader)
LOG_FUNC_ARG(pData)
LOG_FUNC_END;
// If pData is assigned, pData[0..3] is pushed towards nv2a transform data registers
// then sends the nv2a a command to launch the vertex shader function located at Address
LOG_UNIMPLEMENTED();
}

View File

@ -57,6 +57,17 @@ bool XboxRenderStateConverter::Init()
return true;
}
bool IsRenderStateAvailableInCurrentXboxD3D8Lib(RenderStateInfo& aRenderStateInfo)
{
bool bIsRenderStateAvailable = (aRenderStateInfo.V <= g_LibVersion_D3D8);
if (aRenderStateInfo.R > 0) { // Applies to XTL::X_D3DRS_MULTISAMPLETYPE
// Note : X_D3DRS_MULTISAMPLETYPE seems the only render state that got
// removed (from 4039 onwards), so we check that limitation here as well
bIsRenderStateAvailable &= (g_LibVersion_D3D8 < aRenderStateInfo.R);
}
return bIsRenderStateAvailable;
}
void XboxRenderStateConverter::VerifyAndFixDeferredRenderStateOffset()
{
DWORD CullModeOffset = g_SymbolAddresses["D3DRS_CULLMODE"];
@ -68,8 +79,9 @@ void XboxRenderStateConverter::VerifyAndFixDeferredRenderStateOffset()
// Calculate index of D3DRS_CULLMODE for this XDK. We start counting from the first deferred state (D3DRS_FOGENABLE)
DWORD CullModeIndex = 0;
for (int i = XTL::X_D3DRS_FOGENABLE; i < XTL::X_D3DRS_CULLMODE; i++) {
if (DxbxRenderStateInfo[i].V <= g_LibVersion_D3D8) {
for (int i = XTL::X_D3DRS_DEFERRED_FIRST; i < XTL::X_D3DRS_CULLMODE; i++) {
auto RenderStateInfo = GetDxbxRenderStateInfo(i);
if (IsRenderStateAvailableInCurrentXboxD3D8Lib(RenderStateInfo)) {
CullModeIndex++;
}
}
@ -85,22 +97,23 @@ void XboxRenderStateConverter::VerifyAndFixDeferredRenderStateOffset()
void XboxRenderStateConverter::DeriveRenderStateOffsetFromDeferredRenderStateOffset()
{
// When this function is called. D3D__RenderState actually points to the first deferred render state
// this is D3DRS_FOGENABLE. We can count back from this using our RenderStateInfo table to find
// (this is X_D3DRS_FOGENABLE). We can count back from this using our RenderStateInfo table to find
// the start of D3D__RenderStates.
// Count the number of render states (for this XDK) between 0 and D3DRS_FOGENABLE
int FogEnableOffset = 0;
for (unsigned int RenderState = XTL::X_D3DRS_PSALPHAINPUTS0; RenderState < XTL::X_D3DRS_FOGENABLE; RenderState++) {
// Count the number of render states (for this XDK) between 0 and the first deferred render state (D3DRS_FOGENABLE)
int FirstDeferredRenderStateOffset = 0;
for (unsigned int RenderState = XTL::X_D3DRS_FIRST; RenderState < XTL::X_D3DRS_DEFERRED_FIRST; RenderState++) {
// if the current renderstate exists in this XDK version, count it
if (DxbxRenderStateInfo[RenderState].V <= g_LibVersion_D3D8) {
FogEnableOffset++;
auto RenderStateInfo = GetDxbxRenderStateInfo(RenderState);
if (IsRenderStateAvailableInCurrentXboxD3D8Lib(RenderStateInfo)) {
FirstDeferredRenderStateOffset++;
}
}
// At this point, FogEnableOffset should point to the index of D3DRS_FOGENABLE for the given XDK
// At this point, FirstDeferredRenderStateOffset should point to the index of D3DRS_FOGENABLE for the given XDK
// This will be correct as long as our table DxbxRenderStateInfo is correct
// We can get the correct 0 offset by using a negative index
D3D__RenderState = &D3D__RenderState[-FogEnableOffset];
D3D__RenderState = &D3D__RenderState[-FirstDeferredRenderStateOffset];
}
void XboxRenderStateConverter::BuildRenderStateMappingTable()
@ -110,15 +123,16 @@ void XboxRenderStateConverter::BuildRenderStateMappingTable()
XboxRenderStateOffsets.fill(-1);
int XboxIndex = 0;
for (unsigned int RenderState = XTL::X_D3DRS_PSALPHAINPUTS0; RenderState <= XTL::X_D3DRS_LAST; RenderState++) {
if (DxbxRenderStateInfo[RenderState].V <= g_LibVersion_D3D8) {
for (unsigned int RenderState = XTL::X_D3DRS_FIRST; RenderState <= XTL::X_D3DRS_LAST; RenderState++) {
auto RenderStateInfo = GetDxbxRenderStateInfo(RenderState);
if (IsRenderStateAvailableInCurrentXboxD3D8Lib(RenderStateInfo)) {
XboxRenderStateOffsets[RenderState] = XboxIndex;
EmuLog(LOG_LEVEL::INFO, "%s = %d", DxbxRenderStateInfo[RenderState].S, XboxIndex);
EmuLog(LOG_LEVEL::INFO, "%s = %d", RenderStateInfo.S, XboxIndex);
XboxIndex++;
continue;
}
EmuLog(LOG_LEVEL::INFO, "%s Not Present", DxbxRenderStateInfo[RenderState].S);
EmuLog(LOG_LEVEL::INFO, "%s Not Present", RenderStateInfo.S);
}
}
@ -153,7 +167,7 @@ bool XboxRenderStateConverter::XboxRenderStateValueChanged(uint32_t State)
void XboxRenderStateConverter::SetXboxRenderState(uint32_t State, uint32_t Value)
{
if (!XboxRenderStateExists(State)) {
EmuLog(LOG_LEVEL::WARNING, "Attempt to write a Renderstate (%s) that does not exist in the current D3D8 XDK Version (%d)", DxbxRenderStateInfo[State].S, g_LibVersion_D3D8);
EmuLog(LOG_LEVEL::WARNING, "Attempt to write a Renderstate (%s) that does not exist in the current D3D8 XDK Version (%d)", GetDxbxRenderStateInfo(State).S, g_LibVersion_D3D8);
return;
}
@ -163,7 +177,7 @@ void XboxRenderStateConverter::SetXboxRenderState(uint32_t State, uint32_t Value
uint32_t XboxRenderStateConverter::GetXboxRenderState(uint32_t State)
{
if (!XboxRenderStateExists(State)) {
EmuLog(LOG_LEVEL::WARNING, "Attempt to read a Renderstate (%s) that does not exist in the current D3D8 XDK Version (%d)", DxbxRenderStateInfo[State].S, g_LibVersion_D3D8);
EmuLog(LOG_LEVEL::WARNING, "Attempt to read a Renderstate (%s) that does not exist in the current D3D8 XDK Version (%d)", GetDxbxRenderStateInfo(State).S, g_LibVersion_D3D8);
return 0;
}
@ -172,7 +186,7 @@ uint32_t XboxRenderStateConverter::GetXboxRenderState(uint32_t State)
void XboxRenderStateConverter::StoreInitialValues()
{
for (unsigned int RenderState = XTL::X_D3DRS_PSALPHAINPUTS0; RenderState <= XTL::X_D3DRS_LAST; RenderState++) {
for (unsigned int RenderState = XTL::X_D3DRS_FIRST; RenderState <= XTL::X_D3DRS_LAST; RenderState++) {
// Skip Render States that don't exist within this XDK
if (!XboxRenderStateExists(RenderState)) {
continue;
@ -203,7 +217,7 @@ void XboxRenderStateConverter::Apply()
}
auto Value = GetXboxRenderState(RenderState);
EmuLog(LOG_LEVEL::DEBUG, "XboxRenderStateConverter::Apply(%s, %X)\n", DxbxRenderStateInfo[RenderState].S, Value);
EmuLog(LOG_LEVEL::DEBUG, "XboxRenderStateConverter::Apply(%s, %X)\n", GetDxbxRenderStateInfo(RenderState).S, Value);
if (RenderState <= XTL::X_D3DRS_SIMPLE_LAST) {
ApplySimpleRenderState(RenderState, Value);
@ -219,6 +233,8 @@ void XboxRenderStateConverter::Apply()
void XboxRenderStateConverter::ApplySimpleRenderState(uint32_t State, uint32_t Value)
{
auto RenderStateInfo = GetDxbxRenderStateInfo(State);
switch (State) {
case XTL::X_D3DRS_COLORWRITEENABLE: {
DWORD OrigValue = Value;
@ -278,22 +294,24 @@ void XboxRenderStateConverter::ApplySimpleRenderState(uint32_t State, uint32_t V
break;
default:
// Only log missing state if it has a PC counterpart
if (DxbxRenderStateInfo[State].PC != 0) {
EmuLog(LOG_LEVEL::WARNING, "ApplySimpleRenderState(%s, 0x%.08X) is unimplemented!", DxbxRenderStateInfo[State].S, Value);
if (RenderStateInfo.PC != 0) {
EmuLog(LOG_LEVEL::WARNING, "ApplySimpleRenderState(%s, 0x%.08X) is unimplemented!", RenderStateInfo.S, Value);
}
return;
}
// Skip RenderStates that don't have a defined PC counterpart
if (DxbxRenderStateInfo[State].PC == 0) {
if (RenderStateInfo.PC == 0) {
return;
}
g_pD3DDevice->SetRenderState((D3DRENDERSTATETYPE)(DxbxRenderStateInfo[State].PC), Value);
g_pD3DDevice->SetRenderState((D3DRENDERSTATETYPE)(RenderStateInfo.PC), Value);
}
void XboxRenderStateConverter::ApplyDeferredRenderState(uint32_t State, uint32_t Value)
{
auto RenderStateInfo = GetDxbxRenderStateInfo(State);
// Convert from Xbox Data Formats to PC
switch (State) {
case XTL::X_D3DRS_FOGSTART:
@ -373,22 +391,24 @@ void XboxRenderStateConverter::ApplyDeferredRenderState(uint32_t State, uint32_t
} break;
default:
// Only log missing state if it has a PC counterpart
if (DxbxRenderStateInfo[State].PC != 0) {
EmuLog(LOG_LEVEL::WARNING, "ApplyDeferredRenderState(%s, 0x%.08X) is unimplemented!", DxbxRenderStateInfo[State].S, Value);
if (RenderStateInfo.PC != 0) {
EmuLog(LOG_LEVEL::WARNING, "ApplyDeferredRenderState(%s, 0x%.08X) is unimplemented!", RenderStateInfo.S, Value);
}
return;
}
// Skip RenderStates that don't have a defined PC counterpart
if (DxbxRenderStateInfo[State].PC == 0) {
if (RenderStateInfo.PC == 0) {
return;
}
g_pD3DDevice->SetRenderState(DxbxRenderStateInfo[State].PC, Value);
g_pD3DDevice->SetRenderState(RenderStateInfo.PC, Value);
}
void XboxRenderStateConverter::ApplyComplexRenderState(uint32_t State, uint32_t Value)
{
auto RenderStateInfo = GetDxbxRenderStateInfo(State);
switch (State) {
case XTL::X_D3DRS_VERTEXBLEND:
// convert from Xbox direct3d to PC direct3d enumeration
@ -439,16 +459,16 @@ void XboxRenderStateConverter::ApplyComplexRenderState(uint32_t State, uint32_t
break;
default:
// Only log missing state if it has a PC counterpart
if (DxbxRenderStateInfo[State].PC != 0) {
EmuLog(LOG_LEVEL::WARNING, "ApplyComplexRenderState(%s, 0x%.08X) is unimplemented!", DxbxRenderStateInfo[State].S, Value);
if (RenderStateInfo.PC != 0) {
EmuLog(LOG_LEVEL::WARNING, "ApplyComplexRenderState(%s, 0x%.08X) is unimplemented!", RenderStateInfo.S, Value);
}
return;
}
// Skip RenderStates that don't have a defined PC counterpart
if (DxbxRenderStateInfo[State].PC == 0) {
if (RenderStateInfo.PC == 0) {
return;
}
g_pD3DDevice->SetRenderState(DxbxRenderStateInfo[State].PC, Value);
g_pD3DDevice->SetRenderState(RenderStateInfo.PC, Value);
}

View File

@ -28,7 +28,9 @@
#define LOG_PREFIX CXBXR_MODULE::D3DCVT
#include "common\Settings.hpp" // for g_LibVersion_D3D8
#include "core\kernel\support\Emu.h"
#include "XbConvert.h"
// About format color components:
@ -1331,6 +1333,14 @@ void EmuUnswizzleBox
}
} // EmuUnswizzleBox NOPATCH
// Notes :
// * most renderstates were introduced in the (lowest known) XDK version : 3424
// * additional renderstates were introduced between 3434 and 4627
// * we MUST list exact versions for each of those, since their inserts impacts mapping!
// * renderstates were finalized in 4627 (so no change after that version)
// * renderstates after D3DRS_MULTISAMPLEMASK have no host mapping, thus no impact
// * D3DRS_MULTISAMPLETYPE seems the only renderstate that got removed (after 3944, before 4039)
// * all renderstates marked 3424 are also verified present in 3944
const RenderStateInfo DxbxRenderStateInfo[] = {
// String Ord Version Type Method Native
@ -1413,69 +1423,70 @@ const RenderStateInfo DxbxRenderStateInfo[] = {
{ "D3DRS_BLENDCOLOR" /*= 75*/, 3424, xtD3DCOLOR, NV2A_BLEND_COLOR, D3DRS_BLENDFACTOR, "D3DCOLOR for D3DBLEND_CONSTANTCOLOR" },
// D3D9 D3DRS_BLENDFACTOR : D3DCOLOR used for a constant blend factor during alpha blending for devices that support D3DPBLENDCAPS_BLENDFACTOR
{ "D3DRS_SWATHWIDTH" /*= 76*/, 3424, xtD3DSWATH, NV2A_SWATH_WIDTH },
{ "D3DRS_POLYGONOFFSETZSLOPESCALE" /*= 77*/, 3424, xtFloat, NV2A_POLYGON_OFFSET_FACTOR, D3DRS_NONE, "float Z factor for shadow maps" },
{ "D3DRS_POLYGONOFFSETZSLOPESCALE" /*= 77*/, 3424, xtFloat, NV2A_POLYGON_OFFSET_FACTOR, D3DRS_UNSUPPORTED, "float Z factor for shadow maps" },
{ "D3DRS_POLYGONOFFSETZOFFSET" /*= 78*/, 3424, xtFloat, NV2A_POLYGON_OFFSET_UNITS },
{ "D3DRS_POINTOFFSETENABLE" /*= 79*/, 3424, xtBOOL, NV2A_POLYGON_OFFSET_POINT_ENABLE },
{ "D3DRS_WIREFRAMEOFFSETENABLE" /*= 80*/, 3424, xtBOOL, NV2A_POLYGON_OFFSET_LINE_ENABLE },
{ "D3DRS_SOLIDOFFSETENABLE" /*= 81*/, 3424, xtBOOL, NV2A_POLYGON_OFFSET_FILL_ENABLE },
{ "D3DRS_DEPTHCLIPCONTROL" /*= 82*/, 4432, xtD3DDCC, NV2A_DEPTHCLIPCONTROL },
{ "D3DRS_STIPPLEENABLE" /*= 83*/, 4627, xtBOOL, NV2A_POLYGON_STIPPLE_ENABLE },
{ "D3DRS_SIMPLE_UNUSED8" /*= 84*/, 4627, xtDWORD, 0 },
{ "D3DRS_SIMPLE_UNUSED7" /*= 85*/, 4627, xtDWORD, 0 },
{ "D3DRS_SIMPLE_UNUSED6" /*= 86*/, 4627, xtDWORD, 0 },
{ "D3DRS_SIMPLE_UNUSED5" /*= 87*/, 4627, xtDWORD, 0 },
{ "D3DRS_SIMPLE_UNUSED4" /*= 88*/, 4627, xtDWORD, 0 },
{ "D3DRS_SIMPLE_UNUSED3" /*= 89*/, 4627, xtDWORD, 0 },
{ "D3DRS_SIMPLE_UNUSED2" /*= 90*/, 4627, xtDWORD, 0 },
{ "D3DRS_SIMPLE_UNUSED1" /*= 91*/, 4627, xtDWORD, 0 },
{ "D3DRS_DEPTHCLIPCONTROL" /*= 82*/, 4432, xtD3DDCC, NV2A_DEPTHCLIPCONTROL }, // Verified absent in 4361, present in 4432 TODO : Might be introduced around 4400?
{ "D3DRS_STIPPLEENABLE" /*= 83*/, 4627, xtBOOL, NV2A_POLYGON_STIPPLE_ENABLE }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between?
{ "D3DRS_SIMPLE_UNUSED8" /*= 84*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between?
{ "D3DRS_SIMPLE_UNUSED7" /*= 85*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between?
{ "D3DRS_SIMPLE_UNUSED6" /*= 86*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between?
{ "D3DRS_SIMPLE_UNUSED5" /*= 87*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between?
{ "D3DRS_SIMPLE_UNUSED4" /*= 88*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between?
{ "D3DRS_SIMPLE_UNUSED3" /*= 89*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between?
{ "D3DRS_SIMPLE_UNUSED2" /*= 90*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between?
{ "D3DRS_SIMPLE_UNUSED1" /*= 91*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between?
// End of "simple" render states, continuing with "deferred" render states :
{ "D3DRS_FOGENABLE" /*= 92*/, 3424, xtBOOL, NV2A_FOG_ENABLE, D3DRS_FOGENABLE },
{ "D3DRS_FOGTABLEMODE" /*= 93*/, 3424, xtD3DFOGMODE, NV2A_FOG_MODE, D3DRS_FOGTABLEMODE },
{ "D3DRS_FOGSTART" /*= 94*/, 3424, xtFloat, NV2A_FOG_COORD_DIST, D3DRS_FOGSTART },
{ "D3DRS_FOGEND" /*= 95*/, 3424, xtFloat, NV2A_FOG_MODE, D3DRS_FOGEND },
{ "D3DRS_FOGDENSITY" /*= 96*/, 3424, xtFloat, NV2A_FOG_EQUATION_CONSTANT, D3DRS_FOGDENSITY }, // + NV2A_FOG_EQUATION_LINEAR + NV2A_FOG_EQUATION_QUADRATIC
{ "D3DRS_RANGEFOGENABLE" /*= 97*/, 3424, xtBOOL, NV2A_FOG_COORD_DIST, D3DRS_RANGEFOGENABLE },
{ "D3DRS_WRAP0" /*= 98*/, 3424, xtD3DWRAP, NV2A_TX_WRAP(0), D3DRS_WRAP0 },
{ "D3DRS_WRAP1" /*= 99*/, 3424, xtD3DWRAP, NV2A_TX_WRAP(1), D3DRS_WRAP1 },
{ "D3DRS_WRAP2" /*= 100*/, 3424, xtD3DWRAP, NV2A_TX_WRAP(2), D3DRS_WRAP2 },
{ "D3DRS_WRAP3" /*= 101*/, 3424, xtD3DWRAP, NV2A_TX_WRAP(3), D3DRS_WRAP3 },
{ "D3DRS_LIGHTING" /*= 102*/, 3424, xtBOOL, NV2A_LIGHT_MODEL, D3DRS_LIGHTING }, // TODO : Needs push-buffer data conversion
{ "D3DRS_SPECULARENABLE" /*= 103*/, 3424, xtBOOL, NV2A_RC_FINAL0, D3DRS_SPECULARENABLE },
{ "D3DRS_LOCALVIEWER" /*= 104*/, 3424, xtBOOL, 0, D3DRS_LOCALVIEWER },
{ "D3DRS_COLORVERTEX" /*= 105*/, 3424, xtBOOL, 0, D3DRS_COLORVERTEX },
{ "D3DRS_BACKSPECULARMATERIALSOURCE" /*= 106*/, 3424, xtD3DMCS, 0 }, // nsp.
{ "D3DRS_BACKDIFFUSEMATERIALSOURCE" /*= 107*/, 3424, xtD3DMCS, 0 }, // nsp.
{ "D3DRS_BACKAMBIENTMATERIALSOURCE" /*= 108*/, 3424, xtD3DMCS, 0 }, // nsp.
{ "D3DRS_BACKEMISSIVEMATERIALSOURCE" /*= 109*/, 3424, xtD3DMCS, 0 }, // nsp.
{ "D3DRS_SPECULARMATERIALSOURCE" /*= 110*/, 3424, xtD3DMCS, NV2A_COLOR_MATERIAL, D3DRS_SPECULARMATERIALSOURCE },
{ "D3DRS_DIFFUSEMATERIALSOURCE" /*= 111*/, 3424, xtD3DMCS, 0, D3DRS_DIFFUSEMATERIALSOURCE },
{ "D3DRS_AMBIENTMATERIALSOURCE" /*= 112*/, 3424, xtD3DMCS, 0, D3DRS_AMBIENTMATERIALSOURCE },
{ "D3DRS_EMISSIVEMATERIALSOURCE" /*= 113*/, 3424, xtD3DMCS, 0, D3DRS_EMISSIVEMATERIALSOURCE },
{ "D3DRS_BACKAMBIENT" /*= 114*/, 3424, xtD3DCOLOR, NV2A_LIGHT_MODEL_BACK_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_R }, // ..NV2A_MATERIAL_FACTOR_BACK_B nsp. Was NV2A_LIGHT_MODEL_BACK_AMBIENT_R
{ "D3DRS_AMBIENT" /*= 115*/, 3424, xtD3DCOLOR, NV2A_LIGHT_MODEL_FRONT_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_R, D3DRS_AMBIENT }, // ..NV2A_LIGHT_MODEL_FRONT_AMBIENT_B + NV2A_MATERIAL_FACTOR_FRONT_R..NV2A_MATERIAL_FACTOR_FRONT_A Was NV2A_LIGHT_MODEL_FRONT_AMBIENT_R
{ "D3DRS_POINTSIZE" /*= 116*/, 3424, xtFloat, NV2A_POINT_PARAMETER(0), D3DRS_POINTSIZE },
{ "D3DRS_POINTSIZE_MIN" /*= 117*/, 3424, xtFloat, 0, D3DRS_POINTSIZE_MIN },
{ "D3DRS_POINTSPRITEENABLE" /*= 118*/, 3424, xtBOOL, NV2A_POINT_SMOOTH_ENABLE, D3DRS_POINTSPRITEENABLE },
{ "D3DRS_POINTSCALEENABLE" /*= 119*/, 3424, xtBOOL, NV2A_POINT_PARAMETERS_ENABLE, D3DRS_POINTSCALEENABLE },
{ "D3DRS_POINTSCALE_A" /*= 120*/, 3424, xtFloat, 0, D3DRS_POINTSCALE_A },
{ "D3DRS_POINTSCALE_B" /*= 121*/, 3424, xtFloat, 0, D3DRS_POINTSCALE_B },
{ "D3DRS_POINTSCALE_C" /*= 122*/, 3424, xtFloat, 0, D3DRS_POINTSCALE_C },
{ "D3DRS_POINTSIZE_MAX" /*= 123*/, 3424, xtFloat, 0, D3DRS_POINTSIZE_MAX },
{ "D3DRS_PATCHEDGESTYLE" /*= 124*/, 3424, xtDWORD, 0, D3DRS_PATCHEDGESTYLE }, // D3DPATCHEDGESTYLE?
{ "D3DRS_PATCHSEGMENTS" /*= 125*/, 3424, xtDWORD, 0 }, // nsp. // D3DRS_PATCHSEGMENTS exists in Direct3D 8, but not in 9 !?
// Verified as XDK 3911 Deferred RenderStates (3424 yet to do)
{ "D3DRS_FOGENABLE" /*= 92*/, 3424, xtBOOL, NV2A_FOG_ENABLE, D3DRS_FOGENABLE }, // TRUE to enable fog blending
{ "D3DRS_FOGTABLEMODE" /*= 93*/, 3424, xtD3DFOGMODE, NV2A_FOG_MODE, D3DRS_FOGTABLEMODE }, // D3DFOGMODE
{ "D3DRS_FOGSTART" /*= 94*/, 3424, xtFloat, NV2A_FOG_COORD_DIST, D3DRS_FOGSTART }, // float fog start (for both vertex and pixel fog)
{ "D3DRS_FOGEND" /*= 95*/, 3424, xtFloat, NV2A_FOG_MODE, D3DRS_FOGEND }, // float fog end
{ "D3DRS_FOGDENSITY" /*= 96*/, 3424, xtFloat, NV2A_FOG_EQUATION_CONSTANT, D3DRS_FOGDENSITY }, // float fog density // + NV2A_FOG_EQUATION_LINEAR + NV2A_FOG_EQUATION_QUADRATIC
{ "D3DRS_RANGEFOGENABLE" /*= 97*/, 3424, xtBOOL, NV2A_FOG_COORD_DIST, D3DRS_RANGEFOGENABLE }, // TRUE to enable range-based fog
{ "D3DRS_WRAP0" /*= 98*/, 3424, xtD3DWRAP, NV2A_TX_WRAP(0), D3DRS_WRAP0 }, // D3DWRAP* flags (D3DWRAP_U, D3DWRAPCOORD_0, etc.) for 1st texture coord.
{ "D3DRS_WRAP1" /*= 99*/, 3424, xtD3DWRAP, NV2A_TX_WRAP(1), D3DRS_WRAP1 }, // D3DWRAP* flags (D3DWRAP_U, D3DWRAPCOORD_0, etc.) for 2nd texture coord.
{ "D3DRS_WRAP2" /*= 100*/, 3424, xtD3DWRAP, NV2A_TX_WRAP(2), D3DRS_WRAP2 }, // D3DWRAP* flags (D3DWRAP_U, D3DWRAPCOORD_0, etc.) for 3rd texture coord.
{ "D3DRS_WRAP3" /*= 101*/, 3424, xtD3DWRAP, NV2A_TX_WRAP(3), D3DRS_WRAP3 }, // D3DWRAP* flags (D3DWRAP_U, D3DWRAPCOORD_0, etc.) for 4th texture coord.
{ "D3DRS_LIGHTING" /*= 102*/, 3424, xtBOOL, NV2A_LIGHT_MODEL, D3DRS_LIGHTING }, // TRUE to enable lighting // TODO : Needs push-buffer data conversion
{ "D3DRS_SPECULARENABLE" /*= 103*/, 3424, xtBOOL, NV2A_RC_FINAL0, D3DRS_SPECULARENABLE }, // TRUE to enable specular
{ "D3DRS_LOCALVIEWER" /*= 104*/, 3424, xtBOOL, 0, D3DRS_LOCALVIEWER }, // TRUE to enable camera-relative specular highlights
{ "D3DRS_COLORVERTEX" /*= 105*/, 3424, xtBOOL, 0, D3DRS_COLORVERTEX }, // TRUE to enable per-vertex color
{ "D3DRS_BACKSPECULARMATERIALSOURCE" /*= 106*/, 3424, xtD3DMCS, 0 }, // D3DMATERIALCOLORSOURCE (Xbox extension) nsp.
{ "D3DRS_BACKDIFFUSEMATERIALSOURCE" /*= 107*/, 3424, xtD3DMCS, 0 }, // D3DMATERIALCOLORSOURCE (Xbox extension) nsp.
{ "D3DRS_BACKAMBIENTMATERIALSOURCE" /*= 108*/, 3424, xtD3DMCS, 0 }, // D3DMATERIALCOLORSOURCE (Xbox extension) nsp.
{ "D3DRS_BACKEMISSIVEMATERIALSOURCE" /*= 109*/, 3424, xtD3DMCS, 0 }, // D3DMATERIALCOLORSOURCE (Xbox extension) nsp.
{ "D3DRS_SPECULARMATERIALSOURCE" /*= 110*/, 3424, xtD3DMCS, NV2A_COLOR_MATERIAL, D3DRS_SPECULARMATERIALSOURCE }, // D3DMATERIALCOLORSOURCE
{ "D3DRS_DIFFUSEMATERIALSOURCE" /*= 111*/, 3424, xtD3DMCS, 0, D3DRS_DIFFUSEMATERIALSOURCE }, // D3DMATERIALCOLORSOURCE
{ "D3DRS_AMBIENTMATERIALSOURCE" /*= 112*/, 3424, xtD3DMCS, 0, D3DRS_AMBIENTMATERIALSOURCE }, // D3DMATERIALCOLORSOURCE
{ "D3DRS_EMISSIVEMATERIALSOURCE" /*= 113*/, 3424, xtD3DMCS, 0, D3DRS_EMISSIVEMATERIALSOURCE }, // D3DMATERIALCOLORSOURCE
{ "D3DRS_BACKAMBIENT" /*= 114*/, 3424, xtD3DCOLOR, NV2A_LIGHT_MODEL_BACK_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_R }, // D3DCOLOR (Xbox extension) // ..NV2A_MATERIAL_FACTOR_BACK_B nsp. Was NV2A_LIGHT_MODEL_BACK_AMBIENT_R
{ "D3DRS_AMBIENT" /*= 115*/, 3424, xtD3DCOLOR, NV2A_LIGHT_MODEL_FRONT_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_R, D3DRS_AMBIENT }, // D3DCOLOR // ..NV2A_LIGHT_MODEL_FRONT_AMBIENT_B + NV2A_MATERIAL_FACTOR_FRONT_R..NV2A_MATERIAL_FACTOR_FRONT_A Was NV2A_LIGHT_MODEL_FRONT_AMBIENT_R
{ "D3DRS_POINTSIZE" /*= 116*/, 3424, xtFloat, NV2A_POINT_PARAMETER(0), D3DRS_POINTSIZE }, // float point size
{ "D3DRS_POINTSIZE_MIN" /*= 117*/, 3424, xtFloat, 0, D3DRS_POINTSIZE_MIN }, // float point size min threshold
{ "D3DRS_POINTSPRITEENABLE" /*= 118*/, 3424, xtBOOL, NV2A_POINT_SMOOTH_ENABLE, D3DRS_POINTSPRITEENABLE }, // TRUE to enable point sprites
{ "D3DRS_POINTSCALEENABLE" /*= 119*/, 3424, xtBOOL, NV2A_POINT_PARAMETERS_ENABLE, D3DRS_POINTSCALEENABLE }, // TRUE to enable point size scaling
{ "D3DRS_POINTSCALE_A" /*= 120*/, 3424, xtFloat, 0, D3DRS_POINTSCALE_A }, // float point attenuation A value
{ "D3DRS_POINTSCALE_B" /*= 121*/, 3424, xtFloat, 0, D3DRS_POINTSCALE_B }, // float point attenuation B value
{ "D3DRS_POINTSCALE_C" /*= 122*/, 3424, xtFloat, 0, D3DRS_POINTSCALE_C }, // float point attenuation C value
{ "D3DRS_POINTSIZE_MAX" /*= 123*/, 3424, xtFloat, 0, D3DRS_POINTSIZE_MAX }, // float point size max threshold
{ "D3DRS_PATCHEDGESTYLE" /*= 124*/, 3424, xtDWORD, 0, D3DRS_PATCHEDGESTYLE }, // D3DPATCHEDGESTYLE
{ "D3DRS_PATCHSEGMENTS" /*= 125*/, 3424, xtDWORD, 0 }, // DWORD number of segments per edge when drawing patches, nsp (D3DRS_PATCHSEGMENTS exists in Direct3D 8, but not in 9)
// TODO -oDxbx : Is X_D3DRS_SWAPFILTER really a xtD3DMULTISAMPLE_TYPE?
{ "D3DRS_SWAPFILTER" /*= 126*/, 4039, xtD3DMULTISAMPLE_TYPE, 0, D3DRS_NONE, "D3DTEXF_LINEAR etc. filter to use for Swap" }, // nsp.
{ "D3DRS_PRESENTATIONINTERVAL" /*= 127*/, 4627, xtDWORD, 0 }, // nsp.
{ "D3DRS_DEFERRED_UNUSED8" /*= 128*/, 4627, xtDWORD, 0 },
{ "D3DRS_DEFERRED_UNUSED7" /*= 129*/, 4627, xtDWORD, 0 },
{ "D3DRS_DEFERRED_UNUSED6" /*= 130*/, 4627, xtDWORD, 0 },
{ "D3DRS_DEFERRED_UNUSED5" /*= 131*/, 4627, xtDWORD, 0 },
{ "D3DRS_DEFERRED_UNUSED4" /*= 132*/, 4627, xtDWORD, 0 },
{ "D3DRS_DEFERRED_UNUSED3" /*= 133*/, 4627, xtDWORD, 0 },
{ "D3DRS_DEFERRED_UNUSED2" /*= 134*/, 4627, xtDWORD, 0 },
{ "D3DRS_DEFERRED_UNUSED1" /*= 135*/, 4627, xtDWORD, 0 },
{ "D3DRS_SWAPFILTER" /*= 126*/, 4039, xtD3DMULTISAMPLE_TYPE, 0, D3DRS_UNSUPPORTED, "D3DTEXF_LINEAR etc. filter to use for Swap" }, // nsp. Verified absent in 3944, present in 4039 TODO : Might be introduced in 4034?
{ "D3DRS_PRESENTATIONINTERVAL" /*= 127*/, 4627, xtDWORD, 0 }, // nsp. Verified absent in 4531, present in 4627 TODO : might be introduced in between?
{ "D3DRS_DEFERRED_UNUSED8" /*= 128*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between?
{ "D3DRS_DEFERRED_UNUSED7" /*= 129*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between?
{ "D3DRS_DEFERRED_UNUSED6" /*= 130*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between?
{ "D3DRS_DEFERRED_UNUSED5" /*= 131*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between?
{ "D3DRS_DEFERRED_UNUSED4" /*= 132*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between?
{ "D3DRS_DEFERRED_UNUSED3" /*= 133*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between?
{ "D3DRS_DEFERRED_UNUSED2" /*= 134*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between?
{ "D3DRS_DEFERRED_UNUSED1" /*= 135*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between?
// End of "deferred" render states, continuing with "complex" render states :
{ "D3DRS_PSTEXTUREMODES" /*= 136*/, 3424, xtDWORD, 0 },
{ "D3DRS_PSTEXTUREMODES" /*= 136*/, 3424, xtDWORD, 0 }, // This is where pPSDef->PSTextureModes is stored (outside the pPSDEF - see DxbxUpdateActivePixelShader)
{ "D3DRS_VERTEXBLEND" /*= 137*/, 3424, xtD3DVERTEXBLENDFLAGS, NV2A_SKIN_MODE, D3DRS_VERTEXBLEND },
{ "D3DRS_FOGCOLOR" /*= 138*/, 3424, xtD3DCOLOR, NV2A_FOG_COLOR, D3DRS_FOGCOLOR }, // SwapRgb
{ "D3DRS_FILLMODE" /*= 139*/, 3424, xtD3DFILLMODE, NV2A_POLYGON_MODE_FRONT, D3DRS_FILLMODE },
@ -1493,21 +1504,26 @@ const RenderStateInfo DxbxRenderStateInfo[] = {
{ "D3DRS_EDGEANTIALIAS" /*= 151*/, 3424, xtBOOL, NV2A_LINE_SMOOTH_ENABLE, D3DRS_ANTIALIASEDLINEENABLE }, // Was D3DRS_EDGEANTIALIAS. Dxbx note : No Xbox ext. (according to Direct3D8) !
{ "D3DRS_MULTISAMPLEANTIALIAS" /*= 152*/, 3424, xtBOOL, NV2A_MULTISAMPLE_CONTROL, D3DRS_MULTISAMPLEANTIALIAS },
{ "D3DRS_MULTISAMPLEMASK" /*= 153*/, 3424, xtDWORD, NV2A_MULTISAMPLE_CONTROL, D3DRS_MULTISAMPLEMASK },
// { "D3DRS_MULTISAMPLETYPE" /*= 154*/, 3424, xtD3DMULTISAMPLE_TYPE, 0 }, // [-3911] \_ aliasses D3DMULTISAMPLE_TYPE
{ "D3DRS_MULTISAMPLEMODE" /*= 154*/, 3425 /* really 4361 but shares slot with previous entry */, xtD3DMULTISAMPLEMODE, 0 }, // [4361+] / D3DMULTISAMPLEMODE for the backbuffer
{ "D3DRS_MULTISAMPLERENDERTARGETMODE" /*= 155*/, 4242, xtD3DMULTISAMPLEMODE, NV2A_RT_FORMAT },
{ "D3DRS_SHADOWFUNC" /*= 156*/, 3424, xtD3DCMPFUNC, NV2A_TX_RCOMP },
{ "D3DRS_LINEWIDTH" /*= 157*/, 3424, xtFloat, NV2A_LINE_WIDTH },
{ "D3DRS_SAMPLEALPHA" /*= 158*/, 4627, xtD3DSAMPLEALPHA, 0 }, // TODO : Later than 3424, but earlier then 4627?
{ "D3DRS_DXT1NOISEENABLE" /*= 159*/, 3424, xtBOOL, NV2A_CLEAR_DEPTH_VALUE },
{ "D3DRS_YUVENABLE" /*= 160*/, 3911, xtBOOL, NV2A_CONTROL0 },
{ "D3DRS_OCCLUSIONCULLENABLE" /*= 161*/, 3911, xtBOOL, NV2A_OCCLUDE_ZSTENCIL_EN },
{ "D3DRS_STENCILCULLENABLE" /*= 162*/, 3911, xtBOOL, NV2A_OCCLUDE_ZSTENCIL_EN },
{ "D3DRS_ROPZCMPALWAYSREAD" /*= 163*/, 3911, xtBOOL, 0 },
{ "D3DRS_ROPZREAD" /*= 164*/, 3911, xtBOOL, 0 },
{ "D3DRS_DONOTCULLUNCOMPRESSED" /*= 165*/, 3911, xtBOOL, 0 }
{ "D3DRS_MULTISAMPLETYPE" /*= 154*/, 3424, xtD3DMULTISAMPLE_TYPE, 0, D3DRS_UNSUPPORTED, "aliasses D3DMULTISAMPLE_TYPE, removed from 4039 onward", 4039 }, // Verified present in 3944, removed in 4039 TODO : Might be removed in 4034?
{ "D3DRS_MULTISAMPLEMODE" /*= 155*/, 4039, xtD3DMULTISAMPLEMODE, 0 }, // D3DMULTISAMPLEMODE for the backbuffer. Verified absent in 3944, present in 4039 TODO : Might be introduced in 4034?
{ "D3DRS_MULTISAMPLERENDERTARGETMODE" /*= 156*/, 4034, xtD3DMULTISAMPLEMODE, NV2A_RT_FORMAT }, // Verified absent in 3944, present in 4039. Presence in 4034 is based on test-case : The Simpsons Road Rage
{ "D3DRS_SHADOWFUNC" /*= 157*/, 3424, xtD3DCMPFUNC, NV2A_TX_RCOMP },
{ "D3DRS_LINEWIDTH" /*= 158*/, 3424, xtFloat, NV2A_LINE_WIDTH },
{ "D3DRS_SAMPLEALPHA" /*= 159*/, 4627, xtD3DSAMPLEALPHA, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between?
{ "D3DRS_DXT1NOISEENABLE" /*= 160*/, 3424, xtBOOL, NV2A_CLEAR_DEPTH_VALUE },
{ "D3DRS_YUVENABLE" /*= 161*/, 3911, xtBOOL, NV2A_CONTROL0 }, // Verified present in 3944
{ "D3DRS_OCCLUSIONCULLENABLE" /*= 162*/, 3911, xtBOOL, NV2A_OCCLUDE_ZSTENCIL_EN }, // Verified present in 3944
{ "D3DRS_STENCILCULLENABLE" /*= 163*/, 3911, xtBOOL, NV2A_OCCLUDE_ZSTENCIL_EN }, // Verified present in 3944
{ "D3DRS_ROPZCMPALWAYSREAD" /*= 164*/, 3911, xtBOOL, 0 }, // Verified present in 3944
{ "D3DRS_ROPZREAD" /*= 165*/, 3911, xtBOOL, 0 }, // Verified present in 3944
{ "D3DRS_DONOTCULLUNCOMPRESSED" /*= 166*/, 3911, xtBOOL, 0 } // Verified present in 3944
};
const RenderStateInfo& GetDxbxRenderStateInfo(int State)
{
return DxbxRenderStateInfo[State];
}
/*Direct3D8 states unused :
D3DRS_LINEPATTERN
D3DRS_LASTPIXEL

View File

@ -1811,11 +1811,13 @@ typedef struct _RenderStateInfo {
XTL::NV2AMETHOD M; // The related push buffer method. Not always a 1-to-1 mapping. Needs push-buffer interpretation & conversion code.
D3DRENDERSTATETYPE PC = (D3DRENDERSTATETYPE)0; // Map XBox to PC render state
char *N; // XDK notes. Defaults to ''.
WORD R; // The XDK version since which a render state was removed
}
RenderStateInfo;
#define D3DRS_NONE ((D3DRENDERSTATETYPE)0)
#define D3DRS_UNSUPPORTED ((D3DRENDERSTATETYPE)0)
extern const RenderStateInfo& GetDxbxRenderStateInfo(int State);
extern const RenderStateInfo DxbxRenderStateInfo[];
#endif

View File

@ -649,12 +649,12 @@ typedef enum _X_D3DRENDERSTATETYPE {
// Dxbx note : These declarations are from XDK version 5933, the most recent and complete version.
// Older versions are slightly different (some members are missing), so we use a mapping table to
// cater for the differences (see DxbxBuildRenderStateMappingTable). This enables to ignore these
// version-differences in the rest of our code (unless it matters somehow); We write via indirection :
// *EmuMappedD3DRenderState[X_D3DRENDERSTATETYPE] = Value;
// cater for the differences (see XboxRenderStateConverter::BuildRenderStateMappingTable). This enables to ignore these
// version-differences in the rest of our code (unless it matters somehow); We write like this :
// XboxRenderStates.SetXboxRenderState(X_D3DRENDERSTATETYPE, Value);
//
// And we read via the same mapping (do note, that missing elements all point to the same dummy) :
// Result = *EmuMappedD3DRenderState[X_D3DRENDERSTATETYPE];
// And we read like this (do note, that missing elements all point to the same dummy) :
// Result = XboxRenderStates.GetXboxRenderState(X_D3DRENDERSTATETYPE);
// Dxbx note : The PS* render states map 1-on-1 to the X_D3DPIXELSHADERDEF record,
// SetPixelShader actually pushes the definition into these render state slots.
@ -737,14 +737,14 @@ typedef enum _X_D3DRENDERSTATETYPE {
X_D3DRS_STENCILMASK = 72, // BYTE mask value used in stencil test
X_D3DRS_STENCILWRITEMASK = 73, // BYTE write mask applied to values written to stencil buffer
X_D3DRS_BLENDOP = 74, // D3DBLENDOP setting
X_D3DRS_BLENDCOLOR = 75, // D3DCOLOR for D3DBLEND_CONSTANTCOLOR (Xbox ext.)
X_D3DRS_BLENDCOLOR = 75, // D3DCOLOR for D3DBLEND_CONSTANTCOLOR
X_D3DRS_SWATHWIDTH = 76, // D3DSWATHWIDTH (Xbox ext.)
X_D3DRS_POLYGONOFFSETZSLOPESCALE = 77, // float Z factor for shadow maps (Xbox ext.)
X_D3DRS_POLYGONOFFSETZOFFSET = 78, // Xbox ext.
X_D3DRS_POINTOFFSETENABLE = 79, // Xbox ext.
X_D3DRS_WIREFRAMEOFFSETENABLE = 80, // Xbox ext.
X_D3DRS_SOLIDOFFSETENABLE = 81, // Xbox ext.
X_D3DRS_DEPTHCLIPCONTROL = 82, // [4627+] Xbox ext.
X_D3DRS_DEPTHCLIPCONTROL = 82, // [4432+] Xbox ext.
X_D3DRS_STIPPLEENABLE = 83, // [4627+] Xbox ext.
X_D3DRS_SIMPLE_UNUSED8 = 84, // [4627+]
X_D3DRS_SIMPLE_UNUSED7 = 85, // [4627+]
@ -789,8 +789,8 @@ typedef enum _X_D3DRENDERSTATETYPE {
X_D3DRS_POINTSIZE_MAX = 123,
X_D3DRS_PATCHEDGESTYLE = 124, // Dxbx addition
X_D3DRS_PATCHSEGMENTS = 125,
X_D3DRS_SWAPFILTER = 126, // [4361+] Xbox ext. nsp. D3DTEXF_LINEAR etc. filter to use for Swap
X_D3DRS_PRESENTATIONINTERVAL = 127, // [4627+] Xbox ext. nsp.
X_D3DRS_SWAPFILTER = 126, // [4039+] Xbox ext. nsp. D3DTEXF_LINEAR etc. filter to use for Swap
X_D3DRS_PRESENTATIONINTERVAL = 127, // [4627+] Xbox ext. nsp. TODO : Use 4361?
X_D3DRS_DEFERRED_UNUSED8 = 128, // [4627+]
X_D3DRS_DEFERRED_UNUSED7 = 129, // [4627+]
X_D3DRS_DEFERRED_UNUSED6 = 130, // [4627+]
@ -814,23 +814,24 @@ typedef enum _X_D3DRENDERSTATETYPE {
X_D3DRS_CULLMODE = 147,
X_D3DRS_TEXTUREFACTOR = 148,
X_D3DRS_ZBIAS = 149,
X_D3DRS_LOGICOP = 150, // Xbox ext.
X_D3DRS_LOGICOP = 150, // Xbox ext. nsp.
X_D3DRS_EDGEANTIALIAS = 151, // Dxbx note : No Xbox ext. (according to Direct3D8) !
X_D3DRS_MULTISAMPLEANTIALIAS = 152,
X_D3DRS_MULTISAMPLEMASK = 153,
X_D3DRS_MULTISAMPLETYPE = 154, // [-3911] Xbox ext. \_ aliasses D3DMULTISAMPLE_TYPE
X_D3DRS_MULTISAMPLEMODE = 154, // [4361+] Xbox ext. / D3DMULTISAMPLEMODE for the backbuffer
X_D3DRS_MULTISAMPLERENDERTARGETMODE = 155, // [4361+] Xbox ext.
X_D3DRS_SHADOWFUNC = 156, // D3DCMPFUNC (Xbox extension)
X_D3DRS_LINEWIDTH = 157, // Xbox ext.
X_D3DRS_SAMPLEALPHA = 158, // Xbox ext.
X_D3DRS_DXT1NOISEENABLE = 159, // Xbox ext.
X_D3DRS_YUVENABLE = 160, // [3911+] Xbox ext.
X_D3DRS_OCCLUSIONCULLENABLE = 161, // [3911+] Xbox ext.
X_D3DRS_STENCILCULLENABLE = 162, // [3911+] Xbox ext.
X_D3DRS_ROPZCMPALWAYSREAD = 163, // [3911+] Xbox ext.
X_D3DRS_ROPZREAD = 164, // [3911+] Xbox ext.
X_D3DRS_DONOTCULLUNCOMPRESSED = 165, // [3911+] Xbox ext.
X_D3DRS_MULTISAMPLETYPE = 154, // [-4039] Xbox ext.
// Note : X_D3DRS_MULTISAMPLETYPE seems the only one that got removed, but it does need a slot, so the rest is increased by 1 compared to 5933.
X_D3DRS_MULTISAMPLEMODE = 155, // [4361+] Xbox ext. // D3DMULTISAMPLEMODE for the backbuffer
X_D3DRS_MULTISAMPLERENDERTARGETMODE = 156, // [4039+] Xbox ext.
X_D3DRS_SHADOWFUNC = 157, // D3DCMPFUNC (Xbox extension)
X_D3DRS_LINEWIDTH = 158, // Xbox ext.
X_D3DRS_SAMPLEALPHA = 159, // Xbox ext.
X_D3DRS_DXT1NOISEENABLE = 160, // Xbox ext.
X_D3DRS_YUVENABLE = 161, // [3911+] Xbox ext.
X_D3DRS_OCCLUSIONCULLENABLE = 162, // [3911+] Xbox ext.
X_D3DRS_STENCILCULLENABLE = 163, // [3911+] Xbox ext.
X_D3DRS_ROPZCMPALWAYSREAD = 164, // [3911+] Xbox ext.
X_D3DRS_ROPZREAD = 165, // [3911+] Xbox ext.
X_D3DRS_DONOTCULLUNCOMPRESSED = 166, // [3911+] Xbox ext.
// End of "complex" render states.
X_D3DRS_UNK = 0x7fffffff // deferred render state "unknown" flag
} X_D3DRENDERSTATETYPE;

View File

@ -1650,7 +1650,7 @@ bool PSH_IMD_ARGUMENT::Decode(const DWORD Value, DWORD aMask, TArgumentType Argu
Modifiers = (1 << ARGMOD_BIAS);
break;
// case PS_INPUTMAPPING_HALFBIAS_NEGATE:
// Modifiers = ARGMOD_IDENTITY; ???
// Modifiers = (1 << ARGMOD_IDENTITY); ???
// break;
case PS_INPUTMAPPING_SIGNED_IDENTITY:
Modifiers = (1 << ARGMOD_IDENTITY);
@ -5982,11 +5982,9 @@ VOID DxbxUpdateActivePixelShader() // NOPATCH
HRESULT Result = D3D_OK;
// TODO: Is this even right? The first RenderState is PSAlpha,
// The first RenderState is PSAlpha,
// The pixel shader is stored in pDevice->m_pPixelShader
// For now, we still patch SetPixelShader and read from there...
//DWORD *XTL_D3D__RenderState = EmuMappedD3DRenderState[0];
//pPSDef = (XTL::X_D3DPIXELSHADERDEF*)(XTL_D3D__RenderState);
// Use the pixel shader stored in D3D__RenderState rather than the set handle
// This allows changes made via SetRenderState to actually take effect!
@ -5994,6 +5992,7 @@ VOID DxbxUpdateActivePixelShader() // NOPATCH
// All other fields are the same.
// We cast D3D__RenderState to a pPSDef for these fields, but
// manually read from D3D__RenderState[X_D3DRS_PSTEXTUREMODES) for that one field.
// See D3DDevice_SetPixelShaderCommon which implements this
pPSDef = g_pXbox_PixelShader != nullptr ? (XTL::X_D3DPIXELSHADERDEF*)(XboxRenderStates.GetPixelShaderRenderStatePointer()) : nullptr;
@ -6066,25 +6065,16 @@ VOID DxbxUpdateActivePixelShader() // NOPATCH
if (RecompiledPixelShader->ConstInUse[i])
{
// Read the color from the corresponding render state slot :
// TODO: These should read from EmuMappedD3DRenderState, but it doesn't exist yet
// The required code needs o be ported from Wip_LessVertexPatching or Dxbx
switch (i) {
case PSH_XBOX_CONSTANT_FOG:
//dwColor = *EmuMappedD3DRenderState[XTL::X_D3DRS_FOGCOLOR] | 0xFF000000;
// Note : FOG.RGB is correct like this, but FOG.a should be coming
// from the vertex shader (oFog) - however, D3D8 does not forward this...
g_pD3DDevice->GetRenderState(D3DRS_FOGCOLOR, &dwColor);
fColor.a = ((dwColor >> 24) & 0xFF) / 255.0f;
fColor.r = ((dwColor >> 16) & 0xFF) / 255.0f;
fColor.g = ((dwColor >> 8) & 0xFF) / 255.0f;
fColor.b = (dwColor & 0xFF) / 255.0f;
fColor = dwColor = XboxRenderStates.GetXboxRenderState(XTL::X_D3DRS_FOGCOLOR);
break;
case PSH_XBOX_CONSTANT_FC0:
//dwColor = *EmuMappedD3DRenderState[XTL::X_D3DRS_PSFINALCOMBINERCONSTANT0];
fColor = dwColor = XboxRenderStates.GetXboxRenderState(XTL::X_D3DRS_PSFINALCOMBINERCONSTANT0);
break;
case PSH_XBOX_CONSTANT_FC1:
//dwColor = *EmuMappedD3DRenderState[XTL::X_D3DRS_PSFINALCOMBINERCONSTANT1];
fColor = dwColor = XboxRenderStates.GetXboxRenderState(XTL::X_D3DRS_PSFINALCOMBINERCONSTANT1);
break;
case PSH_XBOX_CONSTANT_MUL0:
@ -6119,7 +6109,6 @@ VOID DxbxUpdateActivePixelShader() // NOPATCH
break;
}
default:
//dwColor = *EmuMappedD3DRenderState[XTL::X_D3DRS_PSCONSTANT0_0 + i];
fColor = dwColor = XboxRenderStates.GetXboxRenderState(XTL::X_D3DRS_PSCONSTANT0_0 + i);
break;
}

View File

@ -55,8 +55,10 @@ FLOAT *g_InlineVertexBuffer_pData = nullptr;
UINT g_InlineVertexBuffer_DataSize = 0;
extern DWORD g_dwPrimPerFrame = 0;
extern XTL::X_D3DVertexBuffer*g_D3DStreams[X_VSH_MAX_STREAMS];
extern UINT g_D3DStreamStrides[X_VSH_MAX_STREAMS];
// Copy of active Xbox D3D Vertex Streams (and strides), set by [D3DDevice|CxbxImpl]_SetStreamSource*
XTL::X_STREAMINPUT g_Xbox_SetStreamSource[X_VSH_MAX_STREAMS] = { 0 }; // Note : .Offset member is never set (so always 0)
extern XTL::X_D3DSurface* g_pXbox_RenderTarget;
extern XTL::X_D3DSurface* g_pXbox_BackBufferSurface;
void *GetDataFromXboxResource(XTL::X_D3DResource *pXboxResource);
@ -118,7 +120,7 @@ int CountActiveD3DStreams()
{
int lastStreamIndex = 0;
for (int i = 0; i < X_VSH_MAX_STREAMS; i++) {
if (g_D3DStreams[i] != xbnullptr) {
if (g_Xbox_SetStreamSource[i].VertexBuffer != xbnullptr) {
lastStreamIndex = i + 1;
}
}
@ -292,7 +294,7 @@ void CxbxVertexBufferConverter::ConvertStream
uiHostVertexStride = (bNeedVertexPatching) ? pVertexShaderStreamInfo->HostVertexStride : uiXboxVertexStride;
dwHostVertexDataSize = uiVertexCount * uiHostVertexStride;
} else {
XTL::X_D3DVertexBuffer *pXboxVertexBuffer = g_D3DStreams[uiStream];
XTL::X_D3DVertexBuffer *pXboxVertexBuffer = g_Xbox_SetStreamSource[uiStream].VertexBuffer;
pXboxVertexData = (uint8_t*)GetDataFromXboxResource(pXboxVertexBuffer);
if (pXboxVertexData == xbnullptr) {
HRESULT hRet = g_pD3DDevice->SetStreamSource(
@ -308,7 +310,7 @@ void CxbxVertexBufferConverter::ConvertStream
return;
}
uiXboxVertexStride = g_D3DStreamStrides[uiStream];
uiXboxVertexStride = g_Xbox_SetStreamSource[uiStream].Stride;
// Set a new (exact) vertex count
uiVertexCount = pDrawContext->VerticesInBuffer;
// Dxbx note : Don't overwrite pDrawContext.dwVertexCount with uiVertexCount, because an indexed draw
@ -987,3 +989,15 @@ VOID EmuFlushIVB()
}
g_InlineVertexBuffer_TableOffset = 0; // Might not be needed (also cleared in D3DDevice_Begin)
}
void CxbxImpl_SetStreamSource(UINT StreamNumber, XTL::X_D3DVertexBuffer* pStreamData, UINT Stride)
{
if (pStreamData != xbnullptr && Stride == 0) {
LOG_TEST_CASE("CxbxImpl_SetStreamSource : Stream assigned, and stride set to 0 (might be okay)");
}
assert(StreamNumber < X_VSH_MAX_STREAMS);
g_Xbox_SetStreamSource[StreamNumber].VertexBuffer = pStreamData;
g_Xbox_SetStreamSource[StreamNumber].Stride = Stride;
}

View File

@ -1474,7 +1474,7 @@ static void VshRemoveScreenSpaceInstructions(VSH_XBOX_SHADER *pShader)
MulIntermediate.Parameters[1].Active = TRUE;
MulIntermediate.Parameters[1].IndexesWithA0_X = FALSE;
MulIntermediate.Parameters[1].Parameter.ParameterType = PARAM_C;
MulIntermediate.Parameters[1].Parameter.Address = ConvertCRegister(58);
MulIntermediate.Parameters[1].Parameter.Address = ConvertCRegister(X_D3DVS_RESERVED_CONSTANT1_CORRECTED);
MulIntermediate.Parameters[1].Parameter.Neg = FALSE;
VshSetSwizzle(&MulIntermediate.Parameters[1], SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W);
MulIntermediate.Parameters[2].Active = FALSE;
@ -1487,7 +1487,7 @@ static void VshRemoveScreenSpaceInstructions(VSH_XBOX_SHADER *pShader)
AddIntermediate.Output.Address = OREG_OPOS;
AddIntermediate.Parameters[0].Parameter.ParameterType = PARAM_R;
AddIntermediate.Parameters[0].Parameter.Address = X_VSH_TEMP_SCRATCH;
AddIntermediate.Parameters[1].Parameter.Address = ConvertCRegister(59);
AddIntermediate.Parameters[1].Parameter.Address = ConvertCRegister(X_D3DVS_RESERVED_CONSTANT2_CORRECTED);
VshInsertIntermediate(pShader, &AddIntermediate, ++i);
}
}
@ -2829,3 +2829,33 @@ void SetCxbxVertexShader(DWORD XboxVertexShaderHandle, CxbxVertexShader* shader)
g_CxbxVertexShaders[XboxVertexShaderHandle] = shader;
}
void CxbxImpl_SetVertexShaderInput
(
DWORD Handle,
UINT StreamCount,
XTL::X_STREAMINPUT* pStreamInputs
)
{
LOG_INIT
// If Handle is NULL, all VertexShader input state is cleared.
// Otherwise, Handle is the address of an Xbox VertexShader struct, or-ed with 1 (X_D3DFVF_RESERVED0)
// (Thus, a FVF handle is an invalid argument.)
//
LOG_UNIMPLEMENTED();
}
void CxbxImpl_SelectVertexShaderDirect
(
XTL::X_VERTEXATTRIBUTEFORMAT* pVAF,
DWORD Address
)
{
LOG_INIT;
// When pVAF is non-null, this vertex attribute format takes precedence over the the one
LOG_UNIMPLEMENTED();
}

View File

@ -999,7 +999,7 @@ void CxbxKrnlMain(int argc, char* argv[])
// Write a header to the log
{
printf("[0x%.4X] INIT: Cxbx-Reloaded Version %s\n", GetCurrentThreadId(), _CXBX_VERSION);
printf("[0x%.4X] INIT: Cxbx-Reloaded Version %s\n", GetCurrentThreadId(), CxbxVersionStr);
time_t startTime = time(nullptr);
struct tm* tm_info = localtime(&startTime);

View File

@ -80,8 +80,13 @@ INT_PTR CALLBACK DlgAboutProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
GetClientRect(GetDlgItem(hWndDlg, IDC_TAB1), &tabRect);
SendMessage(GetDlgItem(hWndDlg, IDC_TAB1), TCM_ADJUSTRECT, FALSE, (LPARAM)&tabRect);
// Tab Pane 1
char TabPane1Message[270];
sprintf(TabPane1Message, "\nCxbx-Reloaded\nVersion %s\n© The Cxbx-Reloaded Team"
"\nThis software comes with ABSOLUTELY NO WARRANTY."
"\nThis is free software, and you are welcome to redistribute it"
"\nunder certain conditions; See our website for details.", CxbxVersionStr);
HWND tab = CreateWindowEx
(NULL, "STATIC", "\nCxbx-Reloaded\nVersion " _CXBX_VERSION "\n© The Cxbx-Reloaded Team",
(NULL, "STATIC", TabPane1Message,
WS_CHILD | WS_VISIBLE,
tabRect.left + 10, tabRect.top + 10,
tabRect.right - tabRect.left,
@ -146,6 +151,7 @@ INT_PTR CALLBACK DlgAboutProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
aboutCurrentTab = 0;
UpdateWindow(hWndDlg);
}
break;
@ -183,7 +189,9 @@ INT_PTR CALLBACK DlgAboutProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
}
// Show the selected tab pane
ShowWindow(aboutTabPanes[aboutCurrentTab], SW_HIDE); ShowWindow(aboutTabPanes[index], SW_SHOW);
ShowWindow(aboutTabPanes[aboutCurrentTab], SW_HIDE);
ShowWindow(aboutTabPanes[index], SW_SHOW);
aboutCurrentTab = index;
}
break;

View File

@ -83,7 +83,7 @@ bool Wnd::ProcessMessages()
(
0,
m_classname,
m_wndname,
m_wndname.c_str(),
m_wndstyle,
m_x,
m_y,

View File

@ -84,7 +84,7 @@ public:
// ******************************************************************
ATOM m_class;
const char *m_classname;
const char *m_wndname;
std::string m_wndname;
UINT m_clsstyle;
DWORD m_wndstyle;
int m_x, m_y, m_w, m_h;

View File

@ -173,7 +173,7 @@ WndMain::WndMain(HINSTANCE x_hInstance) :
// initialize members
{
m_classname = "WndMain";
m_wndname = "Cxbx-Reloaded " _CXBX_VERSION;
m_wndname = "Cxbx-Reloaded " + std::string(CxbxVersionStr);
}
// load configuration from settings file
@ -1867,7 +1867,7 @@ void WndMain::UpdateCaption()
{
char AsciiTitle[MAX_PATH];
int i = sprintf(AsciiTitle, "Cxbx-Reloaded %s", _CXBX_VERSION);
int i = sprintf(AsciiTitle, "Cxbx-Reloaded %s", CxbxVersionStr);
if (m_Xbe != nullptr) {
if (m_bIsStarted) {
i += sprintf(AsciiTitle + i, " : Emulating ");