Skip to content

Commit

Permalink
oidnTest: improve async filter test
Browse files Browse the repository at this point in the history
  • Loading branch information
atafra committed Nov 9, 2024
1 parent 348fd64 commit 8d1a9a0
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions apps/oidnTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

#include "common/common.h"
#include "common/timer.h"
#include "utils/image_buffer.h"
#include "utils/random.h"
#include <cassert>
Expand Down Expand Up @@ -869,6 +870,7 @@ TEST_CASE("filter update", "[filter_update]")

TEST_CASE("async filter", "[async_filter]")
{
// Use a small image (one tile) to avoid potential blocking when filtering asynchronously on GPUs
const int W = 799;
const int H = 601;

Expand All @@ -888,9 +890,27 @@ TEST_CASE("async filter", "[async_filter]")
filter.commit();
REQUIRE(device.getError() == Error::None);

// Blocking filter dry run
filter.execute();
REQUIRE(device.getError() == Error::None);

// Measure blocking filter time
Timer timer;
filter.execute();
const double blockingTime = timer.query();
REQUIRE(device.getError() == Error::None);

// Measure async filter time
timer.reset();
filter.executeAsync();
const double asyncTime = timer.query();
REQUIRE(device.getError() == Error::None);
REQUIRE(asyncTime < blockingTime / 2.); // async shouldn't block for long

for (int i = 0; i < 3; ++i)
filter.executeAsync();

// Change filter parameters without manually syncing first
setFilterImage(filter, "albedo", albedo);
filter.set("hdr", false);

Expand All @@ -904,6 +924,8 @@ TEST_CASE("async filter", "[async_filter]")
REQUIRE(device.getError() == Error::None);

filter.executeAsync();

// Release filter without manually syncing first
filter.release();

REQUIRE(device.getError() == Error::None);
Expand Down

0 comments on commit 8d1a9a0

Please sign in to comment.