Skip to content
Permalink
Browse files

Merge pull request #1791 from PatrickvL/hash_palete_in_texture_key

Speed up paletized texture
  • Loading branch information
LukeUsher committed Dec 2, 2019
2 parents 6706830 + b76f4c5 commit 63bc65ece211a70a8e4b94931020bb948d7b966d

Large diffs are not rendered by default.

@@ -3867,3 +3867,57 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_GetLight)
HRESULT hRet = g_pD3DDevice->GetLight(Index, pLight);
DEBUG_D3DRESULT(hRet, "g_pD3DDevice->GetLight");
}

// ******************************************************************
// * patch: IDirect3DPalette8_Lock
// ******************************************************************
VOID WINAPI XTL::EMUPATCH(D3DPalette_Lock)
(
X_D3DPalette *pThis,
D3DCOLOR **ppColors,
DWORD Flags
)
{
LOG_FUNC_BEGIN
LOG_FUNC_ARG(pThis)
LOG_FUNC_ARG_OUT(ppColors)
LOG_FUNC_ARG(Flags)
LOG_FUNC_END;

XB_trampoline(VOID, WINAPI, D3DPalette_Lock, (X_D3DPalette*, D3DCOLOR**, DWORD));
XB_D3DPalette_Lock(pThis, ppColors, Flags);

// Check if this palette is in use by a texture stage, and force it to be re-converted if yes
for (int i = 0; i < XTL::X_D3DTS_STAGECOUNT; i++) {
if (g_pXbox_Texture[i] != nullptr && g_pXbox_Palette[i] == GetDataFromXboxResource(pThis)) {
FreeHostResource(GetHostResourceKey(g_pXbox_Texture[i]));
}
}
}

// ******************************************************************
// * patch: IDirect3DPalette8_Lock2
// ******************************************************************
D3DCOLOR * WINAPI XTL::EMUPATCH(D3DPalette_Lock2)
(
X_D3DPalette *pThis,
DWORD Flags
)
{
LOG_FUNC_BEGIN
LOG_FUNC_ARG(pThis)
LOG_FUNC_ARG(Flags)
LOG_FUNC_END;

XB_trampoline(D3DCOLOR*, WINAPI, D3DPalette_Lock2, (X_D3DPalette*, DWORD));
D3DCOLOR* pData = XB_D3DPalette_Lock2(pThis, Flags);

// Check if this palette is in use by a texture stage, and force it to be re-converted if yes
for (int i = 0; i < XTL::X_D3DTS_STAGECOUNT; i++) {
if (g_pXbox_Texture[i] != nullptr && g_pXbox_Palette[i] == GetDataFromXboxResource(pThis)) {
FreeHostResource(GetHostResourceKey(g_pXbox_Texture[i]));
}
}

RETURN(pData);
}
@@ -67,8 +67,7 @@ extern DWORD g_Xbox_VertexShader_Handle;

extern XTL::X_PixelShader *g_pXbox_PixelShader;

// EmuD3DActiveTexture
extern XTL::X_D3DBaseTexture *EmuD3DActiveTexture[XTL::X_D3DTS_STAGECOUNT];
extern XTL::X_D3DBaseTexture *g_pXbox_SetTexture[XTL::X_D3DTS_STAGECOUNT];

namespace XTL {

@@ -444,7 +444,7 @@ struct X_D3DResource
#define X_D3DCOMMON_INTREFCOUNT_MASK 0x00780000
#define X_D3DCOMMON_INTREFCOUNT_SHIFT 19
#define X_D3DCOMMON_INTREFCOUNT_1 (1 << X_D3DCOMMON_INTREFCOUNT_SHIFT) // Dxbx addition
#define X_D3DCOMMON_VIDEOMEMORY 0x00800000 // Not used.
#define X_D3DCOMMON_VIDEOMEMORY 0x00000000 // Was 0x00800000, but Xbox doesn't have this flag!
#define X_D3DCOMMON_D3DCREATED 0x01000000
#define X_D3DCOMMON_ISLOCKED 0x02000010 // Surface is currently locked (potential unswizzle candidate)
#define X_D3DCOMMON_UNUSED_MASK 0xFE000000
@@ -2922,7 +2922,7 @@ bool PSH_XBOX_SHADER::InsertTextureModeInstruction(XTL::X_D3DPIXELSHADERDEF *pPS
// and include the texture formats in the shader hash, somehow.
bool bias = false;
auto biasModifier = (1 << ARGMOD_SCALE_BX2);
auto pXboxTexture = EmuD3DActiveTexture[inputStage];
auto pXboxTexture = g_pXbox_SetTexture[inputStage];
if (pXboxTexture != nullptr) {
extern XTL::X_D3DFORMAT GetXboxPixelContainerFormat(const XTL::X_D3DPixelContainer *pXboxPixelContainer); // TODO : Move to XTL-independent header file

@@ -240,7 +240,7 @@ void CxbxVertexBufferConverter::ConvertStream
if (i + 1 <= dwTexN) {
pActivePixelContainer[i].NrTexCoords = DxbxFVF_GetNumberOfTextureCoordinates(XboxFVF, i);
// TODO : Use GetXboxBaseTexture()
XTL::X_D3DBaseTexture *pXboxBaseTexture = EmuD3DActiveTexture[i];
XTL::X_D3DBaseTexture *pXboxBaseTexture = g_pXbox_SetTexture[i];
if (pXboxBaseTexture != xbnullptr) {
extern XTL::X_D3DFORMAT GetXboxPixelContainerFormat(const XTL::X_D3DPixelContainer *pXboxPixelContainer); // TODO : Move to XTL-independent header file

@@ -175,8 +175,6 @@ std::map<const std::string, const xbox_patch_t> g_PatchTable = {
PATCH_ENTRY("D3DDevice_Swap_0", XTL::EMUPATCH(D3DDevice_Swap_0), PATCH_HLE_D3D),
PATCH_ENTRY("D3DDevice_SwitchTexture", XTL::EMUPATCH(D3DDevice_SwitchTexture), PATCH_HLE_D3D),
PATCH_ENTRY("D3DDevice_UpdateOverlay", XTL::EMUPATCH(D3DDevice_UpdateOverlay), PATCH_HLE_D3D),
PATCH_ENTRY("D3DPalette_Lock", XTL::EMUPATCH(D3DPalette_Lock), PATCH_HLE_D3D),
PATCH_ENTRY("D3DPalette_Lock2", XTL::EMUPATCH(D3DPalette_Lock2), PATCH_HLE_D3D),
PATCH_ENTRY("D3DResource_BlockUntilNotBusy", XTL::EMUPATCH(D3DResource_BlockUntilNotBusy), PATCH_HLE_D3D),
PATCH_ENTRY("D3D_BlockOnTime", XTL::EMUPATCH(D3D_BlockOnTime), PATCH_HLE_D3D),
PATCH_ENTRY("D3D_DestroyResource", XTL::EMUPATCH(D3D_DestroyResource), PATCH_HLE_D3D),

0 comments on commit 63bc65e

Please sign in to comment.
You can’t perform that action at this time.