1// 2// Copyright 2024 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// ImageCopyFloat.frag: Copy parts of a YUV or multisampled 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 SrcIsFloat 1 14#define DstIsFloat 1 15#define SrcType vec4 16#define DstType vec4 17 18#if SrcIsYUV 19#define SRC_RESOURCE_NAME sampler2D 20#elif SrcIs2DMS 21#define SRC_RESOURCE_NAME texture2DMS 22#else 23#error "Not all source types are accounted for" 24#endif 25 26layout(set = 0, binding = 0) uniform SRC_RESOURCE_NAME src; 27layout(location = 0) out DstType dst; 28 29#include "ImageCopy.inc" 30 31void main() 32{ 33 ivec2 srcSubImageCoords = transformImageCoords(ivec2(gl_FragCoord.xy)); 34 35#if SrcIsYUV 36 SrcType srcValue = texture( 37 src, vec2(params.srcOffset + srcSubImageCoords) / textureSize(src, 0), params.srcMip); 38#elif SrcIs2DMS 39 SrcType srcValue = SrcType(0); 40 for (int i = 0; i < params.srcSampleCount; i++) 41 { 42 srcValue += texelFetch(src, ivec2(params.srcOffset + srcSubImageCoords), i); 43 } 44 srcValue /= params.srcSampleCount; 45#else 46#error "Not all source types are accounted for" 47#endif 48 49 dst = transformSrcValue(srcValue); 50} 51