Skip to content

Commit

Permalink
d3d: Only memcpy if lock was sucessful
Browse files Browse the repository at this point in the history
  • Loading branch information
IonAgorria committed Apr 9, 2024
1 parent 9780518 commit 45d142d
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions Source/Render/D3D/D3DRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1267,8 +1267,15 @@ void cD3DRender::UpdateD3DVertexBuffer(VertexBuffer* vb, size_t len) {
void* lock_ptr = nullptr;
uint32_t flags = vb->dynamic ? D3D_LOCK_FLAGS_DYNAMIC : D3D_LOCK_FLAGS_STATIC;
RDCALL(vb->d3d->Lock(0, len, &lock_ptr, flags));
memcpy(lock_ptr, vb->data, len);
vb->d3d->Unlock();
if (lock_ptr) {
memcpy(lock_ptr, vb->data, len);
vb->d3d->Unlock();
} else {
xassert(0);
#ifdef PERIMETER_EXODUS
fprintf(stderr, "D3D vertex buffer lock failed!\n");
#endif
}
}

void cD3DRender::UpdateD3DIndexBuffer(IndexBuffer* ib, size_t len) {
Expand Down Expand Up @@ -1301,8 +1308,15 @@ void cD3DRender::UpdateD3DIndexBuffer(IndexBuffer* ib, size_t len) {
void* lock_ptr = nullptr;
uint32_t flags = ib->dynamic ? D3D_LOCK_FLAGS_DYNAMIC : D3D_LOCK_FLAGS_STATIC;
RDCALL(ib->d3d->Lock(0, len, &lock_ptr, flags));
memcpy(lock_ptr, ib->data, len);
ib->d3d->Unlock();
if (lock_ptr) {
memcpy(lock_ptr, ib->data, len);
ib->d3d->Unlock();
} else {
xassert(0);
#ifdef PERIMETER_EXODUS
fprintf(stderr, "D3D index buffer lock failed!\n");
#endif
}
}

void cD3DRender::DeleteVertexBuffer(VertexBuffer &vb) {
Expand Down

0 comments on commit 45d142d

Please sign in to comment.