blob: a1c087549a4c8b9e7400644c3b2c5a857c6aa25d [file] [log] [blame]
Austin Engcc2516a2023-10-17 20:57:54 +00001// Copyright 2022 The Dawn & Tint Authors
Ryan Harrisondbc13af2022-02-21 15:19:07 +00002//
Austin Engcc2516a2023-10-17 20:57:54 +00003// Redistribution and use in source and binary forms, with or without
4// modification, are permitted provided that the following conditions are met:
Ryan Harrisondbc13af2022-02-21 15:19:07 +00005//
Austin Engcc2516a2023-10-17 20:57:54 +00006// 1. Redistributions of source code must retain the above copyright notice, this
7// list of conditions and the following disclaimer.
Ryan Harrisondbc13af2022-02-21 15:19:07 +00008//
Austin Engcc2516a2023-10-17 20:57:54 +00009// 2. Redistributions in binary form must reproduce the above copyright notice,
10// this list of conditions and the following disclaimer in the documentation
11// and/or other materials provided with the distribution.
12//
13// 3. Neither the name of the copyright holder nor the names of its
14// contributors may be used to endorse or promote products derived from
15// this software without specific prior written permission.
16//
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Ryan Harrisondbc13af2022-02-21 15:19:07 +000027
dan sinclair99181d82023-07-20 01:14:15 +000028#ifndef SRC_TINT_LANG_WGSL_AST_INTERPOLATE_ATTRIBUTE_H_
29#define SRC_TINT_LANG_WGSL_AST_INTERPOLATE_ATTRIBUTE_H_
Ryan Harrisondbc13af2022-02-21 15:19:07 +000030
Ryan Harrisondbc13af2022-02-21 15:19:07 +000031#include <string>
32
dan sinclair99181d82023-07-20 01:14:15 +000033#include "src/tint/lang/wgsl/ast/attribute.h"
Ben Claytonf0b4dbb2023-02-21 21:05:28 +000034
35// Forward declarations
36namespace tint::ast {
37class Expression;
38}
Ryan Harrisondbc13af2022-02-21 15:19:07 +000039
dan sinclair34323ac2022-04-07 18:39:35 +000040namespace tint::ast {
Ryan Harrisondbc13af2022-02-21 15:19:07 +000041
Ryan Harrisondbc13af2022-02-21 15:19:07 +000042/// An interpolate attribute
dan sinclairbae54e72023-07-28 15:01:54 +000043class InterpolateAttribute final : public Castable<InterpolateAttribute, Attribute> {
dan sinclair41e4d9a2022-05-01 14:40:55 +000044 public:
45 /// Create an interpolate attribute.
46 /// @param pid the identifier of the program that owns this node
Ben Clayton4a92a3c2022-07-18 20:50:02 +000047 /// @param nid the unique node identifier
dan sinclair41e4d9a2022-05-01 14:40:55 +000048 /// @param src the source of this node
49 /// @param type the interpolation type
50 /// @param sampling the interpolation sampling
dan sinclair637a2fe2023-07-24 21:11:41 +000051 InterpolateAttribute(GenerationID pid,
Ben Clayton4a92a3c2022-07-18 20:50:02 +000052 NodeID nid,
dan sinclair41e4d9a2022-05-01 14:40:55 +000053 const Source& src,
Ben Claytonf0b4dbb2023-02-21 21:05:28 +000054 const Expression* type,
55 const Expression* sampling);
dan sinclair41e4d9a2022-05-01 14:40:55 +000056 ~InterpolateAttribute() override;
Ryan Harrisondbc13af2022-02-21 15:19:07 +000057
dan sinclair41e4d9a2022-05-01 14:40:55 +000058 /// @returns the WGSL name for the attribute
59 std::string Name() const override;
Ryan Harrisondbc13af2022-02-21 15:19:07 +000060
dan sinclair41e4d9a2022-05-01 14:40:55 +000061 /// Clones this node and all transitive child nodes using the `CloneContext`
62 /// `ctx`.
63 /// @param ctx the clone context
64 /// @return the newly cloned node
Ben Claytonae18c412023-07-29 13:00:40 +000065 const InterpolateAttribute* Clone(CloneContext& ctx) const override;
Ryan Harrisondbc13af2022-02-21 15:19:07 +000066
dan sinclair41e4d9a2022-05-01 14:40:55 +000067 /// The interpolation type
Ben Claytonf0b4dbb2023-02-21 21:05:28 +000068 const Expression* const type;
Ryan Harrisondbc13af2022-02-21 15:19:07 +000069
dan sinclair41e4d9a2022-05-01 14:40:55 +000070 /// The interpolation sampling
Ben Claytonf0b4dbb2023-02-21 21:05:28 +000071 const Expression* const sampling;
Ryan Harrisondbc13af2022-02-21 15:19:07 +000072};
73
dan sinclair34323ac2022-04-07 18:39:35 +000074} // namespace tint::ast
Ryan Harrisondbc13af2022-02-21 15:19:07 +000075
dan sinclair99181d82023-07-20 01:14:15 +000076#endif // SRC_TINT_LANG_WGSL_AST_INTERPOLATE_ATTRIBUTE_H_