Changeset 1989


Ignore:
Timestamp:
Oct 8, 2012, 1:05:28 PM (5 years ago)
Author:
sam
Message:

gpu: fix some Direct3D programming errors; we cannot call SetVertexDeclaration
with a null argument, and the texture stuff was completely messed up.

Location:
trunk/src/gpu
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gpu/texture.cpp

    r1988 r1989  
    8282    g_d3ddevice->CreateTexture(m_data->m_size.x, m_data->m_size.y, 1,
    8383                               D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8,
    84                                D3DPOOL_SYSTEMMEM, &m_tex, NULL);
     84                               D3DPOOL_DEFAULT, &m_data->m_tex, NULL);
    8585#elif defined _XBOX
    8686    /* By default the X360 will swizzle the texture. Ask for linear. */
    8787    g_d3ddevice->CreateTexture(m_data->m_size.x, m_data->m_size.y, 1,
    8888                               D3DUSAGE_WRITEONLY, D3DFMT_LIN_A8R8G8B8,
    89                                D3DPOOL_DEFAULT, &m_tex, NULL);
     89                               D3DPOOL_DEFAULT, &m_data->m_tex, NULL);
    9090#else
    9191    glGenTextures(1, &m_data->m_texid);
     
    119119#if defined _XBOX || defined USE_D3D9
    120120    D3DLOCKED_RECT rect;
    121 #   if defined _XBOX
    122     m_data->m_tex->LockRect(0, &rect, NULL, D3DLOCK_NOOVERWRITE);
    123 #   else
    124     m_data->m_tex->LockRect(0, &rect, NULL,
    125                             D3DLOCK_DISCARD | D3DLOCK_NOOVERWRITE);
    126 #   endif
    127     memcpy(rect.pBits, data, rect.Pitch * rect.Height);
     121    m_data->m_tex->LockRect(0, &rect, NULL, D3DLOCK_DISCARD);
     122
     123    memcpy(rect.pBits, data, rect.Pitch * m_data->m_size.y);
    128124
    129125    m_data->m_tex->UnlockRect(0);
     
    140136#if defined _XBOX || defined USE_D3D9
    141137    D3DLOCKED_RECT rect;
    142 #   if defined _XBOX
    143     m_data->m_tex->LockRect(0, &rect, NULL, D3DLOCK_NOOVERWRITE);
    144 #   else
    145     m_data->m_tex->LockRect(0, &rect, NULL,
    146                             D3DLOCK_DISCARD | D3DLOCK_NOOVERWRITE);
    147 #   endif
     138    m_data->m_tex->LockRect(0, &rect, NULL, 0);
     139
    148140    for (int j = 0; j < size.y; j++)
    149141    {
    150142        uint8_t *dst = (uint8_t *)rect.pBits + (origin.y + j) * rect.Pitch;
    151143        /* FIXME: the source or destination pitch isn't necessarily 4! */
    152         uint8_t *src = (uint8_t *)data + j * size.y * 4;
    153         memcpy(dst, src, size.y * 4);
     144        uint8_t *src = (uint8_t *)data + j * size.x * 4;
     145        memcpy(dst, src, size.x * 4);
    154146    }
    155147
  • trunk/src/gpu/vertexbuffer.cpp

    r1963 r1989  
    276276                Abort();
    277277        }
    278     if (FAILED(g_d3ddevice->SetVertexDeclaration(NULL)))
    279         Abort();
     278    /* "NULL is an invalid input to SetVertexDeclaration" (DX9 guide), so
     279     * we just don't touch the current vertex declaration. */
    280280#elif !defined __CELLOS_LV2__
    281281    for (int i = 0; i < m_count; i++)
Note: See TracChangeset for help on using the changeset viewer.