VPP  0.7
A high-level modern C++ API for Vulkan
vppLangIntInOut.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 
38 class Shader
39 {
40 public:
53  void DebugCodeDump();
54 
94  template< class ValueT >
95  void DebugProbe (
96  const ValueT& value,
97  const IVec2& coords,
98  const VkExtent3D& extent );
99 };
100 
101 // -----------------------------------------------------------------------------
125 {
128 
131 
134 
137 
143  void setClipPlanes ( int n );
144 
150  void setCullPlanes ( int n );
151 
157  void getClipPlanes();
158 
164  void getCullPlanes();
165 };
166 
167 // -----------------------------------------------------------------------------
168 
180 class VertexShader : public Shader
181 {
182 public:
185 
188 
191 };
192 
193 // -----------------------------------------------------------------------------
222 class TessControlShader : public Shader
223 {
224 public:
227 
230 
233 
236 
239 
242 
245 };
246 
247 // -----------------------------------------------------------------------------
259 class TessEvalShader : public Shader
260 {
261 public:
264 
267 
270 
283 
286 
289 
292 };
293 
294 // -----------------------------------------------------------------------------
306 class GeometryShader : public Shader
307 {
308 public:
316  void EmitVertex();
317 
321  void EndPrimitive();
322 
325 
334 
337 
340 
344 
347 
355 };
356 
357 // -----------------------------------------------------------------------------
369 class FragmentShader : public Shader
370 {
371 public:
373  void Kill();
374 
376  void EarlyTest();
377 
386  template< class ValueT >
387  void DebugProbe ( const ValueT& value );
388 
391 
394 
397 
400 
403 
406 
409 
412 
415 
418 };
419 
420 // -----------------------------------------------------------------------------
429 class ComputeShader : public Shader
430 {
431 public:
434 
437 
440 
443 
446 };
447 
448 // -----------------------------------------------------------------------------
487 template< class ValueT, class OutputShader, class InputShader >
489 {
490 public:
492  ioVariable();
493 };
494 
495 // -----------------------------------------------------------------------------
532 template< class StructT, class OutputShader, class InputShader >
534 {
535 public:
537  ioStructure();
538 };
539 
540 // -----------------------------------------------------------------------------
594 template< class BindingPointT >
595 class Input
596 {
597 public:
601  Input ( const BindingPointT& var );
602 
616  Input ( const BindingPointT& var, std::uint32_t interpFlags );
617 
624  template< typename MemberT >
625  auto operator[]( MemberT StructT::* pMember ) const;
626 
641  auto operator[]( const Int& index );
642 
644  auto operator[]( const UInt& index );
645 
647  auto operator[]( int index );
648 
650  auto operator[]( unsigned int index );
651 
653  Int Size() const;
654 
656  int size() const;
657 
658  // te 3 tylko dla ioVariable< ValueT >
659  ValueT InterpolateAtCentroid();
660  ValueT InterpolateAtSample ( const Int& sample );
661  ValueT InterpolateAtOffset ( const Vec2& offset );
662 };
663 
664 // -----------------------------------------------------------------------------
718 template< class BindingPointT >
719 class Output
720 {
721 public:
725  Output ( const BindingPointT& var );
726 
733  template< typename MemberT >
734  auto operator[]( MemberT struct_type::* pMember ) const;
735 
750  auto operator[]( const Int& index );
751 
753  auto operator[]( const UInt& index );
754 
756  auto operator[]( int index );
757 
759  auto operator[]( unsigned int index );
760 
761  // tylko iovariable
762  template< typename RightT >
763  void operator= ( const RightT& rhs );
764 
766  Int Size() const;
767 
769  int size() const;
770 };
771 
772 // -----------------------------------------------------------------------------
773 } // namespace vpp
774 // -----------------------------------------------------------------------------
Vec2 inPointCoord
In: the sub-pixel position of the sample being shaded.
Definition: vppLangIntInOut.hpp:405
Base class for shader interfaces.
Definition: vppLangIntInOut.hpp:38
Int inPrimitiveId
In: primitive index in current set of primitives.
Definition: vppLangIntInOut.hpp:336
void Kill()
Terminates shader execution without writing the fragment.
Geometry shader interface.
Definition: vppLangIntInOut.hpp:306
Bool inHelperInvocation
In: whether the current invocation is a helper invocation.
Definition: vppLangIntInOut.hpp:408
Binding point class for inter-shader communication variable of simple type (scalar, vector or matrix). Place in your pipeline configuration class to declare an inter-shader communication variable.
Definition: vppLangIntInOut.hpp:488
IVec3 inWorkgroupId
The global workgroup that the current invocation is a member of.
Definition: vppLangIntInOut.hpp:433
Fragment shader interface.
Definition: vppLangIntInOut.hpp:369
Bool inFrontFacing
In: true if current pixel belongs to a front-facing primitive.
Definition: vppLangIntInOut.hpp:393
ioVariable()
Constructor - takes no arguments.
Shader (GPU-side) data type for 32-bit unsigned integer values.
Definition: vppLangScalarTypes.hpp:249
Float outTessLevelInner[2]
Out: computed inner tessellation levels.
Definition: vppLangIntInOut.hpp:244
Float outTessLevelOuter[4]
Out: computed outer tessellation levels.
Definition: vppLangIntInOut.hpp:241
void DebugProbe(const ValueT &value, const IVec2 &coords, const VkExtent3D &extent)
Adds a debug probe to dump an expression value during shader execution.
Input(const BindingPointT &var)
Constructs the input point associated with specified binding point (ioVariable or ioStructure)...
Int inLayer
In: the layer index of the primitive that the fragment invocation belongs to.
Definition: vppLangIntInOut.hpp:396
Int inSampleId
In: zero-based index of the sample the invocation corresponds to.
Definition: vppLangIntInOut.hpp:399
The VPP namespace.
Definition: main.hpp:1
Tessellation evaluation shader interface.
Definition: vppLangIntInOut.hpp:259
Output(const BindingPointT &var)
Constructs the output point associated with specified binding point (ioVariable or ioStructure)...
Int Size() const
Returns GPU-side value equal to the array size (number of vertices).
void EarlyTest()
Enables early tests (depth, stencil, etc.) for this shader.
IVec3 inWorkgroupSize
The dimensions of a local workgroup.
Definition: vppLangIntInOut.hpp:445
void setCullPlanes(int n)
Sets the number of additional culling planes.
gl_perVertex outVertex
Out: computed vertex data.
Definition: vppLangIntInOut.hpp:291
Int inInvocationId
In: index of currently computed output patch vertex.
Definition: vppLangIntInOut.hpp:229
Binding point class for inter-shader communication variable of structural type. Place in your pipelin...
Definition: vppLangIntInOut.hpp:533
Int Size() const
Returns GPU-side value equal to the array size (number of vertices).
Auxiliary structure holding basic vertex attributes.
Definition: vppLangIntInOut.hpp:124
Float inTessLevelOuter[4]
In: outer tessellation levels.
Definition: vppLangIntInOut.hpp:285
Int inPatchVertices
In: number of vertices in current input patch (inVertices array size).
Definition: vppLangIntInOut.hpp:266
void getCullPlanes()
Retrieves the number of additional culling planes.
Int inPatchVertices
In: number of vertices in current input patch (inVertices array size).
Definition: vppLangIntInOut.hpp:232
Int inPrimitiveId
In: index of the input patch in currently rendered set of patches.
Definition: vppLangIntInOut.hpp:269
IVec3 inGlobalInvocationId
The location of the current invocation within the global workgroup.
Definition: vppLangIntInOut.hpp:442
int size() const
Returns CPU-side value equal to the array size (number of vertices).
gl_perVertex outVertex
Out: computed vertex data.
Definition: vppLangIntInOut.hpp:339
gl_perVertex outVertices[]
Out: vertices of the resulting patch.
Definition: vppLangIntInOut.hpp:238
Int inPrimitiveId
In: the index of the current primitive.
Definition: vppLangIntInOut.hpp:411
IVec3 inNumWorkgroups
The number of local workgroups that are part of the dispatch that the invocation belongs to...
Definition: vppLangIntInOut.hpp:436
void EndPrimitive()
Finishes the current primitive and starts a new one. No vertex is emitted.
Int inViewportIndex
In: the index of the viewport.
Definition: vppLangIntInOut.hpp:414
gl_perVertex inVertices[]
In: vertices of currently processed primitive.
Definition: vppLangIntInOut.hpp:324
Shader (GPU-side) data type for 2-element 32-bit integer vectors.
Definition: vppLangVectorTypes.hpp:785
Vec4 position
In or Out: Position of the vertex in clip space (after projection).
Definition: vppLangIntInOut.hpp:127
ioStructure()
Constructor - takes no arguments.
Int inPrimitiveId
In: index of the input patch in currently rendered set of patches.
Definition: vppLangIntInOut.hpp:235
void DebugProbe(const ValueT &value)
Creates a debug probe image and writes given value.
Shader (GPU-side) data type for 32-bit floating point values.
Definition: vppLangScalarTypes.hpp:330
Int inInstanceIndex
In: index of current instance.
Definition: vppLangIntInOut.hpp:187
Provides input access to communication variable binding point from shader code.
Definition: vppLangIntInOut.hpp:595
Shader (GPU-side) data type for 2-element 32-bit float vectors.
Definition: vppLangVectorTypes.hpp:561
Vec3 inTessCoord
In: coordinates of currently evaluated point, inside triangular or rectangular domain.
Definition: vppLangIntInOut.hpp:282
Shader (GPU-side) data type for 4-element 32-bit float vectors.
Definition: vppLangVectorTypes.hpp:298
Float clipDistance[]
In or Out: Array of additional clipping planes.
Definition: vppLangIntInOut.hpp:133
Vec2 inSamplePosition
In: zero-based index of the sample the invocation corresponds to.
Definition: vppLangIntInOut.hpp:402
Vertex shader interface.
Definition: vppLangIntInOut.hpp:180
Float pointSize
In or Out: Size of the point primitive.
Definition: vppLangIntInOut.hpp:130
Int outLayer
Out: allows to direct currently processed primitive to specific layer of multi-layer output attachmen...
Definition: vppLangIntInOut.hpp:343
int size() const
Returns CPU-side value equal to the array size (number of vertices).
auto operator[](MemberT StructT::*pMember) const
Provides access to structure members for ioStructure binding points. Provide a pointer to member of y...
Float inTessLevelInner[2]
In: inner tessellation levels.
Definition: vppLangIntInOut.hpp:288
void getClipPlanes()
Retrieves the number of additional clipping planes.
Int outPrimitiveId
Out: allows to pass the primitive id to the fragment shader.
Definition: vppLangIntInOut.hpp:346
Compute shader interface.
Definition: vppLangIntInOut.hpp:429
gl_perVertex inVertices[]
In: vertices of the source patch.
Definition: vppLangIntInOut.hpp:226
IVec3 inLocalInvocationId
The location of the current compute shader invocation within the local workgroup. ...
Definition: vppLangIntInOut.hpp:439
Shader (GPU-side) data type for 32-bit signed integer values.
Definition: vppLangScalarTypes.hpp:167
Int outViewportIndex
Out: allows to direct currently processed primitive to specific viewport.
Definition: vppLangIntInOut.hpp:354
Shader (GPU-side) data type for 3-element 32-bit integer vectors.
Definition: vppLangVectorTypes.hpp:764
void EmitVertex()
Emits one vertex for currently processed primitive and resets the outVertex and output variables to r...
Tessellation control shader interface.
Definition: vppLangIntInOut.hpp:222
auto operator[](MemberT struct_type::*pMember) const
Provides access to structure members for ioStructure binding points. Provide a pointer to member of y...
void setClipPlanes(int n)
Sets the number of additional clipping planes.
Float outFragDepth
Out: the new depth value for all samples covered by the fragment.
Definition: vppLangIntInOut.hpp:417
gl_perVertex inVertices[]
In: vertices of the evaluated patch.
Definition: vppLangIntInOut.hpp:263
Shader (GPU-side) data type for 3-element 32-bit float vectors.
Definition: vppLangVectorTypes.hpp:540
Int inInvocationId
In: index of current geometry shader invocation in case when multiple geometry shader invocations are...
Definition: vppLangIntInOut.hpp:333
gl_perVertex outVertex
Out: computed basic vertex attributes.
Definition: vppLangIntInOut.hpp:190
Shader (GPU-side) data type for boolean values.
Definition: vppLangScalarTypes.hpp:45
void DebugCodeDump()
Enables diagnostic dump of intermediate SPIR-V code for this shader.
Float cullDistance[]
In or Out: Array of additional culling planes.
Definition: vppLangIntInOut.hpp:136
Provides output access to communication variable binding point from shader code.
Definition: vppLangIntInOut.hpp:719
Vec4 inFragCoord
In: current pixel coordinates in the frame buffer.
Definition: vppLangIntInOut.hpp:390
Int inVertexIndex
In: index of current vertex.
Definition: vppLangIntInOut.hpp:184