Browse Source

gpu: fix vertex and index buffer behaviour on the PS3.

legacy
Sam Hocevar sam 12 years ago
parent
commit
f3dfadd1f9
2 changed files with 21 additions and 12 deletions
  1. +7
    -7
      src/gpu/indexbuffer.cpp
  2. +14
    -5
      src/gpu/vertexbuffer.cpp

+ 7
- 7
src/gpu/indexbuffer.cpp View File

@@ -47,7 +47,7 @@ class IndexBufferData
IDirect3DIndexBuffer9 *m_ibo; IDirect3DIndexBuffer9 *m_ibo;
#elif defined _XBOX #elif defined _XBOX
D3DIndexBuffer *m_ibo; D3DIndexBuffer *m_ibo;
#elif !defined __CELLOS_LV2__ && !defined __ANDROID__
#else
GLuint m_ibo; GLuint m_ibo;
uint8_t *m_memory; uint8_t *m_memory;
#endif #endif
@@ -69,7 +69,7 @@ IndexBuffer::IndexBuffer(size_t size)
D3DFMT_INDEX16, D3DPOOL_MANAGED, D3DFMT_INDEX16, D3DPOOL_MANAGED,
&m_data->m_ibo, NULL))) &m_data->m_ibo, NULL)))
Abort(); Abort();
#elif !defined __CELLOS_LV2__ && !defined __ANDROID__
#else
glGenBuffers(1, &m_data->m_ibo); glGenBuffers(1, &m_data->m_ibo);
m_data->m_memory = new uint8_t[size]; m_data->m_memory = new uint8_t[size];
#endif #endif
@@ -82,7 +82,7 @@ IndexBuffer::~IndexBuffer()
#if defined USE_D3D9 || defined _XBOX #if defined USE_D3D9 || defined _XBOX
if (FAILED(m_data->m_ibo->Release())) if (FAILED(m_data->m_ibo->Release()))
Abort(); Abort();
#elif !defined __CELLOS_LV2__ && !defined __ANDROID__
#else
glDeleteBuffers(1, &m_data->m_ibo); glDeleteBuffers(1, &m_data->m_ibo);
delete[] m_data->m_memory; delete[] m_data->m_memory;
#endif #endif
@@ -100,7 +100,7 @@ void *IndexBuffer::Lock(size_t offset, size_t size)
if (FAILED(m_data->m_ibo->Lock(offset, size, (void **)&ret, 0))) if (FAILED(m_data->m_ibo->Lock(offset, size, (void **)&ret, 0)))
Abort(); Abort();
return ret; return ret;
#elif !defined __CELLOS_LV2__ && !defined __ANDROID__
#else
return m_data->m_memory + offset; return m_data->m_memory + offset;
#endif #endif
} }
@@ -113,7 +113,7 @@ void IndexBuffer::Unlock()
#if defined USE_D3D9 || defined _XBOX #if defined USE_D3D9 || defined _XBOX
if (FAILED(m_data->m_ibo->Unlock())) if (FAILED(m_data->m_ibo->Unlock()))
Abort(); Abort();
#elif !defined __CELLOS_LV2__ && !defined __ANDROID__
#else
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_data->m_ibo); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_data->m_ibo);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_data->m_size, m_data->m_memory, glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_data->m_size, m_data->m_memory,
GL_STATIC_DRAW); GL_STATIC_DRAW);
@@ -128,7 +128,7 @@ void IndexBuffer::Bind()
#if defined USE_D3D9 || defined _XBOX #if defined USE_D3D9 || defined _XBOX
if (FAILED(g_d3ddevice->SetIndices(m_data->m_ibo))) if (FAILED(g_d3ddevice->SetIndices(m_data->m_ibo)))
Abort(); Abort();
#elif !defined __CELLOS_LV2__ && !defined __ANDROID__
#else
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_data->m_ibo); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_data->m_ibo);
/* XXX: not necessary because we kept track of the size */ /* XXX: not necessary because we kept track of the size */
//int size; //int size;
@@ -144,7 +144,7 @@ void IndexBuffer::Unbind()
#if defined USE_D3D9 || defined _XBOX #if defined USE_D3D9 || defined _XBOX
if (FAILED(g_d3ddevice->SetIndices(NULL))) if (FAILED(g_d3ddevice->SetIndices(NULL)))
Abort(); Abort();
#elif !defined __CELLOS_LV2__ && !defined __ANDROID__
#else
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
#endif #endif
} }


