summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-28 01:50:40 +0100
committerskal <pascal.massimino@gmail.com>2026-02-28 01:50:40 +0100
commit1c5a9fb7b8c704a59ec58894adf46d73d1615072 (patch)
tree532ffc9738624cbce23ecdea51c8b94aae4f4b77 /src
parent75e561bd092895a031ae4475f7d1fdc35b1b1832 (diff)
fix: double-free of external views in NodeRegistry and PASSTHROUGH shader test
- NodeRegistry: skip external nodes (texture==nullptr) in ~NodeRegistry() and resize() to avoid double-releasing views set via set_external_view() - test_shader_assets: update PASSTHROUGH check to match #include pattern handoff(Claude): 35/35 tests passing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'src')
-rw-r--r--src/gpu/sequence.cc10
-rw-r--r--src/tests/gpu/test_shader_assets.cc3
2 files changed, 6 insertions, 7 deletions
diff --git a/src/gpu/sequence.cc b/src/gpu/sequence.cc
index 9de4133..783f3df 100644
--- a/src/gpu/sequence.cc
+++ b/src/gpu/sequence.cc
@@ -30,15 +30,14 @@ NodeRegistry::NodeRegistry(WGPUDevice device, int default_width,
NodeRegistry::~NodeRegistry() {
for (auto& [name, node] : nodes_) {
+ if (node.texture == nullptr) continue; // External view, not owned
if (node.view) {
wgpuTextureViewRelease(node.view);
}
for (auto& mip_view : node.mip_views) {
wgpuTextureViewRelease(mip_view);
}
- if (node.texture) {
- wgpuTextureRelease(node.texture);
- }
+ wgpuTextureRelease(node.texture);
}
}
@@ -108,6 +107,7 @@ void NodeRegistry::resize(int width, int height) {
default_height_ = height;
for (auto& [name, node] : nodes_) {
+ if (node.texture == nullptr) continue; // External view, not owned
// Release old texture
if (node.view) {
wgpuTextureViewRelease(node.view);
@@ -115,9 +115,7 @@ void NodeRegistry::resize(int width, int height) {
for (auto& mip_view : node.mip_views) {
wgpuTextureViewRelease(mip_view);
}
- if (node.texture) {
- wgpuTextureRelease(node.texture);
- }
+ wgpuTextureRelease(node.texture);
// Recreate with new dimensions
node.width = width;
diff --git a/src/tests/gpu/test_shader_assets.cc b/src/tests/gpu/test_shader_assets.cc
index 63f9b5d..084694d 100644
--- a/src/tests/gpu/test_shader_assets.cc
+++ b/src/tests/gpu/test_shader_assets.cc
@@ -62,7 +62,8 @@ int main() {
{"@vertex", "vs_main", "@fragment", "fs_main"});
all_passed &=
validate_shader(AssetId::ASSET_SHADER_PASSTHROUGH, "PASSTHROUGH",
- {"@vertex", "vs_main", "@fragment", "fs_main"});
+ {"#include \"render/fullscreen_uv_vs\"", "@fragment",
+ "fs_main"});
all_passed &= validate_shader(
AssetId::ASSET_SHADER_ELLIPSE, "ELLIPSE",
{"#include \"render/fullscreen_vs\"", "@fragment", "fs_main"});