mirror of
https://github.com/libretro/ppsspp.git
synced 2025-04-02 03:32:01 +00:00
d3d9: Try harder to get a shader compile error.
This commit is contained in:
parent
0039eab878
commit
32fc4c7676
@ -98,5 +98,6 @@ extern "C" {
|
||||
// Call directly after the command or use the error num.
|
||||
// This function might change the error code.
|
||||
// Defined in Misc.cpp.
|
||||
const char* GetLastErrorMsg();
|
||||
const char *GetLastErrorMsg();
|
||||
const char *GetStringErrorMsg(int errCode);
|
||||
|
||||
|
@ -30,25 +30,37 @@
|
||||
// Generic function to get last error message.
|
||||
// Call directly after the command or use the error num.
|
||||
// This function might change the error code.
|
||||
const char* GetLastErrorMsg()
|
||||
const char *GetLastErrorMsg()
|
||||
{
|
||||
#ifndef _XBOX
|
||||
#ifdef _WIN32
|
||||
return GetStringErrorMsg(GetLastError());
|
||||
#else
|
||||
return GetStringErrorMsg(errno);
|
||||
#endif
|
||||
#else
|
||||
return "GetLastErrorMsg";
|
||||
#endif
|
||||
}
|
||||
|
||||
const char *GetStringErrorMsg(int errCode) {
|
||||
static const size_t buff_size = 255;
|
||||
#ifndef _XBOX
|
||||
#ifdef _WIN32
|
||||
static __declspec(thread) char err_str[buff_size] = {};
|
||||
|
||||
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
|
||||
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errCode,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
err_str, buff_size, NULL);
|
||||
#else
|
||||
static __thread char err_str[buff_size] = {};
|
||||
|
||||
// Thread safe (XSI-compliant)
|
||||
strerror_r(errno, err_str, buff_size);
|
||||
strerror_r(errCode, err_str, buff_size);
|
||||
#endif
|
||||
|
||||
return err_str;
|
||||
#else
|
||||
return "GetLastErrorMsg";
|
||||
return "GetStringErrorMsg";
|
||||
#endif
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "global.h"
|
||||
#include "fbo.h"
|
||||
#include "thin3d/d3dx9_loader.h"
|
||||
#include "Common/CommonFuncs.h"
|
||||
|
||||
namespace DX9 {
|
||||
|
||||
@ -60,16 +61,14 @@ LPDIRECT3DVERTEXSHADER9 pFramebufferVertexShader = NULL; // Vertex Shader
|
||||
LPDIRECT3DPIXELSHADER9 pFramebufferPixelShader = NULL; // Pixel Shader
|
||||
|
||||
bool CompilePixelShader(const char *code, LPDIRECT3DPIXELSHADER9 *pShader, LPD3DXCONSTANTTABLE *pShaderTable, std::string &errorMessage) {
|
||||
ID3DXBuffer* pShaderCode = NULL;
|
||||
ID3DXBuffer* pErrorMsg = NULL;
|
||||
|
||||
HRESULT hr = E_FAIL;
|
||||
ID3DXBuffer *pShaderCode = nullptr;
|
||||
ID3DXBuffer *pErrorMsg = nullptr;
|
||||
|
||||
// Compile pixel shader.
|
||||
hr = dyn_D3DXCompileShader(code,
|
||||
HRESULT hr = dyn_D3DXCompileShader(code,
|
||||
(UINT)strlen(code),
|
||||
NULL,
|
||||
NULL,
|
||||
nullptr,
|
||||
nullptr,
|
||||
"main",
|
||||
"ps_2_0",
|
||||
0,
|
||||
@ -80,11 +79,13 @@ bool CompilePixelShader(const char *code, LPDIRECT3DPIXELSHADER9 *pShader, LPD3D
|
||||
if (pErrorMsg) {
|
||||
errorMessage = (CHAR *)pErrorMsg->GetBufferPointer();
|
||||
pErrorMsg->Release();
|
||||
} else if (FAILED(hr)) {
|
||||
errorMessage = GetStringErrorMsg(hr);
|
||||
} else {
|
||||
errorMessage = "";
|
||||
}
|
||||
|
||||
if (FAILED(hr)) {
|
||||
if (FAILED(hr) || !pShaderCode) {
|
||||
if (pShaderCode)
|
||||
pShaderCode->Release();
|
||||
return false;
|
||||
@ -100,16 +101,14 @@ bool CompilePixelShader(const char *code, LPDIRECT3DPIXELSHADER9 *pShader, LPD3D
|
||||
}
|
||||
|
||||
bool CompileVertexShader(const char *code, LPDIRECT3DVERTEXSHADER9 *pShader, LPD3DXCONSTANTTABLE *pShaderTable, std::string &errorMessage) {
|
||||
ID3DXBuffer* pShaderCode = NULL;
|
||||
ID3DXBuffer* pErrorMsg = NULL;
|
||||
|
||||
HRESULT hr = E_FAIL;
|
||||
ID3DXBuffer *pShaderCode = nullptr;
|
||||
ID3DXBuffer *pErrorMsg = nullptr;
|
||||
|
||||
// Compile pixel shader.
|
||||
hr = dyn_D3DXCompileShader(code,
|
||||
HRESULT hr = dyn_D3DXCompileShader(code,
|
||||
(UINT)strlen(code),
|
||||
NULL,
|
||||
NULL,
|
||||
nullptr,
|
||||
nullptr,
|
||||
"main",
|
||||
"vs_2_0",
|
||||
0,
|
||||
@ -120,11 +119,13 @@ bool CompileVertexShader(const char *code, LPDIRECT3DVERTEXSHADER9 *pShader, LPD
|
||||
if (pErrorMsg) {
|
||||
errorMessage = (CHAR *)pErrorMsg->GetBufferPointer();
|
||||
pErrorMsg->Release();
|
||||
} else if (FAILED(hr)) {
|
||||
errorMessage = GetStringErrorMsg(hr);
|
||||
} else {
|
||||
errorMessage = "";
|
||||
}
|
||||
|
||||
if (FAILED(hr)) {
|
||||
if (FAILED(hr) || !pShaderCode) {
|
||||
if (pShaderCode)
|
||||
pShaderCode->Release();
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user