1 // Copyright 2020 The Tint Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "src/ast/depth_texture.h"
16
17 #include "src/program_builder.h"
18
19 TINT_INSTANTIATE_TYPEINFO(tint::ast::DepthTexture);
20
21 namespace tint {
22 namespace ast {
23 namespace {
24
IsValidDepthDimension(TextureDimension dim)25 bool IsValidDepthDimension(TextureDimension dim) {
26 return dim == TextureDimension::k2d || dim == TextureDimension::k2dArray ||
27 dim == TextureDimension::kCube || dim == TextureDimension::kCubeArray;
28 }
29
30 } // namespace
31
DepthTexture(ProgramID pid,const Source & src,TextureDimension d)32 DepthTexture::DepthTexture(ProgramID pid, const Source& src, TextureDimension d)
33 : Base(pid, src, d) {
34 TINT_ASSERT(AST, IsValidDepthDimension(dim));
35 }
36
37 DepthTexture::DepthTexture(DepthTexture&&) = default;
38
39 DepthTexture::~DepthTexture() = default;
40
FriendlyName(const SymbolTable &) const41 std::string DepthTexture::FriendlyName(const SymbolTable&) const {
42 std::ostringstream out;
43 out << "texture_depth_" << dim;
44 return out.str();
45 }
46
Clone(CloneContext * ctx) const47 const DepthTexture* DepthTexture::Clone(CloneContext* ctx) const {
48 auto src = ctx->Clone(source);
49 return ctx->dst->create<DepthTexture>(src, dim);
50 }
51
52 } // namespace ast
53 } // namespace tint
54