Skip to content

Commit 10cc4af

Browse files
committed
update buffer
1 parent e30ca35 commit 10cc4af

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@
8989
"print": "cpp",
9090
"filesystem": "cpp",
9191
"forward_list": "cpp",
92-
"ranges": "cpp"
92+
"ranges": "cpp",
93+
"cfenv": "cpp",
94+
"regex": "cpp",
95+
"valarray": "cpp"
9396
},
9497
"files.exclude": {
9598
"build": true,

OpenGL/src/rendering/Buffer.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ class Buffer : public std::enable_shared_from_this<Buffer<T, Uniform>> {
207207
newBufferDesc.size = newSize;
208208
newBufferDesc.usage = usage_ | wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::CopySrc;
209209
newBufferDesc.mappedAtCreation = false;
210+
newBufferDesc.label = (name + " (gen " + std::to_string(generation) + ")").c_str();
210211

211212
wgpu::Buffer newBuffer = device_.createBuffer(newBufferDesc);
212213
if (!newBuffer) {
@@ -226,7 +227,9 @@ class Buffer : public std::enable_shared_from_this<Buffer<T, Uniform>> {
226227
}
227228

228229
// Copy existing data from old buffer to new buffer
229-
encoder->copyBufferToBuffer(buffer_, 0, newBuffer, 0, capacityBytes());
230+
auto bytes_to_copy = sizeBytes();
231+
std::cout << "Copying " << bytes_to_copy << " bytes from old buffer to new buffer" << std::endl;
232+
encoder->copyBufferToBuffer(buffer_, 0, newBuffer, 0, bytes_to_copy);
230233

231234
generation++;
232235

0 commit comments

Comments
 (0)