+ 14
- 5
src/gpu/vertexbuffer.cpp View File

@@ -246,7 +246,10 @@ void VertexDeclaration::Unbind()
//glDisableVertexAttribArray(m_attrib); //glDisableVertexAttribArray(m_attrib);
#else #else
/* Or even: */ /* Or even: */
//glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
#endif #endif
} }


@@ -314,6 +317,12 @@ void VertexDeclaration::SetStream(VertexBuffer *vb, ShaderAttrib attr1,
case VertexUsage::Position: case VertexUsage::Position:
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
break; break;
case VertexUsage::TexCoord:
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
break;
case VertexUsage::Normal:
glEnableClientState(GL_NORMAL_ARRAY);
break;
case VertexUsage::Color: case VertexUsage::Color:
glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_COLOR_ARRAY);
break; break;
@@ -530,7 +539,7 @@ VertexBuffer::VertexBuffer(size_t size)
if (FAILED(g_d3ddevice->CreateVertexBuffer(size, D3DUSAGE_WRITEONLY, NULL, if (FAILED(g_d3ddevice->CreateVertexBuffer(size, D3DUSAGE_WRITEONLY, NULL,
D3DPOOL_MANAGED, &m_data->m_vbo, NULL))) D3DPOOL_MANAGED, &m_data->m_vbo, NULL)))
Abort(); Abort();
#elif !defined __CELLOS_LV2__
#else
glGenBuffers(1, &m_data->m_vbo); glGenBuffers(1, &m_data->m_vbo);
m_data->m_memory = new uint8_t[size]; m_data->m_memory = new uint8_t[size];
#endif #endif
@@ -543,7 +552,7 @@ VertexBuffer::~VertexBuffer()
#if defined USE_D3D9 || defined _XBOX #if defined USE_D3D9 || defined _XBOX
if (FAILED(m_data->m_vbo->Release())) if (FAILED(m_data->m_vbo->Release()))
Abort(); Abort();
#elif !defined __CELLOS_LV2__
#else
glDeleteBuffers(1, &m_data->m_vbo); glDeleteBuffers(1, &m_data->m_vbo);
delete[] m_data->m_memory; delete[] m_data->m_memory;
#endif #endif
@@ -560,7 +569,7 @@ void *VertexBuffer::Lock(size_t offset, size_t size)
if (FAILED(m_data->m_vbo->Lock(offset, size, (void **)&ret, 0))) if (FAILED(m_data->m_vbo->Lock(offset, size, (void **)&ret, 0)))
Abort(); Abort();
return ret; return ret;
#elif !defined __CELLOS_LV2__
#else
return m_data->m_memory + offset; return m_data->m_memory + offset;
#endif #endif
} }
@@ -572,7 +581,7 @@ void VertexBuffer::Unlock()
#if defined USE_D3D9 || defined _XBOX #if defined USE_D3D9 || defined _XBOX
if (FAILED(m_data->m_vbo->Unlock())) if (FAILED(m_data->m_vbo->Unlock()))
Abort(); Abort();
#elif !defined __CELLOS_LV2__
#else
glBindBuffer(GL_ARRAY_BUFFER, m_data->m_vbo); glBindBuffer(GL_ARRAY_BUFFER, m_data->m_vbo);
glBufferData(GL_ARRAY_BUFFER, m_data->m_size, m_data->m_memory, glBufferData(GL_ARRAY_BUFFER, m_data->m_size, m_data->m_memory,
GL_STATIC_DRAW); GL_STATIC_DRAW);


Loading…
Cancel
Save