1#version 420 2 3// Need this extension to permit passing a formatless readonly image to a helper function. 4#extension GL_EXT_shader_image_load_formatted : require 5 6readonly coherent uniform layout(set = 0, binding = 0) image2D image1; 7readonly uniform layout(set = 0, binding = 2) image2D image2; 8writeonly coherent uniform layout(set = 0, binding = 1, rgba32f) image2D image3; 9writeonly uniform layout(set = 0, binding = 3, rgba16f) image2D image4; 10 11flat in layout(location = 0) ivec2 in_coords; 12out layout(location = 0) vec4 out_color; 13 14vec4 image_load(readonly coherent image2D image, ivec2 coords) 15{ 16 return imageLoad(image, in_coords); 17} 18 19void image_store(writeonly coherent image2D image, ivec2 coords, vec4 data) 20{ 21 imageStore(image, in_coords, data); 22} 23 24void main() 25{ 26 vec4 read1 = image_load(image1, in_coords); 27 vec4 read2 = image_load(image2, in_coords); 28 29 image_store(image3, in_coords, read1*0.5); 30 image_store(image4, in_coords, read2*2.0); 31 32 out_color = vec4(0.0); 33} 34