summaryrefslogtreecommitdiffstats
path: root/tests/manual/buffercapture-qml/ComputeMaterial.qml
blob: a8fcaddaf9f3abb9c0d5ada9d26d5c30a37ff774 (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
// Copyright (C) 2017 Juan José Casafranca.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import Qt3D.Core 2.9
import Qt3D.Render 2.9

Material {
    property Buffer dataBuffer;
    property int inputSize;

    parameters: [
        Parameter { name: "inputSize"; value: inputSize}
    ]

    ShaderProgram {
        id: computeShaderGL43
        computeShaderCode: loadSource("qrc:/gl43/bufferSetter.comp")
    }

    ShaderProgram {
        id: computeShaderGL45
        computeShaderCode: loadSource("qrc:/gl45/bufferSetter.comp")
    }

    effect: Effect {
        techniques: [
            Technique {
                renderPasses: [
                    RenderPass {
                        shaderProgram: computeShaderGL43
                        // We set the buffer as the parameter data
                        parameters: [
                            Parameter { name: "input"; value: dataBuffer }
                        ]
                    }
                ]
                filterKeys: [
                    FilterKey { name: "type"; value: "compute" }
                ]
                graphicsApiFilter {
                    api: GraphicsApiFilter.OpenGL
                    profile: GraphicsApiFilter.CoreProfile
                    majorVersion: 4
                    minorVersion: 3
                }
            },
            Technique {
                renderPasses: [
                    RenderPass {
                        shaderProgram: computeShaderGL45
                        // We set the buffer as the parameter data
                        parameters: [
                            Parameter { name: "input"; value: dataBuffer }
                        ]
                    }
                ]
                filterKeys: [
                    FilterKey { name: "type"; value: "compute" }
                ]
                graphicsApiFilter {
                    api: GraphicsApiFilter.RHI
                    profile: GraphicsApiFilter.NoProfile
                    majorVersion: 1
                    minorVersion: 0
                }
            }
        ] // techniques
    }
}