summaryrefslogtreecommitdiff
path: root/tools/render-test/shader-input-layout.h
blob: c4c3d9d8ce308c92e5ef5a77dc6ec6b7444d9703 (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
69
70
71
72
#ifndef SLANG_TEST_SHADER_INPUT_LAYOUT_H
#define SLANG_TEST_SHADER_INPUT_LAYOUT_H

#include "core/basic.h"

namespace renderer_test
{
    enum class ShaderInputType
    {
        Buffer, Texture, Sampler, CombinedTextureSampler
    };
    enum class InputTextureContent
    {
        Zero, One, ChessBoard, Gradient
    };
    struct InputTextureDesc
    {
        int dimension = 2;
        int arrayLength = 0;
        bool isCube = false;
        bool isDepthTexture = false;
        bool isRWTexture = false;
        int size = 4;
        InputTextureContent content = InputTextureContent::One;
    };
    enum class InputBufferType
    {
        ConstantBuffer, StorageBuffer
    };
    struct InputBufferDesc
    {
        InputBufferType type = InputBufferType::ConstantBuffer;
        int stride = 0; // stride == 0 indicates an unstructured buffer.
    };
    struct InputSamplerDesc
    {
        bool isCompareSampler = false;
    };
    class ShaderInputLayoutEntry
    {
    public:
        ShaderInputType type;
        Slang::List<unsigned int> bufferData;
        InputTextureDesc textureDesc;
        InputBufferDesc bufferDesc;
        InputSamplerDesc samplerDesc;
        bool isOutput = false;
        int hlslBinding = -1;
        Slang::List<int> glslBinding;
       
    };

    struct TextureData
    {
        Slang::List<Slang::List<unsigned int>> dataBuffer;
        int textureSize;
        int mipLevels;
        int arraySize;
    };
    void generateTextureData(TextureData & output, const InputTextureDesc & desc);

    class ShaderInputLayout
    {
    public:
        Slang::List<ShaderInputLayoutEntry> entries;
        Slang::List<Slang::String> globalTypeArguments;
        int numRenderTargets = 1;
        void Parse(const char * source);
    };
}

#endif