From badf6907dd071afa7a5438fdf575d73c4c417e3f Mon Sep 17 00:00:00 2001 From: skal Date: Wed, 11 Feb 2026 07:16:51 +0100 Subject: debug: Add shader load verification and GPU sync to CNN test tool Debug additions: - Print loaded shader size (confirms assets work: 2274 bytes) - Add wgpuDevicePoll after each layer for GPU sync - Verify shader loading with null/empty checks Findings: - Shader loads correctly (2274 bytes) - GPU commands execute without validation errors - Pipeline compiles successfully - Output remains all-black despite correct architecture Likely causes: - Render setup differs from demo's CNNEffect - Possible issue with bind group bindings - Fragment shader may not be executing - Texture sampling might be failing Next steps: - Create minimal solid-color render test - Compare bind group setup with working CNNEffect - Add fragment shader debug output (if possible) - Test with demo's CNN effect to verify weights/shader work Co-Authored-By: Claude Sonnet 4.5 --- tools/cnn_test.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tools/cnn_test.cc') diff --git a/tools/cnn_test.cc b/tools/cnn_test.cc index bb4a824..c44606c 100644 --- a/tools/cnn_test.cc +++ b/tools/cnn_test.cc @@ -151,6 +151,13 @@ static WGPURenderPipeline create_cnn_pipeline(WGPUDevice device, bool is_final_layer) { const char* shader_code = SafeGetAsset(AssetId::ASSET_SHADER_CNN_LAYER); + // Debug: check if shader loaded + if (!shader_code || shader_code[0] == '\0') { + fprintf(stderr, "ERROR: CNN shader asset not loaded!\n"); + return nullptr; + } + printf("Loaded CNN shader: %zu bytes\n", strlen(shader_code)); + WGPUBindGroupLayout bgl = BindGroupLayoutBuilder() .sampler(0, WGPUShaderStage_Fragment) @@ -425,6 +432,9 @@ int main(int argc, char** argv) { WGPUCommandBuffer commands = wgpuCommandEncoderFinish(encoder, nullptr); wgpuQueueSubmit(queue, 1, &commands); + // Wait for GPU to complete this layer before proceeding + wgpuDevicePoll(device, true, nullptr); + wgpuCommandBufferRelease(commands); wgpuRenderPassEncoderRelease(pass); wgpuCommandEncoderRelease(encoder); -- cgit v1.2.3