TachyonUI
0.1.0
High-performance UI for building tools.
Toggle main menu visibility
Loading...
Searching...
No Matches
vk_upload_worker.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <condition_variable>
4
#include <cstddef>
5
#include <deque>
6
#include <functional>
7
#include <mutex>
8
#include <thread>
9
#include <vector>
10
11
namespace
tachyon::vulkan
12
{
15
19
class
UploadWorker
20
{
21
public
:
23
static
constexpr
size_t
kInlineBytes
= 32 * 1024;
24
25
UploadWorker
();
26
~UploadWorker
();
27
UploadWorker
(
const
UploadWorker
&) =
delete
;
28
UploadWorker
&
operator=
(
const
UploadWorker
&) =
delete
;
29
32
void
Copy
(
void
* destination,
const
void
* source,
size_t
size);
34
void
Copy
(
void
* destination, std::vector<std::byte>&& source);
37
void
Then
(std::function<
void
()> job);
39
void
Wait
();
41
bool
Busy
()
const
;
42
43
private
:
44
struct
Job
45
{
46
void
* destination =
nullptr
;
47
const
void
* source =
nullptr
;
48
size_t
size = 0;
49
std::vector<std::byte> owned;
50
std::function<void()> then;
51
};
52
void
Push(Job&& job);
53
void
Run();
54
55
mutable
std::mutex m_mutex;
56
std::condition_variable m_wake;
57
std::condition_variable m_done;
58
std::deque<Job> m_jobs;
59
bool
m_running =
false
;
60
bool
m_stop =
false
;
61
std::thread m_thread;
62
};
63
64
}
tachyon::vulkan::UploadWorker::operator=
UploadWorker & operator=(const UploadWorker &)=delete
tachyon::vulkan::UploadWorker::Copy
void Copy(void *destination, const void *source, size_t size)
Copies size bytes from source to destination; a null source zeroes them.
tachyon::vulkan::UploadWorker::~UploadWorker
~UploadWorker()
tachyon::vulkan::UploadWorker::kInlineBytes
static constexpr size_t kInlineBytes
Copies this small run on the calling thread: handing them over costs more.
Definition
vk_upload_worker.h:23
tachyon::vulkan::UploadWorker::Then
void Then(std::function< void()> job)
Runs job on the worker after every copy queued before it (flushing what they wrote),...
tachyon::vulkan::UploadWorker::UploadWorker
UploadWorker(const UploadWorker &)=delete
tachyon::vulkan::UploadWorker::UploadWorker
UploadWorker()
tachyon::vulkan::UploadWorker::Busy
bool Busy() const
Whether anything queued isn't done yet.
tachyon::vulkan::UploadWorker::Wait
void Wait()
Returns once every copy and job queued so far is done.
tachyon::vulkan::UploadWorker::Copy
void Copy(void *destination, std::vector< std::byte > &&source)
As Copy, from bytes the worker keeps until it has copied them.
tachyon::vulkan
Definition
vk_defaults.h:4
gui_core
graphics
vulkan
vk_upload_worker.h
Generated by
1.18.0