Browse Source

gpu: warn when a vertex shader attribute isn’t found and do not crash

when a stream is not found in the vertex declaration at bind time.
legacy
Sam Hocevar sam 12 years ago
parent
commit
84a308af4e
2 changed files with 14 additions and 2 deletions
  1. +7
    -2
      src/gpu/shader.cpp
  2. +7
    -0
      src/gpu/vertexbuffer.cpp

+ 7
- 2
src/gpu/shader.cpp View File

@@ -326,8 +326,13 @@ ShaderAttrib Shader::GetAttribLocation(char const *attr,
ret.m_flags |= (uint64_t)(uint16_t)index; ret.m_flags |= (uint64_t)(uint16_t)index;
#if defined USE_D3D9 || defined _XBOX #if defined USE_D3D9 || defined _XBOX
#elif !defined __CELLOS_LV2__ #elif !defined __CELLOS_LV2__
ret.m_flags |= (uint64_t)
(uint32_t)glGetAttribLocation(data->prog_id, attr) << 32;
GLint l = glGetAttribLocation(data->prog_id, attr);
if (l < 0)
{
Log::Warn("tried to query invalid attribute: %s\n", attr);
l = 0;
}
ret.m_flags |= (uint64_t)(uint32_t)l << 32;
#else #else
/* FIXME: can we do this at all on the PS3? */ /* FIXME: can we do this at all on the PS3? */
#endif #endif


+ 7
- 0
src/gpu/vertexbuffer.cpp View File

@@ -374,6 +374,13 @@ void VertexDeclaration::SetStream(VertexBuffer *vb, ShaderAttrib attr1,
if (usage_index++ == index) if (usage_index++ == index)
break; break;


if (attr_index == m_count)
{
Log::Error("stream #%d with usage %x not found in declaration\n",
index, usage);
attr_index = 0;
}

/* Now compute the stride and offset up to this stream index */ /* Now compute the stride and offset up to this stream index */
int stride = 0, offset = 0; int stride = 0, offset = 0;
for (int i = 0; i < m_count; i++) for (int i = 0; i < m_count; i++)


Loading…
Cancel
Save