some fixes for point rendering

This commit is contained in:
Rodolfo Bogado 2013-08-15 15:14:48 -03:00
parent a5e34dd5cb
commit 8e9bbdeb2f
2 changed files with 1399 additions and 1391 deletions

View File

@ -1080,6 +1080,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
D3D::dev->SetRenderTarget(0, FramebufferManager::GetEFBColorRTSurface());
D3D::dev->SetDepthStencilSurface(FramebufferManager::GetEFBDepthRTSurface());
D3D::dev->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,0), 1.0f, 0);
SetLineWidth();
}
if (XFBWrited)
@ -1140,8 +1141,8 @@ void Renderer::RestoreState()
D3D::RefreshRenderState(D3DRS_ZFUNC);
}
// TODO: Enable this code. Caused glitches for me however (neobrain)
// for (unsigned int i = 0; i < 8; ++i)
// D3D::dev->SetTexture(i, NULL);
// for (unsigned int i = 0; i < 8; ++i)
// D3D::dev->SetTexture(i, NULL);
}
// ALWAYS call RestoreAPIState for each ResetAPIState call you're doing
@ -1315,9 +1316,8 @@ void Renderer::SetLineWidth()
{
// We can't change line width in D3D unless we use ID3DXLine
float fratio = xfregs.viewport.wd != 0 ? Renderer::EFBToScaledXf(1.f) : 1.0f;
float psize = bpmem.lineptwidth.linesize * fratio / 6.0f;
//little hack to compensate scaling problems in dx9 must be taken out when scaling is fixed.
psize *= 2.0f;
float psize = bpmem.lineptwidth.pointsize * fratio / 6.0f;
psize = psize > 0 ? psize : 1.0;
if (psize > m_fMaxPointSize)
{
psize = m_fMaxPointSize;

View File

@ -37,7 +37,7 @@ inline void DumpBadShaders()
{
#if defined(_DEBUG) || defined(DEBUGFAST)
// TODO: Reimplement!
/* std::string error_shaders;
/* std::string error_shaders;
error_shaders.append(VertexShaderCache::GetCurrentShaderCode());
error_shaders.append(PixelShaderCache::GetCurrentShaderCode());
char filename[512] = "bad_shader_combo_0.txt";
@ -144,8 +144,9 @@ void VertexManager::PrepareDrawBuffers(u32 stride)
int datasize = IndexGenerator::GetNumVerts() * stride;
int TdataSize = IndexGenerator::GetTriangleindexLen();
int LDataSize = IndexGenerator::GetLineindexLen();
int PDataSize = IndexGenerator::GetPointindexLen();
int IndexDataSize = TdataSize + LDataSize;
if(IndexDataSize)
{
DWORD LockMode = D3DLOCK_NOOVERWRITE;
m_vertex_buffer_cursor--;
m_vertex_buffer_cursor = m_vertex_buffer_cursor - (m_vertex_buffer_cursor % stride) + stride;
@ -187,10 +188,11 @@ void VertexManager::PrepareDrawBuffers(u32 stride)
pIndices += LDataSize;
}
m_index_buffers[m_current_index_buffer]->Unlock();
}
if(m_current_stride != stride || m_vertex_buffer_cursor == 0)
{
m_current_stride = stride;
D3D::SetStreamSource( 0, m_vertex_buffers[m_current_vertex_buffer], 0, stride);
D3D::SetStreamSource( 0, m_vertex_buffers[m_current_vertex_buffer], 0, m_current_stride);
}
if (m_index_buffer_cursor == 0)
{
@ -241,20 +243,26 @@ void VertexManager::DrawVertexBuffer(int stride)
}
if (points > 0)
{
//DrawIndexedPrimitive does not support point list so we have to draw the points one by one
for (int i = 0; i < points; i++)
//DrawIndexedPrimitive does not support point list so we have to draw them using DrawPrimitive
u16* PointIndexBuffer = GetPointIndexBuffer();
int i = 0;
do
{
int count = i + 1;
while (count < points && PointIndexBuffer[count - 1] + 1 == PointIndexBuffer[count])
{
count++;
}
if (FAILED(D3D::dev->DrawPrimitive(
D3DPT_POINTLIST,
basevertex + GetPointIndexBuffer()[i],
1)))
basevertex + PointIndexBuffer[i],
count - i)))
{
DumpBadShaders();
}
INCSTAT(stats.thisFrame.numDrawCalls);
}
i = count;
} while (i < points);
}
}