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
69
70
71
72
73
74
75
76
77
78
79
|
#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-basic.h"
namespace renderer_test {
struct CPUComputeUtil
{
enum class ExecuteStyle
{
Unknown,
Thread,
Group,
GroupRange,
};
struct Resource : public Slang::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)
Slang::List<BindSet::Value*> m_buffers;
/// Bindless resource objects
Slang::OrderedDictionary<Slang::String, Slang::RefPtr<Resource>> m_bindlessResources;
};
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 createBindlessResources(ShaderCompilerUtil::OutputAndLayout& compilationAndLayout, Context& context);
/// Query and fill in the RTTI pointer and runtime resource handle values in data buffers.
static SlangResult fillRuntimeHandleInBuffers(
ShaderCompilerUtil::OutputAndLayout& compilationAndLayout,
Context& context,
ISlangSharedLibrary* sharedLib);
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
|