Sfoglia il codice sorgente

gpu: fix some Direct3D programming errors; we cannot call SetVertexDeclaration

with a null argument, and the texture stuff was completely messed up.
legacy
Sam Hocevar sam 12 anni fa
parent
commit
e0330e18d7
2 ha cambiato i file con 11 aggiunte e 19 eliminazioni
  1. +9
    -17
      src/gpu/texture.cpp
  2. +2
    -2
      src/gpu/vertexbuffer.cpp

+ 9
- 17
src/gpu/texture.cpp Vedi File

@@ -81,12 +81,12 @@ Texture::Texture(ivec2 size)
#if defined USE_D3D9
g_d3ddevice->CreateTexture(m_data->m_size.x, m_data->m_size.y, 1,
D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8,
D3DPOOL_SYSTEMMEM, &m_tex, NULL);
D3DPOOL_DEFAULT, &m_data->m_tex, NULL);
#elif defined _XBOX
/* By default the X360 will swizzle the texture. Ask for linear. */
g_d3ddevice->CreateTexture(m_data->m_size.x, m_data->m_size.y, 1,
D3DUSAGE_WRITEONLY, D3DFMT_LIN_A8R8G8B8,
D3DPOOL_DEFAULT, &m_tex, NULL);
D3DPOOL_DEFAULT, &m_data->m_tex, NULL);
#else
glGenTextures(1, &m_data->m_texid);
glBindTexture(GL_TEXTURE_2D, m_data->m_texid);
@@ -118,13 +118,9 @@ void Texture::SetData(void *data)
{
#if defined _XBOX || defined USE_D3D9
D3DLOCKED_RECT rect;
# if defined _XBOX
m_data->m_tex->LockRect(0, &rect, NULL, D3DLOCK_NOOVERWRITE);
# else
m_data->m_tex->LockRect(0, &rect, NULL,
D3DLOCK_DISCARD | D3DLOCK_NOOVERWRITE);
# endif
memcpy(rect.pBits, data, rect.Pitch * rect.Height);
m_data->m_tex->LockRect(0, &rect, NULL, D3DLOCK_DISCARD);

memcpy(rect.pBits, data, rect.Pitch * m_data->m_size.y);

m_data->m_tex->UnlockRect(0);

@@ -139,18 +135,14 @@ void Texture::SetSubData(ivec2 origin, ivec2 size, void *data)
{
#if defined _XBOX || defined USE_D3D9
D3DLOCKED_RECT rect;
# if defined _XBOX
m_data->m_tex->LockRect(0, &rect, NULL, D3DLOCK_NOOVERWRITE);
# else
m_data->m_tex->LockRect(0, &rect, NULL,
D3DLOCK_DISCARD | D3DLOCK_NOOVERWRITE);
# endif
m_data->m_tex->LockRect(0, &rect, NULL, 0);

for (int j = 0; j < size.y; j++)
{
uint8_t *dst = (uint8_t *)rect.pBits + (origin.y + j) * rect.Pitch;
/* FIXME: the source or destination pitch isn't necessarily 4! */
uint8_t *src = (uint8_t *)data + j * size.y * 4;
memcpy(dst, src, size.y * 4);
uint8_t *src = (uint8_t *)data + j * size.x * 4;
memcpy(dst, src, size.x * 4);
}

m_data->m_tex->UnlockRect(0);


+ 2
- 2
src/gpu/vertexbuffer.cpp Vedi File

@@ -275,8 +275,8 @@ void VertexDeclaration::Unbind()
if (FAILED(g_d3ddevice->SetStreamSource(stream, 0, 0, 0)))
Abort();
}
if (FAILED(g_d3ddevice->SetVertexDeclaration(NULL)))
Abort();
/* "NULL is an invalid input to SetVertexDeclaration" (DX9 guide), so
* we just don't touch the current vertex declaration. */
#elif !defined __CELLOS_LV2__
for (int i = 0; i < m_count; i++)
{


Caricamento…
Annulla
Salva