Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Add some positive semaphore tests #138

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions tests/unit/sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,81 @@ TEST_F(Sync, GpuWaitWrongSem) {
dump::Parse(dump_file, output_path_);
}

TEST_F(Sync, GpuWaitBinaryPositive) {
layer_settings_.watchdog_timeout_ms = kWatchdogTimeout;
InitInstance();
InitDevice();

ComputeIOTest state(physical_device_, device_, kReadWriteComp);
state.input.Set(uint32_t(65535), ComputeIOTest::kNumElems);
state.output.Set(0.0f, ComputeIOTest::kNumElems);

vk::CommandBufferBeginInfo begin_info;
cmd_buff_.begin(begin_info);
cmd_buff_.bindPipeline(vk::PipelineBindPoint::eCompute, state.pipeline.Pipeline());
cmd_buff_.bindDescriptorSets(vk::PipelineBindPoint::eCompute, state.pipeline.PipelineLayout(), 0,
state.pipeline.DescriptorSet().Set(), {});
cmd_buff_.dispatch(1, 1, 1);
cmd_buff_.end();

vk::SemaphoreCreateInfo sem_ci;

vk::raii::Semaphore binary_sem(device_, sem_ci);
SetObjectName(device_, binary_sem, "binary_semaphore");

vk::PipelineStageFlags wait_mask = vk::PipelineStageFlagBits::eBottomOfPipe;
vk::Semaphore sem_handle;
// NOTE: MSVC win32 doesn't won't compile this with the 'advanced' constructor
vk::SubmitInfo signal_submit(0, nullptr, nullptr, 0, nullptr, 1, &(*binary_sem), nullptr);
queue_.submit(signal_submit);

vk::SubmitInfo wait_submit(*binary_sem, wait_mask, *cmd_buff_, {}, nullptr);

queue_.submit(wait_submit);

queue_.waitIdle();
}

TEST_F(Sync, GpuWaitTimelinePositive) {
layer_settings_.watchdog_timeout_ms = kWatchdogTimeout;
InitInstance();
InitDevice();

ComputeIOTest state(physical_device_, device_, kReadWriteComp);
state.input.Set(uint32_t(65535), ComputeIOTest::kNumElems);
state.output.Set(0.0f, ComputeIOTest::kNumElems);

vk::CommandBufferBeginInfo begin_info;
cmd_buff_.begin(begin_info);
cmd_buff_.bindPipeline(vk::PipelineBindPoint::eCompute, state.pipeline.Pipeline());
cmd_buff_.bindDescriptorSets(vk::PipelineBindPoint::eCompute, state.pipeline.PipelineLayout(), 0,
state.pipeline.DescriptorSet().Set(), {});
cmd_buff_.dispatch(1, 1, 1);
cmd_buff_.end();

std::array<vk::CommandBuffer, 2> cbs = {*cmd_buff_, *cmd_buff_};

vk::SemaphoreTypeCreateInfo sem_type_ci(vk::SemaphoreType::eTimeline, 100);
vk::SemaphoreCreateInfo sem_ci({}, &sem_type_ci);

vk::raii::Semaphore tl_sem(device_, sem_ci);
SetObjectName(device_, tl_sem, "tl_sem");

uint64_t sem_value = 123;
vk::TimelineSemaphoreSubmitInfo signal_tl_info(0, nullptr, 1, &sem_value);
vk::PipelineStageFlags wait_mask = vk::PipelineStageFlagBits::eBottomOfPipe;
vk::SubmitInfo signal_submit({}, {}, {}, *tl_sem, &signal_tl_info);

queue_.submit(signal_submit);

vk::TimelineSemaphoreSubmitInfo wait_tl_info(1, &sem_value);
vk::SubmitInfo wait_submit(*tl_sem, wait_mask, cbs, {}, &wait_tl_info);

queue_.submit(wait_submit);

queue_.waitIdle();
}

TEST_F(Sync, HostWaitHang) {
layer_settings_.watchdog_timeout_ms = kWatchdogTimeout;
InitInstance();
Expand Down
Loading