2010-06-13 19:50:06 +00:00
|
|
|
// Copyright (C) 2003 Dolphin Project.
|
|
|
|
|
|
|
|
// 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"
|
|
|
|
#include "FileUtil.h"
|
|
|
|
|
|
|
|
#include "D3DBase.h"
|
|
|
|
#include "D3DShader.h"
|
|
|
|
#include "D3DUtil.h"
|
2010-06-29 14:40:37 +00:00
|
|
|
#include "Fifo.h"
|
2010-06-13 19:50:06 +00:00
|
|
|
#include "Statistics.h"
|
|
|
|
#include "Profiler.h"
|
2010-09-28 02:15:02 +00:00
|
|
|
#include "FramebufferManager.h"
|
2010-06-13 19:50:06 +00:00
|
|
|
#include "VertexManager.h"
|
|
|
|
#include "OpcodeDecoding.h"
|
|
|
|
#include "IndexGenerator.h"
|
|
|
|
#include "VertexShaderManager.h"
|
|
|
|
#include "VertexShaderCache.h"
|
|
|
|
#include "PixelShaderManager.h"
|
|
|
|
#include "PixelShaderCache.h"
|
|
|
|
#include "NativeVertexFormat.h"
|
|
|
|
#include "NativeVertexWriter.h"
|
|
|
|
#include "TextureCache.h"
|
2010-08-04 21:02:32 +00:00
|
|
|
#include "main.h"
|
2010-06-13 19:50:06 +00:00
|
|
|
|
|
|
|
#include "BPStructs.h"
|
|
|
|
#include "XFStructs.h"
|
|
|
|
|
|
|
|
#include "Globals.h"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
using std::string;
|
|
|
|
|
|
|
|
using namespace D3D;
|
|
|
|
|
2010-09-28 02:15:02 +00:00
|
|
|
// internal state for loading vertices
|
|
|
|
extern NativeVertexFormat *g_nativeVertexFmt;
|
2010-06-13 19:50:06 +00:00
|
|
|
|
|
|
|
namespace VertexManager
|
|
|
|
{
|
|
|
|
|
2010-09-28 02:15:02 +00:00
|
|
|
static int lastPrimitive;
|
|
|
|
|
|
|
|
static u8 *LocalVBuffer;
|
|
|
|
static u16 *TIBuffer;
|
|
|
|
static u16 *LIBuffer;
|
|
|
|
static u16 *PIBuffer;
|
2010-06-13 19:50:06 +00:00
|
|
|
#define MAXVBUFFERSIZE 0x50000
|
2010-07-06 22:10:15 +00:00
|
|
|
#define MAXIBUFFERSIZE 0x10000
|
2010-06-13 19:50:06 +00:00
|
|
|
|
|
|
|
// TODO: find sensible values for these two
|
2010-07-06 22:10:15 +00:00
|
|
|
#define NUM_VERTEXBUFFERS 8
|
|
|
|
#define NUM_INDEXBUFFERS 10
|
2010-06-13 19:50:06 +00:00
|
|
|
|
|
|
|
bool Flushed=false;
|
|
|
|
|
|
|
|
ID3D11Buffer* indexbuffers[NUM_INDEXBUFFERS] = {NULL};
|
|
|
|
ID3D11Buffer* vertexbuffers[NUM_VERTEXBUFFERS] = {NULL};
|
|
|
|
|
2010-07-06 22:10:15 +00:00
|
|
|
inline ID3D11Buffer* GetSuitableIndexBuffer(const u32 minsize)
|
2010-06-13 19:50:06 +00:00
|
|
|
{
|
2010-07-06 22:10:15 +00:00
|
|
|
for (u32 k = 0;k < NUM_INDEXBUFFERS-1;k++)
|
|
|
|
if (minsize > 2 * (((u32)MAXIBUFFERSIZE)>>(k+1)))
|
2010-06-13 19:50:06 +00:00
|
|
|
return indexbuffers[k];
|
|
|
|
return indexbuffers[NUM_INDEXBUFFERS-1];
|
|
|
|
}
|
|
|
|
|
2010-07-06 22:10:15 +00:00
|
|
|
inline ID3D11Buffer* GetSuitableVertexBuffer(const u32 minsize)
|
2010-06-13 19:50:06 +00:00
|
|
|
{
|
2010-07-06 22:10:15 +00:00
|
|
|
for (u32 k = 0;k < NUM_VERTEXBUFFERS-1;++k)
|
|
|
|
if (minsize > (((u32)MAXVBUFFERSIZE)>>(k+1)))
|
2010-06-13 19:50:06 +00:00
|
|
|
return vertexbuffers[k];
|
|
|
|
return vertexbuffers[NUM_VERTEXBUFFERS-1];
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreateDeviceObjects()
|
|
|
|
{
|
|
|
|
D3D11_BUFFER_DESC bufdesc;
|
|
|
|
HRESULT hr;
|
2010-07-06 22:10:15 +00:00
|
|
|
for (u32 k = 0;k < NUM_INDEXBUFFERS;++k)
|
|
|
|
{
|
|
|
|
bufdesc = CD3D11_BUFFER_DESC(2*(MAXIBUFFERSIZE>>k), D3D11_BIND_INDEX_BUFFER, D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE);
|
2010-06-13 19:50:06 +00:00
|
|
|
hr = D3D::device->CreateBuffer(&bufdesc, NULL, &indexbuffers[k]);
|
|
|
|
if (FAILED(hr)) PanicAlert("Failed to create index buffer, %s %d\n", __FILE__, __LINE__);
|
|
|
|
D3D::SetDebugObjectName((ID3D11DeviceChild*)indexbuffers[k], "an index buffer of VertexManager");
|
|
|
|
}
|
2010-07-06 22:10:15 +00:00
|
|
|
|
|
|
|
for (u32 k = 0;k < NUM_VERTEXBUFFERS;++k)
|
2010-06-13 19:50:06 +00:00
|
|
|
{
|
|
|
|
bufdesc = CD3D11_BUFFER_DESC(MAXVBUFFERSIZE >> k, D3D11_BIND_VERTEX_BUFFER, D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE);
|
|
|
|
hr = D3D::device->CreateBuffer(&bufdesc, NULL, &vertexbuffers[k]);
|
|
|
|
if (FAILED(hr)) PanicAlert("Failed to create vertex buffer, %s %d\n", __FILE__, __LINE__);
|
|
|
|
D3D::SetDebugObjectName((ID3D11DeviceChild*)vertexbuffers[k], "a vertex buffer of VertexManager");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DestroyDeviceObjects()
|
|
|
|
{
|
2010-07-06 22:10:15 +00:00
|
|
|
for (u32 k = 0;k < NUM_INDEXBUFFERS;++k)
|
2010-06-13 19:50:06 +00:00
|
|
|
SAFE_RELEASE(indexbuffers[k]);
|
|
|
|
|
2010-07-06 22:10:15 +00:00
|
|
|
for (u32 k = 0;k < NUM_VERTEXBUFFERS;++k)
|
2010-06-13 19:50:06 +00:00
|
|
|
SAFE_RELEASE(vertexbuffers[k]);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Init()
|
|
|
|
{
|
|
|
|
LocalVBuffer = new u8[MAXVBUFFERSIZE];
|
|
|
|
TIBuffer = new u16[MAXIBUFFERSIZE];
|
|
|
|
LIBuffer = new u16[MAXIBUFFERSIZE];
|
|
|
|
PIBuffer = new u16[MAXIBUFFERSIZE];
|
|
|
|
s_pCurBufferPointer = LocalVBuffer;
|
2010-08-29 23:08:56 +00:00
|
|
|
s_pBaseBufferPointer = LocalVBuffer;
|
2010-06-13 19:50:06 +00:00
|
|
|
Flushed=false;
|
|
|
|
|
|
|
|
CreateDeviceObjects();
|
|
|
|
|
2010-07-06 13:14:51 +00:00
|
|
|
IndexGenerator::Start(TIBuffer,LIBuffer,PIBuffer);
|
2010-06-13 19:50:06 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResetBuffer()
|
|
|
|
{
|
2010-07-06 13:14:51 +00:00
|
|
|
s_pCurBufferPointer = LocalVBuffer;
|
2010-06-13 19:50:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Shutdown()
|
|
|
|
{
|
|
|
|
DestroyDeviceObjects();
|
2010-06-18 23:33:07 +00:00
|
|
|
SAFE_DELETE_ARRAY(LocalVBuffer);
|
|
|
|
SAFE_DELETE_ARRAY(TIBuffer);
|
|
|
|
SAFE_DELETE_ARRAY(LIBuffer);
|
|
|
|
SAFE_DELETE_ARRAY(PIBuffer);
|
2010-06-13 19:50:06 +00:00
|
|
|
ResetBuffer();
|
|
|
|
}
|
|
|
|
|
2010-09-28 02:15:02 +00:00
|
|
|
void AddIndices(int primitive, int numVertices)
|
2010-06-13 19:50:06 +00:00
|
|
|
{
|
2010-09-28 02:15:02 +00:00
|
|
|
switch (primitive)
|
2010-06-13 19:50:06 +00:00
|
|
|
{
|
2010-09-28 02:15:02 +00:00
|
|
|
case GX_DRAW_QUADS: IndexGenerator::AddQuads(numVertices); break;
|
|
|
|
case GX_DRAW_TRIANGLES: IndexGenerator::AddList(numVertices); break;
|
|
|
|
case GX_DRAW_TRIANGLE_STRIP: IndexGenerator::AddStrip(numVertices); break;
|
|
|
|
case GX_DRAW_TRIANGLE_FAN: IndexGenerator::AddFan(numVertices); break;
|
|
|
|
case GX_DRAW_LINE_STRIP: IndexGenerator::AddLineStrip(numVertices); break;
|
|
|
|
case GX_DRAW_LINES: IndexGenerator::AddLineList(numVertices); break;
|
|
|
|
case GX_DRAW_POINTS: IndexGenerator::AddPoints(numVertices); break;
|
2010-06-13 19:50:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int GetRemainingSize()
|
|
|
|
{
|
|
|
|
return MAXVBUFFERSIZE - (int)(s_pCurBufferPointer - LocalVBuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
int GetRemainingVertices(int primitive)
|
|
|
|
{
|
|
|
|
switch (primitive)
|
|
|
|
{
|
2010-09-28 02:15:02 +00:00
|
|
|
case GX_DRAW_QUADS:
|
|
|
|
case GX_DRAW_TRIANGLES:
|
|
|
|
case GX_DRAW_TRIANGLE_STRIP:
|
|
|
|
case GX_DRAW_TRIANGLE_FAN:
|
|
|
|
return (MAXIBUFFERSIZE - IndexGenerator::GetTriangleindexLen())/3;
|
|
|
|
case GX_DRAW_LINE_STRIP:
|
|
|
|
case GX_DRAW_LINES:
|
|
|
|
return (MAXIBUFFERSIZE - IndexGenerator::GetLineindexLen())/2;
|
|
|
|
case GX_DRAW_POINTS:
|
|
|
|
return (MAXIBUFFERSIZE - IndexGenerator::GetPointindexLen());
|
|
|
|
default: return 0;
|
2010-06-13 19:50:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-28 02:15:02 +00:00
|
|
|
void AddVertices(int primitive, int numVertices)
|
2010-06-13 19:50:06 +00:00
|
|
|
{
|
2010-09-28 02:15:02 +00:00
|
|
|
if (numVertices <= 0)
|
|
|
|
return;
|
2010-06-13 19:50:06 +00:00
|
|
|
|
2010-09-28 02:15:02 +00:00
|
|
|
switch (primitive)
|
2010-06-13 19:50:06 +00:00
|
|
|
{
|
2010-09-28 02:15:02 +00:00
|
|
|
case GX_DRAW_QUADS:
|
|
|
|
case GX_DRAW_TRIANGLES:
|
|
|
|
case GX_DRAW_TRIANGLE_STRIP:
|
|
|
|
case GX_DRAW_TRIANGLE_FAN:
|
|
|
|
if (MAXIBUFFERSIZE - IndexGenerator::GetTriangleindexLen() < 3 * numVertices)
|
2010-06-13 19:50:06 +00:00
|
|
|
Flush();
|
2010-09-28 02:15:02 +00:00
|
|
|
break;
|
|
|
|
case GX_DRAW_LINE_STRIP:
|
|
|
|
case GX_DRAW_LINES:
|
|
|
|
if (MAXIBUFFERSIZE - IndexGenerator::GetLineindexLen() < 2 * numVertices)
|
2010-06-13 19:50:06 +00:00
|
|
|
Flush();
|
2010-09-28 02:15:02 +00:00
|
|
|
break;
|
|
|
|
case GX_DRAW_POINTS:
|
|
|
|
if (MAXIBUFFERSIZE - IndexGenerator::GetPointindexLen() < numVertices)
|
2010-06-13 19:50:06 +00:00
|
|
|
Flush();
|
2010-09-28 02:15:02 +00:00
|
|
|
break;
|
|
|
|
default: return;
|
2010-06-13 19:50:06 +00:00
|
|
|
}
|
|
|
|
if (Flushed)
|
|
|
|
{
|
|
|
|
IndexGenerator::Start(TIBuffer,LIBuffer,PIBuffer);
|
|
|
|
Flushed=false;
|
|
|
|
}
|
2010-09-28 02:15:02 +00:00
|
|
|
lastPrimitive = primitive;
|
|
|
|
ADDSTAT(stats.thisFrame.numPrims, numVertices);
|
2010-06-13 19:50:06 +00:00
|
|
|
INCSTAT(stats.thisFrame.numPrimitiveJoins);
|
2010-09-28 02:15:02 +00:00
|
|
|
AddIndices(primitive, numVertices);
|
2010-06-13 19:50:06 +00:00
|
|
|
}
|
|
|
|
|
2010-07-06 22:10:15 +00:00
|
|
|
inline void Draw(u32 stride, bool alphapass)
|
2010-06-13 19:50:06 +00:00
|
|
|
{
|
|
|
|
D3D11_MAPPED_SUBRESOURCE map;
|
2010-07-06 22:10:15 +00:00
|
|
|
ID3D11Buffer* vertexbuffer = GetSuitableVertexBuffer((u32)(s_pCurBufferPointer - LocalVBuffer));
|
2010-06-13 19:50:06 +00:00
|
|
|
|
|
|
|
if (!alphapass)
|
|
|
|
{
|
|
|
|
context->Map(vertexbuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
|
2010-07-06 22:10:15 +00:00
|
|
|
memcpy(map.pData, LocalVBuffer, (u32)(s_pCurBufferPointer - LocalVBuffer));
|
2010-06-13 19:50:06 +00:00
|
|
|
context->Unmap(vertexbuffer, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT bufoffset = 0;
|
2010-07-06 13:14:51 +00:00
|
|
|
UINT bufstride = stride;
|
2010-06-13 19:50:06 +00:00
|
|
|
|
|
|
|
if (!alphapass) gfxstate->ApplyState();
|
|
|
|
else gfxstate->AlphaPass();
|
|
|
|
if (IndexGenerator::GetNumTriangles() > 0)
|
|
|
|
{
|
2010-07-06 22:10:15 +00:00
|
|
|
u32 indexbuffersize = IndexGenerator::GetTriangleindexLen();
|
|
|
|
ID3D11Buffer* indexbuffer = GetSuitableIndexBuffer(2*indexbuffersize);
|
2010-06-13 19:50:06 +00:00
|
|
|
if (!alphapass)
|
|
|
|
{
|
|
|
|
D3D::context->Map(indexbuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
|
2010-07-06 22:10:15 +00:00
|
|
|
memcpy(map.pData, TIBuffer, 2*indexbuffersize);
|
2010-06-13 19:50:06 +00:00
|
|
|
D3D::context->Unmap(indexbuffer, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
D3D::context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
|
|
|
D3D::context->IASetVertexBuffers(0, 1, &vertexbuffer, &bufstride, &bufoffset);
|
|
|
|
D3D::context->IASetIndexBuffer(indexbuffer, DXGI_FORMAT_R16_UINT, 0);
|
|
|
|
|
2010-07-06 22:10:15 +00:00
|
|
|
D3D::context->DrawIndexed(indexbuffersize, 0, 0);
|
2010-06-13 19:50:06 +00:00
|
|
|
INCSTAT(stats.thisFrame.numIndexedDrawCalls);
|
|
|
|
}
|
|
|
|
if (IndexGenerator::GetNumLines() > 0)
|
|
|
|
{
|
2010-07-06 22:10:15 +00:00
|
|
|
u32 indexbuffersize = IndexGenerator::GetLineindexLen();
|
|
|
|
ID3D11Buffer* indexbuffer = GetSuitableIndexBuffer(2*indexbuffersize);
|
2010-06-13 19:50:06 +00:00
|
|
|
if (!alphapass)
|
|
|
|
{
|
2010-07-06 22:10:15 +00:00
|
|
|
D3D::context->Map(indexbuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
|
|
|
|
memcpy(map.pData, LIBuffer, 2*indexbuffersize);
|
|
|
|
D3D::context->Unmap(indexbuffer, 0);
|
2010-06-13 19:50:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
D3D::context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_LINELIST);
|
|
|
|
D3D::context->IASetVertexBuffers(0, 1, &vertexbuffer, &bufstride, &bufoffset);
|
2010-07-06 22:10:15 +00:00
|
|
|
D3D::context->IASetIndexBuffer(indexbuffer, DXGI_FORMAT_R16_UINT, 0);
|
2010-06-13 19:50:06 +00:00
|
|
|
|
2010-07-06 22:10:15 +00:00
|
|
|
D3D::context->DrawIndexed(indexbuffersize, 0, 0);
|
2010-06-13 19:50:06 +00:00
|
|
|
INCSTAT(stats.thisFrame.numIndexedDrawCalls);
|
|
|
|
}
|
|
|
|
if (IndexGenerator::GetNumPoints() > 0)
|
|
|
|
{
|
2010-07-06 22:10:15 +00:00
|
|
|
u32 indexbuffersize = IndexGenerator::GetPointindexLen();
|
|
|
|
ID3D11Buffer* indexbuffer = GetSuitableIndexBuffer(2*indexbuffersize);
|
2010-06-13 19:50:06 +00:00
|
|
|
if (!alphapass)
|
|
|
|
{
|
2010-07-06 22:10:15 +00:00
|
|
|
D3D::context->Map(indexbuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
|
|
|
|
memcpy(map.pData, PIBuffer, 2*indexbuffersize);
|
|
|
|
D3D::context->Unmap(indexbuffer, 0);
|
2010-06-13 19:50:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
D3D::context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);
|
|
|
|
D3D::context->IASetVertexBuffers(0, 1, &vertexbuffer, &bufstride, &bufoffset);
|
2010-07-06 22:10:15 +00:00
|
|
|
D3D::context->IASetIndexBuffer(indexbuffer, DXGI_FORMAT_R16_UINT, 0);
|
2010-06-13 19:50:06 +00:00
|
|
|
|
2010-07-06 22:10:15 +00:00
|
|
|
D3D::context->DrawIndexed(indexbuffersize, 0, 0);
|
2010-06-13 19:50:06 +00:00
|
|
|
INCSTAT(stats.thisFrame.numIndexedDrawCalls);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Flush()
|
|
|
|
{
|
|
|
|
if (LocalVBuffer == s_pCurBufferPointer) return;
|
|
|
|
if (Flushed) return;
|
|
|
|
Flushed=true;
|
2010-06-29 14:40:37 +00:00
|
|
|
VideoFifo_CheckEFBAccess();
|
2010-06-13 19:50:06 +00:00
|
|
|
|
|
|
|
DVSTARTPROFILE();
|
|
|
|
|
|
|
|
u32 usedtextures = 0;
|
|
|
|
for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages + 1; ++i)
|
2010-09-28 02:15:02 +00:00
|
|
|
if (bpmem.tevorders[i / 2].getEnable(i & 1))
|
2010-06-13 19:50:06 +00:00
|
|
|
usedtextures |= 1 << bpmem.tevorders[i/2].getTexMap(i & 1);
|
|
|
|
|
|
|
|
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)
|
|
|
|
usedtextures |= 1 << bpmem.tevindref.getTexMap(bpmem.tevind[i].bt);
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
if (usedtextures & (1 << i))
|
|
|
|
{
|
|
|
|
Renderer::SetSamplerState(i & 3, i >> 2);
|
|
|
|
FourTexUnits &tex = bpmem.tex[i >> 2];
|
|
|
|
TextureCache::TCacheEntry* 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,
|
|
|
|
tex.texImage0[i&3].format, tex.texTlut[i&3].tmem_offset<<9,
|
|
|
|
tex.texTlut[i&3].tlut_format,
|
|
|
|
(tex.texMode0[i&3].min_filter & 3) && (tex.texMode0[i&3].min_filter != 8) && g_ActiveConfig.bUseNativeMips,
|
|
|
|
(tex.texMode1[i&3].max_lod >> 4));
|
2010-06-13 19:50:06 +00:00
|
|
|
|
|
|
|
if (tentry)
|
|
|
|
{
|
2010-09-28 02:15:02 +00:00
|
|
|
// 0s are probably for no manual wrapping needed.
|
2010-06-13 19:50:06 +00:00
|
|
|
PixelShaderManager::SetTexDims(i, tentry->w, tentry->h, 0, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ERROR_LOG(VIDEO, "error loading texture");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-28 02:15:02 +00:00
|
|
|
// set global constants
|
2010-06-13 19:50:06 +00:00
|
|
|
VertexShaderManager::SetConstants();
|
|
|
|
PixelShaderManager::SetConstants();
|
|
|
|
|
2010-09-23 02:17:48 +00:00
|
|
|
if (!PixelShaderCache::SetShader(false,g_nativeVertexFmt->m_components))
|
2010-06-13 19:50:06 +00:00
|
|
|
goto shader_fail;
|
|
|
|
if (!VertexShaderCache::SetShader(g_nativeVertexFmt->m_components))
|
|
|
|
goto shader_fail;
|
|
|
|
|
|
|
|
unsigned int stride = g_nativeVertexFmt->GetVertexStride();
|
|
|
|
g_nativeVertexFmt->SetupVertexPointers();
|
|
|
|
|
|
|
|
Draw(stride, false);
|
|
|
|
|
2010-07-06 13:14:51 +00:00
|
|
|
if (bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate)
|
2010-06-13 19:50:06 +00:00
|
|
|
{
|
|
|
|
DWORD write = 0;
|
2010-09-23 02:17:48 +00:00
|
|
|
if (!PixelShaderCache::SetShader(true,g_nativeVertexFmt->m_components))
|
2010-06-13 19:50:06 +00:00
|
|
|
goto shader_fail;
|
|
|
|
|
|
|
|
// update alpha only
|
|
|
|
Draw(stride, true);
|
|
|
|
}
|
2010-06-19 12:48:09 +00:00
|
|
|
gfxstate->Reset();
|
2010-06-13 19:50:06 +00:00
|
|
|
|
|
|
|
shader_fail:
|
|
|
|
ResetBuffer();
|
|
|
|
}
|
|
|
|
} // namespace
|