2009-07-28 21:32:10 +00:00
|
|
|
// Copyright (C) 2003 Dolphin Project.
|
2008-12-08 05:25:12 +00:00
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
|
|
|
|
|
|
|
#include "Common.h"
|
2009-09-02 07:25:22 +00:00
|
|
|
#include "FileUtil.h"
|
2008-12-08 05:25:12 +00:00
|
|
|
|
|
|
|
#include "D3DBase.h"
|
2010-06-29 14:40:37 +00:00
|
|
|
#include "Fifo.h"
|
2008-12-08 05:25:12 +00:00
|
|
|
#include "Statistics.h"
|
|
|
|
#include "VertexManager.h"
|
|
|
|
#include "OpcodeDecoding.h"
|
|
|
|
#include "IndexGenerator.h"
|
2008-12-25 15:56:36 +00:00
|
|
|
#include "VertexShaderManager.h"
|
2008-12-26 19:39:12 +00:00
|
|
|
#include "VertexShaderCache.h"
|
2008-12-25 15:56:36 +00:00
|
|
|
#include "PixelShaderManager.h"
|
2008-12-26 19:39:12 +00:00
|
|
|
#include "PixelShaderCache.h"
|
2009-02-28 22:10:38 +00:00
|
|
|
#include "NativeVertexFormat.h"
|
2009-03-07 18:05:29 +00:00
|
|
|
#include "TextureCache.h"
|
2010-08-04 21:02:32 +00:00
|
|
|
#include "main.h"
|
2009-02-28 22:10:38 +00:00
|
|
|
|
2009-06-22 09:31:30 +00:00
|
|
|
#include "BPStructs.h"
|
2009-02-28 22:10:38 +00:00
|
|
|
#include "XFStructs.h"
|
2010-12-05 14:15:36 +00:00
|
|
|
#include "Debugger.h"
|
|
|
|
#include "VideoConfig.h"
|
2009-09-02 06:33:41 +00:00
|
|
|
|
2009-02-28 22:10:38 +00:00
|
|
|
// internal state for loading vertices
|
|
|
|
extern NativeVertexFormat *g_nativeVertexFmt;
|
2010-10-03 00:41:06 +00:00
|
|
|
namespace DX9
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2012-10-22 22:37:26 +00:00
|
|
|
//This are the initially requeted size for the buffers expresed in elements
|
|
|
|
const u32 IBUFFER_SIZE = VertexManager::MAXIBUFFERSIZE * 16;
|
|
|
|
const u32 VBUFFER_SIZE = VertexManager::MAXVBUFFERSIZE * 16;
|
|
|
|
const u32 MAXVBUFFER_COUNT = 2;
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-11-01 02:03:26 +00:00
|
|
|
inline void DumpBadShaders()
|
|
|
|
{
|
|
|
|
#if defined(_DEBUG) || defined(DEBUGFAST)
|
2010-12-05 14:15:36 +00:00
|
|
|
// TODO: Reimplement!
|
|
|
|
/* std::string error_shaders;
|
2009-11-01 02:03:26 +00:00
|
|
|
error_shaders.append(VertexShaderCache::GetCurrentShaderCode());
|
|
|
|
error_shaders.append(PixelShaderCache::GetCurrentShaderCode());
|
|
|
|
char filename[512] = "bad_shader_combo_0.txt";
|
|
|
|
int which = 0;
|
|
|
|
while (File::Exists(filename))
|
|
|
|
{
|
|
|
|
which++;
|
|
|
|
sprintf(filename, "bad_shader_combo_%i.txt", which);
|
|
|
|
}
|
|
|
|
File::WriteStringToFile(true, error_shaders, filename);
|
2010-12-05 14:15:36 +00:00
|
|
|
PanicAlert("DrawIndexedPrimitiveUP failed. Shaders written to %s", filename);*/
|
2009-11-01 02:03:26 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-10-20 13:22:15 +00:00
|
|
|
void VertexManager::CreateDeviceObjects()
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2012-10-20 13:22:15 +00:00
|
|
|
NumVBuffers = 0;
|
2012-10-22 22:37:26 +00:00
|
|
|
VBuffers = NULL;
|
|
|
|
IBuffers = NULL;
|
2012-10-20 13:22:15 +00:00
|
|
|
D3DCAPS9 DeviceCaps = D3D::GetCaps();
|
2012-10-22 22:37:26 +00:00
|
|
|
u32 devicevMaxBufferSize = DeviceCaps.MaxPrimitiveCount * 3 * DeviceCaps.MaxStreamStride;
|
|
|
|
//Calculate Device Dependant size
|
|
|
|
CurrentVBufferSize = (VBUFFER_SIZE > devicevMaxBufferSize) ? devicevMaxBufferSize : VBUFFER_SIZE;
|
|
|
|
CurrentIBufferSize = (IBUFFER_SIZE > DeviceCaps.MaxVertexIndex) ? DeviceCaps.MaxVertexIndex : IBUFFER_SIZE;
|
|
|
|
//if device caps are not enough for Vbuffer fall back to vertex arrays
|
|
|
|
if (CurrentIBufferSize < MAXIBUFFERSIZE || CurrentVBufferSize < MAXVBUFFERSIZE) return;
|
|
|
|
|
|
|
|
VBuffers = new LPDIRECT3DVERTEXBUFFER9[MAXVBUFFER_COUNT];
|
|
|
|
IBuffers = new LPDIRECT3DINDEXBUFFER9[MAXVBUFFER_COUNT];
|
|
|
|
|
2012-10-20 13:22:15 +00:00
|
|
|
bool Fail = false;
|
2012-10-22 22:37:26 +00:00
|
|
|
for (CurrentVBuffer = 0; CurrentVBuffer < MAXVBUFFER_COUNT; CurrentVBuffer++)
|
2012-10-20 13:22:15 +00:00
|
|
|
{
|
|
|
|
VBuffers[CurrentVBuffer] = NULL;
|
|
|
|
IBuffers[CurrentVBuffer] = NULL;
|
|
|
|
}
|
2012-10-22 22:37:26 +00:00
|
|
|
for (CurrentVBuffer = 0; CurrentVBuffer < MAXVBUFFER_COUNT; CurrentVBuffer++)
|
2012-10-20 13:22:15 +00:00
|
|
|
{
|
|
|
|
if(FAILED( D3D::dev->CreateVertexBuffer( CurrentVBufferSize, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &VBuffers[CurrentVBuffer], NULL ) ) )
|
2009-11-01 02:03:26 +00:00
|
|
|
{
|
2012-10-20 13:22:15 +00:00
|
|
|
Fail = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if( FAILED( D3D::dev->CreateIndexBuffer( CurrentIBufferSize * sizeof(u16), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFMT_INDEX16, D3DPOOL_DEFAULT, &IBuffers[CurrentVBuffer], NULL ) ) )
|
|
|
|
{
|
|
|
|
Fail = true;
|
|
|
|
return;
|
2009-11-01 02:03:26 +00:00
|
|
|
}
|
2009-10-02 14:03:07 +00:00
|
|
|
}
|
2012-10-20 13:22:15 +00:00
|
|
|
NumVBuffers = CurrentVBuffer;
|
|
|
|
CurrentVBuffer = 0;
|
|
|
|
CurrentIBuffer = 0;
|
2012-10-22 22:37:26 +00:00
|
|
|
CurrentIBufferIndex = CurrentIBufferSize;
|
|
|
|
CurrentVBufferIndex = CurrentVBufferSize;
|
|
|
|
|
2012-10-20 13:22:15 +00:00
|
|
|
if (Fail)
|
2009-10-02 14:03:07 +00:00
|
|
|
{
|
2012-10-20 13:22:15 +00:00
|
|
|
NumVBuffers--;
|
|
|
|
if (NumVBuffers < 2)
|
2009-11-01 02:03:26 +00:00
|
|
|
{
|
2012-10-22 22:37:26 +00:00
|
|
|
//Error creating Vertex buffers. clean and fall to Vertex arrays
|
|
|
|
NumVBuffers = MAXVBUFFER_COUNT;
|
2012-10-20 13:22:15 +00:00
|
|
|
DestroyDeviceObjects();
|
|
|
|
}
|
2012-10-22 22:37:26 +00:00
|
|
|
}
|
2012-10-20 13:22:15 +00:00
|
|
|
}
|
|
|
|
void VertexManager::DestroyDeviceObjects()
|
|
|
|
{
|
|
|
|
D3D::dev->SetStreamSource( 0, NULL, 0, 0);
|
|
|
|
D3D::dev->SetIndices(NULL);
|
2012-10-22 22:37:26 +00:00
|
|
|
for (int i = 0; i < MAXVBUFFER_COUNT; i++)
|
2012-10-20 13:22:15 +00:00
|
|
|
{
|
|
|
|
if(VBuffers)
|
|
|
|
{
|
|
|
|
if (VBuffers[i])
|
|
|
|
{
|
|
|
|
VBuffers[i]->Release();
|
|
|
|
VBuffers[i] = NULL;
|
|
|
|
}
|
2009-11-01 02:03:26 +00:00
|
|
|
}
|
2012-10-20 13:22:15 +00:00
|
|
|
|
|
|
|
if (IBuffers[i])
|
|
|
|
{
|
|
|
|
IBuffers[i]->Release();
|
|
|
|
IBuffers[i] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(VBuffers)
|
|
|
|
delete [] VBuffers;
|
|
|
|
if(IBuffers)
|
|
|
|
delete [] IBuffers;
|
|
|
|
VBuffers = NULL;
|
|
|
|
IBuffers = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VertexManager::PrepareVBuffers(int stride)
|
|
|
|
{
|
|
|
|
if (!NumVBuffers)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
u8* pVertices;
|
|
|
|
u16* pIndices;
|
|
|
|
int datasize = IndexGenerator::GetNumVerts() * stride;
|
|
|
|
int TdataSize = IndexGenerator::GetTriangleindexLen();
|
|
|
|
int LDataSize = IndexGenerator::GetLineindexLen();
|
|
|
|
int PDataSize = IndexGenerator::GetPointindexLen();
|
|
|
|
int IndexDataSize = TdataSize + LDataSize + PDataSize;
|
|
|
|
DWORD LockMode = D3DLOCK_NOOVERWRITE;
|
|
|
|
|
2012-10-22 22:37:26 +00:00
|
|
|
if (CurrentVBufferIndex > CurrentVBufferSize - datasize)
|
2012-10-20 13:22:15 +00:00
|
|
|
{
|
|
|
|
LockMode = D3DLOCK_DISCARD;
|
|
|
|
CurrentVBufferIndex = 0;
|
|
|
|
CurrentVBuffer = (CurrentVBuffer + 1) % NumVBuffers;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(FAILED(VBuffers[CurrentVBuffer]->Lock(CurrentVBufferIndex, datasize,(VOID**)(&pVertices), LockMode)))
|
|
|
|
{
|
|
|
|
DestroyDeviceObjects();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
memcpy(pVertices, LocalVBuffer, datasize);
|
|
|
|
VBuffers[CurrentVBuffer]->Unlock();
|
|
|
|
|
|
|
|
LockMode = D3DLOCK_NOOVERWRITE;
|
|
|
|
|
2012-10-22 22:37:26 +00:00
|
|
|
if (CurrentIBufferIndex > CurrentIBufferSize - IndexDataSize)
|
2012-10-20 13:22:15 +00:00
|
|
|
{
|
|
|
|
LockMode = D3DLOCK_DISCARD;
|
|
|
|
CurrentIBufferIndex = 0;
|
|
|
|
CurrentIBuffer = (CurrentIBuffer + 1) % NumVBuffers;
|
2009-09-19 13:14:55 +00:00
|
|
|
}
|
2012-10-20 13:22:15 +00:00
|
|
|
|
|
|
|
if(FAILED(IBuffers[CurrentIBuffer]->Lock(CurrentIBufferIndex * sizeof(u16), IndexDataSize * sizeof(u16), (VOID**)(&pIndices), LockMode )))
|
2009-09-19 13:14:55 +00:00
|
|
|
{
|
2012-10-20 13:22:15 +00:00
|
|
|
DestroyDeviceObjects();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(TdataSize)
|
|
|
|
{
|
|
|
|
memcpy(pIndices, TIBuffer, TdataSize * sizeof(u16));
|
|
|
|
pIndices += TdataSize;
|
|
|
|
}
|
|
|
|
if(LDataSize)
|
|
|
|
{
|
|
|
|
memcpy(pIndices, LIBuffer, LDataSize * sizeof(u16));
|
|
|
|
pIndices += LDataSize;
|
|
|
|
}
|
|
|
|
if(PDataSize)
|
|
|
|
{
|
|
|
|
memcpy(pIndices, PIBuffer, PDataSize * sizeof(u16));
|
|
|
|
}
|
|
|
|
IBuffers[CurrentIBuffer]->Unlock();
|
2012-10-22 22:37:26 +00:00
|
|
|
D3D::dev->SetStreamSource( 0, VBuffers[CurrentVBuffer], CurrentVBufferIndex, stride);
|
|
|
|
if(CurrentIBufferIndex == 0)
|
|
|
|
{
|
|
|
|
D3D::dev->SetIndices(IBuffers[CurrentIBuffer]);
|
|
|
|
}
|
2012-10-20 13:22:15 +00:00
|
|
|
}
|
|
|
|
|
2012-10-22 22:37:26 +00:00
|
|
|
void VertexManager::DrawVB(int stride)
|
2012-10-20 13:22:15 +00:00
|
|
|
{
|
2012-10-22 22:37:26 +00:00
|
|
|
if (IndexGenerator::GetNumTriangles() > 0)
|
2012-10-20 13:22:15 +00:00
|
|
|
{
|
2012-10-22 22:37:26 +00:00
|
|
|
if (FAILED(D3D::dev->DrawIndexedPrimitive(
|
|
|
|
D3DPT_TRIANGLELIST,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
IndexGenerator::GetNumVerts(),
|
|
|
|
CurrentIBufferIndex,
|
|
|
|
IndexGenerator::GetNumTriangles())))
|
2012-10-20 13:22:15 +00:00
|
|
|
{
|
2012-10-22 22:37:26 +00:00
|
|
|
DumpBadShaders();
|
2012-10-20 13:22:15 +00:00
|
|
|
}
|
2012-10-22 22:37:26 +00:00
|
|
|
INCSTAT(stats.thisFrame.numIndexedDrawCalls);
|
|
|
|
}
|
|
|
|
if (IndexGenerator::GetNumLines() > 0)
|
|
|
|
{
|
|
|
|
if (FAILED(D3D::dev->DrawIndexedPrimitive(
|
|
|
|
D3DPT_LINELIST,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
IndexGenerator::GetNumVerts(),
|
|
|
|
CurrentIBufferIndex + IndexGenerator::GetTriangleindexLen(),
|
|
|
|
IndexGenerator::GetNumLines())))
|
2012-10-20 13:22:15 +00:00
|
|
|
{
|
2012-10-22 22:37:26 +00:00
|
|
|
DumpBadShaders();
|
2012-10-20 13:22:15 +00:00
|
|
|
}
|
2012-10-22 22:37:26 +00:00
|
|
|
INCSTAT(stats.thisFrame.numIndexedDrawCalls);
|
|
|
|
}
|
|
|
|
if (IndexGenerator::GetNumPoints() > 0)
|
|
|
|
{
|
|
|
|
if (FAILED(D3D::dev->DrawIndexedPrimitive(
|
|
|
|
D3DPT_POINTLIST,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
IndexGenerator::GetNumVerts(),
|
|
|
|
CurrentIBufferIndex + IndexGenerator::GetTriangleindexLen() + IndexGenerator::GetLineindexLen(),
|
|
|
|
IndexGenerator::GetNumPoints())))
|
2012-10-20 13:22:15 +00:00
|
|
|
{
|
2012-10-22 22:37:26 +00:00
|
|
|
DumpBadShaders();
|
2012-10-20 13:22:15 +00:00
|
|
|
}
|
2012-10-22 22:37:26 +00:00
|
|
|
INCSTAT(stats.thisFrame.numIndexedDrawCalls);
|
2012-10-20 13:22:15 +00:00
|
|
|
}
|
2012-10-22 22:37:26 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void VertexManager::DrawVA(int stride)
|
|
|
|
{
|
|
|
|
if (IndexGenerator::GetNumTriangles() > 0)
|
2012-10-20 13:22:15 +00:00
|
|
|
{
|
2012-10-22 22:37:26 +00:00
|
|
|
if (FAILED(D3D::dev->DrawIndexedPrimitiveUP(
|
|
|
|
D3DPT_TRIANGLELIST,
|
|
|
|
0, IndexGenerator::GetNumVerts(), IndexGenerator::GetNumTriangles(),
|
|
|
|
TIBuffer,
|
|
|
|
D3DFMT_INDEX16,
|
|
|
|
LocalVBuffer,
|
|
|
|
stride)))
|
2012-10-20 13:22:15 +00:00
|
|
|
{
|
2012-10-22 22:37:26 +00:00
|
|
|
DumpBadShaders();
|
2012-10-20 13:22:15 +00:00
|
|
|
}
|
2012-10-22 22:37:26 +00:00
|
|
|
INCSTAT(stats.thisFrame.numIndexedDrawCalls);
|
|
|
|
}
|
|
|
|
if (IndexGenerator::GetNumLines() > 0)
|
|
|
|
{
|
|
|
|
if (FAILED(D3D::dev->DrawIndexedPrimitiveUP(
|
|
|
|
D3DPT_LINELIST,
|
|
|
|
0, IndexGenerator::GetNumVerts(), IndexGenerator::GetNumLines(),
|
|
|
|
LIBuffer,
|
|
|
|
D3DFMT_INDEX16,
|
|
|
|
LocalVBuffer,
|
|
|
|
stride)))
|
2009-11-01 02:03:26 +00:00
|
|
|
{
|
2012-10-22 22:37:26 +00:00
|
|
|
DumpBadShaders();
|
2012-10-20 13:22:15 +00:00
|
|
|
}
|
2012-10-22 22:37:26 +00:00
|
|
|
INCSTAT(stats.thisFrame.numIndexedDrawCalls);
|
|
|
|
}
|
|
|
|
if (IndexGenerator::GetNumPoints() > 0)
|
|
|
|
{
|
|
|
|
if (FAILED(D3D::dev->DrawIndexedPrimitiveUP(
|
|
|
|
D3DPT_POINTLIST,
|
|
|
|
0, IndexGenerator::GetNumVerts(), IndexGenerator::GetNumPoints(),
|
|
|
|
PIBuffer,
|
|
|
|
D3DFMT_INDEX16,
|
|
|
|
LocalVBuffer,
|
|
|
|
stride)))
|
2012-10-20 13:22:15 +00:00
|
|
|
{
|
2012-10-22 22:37:26 +00:00
|
|
|
DumpBadShaders();
|
2009-11-01 02:03:26 +00:00
|
|
|
}
|
2012-10-22 22:37:26 +00:00
|
|
|
INCSTAT(stats.thisFrame.numIndexedDrawCalls);
|
|
|
|
}
|
2009-09-19 13:14:55 +00:00
|
|
|
}
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2010-10-03 00:41:06 +00:00
|
|
|
void VertexManager::vFlush()
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2010-06-05 01:38:22 +00:00
|
|
|
if (LocalVBuffer == s_pCurBufferPointer) return;
|
2010-09-28 02:15:02 +00:00
|
|
|
if (Flushed) return;
|
2010-10-03 00:41:06 +00:00
|
|
|
Flushed = true;
|
2010-06-29 14:40:37 +00:00
|
|
|
VideoFifo_CheckEFBAccess();
|
2010-09-28 02:15:02 +00:00
|
|
|
|
2009-10-06 14:24:10 +00:00
|
|
|
u32 usedtextures = 0;
|
2010-09-28 02:15:02 +00:00
|
|
|
for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages + 1; ++i)
|
|
|
|
if (bpmem.tevorders[i / 2].getEnable(i & 1))
|
2009-10-06 14:24:10 +00:00
|
|
|
usedtextures |= 1 << bpmem.tevorders[i/2].getTexMap(i & 1);
|
2009-03-07 18:05:29 +00:00
|
|
|
|
2010-09-28 02:15:02 +00:00
|
|
|
if (bpmem.genMode.numindstages > 0)
|
|
|
|
for (unsigned int i = 0; i < bpmem.genMode.numtevstages + 1; ++i)
|
|
|
|
if (bpmem.tevind[i].IsActive() && bpmem.tevind[i].bt < bpmem.genMode.numindstages)
|
2009-10-06 14:24:10 +00:00
|
|
|
usedtextures |= 1 << bpmem.tevindref.getTexMap(bpmem.tevind[i].bt);
|
2009-03-07 18:05:29 +00:00
|
|
|
|
2010-09-28 02:15:02 +00:00
|
|
|
for (unsigned int i = 0; i < 8; i++)
|
2009-10-06 14:24:10 +00:00
|
|
|
{
|
2010-09-28 02:15:02 +00:00
|
|
|
if (usedtextures & (1 << i))
|
|
|
|
{
|
2010-11-18 02:21:26 +00:00
|
|
|
g_renderer->SetSamplerState(i & 3, i >> 2);
|
2009-10-06 14:24:10 +00:00
|
|
|
FourTexUnits &tex = bpmem.tex[i >> 2];
|
2010-10-19 22:24:27 +00:00
|
|
|
TextureCache::TCacheEntryBase* tentry = TextureCache::Load(i,
|
2010-09-28 02:15:02 +00:00
|
|
|
(tex.texImage3[i&3].image_base/* & 0x1FFFFF*/) << 5,
|
|
|
|
tex.texImage0[i&3].width + 1, tex.texImage0[i&3].height + 1,
|
2009-10-06 14:24:10 +00:00
|
|
|
tex.texImage0[i&3].format, tex.texTlut[i&3].tmem_offset<<9,
|
2010-04-14 13:57:16 +00:00
|
|
|
tex.texTlut[i&3].tlut_format,
|
2012-06-07 22:18:04 +00:00
|
|
|
(tex.texMode0[i&3].min_filter & 3) && (tex.texMode0[i&3].min_filter != 8),
|
2012-01-29 20:49:50 +00:00
|
|
|
tex.texMode1[i&3].max_lod >> 4,
|
|
|
|
tex.texImage1[i&3].image_type);
|
2009-10-06 14:24:10 +00:00
|
|
|
|
2010-09-28 02:15:02 +00:00
|
|
|
if (tentry)
|
|
|
|
{
|
|
|
|
// 0s are probably for no manual wrapping needed.
|
2012-03-24 03:47:28 +00:00
|
|
|
PixelShaderManager::SetTexDims(i, tentry->native_width, tentry->native_height, 0, 0);
|
2009-10-06 14:24:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ERROR_LOG(VIDEO, "error loading texture");
|
2009-03-07 18:05:29 +00:00
|
|
|
}
|
2009-10-06 14:24:10 +00:00
|
|
|
}
|
2009-07-19 08:17:41 +00:00
|
|
|
|
2009-10-06 14:24:10 +00:00
|
|
|
// set global constants
|
|
|
|
VertexShaderManager::SetConstants();
|
2012-03-24 03:47:28 +00:00
|
|
|
PixelShaderManager::SetConstants();
|
2012-10-20 13:22:15 +00:00
|
|
|
int stride = g_nativeVertexFmt->GetVertexStride();
|
2012-08-10 16:57:37 +00:00
|
|
|
if (!PixelShaderCache::SetShader(DSTALPHA_NONE,g_nativeVertexFmt->m_components))
|
2012-03-29 23:56:24 +00:00
|
|
|
{
|
|
|
|
GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR,true,{printf("Fail to set pixel shader\n");});
|
|
|
|
goto shader_fail;
|
|
|
|
}
|
2009-10-06 14:24:10 +00:00
|
|
|
if (!VertexShaderCache::SetShader(g_nativeVertexFmt->m_components))
|
|
|
|
{
|
2010-12-05 14:15:36 +00:00
|
|
|
GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR,true,{printf("Fail to set vertex shader\n");});
|
2009-10-06 14:24:10 +00:00
|
|
|
goto shader_fail;
|
2009-03-10 14:15:46 +00:00
|
|
|
|
2009-10-06 14:24:10 +00:00
|
|
|
}
|
2012-10-20 13:22:15 +00:00
|
|
|
PrepareVBuffers(stride);
|
|
|
|
g_nativeVertexFmt->SetupVertexPointers();
|
2012-10-22 22:37:26 +00:00
|
|
|
if(NumVBuffers){ DrawVB(stride);} else { DrawVA(stride);}
|
2009-09-02 04:10:40 +00:00
|
|
|
|
2011-02-25 18:22:04 +00:00
|
|
|
bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate &&
|
2011-01-27 17:01:24 +00:00
|
|
|
bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24;
|
|
|
|
if (useDstAlpha)
|
2009-10-06 14:24:10 +00:00
|
|
|
{
|
2012-08-10 16:57:37 +00:00
|
|
|
if (!PixelShaderCache::SetShader(DSTALPHA_ALPHA_PASS, g_nativeVertexFmt->m_components))
|
2010-06-12 15:38:42 +00:00
|
|
|
{
|
2010-12-05 14:15:36 +00:00
|
|
|
GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR,true,{printf("Fail to set pixel shader\n");});
|
2010-06-12 15:38:42 +00:00
|
|
|
goto shader_fail;
|
|
|
|
}
|
|
|
|
// update alpha only
|
2012-08-10 16:57:37 +00:00
|
|
|
g_renderer->ApplyState(true);
|
2012-10-22 22:37:26 +00:00
|
|
|
if(NumVBuffers){ DrawVB(stride);} else { DrawVA(stride);}
|
2012-04-03 03:08:36 +00:00
|
|
|
g_renderer->RestoreState();
|
|
|
|
}
|
2010-12-05 14:15:36 +00:00
|
|
|
GFX_DEBUGGER_PAUSE_AT(NEXT_FLUSH, true);
|
2009-10-06 14:24:10 +00:00
|
|
|
|
|
|
|
shader_fail:
|
2012-10-20 13:22:15 +00:00
|
|
|
if(NumVBuffers)
|
|
|
|
{
|
|
|
|
CurrentIBufferIndex += IndexGenerator::GetTriangleindexLen() + IndexGenerator::GetLineindexLen() + IndexGenerator::GetPointindexLen();
|
|
|
|
CurrentVBufferIndex += IndexGenerator::GetNumVerts() * stride;
|
|
|
|
}
|
2009-10-06 14:24:10 +00:00
|
|
|
ResetBuffer();
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
2010-10-03 00:41:06 +00:00
|
|
|
|
|
|
|
}
|