Merge pull request #1725 from PatrickvL/moving_d3d_types
* Moved XbPushBuffer.h, XbVertexBuffer.h and XbVertexShader.h outside the XTL namespace. Moved Cxbx-specific types from XbD3DTypes.h towards appropriate above header files. Fixed up all XTL-hell that resulted from this. * Moved XbConvert.h outside the XTL namespace. Fixed up all XTL-hell that resulted from this. * Moved XbPixelShader.h outside the XTL namespace. Fixed up all XTL-hell that resulted from this. * Moved XbState.h outside the XTL namespace. Fixed up all XTL-hell that resulted from this.
This commit is contained in:
commit
796561dd6c
|
@ -43,8 +43,14 @@ namespace xboxkrnl
|
||||||
#include "EmuShared.h"
|
#include "EmuShared.h"
|
||||||
#include "gui\DbgConsole.h"
|
#include "gui\DbgConsole.h"
|
||||||
#include "core\hle\D3D8\ResourceTracker.h"
|
#include "core\hle\D3D8\ResourceTracker.h"
|
||||||
|
#include "core\hle\D3D8\XbVertexBuffer.h"
|
||||||
|
#include "core\hle\D3D8\XbVertexShader.h"
|
||||||
|
#include "core\hle\D3D8\XbPixelShader.h" // For DxbxUpdateActivePixelShader
|
||||||
|
#include "core\hle\D3D8\XbPushBuffer.h"
|
||||||
|
#include "core\hle\D3D8\XbState.h" // For EmuUpdateDeferredStates
|
||||||
#include "core\kernel\memory-manager\VMManager.h" // for g_VMManager
|
#include "core\kernel\memory-manager\VMManager.h" // for g_VMManager
|
||||||
#include "core\kernel\support\EmuXTL.h"
|
#include "core\kernel\support\EmuXTL.h"
|
||||||
|
#include "core\hle\D3D8\XbConvert.h"
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
#include "..\XbD3D8Logging.h"
|
#include "..\XbD3D8Logging.h"
|
||||||
#include "core\hle\Intercept.hpp" // for bLLE_GPU
|
#include "core\hle\Intercept.hpp" // for bLLE_GPU
|
||||||
|
@ -148,7 +154,7 @@ static DWORD g_VBLastSwap = 0;
|
||||||
static XTL::D3DSWAPDATA g_SwapData = {0};
|
static XTL::D3DSWAPDATA g_SwapData = {0};
|
||||||
static DWORD g_SwapLast = 0;
|
static DWORD g_SwapLast = 0;
|
||||||
|
|
||||||
static XTL::CxbxVertexBufferConverter VertexBufferConverter = {};
|
static CxbxVertexBufferConverter VertexBufferConverter = {};
|
||||||
|
|
||||||
// cached Direct3D state variable(s)
|
// cached Direct3D state variable(s)
|
||||||
static XTL::IDirect3DIndexBuffer *pClosingLineLoopIndexBuffer = nullptr;
|
static XTL::IDirect3DIndexBuffer *pClosingLineLoopIndexBuffer = nullptr;
|
||||||
|
@ -156,7 +162,7 @@ static XTL::IDirect3DIndexBuffer *pClosingLineLoopIndexBuffer = nullptr;
|
||||||
static XTL::IDirect3DIndexBuffer *pQuadToTriangleD3DIndexBuffer = nullptr;
|
static XTL::IDirect3DIndexBuffer *pQuadToTriangleD3DIndexBuffer = nullptr;
|
||||||
static UINT QuadToTriangleD3DIndexBuffer_Size = 0; // = NrOfQuadVertices
|
static UINT QuadToTriangleD3DIndexBuffer_Size = 0; // = NrOfQuadVertices
|
||||||
|
|
||||||
static XTL::INDEX16 *pQuadToTriangleIndexBuffer = nullptr;
|
static INDEX16 *pQuadToTriangleIndexBuffer = nullptr;
|
||||||
static UINT QuadToTriangleIndexBuffer_Size = 0; // = NrOfQuadVertices
|
static UINT QuadToTriangleIndexBuffer_Size = 0; // = NrOfQuadVertices
|
||||||
|
|
||||||
static XTL::IDirect3DSurface *g_DefaultHostDepthBufferSuface = NULL;
|
static XTL::IDirect3DSurface *g_DefaultHostDepthBufferSuface = NULL;
|
||||||
|
@ -1228,7 +1234,7 @@ void GetSurfaceFaceAndLevelWithinTexture(XTL::X_D3DSurface* pSurface, XTL::X_D3D
|
||||||
CxbxGetPixelContainerMeasures(pSurface, 0, &surfaceWidth, &surfaceHeight, &surfaceDepth, &surfaceRowPitch, &surfaceSlicePitch);
|
CxbxGetPixelContainerMeasures(pSurface, 0, &surfaceWidth, &surfaceHeight, &surfaceDepth, &surfaceRowPitch, &surfaceSlicePitch);
|
||||||
|
|
||||||
// Iterate through all faces and levels, until we find a matching pointer
|
// Iterate through all faces and levels, until we find a matching pointer
|
||||||
bool isCompressed = XTL::EmuXBFormatIsCompressed(GetXboxPixelContainerFormat(pTexture));
|
bool isCompressed = EmuXBFormatIsCompressed(GetXboxPixelContainerFormat(pTexture));
|
||||||
int minSize = (isCompressed) ? 4 : 1;
|
int minSize = (isCompressed) ? 4 : 1;
|
||||||
int cubeFaceOffset = 0; int cubeFaceSize = 0;
|
int cubeFaceOffset = 0; int cubeFaceSize = 0;
|
||||||
auto pData = pTextureData;
|
auto pData = pTextureData;
|
||||||
|
@ -1300,15 +1306,15 @@ bool ConvertD3DTextureToARGBBuffer(
|
||||||
int iTextureStage = 0
|
int iTextureStage = 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const XTL::FormatToARGBRow ConvertRowToARGB = EmuXBFormatComponentConverter(X_Format);
|
const FormatToARGBRow ConvertRowToARGB = EmuXBFormatComponentConverter(X_Format);
|
||||||
if (ConvertRowToARGB == nullptr)
|
if (ConvertRowToARGB == nullptr)
|
||||||
return false; // Unhandled conversion
|
return false; // Unhandled conversion
|
||||||
|
|
||||||
uint8_t *unswizleBuffer = nullptr;
|
uint8_t *unswizleBuffer = nullptr;
|
||||||
if (XTL::EmuXBFormatIsSwizzled(X_Format)) {
|
if (EmuXBFormatIsSwizzled(X_Format)) {
|
||||||
unswizleBuffer = (uint8_t*)malloc(SrcSlicePitch * uiDepth); // TODO : Reuse buffer when performance is important
|
unswizleBuffer = (uint8_t*)malloc(SrcSlicePitch * uiDepth); // TODO : Reuse buffer when performance is important
|
||||||
// First we need to unswizzle the texture data
|
// First we need to unswizzle the texture data
|
||||||
XTL::EmuUnswizzleBox(
|
EmuUnswizzleBox(
|
||||||
pSrc, SrcWidth, SrcHeight, uiDepth,
|
pSrc, SrcWidth, SrcHeight, uiDepth,
|
||||||
EmuXBFormatBytesPerPixel(X_Format),
|
EmuXBFormatBytesPerPixel(X_Format),
|
||||||
// Note : use src pitch on dest, because this is an intermediate step :
|
// Note : use src pitch on dest, because this is an intermediate step :
|
||||||
|
@ -1362,7 +1368,7 @@ uint8_t *XTL::ConvertD3DTextureToARGB(
|
||||||
{
|
{
|
||||||
// Avoid allocating pDest when ConvertD3DTextureToARGBBuffer will fail anyway
|
// Avoid allocating pDest when ConvertD3DTextureToARGBBuffer will fail anyway
|
||||||
XTL::X_D3DFORMAT X_Format = GetXboxPixelContainerFormat(pXboxPixelContainer);
|
XTL::X_D3DFORMAT X_Format = GetXboxPixelContainerFormat(pXboxPixelContainer);
|
||||||
const XTL::FormatToARGBRow ConvertRowToARGB = EmuXBFormatComponentConverter(X_Format);
|
const FormatToARGBRow ConvertRowToARGB = EmuXBFormatComponentConverter(X_Format);
|
||||||
if (ConvertRowToARGB == nullptr)
|
if (ConvertRowToARGB == nullptr)
|
||||||
return nullptr; // Unhandled conversion
|
return nullptr; // Unhandled conversion
|
||||||
|
|
||||||
|
@ -2006,8 +2012,8 @@ static DWORD WINAPI EmuCreateDeviceProxy(LPVOID)
|
||||||
// TODO: Investigate the best option for this
|
// TODO: Investigate the best option for this
|
||||||
g_EmuCDPD.HostPresentationParameters.SwapEffect = XTL::D3DSWAPEFFECT_COPY;
|
g_EmuCDPD.HostPresentationParameters.SwapEffect = XTL::D3DSWAPEFFECT_COPY;
|
||||||
|
|
||||||
g_EmuCDPD.HostPresentationParameters.BackBufferFormat = XTL::EmuXB2PC_D3DFormat(g_EmuCDPD.XboxPresentationParameters.BackBufferFormat);
|
g_EmuCDPD.HostPresentationParameters.BackBufferFormat = EmuXB2PC_D3DFormat(g_EmuCDPD.XboxPresentationParameters.BackBufferFormat);
|
||||||
g_EmuCDPD.HostPresentationParameters.AutoDepthStencilFormat = XTL::EmuXB2PC_D3DFormat(g_EmuCDPD.XboxPresentationParameters.AutoDepthStencilFormat);
|
g_EmuCDPD.HostPresentationParameters.AutoDepthStencilFormat = EmuXB2PC_D3DFormat(g_EmuCDPD.XboxPresentationParameters.AutoDepthStencilFormat);
|
||||||
|
|
||||||
g_EmuCDPD.HostPresentationParameters.PresentationInterval = g_XBVideo.bVSync ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
|
g_EmuCDPD.HostPresentationParameters.PresentationInterval = g_XBVideo.bVSync ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||||
g_DefaultPresentationInterval = g_EmuCDPD.XboxPresentationParameters.PresentationInterval;
|
g_DefaultPresentationInterval = g_EmuCDPD.XboxPresentationParameters.PresentationInterval;
|
||||||
|
@ -2166,9 +2172,9 @@ static DWORD WINAPI EmuCreateDeviceProxy(LPVOID)
|
||||||
memset(g_bSupportsFormatCubeTexture, false, sizeof(g_bSupportsFormatCubeTexture));
|
memset(g_bSupportsFormatCubeTexture, false, sizeof(g_bSupportsFormatCubeTexture));
|
||||||
for (int X_Format = XTL::X_D3DFMT_L8; X_Format <= XTL::X_D3DFMT_LIN_R8G8B8A8; X_Format++) {
|
for (int X_Format = XTL::X_D3DFMT_L8; X_Format <= XTL::X_D3DFMT_LIN_R8G8B8A8; X_Format++) {
|
||||||
// Only process Xbox formats that are directly mappable to host
|
// Only process Xbox formats that are directly mappable to host
|
||||||
if (!XTL::EmuXBFormatRequiresConversionToARGB((XTL::X_D3DFORMAT)X_Format)) {
|
if (!EmuXBFormatRequiresConversionToARGB((XTL::X_D3DFORMAT)X_Format)) {
|
||||||
// Convert the Xbox format into host format (without warning, thanks to the above restriction)
|
// Convert the Xbox format into host format (without warning, thanks to the above restriction)
|
||||||
XTL::D3DFORMAT PCFormat = XTL::EmuXB2PC_D3DFormat((XTL::X_D3DFORMAT)X_Format);
|
XTL::D3DFORMAT PCFormat = EmuXB2PC_D3DFormat((XTL::X_D3DFORMAT)X_Format);
|
||||||
if (PCFormat != XTL::D3DFMT_UNKNOWN) {
|
if (PCFormat != XTL::D3DFMT_UNKNOWN) {
|
||||||
// Index with Xbox D3DFormat, because host FourCC codes are too big to be used as indices
|
// Index with Xbox D3DFormat, because host FourCC codes are too big to be used as indices
|
||||||
if (D3D_OK == g_pDirect3D->CheckDeviceFormat(
|
if (D3D_OK == g_pDirect3D->CheckDeviceFormat(
|
||||||
|
@ -2371,7 +2377,7 @@ static void EmuVerifyResourceIsRegistered(XTL::X_D3DResource *pResource, DWORD D
|
||||||
auto key = GetHostResourceKey(pResource);
|
auto key = GetHostResourceKey(pResource);
|
||||||
auto it = g_XboxDirect3DResources.find(key);
|
auto it = g_XboxDirect3DResources.find(key);
|
||||||
if (it != g_XboxDirect3DResources.end()) {
|
if (it != g_XboxDirect3DResources.end()) {
|
||||||
if (D3DUsage == D3DUSAGE_RENDERTARGET && IsResourceAPixelContainer(pResource) && XTL::EmuXBFormatIsRenderTarget(GetXboxPixelContainerFormat((XTL::X_D3DPixelContainer*)pResource))) {
|
if (D3DUsage == D3DUSAGE_RENDERTARGET && IsResourceAPixelContainer(pResource) && EmuXBFormatIsRenderTarget(GetXboxPixelContainerFormat((XTL::X_D3DPixelContainer*)pResource))) {
|
||||||
// Render targets have special behavior: We can't trash them on guest modification
|
// Render targets have special behavior: We can't trash them on guest modification
|
||||||
// this fixes an issue where CubeMaps were broken because the surface Set in GetCubeMapSurface
|
// this fixes an issue where CubeMaps were broken because the surface Set in GetCubeMapSurface
|
||||||
// would be overwritten by the surface created in SetRenderTarget
|
// would be overwritten by the surface created in SetRenderTarget
|
||||||
|
@ -2525,7 +2531,7 @@ void CxbxUpdateActiveIndexBuffer
|
||||||
}
|
}
|
||||||
|
|
||||||
EmuLog(LOG_LEVEL::DEBUG, "CxbxUpdateActiveIndexBuffer: Copying %d indices (D3DFMT_INDEX16)", IndexCount);
|
EmuLog(LOG_LEVEL::DEBUG, "CxbxUpdateActiveIndexBuffer: Copying %d indices (D3DFMT_INDEX16)", IndexCount);
|
||||||
memcpy(pData, pIndexData, IndexCount * sizeof(XTL::INDEX16));
|
memcpy(pData, pIndexData, IndexCount * sizeof(INDEX16));
|
||||||
|
|
||||||
indexBuffer.pHostIndexBuffer->Unlock();
|
indexBuffer.pHostIndexBuffer->Unlock();
|
||||||
}
|
}
|
||||||
|
@ -3725,7 +3731,7 @@ HRESULT WINAPI XTL::EMUPATCH(D3DDevice_CreateVertexShader)
|
||||||
CxbxVertexShader* pCxbxVertexShader = (CxbxVertexShader*)calloc(1, sizeof(CxbxVertexShader));
|
CxbxVertexShader* pCxbxVertexShader = (CxbxVertexShader*)calloc(1, sizeof(CxbxVertexShader));
|
||||||
D3DVERTEXELEMENT *pRecompiledDeclaration = nullptr;
|
D3DVERTEXELEMENT *pRecompiledDeclaration = nullptr;
|
||||||
|
|
||||||
pRecompiledDeclaration = XTL::EmuRecompileVshDeclaration((DWORD*)pDeclaration,
|
pRecompiledDeclaration = EmuRecompileVshDeclaration((DWORD*)pDeclaration,
|
||||||
/*bIsFixedFunction=*/pFunction == NULL,
|
/*bIsFixedFunction=*/pFunction == NULL,
|
||||||
&XboxDeclarationCount,
|
&XboxDeclarationCount,
|
||||||
&HostDeclarationSize,
|
&HostDeclarationSize,
|
||||||
|
@ -3749,7 +3755,7 @@ HRESULT WINAPI XTL::EMUPATCH(D3DDevice_CreateVertexShader)
|
||||||
{
|
{
|
||||||
bool bUseDeclarationOnly = false;
|
bool bUseDeclarationOnly = false;
|
||||||
|
|
||||||
hRet = XTL::EmuRecompileVshFunction((DWORD*)pFunction,
|
hRet = EmuRecompileVshFunction((DWORD*)pFunction,
|
||||||
/*bNoReservedConstants=*/g_VertexShaderConstantMode == X_D3DSCM_NORESERVEDCONSTANTS,
|
/*bNoReservedConstants=*/g_VertexShaderConstantMode == X_D3DSCM_NORESERVEDCONSTANTS,
|
||||||
pRecompiledDeclaration,
|
pRecompiledDeclaration,
|
||||||
&bUseDeclarationOnly,
|
&bUseDeclarationOnly,
|
||||||
|
@ -5727,7 +5733,7 @@ void CreateHostResource(XTL::X_D3DResource *pResource, DWORD D3DUsage, int iText
|
||||||
}
|
}
|
||||||
else if (bSwizzled) {
|
else if (bSwizzled) {
|
||||||
// First we need to unswizzle the texture data
|
// First we need to unswizzle the texture data
|
||||||
XTL::EmuUnswizzleBox(
|
EmuUnswizzleBox(
|
||||||
pSrc, dwMipWidth, dwMipHeight, dwMipDepth,
|
pSrc, dwMipWidth, dwMipHeight, dwMipDepth,
|
||||||
dwBPP,
|
dwBPP,
|
||||||
pDst, dwDstRowPitch, dwDstSlicePitch
|
pDst, dwDstRowPitch, dwDstSlicePitch
|
||||||
|
@ -6746,7 +6752,7 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetRenderState_PSTextureModes)
|
||||||
XB_trampoline(VOID, WINAPI, D3DDevice_SetRenderState_PSTextureModes, (DWORD));
|
XB_trampoline(VOID, WINAPI, D3DDevice_SetRenderState_PSTextureModes, (DWORD));
|
||||||
XB_D3DDevice_SetRenderState_PSTextureModes(Value);
|
XB_D3DDevice_SetRenderState_PSTextureModes(Value);
|
||||||
|
|
||||||
XTL::TemporaryPixelShaderRenderStates[XTL::X_D3DRS_PSTEXTUREMODES] = Value;
|
TemporaryPixelShaderRenderStates[XTL::X_D3DRS_PSTEXTUREMODES] = Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
|
@ -7354,11 +7360,11 @@ constexpr UINT QuadToTriangleVertexCount(UINT NrOfQuadVertices)
|
||||||
|
|
||||||
// TODO : Move to own file
|
// TODO : Move to own file
|
||||||
bool WindingClockwise = true;
|
bool WindingClockwise = true;
|
||||||
constexpr unsigned int IndicesPerPage = PAGE_SIZE / sizeof(XTL::INDEX16);
|
constexpr unsigned int IndicesPerPage = PAGE_SIZE / sizeof(INDEX16);
|
||||||
constexpr unsigned int InputQuadsPerPage = ((IndicesPerPage * VERTICES_PER_QUAD) / VERTICES_PER_TRIANGLE) / TRIANGLES_PER_QUAD;
|
constexpr unsigned int InputQuadsPerPage = ((IndicesPerPage * VERTICES_PER_QUAD) / VERTICES_PER_TRIANGLE) / TRIANGLES_PER_QUAD;
|
||||||
|
|
||||||
// TODO : Move to own file
|
// TODO : Move to own file
|
||||||
XTL::INDEX16 *CxbxAssureQuadListIndexBuffer(UINT NrOfQuadVertices)
|
INDEX16 *CxbxAssureQuadListIndexBuffer(UINT NrOfQuadVertices)
|
||||||
{
|
{
|
||||||
if (QuadToTriangleIndexBuffer_Size < NrOfQuadVertices)
|
if (QuadToTriangleIndexBuffer_Size < NrOfQuadVertices)
|
||||||
{
|
{
|
||||||
|
@ -7369,10 +7375,10 @@ XTL::INDEX16 *CxbxAssureQuadListIndexBuffer(UINT NrOfQuadVertices)
|
||||||
if (pQuadToTriangleIndexBuffer != nullptr)
|
if (pQuadToTriangleIndexBuffer != nullptr)
|
||||||
free(pQuadToTriangleIndexBuffer);
|
free(pQuadToTriangleIndexBuffer);
|
||||||
|
|
||||||
pQuadToTriangleIndexBuffer = (XTL::INDEX16 *)malloc(sizeof(XTL::INDEX16) * NrOfTriangleVertices);
|
pQuadToTriangleIndexBuffer = (INDEX16 *)malloc(sizeof(INDEX16) * NrOfTriangleVertices);
|
||||||
|
|
||||||
UINT i = 0;
|
UINT i = 0;
|
||||||
XTL::INDEX16 j = 0;
|
INDEX16 j = 0;
|
||||||
while (i + 6 < NrOfTriangleVertices)
|
while (i + 6 < NrOfTriangleVertices)
|
||||||
{
|
{
|
||||||
if (WindingClockwise) {
|
if (WindingClockwise) {
|
||||||
|
@ -7423,7 +7429,7 @@ void CxbxAssureQuadListD3DIndexBuffer(UINT NrOfQuadVertices)
|
||||||
// Round the number of indices up so we'll allocate whole pages
|
// Round the number of indices up so we'll allocate whole pages
|
||||||
QuadToTriangleD3DIndexBuffer_Size = RoundUp(NrOfQuadVertices, InputQuadsPerPage);
|
QuadToTriangleD3DIndexBuffer_Size = RoundUp(NrOfQuadVertices, InputQuadsPerPage);
|
||||||
UINT NrOfTriangleVertices = QuadToTriangleVertexCount(QuadToTriangleD3DIndexBuffer_Size); // 4 > 6
|
UINT NrOfTriangleVertices = QuadToTriangleVertexCount(QuadToTriangleD3DIndexBuffer_Size); // 4 > 6
|
||||||
UINT uiIndexBufferSize = sizeof(XTL::INDEX16) * NrOfTriangleVertices;
|
UINT uiIndexBufferSize = sizeof(INDEX16) * NrOfTriangleVertices;
|
||||||
|
|
||||||
// Create a new native index buffer of the above determined size :
|
// Create a new native index buffer of the above determined size :
|
||||||
if (pQuadToTriangleD3DIndexBuffer != nullptr) {
|
if (pQuadToTriangleD3DIndexBuffer != nullptr) {
|
||||||
|
@ -7445,7 +7451,7 @@ void CxbxAssureQuadListD3DIndexBuffer(UINT NrOfQuadVertices)
|
||||||
CxbxKrnlCleanup("CxbxAssureQuadListD3DIndexBuffer : IndexBuffer Create Failed!");
|
CxbxKrnlCleanup("CxbxAssureQuadListD3DIndexBuffer : IndexBuffer Create Failed!");
|
||||||
|
|
||||||
// Put quadlist-to-triangle-list index mappings into this buffer :
|
// Put quadlist-to-triangle-list index mappings into this buffer :
|
||||||
XTL::INDEX16* pIndexBufferData = nullptr;
|
INDEX16* pIndexBufferData = nullptr;
|
||||||
hRet = pQuadToTriangleD3DIndexBuffer->Lock(0, uiIndexBufferSize, (D3DLockData **)&pIndexBufferData, D3DLOCK_DISCARD);
|
hRet = pQuadToTriangleD3DIndexBuffer->Lock(0, uiIndexBufferSize, (D3DLockData **)&pIndexBufferData, D3DLOCK_DISCARD);
|
||||||
DEBUG_D3DRESULT(hRet, "pQuadToTriangleD3DIndexBuffer->Lock");
|
DEBUG_D3DRESULT(hRet, "pQuadToTriangleD3DIndexBuffer->Lock");
|
||||||
|
|
||||||
|
@ -7467,13 +7473,13 @@ void CxbxAssureQuadListD3DIndexBuffer(UINT NrOfQuadVertices)
|
||||||
|
|
||||||
// TODO : Move to own file
|
// TODO : Move to own file
|
||||||
// Calls SetIndices with a separate index-buffer, that's populated with the supplied indices.
|
// Calls SetIndices with a separate index-buffer, that's populated with the supplied indices.
|
||||||
void CxbxDrawIndexedClosingLine(XTL::INDEX16 LowIndex, XTL::INDEX16 HighIndex)
|
void CxbxDrawIndexedClosingLine(INDEX16 LowIndex, INDEX16 HighIndex)
|
||||||
{
|
{
|
||||||
LOG_INIT // Allows use of DEBUG_D3DRESULT
|
LOG_INIT // Allows use of DEBUG_D3DRESULT
|
||||||
|
|
||||||
HRESULT hRet;
|
HRESULT hRet;
|
||||||
|
|
||||||
const UINT uiIndexBufferSize = sizeof(XTL::INDEX16) * 2; // 4 bytes needed for 2 indices
|
const UINT uiIndexBufferSize = sizeof(INDEX16) * 2; // 4 bytes needed for 2 indices
|
||||||
if (pClosingLineLoopIndexBuffer == nullptr) {
|
if (pClosingLineLoopIndexBuffer == nullptr) {
|
||||||
hRet = g_pD3DDevice->CreateIndexBuffer(
|
hRet = g_pD3DDevice->CreateIndexBuffer(
|
||||||
uiIndexBufferSize,
|
uiIndexBufferSize,
|
||||||
|
@ -7487,7 +7493,7 @@ void CxbxDrawIndexedClosingLine(XTL::INDEX16 LowIndex, XTL::INDEX16 HighIndex)
|
||||||
CxbxKrnlCleanup("Unable to create pClosingLineLoopIndexBuffer for D3DPT_LINELOOP emulation");
|
CxbxKrnlCleanup("Unable to create pClosingLineLoopIndexBuffer for D3DPT_LINELOOP emulation");
|
||||||
}
|
}
|
||||||
|
|
||||||
XTL::INDEX16 *pCxbxClosingLineLoopIndexBufferData = nullptr;
|
INDEX16 *pCxbxClosingLineLoopIndexBufferData = nullptr;
|
||||||
hRet = pClosingLineLoopIndexBuffer->Lock(0, uiIndexBufferSize, (D3DLockData **)(&pCxbxClosingLineLoopIndexBufferData), D3DLOCK_DISCARD);
|
hRet = pClosingLineLoopIndexBuffer->Lock(0, uiIndexBufferSize, (D3DLockData **)(&pCxbxClosingLineLoopIndexBufferData), D3DLOCK_DISCARD);
|
||||||
DEBUG_D3DRESULT(hRet, "pClosingLineLoopIndexBuffer->Lock");
|
DEBUG_D3DRESULT(hRet, "pClosingLineLoopIndexBuffer->Lock");
|
||||||
|
|
||||||
|
@ -7514,11 +7520,11 @@ void CxbxDrawIndexedClosingLine(XTL::INDEX16 LowIndex, XTL::INDEX16 HighIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO : Move to own file
|
// TODO : Move to own file
|
||||||
void CxbxDrawIndexedClosingLineUP(XTL::INDEX16 LowIndex, XTL::INDEX16 HighIndex, void *pHostVertexStreamZeroData, UINT uiHostVertexStreamZeroStride)
|
void CxbxDrawIndexedClosingLineUP(INDEX16 LowIndex, INDEX16 HighIndex, void *pHostVertexStreamZeroData, UINT uiHostVertexStreamZeroStride)
|
||||||
{
|
{
|
||||||
LOG_INIT // Allows use of DEBUG_D3DRESULT
|
LOG_INIT // Allows use of DEBUG_D3DRESULT
|
||||||
|
|
||||||
XTL::INDEX16 CxbxClosingLineIndices[2] = { LowIndex, HighIndex };
|
INDEX16 CxbxClosingLineIndices[2] = { LowIndex, HighIndex };
|
||||||
|
|
||||||
HRESULT hRet = g_pD3DDevice->DrawIndexedPrimitiveUP(
|
HRESULT hRet = g_pD3DDevice->DrawIndexedPrimitiveUP(
|
||||||
XTL::D3DPT_LINELIST,
|
XTL::D3DPT_LINELIST,
|
||||||
|
@ -7537,7 +7543,7 @@ void CxbxDrawIndexedClosingLineUP(XTL::INDEX16 LowIndex, XTL::INDEX16 HighIndex,
|
||||||
|
|
||||||
// Requires assigned pIndexData
|
// Requires assigned pIndexData
|
||||||
// Called by D3DDevice_DrawIndexedVertices and EmuExecutePushBufferRaw (twice)
|
// Called by D3DDevice_DrawIndexedVertices and EmuExecutePushBufferRaw (twice)
|
||||||
void XTL::CxbxDrawIndexed(CxbxDrawContext &DrawContext)
|
void CxbxDrawIndexed(CxbxDrawContext &DrawContext)
|
||||||
{
|
{
|
||||||
LOG_INIT // Allows use of DEBUG_D3DRESULT
|
LOG_INIT // Allows use of DEBUG_D3DRESULT
|
||||||
|
|
||||||
|
@ -7548,7 +7554,7 @@ void XTL::CxbxDrawIndexed(CxbxDrawContext &DrawContext)
|
||||||
CxbxUpdateActiveIndexBuffer(DrawContext.pIndexData, DrawContext.dwVertexCount);
|
CxbxUpdateActiveIndexBuffer(DrawContext.pIndexData, DrawContext.dwVertexCount);
|
||||||
VertexBufferConverter.Apply(&DrawContext);
|
VertexBufferConverter.Apply(&DrawContext);
|
||||||
|
|
||||||
if (DrawContext.XboxPrimitiveType == X_D3DPT_QUADLIST) {
|
if (DrawContext.XboxPrimitiveType == XTL::X_D3DPT_QUADLIST) {
|
||||||
UINT uiStartIndex = 0;
|
UINT uiStartIndex = 0;
|
||||||
int iNumVertices = (int)DrawContext.dwVertexCount;
|
int iNumVertices = (int)DrawContext.dwVertexCount;
|
||||||
// Indexed quadlist can be drawn using unpatched indexes via multiple draws of 2 'strip' triangles :
|
// Indexed quadlist can be drawn using unpatched indexes via multiple draws of 2 'strip' triangles :
|
||||||
|
@ -7564,7 +7570,7 @@ void XTL::CxbxDrawIndexed(CxbxDrawContext &DrawContext)
|
||||||
|
|
||||||
// Emulate a quad by drawing each as a fan of 2 triangles
|
// Emulate a quad by drawing each as a fan of 2 triangles
|
||||||
HRESULT hRet = g_pD3DDevice->DrawIndexedPrimitive(
|
HRESULT hRet = g_pD3DDevice->DrawIndexedPrimitive(
|
||||||
D3DPT_TRIANGLEFAN,
|
XTL::D3DPT_TRIANGLEFAN,
|
||||||
DrawContext.dwIndexBase,
|
DrawContext.dwIndexBase,
|
||||||
LowIndex, // minIndex
|
LowIndex, // minIndex
|
||||||
(HighIndex - LowIndex) + 1, // NumVertices
|
(HighIndex - LowIndex) + 1, // NumVertices
|
||||||
|
@ -7596,7 +7602,7 @@ void XTL::CxbxDrawIndexed(CxbxDrawContext &DrawContext)
|
||||||
DEBUG_D3DRESULT(hRet, "g_pD3DDevice->DrawIndexedPrimitive");
|
DEBUG_D3DRESULT(hRet, "g_pD3DDevice->DrawIndexedPrimitive");
|
||||||
|
|
||||||
g_dwPrimPerFrame += DrawContext.dwHostPrimitiveCount;
|
g_dwPrimPerFrame += DrawContext.dwHostPrimitiveCount;
|
||||||
if (DrawContext.XboxPrimitiveType == X_D3DPT_LINELOOP) {
|
if (DrawContext.XboxPrimitiveType == XTL::X_D3DPT_LINELOOP) {
|
||||||
// Close line-loops using a final single line, drawn from the end to the start vertex
|
// Close line-loops using a final single line, drawn from the end to the start vertex
|
||||||
LOG_TEST_CASE("X_D3DPT_LINELOOP");
|
LOG_TEST_CASE("X_D3DPT_LINELOOP");
|
||||||
// Read the end and start index from the supplied index data
|
// Read the end and start index from the supplied index data
|
||||||
|
@ -7619,7 +7625,7 @@ void XTL::CxbxDrawIndexed(CxbxDrawContext &DrawContext)
|
||||||
// TODO : Move to own file
|
// TODO : Move to own file
|
||||||
// Drawing function specifically for rendering Xbox draw calls supplying a 'User Pointer'.
|
// Drawing function specifically for rendering Xbox draw calls supplying a 'User Pointer'.
|
||||||
// Called by D3DDevice_DrawVerticesUP, EmuExecutePushBufferRaw and EmuFlushIVB
|
// Called by D3DDevice_DrawVerticesUP, EmuExecutePushBufferRaw and EmuFlushIVB
|
||||||
void XTL::CxbxDrawPrimitiveUP(CxbxDrawContext &DrawContext)
|
void CxbxDrawPrimitiveUP(CxbxDrawContext &DrawContext)
|
||||||
{
|
{
|
||||||
LOG_INIT // Allows use of DEBUG_D3DRESULT
|
LOG_INIT // Allows use of DEBUG_D3DRESULT
|
||||||
|
|
||||||
|
@ -7629,7 +7635,7 @@ void XTL::CxbxDrawPrimitiveUP(CxbxDrawContext &DrawContext)
|
||||||
assert(DrawContext.dwIndexBase == 0); // No IndexBase under Draw*UP
|
assert(DrawContext.dwIndexBase == 0); // No IndexBase under Draw*UP
|
||||||
|
|
||||||
VertexBufferConverter.Apply(&DrawContext);
|
VertexBufferConverter.Apply(&DrawContext);
|
||||||
if (DrawContext.XboxPrimitiveType == X_D3DPT_QUADLIST) {
|
if (DrawContext.XboxPrimitiveType == XTL::X_D3DPT_QUADLIST) {
|
||||||
// LOG_TEST_CASE("X_D3DPT_QUADLIST"); // X-Marbles and XDK Sample PlayField hits this case
|
// LOG_TEST_CASE("X_D3DPT_QUADLIST"); // X-Marbles and XDK Sample PlayField hits this case
|
||||||
// Draw quadlists using a single 'quad-to-triangle mapping' index buffer :
|
// Draw quadlists using a single 'quad-to-triangle mapping' index buffer :
|
||||||
INDEX16 *pIndexData = CxbxAssureQuadListIndexBuffer(DrawContext.dwVertexCount);
|
INDEX16 *pIndexData = CxbxAssureQuadListIndexBuffer(DrawContext.dwVertexCount);
|
||||||
|
@ -7642,12 +7648,12 @@ void XTL::CxbxDrawPrimitiveUP(CxbxDrawContext &DrawContext)
|
||||||
INDEX16 HighIndex = (INDEX16)(DrawContext.dwVertexCount - 1);
|
INDEX16 HighIndex = (INDEX16)(DrawContext.dwVertexCount - 1);
|
||||||
|
|
||||||
HRESULT hRet = g_pD3DDevice->DrawIndexedPrimitiveUP(
|
HRESULT hRet = g_pD3DDevice->DrawIndexedPrimitiveUP(
|
||||||
D3DPT_TRIANGLELIST, // Draw indexed triangles instead of quads
|
XTL::D3DPT_TRIANGLELIST, // Draw indexed triangles instead of quads
|
||||||
LowIndex, // MinVertexIndex
|
LowIndex, // MinVertexIndex
|
||||||
(HighIndex - LowIndex) + 1, // NumVertexIndices
|
(HighIndex - LowIndex) + 1, // NumVertexIndices
|
||||||
PrimitiveCount,
|
PrimitiveCount,
|
||||||
pIndexData,
|
pIndexData,
|
||||||
D3DFMT_INDEX16, // IndexDataFormat
|
XTL::D3DFMT_INDEX16, // IndexDataFormat
|
||||||
DrawContext.pHostVertexStreamZeroData,
|
DrawContext.pHostVertexStreamZeroData,
|
||||||
DrawContext.uiHostVertexStreamZeroStride
|
DrawContext.uiHostVertexStreamZeroStride
|
||||||
);
|
);
|
||||||
|
@ -7666,7 +7672,7 @@ void XTL::CxbxDrawPrimitiveUP(CxbxDrawContext &DrawContext)
|
||||||
DEBUG_D3DRESULT(hRet, "g_pD3DDevice->DrawPrimitiveUP");
|
DEBUG_D3DRESULT(hRet, "g_pD3DDevice->DrawPrimitiveUP");
|
||||||
|
|
||||||
g_dwPrimPerFrame += DrawContext.dwHostPrimitiveCount;
|
g_dwPrimPerFrame += DrawContext.dwHostPrimitiveCount;
|
||||||
if (DrawContext.XboxPrimitiveType == X_D3DPT_LINELOOP) {
|
if (DrawContext.XboxPrimitiveType == XTL::X_D3DPT_LINELOOP) {
|
||||||
// Note : XDK samples reaching this case : DebugKeyboard, Gamepad, Tiling, ShadowBuffer
|
// Note : XDK samples reaching this case : DebugKeyboard, Gamepad, Tiling, ShadowBuffer
|
||||||
// Since we can use pHostVertexStreamZeroData here, we can close the line simpler than
|
// Since we can use pHostVertexStreamZeroData here, we can close the line simpler than
|
||||||
// via CxbxDrawIndexedClosingLine, by drawing two indices via DrawIndexedPrimitiveUP.
|
// via CxbxDrawIndexedClosingLine, by drawing two indices via DrawIndexedPrimitiveUP.
|
||||||
|
@ -7704,13 +7710,13 @@ void EmuUpdateActiveTextureStages()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XTL::CxbxUpdateNativeD3DResources()
|
void CxbxUpdateNativeD3DResources()
|
||||||
{
|
{
|
||||||
EmuUpdateActiveTextureStages();
|
EmuUpdateActiveTextureStages();
|
||||||
|
|
||||||
// If Pixel Shaders are not disabled, process them
|
// If Pixel Shaders are not disabled, process them
|
||||||
if (!g_DisablePixelShaders) {
|
if (!g_DisablePixelShaders) {
|
||||||
XTL::DxbxUpdateActivePixelShader();
|
DxbxUpdateActivePixelShader();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some titles set Vertex Shader constants directly via pushbuffers rather than through D3D
|
// Some titles set Vertex Shader constants directly via pushbuffers rather than through D3D
|
||||||
|
@ -7728,7 +7734,7 @@ void XTL::CxbxUpdateNativeD3DResources()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XTL::EmuUpdateDeferredStates();
|
EmuUpdateDeferredStates();
|
||||||
/* TODO : Port these :
|
/* TODO : Port these :
|
||||||
DxbxUpdateActiveVertexShader();
|
DxbxUpdateActiveVertexShader();
|
||||||
DxbxUpdateActiveTextures();
|
DxbxUpdateActiveTextures();
|
||||||
|
@ -7748,8 +7754,8 @@ VOID __declspec(noinline) D3DDevice_SetPixelShaderCommon(DWORD Handle)
|
||||||
// Copy the Pixel Shader data to the TemporaryPixelShaderRenderStates array
|
// Copy the Pixel Shader data to the TemporaryPixelShaderRenderStates array
|
||||||
// This mirrors the fact that unpathed SetPixelShader does the same thing!
|
// This mirrors the fact that unpathed SetPixelShader does the same thing!
|
||||||
if (g_D3DActivePixelShader != nullptr) {
|
if (g_D3DActivePixelShader != nullptr) {
|
||||||
memcpy(&(XTL::TemporaryPixelShaderRenderStates[XTL::X_D3DRS_PSALPHAINPUTS0]), g_D3DActivePixelShader->pPSDef, sizeof(XTL::X_D3DPIXELSHADERDEF) - 3 * sizeof(DWORD));
|
memcpy(&(TemporaryPixelShaderRenderStates[XTL::X_D3DRS_PSALPHAINPUTS0]), g_D3DActivePixelShader->pPSDef, sizeof(XTL::X_D3DPIXELSHADERDEF) - 3 * sizeof(DWORD));
|
||||||
XTL::TemporaryPixelShaderRenderStates[XTL::X_D3DRS_PSTEXTUREMODES] = g_D3DActivePixelShader->pPSDef->PSTextureModes;
|
TemporaryPixelShaderRenderStates[XTL::X_D3DRS_PSTEXTUREMODES] = g_D3DActivePixelShader->pPSDef->PSTextureModes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8324,9 +8330,9 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetPalette)
|
||||||
// g_pD3DDevice9->SetCurrentTexturePalette(Stage, Stage);
|
// g_pD3DDevice9->SetCurrentTexturePalette(Stage, Stage);
|
||||||
|
|
||||||
if (Stage < XTL::X_D3DTS_STAGECOUNT) {
|
if (Stage < XTL::X_D3DTS_STAGECOUNT) {
|
||||||
if (g_pCurrentPalette[Stage] != GetDataFromXboxResource(pPalette) && XTL::EmuD3DActiveTexture[Stage] != nullptr) {
|
if (g_pCurrentPalette[Stage] != GetDataFromXboxResource(pPalette) && EmuD3DActiveTexture[Stage] != nullptr) {
|
||||||
// If the palette for a texture has changed, we need to re-convert the texture
|
// If the palette for a texture has changed, we need to re-convert the texture
|
||||||
FreeHostResource(GetHostResourceKey(XTL::EmuD3DActiveTexture[Stage]));
|
FreeHostResource(GetHostResourceKey(EmuD3DActiveTexture[Stage]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache palette data and size
|
// Cache palette data and size
|
||||||
|
|
|
@ -11,13 +11,13 @@
|
||||||
// Walk an index buffer to find the minimum and maximum indices
|
// Walk an index buffer to find the minimum and maximum indices
|
||||||
|
|
||||||
// Default implementation
|
// Default implementation
|
||||||
void WalkIndexBuffer_NoSIMD(XTL::INDEX16 & LowIndex, XTL::INDEX16 & HighIndex, XTL::INDEX16 * pIndexData, DWORD dwIndexCount)
|
void WalkIndexBuffer_NoSIMD(INDEX16 & LowIndex, INDEX16 & HighIndex, INDEX16 * pIndexData, DWORD dwIndexCount)
|
||||||
{
|
{
|
||||||
// Determine highest and lowest index in use
|
// Determine highest and lowest index in use
|
||||||
LowIndex = pIndexData[0];
|
LowIndex = pIndexData[0];
|
||||||
HighIndex = LowIndex;
|
HighIndex = LowIndex;
|
||||||
for (unsigned int i = 1; i < dwIndexCount; i++) {
|
for (unsigned int i = 1; i < dwIndexCount; i++) {
|
||||||
XTL::INDEX16 Index = pIndexData[i];
|
INDEX16 Index = pIndexData[i];
|
||||||
if (LowIndex > Index)
|
if (LowIndex > Index)
|
||||||
LowIndex = Index;
|
LowIndex = Index;
|
||||||
if (HighIndex < Index)
|
if (HighIndex < Index)
|
||||||
|
@ -26,7 +26,7 @@ void WalkIndexBuffer_NoSIMD(XTL::INDEX16 & LowIndex, XTL::INDEX16 & HighIndex, X
|
||||||
}
|
}
|
||||||
|
|
||||||
//SSE 4.1 implementation
|
//SSE 4.1 implementation
|
||||||
void WalkIndexBuffer_SSE41(XTL::INDEX16 & LowIndex, XTL::INDEX16 & HighIndex, XTL::INDEX16 * pIndexData, DWORD dwIndexCount)
|
void WalkIndexBuffer_SSE41(INDEX16 & LowIndex, INDEX16 & HighIndex, INDEX16 * pIndexData, DWORD dwIndexCount)
|
||||||
{
|
{
|
||||||
// We can fit 8 ushorts into 128 bit SIMD registers
|
// We can fit 8 ushorts into 128 bit SIMD registers
|
||||||
int iterations = dwIndexCount / 8;
|
int iterations = dwIndexCount / 8;
|
||||||
|
@ -58,8 +58,8 @@ void WalkIndexBuffer_SSE41(XTL::INDEX16 & LowIndex, XTL::INDEX16 & HighIndex, XT
|
||||||
max = _mm_minpos_epu16(max);
|
max = _mm_minpos_epu16(max);
|
||||||
|
|
||||||
// Get the min and max out
|
// Get the min and max out
|
||||||
LowIndex = (XTL::INDEX16) _mm_cvtsi128_si32(min);
|
LowIndex = (INDEX16) _mm_cvtsi128_si32(min);
|
||||||
HighIndex = (XTL::INDEX16) USHRT_MAX - _mm_cvtsi128_si32(max); // invert back
|
HighIndex = (INDEX16) USHRT_MAX - _mm_cvtsi128_si32(max); // invert back
|
||||||
|
|
||||||
// Compare with the remaining values that didn't fit neatly into the SIMD registers
|
// Compare with the remaining values that didn't fit neatly into the SIMD registers
|
||||||
for (DWORD i = dwIndexCount - remainder; i < dwIndexCount; i++) {
|
for (DWORD i = dwIndexCount - remainder; i < dwIndexCount; i++) {
|
||||||
|
@ -74,8 +74,8 @@ void WalkIndexBuffer_SSE41(XTL::INDEX16 & LowIndex, XTL::INDEX16 & HighIndex, XT
|
||||||
// TODO AVX2, AVX512 implementations
|
// TODO AVX2, AVX512 implementations
|
||||||
|
|
||||||
// Detect SSE support to select real implementation on first call
|
// Detect SSE support to select real implementation on first call
|
||||||
void(*WalkIndexBuffer)(XTL::INDEX16 &, XTL::INDEX16 &, XTL::INDEX16 *, DWORD) =
|
void(*WalkIndexBuffer)(INDEX16 &, INDEX16 &, INDEX16 *, DWORD) =
|
||||||
[](XTL::INDEX16 &LowIndex, XTL::INDEX16 &HighIndex, XTL::INDEX16 *pIndexData, DWORD dwIndexCount)
|
[](INDEX16 &LowIndex, INDEX16 &HighIndex, INDEX16 *pIndexData, DWORD dwIndexCount)
|
||||||
{
|
{
|
||||||
SimdCaps supports;
|
SimdCaps supports;
|
||||||
if (supports.SSE41())
|
if (supports.SSE41())
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
|
|
||||||
extern void(*WalkIndexBuffer)
|
extern void(*WalkIndexBuffer)
|
||||||
(
|
(
|
||||||
XTL::INDEX16 &LowIndex,
|
INDEX16 &LowIndex,
|
||||||
XTL::INDEX16 &HighIndex,
|
INDEX16 &HighIndex,
|
||||||
XTL::INDEX16 *pIndexData,
|
INDEX16 *pIndexData,
|
||||||
DWORD dwIndexCount
|
DWORD dwIndexCount
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -807,7 +807,7 @@ void ____UYVYToARGBRow_C(const uint8_t* src_uyvy,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const XTL::FormatToARGBRow ComponentConverters[] = {
|
static const FormatToARGBRow ComponentConverters[] = {
|
||||||
nullptr, // NoCmpnts,
|
nullptr, // NoCmpnts,
|
||||||
ARGB1555ToARGBRow_C, // A1R5G5B5,
|
ARGB1555ToARGBRow_C, // A1R5G5B5,
|
||||||
X1R5G5B5ToARGBRow_C, // X1R5G5B5, // Test : Convert X into 255
|
X1R5G5B5ToARGBRow_C, // X1R5G5B5, // Test : Convert X into 255
|
||||||
|
@ -942,9 +942,9 @@ static const FormatInfo FormatInfos[] = {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
const XTL::FormatToARGBRow XTL::EmuXBFormatComponentConverter(X_D3DFORMAT Format)
|
const FormatToARGBRow EmuXBFormatComponentConverter(XTL::X_D3DFORMAT Format)
|
||||||
{
|
{
|
||||||
if (Format <= X_D3DFMT_LIN_R8G8B8A8)
|
if (Format <= XTL::X_D3DFMT_LIN_R8G8B8A8)
|
||||||
if (FormatInfos[Format].components != NoCmpnts)
|
if (FormatInfos[Format].components != NoCmpnts)
|
||||||
return ComponentConverters[FormatInfos[Format].components];
|
return ComponentConverters[FormatInfos[Format].components];
|
||||||
|
|
||||||
|
@ -952,7 +952,7 @@ const XTL::FormatToARGBRow XTL::EmuXBFormatComponentConverter(X_D3DFORMAT Format
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is there a converter available from the supplied format to ARGB?
|
// Is there a converter available from the supplied format to ARGB?
|
||||||
bool XTL::EmuXBFormatCanBeConvertedToARGB(X_D3DFORMAT Format)
|
bool EmuXBFormatCanBeConvertedToARGB(XTL::X_D3DFORMAT Format)
|
||||||
{
|
{
|
||||||
const FormatToARGBRow info = EmuXBFormatComponentConverter(Format);
|
const FormatToARGBRow info = EmuXBFormatComponentConverter(Format);
|
||||||
return (info != nullptr);
|
return (info != nullptr);
|
||||||
|
@ -960,7 +960,7 @@ bool XTL::EmuXBFormatCanBeConvertedToARGB(X_D3DFORMAT Format)
|
||||||
|
|
||||||
// Returns if convertion to ARGB is required. This is the case when
|
// Returns if convertion to ARGB is required. This is the case when
|
||||||
// the format has a warning message and there's a converter present.
|
// the format has a warning message and there's a converter present.
|
||||||
bool XTL::EmuXBFormatRequiresConversionToARGB(X_D3DFORMAT Format)
|
bool EmuXBFormatRequiresConversionToARGB(XTL::X_D3DFORMAT Format)
|
||||||
{
|
{
|
||||||
if (FormatInfos[Format].warning != nullptr)
|
if (FormatInfos[Format].warning != nullptr)
|
||||||
if (EmuXBFormatCanBeConvertedToARGB(Format))
|
if (EmuXBFormatCanBeConvertedToARGB(Format))
|
||||||
|
@ -969,62 +969,64 @@ bool XTL::EmuXBFormatRequiresConversionToARGB(X_D3DFORMAT Format)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD XTL::EmuXBFormatBitsPerPixel(X_D3DFORMAT Format)
|
DWORD EmuXBFormatBitsPerPixel(XTL::X_D3DFORMAT Format)
|
||||||
{
|
{
|
||||||
if (Format <= X_D3DFMT_LIN_R8G8B8A8)
|
if (Format <= XTL::X_D3DFMT_LIN_R8G8B8A8)
|
||||||
if (FormatInfos[Format].bits_per_pixel > 0) // TODO : Remove this
|
if (FormatInfos[Format].bits_per_pixel > 0) // TODO : Remove this
|
||||||
return FormatInfos[Format].bits_per_pixel;
|
return FormatInfos[Format].bits_per_pixel;
|
||||||
|
|
||||||
return 16; // TODO : 8
|
return 16; // TODO : 8
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD XTL::EmuXBFormatBytesPerPixel(X_D3DFORMAT Format)
|
DWORD EmuXBFormatBytesPerPixel(XTL::X_D3DFORMAT Format)
|
||||||
{
|
{
|
||||||
return ((EmuXBFormatBitsPerPixel(Format) + 4) / 8);
|
return ((EmuXBFormatBitsPerPixel(Format) + 4) / 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL XTL::EmuXBFormatIsCompressed(X_D3DFORMAT Format)
|
BOOL EmuXBFormatIsCompressed(XTL::X_D3DFORMAT Format)
|
||||||
{
|
{
|
||||||
if (Format <= X_D3DFMT_LIN_R8G8B8A8)
|
if (Format <= XTL::X_D3DFMT_LIN_R8G8B8A8)
|
||||||
return (FormatInfos[Format].stored == Cmprsd);
|
return (FormatInfos[Format].stored == Cmprsd);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL XTL::EmuXBFormatIsLinear(X_D3DFORMAT Format)
|
BOOL EmuXBFormatIsLinear(XTL::X_D3DFORMAT Format)
|
||||||
{
|
{
|
||||||
if (Format <= X_D3DFMT_LIN_R8G8B8A8)
|
if (Format <= XTL::X_D3DFMT_LIN_R8G8B8A8)
|
||||||
return (FormatInfos[Format].stored == Linear);
|
return (FormatInfos[Format].stored == Linear);
|
||||||
|
|
||||||
return (Format == X_D3DFMT_VERTEXDATA); // TODO : false;
|
return (Format == XTL::X_D3DFMT_VERTEXDATA); // TODO : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL XTL::EmuXBFormatIsSwizzled(X_D3DFORMAT Format)
|
BOOL EmuXBFormatIsSwizzled(XTL::X_D3DFORMAT Format)
|
||||||
{
|
{
|
||||||
if (Format <= X_D3DFMT_LIN_R8G8B8A8)
|
if (Format <= XTL::X_D3DFMT_LIN_R8G8B8A8)
|
||||||
return (FormatInfos[Format].stored == Swzzld);
|
return (FormatInfos[Format].stored == Swzzld);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL XTL::EmuXBFormatIsRenderTarget(X_D3DFORMAT Format)
|
BOOL EmuXBFormatIsRenderTarget(XTL::X_D3DFORMAT Format)
|
||||||
{
|
{
|
||||||
if (Format <= X_D3DFMT_LIN_R8G8B8A8)
|
if (Format <= XTL::X_D3DFMT_LIN_R8G8B8A8)
|
||||||
return (FormatInfos[Format].usage == RenderTarget);
|
return (FormatInfos[Format].usage == RenderTarget);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL XTL::EmuXBFormatIsDepthBuffer(X_D3DFORMAT Format)
|
BOOL EmuXBFormatIsDepthBuffer(XTL::X_D3DFORMAT Format)
|
||||||
{
|
{
|
||||||
if (Format <= X_D3DFMT_LIN_R8G8B8A8)
|
if (Format <= XTL::X_D3DFMT_LIN_R8G8B8A8)
|
||||||
return (FormatInfos[Format].usage == DepthBuffer);
|
return (FormatInfos[Format].usage == DepthBuffer);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
XTL::D3DFORMAT XTL::EmuXB2PC_D3DFormat(X_D3DFORMAT Format)
|
XTL::D3DFORMAT EmuXB2PC_D3DFormat(XTL::X_D3DFORMAT Format)
|
||||||
{
|
{
|
||||||
|
using namespace XTL;
|
||||||
|
|
||||||
if (Format <= X_D3DFMT_LIN_R8G8B8A8 && Format != -1 /*X_D3DFMT_UNKNOWN*/) // The last bit prevents crashing (Metal Slug 3)
|
if (Format <= X_D3DFMT_LIN_R8G8B8A8 && Format != -1 /*X_D3DFMT_UNKNOWN*/) // The last bit prevents crashing (Metal Slug 3)
|
||||||
{
|
{
|
||||||
const FormatInfo *info = &FormatInfos[Format];
|
const FormatInfo *info = &FormatInfos[Format];
|
||||||
|
@ -1047,8 +1049,10 @@ XTL::D3DFORMAT XTL::EmuXB2PC_D3DFormat(X_D3DFORMAT Format)
|
||||||
return D3DFMT_UNKNOWN;
|
return D3DFMT_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
XTL::X_D3DFORMAT XTL::EmuPC2XB_D3DFormat(D3DFORMAT Format, bool bPreferLinear)
|
XTL::X_D3DFORMAT EmuPC2XB_D3DFormat(XTL::D3DFORMAT Format, bool bPreferLinear)
|
||||||
{
|
{
|
||||||
|
using namespace XTL;
|
||||||
|
|
||||||
X_D3DFORMAT result;
|
X_D3DFORMAT result;
|
||||||
switch(Format)
|
switch(Format)
|
||||||
{
|
{
|
||||||
|
@ -1129,8 +1133,10 @@ XTL::X_D3DFORMAT XTL::EmuPC2XB_D3DFormat(D3DFORMAT Format, bool bPreferLinear)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD XTL::EmuXB2PC_D3DLock(DWORD Flags)
|
DWORD EmuXB2PC_D3DLock(DWORD Flags)
|
||||||
{
|
{
|
||||||
|
using namespace XTL;
|
||||||
|
|
||||||
DWORD NewFlags = 0;
|
DWORD NewFlags = 0;
|
||||||
|
|
||||||
// Need to convert the flags, TODO: fix the xbox extensions
|
// Need to convert the flags, TODO: fix the xbox extensions
|
||||||
|
@ -1150,8 +1156,10 @@ DWORD XTL::EmuXB2PC_D3DLock(DWORD Flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert from xbox to pc multisample formats
|
// convert from xbox to pc multisample formats
|
||||||
XTL::D3DMULTISAMPLE_TYPE XTL::EmuXB2PC_D3DMultiSampleFormat(DWORD Type)
|
XTL::D3DMULTISAMPLE_TYPE EmuXB2PC_D3DMultiSampleFormat(DWORD Type)
|
||||||
{
|
{
|
||||||
|
using namespace XTL;
|
||||||
|
|
||||||
D3DMULTISAMPLE_TYPE result;
|
D3DMULTISAMPLE_TYPE result;
|
||||||
switch (Type & 0xFFFF)
|
switch (Type & 0xFFFF)
|
||||||
{
|
{
|
||||||
|
@ -1182,7 +1190,7 @@ XTL::D3DMULTISAMPLE_TYPE XTL::EmuXB2PC_D3DMultiSampleFormat(DWORD Type)
|
||||||
}
|
}
|
||||||
|
|
||||||
// lookup table for converting vertex count to primitive count
|
// lookup table for converting vertex count to primitive count
|
||||||
UINT XTL::EmuD3DVertexToPrimitive[11][2] =
|
UINT EmuD3DVertexToPrimitive[11][2] =
|
||||||
{
|
{
|
||||||
{0, 0}, // NULL
|
{0, 0}, // NULL
|
||||||
{1, 0}, // X_D3DPT_POINTLIST
|
{1, 0}, // X_D3DPT_POINTLIST
|
||||||
|
@ -1198,7 +1206,7 @@ UINT XTL::EmuD3DVertexToPrimitive[11][2] =
|
||||||
};
|
};
|
||||||
|
|
||||||
// conversion table for xbox->pc primitive types
|
// conversion table for xbox->pc primitive types
|
||||||
XTL::D3DPRIMITIVETYPE XTL::EmuPrimitiveTypeLookup[] =
|
XTL::D3DPRIMITIVETYPE EmuPrimitiveTypeLookup[] =
|
||||||
{
|
{
|
||||||
/* NULL = 0 */ (XTL::D3DPRIMITIVETYPE)0,
|
/* NULL = 0 */ (XTL::D3DPRIMITIVETYPE)0,
|
||||||
/* D3DPT_POINTLIST = 1, */ XTL::D3DPT_POINTLIST,
|
/* D3DPT_POINTLIST = 1, */ XTL::D3DPT_POINTLIST,
|
||||||
|
@ -1214,7 +1222,7 @@ XTL::D3DPRIMITIVETYPE XTL::EmuPrimitiveTypeLookup[] =
|
||||||
/* D3DPT_MAX = 11, */ (XTL::D3DPRIMITIVETYPE)11
|
/* D3DPT_MAX = 11, */ (XTL::D3DPRIMITIVETYPE)11
|
||||||
};
|
};
|
||||||
|
|
||||||
void XTL::EmuUnswizzleBox
|
void EmuUnswizzleBox
|
||||||
(
|
(
|
||||||
CONST PVOID pSrcBuff,
|
CONST PVOID pSrcBuff,
|
||||||
CONST DWORD dwWidth,
|
CONST DWORD dwWidth,
|
||||||
|
@ -1328,9 +1336,6 @@ void XTL::EmuUnswizzleBox
|
||||||
}
|
}
|
||||||
} // EmuUnswizzleBox NOPATCH
|
} // EmuUnswizzleBox NOPATCH
|
||||||
|
|
||||||
namespace XTL
|
|
||||||
{
|
|
||||||
|
|
||||||
const RenderStateInfo DxbxRenderStateInfo[] = {
|
const RenderStateInfo DxbxRenderStateInfo[] = {
|
||||||
|
|
||||||
// String Ord Version Type Method Native
|
// String Ord Version Type Method Native
|
||||||
|
@ -1392,25 +1397,25 @@ const RenderStateInfo DxbxRenderStateInfo[] = {
|
||||||
{ "D3DRS_PSDOTMAPPING" /*= 55*/, 3424, xtDWORD, NV2A_TX_SHADER_DOTMAPPING },
|
{ "D3DRS_PSDOTMAPPING" /*= 55*/, 3424, xtDWORD, NV2A_TX_SHADER_DOTMAPPING },
|
||||||
{ "D3DRS_PSINPUTTEXTURE" /*= 56*/, 3424, xtDWORD, NV2A_TX_SHADER_PREVIOUS },
|
{ "D3DRS_PSINPUTTEXTURE" /*= 56*/, 3424, xtDWORD, NV2A_TX_SHADER_PREVIOUS },
|
||||||
// End of "pixel-shader" render states, continuing with "simple" render states :
|
// End of "pixel-shader" render states, continuing with "simple" render states :
|
||||||
{ "D3DRS_ZFUNC" /*= 57*/, 3424, xtD3DCMPFUNC, NV2A_DEPTH_FUNC, D3DRS_ZFUNC },
|
{ "D3DRS_ZFUNC" /*= 57*/, 3424, xtD3DCMPFUNC, NV2A_DEPTH_FUNC, XTL::D3DRS_ZFUNC },
|
||||||
{ "D3DRS_ALPHAFUNC" /*= 58*/, 3424, xtD3DCMPFUNC, NV2A_ALPHA_FUNC_FUNC, D3DRS_ALPHAFUNC },
|
{ "D3DRS_ALPHAFUNC" /*= 58*/, 3424, xtD3DCMPFUNC, NV2A_ALPHA_FUNC_FUNC, XTL::D3DRS_ALPHAFUNC },
|
||||||
{ "D3DRS_ALPHABLENDENABLE" /*= 59*/, 3424, xtBOOL, NV2A_BLEND_FUNC_ENABLE, D3DRS_ALPHABLENDENABLE, "TRUE to enable alpha blending" },
|
{ "D3DRS_ALPHABLENDENABLE" /*= 59*/, 3424, xtBOOL, NV2A_BLEND_FUNC_ENABLE, XTL::D3DRS_ALPHABLENDENABLE, "TRUE to enable alpha blending" },
|
||||||
{ "D3DRS_ALPHATESTENABLE" /*= 60*/, 3424, xtBOOL, NV2A_ALPHA_FUNC_ENABLE, D3DRS_ALPHATESTENABLE, "TRUE to enable alpha tests" },
|
{ "D3DRS_ALPHATESTENABLE" /*= 60*/, 3424, xtBOOL, NV2A_ALPHA_FUNC_ENABLE, XTL::D3DRS_ALPHATESTENABLE, "TRUE to enable alpha tests" },
|
||||||
{ "D3DRS_ALPHAREF" /*= 61*/, 3424, xtBYTE, NV2A_ALPHA_FUNC_REF, D3DRS_ALPHAREF },
|
{ "D3DRS_ALPHAREF" /*= 61*/, 3424, xtBYTE, NV2A_ALPHA_FUNC_REF, XTL::D3DRS_ALPHAREF },
|
||||||
{ "D3DRS_SRCBLEND" /*= 62*/, 3424, xtD3DBLEND, NV2A_BLEND_FUNC_SRC, D3DRS_SRCBLEND },
|
{ "D3DRS_SRCBLEND" /*= 62*/, 3424, xtD3DBLEND, NV2A_BLEND_FUNC_SRC, XTL::D3DRS_SRCBLEND },
|
||||||
{ "D3DRS_DESTBLEND" /*= 63*/, 3424, xtD3DBLEND, NV2A_BLEND_FUNC_DST, D3DRS_DESTBLEND },
|
{ "D3DRS_DESTBLEND" /*= 63*/, 3424, xtD3DBLEND, NV2A_BLEND_FUNC_DST, XTL::D3DRS_DESTBLEND },
|
||||||
{ "D3DRS_ZWRITEENABLE" /*= 64*/, 3424, xtBOOL, NV2A_DEPTH_WRITE_ENABLE, D3DRS_ZWRITEENABLE, "TRUE to enable Z writes" },
|
{ "D3DRS_ZWRITEENABLE" /*= 64*/, 3424, xtBOOL, NV2A_DEPTH_WRITE_ENABLE, XTL::D3DRS_ZWRITEENABLE, "TRUE to enable Z writes" },
|
||||||
{ "D3DRS_DITHERENABLE" /*= 65*/, 3424, xtBOOL, NV2A_DITHER_ENABLE, D3DRS_DITHERENABLE, "TRUE to enable dithering" },
|
{ "D3DRS_DITHERENABLE" /*= 65*/, 3424, xtBOOL, NV2A_DITHER_ENABLE, XTL::D3DRS_DITHERENABLE, "TRUE to enable dithering" },
|
||||||
{ "D3DRS_SHADEMODE" /*= 66*/, 3424, xtD3DSHADEMODE, NV2A_SHADE_MODEL, D3DRS_SHADEMODE },
|
{ "D3DRS_SHADEMODE" /*= 66*/, 3424, xtD3DSHADEMODE, NV2A_SHADE_MODEL, XTL::D3DRS_SHADEMODE },
|
||||||
{ "D3DRS_COLORWRITEENABLE" /*= 67*/, 3424, xtD3DCOLORWRITEENABLE, NV2A_COLOR_MASK, D3DRS_COLORWRITEENABLE }, // *_ALPHA, etc. per-channel write enable
|
{ "D3DRS_COLORWRITEENABLE" /*= 67*/, 3424, xtD3DCOLORWRITEENABLE, NV2A_COLOR_MASK, XTL::D3DRS_COLORWRITEENABLE }, // *_ALPHA, etc. per-channel write enable
|
||||||
{ "D3DRS_STENCILZFAIL" /*= 68*/, 3424, xtD3DSTENCILOP, NV2A_STENCIL_OP_ZFAIL, D3DRS_STENCILZFAIL, "Operation to do if stencil test passes and Z test fails" },
|
{ "D3DRS_STENCILZFAIL" /*= 68*/, 3424, xtD3DSTENCILOP, NV2A_STENCIL_OP_ZFAIL, XTL::D3DRS_STENCILZFAIL, "Operation to do if stencil test passes and Z test fails" },
|
||||||
{ "D3DRS_STENCILPASS" /*= 69*/, 3424, xtD3DSTENCILOP, NV2A_STENCIL_OP_ZPASS, D3DRS_STENCILPASS, "Operation to do if both stencil and Z tests pass" },
|
{ "D3DRS_STENCILPASS" /*= 69*/, 3424, xtD3DSTENCILOP, NV2A_STENCIL_OP_ZPASS, XTL::D3DRS_STENCILPASS, "Operation to do if both stencil and Z tests pass" },
|
||||||
{ "D3DRS_STENCILFUNC" /*= 70*/, 3424, xtD3DCMPFUNC, NV2A_STENCIL_FUNC_FUNC, D3DRS_STENCILFUNC },
|
{ "D3DRS_STENCILFUNC" /*= 70*/, 3424, xtD3DCMPFUNC, NV2A_STENCIL_FUNC_FUNC, XTL::D3DRS_STENCILFUNC },
|
||||||
{ "D3DRS_STENCILREF" /*= 71*/, 3424, xtBYTE, NV2A_STENCIL_FUNC_REF, D3DRS_STENCILREF, "BYTE reference value used in stencil test" },
|
{ "D3DRS_STENCILREF" /*= 71*/, 3424, xtBYTE, NV2A_STENCIL_FUNC_REF, XTL::D3DRS_STENCILREF, "BYTE reference value used in stencil test" },
|
||||||
{ "D3DRS_STENCILMASK" /*= 72*/, 3424, xtBYTE, NV2A_STENCIL_FUNC_MASK, D3DRS_STENCILMASK, "BYTE mask value used in stencil test" },
|
{ "D3DRS_STENCILMASK" /*= 72*/, 3424, xtBYTE, NV2A_STENCIL_FUNC_MASK, XTL::D3DRS_STENCILMASK, "BYTE mask value used in stencil test" },
|
||||||
{ "D3DRS_STENCILWRITEMASK" /*= 73*/, 3424, xtBYTE, NV2A_STENCIL_MASK, D3DRS_STENCILWRITEMASK, "BYTE write mask applied to values written to stencil buffer" },
|
{ "D3DRS_STENCILWRITEMASK" /*= 73*/, 3424, xtBYTE, NV2A_STENCIL_MASK, XTL::D3DRS_STENCILWRITEMASK, "BYTE write mask applied to values written to stencil buffer" },
|
||||||
{ "D3DRS_BLENDOP" /*= 74*/, 3424, xtD3DBLENDOP, NV2A_BLEND_EQUATION, D3DRS_BLENDOP },
|
{ "D3DRS_BLENDOP" /*= 74*/, 3424, xtD3DBLENDOP, NV2A_BLEND_EQUATION, XTL::D3DRS_BLENDOP },
|
||||||
{ "D3DRS_BLENDCOLOR" /*= 75*/, 3424, xtD3DCOLOR, NV2A_BLEND_COLOR, D3DRS_BLENDFACTOR, "D3DCOLOR for D3DBLEND_CONSTANTCOLOR" },
|
{ "D3DRS_BLENDCOLOR" /*= 75*/, 3424, xtD3DCOLOR, NV2A_BLEND_COLOR, XTL::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
|
// 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_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_NONE, "float Z factor for shadow maps" },
|
||||||
|
@ -1429,39 +1434,39 @@ const RenderStateInfo DxbxRenderStateInfo[] = {
|
||||||
{ "D3DRS_SIMPLE_UNUSED2" /*= 90*/, 4627, xtDWORD, 0 },
|
{ "D3DRS_SIMPLE_UNUSED2" /*= 90*/, 4627, xtDWORD, 0 },
|
||||||
{ "D3DRS_SIMPLE_UNUSED1" /*= 91*/, 4627, xtDWORD, 0 },
|
{ "D3DRS_SIMPLE_UNUSED1" /*= 91*/, 4627, xtDWORD, 0 },
|
||||||
// End of "simple" render states, continuing with "deferred" render states :
|
// End of "simple" render states, continuing with "deferred" render states :
|
||||||
{ "D3DRS_FOGENABLE" /*= 92*/, 3424, xtBOOL, NV2A_FOG_ENABLE, D3DRS_FOGENABLE },
|
{ "D3DRS_FOGENABLE" /*= 92*/, 3424, xtBOOL, NV2A_FOG_ENABLE, XTL::D3DRS_FOGENABLE },
|
||||||
{ "D3DRS_FOGTABLEMODE" /*= 93*/, 3424, xtD3DFOGMODE, NV2A_FOG_MODE, D3DRS_FOGTABLEMODE },
|
{ "D3DRS_FOGTABLEMODE" /*= 93*/, 3424, xtD3DFOGMODE, NV2A_FOG_MODE, XTL::D3DRS_FOGTABLEMODE },
|
||||||
{ "D3DRS_FOGSTART" /*= 94*/, 3424, xtFloat, NV2A_FOG_COORD_DIST, D3DRS_FOGSTART },
|
{ "D3DRS_FOGSTART" /*= 94*/, 3424, xtFloat, NV2A_FOG_COORD_DIST, XTL::D3DRS_FOGSTART },
|
||||||
{ "D3DRS_FOGEND" /*= 95*/, 3424, xtFloat, NV2A_FOG_MODE, D3DRS_FOGEND },
|
{ "D3DRS_FOGEND" /*= 95*/, 3424, xtFloat, NV2A_FOG_MODE, XTL::D3DRS_FOGEND },
|
||||||
{ "D3DRS_FOGDENSITY" /*= 96*/, 3424, xtFloat, NV2A_FOG_EQUATION_CONSTANT, D3DRS_FOGDENSITY }, // + NV2A_FOG_EQUATION_LINEAR + NV2A_FOG_EQUATION_QUADRATIC
|
{ "D3DRS_FOGDENSITY" /*= 96*/, 3424, xtFloat, NV2A_FOG_EQUATION_CONSTANT, XTL::D3DRS_FOGDENSITY }, // + NV2A_FOG_EQUATION_LINEAR + NV2A_FOG_EQUATION_QUADRATIC
|
||||||
{ "D3DRS_RANGEFOGENABLE" /*= 97*/, 3424, xtBOOL, NV2A_FOG_COORD_DIST, D3DRS_RANGEFOGENABLE },
|
{ "D3DRS_RANGEFOGENABLE" /*= 97*/, 3424, xtBOOL, NV2A_FOG_COORD_DIST, XTL::D3DRS_RANGEFOGENABLE },
|
||||||
{ "D3DRS_WRAP0" /*= 98*/, 3424, xtD3DWRAP, NV2A_TX_WRAP(0), D3DRS_WRAP0 },
|
{ "D3DRS_WRAP0" /*= 98*/, 3424, xtD3DWRAP, NV2A_TX_WRAP(0), XTL::D3DRS_WRAP0 },
|
||||||
{ "D3DRS_WRAP1" /*= 99*/, 3424, xtD3DWRAP, NV2A_TX_WRAP(1), D3DRS_WRAP1 },
|
{ "D3DRS_WRAP1" /*= 99*/, 3424, xtD3DWRAP, NV2A_TX_WRAP(1), XTL::D3DRS_WRAP1 },
|
||||||
{ "D3DRS_WRAP2" /*= 100*/, 3424, xtD3DWRAP, NV2A_TX_WRAP(2), D3DRS_WRAP2 },
|
{ "D3DRS_WRAP2" /*= 100*/, 3424, xtD3DWRAP, NV2A_TX_WRAP(2), XTL::D3DRS_WRAP2 },
|
||||||
{ "D3DRS_WRAP3" /*= 101*/, 3424, xtD3DWRAP, NV2A_TX_WRAP(3), D3DRS_WRAP3 },
|
{ "D3DRS_WRAP3" /*= 101*/, 3424, xtD3DWRAP, NV2A_TX_WRAP(3), XTL::D3DRS_WRAP3 },
|
||||||
{ "D3DRS_LIGHTING" /*= 102*/, 3424, xtBOOL, NV2A_LIGHT_MODEL, D3DRS_LIGHTING }, // TODO : Needs push-buffer data conversion
|
{ "D3DRS_LIGHTING" /*= 102*/, 3424, xtBOOL, NV2A_LIGHT_MODEL, XTL::D3DRS_LIGHTING }, // TODO : Needs push-buffer data conversion
|
||||||
{ "D3DRS_SPECULARENABLE" /*= 103*/, 3424, xtBOOL, NV2A_RC_FINAL0, D3DRS_SPECULARENABLE },
|
{ "D3DRS_SPECULARENABLE" /*= 103*/, 3424, xtBOOL, NV2A_RC_FINAL0, XTL::D3DRS_SPECULARENABLE },
|
||||||
{ "D3DRS_LOCALVIEWER" /*= 104*/, 3424, xtBOOL, 0, D3DRS_LOCALVIEWER },
|
{ "D3DRS_LOCALVIEWER" /*= 104*/, 3424, xtBOOL, 0, XTL::D3DRS_LOCALVIEWER },
|
||||||
{ "D3DRS_COLORVERTEX" /*= 105*/, 3424, xtBOOL, 0, D3DRS_COLORVERTEX },
|
{ "D3DRS_COLORVERTEX" /*= 105*/, 3424, xtBOOL, 0, XTL::D3DRS_COLORVERTEX },
|
||||||
{ "D3DRS_BACKSPECULARMATERIALSOURCE" /*= 106*/, 3424, xtD3DMCS, 0 }, // nsp.
|
{ "D3DRS_BACKSPECULARMATERIALSOURCE" /*= 106*/, 3424, xtD3DMCS, 0 }, // nsp.
|
||||||
{ "D3DRS_BACKDIFFUSEMATERIALSOURCE" /*= 107*/, 3424, xtD3DMCS, 0 }, // nsp.
|
{ "D3DRS_BACKDIFFUSEMATERIALSOURCE" /*= 107*/, 3424, xtD3DMCS, 0 }, // nsp.
|
||||||
{ "D3DRS_BACKAMBIENTMATERIALSOURCE" /*= 108*/, 3424, xtD3DMCS, 0 }, // nsp.
|
{ "D3DRS_BACKAMBIENTMATERIALSOURCE" /*= 108*/, 3424, xtD3DMCS, 0 }, // nsp.
|
||||||
{ "D3DRS_BACKEMISSIVEMATERIALSOURCE" /*= 109*/, 3424, xtD3DMCS, 0 }, // nsp.
|
{ "D3DRS_BACKEMISSIVEMATERIALSOURCE" /*= 109*/, 3424, xtD3DMCS, 0 }, // nsp.
|
||||||
{ "D3DRS_SPECULARMATERIALSOURCE" /*= 110*/, 3424, xtD3DMCS, NV2A_COLOR_MATERIAL, D3DRS_SPECULARMATERIALSOURCE },
|
{ "D3DRS_SPECULARMATERIALSOURCE" /*= 110*/, 3424, xtD3DMCS, NV2A_COLOR_MATERIAL, XTL::D3DRS_SPECULARMATERIALSOURCE },
|
||||||
{ "D3DRS_DIFFUSEMATERIALSOURCE" /*= 111*/, 3424, xtD3DMCS, 0, D3DRS_DIFFUSEMATERIALSOURCE },
|
{ "D3DRS_DIFFUSEMATERIALSOURCE" /*= 111*/, 3424, xtD3DMCS, 0, XTL::D3DRS_DIFFUSEMATERIALSOURCE },
|
||||||
{ "D3DRS_AMBIENTMATERIALSOURCE" /*= 112*/, 3424, xtD3DMCS, 0, D3DRS_AMBIENTMATERIALSOURCE },
|
{ "D3DRS_AMBIENTMATERIALSOURCE" /*= 112*/, 3424, xtD3DMCS, 0, XTL::D3DRS_AMBIENTMATERIALSOURCE },
|
||||||
{ "D3DRS_EMISSIVEMATERIALSOURCE" /*= 113*/, 3424, xtD3DMCS, 0, D3DRS_EMISSIVEMATERIALSOURCE },
|
{ "D3DRS_EMISSIVEMATERIALSOURCE" /*= 113*/, 3424, xtD3DMCS, 0, XTL::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_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_AMBIENT" /*= 115*/, 3424, xtD3DCOLOR, NV2A_LIGHT_MODEL_FRONT_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_R, XTL::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" /*= 116*/, 3424, xtFloat, NV2A_POINT_PARAMETER(0), XTL::D3DRS_POINTSIZE },
|
||||||
{ "D3DRS_POINTSIZE_MIN" /*= 117*/, 3424, xtFloat, 0, D3DRS_POINTSIZE_MIN },
|
{ "D3DRS_POINTSIZE_MIN" /*= 117*/, 3424, xtFloat, 0, XTL::D3DRS_POINTSIZE_MIN },
|
||||||
{ "D3DRS_POINTSPRITEENABLE" /*= 118*/, 3424, xtBOOL, NV2A_POINT_SMOOTH_ENABLE, D3DRS_POINTSPRITEENABLE },
|
{ "D3DRS_POINTSPRITEENABLE" /*= 118*/, 3424, xtBOOL, NV2A_POINT_SMOOTH_ENABLE, XTL::D3DRS_POINTSPRITEENABLE },
|
||||||
{ "D3DRS_POINTSCALEENABLE" /*= 119*/, 3424, xtBOOL, NV2A_POINT_PARAMETERS_ENABLE, D3DRS_POINTSCALEENABLE },
|
{ "D3DRS_POINTSCALEENABLE" /*= 119*/, 3424, xtBOOL, NV2A_POINT_PARAMETERS_ENABLE, XTL::D3DRS_POINTSCALEENABLE },
|
||||||
{ "D3DRS_POINTSCALE_A" /*= 120*/, 3424, xtFloat, 0, D3DRS_POINTSCALE_A },
|
{ "D3DRS_POINTSCALE_A" /*= 120*/, 3424, xtFloat, 0, XTL::D3DRS_POINTSCALE_A },
|
||||||
{ "D3DRS_POINTSCALE_B" /*= 121*/, 3424, xtFloat, 0, D3DRS_POINTSCALE_B },
|
{ "D3DRS_POINTSCALE_B" /*= 121*/, 3424, xtFloat, 0, XTL::D3DRS_POINTSCALE_B },
|
||||||
{ "D3DRS_POINTSCALE_C" /*= 122*/, 3424, xtFloat, 0, D3DRS_POINTSCALE_C },
|
{ "D3DRS_POINTSCALE_C" /*= 122*/, 3424, xtFloat, 0, XTL::D3DRS_POINTSCALE_C },
|
||||||
{ "D3DRS_POINTSIZE_MAX" /*= 123*/, 3424, xtFloat, 0, D3DRS_POINTSIZE_MAX },
|
{ "D3DRS_POINTSIZE_MAX" /*= 123*/, 3424, xtFloat, 0, XTL::D3DRS_POINTSIZE_MAX },
|
||||||
{ "D3DRS_PATCHEDGESTYLE" /*= 124*/, 3424, xtDWORD, 0, D3DRS_PATCHEDGESTYLE }, // D3DPATCHEDGESTYLE?
|
{ "D3DRS_PATCHEDGESTYLE" /*= 124*/, 3424, xtDWORD, 0, XTL::D3DRS_PATCHEDGESTYLE }, // D3DPATCHEDGESTYLE?
|
||||||
{ "D3DRS_PATCHSEGMENTS" /*= 125*/, 3424, xtDWORD, 0 }, // nsp. // D3DRS_PATCHSEGMENTS exists in Direct3D 8, but not in 9 !?
|
{ "D3DRS_PATCHSEGMENTS" /*= 125*/, 3424, xtDWORD, 0 }, // nsp. // D3DRS_PATCHSEGMENTS exists in Direct3D 8, but not in 9 !?
|
||||||
// TODO -oDxbx : Is X_D3DRS_SWAPFILTER really a xtD3DMULTISAMPLE_TYPE?
|
// 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_SWAPFILTER" /*= 126*/, 4039, xtD3DMULTISAMPLE_TYPE, 0, D3DRS_NONE, "D3DTEXF_LINEAR etc. filter to use for Swap" }, // nsp.
|
||||||
|
@ -1476,23 +1481,23 @@ const RenderStateInfo DxbxRenderStateInfo[] = {
|
||||||
{ "D3DRS_DEFERRED_UNUSED1" /*= 135*/, 4627, xtDWORD, 0 },
|
{ "D3DRS_DEFERRED_UNUSED1" /*= 135*/, 4627, xtDWORD, 0 },
|
||||||
// End of "deferred" render states, continuing with "complex" render states :
|
// End of "deferred" render states, continuing with "complex" render states :
|
||||||
{ "D3DRS_PSTEXTUREMODES" /*= 136*/, 3424, xtDWORD, 0 },
|
{ "D3DRS_PSTEXTUREMODES" /*= 136*/, 3424, xtDWORD, 0 },
|
||||||
{ "D3DRS_VERTEXBLEND" /*= 137*/, 3424, xtD3DVERTEXBLENDFLAGS, NV2A_SKIN_MODE, D3DRS_VERTEXBLEND },
|
{ "D3DRS_VERTEXBLEND" /*= 137*/, 3424, xtD3DVERTEXBLENDFLAGS, NV2A_SKIN_MODE, XTL::D3DRS_VERTEXBLEND },
|
||||||
{ "D3DRS_FOGCOLOR" /*= 138*/, 3424, xtD3DCOLOR, NV2A_FOG_COLOR, D3DRS_FOGCOLOR }, // SwapRgb
|
{ "D3DRS_FOGCOLOR" /*= 138*/, 3424, xtD3DCOLOR, NV2A_FOG_COLOR, XTL::D3DRS_FOGCOLOR }, // SwapRgb
|
||||||
{ "D3DRS_FILLMODE" /*= 139*/, 3424, xtD3DFILLMODE, NV2A_POLYGON_MODE_FRONT, D3DRS_FILLMODE },
|
{ "D3DRS_FILLMODE" /*= 139*/, 3424, xtD3DFILLMODE, NV2A_POLYGON_MODE_FRONT, XTL::D3DRS_FILLMODE },
|
||||||
{ "D3DRS_BACKFILLMODE" /*= 140*/, 3424, xtD3DFILLMODE, 0 }, // nsp.
|
{ "D3DRS_BACKFILLMODE" /*= 140*/, 3424, xtD3DFILLMODE, 0 }, // nsp.
|
||||||
{ "D3DRS_TWOSIDEDLIGHTING" /*= 141*/, 3424, xtBOOL, NV2A_POLYGON_MODE_BACK }, // nsp.
|
{ "D3DRS_TWOSIDEDLIGHTING" /*= 141*/, 3424, xtBOOL, NV2A_POLYGON_MODE_BACK }, // nsp.
|
||||||
{ "D3DRS_NORMALIZENORMALS" /*= 142*/, 3424, xtBOOL, NV2A_NORMALIZE_ENABLE, D3DRS_NORMALIZENORMALS },
|
{ "D3DRS_NORMALIZENORMALS" /*= 142*/, 3424, xtBOOL, NV2A_NORMALIZE_ENABLE, XTL::D3DRS_NORMALIZENORMALS },
|
||||||
{ "D3DRS_ZENABLE" /*= 143*/, 3424, xtBOOL, NV2A_DEPTH_TEST_ENABLE, D3DRS_ZENABLE }, // D3DZBUFFERTYPE?
|
{ "D3DRS_ZENABLE" /*= 143*/, 3424, xtBOOL, NV2A_DEPTH_TEST_ENABLE, XTL::D3DRS_ZENABLE }, // D3DZBUFFERTYPE?
|
||||||
{ "D3DRS_STENCILENABLE" /*= 144*/, 3424, xtBOOL, NV2A_STENCIL_ENABLE, D3DRS_STENCILENABLE },
|
{ "D3DRS_STENCILENABLE" /*= 144*/, 3424, xtBOOL, NV2A_STENCIL_ENABLE, XTL::D3DRS_STENCILENABLE },
|
||||||
{ "D3DRS_STENCILFAIL" /*= 145*/, 3424, xtD3DSTENCILOP, NV2A_STENCIL_OP_FAIL, D3DRS_STENCILFAIL },
|
{ "D3DRS_STENCILFAIL" /*= 145*/, 3424, xtD3DSTENCILOP, NV2A_STENCIL_OP_FAIL, XTL::D3DRS_STENCILFAIL },
|
||||||
{ "D3DRS_FRONTFACE" /*= 146*/, 3424, xtD3DFRONT, NV2A_FRONT_FACE }, // nsp.
|
{ "D3DRS_FRONTFACE" /*= 146*/, 3424, xtD3DFRONT, NV2A_FRONT_FACE }, // nsp.
|
||||||
{ "D3DRS_CULLMODE" /*= 147*/, 3424, xtD3DCULL, NV2A_CULL_FACE, D3DRS_CULLMODE },
|
{ "D3DRS_CULLMODE" /*= 147*/, 3424, xtD3DCULL, NV2A_CULL_FACE, XTL::D3DRS_CULLMODE },
|
||||||
{ "D3DRS_TEXTUREFACTOR" /*= 148*/, 3424, xtD3DCOLOR, NV2A_RC_CONSTANT_COLOR0(0), D3DRS_TEXTUREFACTOR },
|
{ "D3DRS_TEXTUREFACTOR" /*= 148*/, 3424, xtD3DCOLOR, NV2A_RC_CONSTANT_COLOR0(0), XTL::D3DRS_TEXTUREFACTOR },
|
||||||
{ "D3DRS_ZBIAS" /*= 149*/, 3424, xtLONG, 0, D3DRS_DEPTHBIAS }, // Was D3DRS_ZBIAS
|
{ "D3DRS_ZBIAS" /*= 149*/, 3424, xtLONG, 0, XTL::D3DRS_DEPTHBIAS }, // Was D3DRS_ZBIAS
|
||||||
{ "D3DRS_LOGICOP" /*= 150*/, 3424, xtD3DLOGICOP, NV2A_COLOR_LOGIC_OP_OP }, // nsp.
|
{ "D3DRS_LOGICOP" /*= 150*/, 3424, xtD3DLOGICOP, NV2A_COLOR_LOGIC_OP_OP }, // nsp.
|
||||||
{ "D3DRS_EDGEANTIALIAS" /*= 151*/, 3424, xtBOOL, NV2A_LINE_SMOOTH_ENABLE, D3DRS_ANTIALIASEDLINEENABLE }, // Was D3DRS_EDGEANTIALIAS. Dxbx note : No Xbox ext. (according to Direct3D8) !
|
{ "D3DRS_EDGEANTIALIAS" /*= 151*/, 3424, xtBOOL, NV2A_LINE_SMOOTH_ENABLE, XTL::D3DRS_ANTIALIASEDLINEENABLE }, // Was D3DRS_EDGEANTIALIAS. Dxbx note : No Xbox ext. (according to Direct3D8) !
|
||||||
{ "D3DRS_MULTISAMPLEANTIALIAS" /*= 152*/, 3424, xtBOOL, NV2A_MULTISAMPLE_CONTROL, D3DRS_MULTISAMPLEANTIALIAS },
|
{ "D3DRS_MULTISAMPLEANTIALIAS" /*= 152*/, 3424, xtBOOL, NV2A_MULTISAMPLE_CONTROL, XTL::D3DRS_MULTISAMPLEANTIALIAS },
|
||||||
{ "D3DRS_MULTISAMPLEMASK" /*= 153*/, 3424, xtDWORD, NV2A_MULTISAMPLE_CONTROL, D3DRS_MULTISAMPLEMASK },
|
{ "D3DRS_MULTISAMPLEMASK" /*= 153*/, 3424, xtDWORD, NV2A_MULTISAMPLE_CONTROL, XTL::D3DRS_MULTISAMPLEMASK },
|
||||||
// { "D3DRS_MULTISAMPLETYPE" /*= 154*/, 3424, xtD3DMULTISAMPLE_TYPE, 0 }, // [-3911] \_ aliasses D3DMULTISAMPLE_TYPE
|
// { "D3DRS_MULTISAMPLETYPE" /*= 154*/, 3424, xtD3DMULTISAMPLE_TYPE, 0 }, // [-3911] \_ aliasses D3DMULTISAMPLE_TYPE
|
||||||
{ "D3DRS_MULTISAMPLEMODE" /*= 154*/, 4361, xtD3DMULTISAMPLEMODE, 0 }, // [4361+] / D3DMULTISAMPLEMODE for the backbuffer
|
{ "D3DRS_MULTISAMPLEMODE" /*= 154*/, 4361, xtD3DMULTISAMPLEMODE, 0 }, // [4361+] / D3DMULTISAMPLEMODE for the backbuffer
|
||||||
{ "D3DRS_MULTISAMPLERENDERTARGETMODE" /*= 155*/, 4242, xtD3DMULTISAMPLEMODE, NV2A_RT_FORMAT },
|
{ "D3DRS_MULTISAMPLERENDERTARGETMODE" /*= 155*/, 4242, xtD3DMULTISAMPLEMODE, NV2A_RT_FORMAT },
|
||||||
|
@ -1561,8 +1566,6 @@ Direct3D9 states unused :
|
||||||
D3DRS_BLENDOPALPHA = 209 // Blending operation for the alpha channel when D3DRS_SEPARATEDESTALPHAENABLE is TRUE
|
D3DRS_BLENDOPALPHA = 209 // Blending operation for the alpha channel when D3DRS_SEPARATEDESTALPHAENABLE is TRUE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}; // end of namespace XTL
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* Generic swizzle function, usable for both x and y dimensions.
|
/* Generic swizzle function, usable for both x and y dimensions.
|
||||||
When passing x, Max should be 2*height, and Shift should be 0
|
When passing x, Max should be 2*height, and Shift should be 0
|
||||||
|
|
|
@ -38,44 +38,44 @@
|
||||||
|
|
||||||
typedef void(*FormatToARGBRow)(const uint8_t* src, uint8_t* dst_argb, int width);
|
typedef void(*FormatToARGBRow)(const uint8_t* src, uint8_t* dst_argb, int width);
|
||||||
|
|
||||||
extern const FormatToARGBRow EmuXBFormatComponentConverter(X_D3DFORMAT Format);
|
extern const FormatToARGBRow EmuXBFormatComponentConverter(XTL::X_D3DFORMAT Format);
|
||||||
|
|
||||||
bool EmuXBFormatCanBeConvertedToARGB(X_D3DFORMAT Format);
|
bool EmuXBFormatCanBeConvertedToARGB(XTL::X_D3DFORMAT Format);
|
||||||
|
|
||||||
bool EmuXBFormatRequiresConversionToARGB(X_D3DFORMAT Format);
|
bool EmuXBFormatRequiresConversionToARGB(XTL::X_D3DFORMAT Format);
|
||||||
|
|
||||||
// how many bits does this format use per pixel?
|
// how many bits does this format use per pixel?
|
||||||
extern DWORD EmuXBFormatBitsPerPixel(X_D3DFORMAT Format);
|
extern DWORD EmuXBFormatBitsPerPixel(XTL::X_D3DFORMAT Format);
|
||||||
|
|
||||||
// how many bytes does this format use per pixel?
|
// how many bytes does this format use per pixel?
|
||||||
extern DWORD EmuXBFormatBytesPerPixel(X_D3DFORMAT Format);
|
extern DWORD EmuXBFormatBytesPerPixel(XTL::X_D3DFORMAT Format);
|
||||||
|
|
||||||
// is this format compressed?
|
// is this format compressed?
|
||||||
extern BOOL EmuXBFormatIsCompressed(X_D3DFORMAT Format);
|
extern BOOL EmuXBFormatIsCompressed(XTL::X_D3DFORMAT Format);
|
||||||
|
|
||||||
// is this format linear?
|
// is this format linear?
|
||||||
extern BOOL EmuXBFormatIsLinear(X_D3DFORMAT Format);
|
extern BOOL EmuXBFormatIsLinear(XTL::X_D3DFORMAT Format);
|
||||||
|
|
||||||
// is this format swizzled?
|
// is this format swizzled?
|
||||||
extern BOOL EmuXBFormatIsSwizzled(X_D3DFORMAT Format);
|
extern BOOL EmuXBFormatIsSwizzled(XTL::X_D3DFORMAT Format);
|
||||||
|
|
||||||
// is this format a valid render target?
|
// is this format a valid render target?
|
||||||
extern BOOL EmuXBFormatIsRenderTarget(X_D3DFORMAT Format);
|
extern BOOL EmuXBFormatIsRenderTarget(XTL::X_D3DFORMAT Format);
|
||||||
|
|
||||||
// is this format a valid depth buffer?
|
// is this format a valid depth buffer?
|
||||||
extern BOOL EmuXBFormatIsDepthBuffer(X_D3DFORMAT Format);
|
extern BOOL EmuXBFormatIsDepthBuffer(XTL::X_D3DFORMAT Format);
|
||||||
|
|
||||||
// convert from xbox to pc color formats
|
// convert from xbox to pc color formats
|
||||||
extern D3DFORMAT EmuXB2PC_D3DFormat(X_D3DFORMAT Format);
|
extern XTL::D3DFORMAT EmuXB2PC_D3DFormat(XTL::X_D3DFORMAT Format);
|
||||||
|
|
||||||
// convert from pc to xbox color formats
|
// convert from pc to xbox color formats
|
||||||
extern X_D3DFORMAT EmuPC2XB_D3DFormat(D3DFORMAT Format, bool bPreferLinear = true);
|
extern XTL::X_D3DFORMAT EmuPC2XB_D3DFormat(XTL::D3DFORMAT Format, bool bPreferLinear = true);
|
||||||
|
|
||||||
// convert from xbox to pc d3d lock flags
|
// convert from xbox to pc d3d lock flags
|
||||||
extern DWORD EmuXB2PC_D3DLock(DWORD Flags);
|
extern DWORD EmuXB2PC_D3DLock(DWORD Flags);
|
||||||
|
|
||||||
// convert from xbox to pc multisample formats
|
// convert from xbox to pc multisample formats
|
||||||
extern D3DMULTISAMPLE_TYPE EmuXB2PC_D3DMultiSampleFormat(DWORD Type);
|
extern XTL::D3DMULTISAMPLE_TYPE EmuXB2PC_D3DMultiSampleFormat(DWORD Type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
// convert from pc to xbox texture transform state types (unnecessary so far)
|
// convert from pc to xbox texture transform state types (unnecessary so far)
|
||||||
|
@ -90,8 +90,10 @@ else
|
||||||
//*/
|
//*/
|
||||||
|
|
||||||
// convert from xbox to pc texture transform state types
|
// convert from xbox to pc texture transform state types
|
||||||
inline D3DTRANSFORMSTATETYPE EmuXB2PC_D3DTS(D3DTRANSFORMSTATETYPE State)
|
inline XTL::D3DTRANSFORMSTATETYPE EmuXB2PC_D3DTS(XTL::D3DTRANSFORMSTATETYPE State)
|
||||||
{
|
{
|
||||||
|
using namespace XTL;
|
||||||
|
|
||||||
// Handle Xbox -> D3D State mapping
|
// Handle Xbox -> D3D State mapping
|
||||||
switch (State) {
|
switch (State) {
|
||||||
case 0: return (D3DTRANSFORMSTATETYPE)D3DTS_VIEW;
|
case 0: return (D3DTRANSFORMSTATETYPE)D3DTS_VIEW;
|
||||||
|
@ -116,9 +118,11 @@ inline D3DTRANSFORMSTATETYPE EmuXB2PC_D3DTS(D3DTRANSFORMSTATETYPE State)
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert from xbox to pc blend ops
|
// convert from xbox to pc blend ops
|
||||||
inline D3DBLENDOP EmuXB2PC_D3DBLENDOP(X_D3DBLENDOP Value)
|
inline XTL::D3DBLENDOP EmuXB2PC_D3DBLENDOP(XTL::X_D3DBLENDOP Value)
|
||||||
{
|
{
|
||||||
switch(Value)
|
using namespace XTL;
|
||||||
|
|
||||||
|
switch(Value)
|
||||||
{
|
{
|
||||||
case 0x8006: return D3DBLENDOP_ADD;
|
case 0x8006: return D3DBLENDOP_ADD;
|
||||||
case 0x800a: return D3DBLENDOP_SUBTRACT;
|
case 0x800a: return D3DBLENDOP_SUBTRACT;
|
||||||
|
@ -141,9 +145,11 @@ inline D3DBLENDOP EmuXB2PC_D3DBLENDOP(X_D3DBLENDOP Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert from xbox to pc blend types
|
// convert from xbox to pc blend types
|
||||||
inline D3DBLEND EmuXB2PC_D3DBLEND(X_D3DBLEND Value)
|
inline XTL::D3DBLEND EmuXB2PC_D3DBLEND(XTL::X_D3DBLEND Value)
|
||||||
{
|
{
|
||||||
switch (Value) {
|
using namespace XTL;
|
||||||
|
|
||||||
|
switch (Value) {
|
||||||
case 0x000: return D3DBLEND_ZERO;
|
case 0x000: return D3DBLEND_ZERO;
|
||||||
case 0x001: return D3DBLEND_ONE;
|
case 0x001: return D3DBLEND_ONE;
|
||||||
case 0x300: return D3DBLEND_SRCCOLOR;
|
case 0x300: return D3DBLEND_SRCCOLOR;
|
||||||
|
@ -166,9 +172,11 @@ inline D3DBLEND EmuXB2PC_D3DBLEND(X_D3DBLEND Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert from xbox to pc comparison functions
|
// convert from xbox to pc comparison functions
|
||||||
inline D3DCMPFUNC EmuXB2PC_D3DCMPFUNC(X_D3DCMPFUNC Value)
|
inline XTL::D3DCMPFUNC EmuXB2PC_D3DCMPFUNC(XTL::X_D3DCMPFUNC Value)
|
||||||
{
|
{
|
||||||
switch (Value) {
|
using namespace XTL;
|
||||||
|
|
||||||
|
switch (Value) {
|
||||||
case 0x200: return D3DCMP_NEVER;
|
case 0x200: return D3DCMP_NEVER;
|
||||||
case 0x201: return D3DCMP_LESS;
|
case 0x201: return D3DCMP_LESS;
|
||||||
case 0x202: return D3DCMP_EQUAL;
|
case 0x202: return D3DCMP_EQUAL;
|
||||||
|
@ -184,9 +192,11 @@ inline D3DCMPFUNC EmuXB2PC_D3DCMPFUNC(X_D3DCMPFUNC Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert from xbox to pc fill modes
|
// convert from xbox to pc fill modes
|
||||||
inline D3DFILLMODE EmuXB2PC_D3DFILLMODE(X_D3DFILLMODE Value)
|
inline XTL::D3DFILLMODE EmuXB2PC_D3DFILLMODE(XTL::X_D3DFILLMODE Value)
|
||||||
{
|
{
|
||||||
switch (Value) {
|
using namespace XTL;
|
||||||
|
|
||||||
|
switch (Value) {
|
||||||
case 0x1B00: return D3DFILL_POINT;
|
case 0x1B00: return D3DFILL_POINT;
|
||||||
case 0x1B01: return D3DFILL_WIREFRAME;
|
case 0x1B01: return D3DFILL_WIREFRAME;
|
||||||
case 0x1B02: return D3DFILL_SOLID;
|
case 0x1B02: return D3DFILL_SOLID;
|
||||||
|
@ -197,9 +207,11 @@ inline D3DFILLMODE EmuXB2PC_D3DFILLMODE(X_D3DFILLMODE Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert from xbox to pc shade modes
|
// convert from xbox to pc shade modes
|
||||||
inline D3DSHADEMODE EmuXB2PC_D3DSHADEMODE(X_D3DSHADEMODE Value)
|
inline XTL::D3DSHADEMODE EmuXB2PC_D3DSHADEMODE(XTL::X_D3DSHADEMODE Value)
|
||||||
{
|
{
|
||||||
switch (Value) {
|
using namespace XTL;
|
||||||
|
|
||||||
|
switch (Value) {
|
||||||
case 0x1D00: return D3DSHADE_FLAT;
|
case 0x1D00: return D3DSHADE_FLAT;
|
||||||
case 0x1D01: return D3DSHADE_GOURAUD;
|
case 0x1D01: return D3DSHADE_GOURAUD;
|
||||||
}
|
}
|
||||||
|
@ -209,8 +221,10 @@ inline D3DSHADEMODE EmuXB2PC_D3DSHADEMODE(X_D3DSHADEMODE Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert from xbox to pc stencilop modes
|
// convert from xbox to pc stencilop modes
|
||||||
inline D3DSTENCILOP EmuXB2PC_D3DSTENCILOP(X_D3DSTENCILOP Value)
|
inline XTL::D3DSTENCILOP EmuXB2PC_D3DSTENCILOP(XTL::X_D3DSTENCILOP Value)
|
||||||
{
|
{
|
||||||
|
using namespace XTL;
|
||||||
|
|
||||||
switch(Value)
|
switch(Value)
|
||||||
{
|
{
|
||||||
case 0x1e00: return D3DSTENCILOP_KEEP;
|
case 0x1e00: return D3DSTENCILOP_KEEP;
|
||||||
|
@ -229,9 +243,9 @@ inline D3DSTENCILOP EmuXB2PC_D3DSTENCILOP(X_D3DSTENCILOP Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// table used for vertex->primitive count conversion
|
// table used for vertex->primitive count conversion
|
||||||
extern UINT EmuD3DVertexToPrimitive[X_D3DPT_POLYGON + 1][2];
|
extern UINT EmuD3DVertexToPrimitive[XTL::X_D3DPT_POLYGON + 1][2];
|
||||||
|
|
||||||
inline bool EmuD3DValidVertexCount(X_D3DPRIMITIVETYPE XboxPrimitiveType, UINT VertexCount)
|
inline bool EmuD3DValidVertexCount(XTL::X_D3DPRIMITIVETYPE XboxPrimitiveType, UINT VertexCount)
|
||||||
{
|
{
|
||||||
// Are there more vertices than required for setup?
|
// Are there more vertices than required for setup?
|
||||||
if (VertexCount > EmuD3DVertexToPrimitive[XboxPrimitiveType][1])
|
if (VertexCount > EmuD3DVertexToPrimitive[XboxPrimitiveType][1])
|
||||||
|
@ -243,30 +257,30 @@ inline bool EmuD3DValidVertexCount(X_D3DPRIMITIVETYPE XboxPrimitiveType, UINT Ve
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert from vertex count to primitive count (Xbox)
|
// convert from vertex count to primitive count (Xbox)
|
||||||
inline int EmuD3DVertex2PrimitiveCount(X_D3DPRIMITIVETYPE PrimitiveType, int VertexCount)
|
inline int EmuD3DVertex2PrimitiveCount(XTL::X_D3DPRIMITIVETYPE PrimitiveType, int VertexCount)
|
||||||
{
|
{
|
||||||
return (VertexCount - EmuD3DVertexToPrimitive[PrimitiveType][1]) / EmuD3DVertexToPrimitive[PrimitiveType][0];
|
return (VertexCount - EmuD3DVertexToPrimitive[PrimitiveType][1]) / EmuD3DVertexToPrimitive[PrimitiveType][0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert from primitive count to vertex count (Xbox)
|
// convert from primitive count to vertex count (Xbox)
|
||||||
inline int EmuD3DPrimitive2VertexCount(X_D3DPRIMITIVETYPE PrimitiveType, int PrimitiveCount)
|
inline int EmuD3DPrimitive2VertexCount(XTL::X_D3DPRIMITIVETYPE PrimitiveType, int PrimitiveCount)
|
||||||
{
|
{
|
||||||
return (PrimitiveCount * EmuD3DVertexToPrimitive[PrimitiveType][0]) + EmuD3DVertexToPrimitive[PrimitiveType][1];
|
return (PrimitiveCount * EmuD3DVertexToPrimitive[PrimitiveType][0]) + EmuD3DVertexToPrimitive[PrimitiveType][1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// conversion table for xbox->pc primitive types
|
// conversion table for xbox->pc primitive types
|
||||||
extern D3DPRIMITIVETYPE EmuPrimitiveTypeLookup[];
|
extern XTL::D3DPRIMITIVETYPE EmuPrimitiveTypeLookup[];
|
||||||
|
|
||||||
// convert xbox->pc primitive type
|
// convert xbox->pc primitive type
|
||||||
inline D3DPRIMITIVETYPE EmuXB2PC_D3DPrimitiveType(X_D3DPRIMITIVETYPE PrimitiveType)
|
inline XTL::D3DPRIMITIVETYPE EmuXB2PC_D3DPrimitiveType(XTL::X_D3DPRIMITIVETYPE PrimitiveType)
|
||||||
{
|
{
|
||||||
if((DWORD)PrimitiveType == 0x7FFFFFFF)
|
if((DWORD)PrimitiveType == 0x7FFFFFFF)
|
||||||
return D3DPT_FORCE_DWORD;
|
return XTL::D3DPT_FORCE_DWORD;
|
||||||
|
|
||||||
return EmuPrimitiveTypeLookup[PrimitiveType];
|
return EmuPrimitiveTypeLookup[PrimitiveType];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int EmuD3DIndexCountToVertexCount(X_D3DPRIMITIVETYPE XboxPrimitiveType, int IndexCount)
|
inline int EmuD3DIndexCountToVertexCount(XTL::X_D3DPRIMITIVETYPE XboxPrimitiveType, int IndexCount)
|
||||||
{
|
{
|
||||||
return IndexCount;
|
return IndexCount;
|
||||||
}
|
}
|
||||||
|
@ -1809,13 +1823,13 @@ typedef struct _RenderStateInfo {
|
||||||
char *S; // String representation.
|
char *S; // String representation.
|
||||||
WORD V; // The XDK version since which a render state was introduced (using the 5911 declarations as a base).
|
WORD V; // The XDK version since which a render state was introduced (using the 5911 declarations as a base).
|
||||||
TXBType T = xt_Unknown; // The Xbox data type. Defaults to xt_Unknown.
|
TXBType T = xt_Unknown; // The Xbox data type. Defaults to xt_Unknown.
|
||||||
NV2AMETHOD M; // The related push buffer method. Not always a 1-to-1 mapping. Needs push-buffer interpretation & conversion code.
|
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
|
XTL::D3DRENDERSTATETYPE PC = (XTL::D3DRENDERSTATETYPE)0; // Map XBox to PC render state
|
||||||
char *N; // XDK notes. Defaults to ''.
|
char *N; // XDK notes. Defaults to ''.
|
||||||
}
|
}
|
||||||
RenderStateInfo;
|
RenderStateInfo;
|
||||||
|
|
||||||
#define D3DRS_NONE ((D3DRENDERSTATETYPE)0)
|
#define D3DRS_NONE ((XTL::D3DRENDERSTATETYPE)0)
|
||||||
|
|
||||||
extern const RenderStateInfo DxbxRenderStateInfo[];
|
extern const RenderStateInfo DxbxRenderStateInfo[];
|
||||||
|
|
||||||
|
|
|
@ -650,10 +650,10 @@ typedef enum _X_D3DRENDERSTATETYPE {
|
||||||
// Older versions are slightly different (some members are missing), so we use a mapping table to
|
// 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
|
// 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 :
|
// version-differences in the rest of our code (unless it matters somehow); We write via indirection :
|
||||||
// *XTL::EmuMappedD3DRenderState[X_D3DRENDERSTATETYPE] = Value;
|
// *EmuMappedD3DRenderState[X_D3DRENDERSTATETYPE] = Value;
|
||||||
//
|
//
|
||||||
// And we read via the same mapping (do note, that missing elements all point to the same dummy) :
|
// And we read via the same mapping (do note, that missing elements all point to the same dummy) :
|
||||||
// Result = *XTL::EmuMappedD3DRenderState[X_D3DRENDERSTATETYPE];
|
// Result = *EmuMappedD3DRenderState[X_D3DRENDERSTATETYPE];
|
||||||
|
|
||||||
// Dxbx note : The PS* render states map 1-on-1 to the X_D3DPIXELSHADERDEF record,
|
// 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.
|
// SetPixelShader actually pushes the definition into these render state slots.
|
||||||
|
@ -1111,8 +1111,6 @@ const int X_D3DVSDT_PBYTE4 = 0x44; // xbox ext. 4D packed byte expanded to
|
||||||
const int X_D3DVSDT_FLOAT2H = 0x72; // xbox ext. 3D float that expands to (value, value, 0.0, value). Useful for projective texture coordinates.
|
const int X_D3DVSDT_FLOAT2H = 0x72; // xbox ext. 3D float that expands to (value, value, 0.0, value). Useful for projective texture coordinates.
|
||||||
const int X_D3DVSDT_NONE = 0x02; // xbox ext. nsp
|
const int X_D3DVSDT_NONE = 0x02; // xbox ext. nsp
|
||||||
|
|
||||||
typedef WORD INDEX16;
|
|
||||||
|
|
||||||
typedef enum _X_D3DVSD_TOKENTYPE
|
typedef enum _X_D3DVSD_TOKENTYPE
|
||||||
{
|
{
|
||||||
X_D3DVSD_TOKEN_NOP = 0, // NOP or extension
|
X_D3DVSD_TOKEN_NOP = 0, // NOP or extension
|
||||||
|
@ -1210,96 +1208,6 @@ typedef DWORD NV2AMETHOD;
|
||||||
//
|
//
|
||||||
|
|
||||||
// Host vertex shader counts
|
// Host vertex shader counts
|
||||||
#define VSH_MAX_TEMPORARY_REGISTERS 32
|
|
||||||
#define VSH_MAX_INTERMEDIATE_COUNT 1024 // The maximum number of intermediate format slots
|
|
||||||
#define VSH_VS11_MAX_INSTRUCTION_COUNT 128
|
|
||||||
#define VSH_VS2X_MAX_INSTRUCTION_COUNT 256
|
|
||||||
#define VSH_VS30_MAX_INSTRUCTION_COUNT 512
|
|
||||||
|
|
||||||
#define CXBX_D3DVS_CONSTREG_VERTEXDATA4F_BASE (X_D3DVS_CONSTREG_COUNT + 1)
|
#define CXBX_D3DVS_CONSTREG_VERTEXDATA4F_BASE (X_D3DVS_CONSTREG_COUNT + 1)
|
||||||
|
|
||||||
typedef struct _CxbxPixelShader
|
|
||||||
{
|
|
||||||
//IDirect3DPixelShader* pShader;
|
|
||||||
//ID3DXConstantTable *pConstantTable;
|
|
||||||
DWORD Handle;
|
|
||||||
|
|
||||||
BOOL bBumpEnvMap;
|
|
||||||
|
|
||||||
// constants
|
|
||||||
DWORD PSRealC0[8];
|
|
||||||
DWORD PSRealC1[8];
|
|
||||||
DWORD PSRealFC0;
|
|
||||||
DWORD PSRealFC1;
|
|
||||||
|
|
||||||
BOOL bConstantsInitialized;
|
|
||||||
BOOL bConstantsChanged;
|
|
||||||
|
|
||||||
DWORD dwStatus;
|
|
||||||
X_D3DPIXELSHADERDEF PSDef;
|
|
||||||
|
|
||||||
DWORD dwStageMap[X_D3DTS_STAGECOUNT];
|
|
||||||
|
|
||||||
}
|
|
||||||
CxbxPixelShader;
|
|
||||||
|
|
||||||
typedef struct _CxbxVertexShaderStreamElement
|
|
||||||
{
|
|
||||||
UINT XboxType; // The stream element data types (xbox)
|
|
||||||
UINT HostByteSize; // The stream element data sizes (pc)
|
|
||||||
}
|
|
||||||
CxbxVertexShaderStreamElement;
|
|
||||||
|
|
||||||
/* See host typedef struct _D3DVERTEXELEMENT9
|
|
||||||
{
|
|
||||||
WORD Stream; // Stream index
|
|
||||||
WORD Offset; // Offset in the stream in bytes
|
|
||||||
BYTE Type; // Data type
|
|
||||||
BYTE Method; // Processing method
|
|
||||||
BYTE Usage; // Semantics
|
|
||||||
BYTE UsageIndex; // Semantic index
|
|
||||||
} D3DVERTEXELEMENT9, *LPD3DVERTEXELEMENT9;
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct _CxbxVertexShaderStreamInfo
|
|
||||||
{
|
|
||||||
BOOL NeedPatch; // This is to know whether it's data which must be patched
|
|
||||||
BOOL DeclPosition;
|
|
||||||
WORD HostVertexStride;
|
|
||||||
DWORD NumberOfVertexElements; // Number of the stream data types
|
|
||||||
WORD CurrentStreamNumber;
|
|
||||||
CxbxVertexShaderStreamElement VertexElements[X_VSH_MAX_ATTRIBUTES + 16]; // TODO : Why 16 extrahost additions?)
|
|
||||||
}
|
|
||||||
CxbxVertexShaderStreamInfo;
|
|
||||||
|
|
||||||
typedef struct _CxbxVertexShaderInfo
|
|
||||||
{
|
|
||||||
UINT NumberOfVertexStreams; // The number of streams the vertex shader uses
|
|
||||||
CxbxVertexShaderStreamInfo VertexStreams[X_VSH_MAX_STREAMS];
|
|
||||||
}
|
|
||||||
CxbxVertexShaderInfo;
|
|
||||||
|
|
||||||
typedef struct _CxbxVertexShader
|
|
||||||
{
|
|
||||||
// These are the parameters given by the XBE,
|
|
||||||
// we save them to be able to return them when necessary.
|
|
||||||
DWORD* pXboxDeclarationCopy;
|
|
||||||
DWORD XboxDeclarationCount; // Xbox's number of DWORD-sized X_D3DVSD* tokens
|
|
||||||
DWORD XboxFunctionSize;
|
|
||||||
DWORD* pXboxFunctionCopy;
|
|
||||||
UINT XboxNrAddressSlots;
|
|
||||||
DWORD XboxVertexShaderType;
|
|
||||||
// DWORD XboxStatus; // Used by VshHandleIsValidShader()
|
|
||||||
|
|
||||||
// The resulting host variables
|
|
||||||
DWORD HostFVF; // Flexible Vertex Format (used when there's no host vertex shader)
|
|
||||||
XTL::IDirect3DVertexShader* pHostVertexShader; // if nullptr, use SetFVF(HostFVF);
|
|
||||||
XTL::IDirect3DVertexDeclaration* pHostVertexDeclaration;
|
|
||||||
DWORD HostDeclarationSize;
|
|
||||||
|
|
||||||
// Needed for dynamic stream patching
|
|
||||||
CxbxVertexShaderInfo VertexShaderInfo;
|
|
||||||
}
|
|
||||||
CxbxVertexShader;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -65,9 +65,10 @@
|
||||||
|
|
||||||
#include "core\kernel\support\Emu.h"
|
#include "core\kernel\support\Emu.h"
|
||||||
#include "core\kernel\support\EmuFS.h"
|
#include "core\kernel\support\EmuFS.h"
|
||||||
#include "core\kernel\support\EmuXTL.h"
|
#include "core\kernel\support\EmuXTL.h" // X_PSH_COMBINECOUNT
|
||||||
|
|
||||||
//#include <CxbxKrnl/EmuD3D8Types.h> // X_PSH_COMBINECOUNT
|
#include "core\hle\D3D8\XbPixelShader.h"
|
||||||
|
#include "core\hle\D3D8\XbState.h" // For CXBX_D3DRS_UNSUPPORTED
|
||||||
|
|
||||||
#include "core\kernel\init\CxbxKrnl.h" // For CxbxKrnlCleanup()
|
#include "core\kernel\init\CxbxKrnl.h" // For CxbxKrnlCleanup()
|
||||||
|
|
||||||
|
@ -2331,7 +2332,7 @@ std::string PSH_XBOX_SHADER::OriginalToString(XTL::X_D3DPIXELSHADERDEF *pPSDef)
|
||||||
pPSDef->PSRGBOutputs[0], pPSDef->PSRGBOutputs[1], pPSDef->PSRGBOutputs[2], pPSDef->PSRGBOutputs[3],
|
pPSDef->PSRGBOutputs[0], pPSDef->PSRGBOutputs[1], pPSDef->PSRGBOutputs[2], pPSDef->PSRGBOutputs[3],
|
||||||
pPSDef->PSRGBOutputs[4], pPSDef->PSRGBOutputs[5], pPSDef->PSRGBOutputs[6], pPSDef->PSRGBOutputs[7],
|
pPSDef->PSRGBOutputs[4], pPSDef->PSRGBOutputs[5], pPSDef->PSRGBOutputs[6], pPSDef->PSRGBOutputs[7],
|
||||||
pPSDef->PSCombinerCount,
|
pPSDef->PSCombinerCount,
|
||||||
XTL::TemporaryPixelShaderRenderStates[XTL::X_D3DRS_PSTEXTUREMODES], /* pPSDef->PSTextureModes is stored in a different place than pPSDef*/
|
TemporaryPixelShaderRenderStates[XTL::X_D3DRS_PSTEXTUREMODES], /* pPSDef->PSTextureModes is stored in a different place than pPSDef*/
|
||||||
pPSDef->PSDotMapping,
|
pPSDef->PSDotMapping,
|
||||||
pPSDef->PSInputTexture,
|
pPSDef->PSInputTexture,
|
||||||
pPSDef->PSC0Mapping,
|
pPSDef->PSC0Mapping,
|
||||||
|
@ -2343,7 +2344,7 @@ void PSH_XBOX_SHADER::GetPSTextureModes(XTL::X_D3DPIXELSHADERDEF* pPSDef, PS_TEX
|
||||||
{
|
{
|
||||||
for (int i = 0; i < XTL::X_D3DTS_STAGECOUNT; i++)
|
for (int i = 0; i < XTL::X_D3DTS_STAGECOUNT; i++)
|
||||||
{
|
{
|
||||||
psTextureModes[i] = (PS_TEXTUREMODES)((XTL::TemporaryPixelShaderRenderStates[XTL::X_D3DRS_PSTEXTUREMODES] >> (i * 5)) & 0x1F);
|
psTextureModes[i] = (PS_TEXTUREMODES)((TemporaryPixelShaderRenderStates[XTL::X_D3DRS_PSTEXTUREMODES] >> (i * 5)) & 0x1F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2555,7 +2556,7 @@ std::string PSH_XBOX_SHADER::DecodedToString(XTL::X_D3DPIXELSHADERDEF *pPSDef)
|
||||||
_AddStr1("\n-----PixelShader Definition Contents-----");
|
_AddStr1("\n-----PixelShader Definition Contents-----");
|
||||||
_AddStr1(OriginalToString(pPSDef));
|
_AddStr1(OriginalToString(pPSDef));
|
||||||
|
|
||||||
if (XTL::TemporaryPixelShaderRenderStates[XTL::X_D3DRS_PSTEXTUREMODES] > 0)
|
if (TemporaryPixelShaderRenderStates[XTL::X_D3DRS_PSTEXTUREMODES] > 0)
|
||||||
{
|
{
|
||||||
_AddStr1("\nPSTextureModes ->"); // Texture addressing modes
|
_AddStr1("\nPSTextureModes ->"); // Texture addressing modes
|
||||||
_AddStr("Stage 0: %s", PS_TextureModesStr[PSTextureModes[0]]);
|
_AddStr("Stage 0: %s", PS_TextureModesStr[PSTextureModes[0]]);
|
||||||
|
@ -5979,15 +5980,17 @@ static const
|
||||||
} // DxbxRecompilePixelShader
|
} // DxbxRecompilePixelShader
|
||||||
|
|
||||||
// TODO : Initialize this :
|
// TODO : Initialize this :
|
||||||
DWORD *XTL::EmuMappedD3DRenderState[X_D3DRS_UNSUPPORTED]; // 1 extra for the unsupported value
|
DWORD *EmuMappedD3DRenderState[CXBX_D3DRS_UNSUPPORTED]; // 1 extra for the unsupported value
|
||||||
|
|
||||||
std::vector<PSH_RECOMPILED_SHADER> g_RecompiledPixelShaders;
|
std::vector<PSH_RECOMPILED_SHADER> g_RecompiledPixelShaders;
|
||||||
|
|
||||||
// Temporary...
|
// Temporary...
|
||||||
DWORD XTL::TemporaryPixelShaderRenderStates[XTL::X_D3DRS_PSTEXTUREMODES + 1];
|
DWORD TemporaryPixelShaderRenderStates[XTL::X_D3DRS_PSTEXTUREMODES + 1];
|
||||||
|
|
||||||
VOID XTL::DxbxUpdateActivePixelShader() // NOPATCH
|
VOID DxbxUpdateActivePixelShader() // NOPATCH
|
||||||
{
|
{
|
||||||
|
using namespace XTL; // Temporary, not for actual XTL symbols, but for those that are erroneously contained herein (like everything from ddraw.h)
|
||||||
|
|
||||||
XTL::X_D3DPIXELSHADERDEF *pPSDef;
|
XTL::X_D3DPIXELSHADERDEF *pPSDef;
|
||||||
PPSH_RECOMPILED_SHADER RecompiledPixelShader;
|
PPSH_RECOMPILED_SHADER RecompiledPixelShader;
|
||||||
DWORD ConvertedPixelShaderHandle;
|
DWORD ConvertedPixelShaderHandle;
|
||||||
|
@ -6002,7 +6005,7 @@ VOID XTL::DxbxUpdateActivePixelShader() // NOPATCH
|
||||||
// TODO: Is this even right? The first RenderState is PSAlpha,
|
// TODO: Is this even right? The first RenderState is PSAlpha,
|
||||||
// The pixel shader is stored in pDevice->m_pPixelShader
|
// The pixel shader is stored in pDevice->m_pPixelShader
|
||||||
// For now, we still patch SetPixelShader and read from there...
|
// For now, we still patch SetPixelShader and read from there...
|
||||||
//DWORD *XTL_D3D__RenderState = XTL::EmuMappedD3DRenderState[0];
|
//DWORD *XTL_D3D__RenderState = EmuMappedD3DRenderState[0];
|
||||||
//pPSDef = (XTL::X_D3DPIXELSHADERDEF*)(XTL_D3D__RenderState);
|
//pPSDef = (XTL::X_D3DPIXELSHADERDEF*)(XTL_D3D__RenderState);
|
||||||
|
|
||||||
// Use the pixel shader stored in TemporaryPixelShaderRenderStates rather than the set handle
|
// Use the pixel shader stored in TemporaryPixelShaderRenderStates rather than the set handle
|
||||||
|
@ -6037,7 +6040,7 @@ VOID XTL::DxbxUpdateActivePixelShader() // NOPATCH
|
||||||
// Switch to the converted pixel shader (if it's any different from our currently active
|
// Switch to the converted pixel shader (if it's any different from our currently active
|
||||||
// pixel shader, to avoid many unnecessary state changes on the local side).
|
// pixel shader, to avoid many unnecessary state changes on the local side).
|
||||||
ConvertedPixelShaderHandle = RecompiledPixelShader->ConvertedHandle;
|
ConvertedPixelShaderHandle = RecompiledPixelShader->ConvertedHandle;
|
||||||
|
|
||||||
g_pD3DDevice->GetPixelShader(/*out*/(IDirect3DPixelShader**)(&CurrentPixelShader));
|
g_pD3DDevice->GetPixelShader(/*out*/(IDirect3DPixelShader**)(&CurrentPixelShader));
|
||||||
if (CurrentPixelShader != ConvertedPixelShaderHandle)
|
if (CurrentPixelShader != ConvertedPixelShaderHandle)
|
||||||
g_pD3DDevice->SetPixelShader((IDirect3DPixelShader*)ConvertedPixelShaderHandle);
|
g_pD3DDevice->SetPixelShader((IDirect3DPixelShader*)ConvertedPixelShaderHandle);
|
||||||
|
@ -6085,18 +6088,18 @@ VOID XTL::DxbxUpdateActivePixelShader() // NOPATCH
|
||||||
// The required code needs o be ported from Wip_LessVertexPatching or Dxbx
|
// The required code needs o be ported from Wip_LessVertexPatching or Dxbx
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case PSH_XBOX_CONSTANT_FOG:
|
case PSH_XBOX_CONSTANT_FOG:
|
||||||
//dwColor = *XTL::EmuMappedD3DRenderState[XTL::X_D3DRS_FOGCOLOR] | 0xFF000000;
|
//dwColor = *EmuMappedD3DRenderState[XTL::X_D3DRS_FOGCOLOR] | 0xFF000000;
|
||||||
// Note : FOG.RGB is correct like this, but FOG.a should be coming
|
// Note : FOG.RGB is correct like this, but FOG.a should be coming
|
||||||
// from the vertex shader (oFog) - however, D3D8 does not forward this...
|
// from the vertex shader (oFog) - however, D3D8 does not forward this...
|
||||||
g_pD3DDevice->GetRenderState(D3DRS_FOGCOLOR, &dwColor);
|
g_pD3DDevice->GetRenderState(D3DRS_FOGCOLOR, &dwColor);
|
||||||
fColor = dwColor;
|
fColor = dwColor;
|
||||||
break;
|
break;
|
||||||
case PSH_XBOX_CONSTANT_FC0:
|
case PSH_XBOX_CONSTANT_FC0:
|
||||||
//dwColor = *XTL::EmuMappedD3DRenderState[XTL::X_D3DRS_PSFINALCOMBINERCONSTANT0];
|
//dwColor = *EmuMappedD3DRenderState[XTL::X_D3DRS_PSFINALCOMBINERCONSTANT0];
|
||||||
fColor = dwColor = TemporaryPixelShaderRenderStates[XTL::X_D3DRS_PSFINALCOMBINERCONSTANT0];
|
fColor = dwColor = TemporaryPixelShaderRenderStates[XTL::X_D3DRS_PSFINALCOMBINERCONSTANT0];
|
||||||
break;
|
break;
|
||||||
case PSH_XBOX_CONSTANT_FC1:
|
case PSH_XBOX_CONSTANT_FC1:
|
||||||
//dwColor = *XTL::EmuMappedD3DRenderState[XTL::X_D3DRS_PSFINALCOMBINERCONSTANT1];
|
//dwColor = *EmuMappedD3DRenderState[XTL::X_D3DRS_PSFINALCOMBINERCONSTANT1];
|
||||||
fColor = dwColor = TemporaryPixelShaderRenderStates[XTL::X_D3DRS_PSFINALCOMBINERCONSTANT1];
|
fColor = dwColor = TemporaryPixelShaderRenderStates[XTL::X_D3DRS_PSFINALCOMBINERCONSTANT1];
|
||||||
break;
|
break;
|
||||||
case PSH_XBOX_CONSTANT_MUL0:
|
case PSH_XBOX_CONSTANT_MUL0:
|
||||||
|
@ -6131,7 +6134,7 @@ VOID XTL::DxbxUpdateActivePixelShader() // NOPATCH
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
//dwColor = *XTL::EmuMappedD3DRenderState[XTL::X_D3DRS_PSCONSTANT0_0 + i];
|
//dwColor = *EmuMappedD3DRenderState[XTL::X_D3DRS_PSCONSTANT0_0 + i];
|
||||||
fColor = dwColor = TemporaryPixelShaderRenderStates[XTL::X_D3DRS_PSCONSTANT0_0 + i];
|
fColor = dwColor = TemporaryPixelShaderRenderStates[XTL::X_D3DRS_PSCONSTANT0_0 + i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -8111,7 +8114,7 @@ inline void CorrectConstToReg(char *szConst, int *pPSC0, int *pPSC1)
|
||||||
CorrectConstToReg_done:;
|
CorrectConstToReg_done:;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XTL::DumpPixelShaderDefToFile( X_D3DPIXELSHADERDEF* pPSDef, const char* pszCode /*= NULL*/ )
|
void DumpPixelShaderDefToFile(XTL::X_D3DPIXELSHADERDEF* pPSDef, const char* pszCode /*= NULL*/ )
|
||||||
{
|
{
|
||||||
static int PshNumber = 0; // Keep track of how many pixel shaders we've attemted to convert.
|
static int PshNumber = 0; // Keep track of how many pixel shaders we've attemted to convert.
|
||||||
char szPSDef[512];
|
char szPSDef[512];
|
||||||
|
@ -8157,7 +8160,7 @@ void XTL::DumpPixelShaderDefToFile( X_D3DPIXELSHADERDEF* pPSDef, const char* psz
|
||||||
pPSDef->PSRGBOutputs[0], pPSDef->PSRGBOutputs[1], pPSDef->PSRGBOutputs[2], pPSDef->PSRGBOutputs[3],
|
pPSDef->PSRGBOutputs[0], pPSDef->PSRGBOutputs[1], pPSDef->PSRGBOutputs[2], pPSDef->PSRGBOutputs[3],
|
||||||
pPSDef->PSRGBOutputs[4], pPSDef->PSRGBOutputs[5], pPSDef->PSRGBOutputs[6], pPSDef->PSRGBOutputs[7],
|
pPSDef->PSRGBOutputs[4], pPSDef->PSRGBOutputs[5], pPSDef->PSRGBOutputs[6], pPSDef->PSRGBOutputs[7],
|
||||||
pPSDef->PSCombinerCount,
|
pPSDef->PSCombinerCount,
|
||||||
TemporaryPixelShaderRenderStates[X_D3DRS_PSTEXTUREMODES], /* pPSDef->PSTextureModes is stored in a different place than pPSDef*/
|
TemporaryPixelShaderRenderStates[XTL::X_D3DRS_PSTEXTUREMODES], /* pPSDef->PSTextureModes is stored in a different place than pPSDef*/
|
||||||
pPSDef->PSDotMapping,
|
pPSDef->PSDotMapping,
|
||||||
pPSDef->PSInputTexture,
|
pPSDef->PSInputTexture,
|
||||||
pPSDef->PSC0Mapping,
|
pPSDef->PSC0Mapping,
|
||||||
|
@ -8173,19 +8176,19 @@ void XTL::DumpPixelShaderDefToFile( X_D3DPIXELSHADERDEF* pPSDef, const char* psz
|
||||||
}
|
}
|
||||||
|
|
||||||
// print relevant contents to the debug console
|
// print relevant contents to the debug console
|
||||||
void XTL::PrintPixelShaderDefContents( X_D3DPIXELSHADERDEF* pPSDef )
|
void PrintPixelShaderDefContents(XTL::X_D3DPIXELSHADERDEF* pPSDef )
|
||||||
{
|
{
|
||||||
// Show the contents to the user
|
// Show the contents to the user
|
||||||
if( pPSDef )
|
if( pPSDef )
|
||||||
{
|
{
|
||||||
DbgPshPrintf( "\n-----PixelShader Def Contents-----\n" );
|
DbgPshPrintf( "\n-----PixelShader Def Contents-----\n" );
|
||||||
|
|
||||||
if(TemporaryPixelShaderRenderStates[X_D3DRS_PSTEXTUREMODES])
|
if(TemporaryPixelShaderRenderStates[XTL::X_D3DRS_PSTEXTUREMODES])
|
||||||
{
|
{
|
||||||
DWORD dwPSTexMode0 = ( TemporaryPixelShaderRenderStates[X_D3DRS_PSTEXTUREMODES] >> 0 ) & 0x1F;
|
DWORD dwPSTexMode0 = ( TemporaryPixelShaderRenderStates[XTL::X_D3DRS_PSTEXTUREMODES] >> 0 ) & 0x1F;
|
||||||
DWORD dwPSTexMode1 = ( TemporaryPixelShaderRenderStates[X_D3DRS_PSTEXTUREMODES] >> 5 ) & 0x1F;
|
DWORD dwPSTexMode1 = ( TemporaryPixelShaderRenderStates[XTL::X_D3DRS_PSTEXTUREMODES] >> 5 ) & 0x1F;
|
||||||
DWORD dwPSTexMode2 = ( TemporaryPixelShaderRenderStates[X_D3DRS_PSTEXTUREMODES] >> 10 ) & 0x1F;
|
DWORD dwPSTexMode2 = ( TemporaryPixelShaderRenderStates[XTL::X_D3DRS_PSTEXTUREMODES] >> 10 ) & 0x1F;
|
||||||
DWORD dwPSTexMode3 = ( TemporaryPixelShaderRenderStates[X_D3DRS_PSTEXTUREMODES] >> 15 ) & 0x1F;
|
DWORD dwPSTexMode3 = ( TemporaryPixelShaderRenderStates[XTL::X_D3DRS_PSTEXTUREMODES] >> 15 ) & 0x1F;
|
||||||
|
|
||||||
DbgPshPrintf( "PSTextureModes ->\n" );
|
DbgPshPrintf( "PSTextureModes ->\n" );
|
||||||
DbgPshPrintf( "Stage 0: %s\n", PS_TextureModesStr[dwPSTexMode0] );
|
DbgPshPrintf( "Stage 0: %s\n", PS_TextureModesStr[dwPSTexMode0] );
|
||||||
|
|
|
@ -30,14 +30,14 @@
|
||||||
#include "Cxbx.h"
|
#include "Cxbx.h"
|
||||||
|
|
||||||
// dump pixel shader definition to file
|
// dump pixel shader definition to file
|
||||||
void DumpPixelShaderDefToFile( X_D3DPIXELSHADERDEF* pPSDef, const char* pszCode );
|
void DumpPixelShaderDefToFile( XTL::X_D3DPIXELSHADERDEF* pPSDef, const char* pszCode );
|
||||||
// print relevant contents to the debug console
|
// print relevant contents to the debug console
|
||||||
void PrintPixelShaderDefContents( X_D3DPIXELSHADERDEF* pDSDef );
|
void PrintPixelShaderDefContents(XTL::X_D3DPIXELSHADERDEF* pDSDef );
|
||||||
|
|
||||||
// PatrickvL's Dxbx pixel shader translation
|
// PatrickvL's Dxbx pixel shader translation
|
||||||
VOID DxbxUpdateActivePixelShader(); // NOPATCH
|
VOID DxbxUpdateActivePixelShader(); // NOPATCH
|
||||||
|
|
||||||
// TODO: Remove this once the Render State code has been fully ported from Dxbx/Wip_LessVertexPatching
|
// TODO: Remove this once the Render State code has been fully ported from Dxbx/Wip_LessVertexPatching
|
||||||
extern DWORD TemporaryPixelShaderRenderStates[X_D3DRS_PSTEXTUREMODES + 1];
|
extern DWORD TemporaryPixelShaderRenderStates[XTL::X_D3DRS_PSTEXTUREMODES + 1];
|
||||||
|
|
||||||
#endif // PIXELSHADER_H
|
#endif // PIXELSHADER_H
|
||||||
|
|
|
@ -31,8 +31,13 @@
|
||||||
|
|
||||||
#include "core\kernel\support\Emu.h"
|
#include "core\kernel\support\Emu.h"
|
||||||
#include "core\kernel\support\EmuXTL.h"
|
#include "core\kernel\support\EmuXTL.h"
|
||||||
#include "XbD3D8Types.h" // For X_D3DFORMAT
|
namespace XTL {
|
||||||
|
#include "core\hle\D3D8\XbD3D8Types.h" // For X_D3DFORMAT
|
||||||
|
}
|
||||||
#include "core\hle\D3D8\ResourceTracker.h"
|
#include "core\hle\D3D8\ResourceTracker.h"
|
||||||
|
#include "core\hle\D3D8\XbPushBuffer.h"
|
||||||
|
#include "core\hle\D3D8\XbState.h" // For CxbxUpdateNativeD3DResources, etc
|
||||||
|
#include "core\hle\D3D8\XbConvert.h"
|
||||||
#include "devices/video/nv2a.h" // For g_NV2A, PGRAPHState
|
#include "devices/video/nv2a.h" // For g_NV2A, PGRAPHState
|
||||||
#include "devices/video/nv2a_int.h" // For NV** defines
|
#include "devices/video/nv2a_int.h" // For NV** defines
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
|
@ -47,7 +52,7 @@ static void DbgDumpMesh(WORD *pIndexData, DWORD dwCount);
|
||||||
|
|
||||||
// Determine the size (in number of floating point texture coordinates) of the texture format (indexed 0 .. 3).
|
// Determine the size (in number of floating point texture coordinates) of the texture format (indexed 0 .. 3).
|
||||||
// This is the reverse of the D3DFVF_TEXCOORDSIZE[0..3] macros.
|
// This is the reverse of the D3DFVF_TEXCOORDSIZE[0..3] macros.
|
||||||
int XTL::DxbxFVF_GetNumberOfTextureCoordinates(DWORD dwFVF, int aTextureIndex)
|
int DxbxFVF_GetNumberOfTextureCoordinates(DWORD dwFVF, int aTextureIndex)
|
||||||
{
|
{
|
||||||
// See D3DFVF_TEXCOORDSIZE1()
|
// See D3DFVF_TEXCOORDSIZE1()
|
||||||
switch ((dwFVF >> ((aTextureIndex * 2) + 16)) & 3) {
|
switch ((dwFVF >> ((aTextureIndex * 2) + 16)) & 3) {
|
||||||
|
@ -63,7 +68,7 @@ int XTL::DxbxFVF_GetNumberOfTextureCoordinates(DWORD dwFVF, int aTextureIndex)
|
||||||
|
|
||||||
// Dxbx Note: This code appeared in EmuExecutePushBufferRaw and occured
|
// Dxbx Note: This code appeared in EmuExecutePushBufferRaw and occured
|
||||||
// in EmuFlushIVB too, so it's generalize in this single implementation.
|
// in EmuFlushIVB too, so it's generalize in this single implementation.
|
||||||
UINT XTL::DxbxFVFToVertexSizeInBytes(DWORD dwFVF, BOOL bIncludeTextures)
|
UINT DxbxFVFToVertexSizeInBytes(DWORD dwFVF, BOOL bIncludeTextures)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
X_D3DFVF_POSITION_MASK = $00E; // Dec /2 #fl
|
X_D3DFVF_POSITION_MASK = $00E; // Dec /2 #fl
|
||||||
|
@ -115,12 +120,14 @@ UINT XTL::DxbxFVFToVertexSizeInBytes(DWORD dwFVF, BOOL bIncludeTextures)
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XTL::EmuExecutePushBuffer
|
void EmuExecutePushBuffer
|
||||||
(
|
(
|
||||||
X_D3DPushBuffer *pPushBuffer,
|
XTL::X_D3DPushBuffer *pPushBuffer,
|
||||||
X_D3DFixup *pFixup
|
XTL::X_D3DFixup *pFixup
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
using namespace XTL;
|
||||||
|
|
||||||
//Check whether Fixup exists or not.
|
//Check whether Fixup exists or not.
|
||||||
if (pFixup != NULL) {
|
if (pFixup != NULL) {
|
||||||
LOG_TEST_CASE("PushBuffer has fixups");
|
LOG_TEST_CASE("PushBuffer has fixups");
|
||||||
|
@ -451,12 +458,14 @@ typedef union {
|
||||||
#define COMMAND_WORD_MASK_JUMP_LONG 0xFFFFFFFC /* 2 .. 28 */
|
#define COMMAND_WORD_MASK_JUMP_LONG 0xFFFFFFFC /* 2 .. 28 */
|
||||||
} nv_fifo_command;
|
} nv_fifo_command;
|
||||||
|
|
||||||
extern void XTL::EmuExecutePushBufferRaw
|
extern void EmuExecutePushBufferRaw
|
||||||
(
|
(
|
||||||
void *pPushData,
|
void *pPushData,
|
||||||
uint32_t uSizeInBytes
|
uint32_t uSizeInBytes
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
using namespace XTL; // for logging
|
||||||
|
|
||||||
HLE_init_pgraph_plugins(); // TODO : Move to more approriate spot
|
HLE_init_pgraph_plugins(); // TODO : Move to more approriate spot
|
||||||
|
|
||||||
// Test-case : Azurik (see https://github.com/Cxbx-Reloaded/Cxbx-Reloaded/issues/360)
|
// Test-case : Azurik (see https://github.com/Cxbx-Reloaded/Cxbx-Reloaded/issues/360)
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
#ifndef XBPUSHBUFFER_H
|
#ifndef XBPUSHBUFFER_H
|
||||||
#define XBPUSHBUFFER_H
|
#define XBPUSHBUFFER_H
|
||||||
|
|
||||||
|
#include "core/hle/D3D8/XbVertexBuffer.h" // for CxbxDrawContext
|
||||||
|
|
||||||
extern int DxbxFVF_GetNumberOfTextureCoordinates(DWORD dwFVF, int aTextureIndex);
|
extern int DxbxFVF_GetNumberOfTextureCoordinates(DWORD dwFVF, int aTextureIndex);
|
||||||
extern UINT DxbxFVFToVertexSizeInBytes(DWORD dwFVF, BOOL bIncludeTextures);
|
extern UINT DxbxFVFToVertexSizeInBytes(DWORD dwFVF, BOOL bIncludeTextures);
|
||||||
|
@ -33,8 +35,8 @@ extern void CxbxDrawPrimitiveUP(CxbxDrawContext &DrawContext);
|
||||||
|
|
||||||
extern void EmuExecutePushBuffer
|
extern void EmuExecutePushBuffer
|
||||||
(
|
(
|
||||||
X_D3DPushBuffer *pPushBuffer,
|
XTL::X_D3DPushBuffer *pPushBuffer,
|
||||||
X_D3DFixup *pFixup
|
XTL::X_D3DFixup *pFixup
|
||||||
);
|
);
|
||||||
|
|
||||||
extern void EmuExecutePushBufferRaw
|
extern void EmuExecutePushBufferRaw
|
||||||
|
|
|
@ -28,11 +28,12 @@
|
||||||
|
|
||||||
#include "core\kernel\init\CxbxKrnl.h"
|
#include "core\kernel\init\CxbxKrnl.h"
|
||||||
#include "core\kernel\support\Emu.h"
|
#include "core\kernel\support\Emu.h"
|
||||||
#include "core\kernel\support\EmuXTL.h"
|
#include "core\kernel\support\EmuXTL.h"
|
||||||
|
#include "core\hle\D3D8\XbConvert.h" // For DxbxRenderStateInfo
|
||||||
|
|
||||||
// deferred state lookup tables
|
// deferred state lookup tables
|
||||||
DWORD *XTL::EmuD3DDeferredRenderState = nullptr;
|
DWORD *EmuD3DDeferredRenderState = nullptr;
|
||||||
DWORD *XTL::EmuD3DDeferredTextureState = nullptr;
|
DWORD *EmuD3DDeferredTextureState = nullptr;
|
||||||
|
|
||||||
#include "core\hle\Intercept.hpp" // For g_SymbolAddresses
|
#include "core\hle\Intercept.hpp" // For g_SymbolAddresses
|
||||||
#include "common/Settings.hpp" // For g_LibVersion_D3D8
|
#include "common/Settings.hpp" // For g_LibVersion_D3D8
|
||||||
|
@ -60,32 +61,32 @@ void VerifyAndFixEmuDeferredRenderStateOffset()
|
||||||
// Calculate index of D3DRS_CULLMODE for this XDK. We start counting from the first deferred state (D3DRS_FOGENABLE)
|
// Calculate index of D3DRS_CULLMODE for this XDK. We start counting from the first deferred state (D3DRS_FOGENABLE)
|
||||||
DWORD CullModeIndex = 0;
|
DWORD CullModeIndex = 0;
|
||||||
for (int i = XTL::X_D3DRS_FOGENABLE; i < XTL::X_D3DRS_CULLMODE; i++) {
|
for (int i = XTL::X_D3DRS_FOGENABLE; i < XTL::X_D3DRS_CULLMODE; i++) {
|
||||||
if (XTL::DxbxRenderStateInfo[i].V <= g_LibVersion_D3D8) {
|
if (DxbxRenderStateInfo[i].V <= g_LibVersion_D3D8) {
|
||||||
CullModeIndex++;
|
CullModeIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the offset was incorrect, calculate the correct offset, log it, and fix it
|
// If the offset was incorrect, calculate the correct offset, log it, and fix it
|
||||||
if ((DWORD)(&XTL::EmuD3DDeferredRenderState[CullModeIndex]) != CullModeOffset) {
|
if ((DWORD)(&EmuD3DDeferredRenderState[CullModeIndex]) != CullModeOffset) {
|
||||||
DWORD CorrectOffset = CullModeOffset - (CullModeIndex * sizeof(DWORD));
|
DWORD CorrectOffset = CullModeOffset - (CullModeIndex * sizeof(DWORD));
|
||||||
EmuLog(LOG_LEVEL::WARNING, "EmuD3DDeferredRenderState returned by XboxSymbolDatabase (0x%08X) was incorrect. Correcting to be 0x%08X.\nPlease file an issue with the XbSymbolDatabase project", XTL::EmuD3DDeferredRenderState, CorrectOffset);
|
EmuLog(LOG_LEVEL::WARNING, "EmuD3DDeferredRenderState returned by XboxSymbolDatabase (0x%08X) was incorrect. Correcting to be 0x%08X.\nPlease file an issue with the XbSymbolDatabase project", EmuD3DDeferredRenderState, CorrectOffset);
|
||||||
XTL::EmuD3DDeferredRenderState = (DWORD*)CorrectOffset;
|
EmuD3DDeferredRenderState = (DWORD*)CorrectOffset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateDeferredRenderStates()
|
void UpdateDeferredRenderStates()
|
||||||
{
|
{
|
||||||
// Certain D3DRS values need to be checked on each Draw[Indexed]Vertices
|
// Certain D3DRS values need to be checked on each Draw[Indexed]Vertices
|
||||||
if (XTL::EmuD3DDeferredRenderState != 0) {
|
if (EmuD3DDeferredRenderState != 0) {
|
||||||
// Loop through all deferred render states
|
// Loop through all deferred render states
|
||||||
for (unsigned int RenderState = XTL::X_D3DRS_FOGENABLE; RenderState <= XTL::X_D3DRS_PRESENTATIONINTERVAL; RenderState++) {
|
for (unsigned int RenderState = XTL::X_D3DRS_FOGENABLE; RenderState <= XTL::X_D3DRS_PRESENTATIONINTERVAL; RenderState++) {
|
||||||
// If the current state is not present within our desired XDK, skip it
|
// If the current state is not present within our desired XDK, skip it
|
||||||
if (XTL::DxbxRenderStateInfo[RenderState].V >= g_LibVersion_D3D8) {
|
if (DxbxRenderStateInfo[RenderState].V >= g_LibVersion_D3D8) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t index = RenderState - XTL::X_D3DRS_FOGENABLE;
|
uint8_t index = RenderState - XTL::X_D3DRS_FOGENABLE;
|
||||||
DWORD Value = XTL::EmuD3DDeferredRenderState[index];
|
DWORD Value = EmuD3DDeferredRenderState[index];
|
||||||
|
|
||||||
// Convert from Xbox Data Formats to PC
|
// Convert from Xbox Data Formats to PC
|
||||||
switch (RenderState) {
|
switch (RenderState) {
|
||||||
|
@ -165,15 +166,15 @@ void UpdateDeferredRenderStates()
|
||||||
Value |= (OldValue & 0x01000000) ? D3DWRAPCOORD_3 : 0;
|
Value |= (OldValue & 0x01000000) ? D3DWRAPCOORD_3 : 0;
|
||||||
} break;
|
} break;
|
||||||
default:
|
default:
|
||||||
EmuLog(LOG_LEVEL::WARNING, "Unimplemented Deferred Render State: %s", XTL::DxbxRenderStateInfo[RenderState].S);
|
EmuLog(LOG_LEVEL::WARNING, "Unimplemented Deferred Render State: %s", DxbxRenderStateInfo[RenderState].S);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (XTL::DxbxRenderStateInfo[RenderState].PC == 0) {
|
if (DxbxRenderStateInfo[RenderState].PC == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_pD3DDevice->SetRenderState(XTL::DxbxRenderStateInfo[RenderState].PC, Value);
|
g_pD3DDevice->SetRenderState(DxbxRenderStateInfo[RenderState].PC, Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -252,7 +253,7 @@ void UpdateDeferredTextureStates()
|
||||||
// The Xbox NV2A uses only Stage 3 for point-sprites, so we emulate this
|
// The Xbox NV2A uses only Stage 3 for point-sprites, so we emulate this
|
||||||
// by mapping Stage 3 to Stage 0, and disabling all stages > 0
|
// by mapping Stage 3 to Stage 0, and disabling all stages > 0
|
||||||
bool pointSpriteOverride = false;
|
bool pointSpriteOverride = false;
|
||||||
if (XTL::EmuD3DDeferredRenderState[XTL::X_D3DRS_POINTSPRITEENABLE - XTL::X_D3DRS_FOGENABLE] == TRUE) {
|
if (EmuD3DDeferredRenderState[XTL::X_D3DRS_POINTSPRITEENABLE - XTL::X_D3DRS_FOGENABLE] == TRUE) {
|
||||||
pointSpriteOverride = true;
|
pointSpriteOverride = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,7 +263,7 @@ void UpdateDeferredTextureStates()
|
||||||
|
|
||||||
for (int StateIndex = XTL::X_D3DTSS_DEFERRED_FIRST; StateIndex <= XTL::X_D3DTSS_DEFERRED_LAST; StateIndex++) {
|
for (int StateIndex = XTL::X_D3DTSS_DEFERRED_FIRST; StateIndex <= XTL::X_D3DTSS_DEFERRED_LAST; StateIndex++) {
|
||||||
// Read the value of the current stage/state from the Xbox data structure
|
// Read the value of the current stage/state from the Xbox data structure
|
||||||
DWORD Value = XTL::EmuD3DDeferredTextureState[(XboxStage * XTL::X_D3DTS_STAGESIZE) + StateIndex];
|
DWORD Value = EmuD3DDeferredTextureState[(XboxStage * XTL::X_D3DTS_STAGESIZE) + StateIndex];
|
||||||
|
|
||||||
// Convert the index of the current state to an index that we can use
|
// Convert the index of the current state to an index that we can use
|
||||||
// This handles the case when XDKs have different state values
|
// This handles the case when XDKs have different state values
|
||||||
|
@ -518,7 +519,7 @@ void UpdateDeferredTextureStates()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (XTL::EmuD3DDeferredRenderState[XTL::X_D3DRS_POINTSPRITEENABLE - XTL::X_D3DRS_FOGENABLE] == TRUE) {
|
if (EmuD3DDeferredRenderState[XTL::X_D3DRS_POINTSPRITEENABLE - XTL::X_D3DRS_FOGENABLE] == TRUE) {
|
||||||
XTL::IDirect3DBaseTexture *pTexture;
|
XTL::IDirect3DBaseTexture *pTexture;
|
||||||
|
|
||||||
// set the point sprites texture
|
// set the point sprites texture
|
||||||
|
@ -536,7 +537,7 @@ void UpdateDeferredTextureStates()
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * patch: UpdateDeferredStates
|
// * patch: UpdateDeferredStates
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
void XTL::EmuUpdateDeferredStates()
|
void EmuUpdateDeferredStates()
|
||||||
{
|
{
|
||||||
VerifyAndFixEmuDeferredRenderStateOffset();
|
VerifyAndFixEmuDeferredRenderStateOffset();
|
||||||
UpdateDeferredRenderStates();
|
UpdateDeferredRenderStates();
|
||||||
|
|
|
@ -25,10 +25,10 @@
|
||||||
#ifndef XBSTATE_H
|
#ifndef XBSTATE_H
|
||||||
#define XBSTATE_H
|
#define XBSTATE_H
|
||||||
|
|
||||||
#define X_D3DRS_UNSUPPORTED (X_D3DRS_LAST + 1)
|
#define CXBX_D3DRS_UNSUPPORTED (XTL::X_D3DRS_LAST + 1)
|
||||||
|
|
||||||
// XDK version independent renderstate table, containing pointers to the original locations.
|
// XDK version independent renderstate table, containing pointers to the original locations.
|
||||||
extern DWORD *EmuMappedD3DRenderState[X_D3DRS_UNSUPPORTED]; // 1 extra for the unsupported value
|
extern DWORD *EmuMappedD3DRenderState[CXBX_D3DRS_UNSUPPORTED]; // 1 extra for the unsupported value
|
||||||
|
|
||||||
struct X_Stream {
|
struct X_Stream {
|
||||||
DWORD Stride;
|
DWORD Stride;
|
||||||
|
@ -43,7 +43,7 @@ extern DWORD *EmuD3DDeferredRenderState;
|
||||||
extern DWORD *EmuD3DDeferredTextureState;
|
extern DWORD *EmuD3DDeferredTextureState;
|
||||||
|
|
||||||
extern void EmuUpdateDeferredStates();
|
extern void EmuUpdateDeferredStates();
|
||||||
|
|
||||||
extern void CxbxUpdateNativeD3DResources();
|
extern void CxbxUpdateNativeD3DResources();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -33,6 +33,10 @@
|
||||||
#include "core\kernel\support\Emu.h"
|
#include "core\kernel\support\Emu.h"
|
||||||
#include "core\kernel\support\EmuXTL.h"
|
#include "core\kernel\support\EmuXTL.h"
|
||||||
#include "core\hle\D3D8\ResourceTracker.h"
|
#include "core\hle\D3D8\ResourceTracker.h"
|
||||||
|
#include "core\hle\D3D8\XbPushBuffer.h" // for DxbxFVF_GetNumberOfTextureCoordinates
|
||||||
|
#include "core\hle\D3D8\XbState.h" // For CxbxUpdateNativeD3DResources, etc
|
||||||
|
#include "core\hle\D3D8\XbVertexBuffer.h"
|
||||||
|
#include "core\hle\D3D8\XbConvert.h"
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
@ -41,18 +45,18 @@
|
||||||
#define MAX_STREAM_NOT_USED_TIME (2 * CLOCKS_PER_SEC) // TODO: Trim the not used time
|
#define MAX_STREAM_NOT_USED_TIME (2 * CLOCKS_PER_SEC) // TODO: Trim the not used time
|
||||||
|
|
||||||
// Inline vertex buffer emulation
|
// Inline vertex buffer emulation
|
||||||
extern XTL::X_D3DPRIMITIVETYPE XTL::g_InlineVertexBuffer_PrimitiveType = XTL::X_D3DPT_INVALID;
|
extern XTL::X_D3DPRIMITIVETYPE g_InlineVertexBuffer_PrimitiveType = XTL::X_D3DPT_INVALID;
|
||||||
extern DWORD XTL::g_InlineVertexBuffer_FVF = 0;
|
extern DWORD g_InlineVertexBuffer_FVF = 0;
|
||||||
extern struct XTL::_D3DIVB *XTL::g_InlineVertexBuffer_Table = nullptr;
|
extern struct _D3DIVB *g_InlineVertexBuffer_Table = nullptr;
|
||||||
extern UINT XTL::g_InlineVertexBuffer_TableLength = 0;
|
extern UINT g_InlineVertexBuffer_TableLength = 0;
|
||||||
extern UINT XTL::g_InlineVertexBuffer_TableOffset = 0;
|
extern UINT g_InlineVertexBuffer_TableOffset = 0;
|
||||||
|
|
||||||
FLOAT *g_InlineVertexBuffer_pData = nullptr;
|
FLOAT *g_InlineVertexBuffer_pData = nullptr;
|
||||||
UINT g_InlineVertexBuffer_DataSize = 0;
|
UINT g_InlineVertexBuffer_DataSize = 0;
|
||||||
|
|
||||||
extern XTL::X_D3DVertexBuffer *g_pVertexBuffer = NULL;
|
extern XTL::X_D3DVertexBuffer *g_pVertexBuffer = NULL;
|
||||||
|
|
||||||
extern DWORD XTL::g_dwPrimPerFrame = 0;
|
extern DWORD g_dwPrimPerFrame = 0;
|
||||||
extern XTL::X_D3DVertexBuffer*g_D3DStreams[X_VSH_MAX_STREAMS];
|
extern XTL::X_D3DVertexBuffer*g_D3DStreams[X_VSH_MAX_STREAMS];
|
||||||
extern UINT g_D3DStreamStrides[X_VSH_MAX_STREAMS];
|
extern UINT g_D3DStreamStrides[X_VSH_MAX_STREAMS];
|
||||||
extern XTL::X_D3DSurface* g_pXboxRenderTarget;
|
extern XTL::X_D3DSurface* g_pXboxRenderTarget;
|
||||||
|
@ -62,7 +66,7 @@ bool GetHostRenderTargetDimensions(DWORD* pHostWidth, DWORD* pHostHeight, XTL::I
|
||||||
uint32_t GetPixelContainerWidth(XTL::X_D3DPixelContainer* pPixelContainer);
|
uint32_t GetPixelContainerWidth(XTL::X_D3DPixelContainer* pPixelContainer);
|
||||||
uint32_t GetPixelContainerHeight(XTL::X_D3DPixelContainer* pPixelContainer);
|
uint32_t GetPixelContainerHeight(XTL::X_D3DPixelContainer* pPixelContainer);
|
||||||
|
|
||||||
void XTL::CxbxPatchedStream::Activate(XTL::CxbxDrawContext *pDrawContext, UINT uiStream) const
|
void CxbxPatchedStream::Activate(CxbxDrawContext *pDrawContext, UINT uiStream) const
|
||||||
{
|
{
|
||||||
//LOG_INIT // Allows use of DEBUG_D3DRESULT
|
//LOG_INIT // Allows use of DEBUG_D3DRESULT
|
||||||
|
|
||||||
|
@ -86,12 +90,12 @@ void XTL::CxbxPatchedStream::Activate(XTL::CxbxDrawContext *pDrawContext, UINT u
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XTL::CxbxPatchedStream::CxbxPatchedStream()
|
CxbxPatchedStream::CxbxPatchedStream()
|
||||||
{
|
{
|
||||||
isValid = false;
|
isValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
XTL::CxbxPatchedStream::~CxbxPatchedStream()
|
CxbxPatchedStream::~CxbxPatchedStream()
|
||||||
{
|
{
|
||||||
if (bCachedHostVertexStreamZeroDataIsAllocated) {
|
if (bCachedHostVertexStreamZeroDataIsAllocated) {
|
||||||
free(pCachedHostVertexStreamZeroData);
|
free(pCachedHostVertexStreamZeroData);
|
||||||
|
@ -106,7 +110,7 @@ XTL::CxbxPatchedStream::~CxbxPatchedStream()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XTL::CxbxVertexBufferConverter::CxbxVertexBufferConverter()
|
CxbxVertexBufferConverter::CxbxVertexBufferConverter()
|
||||||
{
|
{
|
||||||
m_uiNbrStreams = 0;
|
m_uiNbrStreams = 0;
|
||||||
m_pVertexShaderInfo = nullptr;
|
m_pVertexShaderInfo = nullptr;
|
||||||
|
@ -145,9 +149,9 @@ int CountActiveD3DStreams()
|
||||||
return lastStreamIndex;
|
return lastStreamIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
XTL::CxbxVertexShaderInfo *GetCxbxVertexShaderInfo(DWORD XboxVertexShaderHandle); // forward
|
CxbxVertexShaderInfo *GetCxbxVertexShaderInfo(DWORD XboxVertexShaderHandle); // forward
|
||||||
|
|
||||||
UINT XTL::CxbxVertexBufferConverter::GetNbrStreams(CxbxDrawContext *pDrawContext)
|
UINT CxbxVertexBufferConverter::GetNbrStreams(CxbxDrawContext *pDrawContext)
|
||||||
{
|
{
|
||||||
// Draw..Up always have one stream
|
// Draw..Up always have one stream
|
||||||
if (pDrawContext->pXboxVertexStreamZeroData != xbnullptr) {
|
if (pDrawContext->pXboxVertexStreamZeroData != xbnullptr) {
|
||||||
|
@ -195,7 +199,7 @@ inline FLOAT ByteToFloat(const BYTE value)
|
||||||
return ((FLOAT)value) / 255.0f;
|
return ((FLOAT)value) / 255.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
XTL::CxbxPatchedStream& XTL::CxbxVertexBufferConverter::GetPatchedStream(uint64_t key)
|
CxbxPatchedStream& CxbxVertexBufferConverter::GetPatchedStream(uint64_t key)
|
||||||
{
|
{
|
||||||
// First, attempt to fetch an existing patched stream
|
// First, attempt to fetch an existing patched stream
|
||||||
auto it = m_PatchedStreams.find(key);
|
auto it = m_PatchedStreams.find(key);
|
||||||
|
@ -222,7 +226,7 @@ XTL::CxbxPatchedStream& XTL::CxbxVertexBufferConverter::GetPatchedStream(uint64_
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XTL::CxbxVertexBufferConverter::PrintStats()
|
void CxbxVertexBufferConverter::PrintStats()
|
||||||
{
|
{
|
||||||
printf("Vertex Buffer Cache Status: \n");
|
printf("Vertex Buffer Cache Status: \n");
|
||||||
printf("- Cache Size: %d\n", m_PatchedStreams.size());
|
printf("- Cache Size: %d\n", m_PatchedStreams.size());
|
||||||
|
@ -230,7 +234,7 @@ void XTL::CxbxVertexBufferConverter::PrintStats()
|
||||||
printf("- Misses: %d\n", m_TotalCacheMisses);
|
printf("- Misses: %d\n", m_TotalCacheMisses);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XTL::CxbxVertexBufferConverter::ConvertStream
|
void CxbxVertexBufferConverter::ConvertStream
|
||||||
(
|
(
|
||||||
CxbxDrawContext *pDrawContext,
|
CxbxDrawContext *pDrawContext,
|
||||||
UINT uiStream
|
UINT uiStream
|
||||||
|
@ -257,7 +261,7 @@ void XTL::CxbxVertexBufferConverter::ConvertStream
|
||||||
if (i + 1 <= dwTexN) {
|
if (i + 1 <= dwTexN) {
|
||||||
pActivePixelContainer[i].NrTexCoords = DxbxFVF_GetNumberOfTextureCoordinates(XboxFVF, i);
|
pActivePixelContainer[i].NrTexCoords = DxbxFVF_GetNumberOfTextureCoordinates(XboxFVF, i);
|
||||||
// TODO : Use GetXboxBaseTexture()
|
// TODO : Use GetXboxBaseTexture()
|
||||||
X_D3DBaseTexture *pXboxBaseTexture = EmuD3DActiveTexture[i];
|
XTL::X_D3DBaseTexture *pXboxBaseTexture = XTL::EmuD3DActiveTexture[i];
|
||||||
if (pXboxBaseTexture != xbnullptr) {
|
if (pXboxBaseTexture != xbnullptr) {
|
||||||
extern XTL::X_D3DFORMAT GetXboxPixelContainerFormat(const XTL::X_D3DPixelContainer *pXboxPixelContainer); // TODO : Move to XTL-independent header file
|
extern XTL::X_D3DFORMAT GetXboxPixelContainerFormat(const XTL::X_D3DPixelContainer *pXboxPixelContainer); // TODO : Move to XTL-independent header file
|
||||||
|
|
||||||
|
@ -297,7 +301,7 @@ void XTL::CxbxVertexBufferConverter::ConvertStream
|
||||||
UINT uiHostVertexStride = 0;
|
UINT uiHostVertexStride = 0;
|
||||||
DWORD dwHostVertexDataSize = 0;
|
DWORD dwHostVertexDataSize = 0;
|
||||||
uint8_t *pHostVertexData = nullptr;
|
uint8_t *pHostVertexData = nullptr;
|
||||||
IDirect3DVertexBuffer *pNewHostVertexBuffer = nullptr;
|
XTL::IDirect3DVertexBuffer *pNewHostVertexBuffer = nullptr;
|
||||||
|
|
||||||
if (pDrawContext->pXboxVertexStreamZeroData != xbnullptr) {
|
if (pDrawContext->pXboxVertexStreamZeroData != xbnullptr) {
|
||||||
// There should only be one stream (stream zero) in this case
|
// There should only be one stream (stream zero) in this case
|
||||||
|
@ -440,7 +444,7 @@ void XTL::CxbxVertexBufferConverter::ConvertStream
|
||||||
// Dxbx note : The following code handles only the D3DVSDT enums that need conversion;
|
// Dxbx note : The following code handles only the D3DVSDT enums that need conversion;
|
||||||
// All other cases are catched by the memcpy in the default-block.
|
// All other cases are catched by the memcpy in the default-block.
|
||||||
switch (pVertexShaderStreamInfo->VertexElements[uiElement].XboxType) {
|
switch (pVertexShaderStreamInfo->VertexElements[uiElement].XboxType) {
|
||||||
case X_D3DVSDT_NORMSHORT1: { // 0x11:
|
case XTL::X_D3DVSDT_NORMSHORT1: { // 0x11:
|
||||||
// Test-cases : Halo - Combat Evolved
|
// Test-cases : Halo - Combat Evolved
|
||||||
XboxElementByteSize = 1 * sizeof(SHORT);
|
XboxElementByteSize = 1 * sizeof(SHORT);
|
||||||
if (g_D3DCaps.DeclTypes & D3DDTCAPS_SHORT2N) {
|
if (g_D3DCaps.DeclTypes & D3DDTCAPS_SHORT2N) {
|
||||||
|
@ -456,7 +460,7 @@ void XTL::CxbxVertexBufferConverter::ConvertStream
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case X_D3DVSDT_NORMSHORT2: { // 0x21:
|
case XTL::X_D3DVSDT_NORMSHORT2: { // 0x21:
|
||||||
// Test-cases : Baldur's Gate: Dark Alliance 2, F1 2002, Gun, Halo - Combat Evolved, Scrapland
|
// Test-cases : Baldur's Gate: Dark Alliance 2, F1 2002, Gun, Halo - Combat Evolved, Scrapland
|
||||||
XboxElementByteSize = 2 * sizeof(SHORT);
|
XboxElementByteSize = 2 * sizeof(SHORT);
|
||||||
if (g_D3DCaps.DeclTypes & D3DDTCAPS_SHORT2N) {
|
if (g_D3DCaps.DeclTypes & D3DDTCAPS_SHORT2N) {
|
||||||
|
@ -476,7 +480,7 @@ void XTL::CxbxVertexBufferConverter::ConvertStream
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case X_D3DVSDT_NORMSHORT3: { // 0x31:
|
case XTL::X_D3DVSDT_NORMSHORT3: { // 0x31:
|
||||||
// Test-cases : Cel Damage, Constantine, Destroy All Humans!
|
// Test-cases : Cel Damage, Constantine, Destroy All Humans!
|
||||||
XboxElementByteSize = 3 * sizeof(SHORT);
|
XboxElementByteSize = 3 * sizeof(SHORT);
|
||||||
if (g_D3DCaps.DeclTypes & D3DDTCAPS_SHORT4N) {
|
if (g_D3DCaps.DeclTypes & D3DDTCAPS_SHORT4N) {
|
||||||
|
@ -495,7 +499,7 @@ void XTL::CxbxVertexBufferConverter::ConvertStream
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case X_D3DVSDT_NORMSHORT4: { // 0x41:
|
case XTL::X_D3DVSDT_NORMSHORT4: { // 0x41:
|
||||||
// Test-cases : Judge Dredd: Dredd vs Death, NHL Hitz 2002, Silent Hill 2, Sneakers, Tony Hawk Pro Skater 4
|
// Test-cases : Judge Dredd: Dredd vs Death, NHL Hitz 2002, Silent Hill 2, Sneakers, Tony Hawk Pro Skater 4
|
||||||
XboxElementByteSize = 4 * sizeof(SHORT);
|
XboxElementByteSize = 4 * sizeof(SHORT);
|
||||||
if (g_D3DCaps.DeclTypes & D3DDTCAPS_SHORT4N) {
|
if (g_D3DCaps.DeclTypes & D3DDTCAPS_SHORT4N) {
|
||||||
|
@ -519,7 +523,7 @@ void XTL::CxbxVertexBufferConverter::ConvertStream
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case X_D3DVSDT_NORMPACKED3: { // 0x16:
|
case XTL::X_D3DVSDT_NORMPACKED3: { // 0x16:
|
||||||
// Test-cases : Dashboard
|
// Test-cases : Dashboard
|
||||||
XboxElementByteSize = 1 * sizeof(int32_t);
|
XboxElementByteSize = 1 * sizeof(int32_t);
|
||||||
// Make it FLOAT3
|
// Make it FLOAT3
|
||||||
|
@ -539,14 +543,14 @@ void XTL::CxbxVertexBufferConverter::ConvertStream
|
||||||
pHostVertexAsFloat[2] = PackedIntToFloat(NormPacked3.z, 511.0f, 512.f);
|
pHostVertexAsFloat[2] = PackedIntToFloat(NormPacked3.z, 511.0f, 512.f);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case X_D3DVSDT_SHORT1: { // 0x15:
|
case XTL::X_D3DVSDT_SHORT1: { // 0x15:
|
||||||
XboxElementByteSize = 1 * sizeof(SHORT);
|
XboxElementByteSize = 1 * sizeof(SHORT);
|
||||||
// Make it SHORT2 and set the second short to 0
|
// Make it SHORT2 and set the second short to 0
|
||||||
pHostVertexAsShort[0] = pXboxVertexAsShort[0];
|
pHostVertexAsShort[0] = pXboxVertexAsShort[0];
|
||||||
pHostVertexAsShort[1] = 0;
|
pHostVertexAsShort[1] = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case X_D3DVSDT_SHORT3: { // 0x35:
|
case XTL::X_D3DVSDT_SHORT3: { // 0x35:
|
||||||
// Test-cases : Turok
|
// Test-cases : Turok
|
||||||
XboxElementByteSize = 3 * sizeof(SHORT);
|
XboxElementByteSize = 3 * sizeof(SHORT);
|
||||||
// Make it a SHORT4 and set the fourth short to 1
|
// Make it a SHORT4 and set the fourth short to 1
|
||||||
|
@ -556,7 +560,7 @@ void XTL::CxbxVertexBufferConverter::ConvertStream
|
||||||
pHostVertexAsShort[3] = 1; // Turok verified (character disappears when this is 32767)
|
pHostVertexAsShort[3] = 1; // Turok verified (character disappears when this is 32767)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case X_D3DVSDT_PBYTE1: { // 0x14:
|
case XTL::X_D3DVSDT_PBYTE1: { // 0x14:
|
||||||
XboxElementByteSize = 1 * sizeof(BYTE);
|
XboxElementByteSize = 1 * sizeof(BYTE);
|
||||||
if (g_D3DCaps.DeclTypes & D3DDTCAPS_UBYTE4N) {
|
if (g_D3DCaps.DeclTypes & D3DDTCAPS_UBYTE4N) {
|
||||||
// Make it UBYTE4N
|
// Make it UBYTE4N
|
||||||
|
@ -572,7 +576,7 @@ void XTL::CxbxVertexBufferConverter::ConvertStream
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case X_D3DVSDT_PBYTE2: { // 0x24:
|
case XTL::X_D3DVSDT_PBYTE2: { // 0x24:
|
||||||
XboxElementByteSize = 2 * sizeof(BYTE);
|
XboxElementByteSize = 2 * sizeof(BYTE);
|
||||||
if (g_D3DCaps.DeclTypes & D3DDTCAPS_UBYTE4N) {
|
if (g_D3DCaps.DeclTypes & D3DDTCAPS_UBYTE4N) {
|
||||||
// Make it UBYTE4N
|
// Make it UBYTE4N
|
||||||
|
@ -589,7 +593,7 @@ void XTL::CxbxVertexBufferConverter::ConvertStream
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case X_D3DVSDT_PBYTE3: { // 0x34:
|
case XTL::X_D3DVSDT_PBYTE3: { // 0x34:
|
||||||
// Test-cases : Turok
|
// Test-cases : Turok
|
||||||
XboxElementByteSize = 3 * sizeof(BYTE);
|
XboxElementByteSize = 3 * sizeof(BYTE);
|
||||||
if (g_D3DCaps.DeclTypes & D3DDTCAPS_UBYTE4N) {
|
if (g_D3DCaps.DeclTypes & D3DDTCAPS_UBYTE4N) {
|
||||||
|
@ -608,7 +612,7 @@ void XTL::CxbxVertexBufferConverter::ConvertStream
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case X_D3DVSDT_PBYTE4: { // 0x44:
|
case XTL::X_D3DVSDT_PBYTE4: { // 0x44:
|
||||||
// Test-case : Jet Set Radio Future
|
// Test-case : Jet Set Radio Future
|
||||||
XboxElementByteSize = 4 * sizeof(BYTE);
|
XboxElementByteSize = 4 * sizeof(BYTE);
|
||||||
if (g_D3DCaps.DeclTypes & D3DDTCAPS_UBYTE4N) {
|
if (g_D3DCaps.DeclTypes & D3DDTCAPS_UBYTE4N) {
|
||||||
|
@ -632,7 +636,7 @@ void XTL::CxbxVertexBufferConverter::ConvertStream
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case X_D3DVSDT_FLOAT2H: { // 0x72:
|
case XTL::X_D3DVSDT_FLOAT2H: { // 0x72:
|
||||||
XboxElementByteSize = 3 * sizeof(FLOAT);
|
XboxElementByteSize = 3 * sizeof(FLOAT);
|
||||||
// Make it FLOAT4 and set the third float to 0.0
|
// Make it FLOAT4 and set the third float to 0.0
|
||||||
pHostVertexAsFloat[0] = pXboxVertexAsFloat[0];
|
pHostVertexAsFloat[0] = pXboxVertexAsFloat[0];
|
||||||
|
@ -641,7 +645,7 @@ void XTL::CxbxVertexBufferConverter::ConvertStream
|
||||||
pHostVertexAsFloat[3] = pXboxVertexAsFloat[2];
|
pHostVertexAsFloat[3] = pXboxVertexAsFloat[2];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case X_D3DVSDT_NONE: { // 0x02: // Skip it
|
case XTL::X_D3DVSDT_NONE: { // 0x02: // Skip it
|
||||||
// Test-case : WWE RAW2
|
// Test-case : WWE RAW2
|
||||||
LOG_TEST_CASE("X_D3DVSDT_NONE");
|
LOG_TEST_CASE("X_D3DVSDT_NONE");
|
||||||
break;
|
break;
|
||||||
|
@ -675,7 +679,7 @@ void XTL::CxbxVertexBufferConverter::ConvertStream
|
||||||
|
|
||||||
// Locate texture coordinate offset in vertex structure.
|
// Locate texture coordinate offset in vertex structure.
|
||||||
if (bNeedTextureNormalization) {
|
if (bNeedTextureNormalization) {
|
||||||
uiTextureCoordinatesByteOffsetInVertex = XTL::DxbxFVFToVertexSizeInBytes(XboxFVF, /*bIncludeTextures=*/false);
|
uiTextureCoordinatesByteOffsetInVertex = DxbxFVFToVertexSizeInBytes(XboxFVF, /*bIncludeTextures=*/false);
|
||||||
if (bNeedVertexPatching) {
|
if (bNeedVertexPatching) {
|
||||||
LOG_TEST_CASE("Potential xbox vs host texture-offset difference! (bNeedVertexPatching within bNeedTextureNormalization)");
|
LOG_TEST_CASE("Potential xbox vs host texture-offset difference! (bNeedVertexPatching within bNeedTextureNormalization)");
|
||||||
}
|
}
|
||||||
|
@ -784,9 +788,9 @@ void XTL::CxbxVertexBufferConverter::ConvertStream
|
||||||
patchedStream.Activate(pDrawContext, uiStream);
|
patchedStream.Activate(pDrawContext, uiStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XTL::CxbxVertexBufferConverter::Apply(CxbxDrawContext *pDrawContext)
|
void CxbxVertexBufferConverter::Apply(CxbxDrawContext *pDrawContext)
|
||||||
{
|
{
|
||||||
if ((pDrawContext->XboxPrimitiveType < X_D3DPT_POINTLIST) || (pDrawContext->XboxPrimitiveType > X_D3DPT_POLYGON))
|
if ((pDrawContext->XboxPrimitiveType < XTL::X_D3DPT_POINTLIST) || (pDrawContext->XboxPrimitiveType > XTL::X_D3DPT_POLYGON))
|
||||||
CxbxKrnlCleanup("Unknown primitive type: 0x%.02X\n", pDrawContext->XboxPrimitiveType);
|
CxbxKrnlCleanup("Unknown primitive type: 0x%.02X\n", pDrawContext->XboxPrimitiveType);
|
||||||
|
|
||||||
m_pVertexShaderInfo = nullptr;
|
m_pVertexShaderInfo = nullptr;
|
||||||
|
@ -812,7 +816,7 @@ void XTL::CxbxVertexBufferConverter::Apply(CxbxDrawContext *pDrawContext)
|
||||||
ConvertStream(pDrawContext, uiStream);
|
ConvertStream(pDrawContext, uiStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pDrawContext->XboxPrimitiveType == X_D3DPT_QUADSTRIP) {
|
if (pDrawContext->XboxPrimitiveType == XTL::X_D3DPT_QUADSTRIP) {
|
||||||
// Quad strip is just like a triangle strip, but requires two vertices per primitive.
|
// Quad strip is just like a triangle strip, but requires two vertices per primitive.
|
||||||
// A quadstrip starts with 4 vertices and adds 2 vertices per additional quad.
|
// A quadstrip starts with 4 vertices and adds 2 vertices per additional quad.
|
||||||
// This is much like a trianglestrip, which starts with 3 vertices and adds
|
// This is much like a trianglestrip, which starts with 3 vertices and adds
|
||||||
|
@ -823,12 +827,12 @@ void XTL::CxbxVertexBufferConverter::Apply(CxbxDrawContext *pDrawContext)
|
||||||
// handled by d3d :
|
// handled by d3d :
|
||||||
// Test-case : XDK Samples (FocusBlur, MotionBlur, Trees, PaintEffect, PlayField)
|
// Test-case : XDK Samples (FocusBlur, MotionBlur, Trees, PaintEffect, PlayField)
|
||||||
// No need to set : pDrawContext->XboxPrimitiveType = X_D3DPT_TRIANGLESTRIP;
|
// No need to set : pDrawContext->XboxPrimitiveType = X_D3DPT_TRIANGLESTRIP;
|
||||||
pDrawContext->dwHostPrimitiveCount = EmuD3DVertex2PrimitiveCount(X_D3DPT_TRIANGLESTRIP, pDrawContext->dwVertexCount);
|
pDrawContext->dwHostPrimitiveCount = EmuD3DVertex2PrimitiveCount(XTL::X_D3DPT_TRIANGLESTRIP, pDrawContext->dwVertexCount);
|
||||||
} else {
|
} else {
|
||||||
pDrawContext->dwHostPrimitiveCount = EmuD3DVertex2PrimitiveCount(pDrawContext->XboxPrimitiveType, pDrawContext->dwVertexCount);
|
pDrawContext->dwHostPrimitiveCount = EmuD3DVertex2PrimitiveCount(pDrawContext->XboxPrimitiveType, pDrawContext->dwVertexCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pDrawContext->XboxPrimitiveType == X_D3DPT_POLYGON) {
|
if (pDrawContext->XboxPrimitiveType == XTL::X_D3DPT_POLYGON) {
|
||||||
// Convex polygon is the same as a triangle fan.
|
// Convex polygon is the same as a triangle fan.
|
||||||
// No need to set : pDrawContext->XboxPrimitiveType = X_D3DPT_TRIANGLEFAN;
|
// No need to set : pDrawContext->XboxPrimitiveType = X_D3DPT_TRIANGLEFAN;
|
||||||
// Test-case : Panzer Dragoon ORTA (when entering in-game)
|
// Test-case : Panzer Dragoon ORTA (when entering in-game)
|
||||||
|
@ -836,7 +840,7 @@ void XTL::CxbxVertexBufferConverter::Apply(CxbxDrawContext *pDrawContext)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID XTL::EmuFlushIVB()
|
VOID EmuFlushIVB()
|
||||||
{
|
{
|
||||||
CxbxUpdateNativeD3DResources();
|
CxbxUpdateNativeD3DResources();
|
||||||
|
|
||||||
|
|
|
@ -29,9 +29,12 @@
|
||||||
|
|
||||||
//#include <ctime> // Conflict with io.h
|
//#include <ctime> // Conflict with io.h
|
||||||
|
|
||||||
|
//#include "core\kernel\support\EmuXTL.h"
|
||||||
|
#include "core\hle\D3D8\XbVertexShader.h" // for CxbxVertexShaderInfo
|
||||||
|
|
||||||
typedef struct _CxbxDrawContext
|
typedef struct _CxbxDrawContext
|
||||||
{
|
{
|
||||||
IN X_D3DPRIMITIVETYPE XboxPrimitiveType;
|
IN XTL::X_D3DPRIMITIVETYPE XboxPrimitiveType;
|
||||||
IN DWORD dwVertexCount;
|
IN DWORD dwVertexCount;
|
||||||
IN DWORD dwStartVertex; // Only D3DDevice_DrawVertices sets this (potentially higher than default 0)
|
IN DWORD dwStartVertex; // Only D3DDevice_DrawVertices sets this (potentially higher than default 0)
|
||||||
// The current vertex shader, used to identify the streams
|
// The current vertex shader, used to identify the streams
|
||||||
|
@ -54,7 +57,7 @@ class CxbxPatchedStream
|
||||||
public:
|
public:
|
||||||
CxbxPatchedStream();
|
CxbxPatchedStream();
|
||||||
~CxbxPatchedStream();
|
~CxbxPatchedStream();
|
||||||
void Activate(XTL::CxbxDrawContext *pDrawContext, UINT uiStream) const;
|
void Activate(CxbxDrawContext *pDrawContext, UINT uiStream) const;
|
||||||
bool isValid = false;
|
bool isValid = false;
|
||||||
XTL::X_D3DPRIMITIVETYPE XboxPrimitiveType = XTL::X_D3DPT_NONE;
|
XTL::X_D3DPRIMITIVETYPE XboxPrimitiveType = XTL::X_D3DPT_NONE;
|
||||||
PVOID pCachedXboxVertexData = xbnullptr;
|
PVOID pCachedXboxVertexData = xbnullptr;
|
||||||
|
@ -88,7 +91,7 @@ class CxbxVertexBufferConverter
|
||||||
std::list<CxbxPatchedStream> m_PatchedStreamUsageList; // Linked list of vertex streams, least recently used is last in the list
|
std::list<CxbxPatchedStream> m_PatchedStreamUsageList; // Linked list of vertex streams, least recently used is last in the list
|
||||||
CxbxPatchedStream& GetPatchedStream(uint64_t); // Fetches (or inserts) a patched stream associated with the given key
|
CxbxPatchedStream& GetPatchedStream(uint64_t); // Fetches (or inserts) a patched stream associated with the given key
|
||||||
|
|
||||||
XTL::CxbxVertexShaderInfo *m_pVertexShaderInfo;
|
CxbxVertexShaderInfo *m_pVertexShaderInfo;
|
||||||
|
|
||||||
// Returns the number of streams of a patch
|
// Returns the number of streams of a patch
|
||||||
UINT GetNbrStreams(CxbxDrawContext *pPatchDesc);
|
UINT GetNbrStreams(CxbxDrawContext *pPatchDesc);
|
||||||
|
@ -98,7 +101,7 @@ class CxbxVertexBufferConverter
|
||||||
};
|
};
|
||||||
|
|
||||||
// inline vertex buffer emulation
|
// inline vertex buffer emulation
|
||||||
extern X_D3DPRIMITIVETYPE g_InlineVertexBuffer_PrimitiveType;
|
extern XTL::X_D3DPRIMITIVETYPE g_InlineVertexBuffer_PrimitiveType;
|
||||||
extern DWORD g_InlineVertexBuffer_FVF;
|
extern DWORD g_InlineVertexBuffer_FVF;
|
||||||
|
|
||||||
extern struct _D3DIVB
|
extern struct _D3DIVB
|
||||||
|
@ -107,11 +110,11 @@ extern struct _D3DIVB
|
||||||
FLOAT Rhw; // X_D3DVSDE_VERTEX (*) > D3DFVF_XYZ / D3DFVF_XYZRHW
|
FLOAT Rhw; // X_D3DVSDE_VERTEX (*) > D3DFVF_XYZ / D3DFVF_XYZRHW
|
||||||
FLOAT Blend[4]; // X_D3DVSDE_BLENDWEIGHT > D3DFVF_XYZB1 (and 3 more up to D3DFVF_XYZB4)
|
FLOAT Blend[4]; // X_D3DVSDE_BLENDWEIGHT > D3DFVF_XYZB1 (and 3 more up to D3DFVF_XYZB4)
|
||||||
XTL::D3DXVECTOR3 Normal; // X_D3DVSDE_NORMAL > D3DFVF_NORMAL
|
XTL::D3DXVECTOR3 Normal; // X_D3DVSDE_NORMAL > D3DFVF_NORMAL
|
||||||
D3DCOLOR Diffuse; // X_D3DVSDE_DIFFUSE > D3DFVF_DIFFUSE
|
XTL::D3DCOLOR Diffuse; // X_D3DVSDE_DIFFUSE > D3DFVF_DIFFUSE
|
||||||
D3DCOLOR Specular; // X_D3DVSDE_SPECULAR > D3DFVF_SPECULAR
|
XTL::D3DCOLOR Specular; // X_D3DVSDE_SPECULAR > D3DFVF_SPECULAR
|
||||||
FLOAT Fog; // X_D3DVSDE_FOG > D3DFVF_FOG unavailable; TODO : How to handle?
|
FLOAT Fog; // X_D3DVSDE_FOG > D3DFVF_FOG unavailable; TODO : How to handle?
|
||||||
D3DCOLOR BackDiffuse; // X_D3DVSDE_BACKDIFFUSE > D3DFVF_BACKDIFFUSE unavailable; TODO : How to handle?
|
XTL::D3DCOLOR BackDiffuse; // X_D3DVSDE_BACKDIFFUSE > D3DFVF_BACKDIFFUSE unavailable; TODO : How to handle?
|
||||||
D3DCOLOR BackSpecular; // X_D3DVSDE_BACKSPECULAR > D3DFVF_BACKSPECULAR unavailable; TODO : How to handle?
|
XTL::D3DCOLOR BackSpecular; // X_D3DVSDE_BACKSPECULAR > D3DFVF_BACKSPECULAR unavailable; TODO : How to handle?
|
||||||
XTL::D3DXVECTOR4 TexCoord[4]; // X_D3DVSDE_TEXCOORD0 > D3DFVF_TEX1 (and 4 more up to D3DFVF_TEX4)
|
XTL::D3DXVECTOR4 TexCoord[4]; // X_D3DVSDE_TEXCOORD0 > D3DFVF_TEX1 (and 4 more up to D3DFVF_TEX4)
|
||||||
|
|
||||||
// (*) X_D3DVSDE_POSITION and X_D3DVSDE_VERTEX both set Position, but Rhw seems optional,
|
// (*) X_D3DVSDE_POSITION and X_D3DVSDE_VERTEX both set Position, but Rhw seems optional,
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
#include "core\kernel\support\Emu.h"
|
#include "core\kernel\support\Emu.h"
|
||||||
#include "core\kernel\support\EmuFS.h"
|
#include "core\kernel\support\EmuFS.h"
|
||||||
#include "core\kernel\support\EmuXTL.h"
|
#include "core\kernel\support\EmuXTL.h"
|
||||||
|
#include "core\hle\D3D8\XbVertexShader.h"
|
||||||
|
|
||||||
#include "XbD3D8Types.h" // For X_D3DVSDE_*
|
#include "XbD3D8Types.h" // For X_D3DVSDE_*
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
@ -46,7 +48,7 @@
|
||||||
#define VSH_MAX_INSTRUCTION_COUNT VSH_VS2X_MAX_INSTRUCTION_COUNT // == 256
|
#define VSH_MAX_INSTRUCTION_COUNT VSH_VS2X_MAX_INSTRUCTION_COUNT // == 256
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Host Vertex Shader version (mustn't conflict with any VERSION_XVS*)
|
// Internal Vertex Shader version (mustn't conflict with any VERSION_XVS*)
|
||||||
#define VERSION_CXBX 0x7863 // 'cx' Cxbx vertex shader, not an official value, used in VshConvertShader() and VshWriteShader()
|
#define VERSION_CXBX 0x7863 // 'cx' Cxbx vertex shader, not an official value, used in VshConvertShader() and VshWriteShader()
|
||||||
|
|
||||||
#define DbgVshPrintf \
|
#define DbgVshPrintf \
|
||||||
|
@ -1744,8 +1746,8 @@ class XboxVertexDeclarationConverter
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
// Internal variables
|
// Internal variables
|
||||||
XTL::CxbxVertexShaderInfo* pVertexShaderInfoToSet;
|
CxbxVertexShaderInfo* pVertexShaderInfoToSet;
|
||||||
XTL::CxbxVertexShaderStreamInfo* pCurrentVertexShaderStreamInfo = nullptr;
|
CxbxVertexShaderStreamInfo* pCurrentVertexShaderStreamInfo = nullptr;
|
||||||
DWORD temporaryCount;
|
DWORD temporaryCount;
|
||||||
bool IsFixedFunction;
|
bool IsFixedFunction;
|
||||||
XTL::D3DVERTEXELEMENT* pRecompiled;
|
XTL::D3DVERTEXELEMENT* pRecompiled;
|
||||||
|
@ -2154,7 +2156,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
// save patching information
|
// save patching information
|
||||||
XTL::CxbxVertexShaderStreamElement *pCurrentElement = &(pCurrentVertexShaderStreamInfo->VertexElements[pCurrentVertexShaderStreamInfo->NumberOfVertexElements]);
|
CxbxVertexShaderStreamElement *pCurrentElement = &(pCurrentVertexShaderStreamInfo->VertexElements[pCurrentVertexShaderStreamInfo->NumberOfVertexElements]);
|
||||||
pCurrentElement->XboxType = XboxVertexElementDataType;
|
pCurrentElement->XboxType = XboxVertexElementDataType;
|
||||||
pCurrentElement->HostByteSize = HostVertexElementByteSize;
|
pCurrentElement->HostByteSize = HostVertexElementByteSize;
|
||||||
pCurrentVertexShaderStreamInfo->NumberOfVertexElements++;
|
pCurrentVertexShaderStreamInfo->NumberOfVertexElements++;
|
||||||
|
@ -2278,7 +2280,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
XTL::D3DVERTEXELEMENT *Convert(DWORD* pXboxDeclaration, bool bIsFixedFunction, XTL::CxbxVertexShaderInfo* pCxbxVertexShaderInfo)
|
XTL::D3DVERTEXELEMENT *Convert(DWORD* pXboxDeclaration, bool bIsFixedFunction, CxbxVertexShaderInfo* pCxbxVertexShaderInfo)
|
||||||
{
|
{
|
||||||
using namespace XTL;
|
using namespace XTL;
|
||||||
|
|
||||||
|
@ -2342,7 +2344,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
XTL::D3DVERTEXELEMENT *XTL::EmuRecompileVshDeclaration
|
XTL::D3DVERTEXELEMENT *EmuRecompileVshDeclaration
|
||||||
(
|
(
|
||||||
DWORD *pXboxDeclaration,
|
DWORD *pXboxDeclaration,
|
||||||
bool bIsFixedFunction,
|
bool bIsFixedFunction,
|
||||||
|
@ -2362,16 +2364,18 @@ XTL::D3DVERTEXELEMENT *XTL::EmuRecompileVshDeclaration
|
||||||
}
|
}
|
||||||
|
|
||||||
// recompile xbox vertex shader function
|
// recompile xbox vertex shader function
|
||||||
extern HRESULT XTL::EmuRecompileVshFunction
|
extern HRESULT EmuRecompileVshFunction
|
||||||
(
|
(
|
||||||
DWORD *pXboxFunction,
|
DWORD *pXboxFunction,
|
||||||
bool bNoReservedConstants,
|
bool bNoReservedConstants,
|
||||||
D3DVERTEXELEMENT *pRecompiledDeclaration,
|
XTL::D3DVERTEXELEMENT *pRecompiledDeclaration,
|
||||||
bool *pbUseDeclarationOnly,
|
bool *pbUseDeclarationOnly,
|
||||||
DWORD *pXboxFunctionSize,
|
DWORD *pXboxFunctionSize,
|
||||||
LPD3DXBUFFER *ppRecompiledShader
|
XTL::LPD3DXBUFFER *ppRecompiledShader
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
using namespace XTL;
|
||||||
|
|
||||||
X_VSH_SHADER_HEADER *pXboxVertexShaderHeader = (X_VSH_SHADER_HEADER*)pXboxFunction;
|
X_VSH_SHADER_HEADER *pXboxVertexShaderHeader = (X_VSH_SHADER_HEADER*)pXboxFunction;
|
||||||
DWORD *pToken;
|
DWORD *pToken;
|
||||||
boolean EOI = false;
|
boolean EOI = false;
|
||||||
|
@ -2498,7 +2502,7 @@ extern HRESULT XTL::EmuRecompileVshFunction
|
||||||
return hRet;
|
return hRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void XTL::FreeVertexDynamicPatch(CxbxVertexShader *pVertexShader)
|
extern void FreeVertexDynamicPatch(CxbxVertexShader *pVertexShader)
|
||||||
{
|
{
|
||||||
pVertexShader->VertexShaderInfo.NumberOfVertexStreams = 0;
|
pVertexShader->VertexShaderInfo.NumberOfVertexStreams = 0;
|
||||||
}
|
}
|
||||||
|
@ -2509,7 +2513,7 @@ boolean VshHandleIsValidShader(DWORD XboxVertexShaderHandle)
|
||||||
#if 0
|
#if 0
|
||||||
//printf( "VS = 0x%.08X\n", XboxVertexShaderHandle );
|
//printf( "VS = 0x%.08X\n", XboxVertexShaderHandle );
|
||||||
|
|
||||||
XTL::CxbxVertexShader *pCxbxVertexShader = XTL::GetCxbxVertexShader(XboxVertexShaderHandle);
|
CxbxVertexShader *pCxbxVertexShader = GetCxbxVertexShader(XboxVertexShaderHandle);
|
||||||
if (pCxbxVertexShader) {
|
if (pCxbxVertexShader) {
|
||||||
if (pCxbxVertexShader->XboxStatus != 0)
|
if (pCxbxVertexShader->XboxStatus != 0)
|
||||||
{
|
{
|
||||||
|
@ -2531,16 +2535,16 @@ boolean VshHandleIsValidShader(DWORD XboxVertexShaderHandle)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern boolean XTL::IsValidCurrentShader(void)
|
extern boolean IsValidCurrentShader(void)
|
||||||
{
|
{
|
||||||
// Dxbx addition : There's no need to call
|
// Dxbx addition : There's no need to call
|
||||||
// XTL_EmuIDirect3DDevice_GetVertexShader, just check g_CurrentXboxVertexShaderHandle :
|
// XTL_EmuIDirect3DDevice_GetVertexShader, just check g_CurrentXboxVertexShaderHandle :
|
||||||
return VshHandleIsValidShader(g_CurrentXboxVertexShaderHandle);
|
return VshHandleIsValidShader(g_CurrentXboxVertexShaderHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
XTL::CxbxVertexShaderInfo *GetCxbxVertexShaderInfo(DWORD XboxVertexShaderHandle)
|
CxbxVertexShaderInfo *GetCxbxVertexShaderInfo(DWORD XboxVertexShaderHandle)
|
||||||
{
|
{
|
||||||
XTL::CxbxVertexShader *pCxbxVertexShader = XTL::GetCxbxVertexShader(XboxVertexShaderHandle);
|
CxbxVertexShader *pCxbxVertexShader = GetCxbxVertexShader(XboxVertexShaderHandle);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < pCxbxVertexShader->VertexShaderInfo.NumberOfVertexStreams; i++)
|
for (uint32_t i = 0; i < pCxbxVertexShader->VertexShaderInfo.NumberOfVertexStreams; i++)
|
||||||
{
|
{
|
||||||
|
@ -2552,9 +2556,9 @@ XTL::CxbxVertexShaderInfo *GetCxbxVertexShaderInfo(DWORD XboxVertexShaderHandle)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unordered_map<DWORD, XTL::CxbxVertexShader*> g_CxbxVertexShaders;
|
std::unordered_map<DWORD, CxbxVertexShader*> g_CxbxVertexShaders;
|
||||||
|
|
||||||
XTL::CxbxVertexShader* XTL::GetCxbxVertexShader(DWORD XboxVertexShaderHandle)
|
CxbxVertexShader* GetCxbxVertexShader(DWORD XboxVertexShaderHandle)
|
||||||
{
|
{
|
||||||
if (VshHandleIsVertexShader(XboxVertexShaderHandle)) {
|
if (VshHandleIsVertexShader(XboxVertexShaderHandle)) {
|
||||||
auto it = g_CxbxVertexShaders.find(XboxVertexShaderHandle);
|
auto it = g_CxbxVertexShaders.find(XboxVertexShaderHandle);
|
||||||
|
@ -2566,7 +2570,7 @@ XTL::CxbxVertexShader* XTL::GetCxbxVertexShader(DWORD XboxVertexShaderHandle)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XTL::SetCxbxVertexShader(DWORD XboxVertexShaderHandle, XTL::CxbxVertexShader* shader)
|
void SetCxbxVertexShader(DWORD XboxVertexShaderHandle, CxbxVertexShader* shader)
|
||||||
{
|
{
|
||||||
auto it = g_CxbxVertexShaders.find(XboxVertexShaderHandle);
|
auto it = g_CxbxVertexShaders.find(XboxVertexShaderHandle);
|
||||||
if (it != g_CxbxVertexShaders.end() && it->second != nullptr && shader != nullptr) {
|
if (it != g_CxbxVertexShaders.end() && it->second != nullptr && shader != nullptr) {
|
||||||
|
|
|
@ -25,16 +25,86 @@
|
||||||
#ifndef XBVERTEXSHADER_H
|
#ifndef XBVERTEXSHADER_H
|
||||||
#define XBVERTEXSHADER_H
|
#define XBVERTEXSHADER_H
|
||||||
|
|
||||||
#include "Cxbx.h"
|
//#include "Cxbx.h"
|
||||||
|
//#include "core\hle\D3D8\XbVertexBuffer.h" // for CxbxVertexShaderStreamInfo
|
||||||
|
namespace XTL {
|
||||||
|
#include "core\hle\D3D8\XbD3D8Types.h" // for X_VSH_MAX_ATTRIBUTES
|
||||||
|
}
|
||||||
|
|
||||||
|
// Host vertex shader counts
|
||||||
|
#define VSH_MAX_TEMPORARY_REGISTERS 32
|
||||||
|
#define VSH_MAX_INTERMEDIATE_COUNT 1024 // The maximum number of intermediate format slots
|
||||||
|
#define VSH_VS11_MAX_INSTRUCTION_COUNT 128
|
||||||
|
#define VSH_VS2X_MAX_INSTRUCTION_COUNT 256
|
||||||
|
#define VSH_VS30_MAX_INSTRUCTION_COUNT 512
|
||||||
|
|
||||||
|
typedef struct _CxbxVertexShaderStreamElement
|
||||||
|
{
|
||||||
|
UINT XboxType; // The stream element data types (xbox)
|
||||||
|
UINT HostByteSize; // The stream element data sizes (pc)
|
||||||
|
}
|
||||||
|
CxbxVertexShaderStreamElement;
|
||||||
|
|
||||||
|
/* See host typedef struct _D3DVERTEXELEMENT9
|
||||||
|
{
|
||||||
|
WORD Stream; // Stream index
|
||||||
|
WORD Offset; // Offset in the stream in bytes
|
||||||
|
BYTE Type; // Data type
|
||||||
|
BYTE Method; // Processing method
|
||||||
|
BYTE Usage; // Semantics
|
||||||
|
BYTE UsageIndex; // Semantic index
|
||||||
|
} D3DVERTEXELEMENT9, *LPD3DVERTEXELEMENT9;
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct _CxbxVertexShaderStreamInfo
|
||||||
|
{
|
||||||
|
BOOL NeedPatch; // This is to know whether it's data which must be patched
|
||||||
|
BOOL DeclPosition;
|
||||||
|
WORD HostVertexStride;
|
||||||
|
DWORD NumberOfVertexElements; // Number of the stream data types
|
||||||
|
WORD CurrentStreamNumber;
|
||||||
|
CxbxVertexShaderStreamElement VertexElements[X_VSH_MAX_ATTRIBUTES + 16]; // TODO : Why 16 extrahost additions?)
|
||||||
|
}
|
||||||
|
CxbxVertexShaderStreamInfo;
|
||||||
|
|
||||||
|
typedef struct _CxbxVertexShaderInfo
|
||||||
|
{
|
||||||
|
UINT NumberOfVertexStreams; // The number of streams the vertex shader uses
|
||||||
|
CxbxVertexShaderStreamInfo VertexStreams[X_VSH_MAX_STREAMS];
|
||||||
|
}
|
||||||
|
CxbxVertexShaderInfo;
|
||||||
|
|
||||||
|
typedef struct _CxbxVertexShader
|
||||||
|
{
|
||||||
|
// These are the parameters given by the XBE,
|
||||||
|
// we save them to be able to return them when necessary.
|
||||||
|
DWORD* pXboxDeclarationCopy;
|
||||||
|
DWORD XboxDeclarationCount; // Xbox's number of DWORD-sized X_D3DVSD* tokens
|
||||||
|
DWORD XboxFunctionSize;
|
||||||
|
DWORD* pXboxFunctionCopy;
|
||||||
|
UINT XboxNrAddressSlots;
|
||||||
|
DWORD XboxVertexShaderType;
|
||||||
|
// DWORD XboxStatus; // Used by VshHandleIsValidShader()
|
||||||
|
|
||||||
|
// The resulting host variables
|
||||||
|
DWORD HostFVF; // Flexible Vertex Format (used when there's no host vertex shader)
|
||||||
|
XTL::IDirect3DVertexShader* pHostVertexShader; // if nullptr, use SetFVF(HostFVF);
|
||||||
|
XTL::IDirect3DVertexDeclaration* pHostVertexDeclaration;
|
||||||
|
DWORD HostDeclarationSize;
|
||||||
|
|
||||||
|
// Needed for dynamic stream patching
|
||||||
|
CxbxVertexShaderInfo VertexShaderInfo;
|
||||||
|
}
|
||||||
|
CxbxVertexShader;
|
||||||
|
|
||||||
// recompile xbox vertex shader declaration
|
// recompile xbox vertex shader declaration
|
||||||
extern D3DVERTEXELEMENT *EmuRecompileVshDeclaration
|
extern XTL::D3DVERTEXELEMENT *EmuRecompileVshDeclaration
|
||||||
(
|
(
|
||||||
DWORD *pXboxDeclaration,
|
DWORD *pXboxDeclaration,
|
||||||
bool bIsFixedFunction,
|
bool bIsFixedFunction,
|
||||||
DWORD *pXboxDeclarationCount,
|
DWORD *pXboxDeclarationCount,
|
||||||
DWORD *pHostDeclarationSize,
|
DWORD *pHostDeclarationSize,
|
||||||
XTL::CxbxVertexShaderInfo *pCxbxVertexShaderInfo
|
CxbxVertexShaderInfo *pCxbxVertexShaderInfo
|
||||||
);
|
);
|
||||||
|
|
||||||
// recompile xbox vertex shader function
|
// recompile xbox vertex shader function
|
||||||
|
@ -42,10 +112,10 @@ extern HRESULT EmuRecompileVshFunction
|
||||||
(
|
(
|
||||||
DWORD *pXboxFunction,
|
DWORD *pXboxFunction,
|
||||||
bool bNoReservedConstants,
|
bool bNoReservedConstants,
|
||||||
D3DVERTEXELEMENT *pRecompiledDeclaration,
|
XTL::D3DVERTEXELEMENT *pRecompiledDeclaration,
|
||||||
bool *pbUseDeclarationOnly,
|
bool *pbUseDeclarationOnly,
|
||||||
DWORD *pXboxFunctionSize,
|
DWORD *pXboxFunctionSize,
|
||||||
LPD3DXBUFFER *ppRecompiledShader
|
XTL::LPD3DXBUFFER *ppRecompiledShader
|
||||||
);
|
);
|
||||||
|
|
||||||
extern void FreeVertexDynamicPatch(CxbxVertexShader *pVertexShader);
|
extern void FreeVertexDynamicPatch(CxbxVertexShader *pVertexShader);
|
||||||
|
@ -55,7 +125,7 @@ extern boolean IsValidCurrentShader(void);
|
||||||
|
|
||||||
inline boolean VshHandleIsVertexShader(DWORD Handle) { return (Handle & X_D3DFVF_RESERVED0) ? TRUE : FALSE; }
|
inline boolean VshHandleIsVertexShader(DWORD Handle) { return (Handle & X_D3DFVF_RESERVED0) ? TRUE : FALSE; }
|
||||||
inline boolean VshHandleIsFVF(DWORD Handle) { return !VshHandleIsVertexShader(Handle); }
|
inline boolean VshHandleIsFVF(DWORD Handle) { return !VshHandleIsVertexShader(Handle); }
|
||||||
inline X_D3DVertexShader *VshHandleToXboxVertexShader(DWORD Handle) { return (X_D3DVertexShader *)(Handle & ~X_D3DFVF_RESERVED0);}
|
inline XTL::X_D3DVertexShader *VshHandleToXboxVertexShader(DWORD Handle) { return (XTL::X_D3DVertexShader *)(Handle & ~X_D3DFVF_RESERVED0);}
|
||||||
|
|
||||||
extern CxbxVertexShader* GetCxbxVertexShader(DWORD XboxVertexShaderHandle);
|
extern CxbxVertexShader* GetCxbxVertexShader(DWORD XboxVertexShaderHandle);
|
||||||
extern void SetCxbxVertexShader(DWORD XboxVertexShaderHandle, CxbxVertexShader* shader);
|
extern void SetCxbxVertexShader(DWORD XboxVertexShaderHandle, CxbxVertexShader* shader);
|
||||||
|
|
|
@ -34,10 +34,12 @@
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iomanip> // For std::setfill and std::setw
|
#include <iomanip> // For std::setfill and std::setw
|
||||||
|
|
||||||
#include "core\kernel\init\CxbxKrnl.h"
|
#include "core\kernel\init\CxbxKrnl.h"
|
||||||
#include "core\kernel\support\Emu.h"
|
#include "core\kernel\support\Emu.h"
|
||||||
#include "core\kernel\support\EmuFS.h"
|
#include "core\kernel\support\EmuFS.h"
|
||||||
#include "core\kernel\support\EmuXTL.h"
|
#include "core\kernel\support\EmuXTL.h"
|
||||||
|
#include "core\hle\D3D8\XbState.h" // For EmuD3DDeferredTextureState
|
||||||
#include "EmuShared.h"
|
#include "EmuShared.h"
|
||||||
#include "common\CxbxDebugger.h"
|
#include "common\CxbxDebugger.h"
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
|
@ -46,6 +48,7 @@
|
||||||
#include "Intercept.hpp"
|
#include "Intercept.hpp"
|
||||||
#include "Patches.hpp"
|
#include "Patches.hpp"
|
||||||
#include "common\util\hasher.h"
|
#include "common\util\hasher.h"
|
||||||
|
|
||||||
#include <Shlwapi.h>
|
#include <Shlwapi.h>
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
@ -292,11 +295,11 @@ void CDECL EmuRegisterSymbol(const char* library_str,
|
||||||
void EmuD3D_Init_DeferredStates()
|
void EmuD3D_Init_DeferredStates()
|
||||||
{
|
{
|
||||||
if (g_SymbolAddresses.find("D3DDeferredRenderState") != g_SymbolAddresses.end()) {
|
if (g_SymbolAddresses.find("D3DDeferredRenderState") != g_SymbolAddresses.end()) {
|
||||||
XTL::EmuD3DDeferredRenderState = (DWORD*)g_SymbolAddresses["D3DDeferredRenderState"];
|
EmuD3DDeferredRenderState = (DWORD*)g_SymbolAddresses["D3DDeferredRenderState"];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_SymbolAddresses.find("D3DDeferredTextureState") != g_SymbolAddresses.end()) {
|
if (g_SymbolAddresses.find("D3DDeferredTextureState") != g_SymbolAddresses.end()) {
|
||||||
XTL::EmuD3DDeferredTextureState = (DWORD*)g_SymbolAddresses["D3DDeferredTextureState"];
|
EmuD3DDeferredTextureState = (DWORD*)g_SymbolAddresses["D3DDeferredTextureState"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,7 @@ typedef struct DUMMY_KERNEL
|
||||||
IMAGE_SECTION_HEADER SectionHeader;
|
IMAGE_SECTION_HEADER SectionHeader;
|
||||||
} *PDUMMY_KERNEL;
|
} *PDUMMY_KERNEL;
|
||||||
|
|
||||||
|
typedef WORD INDEX16;
|
||||||
|
|
||||||
extern bool g_DisablePixelShaders;
|
extern bool g_DisablePixelShaders;
|
||||||
extern bool g_UseAllCores;
|
extern bool g_UseAllCores;
|
||||||
|
|
|
@ -32,12 +32,6 @@ namespace XTL
|
||||||
{
|
{
|
||||||
#include "core\hle\XAPI\Xapi.h"
|
#include "core\hle\XAPI\Xapi.h"
|
||||||
#include "core\hle\D3D8\Direct3D9/Direct3D9.h"
|
#include "core\hle\D3D8\Direct3D9/Direct3D9.h"
|
||||||
#include "core\hle\D3D8\XbConvert.h"
|
|
||||||
#include "core\hle\D3D8\XbVertexBuffer.h"
|
|
||||||
#include "core\hle\D3D8\XbPushBuffer.h"
|
|
||||||
#include "core\hle\D3D8\XbVertexShader.h"
|
|
||||||
#include "core\hle\D3D8\XbPixelShader.h"
|
|
||||||
#include "core\hle\D3D8\XbState.h"
|
|
||||||
#include "core\hle\DSOUND\DirectSound\DirectSound.hpp"
|
#include "core\hle\DSOUND\DirectSound\DirectSound.hpp"
|
||||||
#include "core\hle\XONLINE\XOnline.h"
|
#include "core\hle\XONLINE\XOnline.h"
|
||||||
#include "core\hle\XGRAPHIC\XGraphic.h"
|
#include "core\hle\XGRAPHIC\XGraphic.h"
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include "common\xbe\XbePrinter.h" // For DumpInformation
|
#include "common\xbe\XbePrinter.h" // For DumpInformation
|
||||||
#include "EmuShared.h"
|
#include "EmuShared.h"
|
||||||
#include "core\kernel\support\EmuXTL.h"
|
#include "core\kernel\support\EmuXTL.h"
|
||||||
|
#include "core\hle\D3D8\XbConvert.h" // For EmuPC2XB_D3DFormat
|
||||||
#include "common\Settings.hpp"
|
#include "common\Settings.hpp"
|
||||||
|
|
||||||
#include "core\kernel\init\CxbxKrnl.h" // For CxbxConvertArgToString and CxbxExec
|
#include "core\kernel\init\CxbxKrnl.h" // For CxbxConvertArgToString and CxbxExec
|
||||||
|
@ -1513,7 +1514,7 @@ void WndMain::LoadGameLogo()
|
||||||
(XTL::UINT)pDDSHeader->dwWidth,
|
(XTL::UINT)pDDSHeader->dwWidth,
|
||||||
(XTL::UINT)pDDSHeader->dwHeight,
|
(XTL::UINT)pDDSHeader->dwHeight,
|
||||||
1,
|
1,
|
||||||
XTL::EmuPC2XB_D3DFormat(Format),
|
EmuPC2XB_D3DFormat(Format),
|
||||||
2,
|
2,
|
||||||
(XTL::UINT)pDDSHeader->dwPitchOrLinearSize);
|
(XTL::UINT)pDDSHeader->dwPitchOrLinearSize);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue