Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CreateVertexShader to fix missing textures #27

Merged
merged 7 commits into from
Jul 2, 2017
23 changes: 11 additions & 12 deletions source/d3d8to9_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::CopyRects(Direct3DSurface8 *pSourceSu
}
else
{
hr = E_FAIL;
hr = D3DERR_INVALIDCALL;
}
}
else if (SourceDesc.Pool == D3DPOOL_DEFAULT)
Expand Down Expand Up @@ -806,6 +806,7 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::SetRenderState(D3DRENDERSTATETYPE Sta
case D3DRS_ZBIAS:
Biased = static_cast<FLOAT>(Value) * -0.000005f;
Value = *reinterpret_cast<const DWORD *>(&Biased);
State = D3DRS_DEPTHBIAS;
default:
return ProxyInterface->SetRenderState(State, Value);
}
Expand Down Expand Up @@ -1248,7 +1249,7 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::CreateVertexShader(const DWORD *pDecl
LOG << "> Failed because token type '" << TokenType << "' is not supported!" << std::endl;
#endif

return E_NOTIMPL;
return D3DERR_INVALIDCALL;
}

++pDeclaration;
Expand Down Expand Up @@ -1283,7 +1284,7 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::CreateVertexShader(const DWORD *pDecl
}
else
{
hr = E_FAIL;
hr = D3DERR_INVALIDCALL;
}

if (FAILED(hr))
Expand Down Expand Up @@ -1352,8 +1353,6 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::CreateVertexShader(const DWORD *pDecl
}

#pragma region Fill registers with default value
ConstantsCode += " def c95, 0, 0, 0, 0\n";

SourceCode.insert(DeclPosition, ConstantsCode);

for (size_t j = 0; j < 2; j++)
Expand All @@ -1362,7 +1361,7 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::CreateVertexShader(const DWORD *pDecl

if (SourceCode.find(reg) != std::string::npos)
{
SourceCode.insert(DeclPosition + ConstantsCode.size(), " mov " + reg + ", c95 /* initialize output register " + reg + " */\n");
SourceCode.insert(DeclPosition + ConstantsCode.size(), " mov " + reg + ", c0 /* initialize output register " + reg + " */\n");
}
}
for (size_t j = 0; j < 8; j++)
Expand All @@ -1371,7 +1370,7 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::CreateVertexShader(const DWORD *pDecl

if (SourceCode.find(reg) != std::string::npos)
{
SourceCode.insert(DeclPosition + ConstantsCode.size(), " mov " + reg + ", c95 /* initialize output register " + reg + " */\n");
SourceCode.insert(DeclPosition + ConstantsCode.size(), " mov " + reg + ", c0 /* initialize output register " + reg + " */\n");
}
}
for (size_t j = 0; j < 12; j++)
Expand All @@ -1380,7 +1379,7 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::CreateVertexShader(const DWORD *pDecl

if (SourceCode.find(reg) != std::string::npos)
{
SourceCode.insert(DeclPosition + ConstantsCode.size(), " mov " + reg + ", c95 /* initialize register " + reg + " */\n");
SourceCode.insert(DeclPosition + ConstantsCode.size(), " mov " + reg + ", c0 /* initialize register " + reg + " */\n");
}
}
#pragma endregion
Expand All @@ -1401,7 +1400,7 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::CreateVertexShader(const DWORD *pDecl
}
else
{
hr = E_FAIL;
hr = D3DERR_INVALIDCALL;
}

Disassembly->Release();
Expand Down Expand Up @@ -1567,7 +1566,7 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::GetVertexShaderDeclaration(DWORD Hand
LOG << "> 'IDirect3DDevice8::GetVertexShaderDeclaration' is not implemented!" << std::endl;
#endif

return E_NOTIMPL;
return D3DERR_INVALIDCALL;
}
HRESULT STDMETHODCALLTYPE Direct3DDevice8::GetVertexShaderFunction(DWORD Handle, void *pData, DWORD *pSizeOfData)
{
Expand Down Expand Up @@ -1700,7 +1699,7 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::CreatePixelShader(const DWORD *pFunct

ID3DXBuffer *Disassembly = nullptr, *Assembly = nullptr, *ErrorBuffer = nullptr;

HRESULT hr = E_FAIL;
HRESULT hr = D3DERR_INVALIDCALL;

if (D3DXDisassembleShader != nullptr)
{
Expand Down Expand Up @@ -1744,7 +1743,7 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::CreatePixelShader(const DWORD *pFunct
}
else
{
hr = E_FAIL;
hr = D3DERR_INVALIDCALL;
}

Disassembly->Release();
Expand Down