mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
d3d: Release vertex decls on shutdown.
This commit is contained in:
parent
564ae9f184
commit
34b1d13c29
2 changed files with 17 additions and 13 deletions
|
@ -177,6 +177,10 @@ TransformDrawEngineDX9::~TransformDrawEngineDX9() {
|
||||||
FreeMemoryPages(transformed, TRANSFORMED_VERTEX_BUFFER_SIZE);
|
FreeMemoryPages(transformed, TRANSFORMED_VERTEX_BUFFER_SIZE);
|
||||||
FreeMemoryPages(transformedExpanded, 3 * TRANSFORMED_VERTEX_BUFFER_SIZE);
|
FreeMemoryPages(transformedExpanded, 3 * TRANSFORMED_VERTEX_BUFFER_SIZE);
|
||||||
|
|
||||||
|
for (auto decl = vertexDeclMap_.begin(); decl != vertexDeclMap_.end(); ++decl) {
|
||||||
|
decl->second->Release();
|
||||||
|
}
|
||||||
|
|
||||||
delete [] quadIndices_;
|
delete [] quadIndices_;
|
||||||
|
|
||||||
for (auto iter = decoderMap_.begin(); iter != decoderMap_.end(); iter++) {
|
for (auto iter = decoderMap_.begin(); iter != decoderMap_.end(); iter++) {
|
||||||
|
@ -229,10 +233,6 @@ static void VertexAttribSetup(D3DVERTEXELEMENT9 * VertexElement, u8 fmt, u8 offs
|
||||||
VertexElement->UsageIndex = usage_index;
|
VertexElement->UsageIndex = usage_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
static IDirect3DVertexDeclaration9* pHardwareVertexDecl = NULL;
|
|
||||||
static std::map<u32, IDirect3DVertexDeclaration9 *> vertexDeclMap;
|
|
||||||
static D3DVERTEXELEMENT9 VertexElements[8];
|
|
||||||
|
|
||||||
// TODO: Use VBO and get rid of the vertexData pointers - with that, we will supply only offsets
|
// TODO: Use VBO and get rid of the vertexData pointers - with that, we will supply only offsets
|
||||||
static void LogDecFmtForDraw(const DecVtxFormat &decFmt) {
|
static void LogDecFmtForDraw(const DecVtxFormat &decFmt) {
|
||||||
// Vertices Elements orders
|
// Vertices Elements orders
|
||||||
|
@ -269,12 +269,12 @@ static void LogDecFmtForDraw(const DecVtxFormat &decFmt) {
|
||||||
//pD3Ddevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);
|
//pD3Ddevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetupDecFmtForDraw(LinkedShaderDX9 *program, const DecVtxFormat &decFmt, u32 pspFmt) {
|
IDirect3DVertexDeclaration9 *TransformDrawEngineDX9::SetupDecFmtForDraw(LinkedShaderDX9 *program, const DecVtxFormat &decFmt, u32 pspFmt) {
|
||||||
auto vertexDeclCached = vertexDeclMap.find(pspFmt);
|
auto vertexDeclCached = vertexDeclMap_.find(pspFmt);
|
||||||
|
|
||||||
if (vertexDeclCached==vertexDeclMap.end()) {
|
if (vertexDeclCached == vertexDeclMap_.end()) {
|
||||||
D3DVERTEXELEMENT9 * VertexElement = &VertexElements[0];
|
D3DVERTEXELEMENT9 VertexElements[8];
|
||||||
int offset = 0;
|
D3DVERTEXELEMENT9 *VertexElement = &VertexElements[0];
|
||||||
|
|
||||||
// Vertices Elements orders
|
// Vertices Elements orders
|
||||||
// WEIGHT
|
// WEIGHT
|
||||||
|
@ -320,7 +320,8 @@ static void SetupDecFmtForDraw(LinkedShaderDX9 *program, const DecVtxFormat &dec
|
||||||
D3DVERTEXELEMENT9 end = D3DDECL_END();
|
D3DVERTEXELEMENT9 end = D3DDECL_END();
|
||||||
memcpy(VertexElement, &end, sizeof(D3DVERTEXELEMENT9));
|
memcpy(VertexElement, &end, sizeof(D3DVERTEXELEMENT9));
|
||||||
|
|
||||||
// Create declaration
|
// Create declaration
|
||||||
|
IDirect3DVertexDeclaration9 *pHardwareVertexDecl;
|
||||||
HRESULT hr = pD3Ddevice->CreateVertexDeclaration( VertexElements, &pHardwareVertexDecl );
|
HRESULT hr = pD3Ddevice->CreateVertexDeclaration( VertexElements, &pHardwareVertexDecl );
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
// Log
|
// Log
|
||||||
|
@ -329,10 +330,11 @@ static void SetupDecFmtForDraw(LinkedShaderDX9 *program, const DecVtxFormat &dec
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add it to map
|
// Add it to map
|
||||||
vertexDeclMap[pspFmt] = pHardwareVertexDecl;
|
vertexDeclMap_[pspFmt] = pHardwareVertexDecl;
|
||||||
|
return pHardwareVertexDecl;
|
||||||
} else {
|
} else {
|
||||||
// Set it from map
|
// Set it from map
|
||||||
pHardwareVertexDecl = vertexDeclCached->second;
|
return vertexDeclCached->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1218,7 +1220,7 @@ rotateVBO:
|
||||||
|
|
||||||
DEBUG_LOG(G3D, "Flush prim %i! %i verts in one go", prim, vertexCount);
|
DEBUG_LOG(G3D, "Flush prim %i! %i verts in one go", prim, vertexCount);
|
||||||
|
|
||||||
SetupDecFmtForDraw(program, dec_->GetDecVtxFmt(), dec_->VertexType());
|
IDirect3DVertexDeclaration9 *pHardwareVertexDecl = SetupDecFmtForDraw(program, dec_->GetDecVtxFmt(), dec_->VertexType());
|
||||||
|
|
||||||
if (pHardwareVertexDecl) {
|
if (pHardwareVertexDecl) {
|
||||||
pD3Ddevice->SetVertexDeclaration(pHardwareVertexDecl);
|
pD3Ddevice->SetVertexDeclaration(pHardwareVertexDecl);
|
||||||
|
|
|
@ -142,6 +142,7 @@ private:
|
||||||
void SoftwareTransformAndDraw(int prim, u8 *decoded, LinkedShaderDX9 *program, int vertexCount, u32 vertexType, void *inds, int indexType, const DecVtxFormat &decVtxFormat, int maxIndex);
|
void SoftwareTransformAndDraw(int prim, u8 *decoded, LinkedShaderDX9 *program, int vertexCount, u32 vertexType, void *inds, int indexType, const DecVtxFormat &decVtxFormat, int maxIndex);
|
||||||
void ApplyDrawState(int prim);
|
void ApplyDrawState(int prim);
|
||||||
bool IsReallyAClear(int numVerts) const;
|
bool IsReallyAClear(int numVerts) const;
|
||||||
|
IDirect3DVertexDeclaration9 *SetupDecFmtForDraw(LinkedShaderDX9 *program, const DecVtxFormat &decFmt, u32 pspFmt);
|
||||||
|
|
||||||
// Preprocessing for spline/bezier
|
// Preprocessing for spline/bezier
|
||||||
u32 NormalizeVertices(u8 *outPtr, u8 *bufPtr, const u8 *inPtr, VertexDecoderDX9 *dec, int lowerBound, int upperBound, u32 vertType);
|
u32 NormalizeVertices(u8 *outPtr, u8 *bufPtr, const u8 *inPtr, VertexDecoderDX9 *dec, int lowerBound, int upperBound, u32 vertType);
|
||||||
|
@ -184,6 +185,7 @@ private:
|
||||||
TransformedVertex *transformedExpanded;
|
TransformedVertex *transformedExpanded;
|
||||||
|
|
||||||
std::map<u32, VertexArrayInfoDX9 *> vai_;
|
std::map<u32, VertexArrayInfoDX9 *> vai_;
|
||||||
|
std::map<u32, IDirect3DVertexDeclaration9 *> vertexDeclMap_;
|
||||||
|
|
||||||
// Fixed index buffer for easy quad generation from spline/bezier
|
// Fixed index buffer for easy quad generation from spline/bezier
|
||||||
u16 *quadIndices_;
|
u16 *quadIndices_;
|
||||||
|
|
Loading…
Add table
Reference in a new issue