From d0e9447ac0ab8a375c2b83990649ee3b2245c882 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Mon, 25 Aug 2014 20:15:46 +0000 Subject: [PATCH] gpu: fix missing #if blocks in vertex buffer code. --- src/gpu/vertexbuffer.cpp | 6 +++++- src/lol/gpu/vertexbuffer.h | 2 ++ src/scene.cpp | 5 ++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/gpu/vertexbuffer.cpp b/src/gpu/vertexbuffer.cpp index 550a2a56..3ccef66d 100644 --- a/src/gpu/vertexbuffer.cpp +++ b/src/gpu/vertexbuffer.cpp @@ -399,7 +399,7 @@ void VertexDeclaration::SetStream(VertexBuffer *vb, ShaderAttrib attribs[]) if (attr_index == m_count) { Log::Error("stream #%d with usage %x not found in declaration\n", - index, usage); + index, usage.ToScalar()); attr_index = 0; } @@ -423,7 +423,9 @@ void VertexDeclaration::SetStream(VertexBuffer *vb, ShaderAttrib attribs[]) static struct { GLint size; GLenum type; } const tlut[] = { { 0, 0 }, +#if LOL_FEATURE_CXX11_UNRESTRICTED_UNIONS { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, /* half */ +#endif { 1, GL_FLOAT }, { 2, GL_FLOAT }, { 3, GL_FLOAT }, { 4, GL_FLOAT }, /* float */ { 1, GL_DOUBLE }, { 2, GL_DOUBLE }, { 3, GL_DOUBLE }, @@ -514,7 +516,9 @@ void VertexDeclaration::Initialize() static D3DDECLTYPE const tlut[] = { D3DDECLTYPE_UNUSED, +#if LOL_FEATURE_CXX11_UNRESTRICTED_UNIONS X, D3DDECLTYPE_FLOAT16_2, X, D3DDECLTYPE_FLOAT16_4, /* half */ +#endif D3DDECLTYPE_FLOAT1, D3DDECLTYPE_FLOAT2, D3DDECLTYPE_FLOAT3, D3DDECLTYPE_FLOAT4, /* float */ X, X, X, X, /* double */ diff --git a/src/lol/gpu/vertexbuffer.h b/src/lol/gpu/vertexbuffer.h index 785e4e04..5ea0b223 100644 --- a/src/lol/gpu/vertexbuffer.h +++ b/src/lol/gpu/vertexbuffer.h @@ -55,6 +55,8 @@ class VertexStreamBase public: enum { + /* XXX: be sure to fix all appropriate places in vertexbuffer.cpp + * when modifying this list. */ Typevoid = 0, #if LOL_FEATURE_CXX11_UNRESTRICTED_UNIONS Typehalf, Typef16vec2, Typef16vec3, Typef16vec4, diff --git a/src/scene.cpp b/src/scene.cpp index 6d712111..6ac81d77 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -455,10 +455,9 @@ void Scene::RenderLines(float seconds) // XXX: rename to Blit() linecount--; } } - int vb_size = sizeof(vec4) * 4 * real_linecount; - VertexBuffer *vb = new VertexBuffer(vb_size); + VertexBuffer *vb = new VertexBuffer(buff.Bytes()); float *vertex = (float *)vb->Lock(0, 0); - memcpy(vertex, buff.Data(), vb_size); + memcpy(vertex, buff.Data(), buff.Bytes()); vb->Unlock(); data->m_line_shader->Bind();