Merge lp:~fboucault/qt-halide/fix_input_reuse into lp:qt-halide

Proposed by Florian Boucault
Status: Merged
Approved by: Ugo Riboni
Approved revision: 314
Merged at revision: 314
Proposed branch: lp:~fboucault/qt-halide/fix_input_reuse
Merge into: lp:qt-halide
Diff against target: 74 lines (+25/-1)
3 files modified
src/QtHalide/halide_transform_worker.cpp (+10/-1)
src/QtHalide/halide_transform_worker.h (+1/-0)
tests/unit/tst_function_list_model.qml (+14/-0)
To merge this branch: bzr merge lp:~fboucault/qt-halide/fix_input_reuse
Reviewer Review Type Date Requested Status
Ugo Riboni (community) Approve
Review via email: mp+261846@code.launchpad.net

Commit message

Fix deadlock when a function was first disabled then enabled due to the reuse of the input as output.

To post a comment you must log in.
Revision history for this message
Ugo Riboni (uriboni) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/QtHalide/halide_transform_worker.cpp'
2--- src/QtHalide/halide_transform_worker.cpp 2015-06-10 09:45:20 +0000
3+++ src/QtHalide/halide_transform_worker.cpp 2015-06-12 13:09:10 +0000
4@@ -29,7 +29,8 @@
5 QObject(0),
6 m_transform(transform),
7 m_thread(new QThread),
8- m_outputImage(new HalideImageData)
9+ m_outputImage(new HalideImageData),
10+ m_outputImageIsInput(false)
11 {
12 }
13
14@@ -49,8 +50,10 @@
15 m_outputImage = lastOutput;
16 } else if (inputImage) {
17 m_outputImage = inputImage->data();
18+ m_outputImageIsInput = true;
19 } else {
20 m_outputImage.reset(new HalideImageData);
21+ m_outputImageIsInput = false;
22 }
23 Q_EMIT computeFinished(m_outputImage);
24 } else {
25@@ -187,6 +190,12 @@
26 lastOutput->lock.unlock();
27 }
28
29+ // If m_outputImage is a reference to an HalideImageData used as input, it
30+ // should not be written on, replace it with a new empty one instead
31+ if (m_outputImageIsInput) {
32+ m_outputImage.reset(new HalideImageData);
33+ m_outputImageIsInput = false;
34+ }
35 // FIXME: only useful if output is going to be used for reading while being
36 // written on again by this worker
37 qSwap(m_outputImage, functionsData.last()->output);
38
39=== modified file 'src/QtHalide/halide_transform_worker.h'
40--- src/QtHalide/halide_transform_worker.h 2015-04-08 15:48:49 +0000
41+++ src/QtHalide/halide_transform_worker.h 2015-06-12 13:09:10 +0000
42@@ -92,6 +92,7 @@
43 QHash<HalideFunction*, QSharedPointer<HalideFunctionData> > m_cache;
44 QThread* m_thread;
45 QSharedPointer<HalideImageData> m_outputImage;
46+ bool m_outputImageIsInput;
47 static QMutex s_jitLock;
48 };
49
50
51=== modified file 'tests/unit/tst_function_list_model.qml'
52--- tests/unit/tst_function_list_model.qml 2015-04-08 15:48:49 +0000
53+++ tests/unit/tst_function_list_model.qml 2015-06-12 13:09:10 +0000
54@@ -151,6 +151,20 @@
55 compareAllPixelsWithColor(255, 128, 128, 255, "output does not match expected output");
56 }
57
58+ function test_disabled_then_enabled_then_update() {
59+ red.enabled = false;
60+ red.channel = 2;
61+ transform.functions = [red];
62+ spy.waitForUpdate();
63+ compareAllPixelsWithColor(128, 128, 128, 255, "output is not equal to input when no function is enabled");
64+ red.enabled = true;
65+ spy.waitForUpdate();
66+ compareAllPixelsWithColor(128, 128, 255, 255, "output does not match expected output");
67+ red.channel = 0;
68+ spy.waitForUpdate();
69+ compareAllPixelsWithColor(255, 128, 128, 255, "output does not match expected output");
70+ }
71+
72 function test_all_disabled() {
73 red.enabled = false;
74 green.enabled = false;

Subscribers

People subscribed via source and target branches

to all changes: