summaryrefslogtreecommitdiff
path: root/tools/render-test/cuda/cuda-compute-util.h
blob: bc3d7d233edfe92f71c3d6b315f6e1832c69433b (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
#ifndef CUDA_COMPUTE_UTIL_H
#define CUDA_COMPUTE_UTIL_H

#include "../slang-support.h"
#include "../options.h"

#include "../../source/core/slang-smart-pointer.h"

namespace renderer_test {

// Base class for CUDA resources. This includes textures but also
// memory allocations
class CUDAResource : public RefObject
{
public:
};

struct CUDAComputeUtil
{
    // Define here, so we don't need to include the CUDA header
    typedef size_t CUdeviceptr;

        /// NOTE! MUST match up to definitions in the CUDA prelude
    struct ByteAddressBuffer
    {
        CUdeviceptr data;
        size_t sizeInBytes;
    };
    struct StructuredBuffer
    {
        CUdeviceptr data;
        size_t count;
    };
    struct Array
    {
        CUdeviceptr data;
        size_t count;
    };

    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;
    };

    static SlangResult parseFeature(const Slang::UnownedStringSlice& feature, bool& outResult);

    static bool hasFeature(const Slang::UnownedStringSlice& feature);

    static SlangResult createTextureResource(const ShaderInputLayoutEntry& srcEntry, slang::TypeLayoutReflection* typeLayout, RefPtr<CUDAResource>& outResource);

    static SlangResult execute(const ShaderCompilerUtil::OutputAndLayout& outputAndLayout, const uint32_t dispatchSize[3], Context& outContext);

    static bool canCreateDevice();
};


} // renderer_test

#endif //CPU_MEMORY_BINDING_H