mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-28 10:51:06 +00:00
d3d: Reduce D3DX leaks.
This commit is contained in:
parent
780ed765c7
commit
4d54cad9bd
@ -47,6 +47,8 @@ PSShader::PSShader(const char *code, bool useHWTransform) : failed_(false), useH
|
||||
|
||||
if (!success) {
|
||||
failed_ = true;
|
||||
if (shader)
|
||||
shader->Release();
|
||||
shader = NULL;
|
||||
} else {
|
||||
DEBUG_LOG(G3D, "Compiled shader:\n%s\n", (const char *)code);
|
||||
@ -55,6 +57,8 @@ PSShader::PSShader(const char *code, bool useHWTransform) : failed_(false), useH
|
||||
|
||||
PSShader::~PSShader() {
|
||||
pD3Ddevice->SetPixelShader(NULL);
|
||||
if (constant)
|
||||
constant->Release();
|
||||
if (shader)
|
||||
shader->Release();
|
||||
}
|
||||
@ -70,6 +74,8 @@ VSShader::VSShader(const char *code, bool useHWTransform) : failed_(false), useH
|
||||
|
||||
if (!success) {
|
||||
failed_ = true;
|
||||
if (shader)
|
||||
shader->Release();
|
||||
shader = NULL;
|
||||
} else {
|
||||
DEBUG_LOG(G3D, "Compiled shader:\n%s\n", (const char *)code);
|
||||
@ -78,6 +84,8 @@ VSShader::VSShader(const char *code, bool useHWTransform) : failed_(false), useH
|
||||
|
||||
VSShader::~VSShader() {
|
||||
pD3Ddevice->SetVertexShader(NULL);
|
||||
if (constant)
|
||||
constant->Release();
|
||||
if (shader)
|
||||
shader->Release();
|
||||
}
|
||||
|
@ -66,8 +66,6 @@ LPDIRECT3DVERTEXSHADER9 pFramebufferVertexShader = NULL; // Vertex Shader
|
||||
LPDIRECT3DPIXELSHADER9 pFramebufferPixelShader = NULL; // Pixel Shader
|
||||
|
||||
bool CompilePixelShader(const char * code, LPDIRECT3DPIXELSHADER9 * pShader, LPD3DXCONSTANTTABLE * pShaderTable) {
|
||||
LPD3DXCONSTANTTABLE shaderTable = *pShaderTable;
|
||||
|
||||
ID3DXBuffer* pShaderCode = NULL;
|
||||
ID3DXBuffer* pErrorMsg = NULL;
|
||||
|
||||
@ -85,9 +83,12 @@ bool CompilePixelShader(const char * code, LPDIRECT3DPIXELSHADER9 * pShader, LPD
|
||||
&pErrorMsg,
|
||||
pShaderTable);
|
||||
|
||||
if( FAILED(hr) )
|
||||
{
|
||||
if (pErrorMsg) {
|
||||
OutputDebugStringA((CHAR*)pErrorMsg->GetBufferPointer());
|
||||
pErrorMsg->Release();
|
||||
}
|
||||
|
||||
if (FAILED(hr)) {
|
||||
DebugBreak();
|
||||
return false;
|
||||
}
|
||||
@ -102,8 +103,6 @@ bool CompilePixelShader(const char * code, LPDIRECT3DPIXELSHADER9 * pShader, LPD
|
||||
}
|
||||
|
||||
bool CompileVertexShader(const char * code, LPDIRECT3DVERTEXSHADER9 * pShader, LPD3DXCONSTANTTABLE * pShaderTable) {
|
||||
LPD3DXCONSTANTTABLE shaderTable = *pShaderTable;
|
||||
|
||||
ID3DXBuffer* pShaderCode = NULL;
|
||||
ID3DXBuffer* pErrorMsg = NULL;
|
||||
|
||||
@ -121,9 +120,12 @@ bool CompileVertexShader(const char * code, LPDIRECT3DVERTEXSHADER9 * pShader, L
|
||||
&pErrorMsg,
|
||||
pShaderTable);
|
||||
|
||||
if( FAILED(hr) )
|
||||
{
|
||||
if (pErrorMsg) {
|
||||
OutputDebugStringA((CHAR*)pErrorMsg->GetBufferPointer());
|
||||
pErrorMsg->Release();
|
||||
}
|
||||
|
||||
if (FAILED(hr)) {
|
||||
DebugBreak();
|
||||
return false;
|
||||
}
|
||||
@ -154,9 +156,12 @@ void CompileShaders() {
|
||||
&pErrorMsg,
|
||||
NULL);
|
||||
|
||||
if( FAILED(hr) )
|
||||
{
|
||||
if (pErrorMsg) {
|
||||
OutputDebugStringA((CHAR*)pErrorMsg->GetBufferPointer());
|
||||
pErrorMsg->Release();
|
||||
}
|
||||
|
||||
if (FAILED(hr)) {
|
||||
DebugBreak();
|
||||
}
|
||||
|
||||
@ -165,6 +170,10 @@ void CompileShaders() {
|
||||
&pFramebufferVertexShader );
|
||||
|
||||
pShaderCode->Release();
|
||||
if (pErrorMsg) {
|
||||
OutputDebugStringA((CHAR*)pErrorMsg->GetBufferPointer());
|
||||
pErrorMsg->Release();
|
||||
}
|
||||
|
||||
// Compile pixel shader.
|
||||
hr = dyn_D3DXCompileShader(pscode,
|
||||
@ -178,9 +187,12 @@ void CompileShaders() {
|
||||
&pErrorMsg,
|
||||
NULL);
|
||||
|
||||
if( FAILED(hr) )
|
||||
{
|
||||
if (pErrorMsg) {
|
||||
OutputDebugStringA((CHAR*)pErrorMsg->GetBufferPointer());
|
||||
pErrorMsg->Release();
|
||||
}
|
||||
|
||||
if (FAILED(hr)) {
|
||||
DebugBreak();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user