From 0d49891632b61f2f1acfbea482b694d7fa3d1303 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Tue, 17 Apr 2012 23:20:55 +0000 Subject: [PATCH] gpu: fix a nasty bug in the D3D9 vertex declaration code that caused wrong offset computations. --- src/gpu/vertexbuffer.cpp | 3 ++- src/gradient.cpp | 7 ++++++- src/scene.cpp | 8 -------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/gpu/vertexbuffer.cpp b/src/gpu/vertexbuffer.cpp index 79a4f88f..f3767477 100644 --- a/src/gpu/vertexbuffer.cpp +++ b/src/gpu/vertexbuffer.cpp @@ -303,7 +303,8 @@ void VertexDeclaration::Initialize() elements[n].Stream = m_streams[n].index; elements[n].Offset = 0; for (int i = 0; i < n; i++) - elements[n].Offset += m_streams[n].size; + if (m_streams[i].index == m_streams[n].index) + elements[n].Offset += m_streams[i].size; if (m_streams[n].stream_type >= 0 && m_streams[n].stream_type < sizeof(tlut) / sizeof(*tlut)) diff --git a/src/gradient.cpp b/src/gradient.cpp index b039f2de..75eb9131 100644 --- a/src/gradient.cpp +++ b/src/gradient.cpp @@ -154,9 +154,14 @@ void Gradient::TickDraw(float deltams) #if 1 " int x = (int)in_FragCoord.x;" " int y = (int)in_FragCoord.y;" +#if defined USE_D3D9 || defined _XBOX + " float t = bayer[int(frac(x * 0.25) * 4.0)]" + " [int(frac(y * 0.25) * 4.0)];\n" +#else // FIXME: we cannot address this matrix directly on the PS3 " float t = bayer[0][0];\n" - " t = (t + 0.5) / 17.0 + z - x;\n" +#endif + " t = (t + 0.5) / 17.0;\n" " col.x += frac(t - col.x) - t;\n" " col.y += frac(t - col.y) - t;\n" " col.z += frac(t - col.z) - t;\n" diff --git a/src/scene.cpp b/src/scene.cpp index fcac8364..bb78dcd8 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -100,16 +100,12 @@ Scene::Scene(float angle) Scene::~Scene() { -#if defined USE_D3D9 || defined _XBOX - /* FIXME: TODO */ -#else /* FIXME: this must be done while the GL context is still active. * Change the code architecture to make sure of that. */ /* XXX: The test is necessary because of a crash with PSGL. */ for (int i = 0; i < data->nbufs; i++) delete data->bufs[i]; free(data->bufs); -#endif delete data->m_vdecl; delete data; } @@ -381,8 +377,6 @@ void Scene::Render() // XXX: rename to Blit() data->bufs[buf]->Unlock(); data->bufs[buf + 1]->Unlock(); - stdshader->Bind(); - /* Bind texture */ data->tiles[i].tileset->Bind(); @@ -392,9 +386,7 @@ void Scene::Render() // XXX: rename to Blit() data->m_vdecl->SetStream(data->bufs[buf + 1], attr_tex); /* Draw arrays */ -#if 0 data->m_vdecl->DrawElements(MeshPrimitive::Triangles, 0, (n - i) * 2); -#endif data->m_vdecl->Unbind(); data->tiles[i].tileset->Unbind(); }