Hash :
8f367854
Author :
Date :
2024-10-13T13:45:17
Vulkan: Refactor ImageCopy shader - Refactor common shader code into "ImageCopy.inc" - Add ImageCopyFloat shader that supports only float src and dst formats - Perform YUV and multisampled image copies with ImageCopyFloat Bug: angleproject:372059358 Change-Id: I34bbaf49f98920494d9ed9e1fd290b413a89ea13 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5927276 Commit-Queue: mohan maiya <m.maiya@samsung.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
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
//
// Copyright 2018 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ImageCopy.frag: Copy parts of an image to another.
#version 450 core
#extension GL_GOOGLE_include_directive : require
#extension GL_EXT_samplerless_texture_functions : require
#define MAKE_SRC_RESOURCE(prefix, type) prefix ## type
#if SrcIsFloat
#define SRC_RESOURCE(type) type
#define SrcType vec4
#elif SrcIsSint
#define SRC_RESOURCE(type) MAKE_SRC_RESOURCE(i, type)
#define SrcType ivec4
#elif SrcIsUint
#define SRC_RESOURCE(type) MAKE_SRC_RESOURCE(u, type)
#define SrcType uvec4
#else
#error "Not all source formats are accounted for"
#endif
#if SrcIs2D
#define SRC_RESOURCE_NAME texture2D
#elif SrcIs2DArray
#define SRC_RESOURCE_NAME texture2DArray
#elif SrcIs3D
#define SRC_RESOURCE_NAME texture3D
#elif SrcIsYUV
#define SRC_RESOURCE_NAME sampler2D
#elif SrcIs2DMS
#define SRC_RESOURCE_NAME texture2DMS
#else
#error "Not all source types are accounted for"
#endif
#if DstIsFloat
#define DstType vec4
#elif DstIsSint
#define DstType ivec4
#elif DstIsUint
#define DstType uvec4
#else
#error "Not all destination formats are accounted for"
#endif
layout(set = 0, binding = 0) uniform SRC_RESOURCE(SRC_RESOURCE_NAME) src;
layout(location = 0) out DstType dst;
#include "ImageCopy.inc"
void main()
{
ivec2 srcSubImageCoords = transformImageCoords(ivec2(gl_FragCoord.xy));
#if SrcIs2D
SrcType srcValue = texelFetch(src, params.srcOffset + srcSubImageCoords, params.srcMip);
#elif SrcIs2DArray || SrcIs3D
SrcType srcValue = texelFetch(src, ivec3(params.srcOffset + srcSubImageCoords, params.srcLayer), params.srcMip);
#else
#error "Not all source types are accounted for"
#endif
dst = transformSrcValue(srcValue);
}