blob: c6665050685a2fb254c1b8b689e4646ae35dec17 (
plain)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#ifndef CPU_COMPUTE_UTIL_H
#define CPU_COMPUTE_UTIL_H
#include "slang-support.h"
#include "options.h"
#include "bind-location.h"
#include "../../source/core/slang-smart-pointer.h"
namespace renderer_test {
struct CPUComputeUtil
{
enum class ExecuteStyle
{
Unknown,
Thread,
Group,
GroupRange,
};
struct Resource : public RefObject
{
void* getInterface() const { return m_interface; }
void* m_interface;
};
struct Context
{
/// Holds the binding information
BindSet m_bindSet;
CPULikeBindRoot m_bindRoot;
/// Buffers are held in same order as entries in layout (useful for dumping out bindings)
List<BindSet::Value*> m_buffers;
};
struct ExecuteInfo
{
typedef void (*Func)();
ExecuteStyle m_style;
Func m_func;
uint32_t m_dispatchSize[3];
uint32_t m_numThreadsPerAxis[3];
void* m_uniformState;
void* m_uniformEntryPointParams;
};
/// True if this feature is available on CPU
static bool hasFeature(const Slang::UnownedStringSlice& feature);
/// Runs code across run styles and makes sure output buffers match
static SlangResult checkStyleConsistency(ISlangSharedLibrary* sharedLib, const uint32_t dispatchSize[3], const ShaderCompilerUtil::OutputAndLayout& compilationAndLayout);
static SlangResult calcBindings(const ShaderCompilerUtil::OutputAndLayout& compilationAndLayout, Context& outContext);
static SlangResult calcExecuteInfo(ExecuteStyle style, ISlangSharedLibrary* sharedLib, const uint32_t dispatchSize[3], const ShaderCompilerUtil::OutputAndLayout& compilationAndLayout, Context& context, ExecuteInfo& out);
static SlangResult execute(const ExecuteInfo& info);
};
} // renderer_test
#endif //CPU_COMPUTE_UTIL_H
|