d3d9: Show error when default shaders fail.

This commit is contained in:
Unknown W. Brackets 2014-09-26 08:40:55 -07:00
parent 265094f614
commit b97af10a6d
3 changed files with 26 additions and 14 deletions

View File

@ -139,22 +139,25 @@ bool CompileVertexShader(const char *code, LPDIRECT3DVERTEXSHADER9 *pShader, LPD
return true;
}
void CompileShaders() {
std::string errorMsg;
bool CompileShaders(std::string &errorMsg) {
if (!CompileVertexShader(vscode, &pFramebufferVertexShader, NULL, errorMsg)) {
OutputDebugStringA(errorMsg.c_str());
DebugBreak();
return false;
}
if (!CompilePixelShader(pscode, &pFramebufferPixelShader, NULL, errorMsg)) {
OutputDebugStringA(errorMsg.c_str());
DebugBreak();
if (pFramebufferVertexShader) {
pFramebufferVertexShader->Release();
}
return false;
}
pD3Ddevice->CreateVertexDeclaration(VertexElements, &pFramebufferVertexDecl);
pD3Ddevice->SetVertexDeclaration(pFramebufferVertexDecl);
pD3Ddevice->CreateVertexDeclaration(SoftTransVertexElements, &pSoftVertexDecl);
return true;
}
void DestroyShaders() {
@ -207,7 +210,8 @@ void DirectxInit(HWND window) {
pD3Ddevice->SetRingBufferParameters( &d3dr );
#endif
CompileShaders();
std::string errorMessage;
CompileShaders(errorMessage);
fbo_init(pD3D);
}

View File

@ -25,7 +25,7 @@ extern LPDIRECT3DPIXELSHADER9 pFramebufferPixelShader; // Pixel Shader
extern IDirect3DVertexDeclaration9* pFramebufferVertexDecl;
extern IDirect3DVertexDeclaration9* pSoftVertexDecl;
void CompileShaders();
bool CompileShaders(std::string &errorMessage);
bool CompilePixelShader(const char *code, LPDIRECT3DPIXELSHADER9 *pShader, ID3DXConstantTable **pShaderTable, std::string &errorMessage);
bool CompileVertexShader(const char *code, LPDIRECT3DVERTEXSHADER9 *pShader, ID3DXConstantTable **pShaderTable, std::string &errorMessage);
void DestroyShaders();

View File

@ -153,11 +153,7 @@ bool D3D9_Init(HWND hWnd, bool windowed, std::string *error_message) {
if (FAILED(hr)) {
*error_message = "Failed to create D3D device";
if (has9Ex) {
d3dEx->Release();
} else {
d3d->Release();
}
return false;
}
@ -167,7 +163,18 @@ bool D3D9_Init(HWND hWnd, bool windowed, std::string *error_message) {
LoadD3DX9Dynamic();
DX9::CompileShaders();
if (!DX9::CompileShaders(*error_message)) {
*error_message = "Unable to compile shaders: " + *error_message;
device->EndScene();
device->Release();
d3d->Release();
DX9::pD3Ddevice = nullptr;
DX9::pD3DdeviceEx = nullptr;
device = nullptr;
UnloadD3DXDynamic();
return false;
}
DX9::fbo_init(d3d);
if (deviceEx && IsWin7OrLater()) {
@ -188,6 +195,7 @@ void D3D9_Shutdown() {
device->EndScene();
device->Release();
d3d->Release();
UnloadD3DXDynamic();
DX9::pD3Ddevice = nullptr;
DX9::pD3DdeviceEx = nullptr;
device = nullptr;