-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwork_queue.h
More file actions
50 lines (40 loc) · 1.25 KB
/
Copy pathwork_queue.h
File metadata and controls
50 lines (40 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#pragma once
#include "common.h"
#include "mrt_math.h"
#include <atomic>
#include <algorithm>
struct tile {
uint32 xMin;
uint32 xMax;
uint32 yMin;
uint32 yMax;
};
class work_queue {
public:
tile *worklist;
uint64 numTiles;
uint32 numThreads;
std::atomic<uint64> counter;
work_queue(uint32 bufferWidth, uint32 bufferHeight, uint32 tileSize, uint32 numThreads);
virtual tile* getWork(uint32* curSample_out) = 0;
virtual float getPercentDone() = 0;
virtual ~work_queue() {
free(worklist);
}
};
class work_queue_seq final : public work_queue {
public:
work_queue_seq(uint32 bufferWidth, uint32 bufferHeight, uint32 tileSize, uint32 numThreads)
: work_queue(bufferWidth, bufferHeight, tileSize, numThreads) {}
tile* getWork(uint32* curSample_out);
float getPercentDone();
};
class work_queue_dynamic final : public work_queue {
public:
uint32 numSamples;
work_queue_dynamic(uint32 bufferWidth, uint32 bufferHeight, uint32 tileSize, uint32 numThreads, uint32 numSamples)
: work_queue(bufferWidth, bufferHeight, tileSize, numThreads),
numSamples(numSamples) {}
tile* getWork(uint32* curSample_out);
float getPercentDone();
};