Skip to content

Commit

Permalink
d3d: Fix for wine 32 bits
Browse files Browse the repository at this point in the history
  • Loading branch information
IonAgorria committed Apr 9, 2024
1 parent 9780518 commit bfea7b1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
5 changes: 5 additions & 0 deletions Source/Game/Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ const char* currentVersion =
#ifdef PERIMETER_DEBUG
" Debug"
#endif
#ifdef PERIMETER_ARCH_64
" 64 bits"
#else
" 32 bits"
#endif
;

uint16_t currentVersionNumbers[] = {0, 0, 0};
Expand Down
26 changes: 22 additions & 4 deletions Source/Render/D3D/D3DRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,11 @@ void cD3DRender::DeleteDynamicBuffers() {
}

const uint32_t D3D_LOCK_FLAGS_STATIC = D3DLOCK_NOSYSLOCK | D3DLOCK_NO_DIRTY_UPDATE;
#ifndef PERIMETER_ARCH_64
const uint32_t D3D_LOCK_FLAGS_DYNAMIC = D3D_LOCK_FLAGS_STATIC | D3DLOCK_DISCARD;
#else
const uint32_t D3D_LOCK_FLAGS_DYNAMIC = D3D_LOCK_FLAGS_STATIC;
#endif

void cD3DRender::UpdateD3DVertexBuffer(VertexBuffer* vb, size_t len) {
xassert(!vb->burned);
Expand Down Expand Up @@ -1267,8 +1271,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 +1312,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 bfea7b1

Please sign in to comment.