Skip to content

Commit

Permalink
Add a buffer destroy function
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Sep 4, 2024
1 parent ac1f631 commit a77461f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

#include <kope/graphics5/buffer.h>

void kope_d3d12_buffer_destroy(kope_g5_buffer *buffer) {
buffer->d3d12.resource->Release();
}

void *kope_d3d12_buffer_lock(kope_g5_buffer *buffer) {
void *data = NULL;
buffer->d3d12.resource->Map(0, NULL, &data);
return data;
}

void kope_d3d12_buffer_unlock(kope_g5_buffer *buffer) {
buffer->d3d12.resource->Unmap(0, NULL);
buffer->d3d12.resource->Unmap(0, NULL); // doesn't actually do anything in D3D12, just helps with debugging
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
extern "C" {
#endif

void kope_d3d12_buffer_destroy(kope_g5_buffer *buffer);
void *kope_d3d12_buffer_lock(kope_g5_buffer *buffer);
void kope_d3d12_buffer_unlock(kope_g5_buffer *buffer);

Expand Down
4 changes: 4 additions & 0 deletions Sources/kope/graphics5/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#include <kope/vulkan/buffer_functions.h>
#endif

void kope_g5_buffer_destroy(kope_g5_buffer *buffer) {
KOPE_G5_CALL1(buffer_destroy, buffer);
}

void *kope_g5_buffer_lock(kope_g5_buffer *buffer) {
return KOPE_G5_CALL1(buffer_lock, buffer);
}
Expand Down
1 change: 1 addition & 0 deletions Sources/kope/graphics5/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ typedef struct kope_g5_buffer {
KOPE_G5_IMPL(buffer);
} kope_g5_buffer;

void kope_g5_buffer_destroy(kope_g5_buffer *buffer);
void *kope_g5_buffer_lock(kope_g5_buffer *buffer); // TODO
void kope_g5_buffer_unlock(kope_g5_buffer *buffer);

Expand Down

0 comments on commit a77461f

Please sign in to comment.