VPP  0.8
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:
42  const Device& device() const;
43 
56  void DebugCodeDump();
57 
97  template< class ValueT >
98  void DebugProbe (
99  const ValueT& value,
100  const IVec2& coords,
101  const VkExtent3D& extent );
102 };
103 
104 // -----------------------------------------------------------------------------
128 {
131 
134 
137 
140 
146  void setClipPlanes ( int n );
147 
153  void setCullPlanes ( int n );
154 
160  void getClipPlanes();
161 
167  void getCullPlanes();
168 };
169 
170 // -----------------------------------------------------------------------------
171 
183 class VertexShader : public Shader
184 {
185 public:
188 
191 
194 };
195 
196 // -----------------------------------------------------------------------------
225 class TessControlShader : public Shader
226 {
227 public:
230 
233 
236 
239 
242 
245 
248 };
249 
250 // -----------------------------------------------------------------------------
262 class TessEvalShader : public Shader
263 {
264 public:
267 
270 
273 
286 
289 
292 
295 };
296 
297 // -----------------------------------------------------------------------------
309 class GeometryShader : public Shader
310 {
311 public:
319  void EmitVertex();
320 
324  void EndPrimitive();
325 
328 
337 
340 
343 
347 
350 
358 };
359 
360 // -----------------------------------------------------------------------------
372 class FragmentShader : public Shader
373 {
374 public:
376  void Kill();
377 
379  void EarlyTest();
380 
389  template< class ValueT >
390  void DebugProbe ( const ValueT& value );
391 
394 
397 
400 
403 
406 
409 
412 
415 
418 
421 };
422 
423 // -----------------------------------------------------------------------------
432 class ComputeShader : public Shader
433 {
434 public:
437 
440 
443 
446 
449 
451  const SLocalGroupSize& localGroupSize() const;
452 
454  unsigned int getTotalWorkgroupMemory() const;
455 
457  unsigned int getFreeWorkgroupMemory() const;
458 };
459 
460 // -----------------------------------------------------------------------------
499 template< class ValueT, class OutputShader, class InputShader >
501 {
502 public:
504  ioVariable();
505 };
506 
507 // -----------------------------------------------------------------------------
544 template< class StructT, class OutputShader, class InputShader >
546 {
547 public:
549  ioStructure();
550 };
551 
552 // -----------------------------------------------------------------------------
606 template< class BindingPointT >
607 class Input
608 {
609 public:
613  Input ( const BindingPointT& var );
614 
628  Input ( const BindingPointT& var, std::uint32_t interpFlags );
629 
636  template< typename MemberT >
637  auto operator[]( MemberT StructT::* pMember ) const;
638 
653  auto operator[]( const Int& index );
654 
656  auto operator[]( const UInt& index );
657 
659  auto operator[]( int index );
660 
662  auto operator[]( unsigned int index );
663 
665  Int Size() const;
666 
668  int size() const;
669 
670  // te 3 tylko dla ioVariable< ValueT >
671  ValueT InterpolateAtCentroid();
672  ValueT InterpolateAtSample ( const Int& sample );
673  ValueT InterpolateAtOffset ( const Vec2& offset );
674 };
675 
676 // -----------------------------------------------------------------------------
730 template< class BindingPointT >
731 class Output
732 {
733 public:
737  Output ( const BindingPointT& var );
738 
745  template< typename MemberT >
746  auto operator[]( MemberT struct_type::* pMember ) const;
747 
762  auto operator[]( const Int& index );
763 
765  auto operator[]( const UInt& index );
766 
768  auto operator[]( int index );
769 
771  auto operator[]( unsigned int index );
772 
773  // tylko iovariable
774  template< typename RightT >
775  void operator= ( const RightT& rhs );
776 
778  Int Size() const;
779 
781  int size() const;
782 };
783 
784 // -----------------------------------------------------------------------------
785 } // namespace vpp
786 // -----------------------------------------------------------------------------
Vec2 inPointCoord
In: the sub-pixel position of the sample being shaded.
Definition: vppLangIntInOut.hpp:408
Base class for shader interfaces.
Definition: vppLangIntInOut.hpp:38
Represents logical rendering device.
Definition: vppDevice.hpp:49
Int inPrimitiveId
In: primitive index in current set of primitives.
Definition: vppLangIntInOut.hpp:339
void Kill()
Terminates shader execution without writing the fragment.
Geometry shader interface.
Definition: vppLangIntInOut.hpp:309
Bool inHelperInvocation
In: whether the current invocation is a helper invocation.
Definition: vppLangIntInOut.hpp:411
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:500
IVec3 inWorkgroupId
The global workgroup that the current invocation is a member of.
Definition: vppLangIntInOut.hpp:436
Fragment shader interface.
Definition: vppLangIntInOut.hpp:372
Bool inFrontFacing
In: true if current pixel belongs to a front-facing primitive.
Definition: vppLangIntInOut.hpp:396
ioVariable()
Constructor - takes no arguments.
const Device & device() const
Retrieves the device the shader is currently compiled for.
Shader (GPU-side) data type for 32-bit unsigned integer values.
Definition: vppLangScalarTypes.hpp:271
Float outTessLevelInner[2]
Out: computed inner tessellation levels.
Definition: vppLangIntInOut.hpp:247
Float outTessLevelOuter[4]
Out: computed outer tessellation levels.
Definition: vppLangIntInOut.hpp:244
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:399
Int inSampleId
In: zero-based index of the sample the invocation corresponds to.
Definition: vppLangIntInOut.hpp:402
The VPP namespace.
Definition: main.hpp:1
Tessellation evaluation shader interface.
Definition: vppLangIntInOut.hpp:262
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 local workgroup.
Definition: vppLangIntInOut.hpp:448
void setCullPlanes(int n)
Sets the number of additional culling planes.
gl_perVertex outVertex
Out: computed vertex data.
Definition: vppLangIntInOut.hpp:294
Int inInvocationId
In: index of currently computed output patch vertex.
Definition: vppLangIntInOut.hpp:232
Binding point class for inter-shader communication variable of structural type. Place in your pipelin...
Definition: vppLangIntInOut.hpp:545
Int Size() const
Returns GPU-side value equal to the array size (number of vertices).
Auxiliary structure holding basic vertex attributes.
Definition: vppLangIntInOut.hpp:127
const SLocalGroupSize & localGroupSize() const
Returns CPU-side structure specifying the dimensions of local workgroup.
Float inTessLevelOuter[4]
In: outer tessellation levels.
Definition: vppLangIntInOut.hpp:288
Int inPatchVertices
In: number of vertices in current input patch (inVertices array size).
Definition: vppLangIntInOut.hpp:269
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:235
Int inPrimitiveId
In: index of the input patch in currently rendered set of patches.
Definition: vppLangIntInOut.hpp:272
IVec3 inGlobalInvocationId
The location of the current invocation within the global workgroup.
Definition: vppLangIntInOut.hpp:445
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:342
gl_perVertex outVertices[]
Out: vertices of the resulting patch.
Definition: vppLangIntInOut.hpp:241
Int inPrimitiveId
In: the index of the current primitive.
Definition: vppLangIntInOut.hpp:414
IVec3 inNumWorkgroups
The number of local workgroups that are part of the dispatch that the invocation belongs to...
Definition: vppLangIntInOut.hpp:439
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:417
gl_perVertex inVertices[]
In: vertices of currently processed primitive.
Definition: vppLangIntInOut.hpp:327
Shader (GPU-side) data type for 2-element 32-bit integer vectors.
Definition: vppLangVectorTypes.hpp:817
Vec4 position
In or Out: Position of the vertex in clip space (after projection).
Definition: vppLangIntInOut.hpp:130
ioStructure()
Constructor - takes no arguments.
Int inPrimitiveId
In: index of the input patch in currently rendered set of patches.
Definition: vppLangIntInOut.hpp:238
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:356
Int inInstanceIndex
In: index of current instance.
Definition: vppLangIntInOut.hpp:190
unsigned int getFreeWorkgroupMemory() const
Retrieves available size (in bytes) of the workgroup-scoped shared memory.
Provides input access to communication variable binding point from shader code.
Definition: vppLangIntInOut.hpp:607
Shader (GPU-side) data type for 2-element 32-bit float vectors.
Definition: vppLangVectorTypes.hpp:593
Vec3 inTessCoord
In: coordinates of currently evaluated point, inside triangular or rectangular domain.
Definition: vppLangIntInOut.hpp:285
Shader (GPU-side) data type for 4-element 32-bit float vectors.
Definition: vppLangVectorTypes.hpp:314
Float clipDistance[]
In or Out: Array of additional clipping planes.
Definition: vppLangIntInOut.hpp:136
Vec2 inSamplePosition
In: zero-based index of the sample the invocation corresponds to.
Definition: vppLangIntInOut.hpp:405
Vertex shader interface.
Definition: vppLangIntInOut.hpp:183
Float pointSize
In or Out: Size of the point primitive.
Definition: vppLangIntInOut.hpp:133
Int outLayer
Out: allows to direct currently processed primitive to specific layer of multi-layer output attachmen...
Definition: vppLangIntInOut.hpp:346
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:291
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:349
Compute shader interface.
Definition: vppLangIntInOut.hpp:432
gl_perVertex inVertices[]
In: vertices of the source patch.
Definition: vppLangIntInOut.hpp:229
IVec3 inLocalInvocationId
The location of the current compute shader invocation within the local workgroup. ...
Definition: vppLangIntInOut.hpp:442
Shader (GPU-side) data type for 32-bit signed integer values.
Definition: vppLangScalarTypes.hpp:162
Int outViewportIndex
Out: allows to direct currently processed primitive to specific viewport.
Definition: vppLangIntInOut.hpp:357
Shader (GPU-side) data type for 3-element 32-bit integer vectors.
Definition: vppLangVectorTypes.hpp:796
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:225
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:420
gl_perVertex inVertices[]
In: vertices of the evaluated patch.
Definition: vppLangIntInOut.hpp:266
unsigned int getTotalWorkgroupMemory() const
Retrieves total size (in bytes) of the workgroup-scoped shared memory.
Shader (GPU-side) data type for 3-element 32-bit float vectors.
Definition: vppLangVectorTypes.hpp:572
Int inInvocationId
In: index of current geometry shader invocation in case when multiple geometry shader invocations are...
Definition: vppLangIntInOut.hpp:336
gl_perVertex outVertex
Out: computed basic vertex attributes.
Definition: vppLangIntInOut.hpp:193
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:139
Provides output access to communication variable binding point from shader code.
Definition: vppLangIntInOut.hpp:731
Vec4 inFragCoord
In: current pixel coordinates in the frame buffer.
Definition: vppLangIntInOut.hpp:393
Int inVertexIndex
In: index of current vertex.
Definition: vppLangIntInOut.hpp:187