VPP  0.8
A high-level modern C++ API for Vulkan
vppLangConstructs.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2016-2019 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 
29 // -----------------------------------------------------------------------------
30 namespace vpp {
31 // -----------------------------------------------------------------------------
32 
65 void If ( Bool v );
66 
101 void Else();
102 
109 void Fi();
110 
111 // -----------------------------------------------------------------------------
156 void Do();
157 
170 void While ( Bool v );
171 
183 void Od();
184 
185 // -----------------------------------------------------------------------------
234 void For ( VInt& variable, Int begin, Int end, Int step = 1 );
235 
237 void For ( VUInt& variable, UInt begin, UInt end, UInt step = 1 );
238 
244 void Rof();
245 
246 // -----------------------------------------------------------------------------
247 
260 void Switch ( Int expr );
261 
266 void Case ( int value );
267 
272 void Default();
273 
278 void Break();
279 
284 void EndSwitch();
285 
286 // -----------------------------------------------------------------------------
287 // -----------------------------------------------------------------------------
288 
469 template< class ReturnType, typename... Args >
470 struct Function : public detail::KFunction
471 {
478  Function ( const char* pName = "unnamedFunction" );
479 
484  ReturnType operator()( typename Args::rvalue_type ... args );
485 };
486 
491 template< class ParamType >
492 struct Par
493 {
494 };
495 
502 void Begin();
503 
510 void End();
511 
518 void Return();
519 
524 template< typename ValueT >
525 void Return ( const ValueT& value );
526 
527 // -----------------------------------------------------------------------------
528 
552 template< class CondT, class Arg1T, class Arg2T >
553 auto Select ( const CondT& cond, const Arg1T& argIfTrue, const Arg2T& argIfFalse );
554 
555 // -----------------------------------------------------------------------------
556 
557 enum EMemorySemantics
558 {
559  MSM_NONE,
560  MSM_ACQ,
561  MSM_REL,
562  MSM_ACQREL,
563  MSM_UNIFORM,
564  MSM_SUBGROUP,
565  MSM_WORKGROUP,
566  MSM_IMAGE
567 };
568 
569 // -----------------------------------------------------------------------------
570 
575 void WorkgroupBarrier (
576  EMemorySemantics msClass = MSM_WORKGROUP,
577  EMemorySemantics msSem = MSM_ACQREL );
578 
583 void SubgroupBarrier (
584  EMemorySemantics msClass = MSM_SUBGROUP,
585  EMemorySemantics msSem = MSM_ACQREL );
586 
587 // -----------------------------------------------------------------------------
588 } // namespace vpp
589 // -----------------------------------------------------------------------------
void SubgroupBarrier(EMemorySemantics msClass=MSM_SUBGROUP, EMemorySemantics msSem=MSM_ACQREL)
Creates control and memory barrier affecting threads in a subgroup.
Function(const char *pName="unnamedFunction")
Starts the definition of shader-level function.
void Fi()
Creates the ending clause of the conditional construct.
void Do()
Creates the do clause of the loop construct.
The VPP namespace.
Definition: main.hpp:1
Creates shader-level function.
Definition: vppLangConstructs.hpp:470
void Rof()
Creates the closing clause of the &#39;for&#39; loop construct.
void WorkgroupBarrier(EMemorySemantics msClass=MSM_WORKGROUP, EMemorySemantics msSem=MSM_ACQREL)
Creates control and memory barrier affecting threads in a workgroup.
void Else()
Creates the else clause of the conditional construct.
void Switch(Int expr)
Creates the switch construct.
void EndSwitch()
Creates the closing clause of the switch construct.
void Default()
Creates the default clause of the switch construct.
Defines a function parameter.
Definition: vppLangConstructs.hpp:492
void While(Bool v)
Creates the while clause of the loop construct.
void Case(int value)
Creates the case clause of the switch construct.
void Break()
Creates the break clause of the switch construct.
void End()
Marks the end of function body.
auto Select(const CondT &cond, const Arg1T &argIfTrue, const Arg2T &argIfFalse)
A conditional expression.
void Od()
Creates the closing clause of the loop construct.
void If(Bool v)
Creates the if clause of the conditional construct.
void Return()
Immediately returns from the function.
void For(VInt &variable, Int begin, Int end, Int step=1)
Creates the for clause of the &#39;for&#39; loop construct.
void Begin()
Marks the start of function body.
ReturnType operator()(typename Args::rvalue_type ... args)
Calls the defined function from inside shader code on the GPU.