Skip to content

Commit

Permalink
Label pixelBuffer.
Browse files Browse the repository at this point in the history
  • Loading branch information
kugimasa committed Aug 21, 2023
1 parent f8c1976 commit ce4ab8d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/include/utils/save_texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ bool inline saveTexture(const std::filesystem::path &path, wgpu::Device device,
pixelBufferDesc.mappedAtCreation = false;
pixelBufferDesc.usage = BufferUsage::MapRead | BufferUsage::CopyDst;
pixelBufferDesc.size = paddedBytesPerRow * height;
pixelBufferDesc.label = "PixelBuffer";
Buffer pixelBuffer = device.createBuffer(pixelBufferDesc);

// Start encoding the commands
Expand Down Expand Up @@ -56,10 +57,8 @@ bool inline saveTexture(const std::filesystem::path &path, wgpu::Device device,
if (status != BufferMapAsyncStatus::Success) {
success = false;
} else {
const unsigned char *pixelData = (const unsigned char *) pixelBuffer.getConstMappedRange(0,
pixelBufferDesc.size);
int writeSuccess = stbi_write_png(path.string().c_str(), (int) width, (int) height, (int) channels, pixelData,
paddedBytesPerRow);
const auto *pixelData = (const unsigned char *) pixelBuffer.getConstMappedRange(0, pixelBufferDesc.size);
int writeSuccess = stbi_write_png(path.string().c_str(), (int) width, (int) height, (int) channels, pixelData, (int) paddedBytesPerRow);

pixelBuffer.unmap();

Expand Down

0 comments on commit ce4ab8d

Please sign in to comment.