• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//
2// Copyright 2018 The ANGLE Project Authors. All rights reserved.
3// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6// ImageCopy.frag: Copy parts of an image to another.
7
8#version 450 core
9
10#extension GL_GOOGLE_include_directive : require
11#extension GL_EXT_samplerless_texture_functions : require
12
13#define MAKE_SRC_RESOURCE(prefix, type) prefix ## type
14
15#if SrcIsFloat
16#define SRC_RESOURCE(type) type
17#define SrcType vec4
18#elif SrcIsSint
19#define SRC_RESOURCE(type) MAKE_SRC_RESOURCE(i, type)
20#define SrcType ivec4
21#elif SrcIsUint
22#define SRC_RESOURCE(type) MAKE_SRC_RESOURCE(u, type)
23#define SrcType uvec4
24#else
25#error "Not all source formats are accounted for"
26#endif
27
28#if SrcIs2D
29#define SRC_RESOURCE_NAME texture2D
30#elif SrcIs2DArray
31#define SRC_RESOURCE_NAME texture2DArray
32#elif SrcIs3D
33#define SRC_RESOURCE_NAME texture3D
34#elif SrcIsYUV
35#define SRC_RESOURCE_NAME sampler2D
36#elif SrcIs2DMS
37#define SRC_RESOURCE_NAME texture2DMS
38#else
39#error "Not all source types are accounted for"
40#endif
41
42#if DstIsFloat
43#define DstType vec4
44#elif DstIsSint
45#define DstType ivec4
46#elif DstIsUint
47#define DstType uvec4
48#else
49#error "Not all destination formats are accounted for"
50#endif
51
52layout(set = 0, binding = 0) uniform SRC_RESOURCE(SRC_RESOURCE_NAME) src;
53layout(location = 0) out DstType dst;
54
55#include "ImageCopy.inc"
56
57void main()
58{
59    ivec2 srcSubImageCoords = transformImageCoords(ivec2(gl_FragCoord.xy));
60
61#if SrcIs2D
62    SrcType srcValue = texelFetch(src, params.srcOffset + srcSubImageCoords, params.srcMip);
63#elif SrcIs2DArray || SrcIs3D
64    SrcType srcValue = texelFetch(src, ivec3(params.srcOffset + srcSubImageCoords, params.srcLayer), params.srcMip);
65#else
66#error "Not all source types are accounted for"
67#endif
68
69    dst = transformSrcValue(srcValue);
70}
71