VPP  0.7
A high-level modern C++ API for Vulkan
vppLangImgFun.hpp
1 /*
2  Copyright 2016-2018 SOFT-ERG, Przemek Kuczmierczyk (www.softerg.com)
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without modification,
6  are permitted provided that the following conditions are met:
7 
8  1. Redistributions of source code must retain the above copyright notice,
9  this list of conditions and the following disclaimer.
10 
11  2. Redistributions in binary form must reproduce the above copyright notice,
12  this list of conditions and the following disclaimer in the documentation
13  and/or other materials provided with the distribution.
14 
15  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
17  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
22  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
24  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 
27 // -----------------------------------------------------------------------------
28 namespace vpp {
29 // -----------------------------------------------------------------------------
30 
32 {
33  typedef const SGatherOffsets& rvalue_type;
34  int offsets [ 4 ][ 2 ];
35 };
36 
37 // -----------------------------------------------------------------------------
38 
39 /*
40  FIXME wywalic
41 
42  ktore co zwracaja
43 
44  ioImage TRImage
45  inSampler TRSampler
46  inConstSampler TRSampler
47  inTexture TRTexture
48  inSampledTexture TRSampledTexture
49  inConstSampledTexture TRSampledTexture
50  inTextureBuffer TRSampledTexture
51  ioImageBuffer TRImage
52  inAttachment TRInput
53 
54 */
55 
56 // -----------------------------------------------------------------------------
68 template< class TextureT, class SamplerT >
69 auto MakeSampledTexture ( const TextureT& texture, const SamplerT& sampler );
70 
71 // -----------------------------------------------------------------------------
81 template< class TextureT >
82 auto ExtractSampledTexture ( const TextureT& texture );
83 
84 // -----------------------------------------------------------------------------
96 template< class ImageT >
97 auto ImageSize ( const ImageT& image );
98 
99 // -----------------------------------------------------------------------------
112 template< class ImageT, class LodT >
113 auto TextureSize ( const ImageT& image, const Int& lod );
114 
115 // -----------------------------------------------------------------------------
124 template< class ImageT >
125 Int ImageQuerySamples ( const ImageT& image );
126 
127 // -----------------------------------------------------------------------------
135 template< class ImageT >
136 Int ImageQueryLevels ( const ImageT& image );
137 
138 // -----------------------------------------------------------------------------
152 template< class ImageT, class CoordsT >
153 Vec2 TextureQueryLod ( const ImageT& image, const CoordsT& coords );
154 
155 // -----------------------------------------------------------------------------
171 template< class ImageT >
172 auto SubpassLoad ( const ImageT& image );
173 
174 // -----------------------------------------------------------------------------
191 template< class ImageT >
192 auto SubpassLoad ( const ImageT& image, const IVec2& coords );
193 
194 // -----------------------------------------------------------------------------
209 template< class ImageT >
210 auto SubpassLoad ( const ImageT& image, const Int& nSample );
211 
212 // -----------------------------------------------------------------------------
231 template< class ImageT >
232 auto SubpassLoad ( const ImageT& image, const IVec2& coords, const Int& nSample );
233 
234 // -----------------------------------------------------------------------------
246 template< class ImageT, class CoordsT >
247 auto ImageLoad ( const ImageT& image, const CoordsT& coords );
248 
249 // -----------------------------------------------------------------------------
263 template< class ImageT, class CoordsT >
264 auto ImageLoad ( const ImageT& image, const CoordsT& coords, const Int& nSample );
265 
266 // -----------------------------------------------------------------------------
281 template< class ImageT, class CoordsT, class ValueT >
282 void ImageStore ( const ImageT& image, const CoordsT& coords, const ValueT& value );
283 
284 // -----------------------------------------------------------------------------
301 template< class ImageT, class CoordsT, class ValueT >
302 void ImageStore ( const ImageT& image, const CoordsT& coords, const ValueT& value, const Int& nSample );
303 
304 // -----------------------------------------------------------------------------
327 template< class TextureT, class CoordsT >
328 auto TexelFetch ( const TextureT& texture, const CoordsT& coords );
329 
330 // -----------------------------------------------------------------------------
355 template< class TextureT, class CoordsT >
356 auto TexelFetch ( const TextureT& texture, const CoordsT& coords, const Int& nSample );
357 
358 // -----------------------------------------------------------------------------
379 template< class TextureT, class CoordsT >
380 auto TexelFetchLod ( const TextureT& texture, const CoordsT& coords, const Int& nLevel );
381 
382 // -----------------------------------------------------------------------------
409 template< class TextureT, class CoordsT, class OffsetT >
410 auto TexelFetchOffset ( const TextureT& texture, const CoordsT& coords, const OffsetT& offset );
411 
412 // -----------------------------------------------------------------------------
441 template< class TextureT, class CoordsT, class OffsetT >
442 auto TexelFetchLodOffset ( const TextureT& texture, const CoordsT& coords, const Int& nLevel, const OffsetT& offset );
443 
444 // -----------------------------------------------------------------------------
478 template< class TextureT, class CoordsT >
479 auto Texture ( const TextureT& texture, const CoordsT& coords );
480 
481 // -----------------------------------------------------------------------------
494 template< class TextureT, class CoordsT >
495 auto Texture ( const TextureT& texture, const CoordsT& coords, const Float& bias );
496 
497 // -----------------------------------------------------------------------------
510 template< class TextureT, class CoordsT, class OffsetT >
511 auto Texture ( const TextureT& texture, const CoordsT& coords, const OffsetT& offset );
512 
513 // -----------------------------------------------------------------------------
531 template< class TextureT, class CoordsT, class GradT >
532 auto Texture ( const TextureT& texture, const CoordsT& coords, const GradT& gradX, const GradT& gradY );
533 
534 // -----------------------------------------------------------------------------
553 template< class TextureT, class CoordsT, class OffsetT, class GradT >
554 auto Texture ( const TextureT& texture, const CoordsT& coords, const OffsetT& offset, const GradT& gradX, const GradT& gradY );
555 
556 // -----------------------------------------------------------------------------
572 template< class TextureT, class CoordsT >
573 auto TextureLod ( const TextureT& texture, const CoordsT& coords, const Float& lod );
574 
575 // -----------------------------------------------------------------------------
592 template< class TextureT, class CoordsT, class OffsetT >
593 auto TextureLod ( const TextureT& texture, const CoordsT& coords, const OffsetT& offset, const Float& lod );
594 
595 // -----------------------------------------------------------------------------
611 template< class TextureT, class CoordsT >
612 auto TextureProj ( const TextureT& texture, const CoordsT& coords );
613 
614 // -----------------------------------------------------------------------------
625 template< class TextureT, class CoordsT >
626 auto TextureProj ( const TextureT& texture, const CoordsT& coords, const Float& bias );
627 
628 // -----------------------------------------------------------------------------
641 template< class TextureT, class CoordsT, class OffsetT >
642 auto TextureProj ( const TextureT& texture, const CoordsT& coords, const OffsetT& offset );
643 
644 // -----------------------------------------------------------------------------
658 template< class TextureT, class CoordsT, class OffsetT >
659 auto TextureProj ( const TextureT& texture, const CoordsT& coords, const OffsetT& offset, const Float& bias );
660 
661 // -----------------------------------------------------------------------------
673 template< class TextureT, class CoordsT, class GradT >
674 auto TextureProj ( const TextureT& texture, const CoordsT& coords, const GradT& gradX, const GradT& gradY );
675 
676 // -----------------------------------------------------------------------------
690 template< class TextureT, class CoordsT, class OffsetT, class GradT >
691 auto TextureProj ( const TextureT& texture, const CoordsT& coords, const OffsetT& offset, const GradT& gradX, const GradT& gradY );
692 
693 // -----------------------------------------------------------------------------
707 template< class TextureT, class CoordsT >
708 auto TextureLodProj ( const TextureT& texture, const CoordsT& coords, const Float& lod );
709 
710 // -----------------------------------------------------------------------------
726 template< class TextureT, class CoordsT, class OffsetT >
727 auto TextureLodProj ( const TextureT& texture, const CoordsT& coords, const OffsetT& offset, const Float& lod );
728 
729 // -----------------------------------------------------------------------------
735 template< class TextureT, class Arg1T, class Arg2T >
736 auto TextureDref ( const TextureT& texture, const Arg1T& arg1, const Arg2T& arg2 );
737 
738 // -----------------------------------------------------------------------------
744 template< class TextureT, class Arg1T, class Arg2T, class Arg3T >
745 auto TextureDref ( const TextureT& texture, const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3 );
746 
747 // -----------------------------------------------------------------------------
753 template< class TextureT, class Arg1T, class Arg2T, class Arg3T, class Arg4T >
754 auto TextureDref ( const TextureT& texture, const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3, const Arg4T& arg4 );
755 
756 // -----------------------------------------------------------------------------
762 template< class TextureT, class Arg1T, class Arg2T, class Arg3T, class Arg4T, class Arg5T >
763 auto TextureDref ( const TextureT& texture, const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3, const Arg4T& arg4, const Arg5T& arg5 );
764 
765 // -----------------------------------------------------------------------------
771 template< class TextureT, class Arg1T, class Arg2T, class Arg3T >
772 auto TextureLodDref ( const TextureT& texture, const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3 );
773 
774 // -----------------------------------------------------------------------------
780 template< class TextureT, class Arg1T, class Arg2T, class Arg3T, class Arg4T >
781 auto TextureLodDref ( const TextureT& texture, const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3, const Arg4T& arg4 );
782 
783 // -----------------------------------------------------------------------------
789 template< class TextureT, class Arg1T, class Arg2T >
790 auto TextureProjDref ( const TextureT& texture, const Arg1T& arg1, const Arg2T& arg2 );
791 
792 // -----------------------------------------------------------------------------
798 template< class TextureT, class Arg1T, class Arg2T, class Arg3T >
799 auto TextureProjDref ( const TextureT& texture, const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3 );
800 
801 // -----------------------------------------------------------------------------
807 template< class TextureT, class Arg1T, class Arg2T, class Arg3T, class Arg4T >
808 auto TextureProjDref ( const TextureT& texture, const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3, const Arg4T& arg4 );
809 
810 // -----------------------------------------------------------------------------
816 template< class TextureT, class Arg1T, class Arg2T, class Arg3T, class Arg4T, class Arg5T >
817 auto TextureProjDref ( const TextureT& texture, const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3, const Arg4T& arg4, const Arg5T& arg5 );
818 
819 // -----------------------------------------------------------------------------
825 template< class TextureT, class Arg1T, class Arg2T, class Arg3T >
826 auto TextureLodProjDref ( const TextureT& texture, const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3 );
827 
828 // -----------------------------------------------------------------------------
834 template< class TextureT, class Arg1T, class Arg2T, class Arg3T, class Arg4T >
835 auto TextureLodProjDref ( const TextureT& texture, const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3, const Arg4T& arg4 );
836 
837 // -----------------------------------------------------------------------------
843 template< class TextureT, class Arg1T, class Arg2T >
844 auto TextureGather ( const TextureT& texture, const Arg1T& arg1, const Arg2T& arg2 );
845 
846 // -----------------------------------------------------------------------------
852 template< class TextureT, class Arg1T, class Arg2T, class Arg3T >
853 auto TextureGather ( const TextureT& texture, const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3 );
854 
855 // -----------------------------------------------------------------------------
861 template< class TextureT, class Arg1T, class Arg2T, class Arg3T >
862 auto TextureGatherDref ( const TextureT& texture, const Arg1T& arg1, const Arg2T& arg2, const Arg3T& arg3 );
863 
864 // -----------------------------------------------------------------------------
865 } // namespace vpp
866 // -----------------------------------------------------------------------------
Vec2 TextureQueryLod(const ImageT &image, const CoordsT &coords)
Retrieves the mipmap level and the level of detail for a hypothetical sampling of image at coordinate...
auto TexelFetchLod(const TextureT &texture, const CoordsT &coords, const Int &nLevel)
Reads a texel from a specified MIP level of texture without sampling.
auto TextureLod(const TextureT &texture, const CoordsT &coords, const Float &lod)
Samples a texel from a texture with explicit MIP levels selection.
auto ImageSize(const ImageT &image)
Retrieves the extent of specified image.
auto TextureLodProj(const TextureT &texture, const CoordsT &coords, const Float &lod)
Samples a texel from a texture with perspective division and explicit MIP levels selection.
The VPP namespace.
Definition: main.hpp:1
auto Texture(const TextureT &texture, const CoordsT &coords)
Samples a texel from a texture.
void ImageStore(const ImageT &image, const CoordsT &coords, const ValueT &value)
Writes a pixel to a storage image.
Int ImageQuerySamples(const ImageT &image)
Retrieves the number of samples per pixel in the image.
auto TextureSize(const ImageT &image, const Int &lod)
Retrieves the extent of specified MIP image level.
auto TextureDref(const TextureT &texture, const Arg1T &arg1, const Arg2T &arg2)
auto TexelFetch(const TextureT &texture, const CoordsT &coords)
Reads a texel from a texture without sampling.
auto TextureLodProjDref(const TextureT &texture, const Arg1T &arg1, const Arg2T &arg2, const Arg3T &arg3)
Shader (GPU-side) data type for 2-element 32-bit integer vectors.
Definition: vppLangVectorTypes.hpp:785
auto TextureGatherDref(const TextureT &texture, const Arg1T &arg1, const Arg2T &arg2, const Arg3T &arg3)
auto TextureProj(const TextureT &texture, const CoordsT &coords)
Samples a texel from a texture with perspective division.
Shader (GPU-side) data type for 32-bit floating point values.
Definition: vppLangScalarTypes.hpp:330
Shader (GPU-side) data type for 2-element 32-bit float vectors.
Definition: vppLangVectorTypes.hpp:561
auto SubpassLoad(const ImageT &image)
Reads a pixel from input attachment.
Shader (GPU-side) data type for 32-bit signed integer values.
Definition: vppLangScalarTypes.hpp:167
Definition: vppLangImgFun.hpp:31
auto TexelFetchLodOffset(const TextureT &texture, const CoordsT &coords, const Int &nLevel, const OffsetT &offset)
Reads a texel from a specified MIP level (with coordinate offset) of texture without sampling...
auto TextureProjDref(const TextureT &texture, const Arg1T &arg1, const Arg2T &arg2)
auto TexelFetchOffset(const TextureT &texture, const CoordsT &coords, const OffsetT &offset)
Reads a texel (with coordinate offset) from a texture without sampling.
auto TextureGather(const TextureT &texture, const Arg1T &arg1, const Arg2T &arg2)
auto ImageLoad(const ImageT &image, const CoordsT &coords)
Reads a pixel from a storage image.
auto TextureLodDref(const TextureT &texture, const Arg1T &arg1, const Arg2T &arg2, const Arg3T &arg3)
auto MakeSampledTexture(const TextureT &texture, const SamplerT &sampler)
Converts texture and sampler pair to combined sampled texture.
Int ImageQueryLevels(const ImageT &image)
Retrieves the number of MIP levels in the image.
auto ExtractSampledTexture(const TextureT &texture)
Extracts the texture part from combined sampled texture.