summaryrefslogtreecommitdiff
path: root/src/tests/offscreen_render_target.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/offscreen_render_target.cc')
-rw-r--r--src/tests/offscreen_render_target.cc20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/tests/offscreen_render_target.cc b/src/tests/offscreen_render_target.cc
index 81ad082..f4c6b75 100644
--- a/src/tests/offscreen_render_target.cc
+++ b/src/tests/offscreen_render_target.cc
@@ -2,22 +2,16 @@
// It implements offscreen rendering for headless GPU testing.
// Provides pixel readback for validation.
-#if !defined(STRIP_ALL) // Test code only - zero size impact on final binary
-
#include "offscreen_render_target.h"
#include <cassert>
#include <cstdio>
#include <cstring>
OffscreenRenderTarget::OffscreenRenderTarget(WGPUInstance instance,
- WGPUDevice device,
- int width,
+ WGPUDevice device, int width,
int height,
WGPUTextureFormat format)
- : instance_(instance),
- device_(device),
- width_(width),
- height_(height),
+ : instance_(instance), device_(device), width_(width), height_(height),
format_(format) {
// Create offscreen texture
const WGPUTextureDescriptor texture_desc = {
@@ -61,7 +55,7 @@ void OffscreenRenderTarget::map_callback(WGPUMapAsyncStatus status,
}
WGPUBuffer OffscreenRenderTarget::create_staging_buffer() {
- const size_t buffer_size = width_ * height_ * 4; // BGRA8 = 4 bytes/pixel
+ const size_t buffer_size = width_ * height_ * 4; // BGRA8 = 4 bytes/pixel
const WGPUBufferDescriptor buffer_desc = {
.usage = WGPUBufferUsage_CopyDst | WGPUBufferUsage_MapRead,
.size = buffer_size,
@@ -70,7 +64,7 @@ WGPUBuffer OffscreenRenderTarget::create_staging_buffer() {
}
std::vector<uint8_t> OffscreenRenderTarget::read_pixels() {
- const size_t buffer_size = width_ * height_ * 4; // BGRA8
+ const size_t buffer_size = width_ * height_ * 4; // BGRA8
std::vector<uint8_t> pixels(buffer_size);
// Create staging buffer for readback
@@ -99,7 +93,7 @@ std::vector<uint8_t> OffscreenRenderTarget::read_pixels() {
};
const WGPUExtent3D copy_size = {static_cast<uint32_t>(width_),
- static_cast<uint32_t>(height_), 1};
+ static_cast<uint32_t>(height_), 1};
wgpuCommandEncoderCopyTextureToBuffer(encoder, &src, &dst, &copy_size);
@@ -150,7 +144,7 @@ std::vector<uint8_t> OffscreenRenderTarget::read_pixels() {
if (map_state.status != WGPUMapAsyncStatus_Success) {
fprintf(stderr, "Buffer mapping failed: %d\n", map_state.status);
wgpuBufferRelease(staging);
- return pixels; // Return empty
+ return pixels; // Return empty
}
// Copy data from mapped buffer
@@ -166,5 +160,3 @@ std::vector<uint8_t> OffscreenRenderTarget::read_pixels() {
return pixels;
}
-
-#endif /* !defined(STRIP_ALL) */