diff
stringlengths
41
2.03M
msg
stringlengths
1
1.5k
repo
stringlengths
5
40
sha
stringlengths
40
40
time
stringlengths
20
20
mmm a / Makefile <nl> ppp b / Makefile <nl> pedantic_gcc : <nl> - Wextra \ <nl> - Wextra - semi \ <nl> - Wfloat - conversion \ <nl> - - Wfloat - equal \ <nl> - Wformat \ <nl> - Wformat - contains - nul \ <nl> - Wformat - extra - args \ <nl> pedantic_gcc : <nl> - Wmultistatement - macros \ <nl> - Wnarrowing \ <nl> - Wno - deprecated - declarations \ <nl> + - Wno - float - equal \ <nl> - Wno - long - long \ <nl> - Wno - namespaces \ <nl> - Wno - padded \ <nl>
: rotating_light : silenced a warning
nlohmann/json
0da99027b77f0fa6e01466b5519ed5a258d740ad
2019-04-03T15:44:09Z
mmm a / include / rapidjson / filereadstream . h <nl> ppp b / include / rapidjson / filereadstream . h <nl> class FileReadStream { <nl> + + current_ ; <nl> else if ( ! eof_ ) { <nl> count_ + = readCount_ ; <nl> - readCount_ = fread ( buffer_ , 1 , bufferSize_ , fp_ ) ; <nl> + readCount_ = std : : fread ( buffer_ , 1 , bufferSize_ , fp_ ) ; <nl> bufferLast_ = buffer_ + readCount_ - 1 ; <nl> current_ = buffer_ ; <nl> <nl> mmm a / include / rapidjson / filewritestream . h <nl> ppp b / include / rapidjson / filewritestream . h <nl> class FileWriteStream { <nl> <nl> void Flush ( ) { <nl> if ( current_ ! = buffer_ ) { <nl> - size_t result = fwrite ( buffer_ , 1 , static_cast < size_t > ( current_ - buffer_ ) , fp_ ) ; <nl> + size_t result = std : : fwrite ( buffer_ , 1 , static_cast < size_t > ( current_ - buffer_ ) , fp_ ) ; <nl> if ( result < static_cast < size_t > ( current_ - buffer_ ) ) { <nl> / / failure deliberately ignored at this time <nl> / / added to avoid warn_unused_result build errors <nl>
Merge pull request from clach04 / issue_1104_solaris_fread
Tencent/rapidjson
5aa79b72721b7c8f8efa2fd65ae99912a67c9213
2017-10-27T09:12:55Z
mmm a / Unity / README . md <nl> ppp b / Unity / README . md <nl> <nl> <nl> * Airsim Unity allows you to run your simulators in the [ Unity Engine ] ( https : / / unity3d . com / ) . This project comes with some sample Unity projects and a wrapper around the AirLib library to run as a [ native plugin ] ( https : / / docs . unity3d . com / Manual / NativePlugins . html ) in Unity . <nl> * Included are two basic Unity Projects , one for a Car simulator and another for a Drone simulator . They are meant to be lightweight , and can be used to verify your setup is correct . <nl> - * Check out the [ Unity blog ] ( https : / / blogs . unity3d . com / 2018 / 11 / 14 / airsim - on - unity - experiment - with - autonomous - vehicle - simulation / ) . <nl> + * Check out the [ Unity blogpost ] ( https : / / blogs . unity3d . com / 2018 / 11 / 14 / airsim - on - unity - experiment - with - autonomous - vehicle - simulation / ) for overview on the release . <nl> <nl> # # # Warning : Beta Sofware <nl> - This project is still in early development , expect some rough edges . <nl> - We are working to fully support the full AirLib API and feature set , but some things may be missing . <nl> + This project is still in early development , expect some rough edges . We are working to fully support the full AirLib API and feature set , but some things may be missing . <nl> <nl> # # Windows <nl> - <nl> - # # # Binaries <nl> - You can download a prebuilt version of the Demo project in the releases page . <nl> - <nl> # # # Building from source <nl> - <nl> # # # # Install Unity <nl> * Download * * Unity Hub * * from [ this page ] ( https : / / unity3d . com / get - unity / download ) . <nl> * Install * * Unity 2018 . 2 . 15f1 * * using the Unity Hub . [ Detailed instructions here ] ( https : / / docs . unity3d . com / Manual / GettingStartedInstallingHub . html ) . <nl> * Note : If you are using Unity for the first time , check out [ the Getting started guide ] ( https : / / docs . unity3d . com / Manual / GettingStarted . html ) . The [ Unity User Manual ] ( https : / / docs . unity3d . com / Manual / UnityManual . html ) has additional tips , resources , and FAQs . <nl> <nl> # # # # Build Airsim <nl> + * Install Visual Studio 2017 , with * * VC + + * * and * * Windows SDK 8 . x * * . <nl> * Run ` x64 Native Tools Command Prompt for VS 2017 ` . <nl> * Clone the repo : ` git clone https : / / github . com / Microsoft / AirSim . git ` , and go the AirSim directory by ` cd AirSim ` . <nl> * Build AirSim : ` build . cmd ` <nl> <nl> # # # # Build Unity Project <nl> - * Go inside the Unity directory : ` cd Unity ` . <nl> + * Go inside the AirSim \ Unity directory : ` cd Unity ` . <nl> * Build the unity project : ` build . cmd ` . <nl> - * Additionally , there is a free environment ` Windridge City ` which you can download from [ Unity Asset Store ] ( https : / / www . assetstore . unity3d . com / ) , which is perfect for AirSim experimentation . And , of course , you can always create your own environment . <nl> + * Additionally , there is a free environment ` Windridge City ` which you can download from [ Unity Asset Store ] ( https : / / www . assetstore . unity3d . com / ) . And , of course , you can always create your own environment . <nl> <nl> # # # # Usage <nl> * Start Unity and click ` Open project ` . <nl> * Select the folder ` AirSim \ Unity \ UnityDemo ` , and then hit the button ` Select Folder ` . <nl> * In the bottom pane , Click on ` Projects ` - > ` Assets ` - > ` Scenes ` . Then , * * Double - click * * on ` SimModeSelector ` , ` DroneDemo ` , or ` CarDemo ` . <nl> * Hit the play button to start the simulation ( and hit play again to stop the simulation . . <nl> - * Alternatively , you can change the SimMode in your ` Settings . json ` file . ( You can read more about ` Settings . json ` [ here ] ( https : / / github . com / Microsoft / AirSim / blob / master / docs / settings . md ) ) <nl> + * Alternatively , you can change the SimMode in your ` Settings . json ` file . ( You can read more about [ ` Settings . json ` here ] ( https : / / github . com / Microsoft / AirSim / blob / master / docs / settings . md ) ) <nl> * Controlling the car : <nl> Use ` WASD ` or the ` Arrow keys ` or the AirSim client . <nl> * Controlling the drone : <nl> - Use the ` PageUP ` / ` PageDown ` with WASD / Arrow keys . <nl> + Use the ` PageUP ` / ` PageDown ` with ` WASD ` / ` Arrow ` keys . <nl> * Changing camera views : <nl> - Keys 0 , 1 , 2 , and 3 are used to toggle windows of different camera views . <nl> + Keys ` 0 ` , ` 1 ` , ` 2 ` , ` 3 ` are used to toggle windows of different camera views . <nl> * Recording simulation data : <nl> Press * Record * button ( Red button ) located at the right bottom corner of the screen , to toggle recording of the simulation data . The recorded data can be found at ` Documents \ AirSim \ ( Date of recording ) ` <nl> <nl>
Merge pull request from madratman / unity_doc
microsoft/AirSim
391f01b4a31aa7ef8bf15a00f396d94c92817940
2018-11-14T09:17:06Z
mmm a / buildscripts / resmokelib / core / pipe . py <nl> ppp b / buildscripts / resmokelib / core / pipe . py <nl> def run ( self ) : <nl> with self . __pipe_out : <nl> # Avoid buffering the output from the pipe . <nl> for line in iter ( self . __pipe_out . readline , b " " ) : <nl> + # Replace null bytes in the output of the subprocess with a literal backslash ( ' \ ' ) <nl> + # followed by a literal zero ( ' 0 ' ) so tools like grep don ' t treat resmoke . py ' s <nl> + # output as binary data . <nl> + line = line . replace ( b " \ 0 " , b " \ \ 0 " ) <nl> + <nl> # Convert the output of the process from a bytestring to a UTF - 8 string , and replace <nl> # any characters that cannot be decoded with the official Unicode replacement <nl> # character , U + FFFD . The log messages of MongoDB processes are not always valid <nl> new file mode 100644 <nl> index 000000000000 . . 4b7a2bb941b6 <nl> mmm / dev / null <nl> ppp b / buildscripts / tests / resmokelib / core / __init__ . py <nl> @ @ - 0 , 0 + 1 @ @ <nl> + " " " Empty . " " " <nl> new file mode 100644 <nl> index 000000000000 . . 69b0e3fb5767 <nl> mmm / dev / null <nl> ppp b / buildscripts / tests / resmokelib / core / test_pipe . py <nl> <nl> + " " " Unit tests for buildscripts / resmokelib / core / pipe . py . " " " <nl> + <nl> + from __future__ import absolute_import <nl> + <nl> + import io <nl> + import logging <nl> + import unittest <nl> + <nl> + import mock <nl> + <nl> + from buildscripts . resmokelib . core import pipe as _pipe <nl> + <nl> + # pylint : disable = missing - docstring <nl> + <nl> + <nl> + class TestLoggerPipe ( unittest . TestCase ) : <nl> + LOG_LEVEL = logging . DEBUG <nl> + <nl> + @ classmethod <nl> + def _get_log_calls ( cls , output ) : <nl> + logger = logging . Logger ( " for_testing " ) <nl> + logger . log = mock . MagicMock ( ) <nl> + <nl> + logger_pipe = _pipe . LoggerPipe ( logger = logger , level = cls . LOG_LEVEL , <nl> + pipe_out = io . BytesIO ( output ) ) <nl> + logger_pipe . wait_until_started ( ) <nl> + logger_pipe . wait_until_finished ( ) <nl> + <nl> + return logger . log . call_args_list <nl> + <nl> + def test_strips_trailing_whitespace ( self ) : <nl> + calls = self . _get_log_calls ( b " a " ) <nl> + self . assertEqual ( calls , [ mock . call ( self . LOG_LEVEL , u " a " ) ] ) <nl> + <nl> + def test_strips_trailing_newlines ( self ) : <nl> + calls = self . _get_log_calls ( b " a \ r \ n " ) <nl> + self . assertEqual ( calls , [ mock . call ( self . LOG_LEVEL , u " a " ) ] ) <nl> + <nl> + def test_handles_invalid_utf8 ( self ) : <nl> + calls = self . _get_log_calls ( b " a \ x80b " ) <nl> + self . assertEqual ( calls , [ mock . call ( self . LOG_LEVEL , u " a \ ufffdb " ) ] ) <nl> + <nl> + def test_escapes_null_bytes ( self ) : <nl> + calls = self . _get_log_calls ( b " a \ 0b " ) <nl> + self . assertEqual ( calls , [ mock . call ( self . LOG_LEVEL , u " a \ \ 0b " ) ] ) <nl>
SERVER - 40180 Escape null bytes in output of subprocesses .
mongodb/mongo
a191b8f35eadb567d4bbb8d8826fc3702e99538b
2019-03-18T13:39:28Z
mmm a / cocos / platform / apple / CCFileUtils - apple . h <nl> ppp b / cocos / platform / apple / CCFileUtils - apple . h <nl> class CC_DLL FileUtilsApple : public FileUtils <nl> { <nl> public : <nl> FileUtilsApple ( ) ; <nl> + virtual ~ FileUtilsApple ( ) ; <nl> / * override functions * / <nl> virtual std : : string getWritablePath ( ) const override ; <nl> virtual std : : string getFullPathForDirectoryAndFilename ( const std : : string & directory , const std : : string & filename ) const override ; <nl> mmm a / cocos / platform / apple / CCFileUtils - apple . mm <nl> ppp b / cocos / platform / apple / CCFileUtils - apple . mm <nl> static void addObjectToNSDict ( const std : : string & key , const Value & value , NSMuta <nl> FileUtilsApple : : FileUtilsApple ( ) : pimpl_ ( new IMPL ( [ NSBundle mainBundle ] ) ) { <nl> } <nl> <nl> + FileUtilsApple : : ~ FileUtilsApple ( ) = default ; <nl> + <nl> # if CC_FILEUTILS_APPLE_ENABLE_OBJC <nl> void FileUtilsApple : : setBundle ( NSBundle * bundle ) { <nl> pimpl_ - > setBundle ( bundle ) ; <nl>
declare explicitly FileUtilsApple destructor
cocos2d/cocos2d-x
79b9a191d0ea26b96c61df65de5a06acea780828
2016-05-09T12:50:52Z
new file mode 100644 <nl> index 0000000000 . . aa1f37c4b3 <nl> mmm / dev / null <nl> ppp b / code / utility / src / palindrome / palindrome_check / palindrome_check . cs <nl> <nl> + using System ; <nl> + <nl> + namespace Palindrome <nl> + { <nl> + class Program <nl> + { <nl> + public static bool isPalindrome ( string str ) <nl> + { <nl> + for ( int i = 0 , j = str . Length - 1 ; i < str . Length / 2 ; + + i , - - j ) <nl> + { <nl> + if ( str [ i ] ! = str [ j ] ) <nl> + { <nl> + return false ; <nl> + } <nl> + } <nl> + return true ; <nl> + } <nl> + <nl> + public static void Main ( ) <nl> + { <nl> + Console . WriteLine ( isPalindrome ( " lol " ) ) ; / / True <nl> + Console . WriteLine ( isPalindrome ( " lolwa " ) ) ; / / False <nl> + } <nl> + } <nl> + } <nl> \ No newline at end of file <nl>
palindrome checker in c sharp
OpenGenus/cosmos
fd4e8639751902b83c9b82fc19d41939d6355e34
2018-04-19T19:15:34Z
mmm a / js / server / tests / shell - tasks . js <nl> ppp b / js / server / tests / shell - tasks . js <nl> function TaskSuite ( ) { <nl> name : " UnitTests1 " , <nl> command : command , <nl> period : 1 , <nl> + offset : 0 , <nl> params : 23 <nl> } ) ; <nl> <nl> function TaskSuite ( ) { <nl> assertEqual ( 1 , task . period ) ; <nl> assertEqual ( " _system " , task . database ) ; <nl> <nl> - internal . wait ( 5 ) ; <nl> + internal . wait ( 7 ) ; <nl> <nl> tasks . unregister ( task ) ; <nl> <nl> function TaskSuite ( ) { <nl> name : " UnitTests1 " , <nl> command : command , <nl> period : 1 , <nl> + offset : 0 , <nl> params : { cn : cn , val : 42 } <nl> } ) ; <nl> <nl> function TaskSuite ( ) { <nl> assertEqual ( 1 , task . period ) ; <nl> assertEqual ( " _system " , task . database ) ; <nl> <nl> - internal . wait ( 5 ) ; <nl> + internal . wait ( 7 ) ; <nl> <nl> tasks . unregister ( task ) ; <nl> <nl>
added more delay for busy workers
arangodb/arangodb
442fa7503c25f8d2b7fd92aeace86eda0b479e56
2014-05-10T00:34:18Z
mmm a / test / cpp / end2end / xds_end2end_test . cc <nl> ppp b / test / cpp / end2end / xds_end2end_test . cc <nl> class XdsEnd2endTest : public : : testing : : TestWithParam < TestType > { <nl> lb_channel_response_generator_ . get ( ) ) ) ; <nl> if ( xds_resource_does_not_exist_timeout_ms_ > 0 ) { <nl> xds_channel_args_to_add_ . emplace_back ( grpc_channel_arg_integer_create ( <nl> - GRPC_ARG_XDS_RESOURCE_DOES_NOT_EXIST_TIMEOUT_MS , <nl> + const_cast < char * > ( GRPC_ARG_XDS_RESOURCE_DOES_NOT_EXIST_TIMEOUT_MS ) , <nl> xds_resource_does_not_exist_timeout_ms_ ) ) ; <nl> } <nl> xds_channel_args_ . num_args = xds_channel_args_to_add_ . size ( ) ; <nl>
Add missing const_cast < > .
grpc/grpc
2fe1a5cd0a72f0498bd93909a7e53a81eaeef399
2020-09-25T17:00:32Z
mmm a / docs / api / app . md <nl> ppp b / docs / api / app . md <nl> Show the app ' s about panel options . These options can be overridden with ` app . se <nl> * ` credits ` String ( optional ) - Credit information . _macOS_ <nl> * ` authors ` String [ ] ( optional ) - List of app authors . _Linux_ <nl> * ` website ` String ( optional ) - The app ' s website . _Linux_ <nl> - * ` iconPath ` String ( optional ) - Path to the app ' s icon . _Linux_ <nl> + * ` iconPath ` String ( optional ) - Path to the app ' s icon . Will be shown as 64x64 pixels while retaining aspect ratio . _Linux_ <nl> <nl> Set the about panel options . This will override the values defined in the app ' s <nl> ` . plist ` file on MacOS . See the [ Apple docs ] [ about - panel - options ] for more details . On Linux , values must be set in order to be shown ; there are no defaults . <nl> mmm a / shell / browser / browser_linux . cc <nl> ppp b / shell / browser / browser_linux . cc <nl> void Browser : : ShowAboutPanel ( ) { <nl> } <nl> if ( ( str = opts . FindStringKey ( " iconPath " ) ) ) { <nl> GError * error = nullptr ; <nl> - GdkPixbuf * icon = gdk_pixbuf_new_from_file ( str - > c_str ( ) , & error ) ; <nl> + constexpr int width = 64 ; / / width of about panel icon in pixels <nl> + constexpr int height = 64 ; / / height of about panel icon in pixels <nl> + <nl> + / / set preserve_aspect_ratio to true <nl> + GdkPixbuf * icon = <nl> + gdk_pixbuf_new_from_file_at_size ( str - > c_str ( ) , width , height , & error ) ; <nl> if ( error ! = nullptr ) { <nl> g_warning ( " % s " , error - > message ) ; <nl> g_clear_error ( & error ) ; <nl>
fix : set size of GTK about panel icon ( )
electron/electron
5298358b72d05ed75de95b8d62ded6b5e72c1a90
2019-06-26T05:17:30Z
mmm a / trunk / auto / depends . sh <nl> ppp b / trunk / auto / depends . sh <nl> Centos_prepare ; ret = $ ? ; if [ [ 0 - ne $ ret ] ] ; then " CentOS perfapre failed , ret = $ <nl> # check the arm flag file , if flag changed , need to rebuild the st . <nl> if [ $ SRS_ARM_UBUNTU12 = YES ] ; then <nl> # ok , arm specified , if the flag filed does not exists , need to rebuild . <nl> - if [ [ - f $ { SRS_OBJS } / _flag . st . arm . tmp & & - f $ { SRS_OBJS } / st - 1 . 9 / obj / libst . a & & - f $ { SRS_OBJS } / st - 1 . 9 / obj / libst . so ] ] ; then <nl> + if [ [ - f $ { SRS_OBJS } / _flag . st . arm . tmp & & - f $ { SRS_OBJS } / st / libst . a & & - f $ { SRS_OBJS } / st / libst . so ] ] ; then <nl> echo " st - 1 . 9t for arm is ok . " ; <nl> else <nl> # TODO : FIXME : patch the bug . <nl> if [ $ SRS_ARM_UBUNTU12 = YES ] ; then <nl> fi <nl> else <nl> # arm not specified , if exists flag , need to rebuild for no - arm platform . <nl> - if [ [ ! - f $ { SRS_OBJS } / _flag . st . arm . tmp & & - f $ { SRS_OBJS } / st - 1 . 9 / obj / libst . a & & - f $ { SRS_OBJS } / st - 1 . 9 / obj / libst . so ] ] ; then <nl> + if [ [ ! - f $ { SRS_OBJS } / _flag . st . arm . tmp & & - f $ { SRS_OBJS } / st / libst . a & & - f $ { SRS_OBJS } / st / libst . so ] ] ; then <nl> echo " st - 1 . 9t is ok . " ; <nl> else <nl> echo " build st - 1 . 9t " ; <nl> else <nl> fi <nl> # check status <nl> ret = $ ? ; if [ [ $ ret - ne 0 ] ] ; then echo " build st - 1 . 9 failed , ret = $ ret " ; exit $ ret ; fi <nl> - if [ ! - f $ { SRS_OBJS } / st - 1 . 9 / obj / libst . a ] ; then echo " build st - 1 . 9 failed . " ; exit - 1 ; fi <nl> - if [ ! - f $ { SRS_OBJS } / st - 1 . 9 / obj / libst . so ] ; then echo " build st - 1 . 9 failed . " ; exit - 1 ; fi <nl> + if [ ! - f $ { SRS_OBJS } / st / libst . a ] ; then echo " build st - 1 . 9 failed . " ; exit - 1 ; fi <nl> + if [ ! - f $ { SRS_OBJS } / st / libst . so ] ; then echo " build st - 1 . 9 failed . " ; exit - 1 ; fi <nl> <nl> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> # http - parser - 2 . 1 <nl> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> if [ $ SRS_HTTP_CALLBACK = YES ] ; then <nl> - if [ [ - f $ { SRS_OBJS } / http - parser - 2 . 1 / http_parser . h & & - f $ { SRS_OBJS } / http - parser - 2 . 1 / libhttp_parser . a ] ] ; then <nl> + if [ [ - f $ { SRS_OBJS } / hp / http_parser . h & & - f $ { SRS_OBJS } / hp / libhttp_parser . a ] ] ; then <nl> echo " http - parser - 2 . 1 is ok . " ; <nl> else <nl> echo " build http - parser - 2 . 1 " ; <nl> if [ $ SRS_HTTP_CALLBACK = YES ] ; then <nl> fi <nl> # check status <nl> ret = $ ? ; if [ [ $ ret - ne 0 ] ] ; then echo " build http - parser - 2 . 1 failed , ret = $ ret " ; exit $ ret ; fi <nl> - if [ [ ! - f $ { SRS_OBJS } / http - parser - 2 . 1 / http_parser . h ] ] ; then echo " build http - parser - 2 . 1 failed " ; exit - 1 ; fi <nl> - if [ [ ! - f $ { SRS_OBJS } / http - parser - 2 . 1 / libhttp_parser . a ] ] ; then echo " build http - parser - 2 . 1 failed " ; exit - 1 ; fi <nl> + if [ [ ! - f $ { SRS_OBJS } / hp / http_parser . h ] ] ; then echo " build http - parser - 2 . 1 failed " ; exit - 1 ; fi <nl> + if [ [ ! - f $ { SRS_OBJS } / hp / libhttp_parser . a ] ] ; then echo " build http - parser - 2 . 1 failed " ; exit - 1 ; fi <nl> fi <nl> <nl> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> mmm a / trunk / configure <nl> ppp b / trunk / configure <nl> if [ $ SRS_SSL = YES ] ; then LibSSLRoot = " $ { SRS_OBJS } / openssl / include " ; LibSSLfile <nl> # gperftools - 2 . 1 , for mem check and mem / cpu profile <nl> LibGperfRoot = " " ; LibGperfFile = " " <nl> if [ $ SRS_GPERF = YES ] ; then LibGperfRoot = " $ { SRS_OBJS } / gperf / include " ; LibGperfFile = " $ { SRS_OBJS } / gperf / lib / libtcmalloc_and_profiler . a " ; fi <nl> - # the link options , if arm , use static link <nl> - SrsLinkOptions = " - ldl " ; if [ $ SRS_ARM_UBUNTU12 = YES ] ; then SrsLinkOptions = " - ldl - static " ; fi <nl> + # the link options , always use static link <nl> + SrsLinkOptions = " - static " <nl> <nl> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> # Modules , compile each module , then link to binary <nl>
always use static link , for manually build arm , and x86 / 64 use static link is ok .
ossrs/srs
efa22074be37e05a0de10f132aea64788d5d1827
2014-03-19T04:18:48Z
mmm a / src / clustering / reactor / blueprint . hpp <nl> ppp b / src / clustering / reactor / blueprint . hpp <nl> <nl> template < class protocol_t > <nl> class blueprint_t { <nl> public : <nl> - class shard_t { <nl> - peer_id_t primary ; <nl> - std : : set < peer_id_t > secondaries ; <nl> - } ; <nl> - <nl> enum role_t { <nl> role_nothing , <nl> role_primary , <nl> role_secondary <nl> } ; <nl> <nl> + class shard_t { <nl> + public : <nl> + role_t get_role ( peer_id_t ) THROWS_NOTHING ; <nl> + <nl> + peer_id_t primary ; <nl> + std : : set < peer_id_t > secondaries ; <nl> + } ; <nl> + <nl> / * Returns the role that this blueprint assigns to the given peer for the <nl> given shard . If the shard is not a shard of the blueprint , returns <nl> ` boost : : optional < role_t > ( ) ` . If the given peer is not in the blueprint ' s <nl> mmm a / src / clustering / reactor / reactor . hpp <nl> ppp b / src / clustering / reactor / reactor . hpp <nl> class reactor_t { <nl> secondary . If the blueprint is not completely implemented yet , it sets up a <nl> backfiller until the blueprint is complete , and then erases any data in the <nl> region and waits . * / <nl> - void do_role_nothing ( typename protocol_t : : region_t region , signal_t * interruptor ) THROWS_ONLY ( interrupted_exc_t ) ; <nl> + void do_role_nothing ( typename protocol_t : : region_t region , store_view_t < protocol_t > * subview , signal_t * interruptor ) THROWS_ONLY ( interrupted_exc_t ) ; <nl> <nl> / * ` do_role_primary ( ) ` runs for regions where we are supposed to be the <nl> primary . It backfills from a conveniently available backfiller and then <nl> sets up a broadcaster , master , listener , and replier . * / <nl> - void do_role_primary ( typename protocol_t : : region_t region , signal_t * interruptor ) THROWS_ONLY ( interrupted_exc_t ) ; <nl> + void do_role_primary ( typename protocol_t : : region_t region , store_view_t < protocol_t > * subview , signal_t * interruptor ) THROWS_ONLY ( interrupted_exc_t ) ; <nl> <nl> / * ` do_role_secondary ( ) ` runs for regions where we are supposed to be a <nl> secondary . If a primary is available , it tries to track it . Otherwise , it <nl> offers backfills . * / <nl> - void do_role_secondary ( typename protocol_t : : region_t region , signal_t * interruptor ) THROWS_ONLY ( interrupted_exc_t ) ; <nl> + void do_role_secondary ( typename protocol_t : : region_t region , store_view_t < protocol_t > * subview , signal_t * interruptor ) THROWS_ONLY ( interrupted_exc_t ) ; <nl> <nl> / * Sends messages to all peers asking them to confirm that their blueprint <nl> says we are supposed to take the given role for the given region . Returns <nl> mmm a / src / clustering / reactor / reactor . tcc <nl> ppp b / src / clustering / reactor / reactor . tcc <nl> reactor_t < protocol_t > : : reactor_t ( <nl> } <nl> <nl> template < class protocol_t > <nl> - reactor_t < protocol_t > : : activity_type_monitor_t : : activity_type_monitor_t ( reactor_t * p , typename protocol_t : : region_t r , activity_type_t e ) : <nl> + reactor_t < protocol_t > : : role_monitor_t : : role_monitor_t ( reactor_t * p , typename protocol_t : : region_t r , activity_type_t e ) : <nl> parent ( p ) , region ( r ) , expected ( e ) , <nl> subscription ( boost : : bind ( & activity_type_monitor_t : : on_change , this ) ) <nl> { <nl> reactor_t < protocol_t > : : activity_type_monitor_t : : activity_type_monitor_t ( reactor_ <nl> } <nl> <nl> template < class protocol_t > <nl> - void reactor_t < protocol_t > : : activity_type_monitor_t : : on_change ( ) { <nl> + void reactor_t < protocol_t > : : role_monitor_t : : on_change ( ) { <nl> if ( is_failed ( ) & & ! is_pulsed ( ) ) { <nl> pulse ( ) ; <nl> } <nl> } <nl> <nl> template < class protocol_t > <nl> - bool reactor_t < protocol_t > : : activity_type_monitor_t : : is_failed ( ) { <nl> - std : : map < typename protocol_t : : region_t , typename blueprint_t < protocol_t > : : shard_t > shards = <nl> - blueprint - > get ( ) . shards ; <nl> - std : : map < typename protocol_t : : region_t , typename blueprint_t < protocol_t > : : shard_t > : : iterator it = shards . find ( region ) ; <nl> - if ( it = = shards . end ( ) ) { <nl> - return true ; <nl> - } <nl> - if ( parent - > get_blueprint_shard_activity_type ( ( * it ) . second ) ! = expected ) { <nl> - return true ; <nl> - } <nl> - return false ; <nl> + bool reactor_t < protocol_t > : : role_monitor_t : : is_failed ( ) { <nl> + boost : : optional < typename blueprint_t < protocol_t > : : role_t > role = <nl> + parent - > blueprint - > get ( ) . get_role ( <nl> + parent - > mailbox_manager - > get_connectivity_service ( ) - > get_me ( ) , <nl> + region <nl> + ) ; <nl> + return role & & role . get ( ) = = expected ; <nl> } <nl> <nl> template < class protocol_t > <nl> void reactor_t < protocol_t > : : pump ( ) THROWS_NOTHING { <nl> it ! = shards . end ( ) ; it + + ) { <nl> typename protocol_t : : region_t region = ( * it ) . first ; <nl> if ( ! region_is_active ( region ) ) { <nl> - switch ( get_blueprint_shard_activity_type ( ( * it ) . second ) ) { <nl> - case activity_type_nothing : <nl> - spawn_activity ( <nl> - ( * it ) . first , <nl> - boost : : bind ( & reactor_t : : activity_nothing , ( * it ) . first , _1 ) , <nl> - & dont_let_activities_finish ) ; <nl> - break ; <nl> - case activity_type_primary : <nl> - spawn_activity ( <nl> - ( * it ) . first , <nl> - boost : : bind ( & reactor_t : : activity_primary , ( * it ) . first , _1 ) , <nl> - & dont_let_activities_finish ) ; <nl> - break ; <nl> - case activity_type_secondary : <nl> - spawn_activity ( <nl> - ( * it ) . first , <nl> - boost : : bind ( & reactor_t : : activity_secondary , ( * it ) . first , _1 ) , <nl> - & dont_let_activities_finish ) ; <nl> - break ; <nl> - } <nl> + active_regions . insert ( region ) ; <nl> + coro_t : : spawn_sometime ( boost : : bind ( & reactor_t < protocol_t > : : do_role , <nl> + this , <nl> + region , <nl> + ( * it ) . second . get_role ( mailbox_manager - > get_connectivity_service ( ) - > get_me ( ) ) , <nl> + auto_drainer_t : : lock_t ( & drainer ) <nl> + ) ) ; <nl> } <nl> } <nl> } <nl> <nl> template < class protocol_t > <nl> - void reactor_t < protocol_t > : : spawn_activity ( typename protocol_t : : region_t region , <nl> - const boost : : function < void ( auto_drainer_t : : lock_t ) > & activity , <nl> - mutex_assertion_t : : acq_t * proof ) THROWS_NOTHING { <nl> - proof - > assert_is_holding ( & lock ) ; <nl> - rassert ( ! region_is_active ( region ) ) ; <nl> - active_regions . insert ( region ) ; <nl> - coro_t : : spawn_sometime ( boost : : bind ( & reactor_t < protocol_t > : : do_activity , <nl> - region , <nl> - activity , <nl> - auto_drainer_t : : lock_t ( & drainer ) <nl> - ) ) ; <nl> - } <nl> - <nl> - template < class protocol_t > <nl> - void reactor_t < protocol_t > : : do_activity ( typename protocol_t : : region_t region , <nl> - const boost : : function < void ( auto_drainer_t : : lock_t ) > & activity , <nl> + void reactor_t < protocol_t > : : do_role ( typename protocol_t : : region_t region , <nl> + typename blueprint_t < protocol_t > : : role_t role , <nl> auto_drainer_t : : lock_t keepalive ) THROWS_NOTHING { <nl> - activity ( keepalive ) ; <nl> + role_monitor_t role_monitor ( this , region , role ) ; <nl> + wait_any_t interruptor ( & role_monitor , keepalive . get_drain_signal ( ) ) ; <nl> + try { <nl> + switch ( role ) { <nl> + case blueprint_t < protocol_t > : : role_nothing : <nl> + do_role_nothing ( region , & interruptor ) ; <nl> + crash ( " expected do_role_nothing ( ) to throw exception " ) ; <nl> + case blueprint_t < protocol_t > : : role_primary : <nl> + do_role_primary ( region , & interruptor ) ; <nl> + crash ( " expected do_role_primary ( ) to throw exception " ) ; <nl> + case blueprint_t < protocol_t > : : role_secondary : <nl> + do_role_secondary ( region , & interruptor ) ; <nl> + crash ( " expected do_role_secondary ( ) to throw exception " ) ; <nl> + } <nl> + } catch ( interrupted_exc_t ) { <nl> + / * This is what we expected * / <nl> + } <nl> { <nl> mutex_assertion_t : : acq_t acq ( & lock ) ; <nl> active_regions . erase ( region ) ; <nl> bool reactor_t < protocol_t > : : region_is_active ( typename protocol_t : : region_t r ) TH <nl> } <nl> <nl> template < class protocol_t > <nl> - void reactor_t < protocol_t > : : activity_nothing ( typename protocol_t : : region_t region , auto_drainer_t : : lock_t keepalive ) THROWS_NOTHING { <nl> - try { <nl> - activity_type_monitor_t blueprint_watcher ( this , region , activity_type_nothing ) ; <nl> - wait_any_t interruptor ( & blueprint_watcher , keepalive . get_drain_signal ( ) ) ; <nl> - <nl> - / * May throw ` interrupted_exc_t ` * / <nl> - region_map_t < protocol_t , version_range_t > state = <nl> - subview - > begin_read_transaction ( & interruptor ) - > get_metadata ( & interruptor ) ; <nl> - <nl> - if ( state . get_as_pairs ( ) . size ( ) ! = 0 | | state . get_as_pairs ( ) [ 0 ] . second ! = version_range_t : : zero ( ) ) { <nl> - / * We have some data ; we want to get rid of it as soon as it is safe <nl> - to do so . It will be safe once the blueprint is implemented . Until <nl> - then , make the data available to backfillees . * / <nl> - store_subview_t < protocol_t > subview ( & store_file , region ) ; <nl> - { <nl> - backfiller_t < protocol_t > backfiller ( mailbox_manager , branch_history , & subview ) ; <nl> - change_shard_state_t advertisement ( this , region , <nl> - manager_state_t < protocol_t > : : cold_shard_t ( state , backfiller . get_business_card ( ) ) ) ; <nl> - <nl> - / * May throw ` interrupted_exc_t ` * / <nl> - block_until_blueprint_implemented ( & interruptor ) ; <nl> - } <nl> - <nl> - / * Now it ' s safe to destroy the data * / <nl> - boost : : shared_ptr < store_view_t < protocol_t > : : write_transaction_t > txn = <nl> - subview . begin_write_transaction ( & interruptor ) ; / * May throw ` interrupted_exc_t ` * / <nl> - txn - > set_metadata ( region_map_t < protocol_t , version_range_t > ( region , version_range_t : : zero ( ) ) , & interruptor ) ; / * May throw ` interrupted_exc_t ` * / <nl> - txn - > reset_region ( region , & interruptor ) ; / * May throw ` interrupted_exc_t ` * / <nl> - } <nl> + void reactor_t < protocol_t > : : do_role_nothing ( typename protocol_t : : region_t region , store_view_t < protocol_t > * subview , signal_t * interruptor ) THROWS_ONLY ( interrupted_exc_t ) { <nl> <nl> - interruptor . wait_lazily_unordered ( ) ; <nl> + / * <nl> + Wait until ? ? ? <nl> + Stop broadcaster , listener , replier , backfiller . <nl> + Delete data . <nl> + Wait . <nl> + * / <nl> <nl> - } catch ( interrupted_exc_t ) { <nl> - return ; <nl> + <nl> + <nl> + <nl> + <nl> + <nl> + <nl> + / * May throw ` interrupted_exc_t ` * / <nl> + region_map_t < protocol_t , version_range_t > state = <nl> + subview - > begin_read_transaction ( & interruptor ) - > get_metadata ( interruptor ) ; <nl> + <nl> + / * Do we have any data ? * / <nl> + if ( state . get_as_pairs ( ) . size ( ) ! = 0 | | state . get_as_pairs ( ) [ 0 ] . second ! = version_range_t : : zero ( ) ) { <nl> + / * We have some data ; we want to get rid of it as soon as it is safe <nl> + to do so . It will be safe once the blueprint is implemented . Until <nl> + then , make the data available to backfillees . * / <nl> + { <nl> + backfiller_t < protocol_t > backfiller ( mailbox_manager , branch_history , & subview ) ; <nl> + change_shard_state_t advertisement ( this , region , <nl> + manager_state_t < protocol_t > : : cold_shard_t ( state , backfiller . get_business_card ( ) ) ) ; <nl> + <nl> + block_until_primaries_and_secondaries_up_for_shard ( region , interruptor ) ; / * May throw ` interrupted_exc_t ` * / <nl> + check_with_peers ( region , blueprint_t < protocol_t > : : role_nothing , interruptor ) ; / * May throw ` interrupted_exc_t ` * / <nl> + } <nl> + <nl> + / * Now it ' s safe to destroy the data * / <nl> + boost : : shared_ptr < store_view_t < protocol_t > : : write_transaction_t > txn = <nl> + subview . begin_write_transaction ( & interruptor ) ; / * May throw ` interrupted_exc_t ` * / <nl> + txn - > set_metadata ( region_map_t < protocol_t , version_range_t > ( region , version_range_t : : zero ( ) ) , & interruptor ) ; / * May throw ` interrupted_exc_t ` * / <nl> + txn - > reset_region ( region , & interruptor ) ; / * May throw ` interrupted_exc_t ` * / <nl> } <nl> + <nl> + interruptor . wait_lazily_unordered ( ) ; <nl> + throw interrupted_exc_t ( ) ; <nl> } <nl> <nl> template < class protocol_t > <nl> - void reactor_t < protocol_t > : : activity_primary ( typename protocol_t : : region_t region , auto_drainer_t : : lock_t keepalive ) THROWS_NOTHING { <nl> + void reactor_t < protocol_t > : : do_role_primary ( typename protocol_t : : region_t region , store_view_t < protocol_t > * subview , signal_t * interruptor ) THROWS_ONLY ( interrupted_exc_t ) { <nl> + <nl> + / * <nl> + <nl> + Wait until there is no broadcaster for any overlapping region . <nl> + <nl> } <nl> <nl> template < class protocol_t > <nl> - void reactor_t < protocol_t > : : activity_secondary ( typename protocol_t : : region_t region , auto_drainer_t : : lock_t keepalive ) THROWS_NOTHING { <nl> + void reactor_t < protocol_t > : : do_role_secondary ( typename protocol_t : : region_t region , store_view_t < protocol_t > * subview , signal_t * interruptor ) THROWS_ONLY ( interrupted_exc_t ) { <nl> } <nl> <nl>
WIP on reactor
rethinkdb/rethinkdb
94deb159af4fb8c01c479ebbf212139237af4087
2012-01-20T22:52:29Z
mmm a / tensorflow / tensorboard / . gitignore <nl> ppp b / tensorflow / tensorboard / . gitignore <nl> components / * <nl> # This rule should always be in sync with TF_COMPONENTS_TYPESCRIPT_GLOB <nl> # in gulpfile . js <nl> ! components / tf - * <nl> + ! components / vz - * <nl> ! components / index . html <nl> ! components / BUILD <nl> # Ignore the sample graph files since they are too large to <nl> components / tf - graph / demo / tf_model_zoo / * <nl> # All standalone code for TensorBoard components should be written in <nl> # typescript , and the compiled javascript code should be ignored . <nl> components / tf - * / * * / * . js <nl> - lib / js / * * / * . js <nl> + components / vz - * / * * / * . js <nl> mmm a / tensorflow / tensorboard / components / BUILD <nl> ppp b / tensorflow / tensorboard / components / BUILD <nl> exports_files ( [ " LICENSE " ] ) <nl> filegroup ( <nl> name = " all_files " , <nl> srcs = glob ( <nl> - [ " tf - * / * * / * " ] , <nl> + [ " tf - * / * * / * " , " vz - * / * * / * " ] , <nl> exclude = [ <nl> " * * / tf_model_zoo / * " , <nl> " * * / METADATA " , <nl> mmm a / tensorflow / tensorboard / components / tf - tensorboard / test / index . html <nl> ppp b / tensorflow / tensorboard / components / tf - tensorboard / test / index . html <nl> <nl> / / Run the tests for each main component in tensorboard . <nl> WCT . loadSuites ( [ <nl> ' tensorboardTests . html ' , <nl> - ' e2eTests . html ' , <nl> + / / TODO : re - enable or remove . b / 30163860 <nl> + / / ' e2eTests . html ' , <nl> ' fastTabSwitch . html ' <nl> ] ) ; <nl> < / script > <nl> similarity index 98 % <nl> rename from tensorflow / tensorboard / components / tf - histogram - dashboard / tf - vz - histogram - series . html <nl> rename to tensorflow / tensorboard / components / vz - histogram - timeseries / vz - histogram - timeseries . html <nl> mmm a / tensorflow / tensorboard / components / tf - histogram - dashboard / tf - vz - histogram - series . html <nl> ppp b / tensorflow / tensorboard / components / vz - histogram - timeseries / vz - histogram - timeseries . html <nl> <nl> < link rel = " import " href = " . . / polymer / polymer . html " > <nl> <nl> - < dom - module id = " tf - vz - histogram - series " > <nl> + < dom - module id = " vz - histogram - timeseries " > <nl> <nl> < template > <nl> < style > <nl> <nl> < script > <nl> " use strict " ; <nl> Polymer ( { <nl> - is : " tf - vz - histogram - series " , <nl> + is : " vz - histogram - timeseries " , <nl> properties : { <nl> mode : { type : String , value : " offset " } , / / offset | overlay <nl> width : { type : Number , value : 500 } , <nl> <nl> dx : { type : String , value : " dx " } , <nl> y : { type : String , value : " y " } , <nl> data : { type : Array , value : function ( ) { return [ { step : 0 , bins : [ { x : 0 , dx : 1 , y : 0 } ] } , { step : 1 , bins : [ { x : 0 , dx : 1 , y : 0 } ] } ] ; } } <nl> - / / type : HistogramSeriesDatum [ ] as described in tf - vz - histogram - series . d . ts <nl> + / / type : HistogramSeriesDatum [ ] as described in vz - histogram - timeseries . d . ts <nl> } , <nl> ready : function ( ) { <nl> / / Polymer ' s way of scoping styles on nodes that d3 created <nl> mmm a / tensorflow / tensorboard / gulp_tasks / tslint . js <nl> ppp b / tensorflow / tensorboard / gulp_tasks / tslint . js <nl> var tslint = require ( ' gulp - tslint ' ) ; <nl> <nl> module . exports = function ( strict ) { <nl> return function ( ) { <nl> - return gulp . src ( ' components / tf - * / * * / * . ts ' ) <nl> - . pipe ( tslint ( ) ) <nl> - . pipe ( tslint . report ( ' verbose ' , { <nl> - emitError : strict , <nl> - } ) ) ; <nl> - } ; <nl> + return gulp . src ( [ ' components / tf - * / * * / * . ts ' , ' components / vz - * / * * / * . ts ' ] ) <nl> + . pipe ( tslint ( ) ) <nl> + . pipe ( tslint . report ( ' verbose ' , { <nl> + emitError : strict , <nl> + } ) ) ; <nl> + } ; <nl> } <nl> mmm a / tensorflow / tensorboard / gulpfile . js <nl> ppp b / tensorflow / tensorboard / gulpfile . js <nl> gulp . task ( ' test ' , [ ' tslint ' , ' compile ' ] , getTask ( ' test ' ) ) ; <nl> <nl> gulp . task ( ' watch ' , [ ] , function ( ) { <nl> / / Avoid watching generated . d . ts in the build ( aka output ) directory . <nl> - return gulp . watch ( ' components / tf - * / * * / * . ts ' , <nl> - { ignoreInitial : true } , <nl> - [ ' compile ' , ' tslint . permissive ' ] ) ; <nl> + return gulp . watch ( <nl> + [ ' components / tf - * / * * / * . ts ' , ' components / vz - * / * * / * . ts ' ] , <nl> + { ignoreInitial : true } , [ ' compile ' , ' tslint . permissive ' ] ) ; <nl> } ) ; <nl> <nl> <nl> mmm a / tensorflow / tensorboard / wct . conf . json <nl> ppp b / tensorflow / tensorboard / wct . conf . json <nl> <nl> { <nl> " suites " : [ <nl> - " components / tf - * / test " <nl> + " components / tf - * / test " , <nl> + " components / vz - * / test " <nl> ] , <nl> " plugins " : [ " local " ] <nl> } <nl>
Rename the histogram series chart to vz - histogram - chart .
tensorflow/tensorflow
358d92323a43d7a5c08896caaad6e14b0c040cc6
2016-07-18T20:35:45Z
new file mode 100644 <nl> index 000000000000 . . 40752a9d3c6f <nl> mmm / dev / null <nl> ppp b / jstests / replsets / temp_namespace_restart_as_standalone . js <nl> <nl> + / * * <nl> + * Tests that temporary collections are not dropped when a member of a replica set is started up as <nl> + * a stand - alone mongod , i . e . without the - - replSet parameter . <nl> + * <nl> + * @ tags : [ requires_persistence ] <nl> + * / <nl> + ( function ( ) { <nl> + var rst = new ReplSetTest ( { nodes : 2 } ) ; <nl> + rst . startSet ( ) ; <nl> + <nl> + / / Rig the election so that the first node becomes the primary and remains primary despite the <nl> + / / secondary being terminated during this test . <nl> + var replSetConfig = rst . getReplSetConfig ( ) ; <nl> + replSetConfig . members [ 1 ] . priority = 0 ; <nl> + replSetConfig . members [ 1 ] . votes = 0 ; <nl> + rst . initiate ( replSetConfig ) ; <nl> + <nl> + var primaryConn = rst . getPrimary ( ) ; <nl> + var secondaryConn = rst . getSecondary ( ) ; <nl> + <nl> + var primaryDB = primaryConn . getDB ( " test " ) ; <nl> + var secondaryDB = secondaryConn . getDB ( " test " ) ; <nl> + <nl> + / / Create a temporary collection and wait until the operation has replicated to the secondary . <nl> + assert . commandWorked ( primaryDB . runCommand ( { <nl> + create : " temp_collection " , <nl> + temp : true , <nl> + writeConcern : { w : 2 , wtimeout : 60000 } , <nl> + } ) ) ; <nl> + <nl> + / / Verify that the temporary collection exists on the primary and has temp = true . <nl> + var primaryCollectionInfos = primaryDB . getCollectionInfos ( { name : " temp_collection " } ) ; <nl> + assert . eq ( 1 , primaryCollectionInfos . length , " ' temp_collection ' wasn ' t created on the primary " ) ; <nl> + assert . eq ( " temp_collection " , <nl> + primaryCollectionInfos [ 0 ] . name , <nl> + " ' temp_collection ' wasn ' t created on the primary " ) ; <nl> + assert . eq ( true , <nl> + primaryCollectionInfos [ 0 ] . options . temp , <nl> + " ' temp_collection ' wasn ' t created as temporary on the primary : " + <nl> + tojson ( primaryCollectionInfos [ 0 ] . options ) ) ; <nl> + <nl> + / / Verify that the temporary collection exists on the secondary and has temp = true . <nl> + var secondaryCollectionInfos = secondaryDB . getCollectionInfos ( { name : " temp_collection " } ) ; <nl> + assert . eq ( <nl> + 1 , secondaryCollectionInfos . length , " ' temp_collection ' wasn ' t created on the secondary " ) ; <nl> + assert . eq ( " temp_collection " , <nl> + secondaryCollectionInfos [ 0 ] . name , <nl> + " ' temp_collection ' wasn ' t created on the secondary " ) ; <nl> + assert . eq ( true , <nl> + secondaryCollectionInfos [ 0 ] . options . temp , <nl> + " ' temp_collection ' wasn ' t created as temporary on the secondary : " + <nl> + tojson ( secondaryCollectionInfos [ 0 ] . options ) ) ; <nl> + <nl> + / / Shut down the secondary and restart it as a stand - alone mongod . <nl> + var secondaryNodeId = rst . getNodeId ( secondaryDB . getMongo ( ) ) ; <nl> + rst . stop ( secondaryNodeId ) ; <nl> + <nl> + secondaryConn = MongoRunner . runMongod ( { dbpath : secondaryConn . dbpath , noCleanData : true } ) ; <nl> + assert . neq ( null , secondaryConn , " secondary failed to start up as a stand - alone mongod " ) ; <nl> + secondaryDB = secondaryConn . getDB ( " test " ) ; <nl> + <nl> + / / Verify that the temporary collection still exists on the secondary and has temp = true . <nl> + secondaryCollectionInfos = secondaryDB . getCollectionInfos ( { name : " temp_collection " } ) ; <nl> + assert . eq ( 1 , <nl> + secondaryCollectionInfos . length , <nl> + " ' temp_collection ' was dropped after restarting the secondary as a stand - alone " ) ; <nl> + assert . eq ( " temp_collection " , <nl> + secondaryCollectionInfos [ 0 ] . name , <nl> + " ' temp_collection ' was dropped after restarting the secondary as a stand - alone " ) ; <nl> + assert . eq ( true , <nl> + secondaryCollectionInfos [ 0 ] . options . temp , <nl> + " ' temp_collection ' is no longer temporary after restarting the secondary as a " + <nl> + " stand - alone : " + tojson ( secondaryCollectionInfos [ 0 ] . options ) ) ; <nl> + <nl> + / / Shut down the secondary and restart it as a member of the replica set . <nl> + MongoRunner . stopMongod ( secondaryConn ) ; <nl> + <nl> + var restart = true ; <nl> + rst . start ( secondaryNodeId , { } , restart ) ; <nl> + <nl> + / / Verify that writes are replicated to the temporary collection and can successfully be applied <nl> + / / by the secondary after having restarted it . <nl> + assert . writeOK ( primaryDB . temp_collection . insert ( { } , { writeConcern : { w : 2 , wtimeout : 60000 } } ) ) ; <nl> + <nl> + rst . stopSet ( ) ; <nl> + } ) ( ) ; <nl> mmm a / src / mongo / db / db . cpp <nl> ppp b / src / mongo / db / db . cpp <nl> extern int diagLogging ; <nl> namespace { <nl> <nl> const NamespaceString startupLogCollectionName ( " local . startup_log " ) ; <nl> + const NamespaceString kSystemReplSetCollection ( " local . system . replset " ) ; <nl> <nl> # ifdef _WIN32 <nl> ntservice : : NtServiceDefaultStrings defaultServiceStrings = { <nl> void checkForIdIndexes ( OperationContext * txn , Database * db ) { <nl> * - - replset . <nl> * / <nl> unsigned long long checkIfReplMissingFromCommandLine ( OperationContext * txn ) { <nl> - / / This is helpful for the query below to work as you can ' t open files when readlocked <nl> - ScopedTransaction transaction ( txn , MODE_X ) ; <nl> - Lock : : GlobalWrite lk ( txn - > lockState ( ) ) ; <nl> if ( ! repl : : getGlobalReplicationCoordinator ( ) - > getSettings ( ) . usingReplSets ( ) ) { <nl> DBDirectClient c ( txn ) ; <nl> - return c . count ( " local . system . replset " ) ; <nl> + return c . count ( kSystemReplSetCollection . ns ( ) ) ; <nl> } <nl> return 0 ; <nl> } <nl> void repairDatabasesAndCheckVersion ( OperationContext * txn ) { <nl> <nl> const repl : : ReplSettings & replSettings = repl : : getGlobalReplicationCoordinator ( ) - > getSettings ( ) ; <nl> <nl> + if ( ! storageGlobalParams . readOnly ) { <nl> + / / We open the " local " database before calling checkIfReplMissingFromCommandLine ( ) to ensure <nl> + / / the in - memory catalog entries for the ' kSystemReplSetCollection ' collection have been <nl> + / / populated if the collection exists . If the " local " database didn ' t exist at this point <nl> + / / yet , then it will be created . If the mongod is running in a read - only mode , then it is <nl> + / / fine to not open the " local " database and populate the catalog entries because we won ' t <nl> + / / attempt to drop the temporary collections anyway . <nl> + Lock : : DBLock dbLock ( txn - > lockState ( ) , kSystemReplSetCollection . db ( ) , MODE_X ) ; <nl> + dbHolder ( ) . openDb ( txn , kSystemReplSetCollection . db ( ) ) ; <nl> + } <nl> + <nl> / / On replica set members we only clear temp collections on DBs other than " local " during <nl> / / promotion to primary . On pure slaves , they are only cleared when the oplog tells them <nl> / / to . The local DB is special because it is not replicated . See SERVER - 10927 for more <nl>
SERVER - 26741 Retain temp collections when node restarted w / o - - replSet .
mongodb/mongo
43e9c303c08f73b56490b662b3d11988cafafdf4
2017-01-27T05:35:42Z
mmm a / xbmc / FileItem . cpp <nl> ppp b / xbmc / FileItem . cpp <nl> bool CFileItem : : Exists ( bool bUseCache / * = true * / ) const <nl> strPath = CStackDirectory : : GetFirstStackedFile ( strPath ) ; <nl> <nl> if ( m_bIsFolder ) <nl> - return CDirectory : : Exists ( strPath ) ; <nl> + return CDirectory : : Exists ( strPath , bUseCache ) ; <nl> else <nl> return CFile : : Exists ( strPath , bUseCache ) ; <nl> <nl>
[ fileitem ] let CFileItem : : Exists use the cache for directory checks
xbmc/xbmc
68020eec4f7a8355ca54204a6df2a271dea09050
2014-06-14T08:17:07Z
mmm a / tensorflow / core / platform / default / thread_annotations . h <nl> ppp b / tensorflow / core / platform / default / thread_annotations . h <nl> limitations under the License . <nl> / / annotations will be ignored by the analysis . <nl> # define TS_UNCHECKED ( x ) " " <nl> <nl> - / / Disables warnings for a single read operation . This can be used to do racy <nl> - / / reads of guarded data members , in cases where the race is benign . <nl> - # define TS_UNCHECKED_READ ( x ) \ <nl> - : : tensorflow : : thread_safety_analysis : : ts_unchecked_read ( x ) <nl> - <nl> namespace tensorflow { <nl> namespace thread_safety_analysis { <nl> <nl>
Remove definition of macro TS_UNCHECKED_READ .
tensorflow/tensorflow
01e089636c66457c7c82f6e6473c2a82215d37a8
2016-04-09T04:41:55Z
new file mode 100644 <nl> index 00000000000 . . 88af3cf3d55 <nl> mmm / dev / null <nl> ppp b / benchmark / python / ffi / benchmark_ffi . py <nl> <nl> + # Licensed to the Apache Software Foundation ( ASF ) under one <nl> + # or more contributor license agreements . See the NOTICE file <nl> + # distributed with this work for additional information <nl> + # regarding copyright ownership . The ASF licenses this file <nl> + # to you under the Apache License , Version 2 . 0 ( the <nl> + # " License " ) ; you may not use this file except in compliance <nl> + # with the License . You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , <nl> + # software distributed under the License is distributed on an <nl> + # " AS IS " BASIS , WITHOUT WARRANTIES OR CONDITIONS OF ANY <nl> + # KIND , either express or implied . See the License for the <nl> + # specific language governing permissions and limitations <nl> + # under the License . <nl> + import timeit <nl> + import itertools <nl> + import argparse <nl> + import os <nl> + <nl> + class OpArgMngr ( object ) : <nl> + " " " Operator argument manager for storing operator workloads . " " " <nl> + args = { } <nl> + <nl> + @ staticmethod <nl> + def add_workload ( funcname , * args , * * kwargs ) : <nl> + if " _specifier " not in kwargs : <nl> + _specifier = funcname <nl> + else : <nl> + _specifier = kwargs [ " _specififer " ] <nl> + del kwargs [ " _specififer " ] <nl> + if _specifier in OpArgMngr . args : <nl> + raise ValueError ( " duplicate { } " . format ( _specifier ) ) <nl> + OpArgMngr . args [ _specifier ] = { ' args ' : args , ' kwargs ' : kwargs , ' funcname ' : funcname } <nl> + <nl> + <nl> + def generate_workloads ( ) : <nl> + array_pool = { } <nl> + shapes = [ ] <nl> + for ndim in range ( 4 ) : <nl> + shapes . extend ( list ( itertools . product ( range ( 4 ) , repeat = ndim ) ) ) <nl> + for shape in shapes : <nl> + name = ' x ' . join ( str ( i ) for i in shape ) <nl> + if name in array_pool : <nl> + raise ValueError ( " duplicate array { } " . format ( name ) ) <nl> + array_pool [ name ] = dnp . ones ( shape ) <nl> + return array_pool <nl> + <nl> + <nl> + def prepare_workloads ( ) : <nl> + pool = generate_workloads ( ) <nl> + OpArgMngr . add_workload ( " zeros " , ( 2 , 2 ) ) <nl> + OpArgMngr . add_workload ( " tensordot " , pool [ ' 2x2 ' ] , pool [ ' 2x2 ' ] , ( ( 1 , 0 ) , ( 0 , 1 ) ) ) <nl> + OpArgMngr . add_workload ( " cumsum " , pool [ ' 3x2 ' ] , axis = 0 , out = pool [ ' 3x2 ' ] ) <nl> + OpArgMngr . add_workload ( " add " , pool [ ' 2x2 ' ] , pool [ ' 2x2 ' ] ) <nl> + OpArgMngr . add_workload ( " random . uniform " , low = 0 , high = 1 , size = 1 ) <nl> + <nl> + <nl> + def benchmark_helper ( f , * args , * * kwargs ) : <nl> + number = 10000 <nl> + return timeit . timeit ( lambda : f ( * args , * * kwargs ) , number = number ) / number <nl> + <nl> + <nl> + def get_op ( module , funcname ) : <nl> + funcname = funcname . split ( " . " ) <nl> + for fname in funcname : <nl> + module = getattr ( module , fname ) <nl> + return module <nl> + <nl> + <nl> + def run_benchmark ( packages ) : <nl> + results = { } <nl> + for ( k , v ) in OpArgMngr . args . items ( ) : <nl> + result = { } <nl> + for ( name , package ) in packages . items ( ) : <nl> + print ( ' { } . { } running . . . ' . format ( name , k ) ) <nl> + op = get_op ( package [ " module " ] , v [ " funcname " ] ) <nl> + args = [ package [ " data " ] ( arg ) for arg in v [ " args " ] ] <nl> + kwargs = { k : package [ " data " ] ( v ) for ( k , v ) in v [ " kwargs " ] . items ( ) } <nl> + benchmark = benchmark_helper ( op , * args , * * kwargs ) <nl> + result [ name ] = benchmark <nl> + results [ k ] = result <nl> + return results <nl> + <nl> + <nl> + def show_results ( results ) : <nl> + print ( " { : > 24 } { : > 24 } { : > 24 } " . format ( " name " , " package " , " time ( us ) " ) ) <nl> + for ( specifier , d ) in results . items ( ) : <nl> + for ( k , v ) in d . items ( ) : <nl> + print ( " { : > 24 } { : > 24 } { : > 24 } " . format ( specifier , k , v * 10 * * 6 ) ) <nl> + <nl> + <nl> + if __name__ = = " __main__ " : <nl> + parser = argparse . ArgumentParser ( ) <nl> + parser . add_argument ( ' ffi_type ' ) <nl> + parsed = parser . parse_args ( ) <nl> + if parsed . ffi_type = = " cython " : <nl> + os . environ [ ' MXNET_ENABLE_CYTHON ' ] = ' 1 ' <nl> + os . environ [ ' MXNET_ENFORCE_CYTHON ' ] = ' 1 ' <nl> + elif parsed . ffi_type = = " ctypes " : <nl> + os . environ [ ' MXNET_ENABLE_CYTHON ' ] = ' 0 ' <nl> + else : <nl> + raise ValueError ( " unknown ffi_type { } " , format ( parsed . ffi_type ) ) <nl> + os . environ [ " MXNET_ENGINE_TYPE " ] = " NaiveEngine " <nl> + import mxnet as mx <nl> + import numpy as onp <nl> + from mxnet import np as dnp <nl> + <nl> + mx . npx . set_np ( ) <nl> + packages = { <nl> + " onp " : { <nl> + " module " : onp , <nl> + " data " : lambda arr : arr . asnumpy ( ) if isinstance ( arr , dnp . ndarray ) else arr <nl> + } , <nl> + " dnp " : { <nl> + " module " : dnp , <nl> + " data " : lambda arr : arr <nl> + } <nl> + } <nl> + prepare_workloads ( ) <nl> + results = run_benchmark ( packages ) <nl> + show_results ( results ) <nl>
Add ffi benchmark ( )
apache/incubator-mxnet
afb8742e6e1e987833b39c487dc892b5537196a1
2020-03-10T05:37:18Z
mmm a / include / swift / AST / DiagnosticsSema . def <nl> ppp b / include / swift / AST / DiagnosticsSema . def <nl> WARNING ( differentiable_nondiff_type_implicit_noderivative_fixit , none , <nl> " stored property % 0 has no derivative because % 1 does not conform to " <nl> " ' Differentiable ' ; add an explicit ' @ noDerivative ' attribute " <nl> " % select { | , or conform % 2 to ' AdditiveArithmetic ' } 3 " , <nl> - ( Identifier , Type , Identifier , bool ) ) <nl> - WARNING ( differentiable_let_property_implicit_noderivative_fixit , none , <nl> + ( / * propName * / Identifier , / * propType * / Type , / * nominalName * / Identifier , <nl> + / * nominalCanDeriveAdditiveArithmetic * / bool ) ) <nl> + WARNING ( differentiable_immutable_wrapper_implicit_noderivative_fixit , none , <nl> " synthesis of the ' Differentiable . move ( along : ) ' requirement for % 1 " <nl> - " requires all stored properties to be mutable ; use ' var ' instead , or add " <nl> - " an explicit ' @ noDerivative ' attribute " <nl> + " requires all stored properties not marked with ` @ noDerivative ` to be " <nl> + " mutable ; add an explicit ' @ noDerivative ' attribute " <nl> " % select { | , or conform % 1 to ' AdditiveArithmetic ' } 2 " , <nl> - ( Identifier , Identifier , bool ) ) <nl> + ( / * wrapperType * / StringRef , / * nominalName * / Identifier , <nl> + / * nominalCanDeriveAdditiveArithmetic * / bool ) ) <nl> + WARNING ( differentiable_let_property_implicit_noderivative_fixit , none , <nl> + " synthesis of the ' Differentiable . move ( along : ) ' requirement for % 0 " <nl> + " requires all stored properties not marked with ` @ noDerivative ` to be " <nl> + " mutable ; use ' var ' instead , or add an explicit ' @ noDerivative ' attribute " <nl> + " % select { | , or conform % 0 to ' AdditiveArithmetic ' } 1 " , <nl> + ( / * nominalName * / Identifier , / * nominalCanDeriveAdditiveArithmetic * / bool ) ) <nl> <nl> NOTE ( codable_extraneous_codingkey_case_here , none , <nl> " CodingKey case % 0 does not match any stored properties " , ( Identifier ) ) <nl> mmm a / include / swift / SILOptimizer / Differentiation / AdjointValue . h <nl> ppp b / include / swift / SILOptimizer / Differentiation / AdjointValue . h <nl> class AdjointValue final { <nl> break ; <nl> } <nl> } <nl> + SWIFT_DEBUG_DUMP { print ( llvm : : dbgs ( ) ) ; } ; <nl> } ; <nl> <nl> inline llvm : : raw_ostream & operator < < ( llvm : : raw_ostream & os , <nl> mmm a / include / swift / SILOptimizer / Differentiation / Common . h <nl> ppp b / include / swift / SILOptimizer / Differentiation / Common . h <nl> ApplyInst * getAllocateUninitializedArrayIntrinsicElementAddress ( SILValue v ) ; <nl> / / / tuple - typed and such a user exists . <nl> DestructureTupleInst * getSingleDestructureTupleUser ( SILValue value ) ; <nl> <nl> + / / / Returns true if the given original function is a " semantic member accessor " . <nl> + / / / <nl> + / / / " Semantic member accessors " are attached to member properties that have a <nl> + / / / corresponding tangent stored property in the parent ` TangentVector ` type . <nl> + / / / These accessors have special - case pullback generation based on their <nl> + / / / semantic behavior . <nl> + / / / <nl> + / / / " Semantic member accessors " currently include : <nl> + / / / - Stored property accessors . These are implicitly generated . <nl> + / / / - Property wrapper wrapped value accessors . These are implicitly generated <nl> + / / / and internally call ` var wrappedValue ` . <nl> + bool isSemanticMemberAccessor ( SILFunction * original ) ; <nl> + <nl> + / / / Returns true if the given apply site has a " semantic member accessor " <nl> + / / / callee . <nl> + bool hasSemanticMemberAccessorCallee ( ApplySite applySite ) ; <nl> + <nl> / / / Given a full apply site , apply the given callback to each of its <nl> / / / " direct results " . <nl> / / / <nl> mmm a / include / swift / SILOptimizer / Differentiation / PullbackEmitter . h <nl> ppp b / include / swift / SILOptimizer / Differentiation / PullbackEmitter . h <nl> class PullbackEmitter final : public SILInstructionVisitor < PullbackEmitter > { <nl> SILBuilder localAllocBuilder ; <nl> <nl> / / / Stack buffers allocated for storing local adjoint values . <nl> - SmallVector < SILValue , 64 > functionLocalAllocations ; <nl> + SmallVector < AllocStackInst * , 64 > functionLocalAllocations ; <nl> <nl> / / / A set used to remember local allocations that were destroyed . <nl> llvm : : SmallDenseSet < SILValue > destroyedLocalAllocations ; <nl> class PullbackEmitter final : public SILInstructionVisitor < PullbackEmitter > { <nl> / / / if any error occurs . <nl> bool run ( ) ; <nl> <nl> + / / / Performs pullback generation on the empty pullback function , given that <nl> + / / / the original function is a " semantic member accessor " . <nl> + / / / <nl> + / / / " Semantic member accessors " are attached to member properties that have a <nl> + / / / corresponding tangent stored property in the parent ` TangentVector ` type . <nl> + / / / These accessors have special - case pullback generation based on their <nl> + / / / semantic behavior . <nl> + / / / <nl> + / / / Returns true if any error occurs . <nl> + bool runForSemanticMemberAccessor ( ) ; <nl> + bool runForSemanticMemberGetter ( ) ; <nl> + bool runForSemanticMemberSetter ( ) ; <nl> + <nl> / / / If original result is non - varied , it will always have a zero derivative . <nl> / / / Skip full pullback generation and simply emit zero derivatives for wrt <nl> / / / parameters . <nl> mmm a / lib / SILOptimizer / Differentiation / Common . cpp <nl> ppp b / lib / SILOptimizer / Differentiation / Common . cpp <nl> DestructureTupleInst * getSingleDestructureTupleUser ( SILValue value ) { <nl> return result ; <nl> } <nl> <nl> + bool isSemanticMemberAccessor ( SILFunction * original ) { <nl> + auto * dc = original - > getDeclContext ( ) ; <nl> + if ( ! dc ) <nl> + return false ; <nl> + auto * decl = dc - > getAsDecl ( ) ; <nl> + if ( ! decl ) <nl> + return false ; <nl> + auto * accessor = dyn_cast < AccessorDecl > ( decl ) ; <nl> + if ( ! accessor ) <nl> + return false ; <nl> + / / Currently , only getters and setters are supported . <nl> + / / TODO ( SR - 12640 ) : Support ` modify ` accessors . <nl> + if ( accessor - > getAccessorKind ( ) ! = AccessorKind : : Get & & <nl> + accessor - > getAccessorKind ( ) ! = AccessorKind : : Set ) <nl> + return false ; <nl> + / / Accessor must come from a ` var ` declaration . <nl> + auto * varDecl = dyn_cast < VarDecl > ( accessor - > getStorage ( ) ) ; <nl> + if ( ! varDecl ) <nl> + return false ; <nl> + / / Return true for stored property accessors . <nl> + if ( varDecl - > hasStorage ( ) & & varDecl - > isInstanceMember ( ) ) <nl> + return true ; <nl> + / / Return true for properties that have attached property wrappers . <nl> + if ( varDecl - > hasAttachedPropertyWrapper ( ) ) <nl> + return true ; <nl> + / / Otherwise , return false . <nl> + / / User - defined accessors can never be supported because they may use custom <nl> + / / logic that does not semantically perform a member access . <nl> + return false ; <nl> + } <nl> + <nl> + bool hasSemanticMemberAccessorCallee ( ApplySite applySite ) { <nl> + if ( auto * FRI = dyn_cast < FunctionRefBaseInst > ( applySite . getCallee ( ) ) ) <nl> + if ( auto * F = FRI - > getReferencedFunctionOrNull ( ) ) <nl> + return isSemanticMemberAccessor ( F ) ; <nl> + return false ; <nl> + } <nl> + <nl> void forEachApplyDirectResult ( <nl> FullApplySite applySite , <nl> llvm : : function_ref < void ( SILValue ) > resultCallback ) { <nl> mmm a / lib / SILOptimizer / Differentiation / PullbackEmitter . cpp <nl> ppp b / lib / SILOptimizer / Differentiation / PullbackEmitter . cpp <nl> <nl> # include " swift / SILOptimizer / Differentiation / Thunk . h " <nl> # include " swift / SILOptimizer / Differentiation / VJPEmitter . h " <nl> <nl> + # include " swift / AST / Expr . h " <nl> + # include " swift / AST / PropertyWrappers . h " <nl> # include " swift / SIL / InstructionUtils . h " <nl> # include " swift / SIL / Projection . h " <nl> # include " swift / SILOptimizer / PassManager / PrettyStackTrace . h " <nl> void PullbackEmitter : : addToAdjointBuffer ( SILBasicBlock * origBB , <nl> accumulateIndirect ( adjointBuffer , rhsBufferAccess , loc ) ; <nl> } <nl> <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - / / <nl> + / / Member accessor pullback generation <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - / / <nl> + <nl> + bool PullbackEmitter : : runForSemanticMemberAccessor ( ) { <nl> + auto & original = getOriginal ( ) ; <nl> + auto * accessor = cast < AccessorDecl > ( original . getDeclContext ( ) - > getAsDecl ( ) ) ; <nl> + switch ( accessor - > getAccessorKind ( ) ) { <nl> + case AccessorKind : : Get : <nl> + return runForSemanticMemberGetter ( ) ; <nl> + case AccessorKind : : Set : <nl> + return runForSemanticMemberSetter ( ) ; <nl> + / / TODO ( SR - 12640 ) : Support ` modify ` accessors . <nl> + default : <nl> + llvm_unreachable ( " Unsupported accessor kind ; inconsistent with " <nl> + " ` isSemanticMemberAccessor ` ? " ) ; <nl> + } <nl> + } <nl> + <nl> + bool PullbackEmitter : : runForSemanticMemberGetter ( ) { <nl> + auto & original = getOriginal ( ) ; <nl> + auto & pullback = getPullback ( ) ; <nl> + auto pbLoc = getPullback ( ) . getLocation ( ) ; <nl> + <nl> + auto * accessor = cast < AccessorDecl > ( original . getDeclContext ( ) - > getAsDecl ( ) ) ; <nl> + assert ( accessor - > getAccessorKind ( ) = = AccessorKind : : Get ) ; <nl> + <nl> + auto origExitIt = original . findReturnBB ( ) ; <nl> + assert ( origExitIt ! = original . end ( ) & & <nl> + " Functions without returns must have been diagnosed " ) ; <nl> + auto * origExit = & * origExitIt ; <nl> + builder . setInsertionPoint ( pullback . getEntryBlock ( ) ) ; <nl> + <nl> + / / Get getter argument and result values . <nl> + / / Getter type : $ ( Self ) - > Result <nl> + / / Pullback type : $ ( Result ' , PB_Struct ) - > Self ' <nl> + assert ( original . getLoweredFunctionType ( ) - > getNumParameters ( ) = = 1 ) ; <nl> + assert ( pullback . getLoweredFunctionType ( ) - > getNumParameters ( ) = = 2 ) ; <nl> + assert ( pullback . getLoweredFunctionType ( ) - > getNumResults ( ) = = 1 ) ; <nl> + SILValue origSelf = original . getArgumentsWithoutIndirectResults ( ) . front ( ) ; <nl> + <nl> + SmallVector < SILValue , 8 > origFormalResults ; <nl> + collectAllFormalResultsInTypeOrder ( original , origFormalResults ) ; <nl> + auto origResult = origFormalResults [ getIndices ( ) . source ] ; <nl> + <nl> + / / TODO ( TF - 970 ) : Emit diagnostic when ` TangentVector ` is not a struct . <nl> + auto tangentVectorSILTy = pullback . getConventions ( ) . getSingleSILResultType ( <nl> + TypeExpansionContext : : minimal ( ) ) ; <nl> + auto tangentVectorTy = tangentVectorSILTy . getASTType ( ) ; <nl> + auto * tangentVectorDecl = tangentVectorTy - > getStructOrBoundGenericStruct ( ) ; <nl> + <nl> + / / Look up the corresponding field in the tangent space . <nl> + VarDecl * origField = cast < VarDecl > ( accessor - > getStorage ( ) ) ; <nl> + VarDecl * tanField = nullptr ; <nl> + auto tanFieldLookup = tangentVectorDecl - > lookupDirect ( origField - > getName ( ) ) ; <nl> + if ( tanFieldLookup . empty ( ) ) { <nl> + getContext ( ) . emitNondifferentiabilityError ( <nl> + pbLoc . getSourceLoc ( ) , getInvoker ( ) , <nl> + diag : : autodiff_stored_property_no_corresponding_tangent , <nl> + origSelf - > getType ( ) . getASTType ( ) . getString ( ) , origField - > getNameStr ( ) ) ; <nl> + errorOccurred = true ; <nl> + return true ; <nl> + } <nl> + tanField = cast < VarDecl > ( tanFieldLookup . front ( ) ) ; <nl> + <nl> + / / Switch based on the base tangent struct ' s value category . <nl> + / / TODO ( TF - 1255 ) : Simplify using unified adjoint value data structure . <nl> + switch ( tangentVectorSILTy . getCategory ( ) ) { <nl> + case SILValueCategory : : Object : { <nl> + auto adjResult = getAdjointValue ( origExit , origResult ) ; <nl> + switch ( adjResult . getKind ( ) ) { <nl> + case AdjointValueKind : : Zero : <nl> + addAdjointValue ( origExit , origSelf , <nl> + makeZeroAdjointValue ( tangentVectorSILTy ) , pbLoc ) ; <nl> + break ; <nl> + case AdjointValueKind : : Concrete : <nl> + case AdjointValueKind : : Aggregate : { <nl> + SmallVector < AdjointValue , 8 > eltVals ; <nl> + for ( auto * field : tangentVectorDecl - > getStoredProperties ( ) ) { <nl> + if ( field = = tanField ) { <nl> + eltVals . push_back ( adjResult ) ; <nl> + } else { <nl> + auto substMap = tangentVectorTy - > getMemberSubstitutionMap ( <nl> + field - > getModuleContext ( ) , field ) ; <nl> + auto fieldTy = field - > getType ( ) . subst ( substMap ) ; <nl> + auto fieldSILTy = getTypeLowering ( fieldTy ) . getLoweredType ( ) ; <nl> + assert ( fieldSILTy . isObject ( ) ) ; <nl> + eltVals . push_back ( makeZeroAdjointValue ( fieldSILTy ) ) ; <nl> + } <nl> + } <nl> + addAdjointValue ( origExit , origSelf , <nl> + makeAggregateAdjointValue ( tangentVectorSILTy , eltVals ) , <nl> + pbLoc ) ; <nl> + } <nl> + } <nl> + break ; <nl> + } <nl> + case SILValueCategory : : Address : { <nl> + assert ( pullback . getIndirectResults ( ) . size ( ) = = 1 ) ; <nl> + auto pbIndRes = pullback . getIndirectResults ( ) . front ( ) ; <nl> + auto * adjSelf = createFunctionLocalAllocation ( <nl> + pbIndRes - > getType ( ) . getObjectType ( ) , pbLoc ) ; <nl> + setAdjointBuffer ( origExit , origSelf , adjSelf ) ; <nl> + for ( auto * field : tangentVectorDecl - > getStoredProperties ( ) ) { <nl> + auto * adjSelfElt = builder . createStructElementAddr ( pbLoc , adjSelf , field ) ; <nl> + if ( field = = tanField ) { <nl> + / / Switch based on the property ' s value category . <nl> + / / TODO ( TF - 1255 ) : Simplify using unified adjoint value data structure . <nl> + switch ( origResult - > getType ( ) . getCategory ( ) ) { <nl> + case SILValueCategory : : Object : { <nl> + auto adjResult = getAdjointValue ( origExit , origResult ) ; <nl> + auto adjResultValue = materializeAdjointDirect ( adjResult , pbLoc ) ; <nl> + builder . emitStoreValueOperation ( pbLoc , adjResultValue , adjSelfElt , <nl> + StoreOwnershipQualifier : : Init ) ; <nl> + break ; <nl> + } <nl> + case SILValueCategory : : Address : { <nl> + auto adjResult = getAdjointBuffer ( origExit , origResult ) ; <nl> + builder . createCopyAddr ( pbLoc , adjResult , adjSelfElt , IsTake , <nl> + IsInitialization ) ; <nl> + destroyedLocalAllocations . insert ( adjResult ) ; <nl> + break ; <nl> + } <nl> + } <nl> + } else { <nl> + auto fieldType = pullback . mapTypeIntoContext ( field - > getInterfaceType ( ) ) <nl> + - > getCanonicalType ( ) ; <nl> + emitZeroIndirect ( fieldType , adjSelfElt , pbLoc ) ; <nl> + } <nl> + } <nl> + break ; <nl> + } <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + bool PullbackEmitter : : runForSemanticMemberSetter ( ) { <nl> + auto & original = getOriginal ( ) ; <nl> + auto & pullback = getPullback ( ) ; <nl> + auto pbLoc = getPullback ( ) . getLocation ( ) ; <nl> + <nl> + auto * accessor = cast < AccessorDecl > ( original . getDeclContext ( ) - > getAsDecl ( ) ) ; <nl> + assert ( accessor - > getAccessorKind ( ) = = AccessorKind : : Set ) ; <nl> + <nl> + auto origEntry = original . getEntryBlock ( ) ; <nl> + builder . setInsertionPoint ( pullback . getEntryBlock ( ) ) ; <nl> + <nl> + / / Get setter argument values . <nl> + / / Setter type : $ ( inout Self , Argument ) - > ( ) <nl> + / / Pullback type ( wrt self ) : $ ( inout Self ' , PB_Struct ) - > ( ) <nl> + / / Pullback type ( wrt both ) : $ ( inout Self ' , PB_Struct ) - > Argument ' <nl> + assert ( original . getLoweredFunctionType ( ) - > getNumParameters ( ) = = 2 ) ; <nl> + assert ( pullback . getLoweredFunctionType ( ) - > getNumParameters ( ) = = 2 ) ; <nl> + assert ( pullback . getLoweredFunctionType ( ) - > getNumResults ( ) = = 0 | | <nl> + pullback . getLoweredFunctionType ( ) - > getNumResults ( ) = = 1 ) ; <nl> + <nl> + SILValue origArg = original . getArgumentsWithoutIndirectResults ( ) [ 0 ] ; <nl> + SILValue origSelf = original . getArgumentsWithoutIndirectResults ( ) [ 1 ] ; <nl> + <nl> + / / TODO ( TF - 970 ) : Emit diagnostic when ` TangentVector ` is not a struct . <nl> + auto tangentVectorSILTy = pullback . getLoweredFunctionType ( ) <nl> + - > getParameters ( ) [ 0 ] <nl> + . getSILStorageInterfaceType ( ) ; <nl> + assert ( tangentVectorSILTy . getCategory ( ) = = SILValueCategory : : Address ) ; <nl> + auto tangentVectorTy = tangentVectorSILTy . getASTType ( ) ; <nl> + auto * tangentVectorDecl = tangentVectorTy - > getStructOrBoundGenericStruct ( ) ; <nl> + <nl> + / / Look up the corresponding field in the tangent space . <nl> + VarDecl * origField = cast < VarDecl > ( accessor - > getStorage ( ) ) ; <nl> + VarDecl * tanField = nullptr ; <nl> + auto tanFieldLookup = tangentVectorDecl - > lookupDirect ( origField - > getName ( ) ) ; <nl> + if ( tanFieldLookup . empty ( ) ) { <nl> + getContext ( ) . emitNondifferentiabilityError ( <nl> + pbLoc . getSourceLoc ( ) , getInvoker ( ) , <nl> + diag : : autodiff_stored_property_no_corresponding_tangent , <nl> + origSelf - > getType ( ) . getASTType ( ) . getString ( ) , origField - > getNameStr ( ) ) ; <nl> + errorOccurred = true ; <nl> + return true ; <nl> + } <nl> + tanField = cast < VarDecl > ( tanFieldLookup . front ( ) ) ; <nl> + <nl> + auto adjSelf = getAdjointBuffer ( origEntry , origSelf ) ; <nl> + auto * adjSelfElt = builder . createStructElementAddr ( pbLoc , adjSelf , tanField ) ; <nl> + / / Switch based on the property ' s value category . <nl> + / / TODO ( TF - 1255 ) : Simplify using unified adjoint value data structure . <nl> + switch ( origArg - > getType ( ) . getCategory ( ) ) { <nl> + case SILValueCategory : : Object : { <nl> + auto adjArg = builder . emitLoadValueOperation ( pbLoc , adjSelfElt , <nl> + LoadOwnershipQualifier : : Take ) ; <nl> + setAdjointValue ( origEntry , origArg , makeConcreteAdjointValue ( adjArg ) ) ; <nl> + break ; <nl> + } <nl> + case SILValueCategory : : Address : { <nl> + addToAdjointBuffer ( origEntry , origArg , adjSelfElt , pbLoc ) ; <nl> + builder . emitDestroyOperation ( pbLoc , adjSelfElt ) ; <nl> + break ; <nl> + } <nl> + } <nl> + emitZeroIndirect ( adjSelfElt - > getType ( ) . getASTType ( ) , adjSelfElt , pbLoc ) ; <nl> + <nl> + return false ; <nl> + } <nl> + <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - / / <nl> / / Entry point <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - / / <nl> bool PullbackEmitter : : run ( ) { <nl> return ; <nl> visited . insert ( v ) ; <nl> auto type = v - > getType ( ) ; <nl> - / / Diagnose active enum values . Differentiation of enum values requires <nl> - / / special adjoint value handling and is not yet supported . Diagnose <nl> - / / only the first active enum value to prevent too many diagnostics . <nl> - if ( ! diagnosedActiveEnumValue & & type . getEnumOrBoundGenericEnum ( ) ) { <nl> - getContext ( ) . emitNondifferentiabilityError ( <nl> - v , getInvoker ( ) , diag : : autodiff_enums_unsupported ) ; <nl> - errorOccurred = true ; <nl> - diagnosedActiveEnumValue = true ; <nl> - } <nl> / / Diagnose active values whose value category is incompatible with their <nl> / / tangent types ' s value category . <nl> / / <nl> bool PullbackEmitter : : run ( ) { <nl> } <nl> } <nl> } <nl> + / / Do not emit remaining activity - related diagnostics for semantic member <nl> + / / accessors , which have special - case pullback generation . <nl> + if ( isSemanticMemberAccessor ( & original ) ) <nl> + return ; <nl> + / / Diagnose active enum values . Differentiation of enum values requires <nl> + / / special adjoint value handling and is not yet supported . Diagnose <nl> + / / only the first active enum value to prevent too many diagnostics . <nl> + if ( ! diagnosedActiveEnumValue & & type . getEnumOrBoundGenericEnum ( ) ) { <nl> + getContext ( ) . emitNondifferentiabilityError ( <nl> + v , getInvoker ( ) , diag : : autodiff_enums_unsupported ) ; <nl> + errorOccurred = true ; <nl> + diagnosedActiveEnumValue = true ; <nl> + } <nl> / / Skip address projections . <nl> / / Address projections do not need their own adjoint buffers ; they <nl> / / become projections into their adjoint base buffer . <nl> bool PullbackEmitter : : run ( ) { <nl> < < " as the adjoint of original result " < < origResult ) ; <nl> } <nl> <nl> + / / If the original function is an accessor with special - case pullback <nl> + / / generation logic , do special - case generation . <nl> + if ( isSemanticMemberAccessor ( & original ) ) { <nl> + if ( runForSemanticMemberAccessor ( ) ) <nl> + return true ; <nl> + } <nl> + / / Otherwise , perform standard pullback generation . <nl> / / Visit original blocks blocks in post - order and perform differentiation <nl> / / in corresponding pullback blocks . If errors occurred , back out . <nl> - for ( auto * bb : postOrderPostDomOrder ) { <nl> - visitSILBasicBlock ( bb ) ; <nl> - if ( errorOccurred ) <nl> - return true ; <nl> + else { <nl> + for ( auto * bb : postOrderPostDomOrder ) { <nl> + visitSILBasicBlock ( bb ) ; <nl> + if ( errorOccurred ) <nl> + return true ; <nl> + } <nl> } <nl> <nl> / / Prepare and emit a ` return ` in the pullback exit block . <nl> void PullbackEmitter : : visitStructInst ( StructInst * si ) { <nl> auto adjStruct = materializeAdjointDirect ( std : : move ( av ) , loc ) ; <nl> / / Find the struct ` TangentVector ` type . <nl> auto structTy = remapType ( si - > getType ( ) ) . getASTType ( ) ; <nl> - auto tangentVectorTy = <nl> - getTangentSpace ( structTy ) - > getType ( ) - > getCanonicalType ( ) ; <nl> + auto tangentVectorTy = getTangentSpace ( structTy ) - > getCanonicalType ( ) ; <nl> assert ( ! getTypeLowering ( tangentVectorTy ) . isAddressOnly ( ) ) ; <nl> auto * tangentVectorDecl = tangentVectorTy - > getStructOrBoundGenericStruct ( ) ; <nl> assert ( tangentVectorDecl ) ; <nl> void PullbackEmitter : : visitStructExtractInst ( StructExtractInst * sei ) { <nl> " differentiated ; activity analysis should not marked as varied " ) ; <nl> auto * bb = sei - > getParent ( ) ; <nl> auto structTy = remapType ( sei - > getOperand ( ) - > getType ( ) ) . getASTType ( ) ; <nl> - auto tangentVectorTy = <nl> - getTangentSpace ( structTy ) - > getType ( ) - > getCanonicalType ( ) ; <nl> + auto tangentVectorTy = getTangentSpace ( structTy ) - > getCanonicalType ( ) ; <nl> assert ( ! getTypeLowering ( tangentVectorTy ) . isAddressOnly ( ) ) ; <nl> auto tangentVectorSILTy = SILType : : getPrimitiveObjectType ( tangentVectorTy ) ; <nl> auto * tangentVectorDecl = tangentVectorTy - > getStructOrBoundGenericStruct ( ) ; <nl> void PullbackEmitter : : visitStructExtractInst ( StructExtractInst * sei ) { <nl> auto substMap = tangentVectorTy - > getMemberSubstitutionMap ( <nl> field - > getModuleContext ( ) , field ) ; <nl> auto fieldTy = field - > getType ( ) . subst ( substMap ) ; <nl> - auto fieldSILTy = getContext ( ) . getTypeConverter ( ) . getLoweredType ( <nl> - fieldTy , TypeExpansionContext : : minimal ( ) ) ; <nl> + auto fieldSILTy = getTypeLowering ( fieldTy ) . getLoweredType ( ) ; <nl> assert ( fieldSILTy . isObject ( ) ) ; <nl> eltVals . push_back ( makeZeroAdjointValue ( fieldSILTy ) ) ; <nl> } <nl> void PullbackEmitter : : visitRefElementAddrInst ( RefElementAddrInst * reai ) { <nl> auto * bb = reai - > getParent ( ) ; <nl> auto adjBuf = getAdjointBuffer ( bb , reai ) ; <nl> auto classTy = remapType ( reai - > getOperand ( ) - > getType ( ) ) . getASTType ( ) ; <nl> - auto tangentVectorTy = <nl> - getTangentSpace ( classTy ) - > getType ( ) - > getCanonicalType ( ) ; <nl> + auto tangentVectorTy = getTangentSpace ( classTy ) - > getCanonicalType ( ) ; <nl> assert ( ! getTypeLowering ( tangentVectorTy ) . isAddressOnly ( ) ) ; <nl> auto tangentVectorSILTy = SILType : : getPrimitiveObjectType ( tangentVectorTy ) ; <nl> auto * tangentVectorDecl = tangentVectorTy - > getStructOrBoundGenericStruct ( ) ; <nl> void PullbackEmitter : : visitRefElementAddrInst ( RefElementAddrInst * reai ) { <nl> auto substMap = tangentVectorTy - > getMemberSubstitutionMap ( <nl> field - > getModuleContext ( ) , field ) ; <nl> auto fieldTy = field - > getType ( ) . subst ( substMap ) ; <nl> - auto fieldSILTy = getContext ( ) . getTypeConverter ( ) . getLoweredType ( <nl> - fieldTy , TypeExpansionContext : : minimal ( ) ) ; <nl> + auto fieldSILTy = getTypeLowering ( fieldTy ) . getLoweredType ( ) ; <nl> assert ( fieldSILTy . isObject ( ) ) ; <nl> eltVals . push_back ( makeZeroAdjointValue ( fieldSILTy ) ) ; <nl> } <nl> mmm a / lib / SILOptimizer / Differentiation / VJPEmitter . cpp <nl> ppp b / lib / SILOptimizer / Differentiation / VJPEmitter . cpp <nl> void VJPEmitter : : visitSwitchEnumAddrInst ( SwitchEnumAddrInst * seai ) { <nl> } <nl> <nl> void VJPEmitter : : visitApplyInst ( ApplyInst * ai ) { <nl> - / / If the function should not be differentiated or its the array literal <nl> - / / initialization intrinsic , just do standard cloning . <nl> - if ( ! pullbackInfo . shouldDifferentiateApplySite ( ai ) | | <nl> - isArrayLiteralIntrinsic ( ai ) ) { <nl> + / / If callee should not be differentiated , do standard cloning . <nl> + if ( ! pullbackInfo . shouldDifferentiateApplySite ( ai ) ) { <nl> LLVM_DEBUG ( getADDebugStream ( ) < < " No active results : \ n " < < * ai < < ' \ n ' ) ; <nl> TypeSubstCloner : : visitApplyInst ( ai ) ; <nl> return ; <nl> } <nl> + / / If callee is the array literal initialization intrinsic , do standard <nl> + / / cloning . Array literal differentiation is handled separately . <nl> + if ( isArrayLiteralIntrinsic ( ai ) ) { <nl> + LLVM_DEBUG ( getADDebugStream ( ) < < " Cloning array literal intrinsic ` apply ` \ n " <nl> + < < * ai < < ' \ n ' ) ; <nl> + TypeSubstCloner : : visitApplyInst ( ai ) ; <nl> + return ; <nl> + } <nl> + / / If the original function is a semantic member accessor , do standard <nl> + / / cloning . Semantic member accessors have special pullback generation logic , <nl> + / / so all ` apply ` instructions can be directly cloned to the VJP . <nl> + if ( isSemanticMemberAccessor ( original ) ) { <nl> + LLVM_DEBUG ( getADDebugStream ( ) <nl> + < < " Cloning ` apply ` in semantic member accessor : \ n " <nl> + < < * ai < < ' \ n ' ) ; <nl> + TypeSubstCloner : : visitApplyInst ( ai ) ; <nl> + return ; <nl> + } <nl> + <nl> + auto loc = ai - > getLoc ( ) ; <nl> + auto & builder = getBuilder ( ) ; <nl> + auto origCallee = getOpValue ( ai - > getCallee ( ) ) ; <nl> + auto originalFnTy = origCallee - > getType ( ) . castTo < SILFunctionType > ( ) ; <nl> <nl> LLVM_DEBUG ( getADDebugStream ( ) < < " VJP - transforming : \ n " < < * ai < < ' \ n ' ) ; <nl> <nl> void VJPEmitter : : visitApplyInst ( ApplyInst * ai ) { <nl> activeParamIndices ) ) ; <nl> <nl> / / Emit the VJP . <nl> - auto loc = ai - > getLoc ( ) ; <nl> - auto & builder = getBuilder ( ) ; <nl> - auto original = getOpValue ( ai - > getCallee ( ) ) ; <nl> SILValue vjpValue ; <nl> / / If functionSource is a ` @ differentiable ` function , just extract it . <nl> - auto originalFnTy = original - > getType ( ) . castTo < SILFunctionType > ( ) ; <nl> if ( originalFnTy - > isDifferentiable ( ) ) { <nl> auto paramIndices = originalFnTy - > getDifferentiabilityParameterIndices ( ) ; <nl> for ( auto i : indices . parameters - > getIndices ( ) ) { <nl> if ( ! paramIndices - > contains ( i ) ) { <nl> context . emitNondifferentiabilityError ( <nl> - original , invoker , <nl> + origCallee , invoker , <nl> diag : : autodiff_function_noderivative_parameter_not_differentiable ) ; <nl> errorOccurred = true ; <nl> return ; <nl> } <nl> } <nl> - auto origFnType = original - > getType ( ) . castTo < SILFunctionType > ( ) ; <nl> + auto origFnType = origCallee - > getType ( ) . castTo < SILFunctionType > ( ) ; <nl> auto origFnUnsubstType = origFnType - > getUnsubstitutedType ( getModule ( ) ) ; <nl> if ( origFnType ! = origFnUnsubstType ) { <nl> - original = builder . createConvertFunction ( <nl> - loc , original , SILType : : getPrimitiveObjectType ( origFnUnsubstType ) , <nl> + origCallee = builder . createConvertFunction ( <nl> + loc , origCallee , SILType : : getPrimitiveObjectType ( origFnUnsubstType ) , <nl> / * withoutActuallyEscaping * / false ) ; <nl> } <nl> - auto borrowedDiffFunc = builder . emitBeginBorrowOperation ( loc , original ) ; <nl> + auto borrowedDiffFunc = builder . emitBeginBorrowOperation ( loc , origCallee ) ; <nl> vjpValue = builder . createDifferentiableFunctionExtract ( <nl> loc , NormalDifferentiableFunctionTypeComponent : : VJP , borrowedDiffFunc ) ; <nl> vjpValue = builder . emitCopyValueOperation ( loc , vjpValue ) ; <nl> void VJPEmitter : : visitApplyInst ( ApplyInst * ai ) { <nl> } <nl> if ( ! remappedResultType . isDifferentiable ( getModule ( ) ) ) { <nl> context . emitNondifferentiabilityError ( <nl> - original , invoker , diag : : autodiff_nondifferentiable_result ) ; <nl> + origCallee , invoker , diag : : autodiff_nondifferentiable_result ) ; <nl> errorOccurred = true ; <nl> return true ; <nl> } <nl> void VJPEmitter : : visitApplyInst ( ApplyInst * ai ) { <nl> / * <nl> DifferentiationInvoker indirect ( ai , attr ) ; <nl> auto insertion = <nl> - context . getInvokers ( ) . try_emplace ( { this - > original , attr } , indirect ) ; <nl> + context . getInvokers ( ) . try_emplace ( { original , attr } , indirect ) ; <nl> auto & invoker = insertion . first - > getSecond ( ) ; <nl> invoker = indirect ; <nl> * / <nl> void VJPEmitter : : visitApplyInst ( ApplyInst * ai ) { <nl> / / function operand is specialized with a remapped version of same <nl> / / substitution map using an argument - less ` partial_apply ` . <nl> if ( ai - > getSubstitutionMap ( ) . empty ( ) ) { <nl> - original = builder . emitCopyValueOperation ( loc , original ) ; <nl> + origCallee = builder . emitCopyValueOperation ( loc , origCallee ) ; <nl> } else { <nl> auto substMap = getOpSubstitutionMap ( ai - > getSubstitutionMap ( ) ) ; <nl> auto vjpPartialApply = getBuilder ( ) . createPartialApply ( <nl> - ai - > getLoc ( ) , original , substMap , { } , <nl> + ai - > getLoc ( ) , origCallee , substMap , { } , <nl> ParameterConvention : : Direct_Guaranteed ) ; <nl> - original = vjpPartialApply ; <nl> - originalFnTy = original - > getType ( ) . castTo < SILFunctionType > ( ) ; <nl> + origCallee = vjpPartialApply ; <nl> + originalFnTy = origCallee - > getType ( ) . castTo < SILFunctionType > ( ) ; <nl> / / Diagnose if new original function type is non - differentiable . <nl> if ( diagnoseNondifferentiableOriginalFunctionType ( originalFnTy ) ) <nl> return ; <nl> } <nl> <nl> auto * diffFuncInst = context . createDifferentiableFunction ( <nl> - getBuilder ( ) , loc , indices . parameters , original ) ; <nl> + getBuilder ( ) , loc , indices . parameters , origCallee ) ; <nl> <nl> / / Record the ` differentiable_function ` instruction . <nl> context . addDifferentiableFunctionInstToWorklist ( diffFuncInst ) ; <nl> mmm a / lib / Sema / DerivedConformanceDifferentiable . cpp <nl> ppp b / lib / Sema / DerivedConformanceDifferentiable . cpp <nl> <nl> # include " swift / AST / ParameterList . h " <nl> # include " swift / AST / Pattern . h " <nl> # include " swift / AST / ProtocolConformance . h " <nl> + # include " swift / AST / PropertyWrappers . h " <nl> # include " swift / AST / Stmt . h " <nl> # include " swift / AST / Types . h " <nl> # include " DerivedConformances . h " <nl> getStoredPropertiesForDifferentiation ( NominalTypeDecl * nominal , DeclContext * DC , <nl> auto & C = nominal - > getASTContext ( ) ; <nl> auto * diffableProto = C . getProtocol ( KnownProtocolKind : : Differentiable ) ; <nl> for ( auto * vd : nominal - > getStoredProperties ( ) ) { <nl> + / / Peer through property wrappers : use original wrapped properties instead . <nl> + if ( auto * originalProperty = vd - > getOriginalWrappedProperty ( ) ) { <nl> + / / Skip immutable wrapped properties . ` mutating func move ( along : ) ` cannot <nl> + / / be synthesized to update these properties . <nl> + auto mutability = originalProperty - > getPropertyWrapperMutability ( ) ; <nl> + assert ( mutability . hasValue ( ) & & " Expected wrapped property mutability " ) ; <nl> + if ( mutability - > Setter ! = PropertyWrapperMutability : : Value : : Mutating ) <nl> + continue ; <nl> + / / Use the original wrapped property . <nl> + vd = originalProperty ; <nl> + } <nl> / / Skip stored properties with ` @ noDerivative ` attribute . <nl> if ( vd - > getAttrs ( ) . hasAttribute < NoDerivativeAttr > ( ) ) <nl> continue ; <nl> - / / For property wrapper backing storage properties , skip if original <nl> - / / property has ` @ noDerivative ` attribute . <nl> - if ( auto * originalProperty = vd - > getOriginalWrappedProperty ( ) ) <nl> - if ( originalProperty - > getAttrs ( ) . hasAttribute < NoDerivativeAttr > ( ) ) <nl> - continue ; <nl> / / Skip ` let ` stored properties . ` mutating func move ( along : ) ` cannot be <nl> / / synthesized to update these properties . <nl> if ( vd - > isLet ( ) ) <nl> deriveBodyDifferentiable_method ( AbstractFunctionDecl * funcDecl , <nl> if ( confRef . isConcrete ( ) ) <nl> memberMethodDecl = confRef . getConcrete ( ) - > getWitnessDecl ( methodReq ) ; <nl> assert ( memberMethodDecl & & " Member method declaration must exist " ) ; <nl> - auto memberMethodDRE = <nl> + auto * memberMethodDRE = <nl> new ( C ) DeclRefExpr ( memberMethodDecl , DeclNameLoc ( ) , / * Implicit * / true ) ; <nl> memberMethodDRE - > setFunctionRefKind ( FunctionRefKind : : SingleApply ) ; <nl> <nl> / / Create reference to member method : ` x . move ( along : ) ` . <nl> - auto memberExpr = <nl> + Expr * memberExpr = <nl> new ( C ) MemberRefExpr ( selfDRE , SourceLoc ( ) , member , DeclNameLoc ( ) , <nl> / * Implicit * / true ) ; <nl> - auto memberMethodExpr = <nl> + auto * memberMethodExpr = <nl> new ( C ) DotSyntaxCallExpr ( memberMethodDRE , SourceLoc ( ) , memberExpr ) ; <nl> <nl> / / Create reference to parameter member : ` direction . x ` . <nl> static void addAssociatedTypeAliasDecl ( Identifier name , DeclContext * sourceDC , <nl> static void checkAndDiagnoseImplicitNoDerivative ( ASTContext & Context , <nl> NominalTypeDecl * nominal , <nl> DeclContext * DC ) { <nl> - auto * diffableProto = Context . getProtocol ( KnownProtocolKind : : Differentiable ) ; <nl> + / / If nominal type can conform to ` AdditiveArithmetic ` , suggest adding a <nl> + / / conformance to ` AdditiveArithmetic ` in fix - its . <nl> + / / ` Differentiable ` protocol requirements all have default implementations <nl> + / / when ` Self ` conforms to ` AdditiveArithmetic ` , so ` Differentiable ` <nl> + / / derived conformances will no longer be necessary . <nl> bool nominalCanDeriveAdditiveArithmetic = <nl> DerivedConformance : : canDeriveAdditiveArithmetic ( nominal , DC ) ; <nl> + auto * diffableProto = Context . getProtocol ( KnownProtocolKind : : Differentiable ) ; <nl> + / / Check all stored properties . <nl> for ( auto * vd : nominal - > getStoredProperties ( ) ) { <nl> + / / Peer through property wrappers : use original wrapped properties . <nl> + if ( auto * originalProperty = vd - > getOriginalWrappedProperty ( ) ) { <nl> + / / Skip wrapped properties with ` @ noDerivative ` attribute . <nl> + if ( originalProperty - > getAttrs ( ) . hasAttribute < NoDerivativeAttr > ( ) ) <nl> + continue ; <nl> + / / Diagnose wrapped properties whose property wrappers do not define <nl> + / / ` wrappedValue . set ` . ` mutating func move ( along : ) ` cannot be synthesized <nl> + / / to update these properties . <nl> + auto * wrapperDecl = <nl> + vd - > getInterfaceType ( ) - > getNominalOrBoundGenericNominal ( ) ; <nl> + auto mutability = originalProperty - > getPropertyWrapperMutability ( ) ; <nl> + assert ( mutability . hasValue ( ) & & " Expected wrapped property mutability " ) ; <nl> + if ( mutability - > Setter ! = PropertyWrapperMutability : : Value : : Mutating ) { <nl> + auto loc = <nl> + originalProperty - > getAttributeInsertionLoc ( / * forModifier * / false ) ; <nl> + Context . Diags <nl> + . diagnose ( <nl> + loc , <nl> + diag : : <nl> + differentiable_immutable_wrapper_implicit_noderivative_fixit , <nl> + wrapperDecl - > getNameStr ( ) , nominal - > getName ( ) , <nl> + nominalCanDeriveAdditiveArithmetic ) <nl> + . fixItInsert ( loc , " @ noDerivative " ) ; <nl> + / / Add an implicit ` @ noDerivative ` attribute . <nl> + originalProperty - > getAttrs ( ) . add ( <nl> + new ( Context ) NoDerivativeAttr ( / * Implicit * / true ) ) ; <nl> + continue ; <nl> + } <nl> + / / Use the original wrapped property . <nl> + vd = originalProperty ; <nl> + } <nl> if ( vd - > getInterfaceType ( ) - > hasError ( ) ) <nl> continue ; <nl> / / Skip stored properties with ` @ noDerivative ` attribute . <nl> if ( vd - > getAttrs ( ) . hasAttribute < NoDerivativeAttr > ( ) ) <nl> continue ; <nl> - / / For property wrapper backing storage properties , skip if original <nl> - / / property has ` @ noDerivative ` attribute . <nl> - if ( auto * originalProperty = vd - > getOriginalWrappedProperty ( ) ) <nl> - if ( originalProperty - > getAttrs ( ) . hasAttribute < NoDerivativeAttr > ( ) ) <nl> - continue ; <nl> / / Check whether to diagnose stored property . <nl> auto varType = DC - > mapTypeIntoContext ( vd - > getValueInterfaceType ( ) ) ; <nl> bool conformsToDifferentiable = <nl> static void checkAndDiagnoseImplicitNoDerivative ( ASTContext & Context , <nl> / / Otherwise , add an implicit ` @ noDerivative ` attribute . <nl> vd - > getAttrs ( ) . add ( new ( Context ) NoDerivativeAttr ( / * Implicit * / true ) ) ; <nl> auto loc = vd - > getAttributeInsertionLoc ( / * forModifier * / false ) ; <nl> - if ( auto * originalProperty = vd - > getOriginalWrappedProperty ( ) ) <nl> - loc = originalProperty - > getAttributeInsertionLoc ( / * forModifier * / false ) ; <nl> assert ( loc . isValid ( ) & & " Expected valid source location " ) ; <nl> - / / If nominal type can conform to ` AdditiveArithmetic ` , suggest conforming <nl> - / / adding a conformance to ` AdditiveArithmetic ` . <nl> - / / ` Differentiable ` protocol requirements all have default implementations <nl> - / / when ` Self ` conforms to ` AdditiveArithmetic ` , so ` Differentiable ` <nl> - / / derived conformances will no longer be necessary . <nl> + / / Diagnose properties that do not conform to ` Differentiable ` . <nl> if ( ! conformsToDifferentiable ) { <nl> Context . Diags <nl> . diagnose ( <nl> static void checkAndDiagnoseImplicitNoDerivative ( ASTContext & Context , <nl> . fixItInsert ( loc , " @ noDerivative " ) ; <nl> continue ; <nl> } <nl> + / / Otherwise , diagnose ` let ` property . <nl> Context . Diags <nl> . diagnose ( loc , <nl> diag : : differentiable_let_property_implicit_noderivative_fixit , <nl> - vd - > getName ( ) , nominal - > getName ( ) , <nl> - nominalCanDeriveAdditiveArithmetic ) <nl> + nominal - > getName ( ) , nominalCanDeriveAdditiveArithmetic ) <nl> . fixItInsert ( loc , " @ noDerivative " ) ; <nl> } <nl> } <nl> mmm a / test / AutoDiff / SILOptimizer / differentiation_diagnostics . swift <nl> ppp b / test / AutoDiff / SILOptimizer / differentiation_diagnostics . swift <nl> extension TF_691 : Differentiable where Scalar : Differentiable { } <nl> func identity < T > ( _ x : TF_691 < T > ) - > TF_691 < T > { x } <nl> let _ : @ differentiable ( Float ) - > TF_691 < Float > = { x in identity ( TF_691 ( x ) ) } <nl> let _ : @ differentiable ( Float ) - > TF_691 < Float > = { x in id ( TF_691 ( x ) ) } <nl> + <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + / / Property wrappers <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + <nl> + @ propertyWrapper <nl> + struct Wrapper < Value > { <nl> + private var value : Value <nl> + var wrappedValue : Value { <nl> + get { value } <nl> + set { value = newValue } <nl> + } <nl> + var projectedValue : Self { self } <nl> + <nl> + init ( wrappedValue : Value ) { <nl> + self . value = wrappedValue <nl> + } <nl> + } <nl> + <nl> + @ propertyWrapper <nl> + struct DifferentiableWrapper < Value > { <nl> + private var value : Value <nl> + var wrappedValue : Value { <nl> + get { value } <nl> + set { value = newValue } <nl> + } <nl> + var projectedValue : Self { self } <nl> + <nl> + init ( wrappedValue : Value ) { <nl> + self . value = wrappedValue <nl> + } <nl> + } <nl> + extension DifferentiableWrapper : Differentiable where Value : Differentiable { } <nl> + / / Note : property wrapped value differentiation works even if wrapper types do <nl> + / / not conform to ` Differentiable ` . The conformance here tests projected value <nl> + / / accesses . <nl> + <nl> + struct Struct : Differentiable { <nl> + / / expected - error @ + 2 { { expression is not differentiable } } <nl> + / / expected - note @ + 1 { { property cannot be differentiated because ' Struct . TangentVector ' does not have a member named ' _x ' } } <nl> + @ DifferentiableWrapper @ DifferentiableWrapper var x : Float = 10 <nl> + <nl> + @ Wrapper var y : Float = 20 <nl> + var z : Float = 30 <nl> + } <nl> + <nl> + @ differentiable <nl> + func differentiableProjectedValueAccess ( _ s : Struct ) - > Float { <nl> + s . $ x . wrappedValue . wrappedValue <nl> + } <nl> + <nl> + / / expected - error @ + 2 { { function is not differentiable } } <nl> + / / expected - note @ + 2 { { when differentiating this function definition } } <nl> + @ differentiable <nl> + func projectedValueAccess ( _ s : Struct ) - > Float { <nl> + / / expected - note @ + 1 { { cannot differentiate through a non - differentiable result ; do you want to use ' withoutDerivative ( at : ) ' ? } } <nl> + s . $ y . wrappedValue <nl> + } <nl> + <nl> + / / SR - 12640 : Test ` wrapperValue . modify ` differentiation . <nl> + <nl> + / / expected - error @ + 2 { { function is not differentiable } } <nl> + / / expected - note @ + 2 { { when differentiating this function definition } } <nl> + @ differentiable <nl> + func modify ( _ s : Struct , _ x : Float ) - > Float { <nl> + var s = s <nl> + / / expected - note @ + 1 { { differentiation of coroutine calls is not yet supported } } <nl> + s . x * = x * s . z <nl> + return s . x <nl> + } <nl> new file mode 100644 <nl> index 000000000000 . . 5b997ad17e5a <nl> mmm / dev / null <nl> ppp b / test / AutoDiff / SILOptimizer / semantic_member_accessors_sil . swift <nl> <nl> + / / RUN : % target - swift - frontend - emit - sil - Xllvm - sil - print - after = differentiation % s - o / dev / null 2 > & 1 | % FileCheck % s <nl> + <nl> + / / Test differentiation of semantic member accessors : <nl> + / / - Stored property accessors . <nl> + / / - Property wrapper wrapped value accessors . <nl> + <nl> + / / TODO ( TF - 1254 ) : Support forward - mode differentiation and test generated differentials . <nl> + <nl> + import _Differentiation <nl> + <nl> + @ propertyWrapper <nl> + struct Wrapper < Value > { <nl> + var wrappedValue : Value <nl> + } <nl> + <nl> + struct Struct : Differentiable { <nl> + @ Wrapper @ Wrapper var x : Float = 10 <nl> + var y : Float = 10 <nl> + } <nl> + <nl> + struct Generic < T > { <nl> + @ Wrapper @ Wrapper var x : T <nl> + var y : T <nl> + } <nl> + extension Generic : Differentiable where T : Differentiable { } <nl> + <nl> + func trigger < T : Differentiable > ( _ x : T . Type ) { <nl> + let _ : @ differentiable ( Struct ) - > Float = { $ 0 . x } <nl> + let _ : @ differentiable ( inout Struct , Float ) - > Void = { $ 0 . x = $ 1 } <nl> + <nl> + let _ : @ differentiable ( Generic < T > ) - > T = { $ 0 . x } <nl> + let _ : @ differentiable ( inout Generic < T > , T ) - > Void = { $ 0 . x = $ 1 } <nl> + } <nl> + <nl> + / / CHECK - LABEL : / / differentiability witness for Generic . x . setter <nl> + / / CHECK - NEXT : sil_differentiability_witness private [ parameters 0 1 ] [ results 0 ] < τ_0_0 where τ_0_0 : Differentiable > @ $ s4null7GenericV1xxvs : $ @ convention ( method ) < T > ( @ in T , @ inout Generic < T > ) - > ( ) { <nl> + <nl> + / / CHECK - LABEL : / / differentiability witness for Generic . x . getter <nl> + / / CHECK - NEXT : sil_differentiability_witness private [ parameters 0 ] [ results 0 ] < τ_0_0 where τ_0_0 : Differentiable > @ $ s4null7GenericV1xxvg : $ @ convention ( method ) < T > ( @ in_guaranteed Generic < T > ) - > @ out T { <nl> + <nl> + / / CHECK - LABEL : / / differentiability witness for Struct . x . setter <nl> + / / CHECK - NEXT : sil_differentiability_witness private [ parameters 0 1 ] [ results 0 ] @ $ s4null6StructV1xSfvs : $ @ convention ( method ) ( Float , @ inout Struct ) - > ( ) { <nl> + <nl> + / / CHECK - LABEL : / / differentiability witness for Struct . x . getter <nl> + / / CHECK - NEXT : sil_differentiability_witness private [ parameters 0 ] [ results 0 ] @ $ s4null6StructV1xSfvg : $ @ convention ( method ) ( Struct ) - > Float { <nl> + <nl> + / / CHECK - LABEL : sil private [ ossa ] @ AD__ $ s4null7GenericV1xxvs__pullback_src_0_wrt_0_1_16_Differentiation14DifferentiableRzl : $ @ convention ( method ) < τ_0_0 where τ_0_0 : Differentiable > ( @ inout Generic < τ_0_0 > . TangentVector , @ owned { { . * } } ) - > @ out τ_0_0 . TangentVector { <nl> + / / CHECK : bb0 ( [ [ ADJ_X_RESULT : % . * ] ] : $ * τ_0_0 . TangentVector , [ [ ADJ_SELF : % . * ] ] : $ * Generic < τ_0_0 > . TangentVector , { { . * } } : { { . * } } ) : <nl> + / / CHECK : [ [ ADJ_X_TMP : % . * ] ] = alloc_stack $ τ_0_0 . TangentVector <nl> + / / CHECK : [ [ ZERO_FN : % . * ] ] = witness_method $ τ_0_0 . TangentVector , # AdditiveArithmetic . zero ! getter <nl> + / / CHECK : apply [ [ ZERO_FN ] ] < τ_0_0 . TangentVector > ( [ [ ADJ_X_TMP ] ] , { { . * } } ) <nl> + / / CHECK : [ [ ADJ_X : % . * ] ] = struct_element_addr [ [ ADJ_SELF ] ] : $ * Generic < τ_0_0 > . TangentVector , # Generic . TangentVector . x <nl> + / / CHECK : [ [ ZERO_FN : % . * ] ] = witness_method $ τ_0_0 . TangentVector , # AdditiveArithmetic . " + = " <nl> + / / CHECK : apply [ [ ZERO_FN ] ] < τ_0_0 . TangentVector > ( [ [ ADJ_X_TMP ] ] , [ [ ADJ_X ] ] , { { . * } } ) <nl> + / / CHECK : destroy_addr [ [ ADJ_X ] ] : $ * τ_0_0 . TangentVector <nl> + / / CHECK : [ [ ZERO_FN : % . * ] ] = witness_method $ τ_0_0 . TangentVector , # AdditiveArithmetic . zero ! getter <nl> + / / CHECK : apply [ [ ZERO_FN ] ] < τ_0_0 . TangentVector > ( [ [ ADJ_X ] ] , { { . * } } ) <nl> + / / CHECK : copy_addr [ take ] [ [ ADJ_X_TMP ] ] to [ initialization ] [ [ ADJ_X_RESULT ] ] : $ * τ_0_0 . TangentVector <nl> + / / CHECK : dealloc_stack [ [ ADJ_X_TMP ] ] : $ * τ_0_0 . TangentVector <nl> + / / CHECK : return { { . * } } : $ ( ) <nl> + / / CHECK : } <nl> + <nl> + / / CHECK - LABEL : sil private [ ossa ] @ AD__ $ s4null7GenericV1xxvg__pullback_src_0_wrt_0_16_Differentiation14DifferentiableRzl : $ @ convention ( method ) < τ_0_0 where τ_0_0 : Differentiable > ( @ in_guaranteed τ_0_0 . TangentVector , @ owned { { . * } } ) - > @ out Generic < τ_0_0 > . TangentVector { <nl> + / / CHECK : bb0 ( [ [ ADJ_SELF_RESULT : % . * ] ] : $ * Generic < τ_0_0 > . TangentVector , [ [ SEED : % . * ] ] : $ * τ_0_0 . TangentVector , { { . * } } : $ { { . * } } ) : <nl> + / / CHECK : [ [ ADJ_SELF_TMP : % . * ] ] = alloc_stack $ Generic < τ_0_0 > . TangentVector <nl> + / / CHECK : [ [ SEED_COPY : % . * ] ] = alloc_stack $ τ_0_0 . TangentVector <nl> + / / CHECK : copy_addr [ [ SEED ] ] to [ initialization ] [ [ SEED_COPY ] ] : $ * τ_0_0 . TangentVector <nl> + / / CHECK : [ [ ADJ_X : % . * ] ] = struct_element_addr [ [ ADJ_SELF_TMP ] ] : $ * Generic < τ_0_0 > . TangentVector , # Generic . TangentVector . x <nl> + / / CHECK : copy_addr [ take ] [ [ SEED_COPY ] ] to [ initialization ] [ [ ADJ_X ] ] : $ * τ_0_0 . TangentVector <nl> + / / CHECK : [ [ ADJ_Y : % . * ] ] = struct_element_addr [ [ ADJ_SELF_TMP ] ] : $ * Generic < τ_0_0 > . TangentVector , # Generic . TangentVector . y <nl> + / / CHECK : [ [ ZERO_FN : % . * ] ] = witness_method $ τ_0_0 . TangentVector , # AdditiveArithmetic . zero ! getter <nl> + / / CHECK : apply [ [ ZERO_FN ] ] < τ_0_0 . TangentVector > ( [ [ ADJ_Y ] ] , { { . * } } ) <nl> + / / CHECK : copy_addr [ take ] [ [ ADJ_SELF_TMP ] ] to [ initialization ] [ [ ADJ_SELF_RESULT ] ] : $ * Generic < τ_0_0 > . TangentVector <nl> + / / CHECK : dealloc_stack [ [ SEED_COPY ] ] : $ * τ_0_0 . TangentVector <nl> + / / CHECK : dealloc_stack [ [ ADJ_SELF_TMP ] ] : $ * Generic < τ_0_0 > . TangentVector <nl> + / / CHECK : return { { . * } } : $ ( ) <nl> + / / CHECK : } <nl> + <nl> + / / CHECK - LABEL : sil private [ ossa ] @ AD__ $ s4null6StructV1xSfvs__pullback_src_0_wrt_0_1 : $ @ convention ( method ) ( @ inout Struct . TangentVector , @ owned _AD__ $ s4null6StructV1xSfvs_bb0__PB__src_0_wrt_0_1 ) - > Float { <nl> + / / CHECK : bb0 ( [ [ ADJ_SELF : % . * ] ] : $ * Struct . TangentVector , { { . * } } : $ _AD__ $ s4null6StructV1xSfvs_bb0__PB__src_0_wrt_0_1 ) : <nl> + / / CHECK : [ [ ADJ_X_ADDR : % . * ] ] = struct_element_addr [ [ ADJ_SELF ] ] : $ * Struct . TangentVector , # Struct . TangentVector . x <nl> + / / CHECK : [ [ ADJ_X : % . * ] ] = load [ trivial ] [ [ ADJ_X_ADDR ] ] : $ * Float <nl> + / / CHECK : [ [ ZERO_FN : % . * ] ] = witness_method $ Float , # AdditiveArithmetic . zero ! getter <nl> + / / CHECK : apply [ [ ZERO_FN ] ] < Float > ( [ [ ADJ_X_ADDR ] ] , { { . * } } ) <nl> + / / CHECK : return [ [ ADJ_X ] ] : $ Float <nl> + / / CHECK : } <nl> + <nl> + / / CHECK - LABEL : sil private [ ossa ] @ AD__ $ s4null6StructV1xSfvg__pullback_src_0_wrt_0 : $ @ convention ( method ) ( Float , @ owned _AD__ $ s4null6StructV1xSfvg_bb0__PB__src_0_wrt_0 ) - > Struct . TangentVector { <nl> + / / CHECK : bb0 ( [ [ ADJ_X : % . * ] ] : $ Float , { { . * } } : $ _AD__ $ s4null6StructV1xSfvg_bb0__PB__src_0_wrt_0 ) : <nl> + / / CHECK : [ [ ADJ_Y_ADDR : % . * ] ] = alloc_stack $ Float <nl> + / / CHECK : [ [ ZERO_FN : % . * ] ] = witness_method $ Float , # AdditiveArithmetic . zero ! getter <nl> + / / CHECK : apply [ [ ZERO_FN ] ] < Float > ( [ [ ADJ_Y_ADDR ] ] , { { . * } } ) <nl> + / / CHECK : [ [ ADJ_Y : % . * ] ] = load [ trivial ] [ [ ADJ_Y_ADDR ] ] : $ * Float <nl> + / / CHECK : dealloc_stack [ [ ADJ_Y_ADDR ] ] : $ * Float <nl> + / / CHECK : [ [ ADJ_SELF : % . * ] ] = struct $ Struct . TangentVector ( [ [ ADJ_X ] ] : $ Float , [ [ ADJ_Y ] ] : $ Float ) <nl> + / / CHECK : return [ [ ADJ_SELF ] ] : $ Struct . TangentVector <nl> + / / CHECK : } <nl> mmm a / test / AutoDiff / Sema / DerivedConformances / class_differentiable . swift <nl> ppp b / test / AutoDiff / Sema / DerivedConformances / class_differentiable . swift <nl> class ImmutableStoredProperties : Differentiable { <nl> / / expected - warning @ + 1 { { stored property ' nondiff ' has no derivative because ' Int ' does not conform to ' Differentiable ' ; add an explicit ' @ noDerivative ' attribute } } { { 3 - 3 = @ noDerivative } } <nl> let nondiff : Int <nl> <nl> - / / expected - warning @ + 1 { { synthesis of the ' Differentiable . move ( along : ) ' requirement for ' ImmutableStoredProperties ' requires all stored properties to be mutable ; use ' var ' instead , or add an explicit ' @ noDerivative ' attribute } } { { 3 - 3 = @ noDerivative } } <nl> + / / expected - warning @ + 1 { { synthesis of the ' Differentiable . move ( along : ) ' requirement for ' ImmutableStoredProperties ' requires all stored properties not marked with ` @ noDerivative ` to be mutable ; use ' var ' instead , or add an explicit ' @ noDerivative ' attribute } } { { 3 - 3 = @ noDerivative } } <nl> let diff : Float <nl> <nl> init ( ) { <nl> class MutableStoredPropertiesWithInitialValue : Differentiable { <nl> } <nl> / / Test class with both an empty constructor and memberwise initializer . <nl> class AllMixedStoredPropertiesHaveInitialValue : Differentiable { <nl> - let x = Float ( 1 ) / / expected - warning { { synthesis of the ' Differentiable . move ( along : ) ' requirement for ' AllMixedStoredPropertiesHaveInitialValue ' requires all stored properties to be mutable ; use ' var ' instead , or add an explicit ' @ noDerivative ' attribute } } { { 3 - 3 = @ noDerivative } } <nl> + / / expected - warning @ + 1 { { synthesis of the ' Differentiable . move ( along : ) ' requirement for ' AllMixedStoredPropertiesHaveInitialValue ' requires all stored properties not marked with ` @ noDerivative ` to be mutable ; use ' var ' instead , or add an explicit ' @ noDerivative ' attribute } } { { 3 - 3 = @ noDerivative } } <nl> + let x = Float ( 1 ) <nl> var y = Float ( 1 ) <nl> / / Memberwise initializer should be ` init ( y : ) ` since ` x ` is immutable . <nl> static func testMemberwiseInitializer ( ) { <nl> where T : AdditiveArithmetic { } <nl> extension NoMemberwiseInitializerExtended : Differentiable <nl> where T : Differentiable & AdditiveArithmetic { } <nl> <nl> + / / Test property wrappers . <nl> / / TF - 1190 : Test ` @ noDerivative ` warning for property wrapper backing storage properties . <nl> <nl> @ propertyWrapper <nl> - struct Wrapper < Value > { <nl> + struct ImmutableWrapper < Value > { <nl> private var value : Value <nl> - var wrappedValue : Value { <nl> - get { value } <nl> - set { value = newValue } <nl> + var wrappedValue : Value { value } <nl> + init ( wrappedValue : Value ) { <nl> + self . value = wrappedValue <nl> } <nl> } <nl> - struct TF_1190 < T > { } <nl> - class TF_1190_Outer : Differentiable { <nl> - / / expected - warning @ + 1 { { stored property ' _x ' has no derivative because ' Wrapper < TF_1190 < Float > > ' does not conform to ' Differentiable ' ; add an explicit ' @ noDerivative ' attribute } } <nl> - @ Wrapper var x : TF_1190 < Float > <nl> - @ noDerivative @ Wrapper var y : TF_1190 < Float > <nl> <nl> - init ( x : TF_1190 < Float > , y : TF_1190 < Float > ) { <nl> - self . x = x <nl> - self . y = y <nl> - } <nl> + @ propertyWrapper <nl> + struct Wrapper < Value > { <nl> + var wrappedValue : Value <nl> + } <nl> + <nl> + struct Generic < T > { } <nl> + extension Generic : Differentiable where T : Differentiable { } <nl> + <nl> + class WrappedProperties : Differentiable { <nl> + / / expected - warning @ + 1 { { synthesis of the ' Differentiable . move ( along : ) ' requirement for ' WrappedProperties ' requires all stored properties not marked with ` @ noDerivative ` to be mutable ; add an explicit ' @ noDerivative ' attribute } } <nl> + @ ImmutableWrapper var immutableInt : Generic < Int > = Generic ( ) <nl> + <nl> + / / expected - warning @ + 1 { { stored property ' mutableInt ' has no derivative because ' Generic < Int > ' does not conform to ' Differentiable ' ; add an explicit ' @ noDerivative ' attribute } } <nl> + @ Wrapper var mutableInt : Generic < Int > = Generic ( ) <nl> + <nl> + @ Wrapper var float : Generic < Float > = Generic ( ) <nl> + @ noDerivative @ ImmutableWrapper var nondiff : Generic < Int > = Generic ( ) <nl> } <nl> <nl> / / Test derived conformances in disallowed contexts . <nl> mmm a / test / AutoDiff / Sema / DerivedConformances / derived_differentiable . swift <nl> ppp b / test / AutoDiff / Sema / DerivedConformances / derived_differentiable . swift <nl> struct UsableFromInlineStruct : Differentiable { } <nl> / / CHECK - AST : internal init ( ) <nl> / / CHECK - AST : @ usableFromInline <nl> / / CHECK - AST : struct TangentVector : Differentiable , AdditiveArithmetic { <nl> + <nl> + / / Test property wrappers . <nl> + <nl> + @ propertyWrapper <nl> + struct Wrapper < Value > { <nl> + var wrappedValue : Value <nl> + } <nl> + <nl> + struct WrappedPropertiesStruct : Differentiable { <nl> + @ Wrapper @ Wrapper var x : Float <nl> + @ Wrapper var y : Float <nl> + var z : Float <nl> + @ noDerivative @ Wrapper var nondiff : Float <nl> + } <nl> + <nl> + / / CHECK - AST - LABEL : internal struct WrappedPropertiesStruct : Differentiable { <nl> + / / CHECK - AST : internal struct TangentVector : Differentiable , AdditiveArithmetic { <nl> + / / CHECK - AST : internal var x : Float . TangentVector <nl> + / / CHECK - AST : internal var y : Float . TangentVector <nl> + / / CHECK - AST : internal var z : Float . TangentVector <nl> + / / CHECK - AST : } <nl> + / / CHECK - AST : } <nl> + <nl> + class WrappedPropertiesClass : Differentiable { <nl> + @ Wrapper @ Wrapper var x : Float = 1 <nl> + @ Wrapper var y : Float = 2 <nl> + var z : Float = 3 <nl> + @ noDerivative @ Wrapper var noDeriv : Float = 4 <nl> + } <nl> + <nl> + / / CHECK - AST - LABEL : internal class WrappedPropertiesClass : Differentiable { <nl> + / / CHECK - AST : internal struct TangentVector : Differentiable , AdditiveArithmetic { <nl> + / / CHECK - AST : internal var x : Float . TangentVector <nl> + / / CHECK - AST : internal var y : Float . TangentVector <nl> + / / CHECK - AST : internal var z : Float . TangentVector <nl> + / / CHECK - AST : } <nl> + / / CHECK - AST : } <nl> mmm a / test / AutoDiff / Sema / DerivedConformances / struct_differentiable . swift <nl> ppp b / test / AutoDiff / Sema / DerivedConformances / struct_differentiable . swift <nl> struct ImmutableStoredProperties : Differentiable { <nl> / / expected - warning @ + 1 { { stored property ' nondiff ' has no derivative because ' Int ' does not conform to ' Differentiable ' ; add an explicit ' @ noDerivative ' attribute , or conform ' ImmutableStoredProperties ' to ' AdditiveArithmetic ' } } { { 3 - 3 = @ noDerivative } } <nl> let nondiff : Int <nl> <nl> - / / expected - warning @ + 1 { { synthesis of the ' Differentiable . move ( along : ) ' requirement for ' ImmutableStoredProperties ' requires all stored properties to be mutable ; use ' var ' instead , or add an explicit ' @ noDerivative ' attribute , or conform ' ImmutableStoredProperties ' to ' AdditiveArithmetic ' } } { { 3 - 3 = @ noDerivative } } <nl> + / / expected - warning @ + 1 { { synthesis of the ' Differentiable . move ( along : ) ' requirement for ' ImmutableStoredProperties ' requires all stored properties not marked with ` @ noDerivative ` to be mutable ; use ' var ' instead , or add an explicit ' @ noDerivative ' attribute , or conform ' ImmutableStoredProperties ' to ' AdditiveArithmetic } } { { 3 - 3 = @ noDerivative } } <nl> let diff : Float <nl> } <nl> func testImmutableStoredProperties ( ) { <nl> struct MutableStoredPropertiesWithInitialValue : Differentiable { <nl> } <nl> / / Test struct with both an empty constructor and memberwise initializer . <nl> struct AllMixedStoredPropertiesHaveInitialValue : Differentiable { <nl> - let x = Float ( 1 ) / / expected - warning { { synthesis of the ' Differentiable . move ( along : ) ' requirement for ' AllMixedStoredPropertiesHaveInitialValue ' requires all stored properties to be mutable ; use ' var ' instead , or add an explicit ' @ noDerivative ' attribute } } { { 3 - 3 = @ noDerivative } } <nl> + / / expected - warning @ + 1 { { synthesis of the ' Differentiable . move ( along : ) ' requirement for ' AllMixedStoredPropertiesHaveInitialValue ' requires all stored properties not marked with ` @ noDerivative ` to be mutable ; use ' var ' instead , or add an explicit ' @ noDerivative ' attribute } } { { 3 - 3 = @ noDerivative } } <nl> + let x = Float ( 1 ) <nl> var y = Float ( 1 ) <nl> / / Memberwise initializer should be ` init ( y : ) ` since ` x ` is immutable . <nl> static func testMemberwiseInitializer ( ) { <nl> where T : AdditiveArithmetic { } <nl> extension NoMemberwiseInitializerExtended : Differentiable <nl> where T : Differentiable & AdditiveArithmetic { } <nl> <nl> + / / Test property wrappers . <nl> / / TF - 1190 : Test ` @ noDerivative ` warning for property wrapper backing storage properties . <nl> <nl> @ propertyWrapper <nl> - struct Wrapper < Value > { <nl> + struct ImmutableWrapper < Value > { <nl> private var value : Value <nl> - var wrappedValue : Value { <nl> - value <nl> - } <nl> + var wrappedValue : Value { value } <nl> + } <nl> + <nl> + @ propertyWrapper <nl> + struct Wrapper < Value > { <nl> + var wrappedValue : Value <nl> } <nl> - struct TF_1190 < T > { } <nl> - struct TF_1190_Outer : Differentiable { <nl> - / / expected - warning @ + 1 { { stored property ' _x ' has no derivative because ' Wrapper < TF_1190 < Float > > ' does not conform to ' Differentiable ' ; add an explicit ' @ noDerivative ' attribute } } <nl> - @ Wrapper var x : TF_1190 < Float > <nl> - @ noDerivative @ Wrapper var y : TF_1190 < Float > <nl> + <nl> + struct Generic < T > { } <nl> + extension Generic : Differentiable where T : Differentiable { } <nl> + <nl> + struct WrappedProperties : Differentiable { <nl> + / / expected - warning @ + 1 { { synthesis of the ' Differentiable . move ( along : ) ' requirement for ' WrappedProperties ' requires all stored properties not marked with ` @ noDerivative ` to be mutable ; add an explicit ' @ noDerivative ' attribute } } <nl> + @ ImmutableWrapper var immutableInt : Generic < Int > <nl> + <nl> + / / expected - warning @ + 1 { { stored property ' mutableInt ' has no derivative because ' Generic < Int > ' does not conform to ' Differentiable ' ; add an explicit ' @ noDerivative ' attribute } } <nl> + @ Wrapper var mutableInt : Generic < Int > <nl> + <nl> + @ Wrapper var float : Generic < Float > <nl> + @ noDerivative @ ImmutableWrapper var nondiff : Generic < Int > <nl> } <nl> <nl> / / Verify that cross - file derived conformances are disallowed . <nl> new file mode 100644 <nl> index 000000000000 . . fdcace744089 <nl> mmm / dev / null <nl> ppp b / test / AutoDiff / compiler_crashers_fixed / sr12642 - differentiable - derivation - redeclared - property . swift <nl> <nl> + / / RUN : % target - swift - frontend - typecheck - verify % s <nl> + / / REQUIRES : asserts <nl> + <nl> + / / SR - 12642 : Crash regarding ` Differentiable ` derived conformances and <nl> + / / redeclared properties . This crash surfaced only briefly during the <nl> + / / implementation of wrapped property differentiation ( SR - 12637 ) . <nl> + <nl> + import _Differentiation <nl> + <nl> + @ propertyWrapper <nl> + struct Wrapper < Value > { <nl> + var wrappedValue : Value <nl> + } <nl> + <nl> + struct Generic < T > { } <nl> + extension Generic : Differentiable where T : Differentiable { } <nl> + <nl> + struct WrappedProperties : Differentiable { <nl> + / / expected - note @ + 2 { { ' int ' previously declared here } } <nl> + / / expected - warning @ + 1 { { stored property ' int ' has no derivative because ' Generic < Int > ' does not conform to ' Differentiable ' ; add an explicit ' @ noDerivative ' attribute } } <nl> + @ Wrapper var int : Generic < Int > <nl> + <nl> + / / expected - error @ + 1 { { invalid redeclaration of ' int ' } } <nl> + @ Wrapper var int : Generic < Int > <nl> + } <nl> new file mode 100644 <nl> index 000000000000 . . 6e637a619d4f <nl> mmm / dev / null <nl> ppp b / test / AutoDiff / validation - test / property_wrappers . swift <nl> <nl> + / / RUN : % target - run - simple - swift <nl> + / / TODO ( TF - 1254 ) : Support and test forward - mode differentiation . <nl> + / / TODO ( TF - 1254 ) : % target - run - simple - swift ( - Xfrontend - enable - experimental - forward - mode - differentiation ) <nl> + / / REQUIRES : executable_test <nl> + <nl> + import StdlibUnittest <nl> + import DifferentiationUnittest <nl> + <nl> + var PropertyWrapperTests = TestSuite ( " PropertyWrapperDifferentiation " ) <nl> + <nl> + @ propertyWrapper <nl> + struct SimpleWrapper < Value > { <nl> + var wrappedValue : Value / / stored property <nl> + } <nl> + <nl> + @ propertyWrapper <nl> + struct Wrapper < Value > { <nl> + private var value : Value <nl> + var wrappedValue : Value { / / computed property <nl> + get { value } <nl> + set { value = newValue } <nl> + } <nl> + <nl> + init ( wrappedValue : Value ) { <nl> + self . value = wrappedValue <nl> + } <nl> + } <nl> + <nl> + struct Struct : Differentiable { <nl> + @ Wrapper @ SimpleWrapper var x : Tracked < Float > = 10 <nl> + @ SimpleWrapper @ Wrapper var y : Tracked < Float > = 20 <nl> + var z : Tracked < Float > = 30 <nl> + } <nl> + <nl> + PropertyWrapperTests . test ( " SimpleStruct " ) { <nl> + func getter ( _ s : Struct ) - > Tracked < Float > { <nl> + return s . x <nl> + } <nl> + expectEqual ( . init ( x : 1 , y : 0 , z : 0 ) , gradient ( at : Struct ( ) , in : getter ) ) <nl> + <nl> + func setter ( _ s : Struct , _ x : Tracked < Float > ) - > Tracked < Float > { <nl> + var s = s <nl> + s . x = s . x * x * s . z <nl> + return s . x <nl> + } <nl> + expectEqual ( ( . init ( x : 60 , y : 0 , z : 20 ) , 300 ) , <nl> + gradient ( at : Struct ( ) , 2 , in : setter ) ) <nl> + <nl> + / / TODO ( SR - 12640 ) : Support ` modify ` accessors . <nl> + / * <nl> + func modify ( _ s : Struct , _ x : Tracked < Float > ) - > Tracked < Float > { <nl> + var s = s <nl> + s . x * = x * s . z <nl> + return s . x <nl> + } <nl> + expectEqual ( ( . init ( x : 60 , y : 0 , z : 20 ) , 300 ) , <nl> + gradient ( at : Struct ( ) , 2 , in : modify ) ) <nl> + * / <nl> + } <nl> + <nl> + struct GenericStruct < T > { <nl> + @ Wrapper var x : Tracked < Float > = 10 <nl> + @ Wrapper @ Wrapper @ Wrapper var y : T <nl> + var z : Tracked < Float > = 30 <nl> + } <nl> + extension GenericStruct : Differentiable where T : Differentiable { } <nl> + <nl> + PropertyWrapperTests . test ( " GenericStruct " ) { <nl> + func getter < T > ( _ s : GenericStruct < T > ) - > T { <nl> + return s . y <nl> + } <nl> + expectEqual ( . init ( x : 0 , y : 1 , z : 0 ) , <nl> + gradient ( at : GenericStruct < Tracked < Float > > ( y : 20 ) , in : getter ) ) <nl> + <nl> + func getter2 < T > ( _ s : GenericStruct < T > ) - > Tracked < Float > { <nl> + return s . x * s . z <nl> + } <nl> + expectEqual ( . init ( x : 30 , y : 0 , z : 10 ) , <nl> + gradient ( at : GenericStruct < Tracked < Float > > ( y : 20 ) , in : getter2 ) ) <nl> + <nl> + func setter < T > ( _ s : GenericStruct < T > , _ x : Tracked < Float > ) - > Tracked < Float > { <nl> + var s = s <nl> + s . x = s . x * x * s . z <nl> + return s . x <nl> + } <nl> + expectEqual ( ( . init ( x : 60 , y : 0 , z : 20 ) , 300 ) , <nl> + gradient ( at : GenericStruct < Tracked < Float > > ( y : 20 ) , 2 , in : setter ) ) <nl> + <nl> + / / TODO ( SR - 12640 ) : Support ` modify ` accessors . <nl> + / * <nl> + func modify < T > ( _ s : GenericStruct < T > , _ x : Tracked < Float > ) - > Tracked < Float > { <nl> + var s = s <nl> + s . x * = x * s . z <nl> + return s . x <nl> + } <nl> + expectEqual ( ( . init ( x : 60 , y : 0 , z : 20 ) , 300 ) , <nl> + gradient ( at : GenericStruct < Tracked < Float > > ( y : 1 ) , 2 , in : modify ) ) <nl> + * / <nl> + } <nl> + <nl> + / / FIXME ( TF - 1149 ) : Cannot differentiate active value with loadable type but <nl> + / / address - only tangent type . Triggered by marking properties with <nl> + / / ` @ differentiable ` , which triggers derivative vtable thunk entries . <nl> + / * <nl> + class Class : Differentiable { <nl> + @ differentiable <nl> + @ Wrapper @ Wrapper var x : Tracked < Float > = 10 <nl> + <nl> + @ differentiable <nl> + @ Wrapper var y : Tracked < Float > = 20 <nl> + <nl> + @ differentiable <nl> + var z : Tracked < Float > = 30 <nl> + } <nl> + <nl> + PropertyWrapperTests . test ( " SimpleClass " ) { <nl> + func getter ( _ c : Class ) - > Tracked < Float > { <nl> + return c . x <nl> + } <nl> + expectEqual ( . init ( x : 1 , y : 0 , z : 0 ) , gradient ( at : Class ( ) , in : getter ) ) <nl> + <nl> + func setter ( _ c : Class , _ x : Tracked < Float > ) - > Tracked < Float > { <nl> + var c = c <nl> + c . x = c . x * x * c . z <nl> + return c . x <nl> + } <nl> + expectEqual ( ( . init ( x : 60 , y : 0 , z : 20 ) , 300 ) , <nl> + gradient ( at : Class ( ) , 2 , in : setter ) ) <nl> + <nl> + / / TODO ( SR - 12640 ) : Support ` modify ` accessors . <nl> + / * <nl> + func modify ( _ c : Class , _ x : Tracked < Float > ) - > Tracked < Float > { <nl> + var c = c <nl> + c . x * = x * c . z <nl> + return c . x <nl> + } <nl> + expectEqual ( ( . init ( x : 60 , y : 0 , z : 20 ) , 300 ) , <nl> + gradient ( at : Class ( ) , 2 , in : modify ) ) <nl> + * / <nl> + } <nl> + * / <nl> + <nl> + / / From : https : / / github . com / apple / swift - evolution / blob / master / proposals / 0258 - property - wrappers . md # proposed - solution <nl> + @ propertyWrapper <nl> + enum Lazy < Value > { <nl> + case uninitialized ( ( ) - > Value ) <nl> + case initialized ( Value ) <nl> + <nl> + init ( wrappedValue : @ autoclosure @ escaping ( ) - > Value ) { <nl> + self = . uninitialized ( wrappedValue ) <nl> + } <nl> + <nl> + var wrappedValue : Value { <nl> + get { <nl> + switch self { <nl> + case . uninitialized ( let initializer ) : <nl> + let value = initializer ( ) <nl> + return value <nl> + case . initialized ( let value ) : <nl> + return value <nl> + } <nl> + } <nl> + set { <nl> + self = . initialized ( newValue ) <nl> + } <nl> + } <nl> + } <nl> + <nl> + / / From : https : / / github . com / apple / swift - evolution / blob / master / proposals / 0258 - property - wrappers . md # clamping - a - value - within - bounds <nl> + @ propertyWrapper <nl> + struct Clamping < V : Comparable > { <nl> + var value : V <nl> + let min : V <nl> + let max : V <nl> + <nl> + init ( wrappedValue : V , min : V , max : V ) { <nl> + value = wrappedValue <nl> + self . min = min <nl> + self . max = max <nl> + assert ( value > = min & & value < = max ) <nl> + } <nl> + <nl> + var wrappedValue : V { <nl> + get { return value } <nl> + set { <nl> + if newValue < min { <nl> + value = min <nl> + } else if newValue > max { <nl> + value = max <nl> + } else { <nl> + value = newValue <nl> + } <nl> + } <nl> + } <nl> + } <nl> + <nl> + struct RealPropertyWrappers : Differentiable { <nl> + @ Lazy var x : Float = 3 <nl> + <nl> + @ Clamping ( min : - 10 , max : 10 ) <nl> + var y : Float = 4 <nl> + } <nl> + <nl> + PropertyWrapperTests . test ( " RealPropertyWrappers " ) { <nl> + @ differentiable <nl> + func multiply ( _ s : RealPropertyWrappers ) - > Float { <nl> + return s . x * s . y <nl> + } <nl> + expectEqual ( . init ( x : 4 , y : 3 ) , <nl> + gradient ( at : RealPropertyWrappers ( x : 3 , y : 4 ) , in : multiply ) ) <nl> + } <nl> + <nl> + runAllTests ( ) <nl>
Merge remote - tracking branch ' origin / master ' into master - next
apple/swift
a30b2a61b1b9bdbb7b05fc4777daf24e689bd53e
2020-05-11T01:38:37Z
mmm a / flow / flow . cpp <nl> ppp b / flow / flow . cpp <nl> IRandom * deterministicRandom ( ) { <nl> if ( ! deterministicRandomSeed ) { <nl> static thread_local IRandom * preseedRandom = nullptr ; <nl> if ( ! preseedRandom ) { <nl> - preseedRandom = new DeterministicRandom ( 1 ) ; <nl> + preseedRandom = new DeterministicRandom ( 1 , true ) ; <nl> } <nl> <nl> return preseedRandom ; <nl> } <nl> - random = new DeterministicRandom ( deterministicRandomSeed ) ; <nl> + random = new DeterministicRandom ( deterministicRandomSeed , true ) ; <nl> } <nl> return random ; <nl> } <nl> mmm a / flow / flow . h <nl> ppp b / flow / flow . h <nl> inline Future < Void > delayJittered ( double seconds , int taskID = TaskDefaultDelay ) <nl> inline Future < Void > yield ( int taskID = TaskDefaultYield ) { return g_network - > yield ( taskID ) ; } <nl> inline bool check_yield ( int taskID = TaskDefaultYield ) { return g_network - > check_yield ( taskID ) ; } <nl> <nl> - void setRandomSeed ( ) ; <nl> - IRandom * deterministicRandom ( ) ; <nl> - IRandom * nondeterministicRandom ( ) ; <nl> - <nl> # include " flow / genericactors . actor . h " <nl> # endif <nl>
Remove unnecessary redefinition of new random functions . Enable rand logging for the generators returned by deterministicRandom ( ) .
apple/foundationdb
acb2fc67ac98db92688af300a102dc7bf9f38ced
2019-05-10T21:16:48Z
new file mode 100644 <nl> index 00000000000 . . a5366f5ab81 <nl> mmm / dev / null <nl> ppp b / ports / lz4 / CMakeLists . txt <nl> <nl> + cmake_minimum_required ( VERSION 3 . 0 ) <nl> + project ( lz4 ) <nl> + <nl> + if ( BUILD_SHARED_LIBS ) <nl> + add_definitions ( - DLZ4_DLL_EXPORT ) <nl> + endif ( ) <nl> + add_definitions ( - DXXH_NAMESPACE = LZ4_ ) <nl> + <nl> + add_library ( lz4 <nl> + lib / lz4 . c <nl> + lib / lz4frame . c <nl> + lib / lz4hc . c <nl> + lib / xxhash . c ) <nl> + <nl> + install ( TARGETS lz4 <nl> + RUNTIME DESTINATION bin <nl> + ARCHIVE DESTINATION lib <nl> + LIBRARY DESTINATION lib ) <nl> + <nl> + if ( NOT LZ4_SKIP_INCLUDES ) <nl> + install ( FILES <nl> + lib / lz4 . h <nl> + lib / lz4frame . h <nl> + lib / lz4hc . h <nl> + DESTINATION include ) <nl> + endif ( ) <nl> new file mode 100644 <nl> index 00000000000 . . 90be24a5b33 <nl> mmm / dev / null <nl> ppp b / ports / lz4 / CONTROL <nl> <nl> + Source : lz4 <nl> + Version : 1 . 7 . 4 . 2 <nl> + Description : Lossless compression algorithm , providing compression speed at 400 MB / s per core . <nl> new file mode 100644 <nl> index 00000000000 . . 48b4585ea5c <nl> mmm / dev / null <nl> ppp b / ports / lz4 / auto - define - import - macro . patch <nl> <nl> + diff - - git a / lz4 . h b / lz4 . h <nl> + index 7420ad8 . . c1c3e56 100644 <nl> + mmm a / lz4 . h <nl> ppp + b / lz4 . h <nl> + extern " C " { <nl> + * LZ4_DLL_EXPORT : <nl> + * Enable exporting of functions when building a Windows DLL <nl> + * / <nl> + + <nl> + + # define LZ4_DLL_IMPORT 1 <nl> + + <nl> + # if defined ( LZ4_DLL_EXPORT ) & & ( LZ4_DLL_EXPORT = = 1 ) <nl> + # define LZ4LIB_API __declspec ( dllexport ) <nl> + # elif defined ( LZ4_DLL_IMPORT ) & & ( LZ4_DLL_IMPORT = = 1 ) <nl> + diff - - git a / lz4frame . h b / lz4frame . h <nl> + index 3104d2e . . 4442461 100644 <nl> + mmm a / lz4frame . h <nl> ppp + b / lz4frame . h <nl> + extern " C " { <nl> + * LZ4_DLL_EXPORT : <nl> + * Enable exporting of functions when building a Windows DLL <nl> + * / <nl> + + <nl> + + # define LZ4_DLL_IMPORT 1 <nl> + + <nl> + # if defined ( LZ4_DLL_EXPORT ) & & ( LZ4_DLL_EXPORT = = 1 ) <nl> + # define LZ4FLIB_API __declspec ( dllexport ) <nl> + # elif defined ( LZ4_DLL_IMPORT ) & & ( LZ4_DLL_IMPORT = = 1 ) <nl> new file mode 100644 <nl> index 00000000000 . . 9e2153e4b55 <nl> mmm / dev / null <nl> ppp b / ports / lz4 / portfile . cmake <nl> <nl> + <nl> + include ( vcpkg_common_functions ) <nl> + set ( SOURCE_PATH $ { CURRENT_BUILDTREES_DIR } / src / lz4 - 1 . 7 . 4 . 2 ) <nl> + vcpkg_download_distfile ( ARCHIVE <nl> + URLS " https : / / github . com / lz4 / lz4 / archive / v1 . 7 . 4 . 2 . zip " <nl> + FILENAME " lz4 - 1 . 7 . 4 . 2 . zip " <nl> + SHA512 c9a65031225ccda43ad4c7622e9f36762c18e58b4aaf43b1a33f219186fb55c43ca354f574a1591188db39f57631351b1b90f96e0c150e28de08dcb65c6759d0 ) <nl> + <nl> + vcpkg_extract_source_archive ( $ { ARCHIVE } ) <nl> + <nl> + file ( COPY $ { CMAKE_CURRENT_LIST_DIR } / CMakeLists . txt DESTINATION $ { SOURCE_PATH } ) <nl> + <nl> + vcpkg_configure_cmake ( <nl> + SOURCE_PATH $ { SOURCE_PATH } <nl> + OPTIONS_DEBUG <nl> + - DLZ4_SKIP_INCLUDES = ON ) <nl> + <nl> + vcpkg_install_cmake ( ) <nl> + vcpkg_copy_pdbs ( ) <nl> + <nl> + if ( VCPKG_LIBRARY_LINKAGE STREQUAL dynamic ) <nl> + vcpkg_apply_patches ( <nl> + SOURCE_PATH $ { CURRENT_PACKAGES_DIR } / include <nl> + PATCHES <nl> + $ { CMAKE_CURRENT_LIST_DIR } / auto - define - import - macro . patch ) <nl> + endif ( ) <nl> + <nl> + file ( COPY $ { SOURCE_PATH } / lib / LICENSE DESTINATION $ { CURRENT_PACKAGES_DIR } / share / lz4 ) <nl> + file ( RENAME $ { CURRENT_PACKAGES_DIR } / share / lz4 / LICENSE $ { CURRENT_PACKAGES_DIR } / share / lz4 / copyright ) <nl>
add lz4
microsoft/vcpkg
bf559d51ec103b1267ba61798f230f8cca413adb
2016-12-30T12:31:33Z
mmm a / . gitmodules <nl> ppp b / . gitmodules <nl> <nl> [ submodule " FAudio " ] <nl> path = FAudio <nl> url = https : / / github . com / FNA - XNA / FAudio / <nl> - [ submodule " vkd3d " ] <nl> - path = vkd3d <nl> - url = https : / / github . com / ValveSoftware / vkd3d / <nl> - [ submodule " SPIRV - Headers " ] <nl> - path = SPIRV - Headers <nl> - url = https : / / github . com / KhronosGroup / SPIRV - Headers <nl> - [ submodule " Vulkan - Headers " ] <nl> - path = Vulkan - Headers <nl> - url = https : / / github . com / KhronosGroup / Vulkan - Headers <nl> [ submodule " gstreamer " ] <nl> path = gstreamer <nl> url = https : / / gitlab . freedesktop . org / gstreamer / gstreamer . git <nl> <nl> [ submodule " gst - orc " ] <nl> path = gst - orc <nl> url = https : / / gitlab . freedesktop . org / gstreamer / orc . git <nl> + [ submodule " vkd3d - proton " ] <nl> + path = vkd3d - proton <nl> + url = https : / / github . com / HansKristian - Work / vkd3d - proton <nl> mmm a / Makefile <nl> ppp b / Makefile <nl> d9vk : configure <nl> cp $ ( BUILD_DIR ) / dist / dist / lib / wine / dxvk / * . dll / vagrant / d9vk / lib / wine / dxvk / & & \ <nl> cp $ ( BUILD_DIR ) / dist / dist / lib64 / wine / dxvk / * . dll / vagrant / d9vk / lib64 / wine / dxvk / ' <nl> <nl> - vkd3d : configure <nl> - mkdir - p vagrant_share / vkd3d / lib / wine / vkd3d <nl> - mkdir - p vagrant_share / vkd3d / lib64 / wine / vkd3d <nl> - vagrant ssh - c ' make - C $ ( BUILD_DIR ) / $ ( UNSTRIPPED ) vkd3d & & \ <nl> - cp $ ( BUILD_DIR ) / dist / dist / lib / wine / vkd3d / * . dll / vagrant / vkd3d / lib / wine / vkd3d & & \ <nl> - cp $ ( BUILD_DIR ) / dist / dist / lib64 / wine / vkd3d / * . dll / vagrant / vkd3d / lib64 / wine / vkd3d ' <nl> + vkd3d - proton : configure <nl> + mkdir - p vagrant_share / vkd3d - proton / lib / wine / vkd3d - proton / <nl> + mkdir - p vagrant_share / vkd3d - proton / lib64 / wine / vkd3d - proton / <nl> + vagrant ssh - c ' make - C $ ( BUILD_DIR ) / $ ( UNSTRIPPED ) vkd3d - proton & & \ <nl> + cp $ ( BUILD_DIR ) / dist / dist / lib / wine / vkd3d - proton / * . dll / vagrant / vkd3d - proton / lib / wine / vkd3d - proton / & & \ <nl> + cp $ ( BUILD_DIR ) / dist / dist / lib64 / wine / vkd3d - proton / * . dll / vagrant / vkd3d - proton / lib64 / wine / vkd3d - proton / ' <nl> <nl> lsteamclient : configure <nl> mkdir - p vagrant_share / lsteamclient / lib / wine <nl> deleted file mode 160000 <nl> index 63d4d272 . . 00000000 <nl> mmm a / SPIRV - Headers <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - Subproject commit 63d4d272f6e5b3cb9bb2bb50718a886a3eef4dab <nl> deleted file mode 160000 <nl> index db1a98c6 . . 00000000 <nl> mmm a / Vulkan - Headers <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - Subproject commit db1a98c6cc430725669ea10eb6a35b3584d5f3ab <nl> mmm a / build / makefile_base . mak <nl> ppp b / build / makefile_base . mak <nl> ifneq ( $ ( UNSTRIPPED_BUILD ) , ) <nl> STRIP : = <nl> INSTALL_PROGRAM_FLAGS : = <nl> MESON_STRIP_ARG : = <nl> - VKD3D_INSTALL_TARGET : = install <nl> else <nl> STRIP : = strip <nl> INSTALL_PROGRAM_FLAGS : = - s <nl> MESON_STRIP_ARG : = - - strip <nl> - VKD3D_INSTALL_TARGET : = install - strip <nl> endif <nl> <nl> OPTIMIZE_FLAGS : = - O2 - march = nocona $ ( call cc - option , $ ( CC ) , - mtune = core - avx2 , ) - mfpmath = sse <nl> DXVK : = $ ( SRCDIR ) / dxvk <nl> DXVK_OBJ32 : = . / obj - dxvk32 <nl> DXVK_OBJ64 : = . / obj - dxvk64 <nl> <nl> - VULKAN_HEADERS : = $ ( SRCDIR ) / Vulkan - Headers <nl> - VULKAN_H_OBJ32 : = . / obj - vulkan - headers32 <nl> - VULKAN_H_OBJ64 : = . / obj - vulkan - headers64 <nl> - VULKAN_H32 : = $ ( TOOLS_DIR32 ) / include / vulkan / vulkan . h <nl> - VULKAN_H64 : = $ ( TOOLS_DIR64 ) / include / vulkan / vulkan . h <nl> - <nl> - SPIRV_HEADERS : = $ ( SRCDIR ) / SPIRV - Headers <nl> - SPIRV_H_OBJ32 : = . / obj - spirv - headers32 <nl> - SPIRV_H_OBJ64 : = . / obj - spirv - headers64 <nl> - SPIRV_H32 : = $ ( TOOLS_DIR32 ) / include / spirv / spirv . h <nl> - SPIRV_H64 : = $ ( TOOLS_DIR64 ) / include / spirv / spirv . h <nl> - <nl> - VKD3D : = $ ( SRCDIR ) / vkd3d <nl> + VKD3D : = $ ( SRCDIR ) / vkd3d - proton <nl> VKD3D_OBJ32 : = . / obj - vkd3d32 <nl> VKD3D_OBJ64 : = . / obj - vkd3d64 <nl> <nl> OBJ_DIRS : = $ ( TOOLS_DIR32 ) $ ( TOOLS_DIR64 ) \ <nl> $ ( VRCLIENT_OBJ32 ) $ ( VRCLIENT_OBJ64 ) \ <nl> $ ( DXVK_OBJ32 ) $ ( DXVK_OBJ64 ) \ <nl> $ ( BISON_OBJ32 ) $ ( BISON_OBJ64 ) \ <nl> - $ ( VULKAN_H_OBJ32 ) $ ( VULKAN_H_OBJ64 ) \ <nl> - $ ( SPIRV_H_OBJ32 ) $ ( SPIRV_H_OBJ64 ) \ <nl> $ ( WINEWIDL_OBJ32 ) $ ( WINEWIDL_OBJ64 ) \ <nl> $ ( VKD3D_OBJ32 ) $ ( VKD3D_OBJ64 ) \ <nl> $ ( CMAKE_OBJ32 ) $ ( CMAKE_OBJ64 ) <nl> $ ( DIST_FONTS ) : fonts <nl> ALL_TARGETS + = dist <nl> GOAL_TARGETS + = dist <nl> <nl> - dist : $ ( DIST_TARGETS ) wine gst_good vrclient lsteamclient steam dxvk | $ ( DST_DIR ) <nl> + dist : $ ( DIST_TARGETS ) wine gst_good vrclient lsteamclient steam dxvk vkd3d - proton | $ ( DST_DIR ) <nl> echo ` date ' + % s ' ` ` GIT_DIR = $ ( abspath $ ( SRCDIR ) / . git ) git describe - - tags ` > $ ( DIST_VERSION ) <nl> cp $ ( DIST_VERSION ) $ ( DST_BASE ) / <nl> rm - rf $ ( abspath $ ( DIST_PREFIX ) ) & & \ <nl> dxvk32 : $ ( DXVK_CONFIGURE_FILES32 ) <nl> <nl> endif # NO_DXVK <nl> <nl> - # Vulkan - Headers <nl> - <nl> - VULKAN_H_CONFIGURE_FILES32 : = $ ( VULKAN_H_OBJ32 ) / Makefile <nl> - VULKAN_H_CONFIGURE_FILES64 : = $ ( VULKAN_H_OBJ64 ) / Makefile <nl> - <nl> - $ ( VULKAN_H_CONFIGURE_FILES32 ) : SHELL = $ ( CONTAINER_SHELL32 ) <nl> - $ ( VULKAN_H_CONFIGURE_FILES32 ) : $ ( MAKEFILE_DEP ) $ ( CMAKE_BIN32 ) $ ( VULKAN_HEADERS ) / CMakeLists . txt | $ ( VULKAN_H_OBJ32 ) <nl> - cd $ ( abspath $ ( VULKAN_H_OBJ32 ) ) & & \ <nl> - . . / $ ( CMAKE_BIN32 ) - DCMAKE_INSTALL_PREFIX = $ ( abspath $ ( TOOLS_DIR32 ) ) $ ( abspath $ ( VULKAN_HEADERS ) ) <nl> - <nl> - $ ( VULKAN_H_CONFIGURE_FILES64 ) : SHELL = $ ( CONTAINER_SHELL64 ) <nl> - $ ( VULKAN_H_CONFIGURE_FILES64 ) : $ ( MAKEFILE_DEP ) $ ( CMAKE_BIN64 ) $ ( VULKAN_HEADERS ) / CMakeLists . txt | $ ( VULKAN_H_OBJ64 ) <nl> - cd $ ( abspath $ ( VULKAN_H_OBJ64 ) ) & & \ <nl> - . . / $ ( CMAKE_BIN64 ) - DCMAKE_INSTALL_PREFIX = $ ( abspath $ ( TOOLS_DIR64 ) ) $ ( abspath $ ( VULKAN_HEADERS ) ) <nl> - <nl> - $ ( VULKAN_H32 ) : SHELL = $ ( CONTAINER_SHELL32 ) <nl> - $ ( VULKAN_H32 ) : $ ( VULKAN_H_CONFIGURE_FILES32 ) | $ ( VULKAN_H_OBJ32 ) <nl> - cd $ ( abspath $ ( VULKAN_H_OBJ32 ) ) & & \ <nl> - . . / $ ( CMAKE_BIN32 ) - - build . - - target install <nl> - <nl> - $ ( VULKAN_H64 ) : SHELL = $ ( CONTAINER_SHELL64 ) <nl> - $ ( VULKAN_H64 ) : $ ( VULKAN_H_CONFIGURE_FILES64 ) | $ ( VULKAN_H_OBJ64 ) <nl> - cd $ ( abspath $ ( VULKAN_H_OBJ64 ) ) & & \ <nl> - . . / $ ( CMAKE_BIN64 ) - - build . - - target install <nl> - <nl> - # SPIRV - Headers <nl> - <nl> - SPIRV_H_CONFIGURE_FILES32 : = $ ( SPIRV_H_OBJ32 ) / Makefile <nl> - SPIRV_H_CONFIGURE_FILES64 : = $ ( SPIRV_H_OBJ64 ) / Makefile <nl> - <nl> - $ ( SPIRV_H_CONFIGURE_FILES32 ) : SHELL = $ ( CONTAINER_SHELL32 ) <nl> - $ ( SPIRV_H_CONFIGURE_FILES32 ) : $ ( MAKEFILE_DEP ) $ ( CMAKE_BIN32 ) $ ( SPIRV_HEADERS ) / CMakeLists . txt | $ ( SPIRV_H_OBJ32 ) <nl> - cd $ ( abspath $ ( SPIRV_H_OBJ32 ) ) & & \ <nl> - . . / $ ( CMAKE_BIN32 ) - DCMAKE_INSTALL_PREFIX = $ ( abspath $ ( TOOLS_DIR32 ) ) $ ( abspath $ ( SPIRV_HEADERS ) ) <nl> - <nl> - $ ( SPIRV_H_CONFIGURE_FILES64 ) : SHELL = $ ( CONTAINER_SHELL64 ) <nl> - $ ( SPIRV_H_CONFIGURE_FILES64 ) : $ ( MAKEFILE_DEP ) $ ( CMAKE_BIN64 ) $ ( SPIRV_HEADERS ) / CMakeLists . txt | $ ( SPIRV_H_OBJ64 ) <nl> - cd $ ( abspath $ ( SPIRV_H_OBJ64 ) ) & & \ <nl> - . . / $ ( CMAKE_BIN64 ) - DCMAKE_INSTALL_PREFIX = $ ( abspath $ ( TOOLS_DIR64 ) ) $ ( abspath $ ( SPIRV_HEADERS ) ) <nl> - <nl> - $ ( SPIRV_H32 ) : SHELL = $ ( CONTAINER_SHELL32 ) <nl> - $ ( SPIRV_H32 ) : $ ( SPIRV_H_CONFIGURE_FILES32 ) <nl> - cd $ ( abspath $ ( SPIRV_H_OBJ32 ) ) & & \ <nl> - . . / $ ( CMAKE_BIN32 ) - - build . - - target install <nl> - <nl> - $ ( SPIRV_H64 ) : SHELL = $ ( CONTAINER_SHELL64 ) <nl> - $ ( SPIRV_H64 ) : $ ( SPIRV_H_CONFIGURE_FILES64 ) <nl> - cd $ ( abspath $ ( SPIRV_H_OBJ64 ) ) & & \ <nl> - . . / $ ( CMAKE_BIN64 ) - - build . - - target install <nl> - <nl> # widl ; required for vkd3d , which is built before wine <nl> <nl> WINEWIDL_CONFIGURE_FILES64 : = $ ( WINEWIDL_OBJ64 ) / Makefile <nl> VKD3D_CONFIGURE_FILES64 : = $ ( VKD3D_OBJ64 ) / build . ninja <nl> <nl> $ ( VKD3D_CONFIGURE_FILES32 ) : SHELL = $ ( CONTAINER_SHELL32 ) <nl> $ ( VKD3D_CONFIGURE_FILES32 ) : $ ( VKD3D ) / meson . build $ ( VKD3D ) / build - win32 . txt $ ( WINEWIDL32 ) | $ ( VKD3D_OBJ32 ) <nl> - ( cd $ ( abspath $ ( VKD3D ) ) & & git submodule update - - init - - recursive ) & & \ <nl> - cd $ ( abspath $ ( VKD3D_OBJ32 ) ) & & \ <nl> - PATH = " $ ( abspath $ ( SRCDIR ) ) / glslang / bin / : $ ( abspath $ ( WINEWIDL_OBJ32 ) ) / tools / widl : $ ( PATH ) " \ <nl> - meson - - prefix = " $ ( abspath $ ( VKD3D_OBJ32 ) ) " - - cross - file " $ ( abspath $ ( VKD3D ) ) / build - win32 . txt " $ ( MESON_STRIP_ARG ) - - buildtype = release - Denable_standalone_d3d12 = true " $ ( abspath $ ( VKD3D ) ) " <nl> + cd $ ( abspath $ ( VKD3D_OBJ32 ) ) & & \ <nl> + PATH = " $ ( abspath $ ( SRCDIR ) ) / glslang / bin / : $ ( abspath $ ( WINEWIDL_OBJ32 ) ) / tools / widl : $ ( PATH ) " \ <nl> + meson - - prefix = " $ ( abspath $ ( VKD3D_OBJ32 ) ) " \ <nl> + - - cross - file " $ ( abspath $ ( VKD3D ) ) / build - win32 . txt " \ <nl> + $ ( MESON_STRIP_ARG ) \ <nl> + - - buildtype = release - Denable_standalone_d3d12 = true \ <nl> + " $ ( abspath $ ( VKD3D ) ) " <nl> <nl> vkd3d32 : SHELL = $ ( CONTAINER_SHELL32 ) <nl> vkd3d32 : $ ( VKD3D_CONFIGURE_FILES32 ) <nl> - ( cd $ ( abspath $ ( VKD3D ) ) & & git submodule update - - init - - recursive ) & & \ <nl> - ninja - C " $ ( VKD3D_OBJ32 ) " install & & \ <nl> - mkdir - p " $ ( DST_DIR ) " / lib / wine / vkd3d & & \ <nl> - cp " $ ( VKD3D_OBJ32 ) / bin / d3d12 . dll " " $ ( DST_DIR ) " / lib / wine / vkd3d <nl> + ninja - C " $ ( VKD3D_OBJ32 ) " install <nl> + mkdir - p " $ ( DST_DIR ) " / lib / wine / vkd3d - proton <nl> + cp " $ ( VKD3D_OBJ32 ) / bin / d3d12 . dll " " $ ( DST_DIR ) " / lib / wine / vkd3d - proton / <nl> + if test - e $ ( SRCDIR ) / . git ; then ( cd $ ( SRCDIR ) & & git submodule status - - vkd3d - proton ) > " $ ( DST_DIR ) " / lib / wine / vkd3d - proton / version ; fi <nl> <nl> $ ( VKD3D_CONFIGURE_FILES64 ) : SHELL = $ ( CONTAINER_SHELL64 ) <nl> $ ( VKD3D_CONFIGURE_FILES64 ) : $ ( VKD3D ) / meson . build $ ( VKD3D ) / build - win64 . txt $ ( WINEWIDL64 ) | $ ( VKD3D_OBJ64 ) <nl> - ( cd $ ( abspath $ ( VKD3D ) ) & & git submodule update - - init - - recursive ) & & \ <nl> - cd $ ( abspath $ ( VKD3D_OBJ64 ) ) & & \ <nl> - PATH = " $ ( abspath $ ( SRCDIR ) ) / glslang / bin / : $ ( abspath $ ( WINEWIDL_OBJ64 ) ) / tools / widl : $ ( PATH ) " \ <nl> - meson - - prefix = " $ ( abspath $ ( VKD3D_OBJ64 ) ) " - - cross - file " $ ( abspath $ ( VKD3D ) ) / build - win64 . txt " $ ( MESON_STRIP_ARG ) - - buildtype = release - Denable_standalone_d3d12 = true " $ ( abspath $ ( VKD3D ) ) " <nl> + cd $ ( abspath $ ( VKD3D_OBJ64 ) ) & & \ <nl> + PATH = " $ ( abspath $ ( SRCDIR ) ) / glslang / bin / : $ ( abspath $ ( WINEWIDL_OBJ64 ) ) / tools / widl : $ ( PATH ) " \ <nl> + meson - - prefix = " $ ( abspath $ ( VKD3D_OBJ64 ) ) " \ <nl> + - - cross - file " $ ( abspath $ ( VKD3D ) ) / build - win64 . txt " \ <nl> + $ ( MESON_STRIP_ARG ) \ <nl> + - - buildtype = release - Denable_standalone_d3d12 = true \ <nl> + " $ ( abspath $ ( VKD3D ) ) " <nl> <nl> vkd3d64 : SHELL = $ ( CONTAINER_SHELL64 ) <nl> vkd3d64 : $ ( VKD3D_CONFIGURE_FILES64 ) <nl> - ( cd $ ( abspath $ ( VKD3D ) ) & & git submodule update - - init - - recursive ) & & \ <nl> - ninja - C " $ ( VKD3D_OBJ64 ) " install & & \ <nl> - mkdir - p " $ ( DST_DIR ) " / lib64 / wine / vkd3d & & \ <nl> - cp " $ ( VKD3D_OBJ64 ) / bin / d3d12 . dll " " $ ( DST_DIR ) " / lib64 / wine / vkd3d <nl> + ninja - C " $ ( VKD3D_OBJ64 ) " install <nl> + mkdir - p " $ ( DST_DIR ) " / lib64 / wine / vkd3d - proton <nl> + cp " $ ( VKD3D_OBJ64 ) / bin / d3d12 . dll " " $ ( DST_DIR ) " / lib64 / wine / vkd3d - proton / <nl> + if test - e $ ( SRCDIR ) / . git ; then ( cd $ ( SRCDIR ) & & git submodule status - - vkd3d - proton ) > " $ ( DST_DIR ) " / lib64 / wine / vkd3d - proton / version ; fi <nl> + <nl> + vkd3d : vkd3d - proton <nl> <nl> - vkd3d : vkd3d32 vkd3d64 <nl> + vkd3d - proton : vkd3d32 vkd3d64 <nl> <nl> # TODO Tests <nl> # build_vrclient64_tests <nl> Binary files a / glslang / bin / glslangValidator and b / glslang / bin / glslangValidator differ <nl> deleted file mode 100644 <nl> index d4f57efd . . 00000000 <nl> mmm a / glslang / include / SPIRV / GLSL . ext . AMD . h <nl> ppp / dev / null <nl> <nl> - / * <nl> - * * Copyright ( c ) 2014 - 2016 The Khronos Group Inc . <nl> - * * <nl> - * * Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - * * of this software and / or associated documentation files ( the " Materials " ) , <nl> - * * to deal in the Materials without restriction , including without limitation <nl> - * * the rights to use , copy , modify , merge , publish , distribute , sublicense , <nl> - * * and / or sell copies of the Materials , and to permit persons to whom the <nl> - * * Materials are furnished to do so , subject to the following conditions : <nl> - * * <nl> - * * The above copyright notice and this permission notice shall be included in <nl> - * * all copies or substantial portions of the Materials . <nl> - * * <nl> - * * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS <nl> - * * STANDARDS . THE UNMODIFIED , NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND <nl> - * * HEADER INFORMATION ARE LOCATED AT https : / / www . khronos . org / registry / <nl> - * * <nl> - * * THE MATERIALS ARE PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS <nl> - * * OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - * * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL <nl> - * * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - * * LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING <nl> - * * FROM , OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS <nl> - * * IN THE MATERIALS . <nl> - * / <nl> - <nl> - # ifndef GLSLextAMD_H <nl> - # define GLSLextAMD_H <nl> - <nl> - enum BuiltIn ; <nl> - enum Capability ; <nl> - enum Decoration ; <nl> - enum Op ; <nl> - <nl> - static const int GLSLextAMDVersion = 100 ; <nl> - static const int GLSLextAMDRevision = 6 ; <nl> - <nl> - / / SPV_AMD_shader_ballot <nl> - static const char * const E_SPV_AMD_shader_ballot = " SPV_AMD_shader_ballot " ; <nl> - <nl> - enum ShaderBallotAMD { <nl> - ShaderBallotBadAMD = 0 , / / Don ' t use <nl> - <nl> - SwizzleInvocationsAMD = 1 , <nl> - SwizzleInvocationsMaskedAMD = 2 , <nl> - WriteInvocationAMD = 3 , <nl> - MbcntAMD = 4 , <nl> - <nl> - ShaderBallotCountAMD <nl> - } ; <nl> - <nl> - / / SPV_AMD_shader_trinary_minmax <nl> - static const char * const E_SPV_AMD_shader_trinary_minmax = " SPV_AMD_shader_trinary_minmax " ; <nl> - <nl> - enum ShaderTrinaryMinMaxAMD { <nl> - ShaderTrinaryMinMaxBadAMD = 0 , / / Don ' t use <nl> - <nl> - FMin3AMD = 1 , <nl> - UMin3AMD = 2 , <nl> - SMin3AMD = 3 , <nl> - FMax3AMD = 4 , <nl> - UMax3AMD = 5 , <nl> - SMax3AMD = 6 , <nl> - FMid3AMD = 7 , <nl> - UMid3AMD = 8 , <nl> - SMid3AMD = 9 , <nl> - <nl> - ShaderTrinaryMinMaxCountAMD <nl> - } ; <nl> - <nl> - / / SPV_AMD_shader_explicit_vertex_parameter <nl> - static const char * const E_SPV_AMD_shader_explicit_vertex_parameter = " SPV_AMD_shader_explicit_vertex_parameter " ; <nl> - <nl> - enum ShaderExplicitVertexParameterAMD { <nl> - ShaderExplicitVertexParameterBadAMD = 0 , / / Don ' t use <nl> - <nl> - InterpolateAtVertexAMD = 1 , <nl> - <nl> - ShaderExplicitVertexParameterCountAMD <nl> - } ; <nl> - <nl> - / / SPV_AMD_gcn_shader <nl> - static const char * const E_SPV_AMD_gcn_shader = " SPV_AMD_gcn_shader " ; <nl> - <nl> - enum GcnShaderAMD { <nl> - GcnShaderBadAMD = 0 , / / Don ' t use <nl> - <nl> - CubeFaceIndexAMD = 1 , <nl> - CubeFaceCoordAMD = 2 , <nl> - TimeAMD = 3 , <nl> - <nl> - GcnShaderCountAMD <nl> - } ; <nl> - <nl> - / / SPV_AMD_gpu_shader_half_float <nl> - static const char * const E_SPV_AMD_gpu_shader_half_float = " SPV_AMD_gpu_shader_half_float " ; <nl> - <nl> - / / SPV_AMD_texture_gather_bias_lod <nl> - static const char * const E_SPV_AMD_texture_gather_bias_lod = " SPV_AMD_texture_gather_bias_lod " ; <nl> - <nl> - / / SPV_AMD_gpu_shader_int16 <nl> - static const char * const E_SPV_AMD_gpu_shader_int16 = " SPV_AMD_gpu_shader_int16 " ; <nl> - <nl> - / / SPV_AMD_shader_image_load_store_lod <nl> - static const char * const E_SPV_AMD_shader_image_load_store_lod = " SPV_AMD_shader_image_load_store_lod " ; <nl> - <nl> - / / SPV_AMD_shader_fragment_mask <nl> - static const char * const E_SPV_AMD_shader_fragment_mask = " SPV_AMD_shader_fragment_mask " ; <nl> - <nl> - # endif / / # ifndef GLSLextAMD_H <nl> deleted file mode 100644 <nl> index 2eb10ae6 . . 00000000 <nl> mmm a / glslang / include / SPIRV / GLSL . ext . KHR . h <nl> ppp / dev / null <nl> <nl> - / * <nl> - * * Copyright ( c ) 2014 - 2016 The Khronos Group Inc . <nl> - * * <nl> - * * Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - * * of this software and / or associated documentation files ( the " Materials " ) , <nl> - * * to deal in the Materials without restriction , including without limitation <nl> - * * the rights to use , copy , modify , merge , publish , distribute , sublicense , <nl> - * * and / or sell copies of the Materials , and to permit persons to whom the <nl> - * * Materials are furnished to do so , subject to the following conditions : <nl> - * * <nl> - * * The above copyright notice and this permission notice shall be included in <nl> - * * all copies or substantial portions of the Materials . <nl> - * * <nl> - * * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS <nl> - * * STANDARDS . THE UNMODIFIED , NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND <nl> - * * HEADER INFORMATION ARE LOCATED AT https : / / www . khronos . org / registry / <nl> - * * <nl> - * * THE MATERIALS ARE PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS <nl> - * * OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - * * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL <nl> - * * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - * * LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING <nl> - * * FROM , OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS <nl> - * * IN THE MATERIALS . <nl> - * / <nl> - <nl> - # ifndef GLSLextKHR_H <nl> - # define GLSLextKHR_H <nl> - <nl> - enum BuiltIn ; <nl> - enum Op ; <nl> - enum Capability ; <nl> - <nl> - static const int GLSLextKHRVersion = 100 ; <nl> - static const int GLSLextKHRRevision = 2 ; <nl> - <nl> - static const char * const E_SPV_KHR_shader_ballot = " SPV_KHR_shader_ballot " ; <nl> - static const char * const E_SPV_KHR_subgroup_vote = " SPV_KHR_subgroup_vote " ; <nl> - static const char * const E_SPV_KHR_device_group = " SPV_KHR_device_group " ; <nl> - static const char * const E_SPV_KHR_multiview = " SPV_KHR_multiview " ; <nl> - static const char * const E_SPV_KHR_shader_draw_parameters = " SPV_KHR_shader_draw_parameters " ; <nl> - static const char * const E_SPV_KHR_16bit_storage = " SPV_KHR_16bit_storage " ; <nl> - static const char * const E_SPV_KHR_storage_buffer_storage_class = " SPV_KHR_storage_buffer_storage_class " ; <nl> - static const char * const E_SPV_KHR_post_depth_coverage = " SPV_KHR_post_depth_coverage " ; <nl> - static const char * const E_SPV_EXT_shader_stencil_export = " SPV_EXT_shader_stencil_export " ; <nl> - static const char * const E_SPV_EXT_shader_viewport_index_layer = " SPV_EXT_shader_viewport_index_layer " ; <nl> - <nl> - # endif / / # ifndef GLSLextKHR_H <nl> deleted file mode 100644 <nl> index c01858be . . 00000000 <nl> mmm a / glslang / include / SPIRV / GLSL . ext . NV . h <nl> ppp / dev / null <nl> <nl> - / * <nl> - * * Copyright ( c ) 2014 - 2017 The Khronos Group Inc . <nl> - * * <nl> - * * Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - * * of this software and / or associated documentation files ( the " Materials " ) , <nl> - * * to deal in the Materials without restriction , including without limitation <nl> - * * the rights to use , copy , modify , merge , publish , distribute , sublicense , <nl> - * * and / or sell copies of the Materials , and to permit persons to whom the <nl> - * * Materials are furnished to do so , subject to the following conditions : <nl> - * * <nl> - * * The above copyright notice and this permission notice shall be included in <nl> - * * all copies or substantial portions of the Materials . <nl> - * * <nl> - * * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS <nl> - * * STANDARDS . THE UNMODIFIED , NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND <nl> - * * HEADER INFORMATION ARE LOCATED AT https : / / www . khronos . org / registry / <nl> - * * <nl> - * * THE MATERIALS ARE PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS <nl> - * * OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - * * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL <nl> - * * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - * * LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING <nl> - * * FROM , OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS <nl> - * * IN THE MATERIALS . <nl> - * / <nl> - <nl> - # ifndef GLSLextNV_H <nl> - # define GLSLextNV_H <nl> - <nl> - enum BuiltIn ; <nl> - enum Decoration ; <nl> - enum Op ; <nl> - enum Capability ; <nl> - <nl> - static const int GLSLextNVVersion = 100 ; <nl> - static const int GLSLextNVRevision = 5 ; <nl> - <nl> - / / SPV_NV_sample_mask_override_coverage <nl> - const char * const E_SPV_NV_sample_mask_override_coverage = " SPV_NV_sample_mask_override_coverage " ; <nl> - <nl> - / / SPV_NV_geometry_shader_passthrough <nl> - const char * const E_SPV_NV_geometry_shader_passthrough = " SPV_NV_geometry_shader_passthrough " ; <nl> - <nl> - / / SPV_NV_viewport_array2 <nl> - const char * const E_SPV_NV_viewport_array2 = " SPV_NV_viewport_array2 " ; <nl> - const char * const E_ARB_shader_viewport_layer_array = " SPV_ARB_shader_viewport_layer_array " ; <nl> - <nl> - / / SPV_NV_stereo_view_rendering <nl> - const char * const E_SPV_NV_stereo_view_rendering = " SPV_NV_stereo_view_rendering " ; <nl> - <nl> - / / SPV_NVX_multiview_per_view_attributes <nl> - const char * const E_SPV_NVX_multiview_per_view_attributes = " SPV_NVX_multiview_per_view_attributes " ; <nl> - <nl> - # endif / / # ifndef GLSLextNV_H <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index df31092b . . 00000000 <nl> mmm a / glslang / include / SPIRV / GLSL . std . 450 . h <nl> ppp / dev / null <nl> <nl> - / * <nl> - * * Copyright ( c ) 2014 - 2016 The Khronos Group Inc . <nl> - * * <nl> - * * Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - * * of this software and / or associated documentation files ( the " Materials " ) , <nl> - * * to deal in the Materials without restriction , including without limitation <nl> - * * the rights to use , copy , modify , merge , publish , distribute , sublicense , <nl> - * * and / or sell copies of the Materials , and to permit persons to whom the <nl> - * * Materials are furnished to do so , subject to the following conditions : <nl> - * * <nl> - * * The above copyright notice and this permission notice shall be included in <nl> - * * all copies or substantial portions of the Materials . <nl> - * * <nl> - * * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS <nl> - * * STANDARDS . THE UNMODIFIED , NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND <nl> - * * HEADER INFORMATION ARE LOCATED AT https : / / www . khronos . org / registry / <nl> - * * <nl> - * * THE MATERIALS ARE PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS <nl> - * * OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - * * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL <nl> - * * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - * * LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING <nl> - * * FROM , OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS <nl> - * * IN THE MATERIALS . <nl> - * / <nl> - <nl> - # ifndef GLSLstd450_H <nl> - # define GLSLstd450_H <nl> - <nl> - static const int GLSLstd450Version = 100 ; <nl> - static const int GLSLstd450Revision = 1 ; <nl> - <nl> - enum GLSLstd450 { <nl> - GLSLstd450Bad = 0 , / / Don ' t use <nl> - <nl> - GLSLstd450Round = 1 , <nl> - GLSLstd450RoundEven = 2 , <nl> - GLSLstd450Trunc = 3 , <nl> - GLSLstd450FAbs = 4 , <nl> - GLSLstd450SAbs = 5 , <nl> - GLSLstd450FSign = 6 , <nl> - GLSLstd450SSign = 7 , <nl> - GLSLstd450Floor = 8 , <nl> - GLSLstd450Ceil = 9 , <nl> - GLSLstd450Fract = 10 , <nl> - <nl> - GLSLstd450Radians = 11 , <nl> - GLSLstd450Degrees = 12 , <nl> - GLSLstd450Sin = 13 , <nl> - GLSLstd450Cos = 14 , <nl> - GLSLstd450Tan = 15 , <nl> - GLSLstd450Asin = 16 , <nl> - GLSLstd450Acos = 17 , <nl> - GLSLstd450Atan = 18 , <nl> - GLSLstd450Sinh = 19 , <nl> - GLSLstd450Cosh = 20 , <nl> - GLSLstd450Tanh = 21 , <nl> - GLSLstd450Asinh = 22 , <nl> - GLSLstd450Acosh = 23 , <nl> - GLSLstd450Atanh = 24 , <nl> - GLSLstd450Atan2 = 25 , <nl> - <nl> - GLSLstd450Pow = 26 , <nl> - GLSLstd450Exp = 27 , <nl> - GLSLstd450Log = 28 , <nl> - GLSLstd450Exp2 = 29 , <nl> - GLSLstd450Log2 = 30 , <nl> - GLSLstd450Sqrt = 31 , <nl> - GLSLstd450InverseSqrt = 32 , <nl> - <nl> - GLSLstd450Determinant = 33 , <nl> - GLSLstd450MatrixInverse = 34 , <nl> - <nl> - GLSLstd450Modf = 35 , / / second operand needs an OpVariable to write to <nl> - GLSLstd450ModfStruct = 36 , / / no OpVariable operand <nl> - GLSLstd450FMin = 37 , <nl> - GLSLstd450UMin = 38 , <nl> - GLSLstd450SMin = 39 , <nl> - GLSLstd450FMax = 40 , <nl> - GLSLstd450UMax = 41 , <nl> - GLSLstd450SMax = 42 , <nl> - GLSLstd450FClamp = 43 , <nl> - GLSLstd450UClamp = 44 , <nl> - GLSLstd450SClamp = 45 , <nl> - GLSLstd450FMix = 46 , <nl> - GLSLstd450IMix = 47 , / / Reserved <nl> - GLSLstd450Step = 48 , <nl> - GLSLstd450SmoothStep = 49 , <nl> - <nl> - GLSLstd450Fma = 50 , <nl> - GLSLstd450Frexp = 51 , / / second operand needs an OpVariable to write to <nl> - GLSLstd450FrexpStruct = 52 , / / no OpVariable operand <nl> - GLSLstd450Ldexp = 53 , <nl> - <nl> - GLSLstd450PackSnorm4x8 = 54 , <nl> - GLSLstd450PackUnorm4x8 = 55 , <nl> - GLSLstd450PackSnorm2x16 = 56 , <nl> - GLSLstd450PackUnorm2x16 = 57 , <nl> - GLSLstd450PackHalf2x16 = 58 , <nl> - GLSLstd450PackDouble2x32 = 59 , <nl> - GLSLstd450UnpackSnorm2x16 = 60 , <nl> - GLSLstd450UnpackUnorm2x16 = 61 , <nl> - GLSLstd450UnpackHalf2x16 = 62 , <nl> - GLSLstd450UnpackSnorm4x8 = 63 , <nl> - GLSLstd450UnpackUnorm4x8 = 64 , <nl> - GLSLstd450UnpackDouble2x32 = 65 , <nl> - <nl> - GLSLstd450Length = 66 , <nl> - GLSLstd450Distance = 67 , <nl> - GLSLstd450Cross = 68 , <nl> - GLSLstd450Normalize = 69 , <nl> - GLSLstd450FaceForward = 70 , <nl> - GLSLstd450Reflect = 71 , <nl> - GLSLstd450Refract = 72 , <nl> - <nl> - GLSLstd450FindILsb = 73 , <nl> - GLSLstd450FindSMsb = 74 , <nl> - GLSLstd450FindUMsb = 75 , <nl> - <nl> - GLSLstd450InterpolateAtCentroid = 76 , <nl> - GLSLstd450InterpolateAtSample = 77 , <nl> - GLSLstd450InterpolateAtOffset = 78 , <nl> - <nl> - GLSLstd450NMin = 79 , <nl> - GLSLstd450NMax = 80 , <nl> - GLSLstd450NClamp = 81 , <nl> - <nl> - GLSLstd450Count <nl> - } ; <nl> - <nl> - # endif / / # ifndef GLSLstd450_H <nl> deleted file mode 100644 <nl> index 3a437137 . . 00000000 <nl> mmm a / glslang / include / SPIRV / GlslangToSpv . h <nl> ppp / dev / null <nl> <nl> - / / <nl> - / / Copyright ( C ) 2014 LunarG , Inc . <nl> - / / <nl> - / / All rights reserved . <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions <nl> - / / are met : <nl> - / / <nl> - / / Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / <nl> - / / Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following <nl> - / / disclaimer in the documentation and / or other materials provided <nl> - / / with the distribution . <nl> - / / <nl> - / / Neither the name of 3Dlabs Inc . Ltd . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived <nl> - / / from this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS <nl> - / / FOR A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE <nl> - / / COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , <nl> - / / INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , <nl> - / / BUT NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; <nl> - / / LOSS OF USE , DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER <nl> - / / CAUSED AND ON ANY THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT <nl> - / / LIABILITY , OR TORT ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN <nl> - / / ANY WAY OUT OF THE USE OF THIS SOFTWARE , EVEN IF ADVISED OF THE <nl> - / / POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - # pragma once <nl> - <nl> - # if _MSC_VER > = 1900 <nl> - # pragma warning ( disable : 4464 ) / / relative include path contains ' . . ' <nl> - # endif <nl> - <nl> - # include " . . / glslang / Include / intermediate . h " <nl> - <nl> - # include < string > <nl> - # include < vector > <nl> - <nl> - # include " Logger . h " <nl> - <nl> - namespace glslang { <nl> - <nl> - struct SpvOptions { <nl> - SpvOptions ( ) : generateDebugInfo ( false ) , disableOptimizer ( true ) , <nl> - optimizeSize ( false ) { } <nl> - bool generateDebugInfo ; <nl> - bool disableOptimizer ; <nl> - bool optimizeSize ; <nl> - } ; <nl> - <nl> - void GetSpirvVersion ( std : : string & ) ; <nl> - int GetSpirvGeneratorVersion ( ) ; <nl> - void GlslangToSpv ( const glslang : : TIntermediate & intermediate , std : : vector < unsigned int > & spirv , <nl> - SpvOptions * options = nullptr ) ; <nl> - void GlslangToSpv ( const glslang : : TIntermediate & intermediate , std : : vector < unsigned int > & spirv , <nl> - spv : : SpvBuildLogger * logger , SpvOptions * options = nullptr ) ; <nl> - void OutputSpvBin ( const std : : vector < unsigned int > & spirv , const char * baseName ) ; <nl> - void OutputSpvHex ( const std : : vector < unsigned int > & spirv , const char * baseName , const char * varName ) ; <nl> - <nl> - } <nl> deleted file mode 100644 <nl> index 2e4ddaf5 . . 00000000 <nl> mmm a / glslang / include / SPIRV / Logger . h <nl> ppp / dev / null <nl> <nl> - / / <nl> - / / Copyright ( C ) 2016 Google , Inc . <nl> - / / <nl> - / / All rights reserved . <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions <nl> - / / are met : <nl> - / / <nl> - / / Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / <nl> - / / Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following <nl> - / / disclaimer in the documentation and / or other materials provided <nl> - / / with the distribution . <nl> - / / <nl> - / / Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived <nl> - / / from this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS <nl> - / / FOR A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE <nl> - / / COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , <nl> - / / INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , <nl> - / / BUT NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; <nl> - / / LOSS OF USE , DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER <nl> - / / CAUSED AND ON ANY THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT <nl> - / / LIABILITY , OR TORT ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN <nl> - / / ANY WAY OUT OF THE USE OF THIS SOFTWARE , EVEN IF ADVISED OF THE <nl> - / / POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - # ifndef GLSLANG_SPIRV_LOGGER_H <nl> - # define GLSLANG_SPIRV_LOGGER_H <nl> - <nl> - # include < string > <nl> - # include < vector > <nl> - <nl> - namespace spv { <nl> - <nl> - / / A class for holding all SPIR - V build status messages , including <nl> - / / missing / TBD functionalities , warnings , and errors . <nl> - class SpvBuildLogger { <nl> - public : <nl> - SpvBuildLogger ( ) { } <nl> - <nl> - / / Registers a TBD functionality . <nl> - void tbdFunctionality ( const std : : string & f ) ; <nl> - / / Registers a missing functionality . <nl> - void missingFunctionality ( const std : : string & f ) ; <nl> - <nl> - / / Logs a warning . <nl> - void warning ( const std : : string & w ) { warnings . push_back ( w ) ; } <nl> - / / Logs an error . <nl> - void error ( const std : : string & e ) { errors . push_back ( e ) ; } <nl> - <nl> - / / Returns all messages accumulated in the order of : <nl> - / / TBD functionalities , missing functionalities , warnings , errors . <nl> - std : : string getAllMessages ( ) const ; <nl> - <nl> - private : <nl> - SpvBuildLogger ( const SpvBuildLogger & ) ; <nl> - <nl> - std : : vector < std : : string > tbdFeatures ; <nl> - std : : vector < std : : string > missingFeatures ; <nl> - std : : vector < std : : string > warnings ; <nl> - std : : vector < std : : string > errors ; <nl> - } ; <nl> - <nl> - } / / end spv namespace <nl> - <nl> - # endif / / GLSLANG_SPIRV_LOGGER_H <nl> deleted file mode 100644 <nl> index 97e3f31f . . 00000000 <nl> mmm a / glslang / include / SPIRV / SPVRemapper . h <nl> ppp / dev / null <nl> <nl> - / / <nl> - / / Copyright ( C ) 2015 LunarG , Inc . <nl> - / / <nl> - / / All rights reserved . <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions <nl> - / / are met : <nl> - / / <nl> - / / Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / <nl> - / / Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following <nl> - / / disclaimer in the documentation and / or other materials provided <nl> - / / with the distribution . <nl> - / / <nl> - / / Neither the name of 3Dlabs Inc . Ltd . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived <nl> - / / from this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS <nl> - / / FOR A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE <nl> - / / COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , <nl> - / / INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , <nl> - / / BUT NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; <nl> - / / LOSS OF USE , DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER <nl> - / / CAUSED AND ON ANY THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT <nl> - / / LIABILITY , OR TORT ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN <nl> - / / ANY WAY OUT OF THE USE OF THIS SOFTWARE , EVEN IF ADVISED OF THE <nl> - / / POSSIBILITY OF SUCH DAMAGE . <nl> - / / <nl> - <nl> - # ifndef SPIRVREMAPPER_H <nl> - # define SPIRVREMAPPER_H <nl> - <nl> - # include < string > <nl> - # include < vector > <nl> - # include < cstdlib > <nl> - # include < exception > <nl> - <nl> - namespace spv { <nl> - <nl> - / / MSVC defines __cplusplus as an older value , even when it supports almost all of 11 . <nl> - / / We handle that here by making our own symbol . <nl> - # if __cplusplus > = 201103L | | _MSC_VER > = 1700 <nl> - # define use_cpp11 1 <nl> - # endif <nl> - <nl> - class spirvbin_base_t <nl> - { <nl> - public : <nl> - enum Options { <nl> - NONE = 0 , <nl> - STRIP = ( 1 < < 0 ) , <nl> - MAP_TYPES = ( 1 < < 1 ) , <nl> - MAP_NAMES = ( 1 < < 2 ) , <nl> - MAP_FUNCS = ( 1 < < 3 ) , <nl> - DCE_FUNCS = ( 1 < < 4 ) , <nl> - DCE_VARS = ( 1 < < 5 ) , <nl> - DCE_TYPES = ( 1 < < 6 ) , <nl> - OPT_LOADSTORE = ( 1 < < 7 ) , <nl> - OPT_FWD_LS = ( 1 < < 8 ) , / / EXPERIMENTAL : PRODUCES INVALID SCHEMA - 0 SPIRV <nl> - MAP_ALL = ( MAP_TYPES | MAP_NAMES | MAP_FUNCS ) , <nl> - DCE_ALL = ( DCE_FUNCS | DCE_VARS | DCE_TYPES ) , <nl> - OPT_ALL = ( OPT_LOADSTORE ) , <nl> - <nl> - ALL_BUT_STRIP = ( MAP_ALL | DCE_ALL | OPT_ALL ) , <nl> - DO_EVERYTHING = ( STRIP | ALL_BUT_STRIP ) <nl> - } ; <nl> - } ; <nl> - <nl> - } / / namespace SPV <nl> - <nl> - # if ! defined ( use_cpp11 ) <nl> - # include < cstdio > <nl> - # include < cstdint > <nl> - <nl> - namespace spv { <nl> - class spirvbin_t : public spirvbin_base_t <nl> - { <nl> - public : <nl> - spirvbin_t ( int / * verbose = 0 * / ) { } <nl> - <nl> - void remap ( std : : vector < std : : uint32_t > & / * spv * / , unsigned int / * opts = 0 * / ) <nl> - { <nl> - printf ( " Tool not compiled for C + + 11 , which is required for SPIR - V remapping . \ n " ) ; <nl> - exit ( 5 ) ; <nl> - } <nl> - } ; <nl> - <nl> - } / / namespace SPV <nl> - <nl> - # else / / defined ( use_cpp11 ) <nl> - <nl> - # include < functional > <nl> - # include < cstdint > <nl> - # include < unordered_map > <nl> - # include < unordered_set > <nl> - # include < map > <nl> - # include < set > <nl> - # include < cassert > <nl> - <nl> - # include " spirv . hpp " <nl> - # include " spvIR . h " <nl> - <nl> - namespace spv { <nl> - <nl> - / / class to hold SPIR - V binary data for remapping , DCE , and debug stripping <nl> - class spirvbin_t : public spirvbin_base_t <nl> - { <nl> - public : <nl> - spirvbin_t ( int verbose = 0 ) : entryPoint ( spv : : NoResult ) , largestNewId ( 0 ) , verbose ( verbose ) , errorLatch ( false ) <nl> - { } <nl> - <nl> - virtual ~ spirvbin_t ( ) { } <nl> - <nl> - / / remap on an existing binary in memory <nl> - void remap ( std : : vector < std : : uint32_t > & spv , std : : uint32_t opts = DO_EVERYTHING ) ; <nl> - <nl> - / / Type for error / log handler functions <nl> - typedef std : : function < void ( const std : : string & ) > errorfn_t ; <nl> - typedef std : : function < void ( const std : : string & ) > logfn_t ; <nl> - <nl> - / / Register error / log handling functions ( can be lambda fn / functor / etc ) <nl> - static void registerErrorHandler ( errorfn_t handler ) { errorHandler = handler ; } <nl> - static void registerLogHandler ( logfn_t handler ) { logHandler = handler ; } <nl> - <nl> - protected : <nl> - / / This can be overridden to provide other message behavior if needed <nl> - virtual void msg ( int minVerbosity , int indent , const std : : string & txt ) const ; <nl> - <nl> - private : <nl> - / / Local to global , or global to local ID map <nl> - typedef std : : unordered_map < spv : : Id , spv : : Id > idmap_t ; <nl> - typedef std : : unordered_set < spv : : Id > idset_t ; <nl> - typedef std : : unordered_map < spv : : Id , int > blockmap_t ; <nl> - <nl> - void remap ( std : : uint32_t opts = DO_EVERYTHING ) ; <nl> - <nl> - / / Map of names to IDs <nl> - typedef std : : unordered_map < std : : string , spv : : Id > namemap_t ; <nl> - <nl> - typedef std : : uint32_t spirword_t ; <nl> - <nl> - typedef std : : pair < unsigned , unsigned > range_t ; <nl> - typedef std : : function < void ( spv : : Id & ) > idfn_t ; <nl> - typedef std : : function < bool ( spv : : Op , unsigned start ) > instfn_t ; <nl> - <nl> - / / Special Values for ID map : <nl> - static const spv : : Id unmapped ; / / unchanged from default value <nl> - static const spv : : Id unused ; / / unused ID <nl> - static const int header_size ; / / SPIR header = 5 words <nl> - <nl> - class id_iterator_t ; <nl> - <nl> - / / For mapping type entries between different shaders <nl> - typedef std : : vector < spirword_t > typeentry_t ; <nl> - typedef std : : map < spv : : Id , typeentry_t > globaltypes_t ; <nl> - <nl> - / / A set that preserves position order , and a reverse map <nl> - typedef std : : set < int > posmap_t ; <nl> - typedef std : : unordered_map < spv : : Id , int > posmap_rev_t ; <nl> - <nl> - / / Maps and ID to the size of its base type , if known . <nl> - typedef std : : unordered_map < spv : : Id , unsigned > typesize_map_t ; <nl> - <nl> - / / handle error <nl> - void error ( const std : : string & txt ) const { errorLatch = true ; errorHandler ( txt ) ; } <nl> - <nl> - bool isConstOp ( spv : : Op opCode ) const ; <nl> - bool isTypeOp ( spv : : Op opCode ) const ; <nl> - bool isStripOp ( spv : : Op opCode ) const ; <nl> - bool isFlowCtrl ( spv : : Op opCode ) const ; <nl> - range_t literalRange ( spv : : Op opCode ) const ; <nl> - range_t typeRange ( spv : : Op opCode ) const ; <nl> - range_t constRange ( spv : : Op opCode ) const ; <nl> - unsigned typeSizeInWords ( spv : : Id id ) const ; <nl> - unsigned idTypeSizeInWords ( spv : : Id id ) const ; <nl> - <nl> - spv : : Id & asId ( unsigned word ) { return spv [ word ] ; } <nl> - const spv : : Id & asId ( unsigned word ) const { return spv [ word ] ; } <nl> - spv : : Op asOpCode ( unsigned word ) const { return opOpCode ( spv [ word ] ) ; } <nl> - std : : uint32_t asOpCodeHash ( unsigned word ) ; <nl> - spv : : Decoration asDecoration ( unsigned word ) const { return spv : : Decoration ( spv [ word ] ) ; } <nl> - unsigned asWordCount ( unsigned word ) const { return opWordCount ( spv [ word ] ) ; } <nl> - spv : : Id asTypeConstId ( unsigned word ) const { return asId ( word + ( isTypeOp ( asOpCode ( word ) ) ? 1 : 2 ) ) ; } <nl> - unsigned idPos ( spv : : Id id ) const ; <nl> - <nl> - static unsigned opWordCount ( spirword_t data ) { return data > > spv : : WordCountShift ; } <nl> - static spv : : Op opOpCode ( spirword_t data ) { return spv : : Op ( data & spv : : OpCodeMask ) ; } <nl> - <nl> - / / Header access & set methods <nl> - spirword_t magic ( ) const { return spv [ 0 ] ; } / / return magic number <nl> - spirword_t bound ( ) const { return spv [ 3 ] ; } / / return Id bound from header <nl> - spirword_t bound ( spirword_t b ) { return spv [ 3 ] = b ; } ; <nl> - spirword_t genmagic ( ) const { return spv [ 2 ] ; } / / generator magic <nl> - spirword_t genmagic ( spirword_t m ) { return spv [ 2 ] = m ; } <nl> - spirword_t schemaNum ( ) const { return spv [ 4 ] ; } / / schema number from header <nl> - <nl> - / / Mapping fns : get <nl> - spv : : Id localId ( spv : : Id id ) const { return idMapL [ id ] ; } <nl> - <nl> - / / Mapping fns : set <nl> - inline spv : : Id localId ( spv : : Id id , spv : : Id newId ) ; <nl> - void countIds ( spv : : Id id ) ; <nl> - <nl> - / / Return next unused new local ID . <nl> - / / NOTE : boost : : dynamic_bitset would be more efficient due to find_next ( ) , <nl> - / / which std : : vector < bool > doens ' t have . <nl> - inline spv : : Id nextUnusedId ( spv : : Id id ) ; <nl> - <nl> - void buildLocalMaps ( ) ; <nl> - std : : string literalString ( unsigned word ) const ; / / Return literal as a std : : string <nl> - int literalStringWords ( const std : : string & str ) const { return ( int ( str . size ( ) ) + 4 ) / 4 ; } <nl> - <nl> - bool isNewIdMapped ( spv : : Id newId ) const { return isMapped ( newId ) ; } <nl> - bool isOldIdUnmapped ( spv : : Id oldId ) const { return localId ( oldId ) = = unmapped ; } <nl> - bool isOldIdUnused ( spv : : Id oldId ) const { return localId ( oldId ) = = unused ; } <nl> - bool isOldIdMapped ( spv : : Id oldId ) const { return ! isOldIdUnused ( oldId ) & & ! isOldIdUnmapped ( oldId ) ; } <nl> - bool isFunction ( spv : : Id oldId ) const { return fnPos . find ( oldId ) ! = fnPos . end ( ) ; } <nl> - <nl> - / / bool matchType ( const globaltypes_t & globalTypes , spv : : Id lt , spv : : Id gt ) const ; <nl> - / / spv : : Id findType ( const globaltypes_t & globalTypes , spv : : Id lt ) const ; <nl> - std : : uint32_t hashType ( unsigned typeStart ) const ; <nl> - <nl> - spirvbin_t & process ( instfn_t , idfn_t , unsigned begin = 0 , unsigned end = 0 ) ; <nl> - int processInstruction ( unsigned word , instfn_t , idfn_t ) ; <nl> - <nl> - void validate ( ) const ; <nl> - void mapTypeConst ( ) ; <nl> - void mapFnBodies ( ) ; <nl> - void optLoadStore ( ) ; <nl> - void dceFuncs ( ) ; <nl> - void dceVars ( ) ; <nl> - void dceTypes ( ) ; <nl> - void mapNames ( ) ; <nl> - void foldIds ( ) ; / / fold IDs to smallest space <nl> - void forwardLoadStores ( ) ; / / load store forwarding ( EXPERIMENTAL ) <nl> - void offsetIds ( ) ; / / create relative offset IDs <nl> - <nl> - void applyMap ( ) ; / / remap per local name map <nl> - void mapRemainder ( ) ; / / map any IDs we haven ' t touched yet <nl> - void stripDebug ( ) ; / / strip all debug info <nl> - void stripDeadRefs ( ) ; / / strips debug info for now - dead references after DCE <nl> - void strip ( ) ; / / remove debug symbols <nl> - <nl> - std : : vector < spirword_t > spv ; / / SPIR words <nl> - <nl> - namemap_t nameMap ; / / ID names from OpName <nl> - <nl> - / / Since we want to also do binary ops , we can ' t use std : : vector < bool > . we could use <nl> - / / boost : : dynamic_bitset , but we ' re trying to avoid a boost dependency . <nl> - typedef std : : uint64_t bits_t ; <nl> - std : : vector < bits_t > mapped ; / / which new IDs have been mapped <nl> - static const int mBits = sizeof ( bits_t ) * 4 ; <nl> - <nl> - bool isMapped ( spv : : Id id ) const { return id < maxMappedId ( ) & & ( ( mapped [ id / mBits ] & ( 1LL < < ( id % mBits ) ) ) ! = 0 ) ; } <nl> - void setMapped ( spv : : Id id ) { resizeMapped ( id ) ; mapped [ id / mBits ] | = ( 1LL < < ( id % mBits ) ) ; } <nl> - void resizeMapped ( spv : : Id id ) { if ( id > = maxMappedId ( ) ) mapped . resize ( id / mBits + 1 , 0 ) ; } <nl> - size_t maxMappedId ( ) const { return mapped . size ( ) * mBits ; } <nl> - <nl> - / / Add a strip range for a given instruction starting at ' start ' <nl> - / / Note : avoiding brace initializers to please older versions os MSVC . <nl> - void stripInst ( unsigned start ) { stripRange . push_back ( range_t ( start , start + asWordCount ( start ) ) ) ; } <nl> - <nl> - / / Function start and end . use unordered_map because we ' ll have <nl> - / / many fewer functions than IDs . <nl> - std : : unordered_map < spv : : Id , range_t > fnPos ; <nl> - <nl> - / / Which functions are called , anywhere in the module , with a call count <nl> - std : : unordered_map < spv : : Id , int > fnCalls ; <nl> - <nl> - posmap_t typeConstPos ; / / word positions that define types & consts ( ordered ) <nl> - posmap_rev_t idPosR ; / / reverse map from IDs to positions <nl> - typesize_map_t idTypeSizeMap ; / / maps each ID to its type size , if known . <nl> - <nl> - std : : vector < spv : : Id > idMapL ; / / ID { M } ap from { L } ocal to { G } lobal IDs <nl> - <nl> - spv : : Id entryPoint ; / / module entry point <nl> - spv : : Id largestNewId ; / / biggest new ID we have mapped anything to <nl> - <nl> - / / Sections of the binary to strip , given as [ begin , end ) <nl> - std : : vector < range_t > stripRange ; <nl> - <nl> - / / processing options : <nl> - std : : uint32_t options ; <nl> - int verbose ; / / verbosity level <nl> - <nl> - / / Error latch : this is set if the error handler is ever executed . It would be better to <nl> - / / use a try / catch block and throw , but that ' s not desired for certain environments , so <nl> - / / this is the alternative . <nl> - mutable bool errorLatch ; <nl> - <nl> - static errorfn_t errorHandler ; <nl> - static logfn_t logHandler ; <nl> - } ; <nl> - <nl> - } / / namespace SPV <nl> - <nl> - # endif / / defined ( use_cpp11 ) <nl> - # endif / / SPIRVREMAPPER_H <nl> deleted file mode 100644 <nl> index c0e244c8 . . 00000000 <nl> mmm a / glslang / include / SPIRV / SpvBuilder . h <nl> ppp / dev / null <nl> <nl> - / / <nl> - / / Copyright ( C ) 2014 - 2015 LunarG , Inc . <nl> - / / Copyright ( C ) 2015 - 2016 Google , Inc . <nl> - / / <nl> - / / All rights reserved . <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions <nl> - / / are met : <nl> - / / <nl> - / / Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / <nl> - / / Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following <nl> - / / disclaimer in the documentation and / or other materials provided <nl> - / / with the distribution . <nl> - / / <nl> - / / Neither the name of 3Dlabs Inc . Ltd . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived <nl> - / / from this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS <nl> - / / FOR A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE <nl> - / / COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , <nl> - / / INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , <nl> - / / BUT NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; <nl> - / / LOSS OF USE , DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER <nl> - / / CAUSED AND ON ANY THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT <nl> - / / LIABILITY , OR TORT ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN <nl> - / / ANY WAY OUT OF THE USE OF THIS SOFTWARE , EVEN IF ADVISED OF THE <nl> - / / POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / <nl> - / / " Builder " is an interface to fully build SPIR - V IR . Allocate one of <nl> - / / these to build ( a thread safe ) internal SPIR - V representation ( IR ) , <nl> - / / and then dump it as a binary stream according to the SPIR - V specification . <nl> - / / <nl> - / / A Builder has a 1 : 1 relationship with a SPIR - V module . <nl> - / / <nl> - <nl> - # pragma once <nl> - # ifndef SpvBuilder_H <nl> - # define SpvBuilder_H <nl> - <nl> - # include " Logger . h " <nl> - # include " spirv . hpp " <nl> - # include " spvIR . h " <nl> - <nl> - # include < algorithm > <nl> - # include < map > <nl> - # include < memory > <nl> - # include < set > <nl> - # include < sstream > <nl> - # include < stack > <nl> - <nl> - namespace spv { <nl> - <nl> - class Builder { <nl> - public : <nl> - Builder ( unsigned int spvVersion , unsigned int userNumber , SpvBuildLogger * logger ) ; <nl> - virtual ~ Builder ( ) ; <nl> - <nl> - static const int maxMatrixSize = 4 ; <nl> - <nl> - void setSource ( spv : : SourceLanguage lang , int version ) <nl> - { <nl> - source = lang ; <nl> - sourceVersion = version ; <nl> - } <nl> - void setSourceFile ( const std : : string & file ) <nl> - { <nl> - Instruction * fileString = new Instruction ( getUniqueId ( ) , NoType , OpString ) ; <nl> - fileString - > addStringOperand ( file . c_str ( ) ) ; <nl> - sourceFileStringId = fileString - > getResultId ( ) ; <nl> - strings . push_back ( std : : unique_ptr < Instruction > ( fileString ) ) ; <nl> - } <nl> - void setSourceText ( const std : : string & text ) { sourceText = text ; } <nl> - void addSourceExtension ( const char * ext ) { sourceExtensions . push_back ( ext ) ; } <nl> - void addModuleProcessed ( const std : : string & p ) { moduleProcesses . push_back ( p . c_str ( ) ) ; } <nl> - void setEmitOpLines ( ) { emitOpLines = true ; } <nl> - void addExtension ( const char * ext ) { extensions . insert ( ext ) ; } <nl> - Id import ( const char * ) ; <nl> - void setMemoryModel ( spv : : AddressingModel addr , spv : : MemoryModel mem ) <nl> - { <nl> - addressModel = addr ; <nl> - memoryModel = mem ; <nl> - } <nl> - <nl> - void addCapability ( spv : : Capability cap ) { capabilities . insert ( cap ) ; } <nl> - <nl> - / / To get a new < id > for anything needing a new one . <nl> - Id getUniqueId ( ) { return + + uniqueId ; } <nl> - <nl> - / / To get a set of new < id > s , e . g . , for a set of function parameters <nl> - Id getUniqueIds ( int numIds ) <nl> - { <nl> - Id id = uniqueId + 1 ; <nl> - uniqueId + = numIds ; <nl> - return id ; <nl> - } <nl> - <nl> - / / Log the current line , and if different than the last one , <nl> - / / issue a new OpLine , using the current file name . <nl> - void setLine ( int line ) ; <nl> - / / Low - level OpLine . See setLine ( ) for a layered helper . <nl> - void addLine ( Id fileName , int line , int column ) ; <nl> - <nl> - / / For creating new types ( will return old type if the requested one was already made ) . <nl> - Id makeVoidType ( ) ; <nl> - Id makeBoolType ( ) ; <nl> - Id makePointer ( StorageClass , Id type ) ; <nl> - Id makeIntegerType ( int width , bool hasSign ) ; / / generic <nl> - Id makeIntType ( int width ) { return makeIntegerType ( width , true ) ; } <nl> - Id makeUintType ( int width ) { return makeIntegerType ( width , false ) ; } <nl> - Id makeFloatType ( int width ) ; <nl> - Id makeStructType ( const std : : vector < Id > & members , const char * ) ; <nl> - Id makeStructResultType ( Id type0 , Id type1 ) ; <nl> - Id makeVectorType ( Id component , int size ) ; <nl> - Id makeMatrixType ( Id component , int cols , int rows ) ; <nl> - Id makeArrayType ( Id element , Id sizeId , int stride ) ; / / 0 stride means no stride decoration <nl> - Id makeRuntimeArray ( Id element ) ; <nl> - Id makeFunctionType ( Id returnType , const std : : vector < Id > & paramTypes ) ; <nl> - Id makeImageType ( Id sampledType , Dim , bool depth , bool arrayed , bool ms , unsigned sampled , ImageFormat format ) ; <nl> - Id makeSamplerType ( ) ; <nl> - Id makeSampledImageType ( Id imageType ) ; <nl> - <nl> - / / For querying about types . <nl> - Id getTypeId ( Id resultId ) const { return module . getTypeId ( resultId ) ; } <nl> - Id getDerefTypeId ( Id resultId ) const ; <nl> - Op getOpCode ( Id id ) const { return module . getInstruction ( id ) - > getOpCode ( ) ; } <nl> - Op getTypeClass ( Id typeId ) const { return getOpCode ( typeId ) ; } <nl> - Op getMostBasicTypeClass ( Id typeId ) const ; <nl> - int getNumComponents ( Id resultId ) const { return getNumTypeComponents ( getTypeId ( resultId ) ) ; } <nl> - int getNumTypeConstituents ( Id typeId ) const ; <nl> - int getNumTypeComponents ( Id typeId ) const { return getNumTypeConstituents ( typeId ) ; } <nl> - Id getScalarTypeId ( Id typeId ) const ; <nl> - Id getContainedTypeId ( Id typeId ) const ; <nl> - Id getContainedTypeId ( Id typeId , int ) const ; <nl> - StorageClass getTypeStorageClass ( Id typeId ) const { return module . getStorageClass ( typeId ) ; } <nl> - ImageFormat getImageTypeFormat ( Id typeId ) const { return ( ImageFormat ) module . getInstruction ( typeId ) - > getImmediateOperand ( 6 ) ; } <nl> - <nl> - bool isPointer ( Id resultId ) const { return isPointerType ( getTypeId ( resultId ) ) ; } <nl> - bool isScalar ( Id resultId ) const { return isScalarType ( getTypeId ( resultId ) ) ; } <nl> - bool isVector ( Id resultId ) const { return isVectorType ( getTypeId ( resultId ) ) ; } <nl> - bool isMatrix ( Id resultId ) const { return isMatrixType ( getTypeId ( resultId ) ) ; } <nl> - bool isAggregate ( Id resultId ) const { return isAggregateType ( getTypeId ( resultId ) ) ; } <nl> - bool isSampledImage ( Id resultId ) const { return isSampledImageType ( getTypeId ( resultId ) ) ; } <nl> - <nl> - bool isBoolType ( Id typeId ) const { return groupedTypes [ OpTypeBool ] . size ( ) > 0 & & typeId = = groupedTypes [ OpTypeBool ] . back ( ) - > getResultId ( ) ; } <nl> - bool isIntType ( Id typeId ) const { return getTypeClass ( typeId ) = = OpTypeInt & & module . getInstruction ( typeId ) - > getImmediateOperand ( 1 ) ! = 0 ; } <nl> - bool isUintType ( Id typeId ) const { return getTypeClass ( typeId ) = = OpTypeInt & & module . getInstruction ( typeId ) - > getImmediateOperand ( 1 ) = = 0 ; } <nl> - bool isFloatType ( Id typeId ) const { return getTypeClass ( typeId ) = = OpTypeFloat ; } <nl> - bool isPointerType ( Id typeId ) const { return getTypeClass ( typeId ) = = OpTypePointer ; } <nl> - bool isScalarType ( Id typeId ) const { return getTypeClass ( typeId ) = = OpTypeFloat | | getTypeClass ( typeId ) = = OpTypeInt | | getTypeClass ( typeId ) = = OpTypeBool ; } <nl> - bool isVectorType ( Id typeId ) const { return getTypeClass ( typeId ) = = OpTypeVector ; } <nl> - bool isMatrixType ( Id typeId ) const { return getTypeClass ( typeId ) = = OpTypeMatrix ; } <nl> - bool isStructType ( Id typeId ) const { return getTypeClass ( typeId ) = = OpTypeStruct ; } <nl> - bool isArrayType ( Id typeId ) const { return getTypeClass ( typeId ) = = OpTypeArray ; } <nl> - bool isAggregateType ( Id typeId ) const { return isArrayType ( typeId ) | | isStructType ( typeId ) ; } <nl> - bool isImageType ( Id typeId ) const { return getTypeClass ( typeId ) = = OpTypeImage ; } <nl> - bool isSamplerType ( Id typeId ) const { return getTypeClass ( typeId ) = = OpTypeSampler ; } <nl> - bool isSampledImageType ( Id typeId ) const { return getTypeClass ( typeId ) = = OpTypeSampledImage ; } <nl> - <nl> - bool isConstantOpCode ( Op opcode ) const ; <nl> - bool isSpecConstantOpCode ( Op opcode ) const ; <nl> - bool isConstant ( Id resultId ) const { return isConstantOpCode ( getOpCode ( resultId ) ) ; } <nl> - bool isConstantScalar ( Id resultId ) const { return getOpCode ( resultId ) = = OpConstant ; } <nl> - bool isSpecConstant ( Id resultId ) const { return isSpecConstantOpCode ( getOpCode ( resultId ) ) ; } <nl> - unsigned int getConstantScalar ( Id resultId ) const { return module . getInstruction ( resultId ) - > getImmediateOperand ( 0 ) ; } <nl> - StorageClass getStorageClass ( Id resultId ) const { return getTypeStorageClass ( getTypeId ( resultId ) ) ; } <nl> - <nl> - int getScalarTypeWidth ( Id typeId ) const <nl> - { <nl> - Id scalarTypeId = getScalarTypeId ( typeId ) ; <nl> - assert ( getTypeClass ( scalarTypeId ) = = OpTypeInt | | getTypeClass ( scalarTypeId ) = = OpTypeFloat ) ; <nl> - return module . getInstruction ( scalarTypeId ) - > getImmediateOperand ( 0 ) ; <nl> - } <nl> - <nl> - int getTypeNumColumns ( Id typeId ) const <nl> - { <nl> - assert ( isMatrixType ( typeId ) ) ; <nl> - return getNumTypeConstituents ( typeId ) ; <nl> - } <nl> - int getNumColumns ( Id resultId ) const { return getTypeNumColumns ( getTypeId ( resultId ) ) ; } <nl> - int getTypeNumRows ( Id typeId ) const <nl> - { <nl> - assert ( isMatrixType ( typeId ) ) ; <nl> - return getNumTypeComponents ( getContainedTypeId ( typeId ) ) ; <nl> - } <nl> - int getNumRows ( Id resultId ) const { return getTypeNumRows ( getTypeId ( resultId ) ) ; } <nl> - <nl> - Dim getTypeDimensionality ( Id typeId ) const <nl> - { <nl> - assert ( isImageType ( typeId ) ) ; <nl> - return ( Dim ) module . getInstruction ( typeId ) - > getImmediateOperand ( 1 ) ; <nl> - } <nl> - Id getImageType ( Id resultId ) const <nl> - { <nl> - Id typeId = getTypeId ( resultId ) ; <nl> - assert ( isImageType ( typeId ) | | isSampledImageType ( typeId ) ) ; <nl> - return isSampledImageType ( typeId ) ? module . getInstruction ( typeId ) - > getIdOperand ( 0 ) : typeId ; <nl> - } <nl> - bool isArrayedImageType ( Id typeId ) const <nl> - { <nl> - assert ( isImageType ( typeId ) ) ; <nl> - return module . getInstruction ( typeId ) - > getImmediateOperand ( 3 ) ! = 0 ; <nl> - } <nl> - <nl> - / / For making new constants ( will return old constant if the requested one was already made ) . <nl> - Id makeBoolConstant ( bool b , bool specConstant = false ) ; <nl> - Id makeIntConstant ( int i , bool specConstant = false ) { return makeIntConstant ( makeIntType ( 32 ) , ( unsigned ) i , specConstant ) ; } <nl> - Id makeUintConstant ( unsigned u , bool specConstant = false ) { return makeIntConstant ( makeUintType ( 32 ) , u , specConstant ) ; } <nl> - Id makeInt64Constant ( long long i , bool specConstant = false ) { return makeInt64Constant ( makeIntType ( 64 ) , ( unsigned long long ) i , specConstant ) ; } <nl> - Id makeUint64Constant ( unsigned long long u , bool specConstant = false ) { return makeInt64Constant ( makeUintType ( 64 ) , u , specConstant ) ; } <nl> - # ifdef AMD_EXTENSIONS <nl> - Id makeInt16Constant ( short i , bool specConstant = false ) { return makeIntConstant ( makeIntType ( 16 ) , ( unsigned ) ( ( unsigned short ) i ) , specConstant ) ; } <nl> - Id makeUint16Constant ( unsigned short u , bool specConstant = false ) { return makeIntConstant ( makeUintType ( 16 ) , ( unsigned ) u , specConstant ) ; } <nl> - # endif <nl> - Id makeFloatConstant ( float f , bool specConstant = false ) ; <nl> - Id makeDoubleConstant ( double d , bool specConstant = false ) ; <nl> - # ifdef AMD_EXTENSIONS <nl> - Id makeFloat16Constant ( float f16 , bool specConstant = false ) ; <nl> - # endif <nl> - <nl> - / / Turn the array of constants into a proper spv constant of the requested type . <nl> - Id makeCompositeConstant ( Id type , const std : : vector < Id > & comps , bool specConst = false ) ; <nl> - <nl> - / / Methods for adding information outside the CFG . <nl> - Instruction * addEntryPoint ( ExecutionModel , Function * , const char * name ) ; <nl> - void addExecutionMode ( Function * , ExecutionMode mode , int value1 = - 1 , int value2 = - 1 , int value3 = - 1 ) ; <nl> - void addName ( Id , const char * name ) ; <nl> - void addMemberName ( Id , int member , const char * name ) ; <nl> - void addDecoration ( Id , Decoration , int num = - 1 ) ; <nl> - void addMemberDecoration ( Id , unsigned int member , Decoration , int num = - 1 ) ; <nl> - <nl> - / / At the end of what block do the next create * ( ) instructions go ? <nl> - void setBuildPoint ( Block * bp ) { buildPoint = bp ; } <nl> - Block * getBuildPoint ( ) const { return buildPoint ; } <nl> - <nl> - / / Make the entry - point function . The returned pointer is only valid <nl> - / / for the lifetime of this builder . <nl> - Function * makeEntryPoint ( const char * ) ; <nl> - <nl> - / / Make a shader - style function , and create its entry block if entry is non - zero . <nl> - / / Return the function , pass back the entry . <nl> - / / The returned pointer is only valid for the lifetime of this builder . <nl> - Function * makeFunctionEntry ( Decoration precision , Id returnType , const char * name , const std : : vector < Id > & paramTypes , <nl> - const std : : vector < std : : vector < Decoration > > & precisions , Block * * entry = 0 ) ; <nl> - <nl> - / / Create a return . An ' implicit ' return is one not appearing in the source <nl> - / / code . In the case of an implicit return , no post - return block is inserted . <nl> - void makeReturn ( bool implicit , Id retVal = 0 ) ; <nl> - <nl> - / / Generate all the code needed to finish up a function . <nl> - void leaveFunction ( ) ; <nl> - <nl> - / / Create a discard . <nl> - void makeDiscard ( ) ; <nl> - <nl> - / / Create a global or function local or IO variable . <nl> - Id createVariable ( StorageClass , Id type , const char * name = 0 ) ; <nl> - <nl> - / / Create an intermediate with an undefined value . <nl> - Id createUndefined ( Id type ) ; <nl> - <nl> - / / Store into an Id and return the l - value <nl> - void createStore ( Id rValue , Id lValue ) ; <nl> - <nl> - / / Load from an Id and return it <nl> - Id createLoad ( Id lValue ) ; <nl> - <nl> - / / Create an OpAccessChain instruction <nl> - Id createAccessChain ( StorageClass , Id base , const std : : vector < Id > & offsets ) ; <nl> - <nl> - / / Create an OpArrayLength instruction <nl> - Id createArrayLength ( Id base , unsigned int member ) ; <nl> - <nl> - / / Create an OpCompositeExtract instruction <nl> - Id createCompositeExtract ( Id composite , Id typeId , unsigned index ) ; <nl> - Id createCompositeExtract ( Id composite , Id typeId , const std : : vector < unsigned > & indexes ) ; <nl> - Id createCompositeInsert ( Id object , Id composite , Id typeId , unsigned index ) ; <nl> - Id createCompositeInsert ( Id object , Id composite , Id typeId , const std : : vector < unsigned > & indexes ) ; <nl> - <nl> - Id createVectorExtractDynamic ( Id vector , Id typeId , Id componentIndex ) ; <nl> - Id createVectorInsertDynamic ( Id vector , Id typeId , Id component , Id componentIndex ) ; <nl> - <nl> - void createNoResultOp ( Op ) ; <nl> - void createNoResultOp ( Op , Id operand ) ; <nl> - void createNoResultOp ( Op , const std : : vector < Id > & operands ) ; <nl> - void createControlBarrier ( Scope execution , Scope memory , MemorySemanticsMask ) ; <nl> - void createMemoryBarrier ( unsigned executionScope , unsigned memorySemantics ) ; <nl> - Id createUnaryOp ( Op , Id typeId , Id operand ) ; <nl> - Id createBinOp ( Op , Id typeId , Id operand1 , Id operand2 ) ; <nl> - Id createTriOp ( Op , Id typeId , Id operand1 , Id operand2 , Id operand3 ) ; <nl> - Id createOp ( Op , Id typeId , const std : : vector < Id > & operands ) ; <nl> - Id createFunctionCall ( spv : : Function * , const std : : vector < spv : : Id > & ) ; <nl> - Id createSpecConstantOp ( Op , Id typeId , const std : : vector < spv : : Id > & operands , const std : : vector < unsigned > & literals ) ; <nl> - <nl> - / / Take an rvalue ( source ) and a set of channels to extract from it to <nl> - / / make a new rvalue , which is returned . <nl> - Id createRvalueSwizzle ( Decoration precision , Id typeId , Id source , const std : : vector < unsigned > & channels ) ; <nl> - <nl> - / / Take a copy of an lvalue ( target ) and a source of components , and set the <nl> - / / source components into the lvalue where the ' channels ' say to put them . <nl> - / / An updated version of the target is returned . <nl> - / / ( No true lvalue or stores are used . ) <nl> - Id createLvalueSwizzle ( Id typeId , Id target , Id source , const std : : vector < unsigned > & channels ) ; <nl> - <nl> - / / If both the id and precision are valid , the id <nl> - / / gets tagged with the requested precision . <nl> - / / The passed in id is always the returned id , to simplify use patterns . <nl> - Id setPrecision ( Id id , Decoration precision ) <nl> - { <nl> - if ( precision ! = NoPrecision & & id ! = NoResult ) <nl> - addDecoration ( id , precision ) ; <nl> - <nl> - return id ; <nl> - } <nl> - <nl> - / / Can smear a scalar to a vector for the following forms : <nl> - / / - promoteScalar ( scalar , vector ) / / smear scalar to width of vector <nl> - / / - promoteScalar ( vector , scalar ) / / smear scalar to width of vector <nl> - / / - promoteScalar ( pointer , scalar ) / / smear scalar to width of what pointer points to <nl> - / / - promoteScalar ( scalar , scalar ) / / do nothing <nl> - / / Other forms are not allowed . <nl> - / / <nl> - / / Generally , the type of ' scalar ' does not need to be the same type as the components in ' vector ' . <nl> - / / The type of the created vector is a vector of components of the same type as the scalar . <nl> - / / <nl> - / / Note : One of the arguments will change , with the result coming back that way rather than <nl> - / / through the return value . <nl> - void promoteScalar ( Decoration precision , Id & left , Id & right ) ; <nl> - <nl> - / / Make a value by smearing the scalar to fill the type . <nl> - / / vectorType should be the correct type for making a vector of scalarVal . <nl> - / / ( No conversions are done . ) <nl> - Id smearScalar ( Decoration precision , Id scalarVal , Id vectorType ) ; <nl> - <nl> - / / Create a call to a built - in function . <nl> - Id createBuiltinCall ( Id resultType , Id builtins , int entryPoint , const std : : vector < Id > & args ) ; <nl> - <nl> - / / List of parameters used to create a texture operation <nl> - struct TextureParameters { <nl> - Id sampler ; <nl> - Id coords ; <nl> - Id bias ; <nl> - Id lod ; <nl> - Id Dref ; <nl> - Id offset ; <nl> - Id offsets ; <nl> - Id gradX ; <nl> - Id gradY ; <nl> - Id sample ; <nl> - Id component ; <nl> - Id texelOut ; <nl> - Id lodClamp ; <nl> - } ; <nl> - <nl> - / / Select the correct texture operation based on all inputs , and emit the correct instruction <nl> - Id createTextureCall ( Decoration precision , Id resultType , bool sparse , bool fetch , bool proj , bool gather , bool noImplicit , const TextureParameters & ) ; <nl> - <nl> - / / Emit the OpTextureQuery * instruction that was passed in . <nl> - / / Figure out the right return value and type , and return it . <nl> - Id createTextureQueryCall ( Op , const TextureParameters & , bool isUnsignedResult ) ; <nl> - <nl> - Id createSamplePositionCall ( Decoration precision , Id , Id ) ; <nl> - <nl> - Id createBitFieldExtractCall ( Decoration precision , Id , Id , Id , bool isSigned ) ; <nl> - Id createBitFieldInsertCall ( Decoration precision , Id , Id , Id , Id ) ; <nl> - <nl> - / / Reduction comparison for composites : For equal and not - equal resulting in a scalar . <nl> - Id createCompositeCompare ( Decoration precision , Id , Id , bool / * true if for equal , false if for not - equal * / ) ; <nl> - <nl> - / / OpCompositeConstruct <nl> - Id createCompositeConstruct ( Id typeId , const std : : vector < Id > & constituents ) ; <nl> - <nl> - / / vector or scalar constructor <nl> - Id createConstructor ( Decoration precision , const std : : vector < Id > & sources , Id resultTypeId ) ; <nl> - <nl> - / / matrix constructor <nl> - Id createMatrixConstructor ( Decoration precision , const std : : vector < Id > & sources , Id constructee ) ; <nl> - <nl> - / / Helper to use for building nested control flow with if - then - else . <nl> - class If { <nl> - public : <nl> - If ( Id condition , unsigned int ctrl , Builder & builder ) ; <nl> - ~ If ( ) { } <nl> - <nl> - void makeBeginElse ( ) ; <nl> - void makeEndIf ( ) ; <nl> - <nl> - private : <nl> - If ( const If & ) ; <nl> - If & operator = ( If & ) ; <nl> - <nl> - Builder & builder ; <nl> - Id condition ; <nl> - unsigned int control ; <nl> - Function * function ; <nl> - Block * headerBlock ; <nl> - Block * thenBlock ; <nl> - Block * elseBlock ; <nl> - Block * mergeBlock ; <nl> - } ; <nl> - <nl> - / / Make a switch statement . A switch has ' numSegments ' of pieces of code , not containing <nl> - / / any case / default labels , all separated by one or more case / default labels . Each possible <nl> - / / case value v is a jump to the caseValues [ v ] segment . The defaultSegment is also in this <nl> - / / number space . How to compute the value is given by ' condition ' , as in switch ( condition ) . <nl> - / / <nl> - / / The SPIR - V Builder will maintain the stack of post - switch merge blocks for nested switches . <nl> - / / <nl> - / / Use a defaultSegment < 0 if there is no default segment ( to branch to post switch ) . <nl> - / / <nl> - / / Returns the right set of basic blocks to start each code segment with , so that the caller ' s <nl> - / / recursion stack can hold the memory for it . <nl> - / / <nl> - void makeSwitch ( Id condition , unsigned int control , int numSegments , const std : : vector < int > & caseValues , <nl> - const std : : vector < int > & valueToSegment , int defaultSegment , std : : vector < Block * > & segmentBB ) ; / / return argument <nl> - <nl> - / / Add a branch to the innermost switch ' s merge block . <nl> - void addSwitchBreak ( ) ; <nl> - <nl> - / / Move to the next code segment , passing in the return argument in makeSwitch ( ) <nl> - void nextSwitchSegment ( std : : vector < Block * > & segmentBB , int segment ) ; <nl> - <nl> - / / Finish off the innermost switch . <nl> - void endSwitch ( std : : vector < Block * > & segmentBB ) ; <nl> - <nl> - struct LoopBlocks { <nl> - LoopBlocks ( Block & head , Block & body , Block & merge , Block & continue_target ) : <nl> - head ( head ) , body ( body ) , merge ( merge ) , continue_target ( continue_target ) { } <nl> - Block & head , & body , & merge , & continue_target ; <nl> - private : <nl> - LoopBlocks ( ) ; <nl> - LoopBlocks & operator = ( const LoopBlocks & ) ; <nl> - } ; <nl> - <nl> - / / Start a new loop and prepare the builder to generate code for it . Until <nl> - / / closeLoop ( ) is called for this loop , createLoopContinue ( ) and <nl> - / / createLoopExit ( ) will target its corresponding blocks . <nl> - LoopBlocks & makeNewLoop ( ) ; <nl> - <nl> - / / Create a new block in the function containing the build point . Memory is <nl> - / / owned by the function object . <nl> - Block & makeNewBlock ( ) ; <nl> - <nl> - / / Add a branch to the continue_target of the current ( innermost ) loop . <nl> - void createLoopContinue ( ) ; <nl> - <nl> - / / Add an exit ( e . g . " break " ) from the innermost loop that we ' re currently <nl> - / / in . <nl> - void createLoopExit ( ) ; <nl> - <nl> - / / Close the innermost loop that you ' re in <nl> - void closeLoop ( ) ; <nl> - <nl> - / / <nl> - / / Access chain design for an R - Value vs . L - Value : <nl> - / / <nl> - / / There is a single access chain the builder is building at <nl> - / / any particular time . Such a chain can be used to either to a load or <nl> - / / a store , when desired . <nl> - / / <nl> - / / Expressions can be r - values , l - values , or both , or only r - values : <nl> - / / a [ b . c ] . d = . . . . / / l - value <nl> - / / . . . = a [ b . c ] . d ; / / r - value , that also looks like an l - value <nl> - / / + + a [ b . c ] . d ; / / r - value and l - value <nl> - / / ( x + y ) [ 2 ] ; / / r - value only , can ' t possibly be l - value <nl> - / / <nl> - / / Computing an r - value means generating code . Hence , <nl> - / / r - values should only be computed when they are needed , not speculatively . <nl> - / / <nl> - / / Computing an l - value means saving away information for later use in the compiler , <nl> - / / no code is generated until the l - value is later dereferenced . It is okay <nl> - / / to speculatively generate an l - value , just not okay to speculatively dereference it . <nl> - / / <nl> - / / The base of the access chain ( the left - most variable or expression <nl> - / / from which everything is based ) can be set either as an l - value <nl> - / / or as an r - value . Most efficient would be to set an l - value if one <nl> - / / is available . If an expression was evaluated , the resulting r - value <nl> - / / can be set as the chain base . <nl> - / / <nl> - / / The users of this single access chain can save and restore if they <nl> - / / want to nest or manage multiple chains . <nl> - / / <nl> - <nl> - struct AccessChain { <nl> - Id base ; / / for l - values , pointer to the base object , for r - values , the base object <nl> - std : : vector < Id > indexChain ; <nl> - Id instr ; / / cache the instruction that generates this access chain <nl> - std : : vector < unsigned > swizzle ; / / each std : : vector element selects the next GLSL component number <nl> - Id component ; / / a dynamic component index , can coexist with a swizzle , done after the swizzle , NoResult if not present <nl> - Id preSwizzleBaseType ; / / dereferenced type , before swizzle or component is applied ; NoType unless a swizzle or component is present <nl> - bool isRValue ; / / true if ' base ' is an r - value , otherwise , base is an l - value <nl> - } ; <nl> - <nl> - / / <nl> - / / the SPIR - V builder maintains a single active chain that <nl> - / / the following methods operate on <nl> - / / <nl> - <nl> - / / for external save and restore <nl> - AccessChain getAccessChain ( ) { return accessChain ; } <nl> - void setAccessChain ( AccessChain newChain ) { accessChain = newChain ; } <nl> - <nl> - / / clear accessChain <nl> - void clearAccessChain ( ) ; <nl> - <nl> - / / set new base as an l - value base <nl> - void setAccessChainLValue ( Id lValue ) <nl> - { <nl> - assert ( isPointer ( lValue ) ) ; <nl> - accessChain . base = lValue ; <nl> - } <nl> - <nl> - / / set new base value as an r - value <nl> - void setAccessChainRValue ( Id rValue ) <nl> - { <nl> - accessChain . isRValue = true ; <nl> - accessChain . base = rValue ; <nl> - } <nl> - <nl> - / / push offset onto the end of the chain <nl> - void accessChainPush ( Id offset ) <nl> - { <nl> - accessChain . indexChain . push_back ( offset ) ; <nl> - } <nl> - <nl> - / / push new swizzle onto the end of any existing swizzle , merging into a single swizzle <nl> - void accessChainPushSwizzle ( std : : vector < unsigned > & swizzle , Id preSwizzleBaseType ) ; <nl> - <nl> - / / push a dynamic component selection onto the access chain , only applicable with a <nl> - / / non - trivial swizzle or no swizzle <nl> - void accessChainPushComponent ( Id component , Id preSwizzleBaseType ) <nl> - { <nl> - if ( accessChain . swizzle . size ( ) ! = 1 ) { <nl> - accessChain . component = component ; <nl> - if ( accessChain . preSwizzleBaseType = = NoType ) <nl> - accessChain . preSwizzleBaseType = preSwizzleBaseType ; <nl> - } <nl> - } <nl> - <nl> - / / use accessChain and swizzle to store value <nl> - void accessChainStore ( Id rvalue ) ; <nl> - <nl> - / / use accessChain and swizzle to load an r - value <nl> - Id accessChainLoad ( Decoration precision , Id ResultType ) ; <nl> - <nl> - / / get the direct pointer for an l - value <nl> - Id accessChainGetLValue ( ) ; <nl> - <nl> - / / Get the inferred SPIR - V type of the result of the current access chain , <nl> - / / based on the type of the base and the chain of dereferences . <nl> - Id accessChainGetInferredType ( ) ; <nl> - <nl> - / / Remove OpDecorate instructions whose operands are defined in unreachable <nl> - / / blocks . <nl> - void eliminateDeadDecorations ( ) ; <nl> - void dump ( std : : vector < unsigned int > & ) const ; <nl> - <nl> - void createBranch ( Block * block ) ; <nl> - void createConditionalBranch ( Id condition , Block * thenBlock , Block * elseBlock ) ; <nl> - void createLoopMerge ( Block * mergeBlock , Block * continueBlock , unsigned int control , unsigned int dependencyLength ) ; <nl> - <nl> - / / Sets to generate opcode for specialization constants . <nl> - void setToSpecConstCodeGenMode ( ) { generatingOpCodeForSpecConst = true ; } <nl> - / / Sets to generate opcode for non - specialization constants ( normal mode ) . <nl> - void setToNormalCodeGenMode ( ) { generatingOpCodeForSpecConst = false ; } <nl> - / / Check if the builder is generating code for spec constants . <nl> - bool isInSpecConstCodeGenMode ( ) { return generatingOpCodeForSpecConst ; } <nl> - <nl> - protected : <nl> - Id makeIntConstant ( Id typeId , unsigned value , bool specConstant ) ; <nl> - Id makeInt64Constant ( Id typeId , unsigned long long value , bool specConstant ) ; <nl> - Id findScalarConstant ( Op typeClass , Op opcode , Id typeId , unsigned value ) const ; <nl> - Id findScalarConstant ( Op typeClass , Op opcode , Id typeId , unsigned v1 , unsigned v2 ) const ; <nl> - Id findCompositeConstant ( Op typeClass , const std : : vector < Id > & comps ) const ; <nl> - Id collapseAccessChain ( ) ; <nl> - void remapDynamicSwizzle ( ) ; <nl> - void transferAccessChainSwizzle ( bool dynamic ) ; <nl> - void simplifyAccessChainSwizzle ( ) ; <nl> - void createAndSetNoPredecessorBlock ( const char * ) ; <nl> - void createSelectionMerge ( Block * mergeBlock , unsigned int control ) ; <nl> - void dumpSourceInstructions ( std : : vector < unsigned int > & ) const ; <nl> - void dumpInstructions ( std : : vector < unsigned int > & , const std : : vector < std : : unique_ptr < Instruction > > & ) const ; <nl> - void dumpModuleProcesses ( std : : vector < unsigned int > & ) const ; <nl> - <nl> - unsigned int spvVersion ; / / the version of SPIR - V to emit in the header <nl> - SourceLanguage source ; <nl> - int sourceVersion ; <nl> - spv : : Id sourceFileStringId ; <nl> - std : : string sourceText ; <nl> - int currentLine ; <nl> - bool emitOpLines ; <nl> - std : : set < std : : string > extensions ; <nl> - std : : vector < const char * > sourceExtensions ; <nl> - std : : vector < const char * > moduleProcesses ; <nl> - AddressingModel addressModel ; <nl> - MemoryModel memoryModel ; <nl> - std : : set < spv : : Capability > capabilities ; <nl> - int builderNumber ; <nl> - Module module ; <nl> - Block * buildPoint ; <nl> - Id uniqueId ; <nl> - Function * entryPointFunction ; <nl> - bool generatingOpCodeForSpecConst ; <nl> - AccessChain accessChain ; <nl> - <nl> - / / special blocks of instructions for output <nl> - std : : vector < std : : unique_ptr < Instruction > > strings ; <nl> - std : : vector < std : : unique_ptr < Instruction > > imports ; <nl> - std : : vector < std : : unique_ptr < Instruction > > entryPoints ; <nl> - std : : vector < std : : unique_ptr < Instruction > > executionModes ; <nl> - std : : vector < std : : unique_ptr < Instruction > > names ; <nl> - std : : vector < std : : unique_ptr < Instruction > > lines ; <nl> - std : : vector < std : : unique_ptr < Instruction > > decorations ; <nl> - std : : vector < std : : unique_ptr < Instruction > > constantsTypesGlobals ; <nl> - std : : vector < std : : unique_ptr < Instruction > > externals ; <nl> - std : : vector < std : : unique_ptr < Function > > functions ; <nl> - <nl> - / / not output , internally used for quick & dirty canonical ( unique ) creation <nl> - std : : vector < Instruction * > groupedConstants [ OpConstant ] ; / / all types appear before OpConstant <nl> - std : : vector < Instruction * > groupedTypes [ OpConstant ] ; <nl> - <nl> - / / stack of switches <nl> - std : : stack < Block * > switchMerges ; <nl> - <nl> - / / Our loop stack . <nl> - std : : stack < LoopBlocks > loops ; <nl> - <nl> - / / The stream for outputting warnings and errors . <nl> - SpvBuildLogger * logger ; <nl> - } ; / / end Builder class <nl> - <nl> - } ; / / end spv namespace <nl> - <nl> - # endif / / SpvBuilder_H <nl> deleted file mode 100644 <nl> index 31288ab6 . . 00000000 <nl> mmm a / glslang / include / SPIRV / bitutils . h <nl> ppp / dev / null <nl> <nl> - / / Copyright ( c ) 2015 - 2016 The Khronos Group Inc . <nl> - / / <nl> - / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> - / / you may not use this file except in compliance with the License . <nl> - / / You may obtain a copy of the License at <nl> - / / <nl> - / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> - / / <nl> - / / Unless required by applicable law or agreed to in writing , software <nl> - / / distributed under the License is distributed on an " AS IS " BASIS , <nl> - / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> - / / See the License for the specific language governing permissions and <nl> - / / limitations under the License . <nl> - <nl> - # ifndef LIBSPIRV_UTIL_BITUTILS_H_ <nl> - # define LIBSPIRV_UTIL_BITUTILS_H_ <nl> - <nl> - # include < cstdint > <nl> - # include < cstring > <nl> - <nl> - namespace spvutils { <nl> - <nl> - / / Performs a bitwise copy of source to the destination type Dest . <nl> - template < typename Dest , typename Src > <nl> - Dest BitwiseCast ( Src source ) { <nl> - Dest dest ; <nl> - static_assert ( sizeof ( source ) = = sizeof ( dest ) , <nl> - " BitwiseCast : Source and destination must have the same size " ) ; <nl> - std : : memcpy ( & dest , & source , sizeof ( dest ) ) ; <nl> - return dest ; <nl> - } <nl> - <nl> - / / SetBits < T , First , Num > returns an integer of type < T > with bits set <nl> - / / for position < First > through < First + Num - 1 > , counting from the least <nl> - / / significant bit . In particular when Num = = 0 , no positions are set to 1 . <nl> - / / A static assert will be triggered if First + Num > sizeof ( T ) * 8 , that is , <nl> - / / a bit that will not fit in the underlying type is set . <nl> - template < typename T , size_t First = 0 , size_t Num = 0 > <nl> - struct SetBits { <nl> - static_assert ( First < sizeof ( T ) * 8 , <nl> - " Tried to set a bit that is shifted too far . " ) ; <nl> - const static T get = ( T ( 1 ) < < First ) | SetBits < T , First + 1 , Num - 1 > : : get ; <nl> - } ; <nl> - <nl> - template < typename T , size_t Last > <nl> - struct SetBits < T , Last , 0 > { <nl> - const static T get = T ( 0 ) ; <nl> - } ; <nl> - <nl> - / / This is all compile - time so we can put our tests right here . <nl> - static_assert ( SetBits < uint32_t , 0 , 0 > : : get = = uint32_t ( 0x00000000 ) , <nl> - " SetBits failed " ) ; <nl> - static_assert ( SetBits < uint32_t , 0 , 1 > : : get = = uint32_t ( 0x00000001 ) , <nl> - " SetBits failed " ) ; <nl> - static_assert ( SetBits < uint32_t , 31 , 1 > : : get = = uint32_t ( 0x80000000 ) , <nl> - " SetBits failed " ) ; <nl> - static_assert ( SetBits < uint32_t , 1 , 2 > : : get = = uint32_t ( 0x00000006 ) , <nl> - " SetBits failed " ) ; <nl> - static_assert ( SetBits < uint32_t , 30 , 2 > : : get = = uint32_t ( 0xc0000000 ) , <nl> - " SetBits failed " ) ; <nl> - static_assert ( SetBits < uint32_t , 0 , 31 > : : get = = uint32_t ( 0x7FFFFFFF ) , <nl> - " SetBits failed " ) ; <nl> - static_assert ( SetBits < uint32_t , 0 , 32 > : : get = = uint32_t ( 0xFFFFFFFF ) , <nl> - " SetBits failed " ) ; <nl> - static_assert ( SetBits < uint32_t , 16 , 16 > : : get = = uint32_t ( 0xFFFF0000 ) , <nl> - " SetBits failed " ) ; <nl> - <nl> - static_assert ( SetBits < uint64_t , 0 , 1 > : : get = = uint64_t ( 0x0000000000000001LL ) , <nl> - " SetBits failed " ) ; <nl> - static_assert ( SetBits < uint64_t , 63 , 1 > : : get = = uint64_t ( 0x8000000000000000LL ) , <nl> - " SetBits failed " ) ; <nl> - static_assert ( SetBits < uint64_t , 62 , 2 > : : get = = uint64_t ( 0xc000000000000000LL ) , <nl> - " SetBits failed " ) ; <nl> - static_assert ( SetBits < uint64_t , 31 , 1 > : : get = = uint64_t ( 0x0000000080000000LL ) , <nl> - " SetBits failed " ) ; <nl> - static_assert ( SetBits < uint64_t , 16 , 16 > : : get = = uint64_t ( 0x00000000FFFF0000LL ) , <nl> - " SetBits failed " ) ; <nl> - <nl> - } / / namespace spvutils <nl> - <nl> - # endif / / LIBSPIRV_UTIL_BITUTILS_H_ <nl> deleted file mode 100644 <nl> index 47cef65a . . 00000000 <nl> mmm a / glslang / include / SPIRV / disassemble . h <nl> ppp / dev / null <nl> <nl> - / / <nl> - / / Copyright ( C ) 2014 - 2015 LunarG , Inc . <nl> - / / <nl> - / / All rights reserved . <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions <nl> - / / are met : <nl> - / / <nl> - / / Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / <nl> - / / Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following <nl> - / / disclaimer in the documentation and / or other materials provided <nl> - / / with the distribution . <nl> - / / <nl> - / / Neither the name of 3Dlabs Inc . Ltd . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived <nl> - / / from this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS <nl> - / / FOR A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE <nl> - / / COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , <nl> - / / INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , <nl> - / / BUT NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; <nl> - / / LOSS OF USE , DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER <nl> - / / CAUSED AND ON ANY THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT <nl> - / / LIABILITY , OR TORT ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN <nl> - / / ANY WAY OUT OF THE USE OF THIS SOFTWARE , EVEN IF ADVISED OF THE <nl> - / / POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / <nl> - / / Disassembler for SPIR - V . <nl> - / / <nl> - <nl> - # pragma once <nl> - # ifndef disassembler_H <nl> - # define disassembler_H <nl> - <nl> - # include < iostream > <nl> - # include < vector > <nl> - <nl> - namespace spv { <nl> - <nl> - void Disassemble ( std : : ostream & out , const std : : vector < unsigned int > & ) ; <nl> - <nl> - } ; / / end namespace spv <nl> - <nl> - # endif / / disassembler_H <nl> deleted file mode 100644 <nl> index 710ca1a5 . . 00000000 <nl> mmm a / glslang / include / SPIRV / doc . h <nl> ppp / dev / null <nl> <nl> - / / <nl> - / / Copyright ( C ) 2014 - 2015 LunarG , Inc . <nl> - / / <nl> - / / All rights reserved . <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions <nl> - / / are met : <nl> - / / <nl> - / / Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / <nl> - / / Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following <nl> - / / disclaimer in the documentation and / or other materials provided <nl> - / / with the distribution . <nl> - / / <nl> - / / Neither the name of 3Dlabs Inc . Ltd . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived <nl> - / / from this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS <nl> - / / FOR A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE <nl> - / / COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , <nl> - / / INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , <nl> - / / BUT NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; <nl> - / / LOSS OF USE , DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER <nl> - / / CAUSED AND ON ANY THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT <nl> - / / LIABILITY , OR TORT ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN <nl> - / / ANY WAY OUT OF THE USE OF THIS SOFTWARE , EVEN IF ADVISED OF THE <nl> - / / POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / <nl> - / / Parameterize the SPIR - V enumerants . <nl> - / / <nl> - <nl> - # pragma once <nl> - <nl> - # include " spirv . hpp " <nl> - <nl> - # include < vector > <nl> - <nl> - namespace spv { <nl> - <nl> - / / Fill in all the parameters <nl> - void Parameterize ( ) ; <nl> - <nl> - / / Return the English names of all the enums . <nl> - const char * SourceString ( int ) ; <nl> - const char * AddressingString ( int ) ; <nl> - const char * MemoryString ( int ) ; <nl> - const char * ExecutionModelString ( int ) ; <nl> - const char * ExecutionModeString ( int ) ; <nl> - const char * StorageClassString ( int ) ; <nl> - const char * DecorationString ( int ) ; <nl> - const char * BuiltInString ( int ) ; <nl> - const char * DimensionString ( int ) ; <nl> - const char * SelectControlString ( int ) ; <nl> - const char * LoopControlString ( int ) ; <nl> - const char * FunctionControlString ( int ) ; <nl> - const char * SamplerAddressingModeString ( int ) ; <nl> - const char * SamplerFilterModeString ( int ) ; <nl> - const char * ImageFormatString ( int ) ; <nl> - const char * ImageChannelOrderString ( int ) ; <nl> - const char * ImageChannelTypeString ( int ) ; <nl> - const char * ImageChannelDataTypeString ( int type ) ; <nl> - const char * ImageOperandsString ( int format ) ; <nl> - const char * ImageOperands ( int ) ; <nl> - const char * FPFastMathString ( int ) ; <nl> - const char * FPRoundingModeString ( int ) ; <nl> - const char * LinkageTypeString ( int ) ; <nl> - const char * FuncParamAttrString ( int ) ; <nl> - const char * AccessQualifierString ( int ) ; <nl> - const char * MemorySemanticsString ( int ) ; <nl> - const char * MemoryAccessString ( int ) ; <nl> - const char * ExecutionScopeString ( int ) ; <nl> - const char * GroupOperationString ( int ) ; <nl> - const char * KernelEnqueueFlagsString ( int ) ; <nl> - const char * KernelProfilingInfoString ( int ) ; <nl> - const char * CapabilityString ( int ) ; <nl> - const char * OpcodeString ( int ) ; <nl> - const char * ScopeString ( int mem ) ; <nl> - <nl> - / / For grouping opcodes into subsections <nl> - enum OpcodeClass { <nl> - OpClassMisc , <nl> - OpClassDebug , <nl> - OpClassAnnotate , <nl> - OpClassExtension , <nl> - OpClassMode , <nl> - OpClassType , <nl> - OpClassConstant , <nl> - OpClassMemory , <nl> - OpClassFunction , <nl> - OpClassImage , <nl> - OpClassConvert , <nl> - OpClassComposite , <nl> - OpClassArithmetic , <nl> - OpClassBit , <nl> - OpClassRelationalLogical , <nl> - OpClassDerivative , <nl> - OpClassFlowControl , <nl> - OpClassAtomic , <nl> - OpClassPrimitive , <nl> - OpClassBarrier , <nl> - OpClassGroup , <nl> - OpClassDeviceSideEnqueue , <nl> - OpClassPipe , <nl> - <nl> - OpClassCount , <nl> - OpClassMissing / / all instructions start out as missing <nl> - } ; <nl> - <nl> - / / For parameterizing operands . <nl> - enum OperandClass { <nl> - OperandNone , <nl> - OperandId , <nl> - OperandVariableIds , <nl> - OperandOptionalLiteral , <nl> - OperandOptionalLiteralString , <nl> - OperandVariableLiterals , <nl> - OperandVariableIdLiteral , <nl> - OperandVariableLiteralId , <nl> - OperandLiteralNumber , <nl> - OperandLiteralString , <nl> - OperandSource , <nl> - OperandExecutionModel , <nl> - OperandAddressing , <nl> - OperandMemory , <nl> - OperandExecutionMode , <nl> - OperandStorage , <nl> - OperandDimensionality , <nl> - OperandSamplerAddressingMode , <nl> - OperandSamplerFilterMode , <nl> - OperandSamplerImageFormat , <nl> - OperandImageChannelOrder , <nl> - OperandImageChannelDataType , <nl> - OperandImageOperands , <nl> - OperandFPFastMath , <nl> - OperandFPRoundingMode , <nl> - OperandLinkageType , <nl> - OperandAccessQualifier , <nl> - OperandFuncParamAttr , <nl> - OperandDecoration , <nl> - OperandBuiltIn , <nl> - OperandSelect , <nl> - OperandLoop , <nl> - OperandFunction , <nl> - OperandMemorySemantics , <nl> - OperandMemoryAccess , <nl> - OperandScope , <nl> - OperandGroupOperation , <nl> - OperandKernelEnqueueFlags , <nl> - OperandKernelProfilingInfo , <nl> - OperandCapability , <nl> - <nl> - OperandOpcode , <nl> - <nl> - OperandCount <nl> - } ; <nl> - <nl> - / / Any specific enum can have a set of capabilities that allow it : <nl> - typedef std : : vector < Capability > EnumCaps ; <nl> - <nl> - / / Parameterize a set of operands with their OperandClass ( es ) and descriptions . <nl> - class OperandParameters { <nl> - public : <nl> - OperandParameters ( ) { } <nl> - void push ( OperandClass oc , const char * d , bool opt = false ) <nl> - { <nl> - opClass . push_back ( oc ) ; <nl> - desc . push_back ( d ) ; <nl> - optional . push_back ( opt ) ; <nl> - } <nl> - void setOptional ( ) ; <nl> - OperandClass getClass ( int op ) const { return opClass [ op ] ; } <nl> - const char * getDesc ( int op ) const { return desc [ op ] ; } <nl> - bool isOptional ( int op ) const { return optional [ op ] ; } <nl> - int getNum ( ) const { return ( int ) opClass . size ( ) ; } <nl> - <nl> - protected : <nl> - std : : vector < OperandClass > opClass ; <nl> - std : : vector < const char * > desc ; <nl> - std : : vector < bool > optional ; <nl> - } ; <nl> - <nl> - / / Parameterize an enumerant <nl> - class EnumParameters { <nl> - public : <nl> - EnumParameters ( ) : desc ( 0 ) { } <nl> - EnumCaps caps ; <nl> - const char * desc ; <nl> - } ; <nl> - <nl> - / / Parameterize a set of enumerants that form an enum <nl> - class EnumDefinition : public EnumParameters { <nl> - public : <nl> - EnumDefinition ( ) : <nl> - ceiling ( 0 ) , bitmask ( false ) , getName ( 0 ) , enumParams ( 0 ) , operandParams ( 0 ) { } <nl> - void set ( int ceil , const char * ( * name ) ( int ) , EnumParameters * ep , bool mask = false ) <nl> - { <nl> - ceiling = ceil ; <nl> - getName = name ; <nl> - bitmask = mask ; <nl> - enumParams = ep ; <nl> - } <nl> - void setOperands ( OperandParameters * op ) { operandParams = op ; } <nl> - int ceiling ; / / ceiling of enumerants <nl> - bool bitmask ; / / true if these enumerants combine into a bitmask <nl> - const char * ( * getName ) ( int ) ; / / a function that returns the name for each enumerant value ( or shift ) <nl> - EnumParameters * enumParams ; / / parameters for each individual enumerant <nl> - OperandParameters * operandParams ; / / sets of operands <nl> - } ; <nl> - <nl> - / / Parameterize an instruction ' s logical format , including its known set of operands , <nl> - / / per OperandParameters above . <nl> - class InstructionParameters { <nl> - public : <nl> - InstructionParameters ( ) : <nl> - opDesc ( " TBD " ) , <nl> - opClass ( OpClassMissing ) , <nl> - typePresent ( true ) , / / most normal , only exceptions have to be spelled out <nl> - resultPresent ( true ) / / most normal , only exceptions have to be spelled out <nl> - { } <nl> - <nl> - void setResultAndType ( bool r , bool t ) <nl> - { <nl> - resultPresent = r ; <nl> - typePresent = t ; <nl> - } <nl> - <nl> - bool hasResult ( ) const { return resultPresent ! = 0 ; } <nl> - bool hasType ( ) const { return typePresent ! = 0 ; } <nl> - <nl> - const char * opDesc ; <nl> - EnumCaps capabilities ; <nl> - OpcodeClass opClass ; <nl> - OperandParameters operands ; <nl> - <nl> - protected : <nl> - int typePresent : 1 ; <nl> - int resultPresent : 1 ; <nl> - } ; <nl> - <nl> - const int OpcodeCeiling = 321 ; <nl> - <nl> - / / The set of objects that hold all the instruction / operand <nl> - / / parameterization information . <nl> - extern InstructionParameters InstructionDesc [ ] ; <nl> - <nl> - / / These hold definitions of the enumerants used for operands <nl> - extern EnumDefinition OperandClassParams [ ] ; <nl> - <nl> - const char * GetOperandDesc ( OperandClass operand ) ; <nl> - void PrintImmediateRow ( int imm , const char * name , const EnumParameters * enumParams , bool caps , bool hex = false ) ; <nl> - const char * AccessQualifierString ( int attr ) ; <nl> - <nl> - void PrintOperands ( const OperandParameters & operands , int reservedOperands ) ; <nl> - <nl> - } ; / / end namespace spv <nl> deleted file mode 100644 <nl> index 905b21a4 . . 00000000 <nl> mmm a / glslang / include / SPIRV / hex_float . h <nl> ppp / dev / null <nl> <nl> - / / Copyright ( c ) 2015 - 2016 The Khronos Group Inc . <nl> - / / <nl> - / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> - / / you may not use this file except in compliance with the License . <nl> - / / You may obtain a copy of the License at <nl> - / / <nl> - / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> - / / <nl> - / / Unless required by applicable law or agreed to in writing , software <nl> - / / distributed under the License is distributed on an " AS IS " BASIS , <nl> - / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> - / / See the License for the specific language governing permissions and <nl> - / / limitations under the License . <nl> - <nl> - # ifndef LIBSPIRV_UTIL_HEX_FLOAT_H_ <nl> - # define LIBSPIRV_UTIL_HEX_FLOAT_H_ <nl> - <nl> - # include < cassert > <nl> - # include < cctype > <nl> - # include < cmath > <nl> - # include < cstdint > <nl> - # include < iomanip > <nl> - # include < limits > <nl> - # include < sstream > <nl> - <nl> - # if defined ( _MSC_VER ) & & _MSC_VER < 1800 <nl> - namespace std { <nl> - bool isnan ( double f ) <nl> - { <nl> - return : : _isnan ( f ) ! = 0 ; <nl> - } <nl> - bool isinf ( double f ) <nl> - { <nl> - return : : _finite ( f ) = = 0 ; <nl> - } <nl> - } <nl> - # endif <nl> - <nl> - # include " bitutils . h " <nl> - <nl> - namespace spvutils { <nl> - <nl> - class Float16 { <nl> - public : <nl> - Float16 ( uint16_t v ) : val ( v ) { } <nl> - Float16 ( ) { } <nl> - static bool isNan ( const Float16 & val ) { <nl> - return ( ( val . val & 0x7C00 ) = = 0x7C00 ) & & ( ( val . val & 0x3FF ) ! = 0 ) ; <nl> - } <nl> - / / Returns true if the given value is any kind of infinity . <nl> - static bool isInfinity ( const Float16 & val ) { <nl> - return ( ( val . val & 0x7C00 ) = = 0x7C00 ) & & ( ( val . val & 0x3FF ) = = 0 ) ; <nl> - } <nl> - Float16 ( const Float16 & other ) { val = other . val ; } <nl> - uint16_t get_value ( ) const { return val ; } <nl> - <nl> - / / Returns the maximum normal value . <nl> - static Float16 max ( ) { return Float16 ( 0x7bff ) ; } <nl> - / / Returns the lowest normal value . <nl> - static Float16 lowest ( ) { return Float16 ( 0xfbff ) ; } <nl> - <nl> - private : <nl> - uint16_t val ; <nl> - } ; <nl> - <nl> - / / To specialize this type , you must override uint_type to define <nl> - / / an unsigned integer that can fit your floating point type . <nl> - / / You must also add a isNan function that returns true if <nl> - / / a value is Nan . <nl> - template < typename T > <nl> - struct FloatProxyTraits { <nl> - typedef void uint_type ; <nl> - } ; <nl> - <nl> - template < > <nl> - struct FloatProxyTraits < float > { <nl> - typedef uint32_t uint_type ; <nl> - static bool isNan ( float f ) { return std : : isnan ( f ) ; } <nl> - / / Returns true if the given value is any kind of infinity . <nl> - static bool isInfinity ( float f ) { return std : : isinf ( f ) ; } <nl> - / / Returns the maximum normal value . <nl> - static float max ( ) { return std : : numeric_limits < float > : : max ( ) ; } <nl> - / / Returns the lowest normal value . <nl> - static float lowest ( ) { return std : : numeric_limits < float > : : lowest ( ) ; } <nl> - } ; <nl> - <nl> - template < > <nl> - struct FloatProxyTraits < double > { <nl> - typedef uint64_t uint_type ; <nl> - static bool isNan ( double f ) { return std : : isnan ( f ) ; } <nl> - / / Returns true if the given value is any kind of infinity . <nl> - static bool isInfinity ( double f ) { return std : : isinf ( f ) ; } <nl> - / / Returns the maximum normal value . <nl> - static double max ( ) { return std : : numeric_limits < double > : : max ( ) ; } <nl> - / / Returns the lowest normal value . <nl> - static double lowest ( ) { return std : : numeric_limits < double > : : lowest ( ) ; } <nl> - } ; <nl> - <nl> - template < > <nl> - struct FloatProxyTraits < Float16 > { <nl> - typedef uint16_t uint_type ; <nl> - static bool isNan ( Float16 f ) { return Float16 : : isNan ( f ) ; } <nl> - / / Returns true if the given value is any kind of infinity . <nl> - static bool isInfinity ( Float16 f ) { return Float16 : : isInfinity ( f ) ; } <nl> - / / Returns the maximum normal value . <nl> - static Float16 max ( ) { return Float16 : : max ( ) ; } <nl> - / / Returns the lowest normal value . <nl> - static Float16 lowest ( ) { return Float16 : : lowest ( ) ; } <nl> - } ; <nl> - <nl> - / / Since copying a floating point number ( especially if it is NaN ) <nl> - / / does not guarantee that bits are preserved , this class lets us <nl> - / / store the type and use it as a float when necessary . <nl> - template < typename T > <nl> - class FloatProxy { <nl> - public : <nl> - typedef typename FloatProxyTraits < T > : : uint_type uint_type ; <nl> - <nl> - / / Since this is to act similar to the normal floats , <nl> - / / do not initialize the data by default . <nl> - FloatProxy ( ) { } <nl> - <nl> - / / Intentionally non - explicit . This is a proxy type so <nl> - / / implicit conversions allow us to use it more transparently . <nl> - FloatProxy ( T val ) { data_ = BitwiseCast < uint_type > ( val ) ; } <nl> - <nl> - / / Intentionally non - explicit . This is a proxy type so <nl> - / / implicit conversions allow us to use it more transparently . <nl> - FloatProxy ( uint_type val ) { data_ = val ; } <nl> - <nl> - / / This is helpful to have and is guaranteed not to stomp bits . <nl> - FloatProxy < T > operator - ( ) const { <nl> - return static_cast < uint_type > ( data_ ^ <nl> - ( uint_type ( 0x1 ) < < ( sizeof ( T ) * 8 - 1 ) ) ) ; <nl> - } <nl> - <nl> - / / Returns the data as a floating point value . <nl> - T getAsFloat ( ) const { return BitwiseCast < T > ( data_ ) ; } <nl> - <nl> - / / Returns the raw data . <nl> - uint_type data ( ) const { return data_ ; } <nl> - <nl> - / / Returns true if the value represents any type of NaN . <nl> - bool isNan ( ) { return FloatProxyTraits < T > : : isNan ( getAsFloat ( ) ) ; } <nl> - / / Returns true if the value represents any type of infinity . <nl> - bool isInfinity ( ) { return FloatProxyTraits < T > : : isInfinity ( getAsFloat ( ) ) ; } <nl> - <nl> - / / Returns the maximum normal value . <nl> - static FloatProxy < T > max ( ) { <nl> - return FloatProxy < T > ( FloatProxyTraits < T > : : max ( ) ) ; <nl> - } <nl> - / / Returns the lowest normal value . <nl> - static FloatProxy < T > lowest ( ) { <nl> - return FloatProxy < T > ( FloatProxyTraits < T > : : lowest ( ) ) ; <nl> - } <nl> - <nl> - private : <nl> - uint_type data_ ; <nl> - } ; <nl> - <nl> - template < typename T > <nl> - bool operator = = ( const FloatProxy < T > & first , const FloatProxy < T > & second ) { <nl> - return first . data ( ) = = second . data ( ) ; <nl> - } <nl> - <nl> - / / Reads a FloatProxy value as a normal float from a stream . <nl> - template < typename T > <nl> - std : : istream & operator > > ( std : : istream & is , FloatProxy < T > & value ) { <nl> - T float_val ; <nl> - is > > float_val ; <nl> - value = FloatProxy < T > ( float_val ) ; <nl> - return is ; <nl> - } <nl> - <nl> - / / This is an example traits . It is not meant to be used in practice , but will <nl> - / / be the default for any non - specialized type . <nl> - template < typename T > <nl> - struct HexFloatTraits { <nl> - / / Integer type that can store this hex - float . <nl> - typedef void uint_type ; <nl> - / / Signed integer type that can store this hex - float . <nl> - typedef void int_type ; <nl> - / / The numerical type that this HexFloat represents . <nl> - typedef void underlying_type ; <nl> - / / The type needed to construct the underlying type . <nl> - typedef void native_type ; <nl> - / / The number of bits that are actually relevant in the uint_type . <nl> - / / This allows us to deal with , for example , 24 - bit values in a 32 - bit <nl> - / / integer . <nl> - static const uint32_t num_used_bits = 0 ; <nl> - / / Number of bits that represent the exponent . <nl> - static const uint32_t num_exponent_bits = 0 ; <nl> - / / Number of bits that represent the fractional part . <nl> - static const uint32_t num_fraction_bits = 0 ; <nl> - / / The bias of the exponent . ( How much we need to subtract from the stored <nl> - / / value to get the correct value . ) <nl> - static const uint32_t exponent_bias = 0 ; <nl> - } ; <nl> - <nl> - / / Traits for IEEE float . <nl> - / / 1 sign bit , 8 exponent bits , 23 fractional bits . <nl> - template < > <nl> - struct HexFloatTraits < FloatProxy < float > > { <nl> - typedef uint32_t uint_type ; <nl> - typedef int32_t int_type ; <nl> - typedef FloatProxy < float > underlying_type ; <nl> - typedef float native_type ; <nl> - static const uint_type num_used_bits = 32 ; <nl> - static const uint_type num_exponent_bits = 8 ; <nl> - static const uint_type num_fraction_bits = 23 ; <nl> - static const uint_type exponent_bias = 127 ; <nl> - } ; <nl> - <nl> - / / Traits for IEEE double . <nl> - / / 1 sign bit , 11 exponent bits , 52 fractional bits . <nl> - template < > <nl> - struct HexFloatTraits < FloatProxy < double > > { <nl> - typedef uint64_t uint_type ; <nl> - typedef int64_t int_type ; <nl> - typedef FloatProxy < double > underlying_type ; <nl> - typedef double native_type ; <nl> - static const uint_type num_used_bits = 64 ; <nl> - static const uint_type num_exponent_bits = 11 ; <nl> - static const uint_type num_fraction_bits = 52 ; <nl> - static const uint_type exponent_bias = 1023 ; <nl> - } ; <nl> - <nl> - / / Traits for IEEE half . <nl> - / / 1 sign bit , 5 exponent bits , 10 fractional bits . <nl> - template < > <nl> - struct HexFloatTraits < FloatProxy < Float16 > > { <nl> - typedef uint16_t uint_type ; <nl> - typedef int16_t int_type ; <nl> - typedef uint16_t underlying_type ; <nl> - typedef uint16_t native_type ; <nl> - static const uint_type num_used_bits = 16 ; <nl> - static const uint_type num_exponent_bits = 5 ; <nl> - static const uint_type num_fraction_bits = 10 ; <nl> - static const uint_type exponent_bias = 15 ; <nl> - } ; <nl> - <nl> - enum round_direction { <nl> - kRoundToZero , <nl> - kRoundToNearestEven , <nl> - kRoundToPositiveInfinity , <nl> - kRoundToNegativeInfinity <nl> - } ; <nl> - <nl> - / / Template class that houses a floating pointer number . <nl> - / / It exposes a number of constants based on the provided traits to <nl> - / / assist in interpreting the bits of the value . <nl> - template < typename T , typename Traits = HexFloatTraits < T > > <nl> - class HexFloat { <nl> - public : <nl> - typedef typename Traits : : uint_type uint_type ; <nl> - typedef typename Traits : : int_type int_type ; <nl> - typedef typename Traits : : underlying_type underlying_type ; <nl> - typedef typename Traits : : native_type native_type ; <nl> - <nl> - explicit HexFloat ( T f ) : value_ ( f ) { } <nl> - <nl> - T value ( ) const { return value_ ; } <nl> - void set_value ( T f ) { value_ = f ; } <nl> - <nl> - / / These are all written like this because it is convenient to have <nl> - / / compile - time constants for all of these values . <nl> - <nl> - / / Pass - through values to save typing . <nl> - static const uint32_t num_used_bits = Traits : : num_used_bits ; <nl> - static const uint32_t exponent_bias = Traits : : exponent_bias ; <nl> - static const uint32_t num_exponent_bits = Traits : : num_exponent_bits ; <nl> - static const uint32_t num_fraction_bits = Traits : : num_fraction_bits ; <nl> - <nl> - / / Number of bits to shift left to set the highest relevant bit . <nl> - static const uint32_t top_bit_left_shift = num_used_bits - 1 ; <nl> - / / How many nibbles ( hex characters ) the fractional part takes up . <nl> - static const uint32_t fraction_nibbles = ( num_fraction_bits + 3 ) / 4 ; <nl> - / / If the fractional part does not fit evenly into a hex character ( 4 - bits ) <nl> - / / then we have to left - shift to get rid of leading 0s . This is the amount <nl> - / / we have to shift ( might be 0 ) . <nl> - static const uint32_t num_overflow_bits = <nl> - fraction_nibbles * 4 - num_fraction_bits ; <nl> - <nl> - / / The representation of the fraction , not the actual bits . This <nl> - / / includes the leading bit that is usually implicit . <nl> - static const uint_type fraction_represent_mask = <nl> - spvutils : : SetBits < uint_type , 0 , <nl> - num_fraction_bits + num_overflow_bits > : : get ; <nl> - <nl> - / / The topmost bit in the nibble - aligned fraction . <nl> - static const uint_type fraction_top_bit = <nl> - uint_type ( 1 ) < < ( num_fraction_bits + num_overflow_bits - 1 ) ; <nl> - <nl> - / / The least significant bit in the exponent , which is also the bit <nl> - / / immediately to the left of the significand . <nl> - static const uint_type first_exponent_bit = uint_type ( 1 ) <nl> - < < ( num_fraction_bits ) ; <nl> - <nl> - / / The mask for the encoded fraction . It does not include the <nl> - / / implicit bit . <nl> - static const uint_type fraction_encode_mask = <nl> - spvutils : : SetBits < uint_type , 0 , num_fraction_bits > : : get ; <nl> - <nl> - / / The bit that is used as a sign . <nl> - static const uint_type sign_mask = uint_type ( 1 ) < < top_bit_left_shift ; <nl> - <nl> - / / The bits that represent the exponent . <nl> - static const uint_type exponent_mask = <nl> - spvutils : : SetBits < uint_type , num_fraction_bits , num_exponent_bits > : : get ; <nl> - <nl> - / / How far left the exponent is shifted . <nl> - static const uint32_t exponent_left_shift = num_fraction_bits ; <nl> - <nl> - / / How far from the right edge the fraction is shifted . <nl> - static const uint32_t fraction_right_shift = <nl> - static_cast < uint32_t > ( sizeof ( uint_type ) * 8 ) - num_fraction_bits ; <nl> - <nl> - / / The maximum representable unbiased exponent . <nl> - static const int_type max_exponent = <nl> - ( exponent_mask > > num_fraction_bits ) - exponent_bias ; <nl> - / / The minimum representable exponent for normalized numbers . <nl> - static const int_type min_exponent = - static_cast < int_type > ( exponent_bias ) ; <nl> - <nl> - / / Returns the bits associated with the value . <nl> - uint_type getBits ( ) const { return spvutils : : BitwiseCast < uint_type > ( value_ ) ; } <nl> - <nl> - / / Returns the bits associated with the value , without the leading sign bit . <nl> - uint_type getUnsignedBits ( ) const { <nl> - return static_cast < uint_type > ( spvutils : : BitwiseCast < uint_type > ( value_ ) & <nl> - ~ sign_mask ) ; <nl> - } <nl> - <nl> - / / Returns the bits associated with the exponent , shifted to start at the <nl> - / / lsb of the type . <nl> - const uint_type getExponentBits ( ) const { <nl> - return static_cast < uint_type > ( ( getBits ( ) & exponent_mask ) > > <nl> - num_fraction_bits ) ; <nl> - } <nl> - <nl> - / / Returns the exponent in unbiased form . This is the exponent in the <nl> - / / human - friendly form . <nl> - const int_type getUnbiasedExponent ( ) const { <nl> - return static_cast < int_type > ( getExponentBits ( ) - exponent_bias ) ; <nl> - } <nl> - <nl> - / / Returns just the significand bits from the value . <nl> - const uint_type getSignificandBits ( ) const { <nl> - return getBits ( ) & fraction_encode_mask ; <nl> - } <nl> - <nl> - / / If the number was normalized , returns the unbiased exponent . <nl> - / / If the number was denormal , normalize the exponent first . <nl> - const int_type getUnbiasedNormalizedExponent ( ) const { <nl> - if ( ( getBits ( ) & ~ sign_mask ) = = 0 ) { / / special case if everything is 0 <nl> - return 0 ; <nl> - } <nl> - int_type exp = getUnbiasedExponent ( ) ; <nl> - if ( exp = = min_exponent ) { / / We are in denorm land . <nl> - uint_type significand_bits = getSignificandBits ( ) ; <nl> - while ( ( significand_bits & ( first_exponent_bit > > 1 ) ) = = 0 ) { <nl> - significand_bits = static_cast < uint_type > ( significand_bits < < 1 ) ; <nl> - exp = static_cast < int_type > ( exp - 1 ) ; <nl> - } <nl> - significand_bits & = fraction_encode_mask ; <nl> - } <nl> - return exp ; <nl> - } <nl> - <nl> - / / Returns the signficand after it has been normalized . <nl> - const uint_type getNormalizedSignificand ( ) const { <nl> - int_type unbiased_exponent = getUnbiasedNormalizedExponent ( ) ; <nl> - uint_type significand = getSignificandBits ( ) ; <nl> - for ( int_type i = unbiased_exponent ; i < = min_exponent ; + + i ) { <nl> - significand = static_cast < uint_type > ( significand < < 1 ) ; <nl> - } <nl> - significand & = fraction_encode_mask ; <nl> - return significand ; <nl> - } <nl> - <nl> - / / Returns true if this number represents a negative value . <nl> - bool isNegative ( ) const { return ( getBits ( ) & sign_mask ) ! = 0 ; } <nl> - <nl> - / / Sets this HexFloat from the individual components . <nl> - / / Note this assumes EVERY significand is normalized , and has an implicit <nl> - / / leading one . This means that the only way that this method will set 0 , <nl> - / / is if you set a number so denormalized that it underflows . <nl> - / / Do not use this method with raw bits extracted from a subnormal number , <nl> - / / since subnormals do not have an implicit leading 1 in the significand . <nl> - / / The significand is also expected to be in the <nl> - / / lowest - most num_fraction_bits of the uint_type . <nl> - / / The exponent is expected to be unbiased , meaning an exponent of <nl> - / / 0 actually means 0 . <nl> - / / If underflow_round_up is set , then on underflow , if a number is non - 0 <nl> - / / and would underflow , we round up to the smallest denorm . <nl> - void setFromSignUnbiasedExponentAndNormalizedSignificand ( <nl> - bool negative , int_type exponent , uint_type significand , <nl> - bool round_denorm_up ) { <nl> - bool significand_is_zero = significand = = 0 ; <nl> - <nl> - if ( exponent < = min_exponent ) { <nl> - / / If this was denormalized , then we have to shift the bit on , meaning <nl> - / / the significand is not zero . <nl> - significand_is_zero = false ; <nl> - significand | = first_exponent_bit ; <nl> - significand = static_cast < uint_type > ( significand > > 1 ) ; <nl> - } <nl> - <nl> - while ( exponent < min_exponent ) { <nl> - significand = static_cast < uint_type > ( significand > > 1 ) ; <nl> - + + exponent ; <nl> - } <nl> - <nl> - if ( exponent = = min_exponent ) { <nl> - if ( significand = = 0 & & ! significand_is_zero & & round_denorm_up ) { <nl> - significand = static_cast < uint_type > ( 0x1 ) ; <nl> - } <nl> - } <nl> - <nl> - uint_type new_value = 0 ; <nl> - if ( negative ) { <nl> - new_value = static_cast < uint_type > ( new_value | sign_mask ) ; <nl> - } <nl> - exponent = static_cast < int_type > ( exponent + exponent_bias ) ; <nl> - assert ( exponent > = 0 ) ; <nl> - <nl> - / / put it all together <nl> - exponent = static_cast < uint_type > ( ( exponent < < exponent_left_shift ) & <nl> - exponent_mask ) ; <nl> - significand = static_cast < uint_type > ( significand & fraction_encode_mask ) ; <nl> - new_value = static_cast < uint_type > ( new_value | ( exponent | significand ) ) ; <nl> - value_ = BitwiseCast < T > ( new_value ) ; <nl> - } <nl> - <nl> - / / Increments the significand of this number by the given amount . <nl> - / / If this would spill the significand into the implicit bit , <nl> - / / carry is set to true and the significand is shifted to fit into <nl> - / / the correct location , otherwise carry is set to false . <nl> - / / All significands and to_increment are assumed to be within the bounds <nl> - / / for a valid significand . <nl> - static uint_type incrementSignificand ( uint_type significand , <nl> - uint_type to_increment , bool * carry ) { <nl> - significand = static_cast < uint_type > ( significand + to_increment ) ; <nl> - * carry = false ; <nl> - if ( significand & first_exponent_bit ) { <nl> - * carry = true ; <nl> - / / The implicit 1 - bit will have carried , so we should zero - out the <nl> - / / top bit and shift back . <nl> - significand = static_cast < uint_type > ( significand & ~ first_exponent_bit ) ; <nl> - significand = static_cast < uint_type > ( significand > > 1 ) ; <nl> - } <nl> - return significand ; <nl> - } <nl> - <nl> - / / These exist because MSVC throws warnings on negative right - shifts <nl> - / / even if they are not going to be executed . Eg : <nl> - / / constant_number < 0 ? 0 : constant_number <nl> - / / These convert the negative left - shifts into right shifts . <nl> - <nl> - template < typename int_type > <nl> - uint_type negatable_left_shift ( int_type N , uint_type val ) <nl> - { <nl> - if ( N > = 0 ) <nl> - return val < < N ; <nl> - <nl> - return val > > - N ; <nl> - } <nl> - <nl> - template < typename int_type > <nl> - uint_type negatable_right_shift ( int_type N , uint_type val ) <nl> - { <nl> - if ( N > = 0 ) <nl> - return val > > N ; <nl> - <nl> - return val < < - N ; <nl> - } <nl> - <nl> - / / Returns the significand , rounded to fit in a significand in <nl> - / / other_T . This is shifted so that the most significant <nl> - / / bit of the rounded number lines up with the most significant bit <nl> - / / of the returned significand . <nl> - template < typename other_T > <nl> - typename other_T : : uint_type getRoundedNormalizedSignificand ( <nl> - round_direction dir , bool * carry_bit ) { <nl> - typedef typename other_T : : uint_type other_uint_type ; <nl> - static const int_type num_throwaway_bits = <nl> - static_cast < int_type > ( num_fraction_bits ) - <nl> - static_cast < int_type > ( other_T : : num_fraction_bits ) ; <nl> - <nl> - static const uint_type last_significant_bit = <nl> - ( num_throwaway_bits < 0 ) <nl> - ? 0 <nl> - : negatable_left_shift ( num_throwaway_bits , 1u ) ; <nl> - static const uint_type first_rounded_bit = <nl> - ( num_throwaway_bits < 1 ) <nl> - ? 0 <nl> - : negatable_left_shift ( num_throwaway_bits - 1 , 1u ) ; <nl> - <nl> - static const uint_type throwaway_mask_bits = <nl> - num_throwaway_bits > 0 ? num_throwaway_bits : 0 ; <nl> - static const uint_type throwaway_mask = <nl> - spvutils : : SetBits < uint_type , 0 , throwaway_mask_bits > : : get ; <nl> - <nl> - * carry_bit = false ; <nl> - other_uint_type out_val = 0 ; <nl> - uint_type significand = getNormalizedSignificand ( ) ; <nl> - / / If we are up - casting , then we just have to shift to the right location . <nl> - if ( num_throwaway_bits < = 0 ) { <nl> - out_val = static_cast < other_uint_type > ( significand ) ; <nl> - uint_type shift_amount = static_cast < uint_type > ( - num_throwaway_bits ) ; <nl> - out_val = static_cast < other_uint_type > ( out_val < < shift_amount ) ; <nl> - return out_val ; <nl> - } <nl> - <nl> - / / If every non - representable bit is 0 , then we don ' t have any casting to <nl> - / / do . <nl> - if ( ( significand & throwaway_mask ) = = 0 ) { <nl> - return static_cast < other_uint_type > ( <nl> - negatable_right_shift ( num_throwaway_bits , significand ) ) ; <nl> - } <nl> - <nl> - bool round_away_from_zero = false ; <nl> - / / We actually have to narrow the significand here , so we have to follow the <nl> - / / rounding rules . <nl> - switch ( dir ) { <nl> - case kRoundToZero : <nl> - break ; <nl> - case kRoundToPositiveInfinity : <nl> - round_away_from_zero = ! isNegative ( ) ; <nl> - break ; <nl> - case kRoundToNegativeInfinity : <nl> - round_away_from_zero = isNegative ( ) ; <nl> - break ; <nl> - case kRoundToNearestEven : <nl> - / / Have to round down , round bit is 0 <nl> - if ( ( first_rounded_bit & significand ) = = 0 ) { <nl> - break ; <nl> - } <nl> - if ( ( ( significand & throwaway_mask ) & ~ first_rounded_bit ) ! = 0 ) { <nl> - / / If any subsequent bit of the rounded portion is non - 0 then we round <nl> - / / up . <nl> - round_away_from_zero = true ; <nl> - break ; <nl> - } <nl> - / / We are exactly half - way between 2 numbers , pick even . <nl> - if ( ( significand & last_significant_bit ) ! = 0 ) { <nl> - / / 1 for our last bit , round up . <nl> - round_away_from_zero = true ; <nl> - break ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - if ( round_away_from_zero ) { <nl> - return static_cast < other_uint_type > ( <nl> - negatable_right_shift ( num_throwaway_bits , incrementSignificand ( <nl> - significand , last_significant_bit , carry_bit ) ) ) ; <nl> - } else { <nl> - return static_cast < other_uint_type > ( <nl> - negatable_right_shift ( num_throwaway_bits , significand ) ) ; <nl> - } <nl> - } <nl> - <nl> - / / Casts this value to another HexFloat . If the cast is widening , <nl> - / / then round_dir is ignored . If the cast is narrowing , then <nl> - / / the result is rounded in the direction specified . <nl> - / / This number will retain Nan and Inf values . <nl> - / / It will also saturate to Inf if the number overflows , and <nl> - / / underflow to ( 0 or min depending on rounding ) if the number underflows . <nl> - template < typename other_T > <nl> - void castTo ( other_T & other , round_direction round_dir ) { <nl> - other = other_T ( static_cast < typename other_T : : native_type > ( 0 ) ) ; <nl> - bool negate = isNegative ( ) ; <nl> - if ( getUnsignedBits ( ) = = 0 ) { <nl> - if ( negate ) { <nl> - other . set_value ( - other . value ( ) ) ; <nl> - } <nl> - return ; <nl> - } <nl> - uint_type significand = getSignificandBits ( ) ; <nl> - bool carried = false ; <nl> - typename other_T : : uint_type rounded_significand = <nl> - getRoundedNormalizedSignificand < other_T > ( round_dir , & carried ) ; <nl> - <nl> - int_type exponent = getUnbiasedExponent ( ) ; <nl> - if ( exponent = = min_exponent ) { <nl> - / / If we are denormal , normalize the exponent , so that we can encode <nl> - / / easily . <nl> - exponent = static_cast < int_type > ( exponent + 1 ) ; <nl> - for ( uint_type check_bit = first_exponent_bit > > 1 ; check_bit ! = 0 ; <nl> - check_bit = static_cast < uint_type > ( check_bit > > 1 ) ) { <nl> - exponent = static_cast < int_type > ( exponent - 1 ) ; <nl> - if ( check_bit & significand ) break ; <nl> - } <nl> - } <nl> - <nl> - bool is_nan = <nl> - ( getBits ( ) & exponent_mask ) = = exponent_mask & & significand ! = 0 ; <nl> - bool is_inf = <nl> - ! is_nan & & <nl> - ( ( exponent + carried ) > static_cast < int_type > ( other_T : : exponent_bias ) | | <nl> - ( significand = = 0 & & ( getBits ( ) & exponent_mask ) = = exponent_mask ) ) ; <nl> - <nl> - / / If we are Nan or Inf we should pass that through . <nl> - if ( is_inf ) { <nl> - other . set_value ( BitwiseCast < typename other_T : : underlying_type > ( <nl> - static_cast < typename other_T : : uint_type > ( <nl> - ( negate ? other_T : : sign_mask : 0 ) | other_T : : exponent_mask ) ) ) ; <nl> - return ; <nl> - } <nl> - if ( is_nan ) { <nl> - typename other_T : : uint_type shifted_significand ; <nl> - shifted_significand = static_cast < typename other_T : : uint_type > ( <nl> - negatable_left_shift ( <nl> - static_cast < int_type > ( other_T : : num_fraction_bits ) - <nl> - static_cast < int_type > ( num_fraction_bits ) , significand ) ) ; <nl> - <nl> - / / We are some sort of Nan . We try to keep the bit - pattern of the Nan <nl> - / / as close as possible . If we had to shift off bits so we are 0 , then we <nl> - / / just set the last bit . <nl> - other . set_value ( BitwiseCast < typename other_T : : underlying_type > ( <nl> - static_cast < typename other_T : : uint_type > ( <nl> - ( negate ? other_T : : sign_mask : 0 ) | other_T : : exponent_mask | <nl> - ( shifted_significand = = 0 ? 0x1 : shifted_significand ) ) ) ) ; <nl> - return ; <nl> - } <nl> - <nl> - bool round_underflow_up = <nl> - isNegative ( ) ? round_dir = = kRoundToNegativeInfinity <nl> - : round_dir = = kRoundToPositiveInfinity ; <nl> - typedef typename other_T : : int_type other_int_type ; <nl> - / / setFromSignUnbiasedExponentAndNormalizedSignificand will <nl> - / / zero out any underflowing value ( but retain the sign ) . <nl> - other . setFromSignUnbiasedExponentAndNormalizedSignificand ( <nl> - negate , static_cast < other_int_type > ( exponent ) , rounded_significand , <nl> - round_underflow_up ) ; <nl> - return ; <nl> - } <nl> - <nl> - private : <nl> - T value_ ; <nl> - <nl> - static_assert ( num_used_bits = = <nl> - Traits : : num_exponent_bits + Traits : : num_fraction_bits + 1 , <nl> - " The number of bits do not fit " ) ; <nl> - static_assert ( sizeof ( T ) = = sizeof ( uint_type ) , " The type sizes do not match " ) ; <nl> - } ; <nl> - <nl> - / / Returns 4 bits represented by the hex character . <nl> - inline uint8_t get_nibble_from_character ( int character ) { <nl> - const char * dec = " 0123456789 " ; <nl> - const char * lower = " abcdef " ; <nl> - const char * upper = " ABCDEF " ; <nl> - const char * p = nullptr ; <nl> - if ( ( p = strchr ( dec , character ) ) ) { <nl> - return static_cast < uint8_t > ( p - dec ) ; <nl> - } else if ( ( p = strchr ( lower , character ) ) ) { <nl> - return static_cast < uint8_t > ( p - lower + 0xa ) ; <nl> - } else if ( ( p = strchr ( upper , character ) ) ) { <nl> - return static_cast < uint8_t > ( p - upper + 0xa ) ; <nl> - } <nl> - <nl> - assert ( false & & " This was called with a non - hex character " ) ; <nl> - return 0 ; <nl> - } <nl> - <nl> - / / Outputs the given HexFloat to the stream . <nl> - template < typename T , typename Traits > <nl> - std : : ostream & operator < < ( std : : ostream & os , const HexFloat < T , Traits > & value ) { <nl> - typedef HexFloat < T , Traits > HF ; <nl> - typedef typename HF : : uint_type uint_type ; <nl> - typedef typename HF : : int_type int_type ; <nl> - <nl> - static_assert ( HF : : num_used_bits ! = 0 , <nl> - " num_used_bits must be non - zero for a valid float " ) ; <nl> - static_assert ( HF : : num_exponent_bits ! = 0 , <nl> - " num_exponent_bits must be non - zero for a valid float " ) ; <nl> - static_assert ( HF : : num_fraction_bits ! = 0 , <nl> - " num_fractin_bits must be non - zero for a valid float " ) ; <nl> - <nl> - const uint_type bits = spvutils : : BitwiseCast < uint_type > ( value . value ( ) ) ; <nl> - const char * const sign = ( bits & HF : : sign_mask ) ? " - " : " " ; <nl> - const uint_type exponent = static_cast < uint_type > ( <nl> - ( bits & HF : : exponent_mask ) > > HF : : num_fraction_bits ) ; <nl> - <nl> - uint_type fraction = static_cast < uint_type > ( ( bits & HF : : fraction_encode_mask ) <nl> - < < HF : : num_overflow_bits ) ; <nl> - <nl> - const bool is_zero = exponent = = 0 & & fraction = = 0 ; <nl> - const bool is_denorm = exponent = = 0 & & ! is_zero ; <nl> - <nl> - / / exponent contains the biased exponent we have to convert it back into <nl> - / / the normal range . <nl> - int_type int_exponent = static_cast < int_type > ( exponent - HF : : exponent_bias ) ; <nl> - / / If the number is all zeros , then we actually have to NOT shift the <nl> - / / exponent . <nl> - int_exponent = is_zero ? 0 : int_exponent ; <nl> - <nl> - / / If we are denorm , then start shifting , and decreasing the exponent until <nl> - / / our leading bit is 1 . <nl> - <nl> - if ( is_denorm ) { <nl> - while ( ( fraction & HF : : fraction_top_bit ) = = 0 ) { <nl> - fraction = static_cast < uint_type > ( fraction < < 1 ) ; <nl> - int_exponent = static_cast < int_type > ( int_exponent - 1 ) ; <nl> - } <nl> - / / Since this is denormalized , we have to consume the leading 1 since it <nl> - / / will end up being implicit . <nl> - fraction = static_cast < uint_type > ( fraction < < 1 ) ; / / eat the leading 1 <nl> - fraction & = HF : : fraction_represent_mask ; <nl> - } <nl> - <nl> - uint_type fraction_nibbles = HF : : fraction_nibbles ; <nl> - / / We do not have to display any trailing 0s , since this represents the <nl> - / / fractional part . <nl> - while ( fraction_nibbles > 0 & & ( fraction & 0xF ) = = 0 ) { <nl> - / / Shift off any trailing values ; <nl> - fraction = static_cast < uint_type > ( fraction > > 4 ) ; <nl> - - - fraction_nibbles ; <nl> - } <nl> - <nl> - const auto saved_flags = os . flags ( ) ; <nl> - const auto saved_fill = os . fill ( ) ; <nl> - <nl> - os < < sign < < " 0x " < < ( is_zero ? ' 0 ' : ' 1 ' ) ; <nl> - if ( fraction_nibbles ) { <nl> - / / Make sure to keep the leading 0s in place , since this is the fractional <nl> - / / part . <nl> - os < < " . " < < std : : setw ( static_cast < int > ( fraction_nibbles ) ) <nl> - < < std : : setfill ( ' 0 ' ) < < std : : hex < < fraction ; <nl> - } <nl> - os < < " p " < < std : : dec < < ( int_exponent > = 0 ? " + " : " " ) < < int_exponent ; <nl> - <nl> - os . flags ( saved_flags ) ; <nl> - os . fill ( saved_fill ) ; <nl> - <nl> - return os ; <nl> - } <nl> - <nl> - / / Returns true if negate_value is true and the next character on the <nl> - / / input stream is a plus or minus sign . In that case we also set the fail bit <nl> - / / on the stream and set the value to the zero value for its type . <nl> - template < typename T , typename Traits > <nl> - inline bool RejectParseDueToLeadingSign ( std : : istream & is , bool negate_value , <nl> - HexFloat < T , Traits > & value ) { <nl> - if ( negate_value ) { <nl> - auto next_char = is . peek ( ) ; <nl> - if ( next_char = = ' - ' | | next_char = = ' + ' ) { <nl> - / / Fail the parse . Emulate standard behaviour by setting the value to <nl> - / / the zero value , and set the fail bit on the stream . <nl> - value = HexFloat < T , Traits > ( typename HexFloat < T , Traits > : : uint_type ( 0 ) ) ; <nl> - is . setstate ( std : : ios_base : : failbit ) ; <nl> - return true ; <nl> - } <nl> - } <nl> - return false ; <nl> - } <nl> - <nl> - / / Parses a floating point number from the given stream and stores it into the <nl> - / / value parameter . <nl> - / / If negate_value is true then the number may not have a leading minus or <nl> - / / plus , and if it successfully parses , then the number is negated before <nl> - / / being stored into the value parameter . <nl> - / / If the value cannot be correctly parsed or overflows the target floating <nl> - / / point type , then set the fail bit on the stream . <nl> - / / TODO ( dneto ) : Promise C + + 11 standard behavior in how the value is set in <nl> - / / the error case , but only after all target platforms implement it correctly . <nl> - / / In particular , the Microsoft C + + runtime appears to be out of spec . <nl> - template < typename T , typename Traits > <nl> - inline std : : istream & ParseNormalFloat ( std : : istream & is , bool negate_value , <nl> - HexFloat < T , Traits > & value ) { <nl> - if ( RejectParseDueToLeadingSign ( is , negate_value , value ) ) { <nl> - return is ; <nl> - } <nl> - T val ; <nl> - is > > val ; <nl> - if ( negate_value ) { <nl> - val = - val ; <nl> - } <nl> - value . set_value ( val ) ; <nl> - / / In the failure case , map - 0 . 0 to 0 . 0 . <nl> - if ( is . fail ( ) & & value . getUnsignedBits ( ) = = 0u ) { <nl> - value = HexFloat < T , Traits > ( typename HexFloat < T , Traits > : : uint_type ( 0 ) ) ; <nl> - } <nl> - if ( val . isInfinity ( ) ) { <nl> - / / Fail the parse . Emulate standard behaviour by setting the value to <nl> - / / the closest normal value , and set the fail bit on the stream . <nl> - value . set_value ( ( value . isNegative ( ) | negate_value ) ? T : : lowest ( ) <nl> - : T : : max ( ) ) ; <nl> - is . setstate ( std : : ios_base : : failbit ) ; <nl> - } <nl> - return is ; <nl> - } <nl> - <nl> - / / Specialization of ParseNormalFloat for FloatProxy < Float16 > values . <nl> - / / This will parse the float as it were a 32 - bit floating point number , <nl> - / / and then round it down to fit into a Float16 value . <nl> - / / The number is rounded towards zero . <nl> - / / If negate_value is true then the number may not have a leading minus or <nl> - / / plus , and if it successfully parses , then the number is negated before <nl> - / / being stored into the value parameter . <nl> - / / If the value cannot be correctly parsed or overflows the target floating <nl> - / / point type , then set the fail bit on the stream . <nl> - / / TODO ( dneto ) : Promise C + + 11 standard behavior in how the value is set in <nl> - / / the error case , but only after all target platforms implement it correctly . <nl> - / / In particular , the Microsoft C + + runtime appears to be out of spec . <nl> - template < > <nl> - inline std : : istream & <nl> - ParseNormalFloat < FloatProxy < Float16 > , HexFloatTraits < FloatProxy < Float16 > > > ( <nl> - std : : istream & is , bool negate_value , <nl> - HexFloat < FloatProxy < Float16 > , HexFloatTraits < FloatProxy < Float16 > > > & value ) { <nl> - / / First parse as a 32 - bit float . <nl> - HexFloat < FloatProxy < float > > float_val ( 0 . 0f ) ; <nl> - ParseNormalFloat ( is , negate_value , float_val ) ; <nl> - <nl> - / / Then convert to 16 - bit float , saturating at infinities , and <nl> - / / rounding toward zero . <nl> - float_val . castTo ( value , kRoundToZero ) ; <nl> - <nl> - / / Overflow on 16 - bit behaves the same as for 32 - and 64 - bit : set the <nl> - / / fail bit and set the lowest or highest value . <nl> - if ( Float16 : : isInfinity ( value . value ( ) . getAsFloat ( ) ) ) { <nl> - value . set_value ( value . isNegative ( ) ? Float16 : : lowest ( ) : Float16 : : max ( ) ) ; <nl> - is . setstate ( std : : ios_base : : failbit ) ; <nl> - } <nl> - return is ; <nl> - } <nl> - <nl> - / / Reads a HexFloat from the given stream . <nl> - / / If the float is not encoded as a hex - float then it will be parsed <nl> - / / as a regular float . <nl> - / / This may fail if your stream does not support at least one unget . <nl> - / / Nan values can be encoded with " 0x1 . < not zero > p + exponent_bias " . <nl> - / / This would normally overflow a float and round to <nl> - / / infinity but this special pattern is the exact representation for a NaN , <nl> - / / and therefore is actually encoded as the correct NaN . To encode inf , <nl> - / / either 0x0p + exponent_bias can be specified or any exponent greater than <nl> - / / exponent_bias . <nl> - / / Examples using IEEE 32 - bit float encoding . <nl> - / / 0x1 . 0p + 128 ( + inf ) <nl> - / / - 0x1 . 0p - 128 ( - inf ) <nl> - / / <nl> - / / 0x1 . 1p + 128 ( + Nan ) <nl> - / / - 0x1 . 1p + 128 ( - Nan ) <nl> - / / <nl> - / / 0x1p + 129 ( + inf ) <nl> - / / - 0x1p + 129 ( - inf ) <nl> - template < typename T , typename Traits > <nl> - std : : istream & operator > > ( std : : istream & is , HexFloat < T , Traits > & value ) { <nl> - using HF = HexFloat < T , Traits > ; <nl> - using uint_type = typename HF : : uint_type ; <nl> - using int_type = typename HF : : int_type ; <nl> - <nl> - value . set_value ( static_cast < typename HF : : native_type > ( 0 . f ) ) ; <nl> - <nl> - if ( is . flags ( ) & std : : ios : : skipws ) { <nl> - / / If the user wants to skip whitespace , then we should obey that . <nl> - while ( std : : isspace ( is . peek ( ) ) ) { <nl> - is . get ( ) ; <nl> - } <nl> - } <nl> - <nl> - auto next_char = is . peek ( ) ; <nl> - bool negate_value = false ; <nl> - <nl> - if ( next_char ! = ' - ' & & next_char ! = ' 0 ' ) { <nl> - return ParseNormalFloat ( is , negate_value , value ) ; <nl> - } <nl> - <nl> - if ( next_char = = ' - ' ) { <nl> - negate_value = true ; <nl> - is . get ( ) ; <nl> - next_char = is . peek ( ) ; <nl> - } <nl> - <nl> - if ( next_char = = ' 0 ' ) { <nl> - is . get ( ) ; / / We may have to unget this . <nl> - auto maybe_hex_start = is . peek ( ) ; <nl> - if ( maybe_hex_start ! = ' x ' & & maybe_hex_start ! = ' X ' ) { <nl> - is . unget ( ) ; <nl> - return ParseNormalFloat ( is , negate_value , value ) ; <nl> - } else { <nl> - is . get ( ) ; / / Throw away the ' x ' ; <nl> - } <nl> - } else { <nl> - return ParseNormalFloat ( is , negate_value , value ) ; <nl> - } <nl> - <nl> - / / This " looks " like a hex - float so treat it as one . <nl> - bool seen_p = false ; <nl> - bool seen_dot = false ; <nl> - uint_type fraction_index = 0 ; <nl> - <nl> - uint_type fraction = 0 ; <nl> - int_type exponent = HF : : exponent_bias ; <nl> - <nl> - / / Strip off leading zeros so we don ' t have to special - case them later . <nl> - while ( ( next_char = is . peek ( ) ) = = ' 0 ' ) { <nl> - is . get ( ) ; <nl> - } <nl> - <nl> - bool is_denorm = <nl> - true ; / / Assume denorm " representation " until we hear otherwise . <nl> - / / NB : This does not mean the value is actually denorm , <nl> - / / it just means that it was written 0 . <nl> - bool bits_written = false ; / / Stays false until we write a bit . <nl> - while ( ! seen_p & & ! seen_dot ) { <nl> - / / Handle characters that are left of the fractional part . <nl> - if ( next_char = = ' . ' ) { <nl> - seen_dot = true ; <nl> - } else if ( next_char = = ' p ' ) { <nl> - seen_p = true ; <nl> - } else if ( : : isxdigit ( next_char ) ) { <nl> - / / We know this is not denormalized since we have stripped all leading <nl> - / / zeroes and we are not a " . " . <nl> - is_denorm = false ; <nl> - int number = get_nibble_from_character ( next_char ) ; <nl> - for ( int i = 0 ; i < 4 ; + + i , number < < = 1 ) { <nl> - uint_type write_bit = ( number & 0x8 ) ? 0x1 : 0x0 ; <nl> - if ( bits_written ) { <nl> - / / If we are here the bits represented belong in the fractional <nl> - / / part of the float , and we have to adjust the exponent accordingly . <nl> - fraction = static_cast < uint_type > ( <nl> - fraction | <nl> - static_cast < uint_type > ( <nl> - write_bit < < ( HF : : top_bit_left_shift - fraction_index + + ) ) ) ; <nl> - exponent = static_cast < int_type > ( exponent + 1 ) ; <nl> - } <nl> - bits_written | = write_bit ! = 0 ; <nl> - } <nl> - } else { <nl> - / / We have not found our exponent yet , so we have to fail . <nl> - is . setstate ( std : : ios : : failbit ) ; <nl> - return is ; <nl> - } <nl> - is . get ( ) ; <nl> - next_char = is . peek ( ) ; <nl> - } <nl> - bits_written = false ; <nl> - while ( seen_dot & & ! seen_p ) { <nl> - / / Handle only fractional parts now . <nl> - if ( next_char = = ' p ' ) { <nl> - seen_p = true ; <nl> - } else if ( : : isxdigit ( next_char ) ) { <nl> - int number = get_nibble_from_character ( next_char ) ; <nl> - for ( int i = 0 ; i < 4 ; + + i , number < < = 1 ) { <nl> - uint_type write_bit = ( number & 0x8 ) ? 0x01 : 0x00 ; <nl> - bits_written | = write_bit ! = 0 ; <nl> - if ( is_denorm & & ! bits_written ) { <nl> - / / Handle modifying the exponent here this way we can handle <nl> - / / an arbitrary number of hex values without overflowing our <nl> - / / integer . <nl> - exponent = static_cast < int_type > ( exponent - 1 ) ; <nl> - } else { <nl> - fraction = static_cast < uint_type > ( <nl> - fraction | <nl> - static_cast < uint_type > ( <nl> - write_bit < < ( HF : : top_bit_left_shift - fraction_index + + ) ) ) ; <nl> - } <nl> - } <nl> - } else { <nl> - / / We still have not found our ' p ' exponent yet , so this is not a valid <nl> - / / hex - float . <nl> - is . setstate ( std : : ios : : failbit ) ; <nl> - return is ; <nl> - } <nl> - is . get ( ) ; <nl> - next_char = is . peek ( ) ; <nl> - } <nl> - <nl> - bool seen_sign = false ; <nl> - int8_t exponent_sign = 1 ; <nl> - int_type written_exponent = 0 ; <nl> - while ( true ) { <nl> - if ( ( next_char = = ' - ' | | next_char = = ' + ' ) ) { <nl> - if ( seen_sign ) { <nl> - is . setstate ( std : : ios : : failbit ) ; <nl> - return is ; <nl> - } <nl> - seen_sign = true ; <nl> - exponent_sign = ( next_char = = ' - ' ) ? - 1 : 1 ; <nl> - } else if ( : : isdigit ( next_char ) ) { <nl> - / / Hex - floats express their exponent as decimal . <nl> - written_exponent = static_cast < int_type > ( written_exponent * 10 ) ; <nl> - written_exponent = <nl> - static_cast < int_type > ( written_exponent + ( next_char - ' 0 ' ) ) ; <nl> - } else { <nl> - break ; <nl> - } <nl> - is . get ( ) ; <nl> - next_char = is . peek ( ) ; <nl> - } <nl> - <nl> - written_exponent = static_cast < int_type > ( written_exponent * exponent_sign ) ; <nl> - exponent = static_cast < int_type > ( exponent + written_exponent ) ; <nl> - <nl> - bool is_zero = is_denorm & & ( fraction = = 0 ) ; <nl> - if ( is_denorm & & ! is_zero ) { <nl> - fraction = static_cast < uint_type > ( fraction < < 1 ) ; <nl> - exponent = static_cast < int_type > ( exponent - 1 ) ; <nl> - } else if ( is_zero ) { <nl> - exponent = 0 ; <nl> - } <nl> - <nl> - if ( exponent < = 0 & & ! is_zero ) { <nl> - fraction = static_cast < uint_type > ( fraction > > 1 ) ; <nl> - fraction | = static_cast < uint_type > ( 1 ) < < HF : : top_bit_left_shift ; <nl> - } <nl> - <nl> - fraction = ( fraction > > HF : : fraction_right_shift ) & HF : : fraction_encode_mask ; <nl> - <nl> - const int_type max_exponent = <nl> - SetBits < uint_type , 0 , HF : : num_exponent_bits > : : get ; <nl> - <nl> - / / Handle actual denorm numbers <nl> - while ( exponent < 0 & & ! is_zero ) { <nl> - fraction = static_cast < uint_type > ( fraction > > 1 ) ; <nl> - exponent = static_cast < int_type > ( exponent + 1 ) ; <nl> - <nl> - fraction & = HF : : fraction_encode_mask ; <nl> - if ( fraction = = 0 ) { <nl> - / / We have underflowed our fraction . We should clamp to zero . <nl> - is_zero = true ; <nl> - exponent = 0 ; <nl> - } <nl> - } <nl> - <nl> - / / We have overflowed so we should be inf / - inf . <nl> - if ( exponent > max_exponent ) { <nl> - exponent = max_exponent ; <nl> - fraction = 0 ; <nl> - } <nl> - <nl> - uint_type output_bits = static_cast < uint_type > ( <nl> - static_cast < uint_type > ( negate_value ? 1 : 0 ) < < HF : : top_bit_left_shift ) ; <nl> - output_bits | = fraction ; <nl> - <nl> - uint_type shifted_exponent = static_cast < uint_type > ( <nl> - static_cast < uint_type > ( exponent < < HF : : exponent_left_shift ) & <nl> - HF : : exponent_mask ) ; <nl> - output_bits | = shifted_exponent ; <nl> - <nl> - T output_float = spvutils : : BitwiseCast < T > ( output_bits ) ; <nl> - value . set_value ( output_float ) ; <nl> - <nl> - return is ; <nl> - } <nl> - <nl> - / / Writes a FloatProxy value to a stream . <nl> - / / Zero and normal numbers are printed in the usual notation , but with <nl> - / / enough digits to fully reproduce the value . Other values ( subnormal , <nl> - / / NaN , and infinity ) are printed as a hex float . <nl> - template < typename T > <nl> - std : : ostream & operator < < ( std : : ostream & os , const FloatProxy < T > & value ) { <nl> - auto float_val = value . getAsFloat ( ) ; <nl> - switch ( std : : fpclassify ( float_val ) ) { <nl> - case FP_ZERO : <nl> - case FP_NORMAL : { <nl> - auto saved_precision = os . precision ( ) ; <nl> - os . precision ( std : : numeric_limits < T > : : digits10 ) ; <nl> - os < < float_val ; <nl> - os . precision ( saved_precision ) ; <nl> - } break ; <nl> - default : <nl> - os < < HexFloat < FloatProxy < T > > ( value ) ; <nl> - break ; <nl> - } <nl> - return os ; <nl> - } <nl> - <nl> - template < > <nl> - inline std : : ostream & operator < < < Float16 > ( std : : ostream & os , <nl> - const FloatProxy < Float16 > & value ) { <nl> - os < < HexFloat < FloatProxy < Float16 > > ( value ) ; <nl> - return os ; <nl> - } <nl> - } <nl> - <nl> - # endif / / LIBSPIRV_UTIL_HEX_FLOAT_H_ <nl> deleted file mode 100644 <nl> index c6776638 . . 00000000 <nl> mmm a / glslang / include / SPIRV / spirv . hpp <nl> ppp / dev / null <nl> <nl> - / / Copyright ( c ) 2014 - 2018 The Khronos Group Inc . <nl> - / / <nl> - / / Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - / / of this software and / or associated documentation files ( the " Materials " ) , <nl> - / / to deal in the Materials without restriction , including without limitation <nl> - / / the rights to use , copy , modify , merge , publish , distribute , sublicense , <nl> - / / and / or sell copies of the Materials , and to permit persons to whom the <nl> - / / Materials are furnished to do so , subject to the following conditions : <nl> - / / <nl> - / / The above copyright notice and this permission notice shall be included in <nl> - / / all copies or substantial portions of the Materials . <nl> - / / <nl> - / / MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS <nl> - / / STANDARDS . THE UNMODIFIED , NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND <nl> - / / HEADER INFORMATION ARE LOCATED AT https : / / www . khronos . org / registry / <nl> - / / <nl> - / / THE MATERIALS ARE PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS <nl> - / / OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - / / FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL <nl> - / / THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - / / LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING <nl> - / / FROM , OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS <nl> - / / IN THE MATERIALS . <nl> - <nl> - / / This header is automatically generated by the same tool that creates <nl> - / / the Binary Section of the SPIR - V specification . <nl> - <nl> - / / Enumeration tokens for SPIR - V , in various styles : <nl> - / / C , C + + , C + + 11 , JSON , Lua , Python <nl> - / / <nl> - / / - C will have tokens with a " Spv " prefix , e . g . : SpvSourceLanguageGLSL <nl> - / / - C + + will have tokens in the " spv " name space , e . g . : spv : : SourceLanguageGLSL <nl> - / / - C + + 11 will use enum classes in the spv namespace , e . g . : spv : : SourceLanguage : : GLSL <nl> - / / - Lua will use tables , e . g . : spv . SourceLanguage . GLSL <nl> - / / - Python will use dictionaries , e . g . : spv [ ' SourceLanguage ' ] [ ' GLSL ' ] <nl> - / / <nl> - / / Some tokens act like mask values , which can be OR ' d together , <nl> - / / while others are mutually exclusive . The mask - like ones have <nl> - / / " Mask " in their name , and a parallel enum that has the shift <nl> - / / amount ( 1 < < x ) for each corresponding enumerant . <nl> - <nl> - # ifndef spirv_HPP <nl> - # define spirv_HPP <nl> - <nl> - namespace spv { <nl> - <nl> - typedef unsigned int Id ; <nl> - <nl> - # define SPV_VERSION 0x10200 <nl> - # define SPV_REVISION 3 <nl> - <nl> - static const unsigned int MagicNumber = 0x07230203 ; <nl> - static const unsigned int Version = 0x00010200 ; <nl> - static const unsigned int Revision = 3 ; <nl> - static const unsigned int OpCodeMask = 0xffff ; <nl> - static const unsigned int WordCountShift = 16 ; <nl> - <nl> - enum SourceLanguage { <nl> - SourceLanguageUnknown = 0 , <nl> - SourceLanguageESSL = 1 , <nl> - SourceLanguageGLSL = 2 , <nl> - SourceLanguageOpenCL_C = 3 , <nl> - SourceLanguageOpenCL_CPP = 4 , <nl> - SourceLanguageHLSL = 5 , <nl> - SourceLanguageMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum ExecutionModel { <nl> - ExecutionModelVertex = 0 , <nl> - ExecutionModelTessellationControl = 1 , <nl> - ExecutionModelTessellationEvaluation = 2 , <nl> - ExecutionModelGeometry = 3 , <nl> - ExecutionModelFragment = 4 , <nl> - ExecutionModelGLCompute = 5 , <nl> - ExecutionModelKernel = 6 , <nl> - ExecutionModelMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum AddressingModel { <nl> - AddressingModelLogical = 0 , <nl> - AddressingModelPhysical32 = 1 , <nl> - AddressingModelPhysical64 = 2 , <nl> - AddressingModelMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum MemoryModel { <nl> - MemoryModelSimple = 0 , <nl> - MemoryModelGLSL450 = 1 , <nl> - MemoryModelOpenCL = 2 , <nl> - MemoryModelMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum ExecutionMode { <nl> - ExecutionModeInvocations = 0 , <nl> - ExecutionModeSpacingEqual = 1 , <nl> - ExecutionModeSpacingFractionalEven = 2 , <nl> - ExecutionModeSpacingFractionalOdd = 3 , <nl> - ExecutionModeVertexOrderCw = 4 , <nl> - ExecutionModeVertexOrderCcw = 5 , <nl> - ExecutionModePixelCenterInteger = 6 , <nl> - ExecutionModeOriginUpperLeft = 7 , <nl> - ExecutionModeOriginLowerLeft = 8 , <nl> - ExecutionModeEarlyFragmentTests = 9 , <nl> - ExecutionModePointMode = 10 , <nl> - ExecutionModeXfb = 11 , <nl> - ExecutionModeDepthReplacing = 12 , <nl> - ExecutionModeDepthGreater = 14 , <nl> - ExecutionModeDepthLess = 15 , <nl> - ExecutionModeDepthUnchanged = 16 , <nl> - ExecutionModeLocalSize = 17 , <nl> - ExecutionModeLocalSizeHint = 18 , <nl> - ExecutionModeInputPoints = 19 , <nl> - ExecutionModeInputLines = 20 , <nl> - ExecutionModeInputLinesAdjacency = 21 , <nl> - ExecutionModeTriangles = 22 , <nl> - ExecutionModeInputTrianglesAdjacency = 23 , <nl> - ExecutionModeQuads = 24 , <nl> - ExecutionModeIsolines = 25 , <nl> - ExecutionModeOutputVertices = 26 , <nl> - ExecutionModeOutputPoints = 27 , <nl> - ExecutionModeOutputLineStrip = 28 , <nl> - ExecutionModeOutputTriangleStrip = 29 , <nl> - ExecutionModeVecTypeHint = 30 , <nl> - ExecutionModeContractionOff = 31 , <nl> - ExecutionModeInitializer = 33 , <nl> - ExecutionModeFinalizer = 34 , <nl> - ExecutionModeSubgroupSize = 35 , <nl> - ExecutionModeSubgroupsPerWorkgroup = 36 , <nl> - ExecutionModeSubgroupsPerWorkgroupId = 37 , <nl> - ExecutionModeLocalSizeId = 38 , <nl> - ExecutionModeLocalSizeHintId = 39 , <nl> - ExecutionModePostDepthCoverage = 4446 , <nl> - ExecutionModeStencilRefReplacingEXT = 5027 , <nl> - ExecutionModeMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum StorageClass { <nl> - StorageClassUniformConstant = 0 , <nl> - StorageClassInput = 1 , <nl> - StorageClassUniform = 2 , <nl> - StorageClassOutput = 3 , <nl> - StorageClassWorkgroup = 4 , <nl> - StorageClassCrossWorkgroup = 5 , <nl> - StorageClassPrivate = 6 , <nl> - StorageClassFunction = 7 , <nl> - StorageClassGeneric = 8 , <nl> - StorageClassPushConstant = 9 , <nl> - StorageClassAtomicCounter = 10 , <nl> - StorageClassImage = 11 , <nl> - StorageClassStorageBuffer = 12 , <nl> - StorageClassMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum Dim { <nl> - Dim1D = 0 , <nl> - Dim2D = 1 , <nl> - Dim3D = 2 , <nl> - DimCube = 3 , <nl> - DimRect = 4 , <nl> - DimBuffer = 5 , <nl> - DimSubpassData = 6 , <nl> - DimMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum SamplerAddressingMode { <nl> - SamplerAddressingModeNone = 0 , <nl> - SamplerAddressingModeClampToEdge = 1 , <nl> - SamplerAddressingModeClamp = 2 , <nl> - SamplerAddressingModeRepeat = 3 , <nl> - SamplerAddressingModeRepeatMirrored = 4 , <nl> - SamplerAddressingModeMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum SamplerFilterMode { <nl> - SamplerFilterModeNearest = 0 , <nl> - SamplerFilterModeLinear = 1 , <nl> - SamplerFilterModeMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum ImageFormat { <nl> - ImageFormatUnknown = 0 , <nl> - ImageFormatRgba32f = 1 , <nl> - ImageFormatRgba16f = 2 , <nl> - ImageFormatR32f = 3 , <nl> - ImageFormatRgba8 = 4 , <nl> - ImageFormatRgba8Snorm = 5 , <nl> - ImageFormatRg32f = 6 , <nl> - ImageFormatRg16f = 7 , <nl> - ImageFormatR11fG11fB10f = 8 , <nl> - ImageFormatR16f = 9 , <nl> - ImageFormatRgba16 = 10 , <nl> - ImageFormatRgb10A2 = 11 , <nl> - ImageFormatRg16 = 12 , <nl> - ImageFormatRg8 = 13 , <nl> - ImageFormatR16 = 14 , <nl> - ImageFormatR8 = 15 , <nl> - ImageFormatRgba16Snorm = 16 , <nl> - ImageFormatRg16Snorm = 17 , <nl> - ImageFormatRg8Snorm = 18 , <nl> - ImageFormatR16Snorm = 19 , <nl> - ImageFormatR8Snorm = 20 , <nl> - ImageFormatRgba32i = 21 , <nl> - ImageFormatRgba16i = 22 , <nl> - ImageFormatRgba8i = 23 , <nl> - ImageFormatR32i = 24 , <nl> - ImageFormatRg32i = 25 , <nl> - ImageFormatRg16i = 26 , <nl> - ImageFormatRg8i = 27 , <nl> - ImageFormatR16i = 28 , <nl> - ImageFormatR8i = 29 , <nl> - ImageFormatRgba32ui = 30 , <nl> - ImageFormatRgba16ui = 31 , <nl> - ImageFormatRgba8ui = 32 , <nl> - ImageFormatR32ui = 33 , <nl> - ImageFormatRgb10a2ui = 34 , <nl> - ImageFormatRg32ui = 35 , <nl> - ImageFormatRg16ui = 36 , <nl> - ImageFormatRg8ui = 37 , <nl> - ImageFormatR16ui = 38 , <nl> - ImageFormatR8ui = 39 , <nl> - ImageFormatMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum ImageChannelOrder { <nl> - ImageChannelOrderR = 0 , <nl> - ImageChannelOrderA = 1 , <nl> - ImageChannelOrderRG = 2 , <nl> - ImageChannelOrderRA = 3 , <nl> - ImageChannelOrderRGB = 4 , <nl> - ImageChannelOrderRGBA = 5 , <nl> - ImageChannelOrderBGRA = 6 , <nl> - ImageChannelOrderARGB = 7 , <nl> - ImageChannelOrderIntensity = 8 , <nl> - ImageChannelOrderLuminance = 9 , <nl> - ImageChannelOrderRx = 10 , <nl> - ImageChannelOrderRGx = 11 , <nl> - ImageChannelOrderRGBx = 12 , <nl> - ImageChannelOrderDepth = 13 , <nl> - ImageChannelOrderDepthStencil = 14 , <nl> - ImageChannelOrdersRGB = 15 , <nl> - ImageChannelOrdersRGBx = 16 , <nl> - ImageChannelOrdersRGBA = 17 , <nl> - ImageChannelOrdersBGRA = 18 , <nl> - ImageChannelOrderABGR = 19 , <nl> - ImageChannelOrderMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum ImageChannelDataType { <nl> - ImageChannelDataTypeSnormInt8 = 0 , <nl> - ImageChannelDataTypeSnormInt16 = 1 , <nl> - ImageChannelDataTypeUnormInt8 = 2 , <nl> - ImageChannelDataTypeUnormInt16 = 3 , <nl> - ImageChannelDataTypeUnormShort565 = 4 , <nl> - ImageChannelDataTypeUnormShort555 = 5 , <nl> - ImageChannelDataTypeUnormInt101010 = 6 , <nl> - ImageChannelDataTypeSignedInt8 = 7 , <nl> - ImageChannelDataTypeSignedInt16 = 8 , <nl> - ImageChannelDataTypeSignedInt32 = 9 , <nl> - ImageChannelDataTypeUnsignedInt8 = 10 , <nl> - ImageChannelDataTypeUnsignedInt16 = 11 , <nl> - ImageChannelDataTypeUnsignedInt32 = 12 , <nl> - ImageChannelDataTypeHalfFloat = 13 , <nl> - ImageChannelDataTypeFloat = 14 , <nl> - ImageChannelDataTypeUnormInt24 = 15 , <nl> - ImageChannelDataTypeUnormInt101010_2 = 16 , <nl> - ImageChannelDataTypeMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum ImageOperandsShift { <nl> - ImageOperandsBiasShift = 0 , <nl> - ImageOperandsLodShift = 1 , <nl> - ImageOperandsGradShift = 2 , <nl> - ImageOperandsConstOffsetShift = 3 , <nl> - ImageOperandsOffsetShift = 4 , <nl> - ImageOperandsConstOffsetsShift = 5 , <nl> - ImageOperandsSampleShift = 6 , <nl> - ImageOperandsMinLodShift = 7 , <nl> - ImageOperandsMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum ImageOperandsMask { <nl> - ImageOperandsMaskNone = 0 , <nl> - ImageOperandsBiasMask = 0x00000001 , <nl> - ImageOperandsLodMask = 0x00000002 , <nl> - ImageOperandsGradMask = 0x00000004 , <nl> - ImageOperandsConstOffsetMask = 0x00000008 , <nl> - ImageOperandsOffsetMask = 0x00000010 , <nl> - ImageOperandsConstOffsetsMask = 0x00000020 , <nl> - ImageOperandsSampleMask = 0x00000040 , <nl> - ImageOperandsMinLodMask = 0x00000080 , <nl> - } ; <nl> - <nl> - enum FPFastMathModeShift { <nl> - FPFastMathModeNotNaNShift = 0 , <nl> - FPFastMathModeNotInfShift = 1 , <nl> - FPFastMathModeNSZShift = 2 , <nl> - FPFastMathModeAllowRecipShift = 3 , <nl> - FPFastMathModeFastShift = 4 , <nl> - FPFastMathModeMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum FPFastMathModeMask { <nl> - FPFastMathModeMaskNone = 0 , <nl> - FPFastMathModeNotNaNMask = 0x00000001 , <nl> - FPFastMathModeNotInfMask = 0x00000002 , <nl> - FPFastMathModeNSZMask = 0x00000004 , <nl> - FPFastMathModeAllowRecipMask = 0x00000008 , <nl> - FPFastMathModeFastMask = 0x00000010 , <nl> - } ; <nl> - <nl> - enum FPRoundingMode { <nl> - FPRoundingModeRTE = 0 , <nl> - FPRoundingModeRTZ = 1 , <nl> - FPRoundingModeRTP = 2 , <nl> - FPRoundingModeRTN = 3 , <nl> - FPRoundingModeMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum LinkageType { <nl> - LinkageTypeExport = 0 , <nl> - LinkageTypeImport = 1 , <nl> - LinkageTypeMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum AccessQualifier { <nl> - AccessQualifierReadOnly = 0 , <nl> - AccessQualifierWriteOnly = 1 , <nl> - AccessQualifierReadWrite = 2 , <nl> - AccessQualifierMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum FunctionParameterAttribute { <nl> - FunctionParameterAttributeZext = 0 , <nl> - FunctionParameterAttributeSext = 1 , <nl> - FunctionParameterAttributeByVal = 2 , <nl> - FunctionParameterAttributeSret = 3 , <nl> - FunctionParameterAttributeNoAlias = 4 , <nl> - FunctionParameterAttributeNoCapture = 5 , <nl> - FunctionParameterAttributeNoWrite = 6 , <nl> - FunctionParameterAttributeNoReadWrite = 7 , <nl> - FunctionParameterAttributeMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum Decoration { <nl> - DecorationRelaxedPrecision = 0 , <nl> - DecorationSpecId = 1 , <nl> - DecorationBlock = 2 , <nl> - DecorationBufferBlock = 3 , <nl> - DecorationRowMajor = 4 , <nl> - DecorationColMajor = 5 , <nl> - DecorationArrayStride = 6 , <nl> - DecorationMatrixStride = 7 , <nl> - DecorationGLSLShared = 8 , <nl> - DecorationGLSLPacked = 9 , <nl> - DecorationCPacked = 10 , <nl> - DecorationBuiltIn = 11 , <nl> - DecorationNoPerspective = 13 , <nl> - DecorationFlat = 14 , <nl> - DecorationPatch = 15 , <nl> - DecorationCentroid = 16 , <nl> - DecorationSample = 17 , <nl> - DecorationInvariant = 18 , <nl> - DecorationRestrict = 19 , <nl> - DecorationAliased = 20 , <nl> - DecorationVolatile = 21 , <nl> - DecorationConstant = 22 , <nl> - DecorationCoherent = 23 , <nl> - DecorationNonWritable = 24 , <nl> - DecorationNonReadable = 25 , <nl> - DecorationUniform = 26 , <nl> - DecorationSaturatedConversion = 28 , <nl> - DecorationStream = 29 , <nl> - DecorationLocation = 30 , <nl> - DecorationComponent = 31 , <nl> - DecorationIndex = 32 , <nl> - DecorationBinding = 33 , <nl> - DecorationDescriptorSet = 34 , <nl> - DecorationOffset = 35 , <nl> - DecorationXfbBuffer = 36 , <nl> - DecorationXfbStride = 37 , <nl> - DecorationFuncParamAttr = 38 , <nl> - DecorationFPRoundingMode = 39 , <nl> - DecorationFPFastMathMode = 40 , <nl> - DecorationLinkageAttributes = 41 , <nl> - DecorationNoContraction = 42 , <nl> - DecorationInputAttachmentIndex = 43 , <nl> - DecorationAlignment = 44 , <nl> - DecorationMaxByteOffset = 45 , <nl> - DecorationAlignmentId = 46 , <nl> - DecorationMaxByteOffsetId = 47 , <nl> - DecorationExplicitInterpAMD = 4999 , <nl> - DecorationOverrideCoverageNV = 5248 , <nl> - DecorationPassthroughNV = 5250 , <nl> - DecorationViewportRelativeNV = 5252 , <nl> - DecorationSecondaryViewportRelativeNV = 5256 , <nl> - DecorationMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum BuiltIn { <nl> - BuiltInPosition = 0 , <nl> - BuiltInPointSize = 1 , <nl> - BuiltInClipDistance = 3 , <nl> - BuiltInCullDistance = 4 , <nl> - BuiltInVertexId = 5 , <nl> - BuiltInInstanceId = 6 , <nl> - BuiltInPrimitiveId = 7 , <nl> - BuiltInInvocationId = 8 , <nl> - BuiltInLayer = 9 , <nl> - BuiltInViewportIndex = 10 , <nl> - BuiltInTessLevelOuter = 11 , <nl> - BuiltInTessLevelInner = 12 , <nl> - BuiltInTessCoord = 13 , <nl> - BuiltInPatchVertices = 14 , <nl> - BuiltInFragCoord = 15 , <nl> - BuiltInPointCoord = 16 , <nl> - BuiltInFrontFacing = 17 , <nl> - BuiltInSampleId = 18 , <nl> - BuiltInSamplePosition = 19 , <nl> - BuiltInSampleMask = 20 , <nl> - BuiltInFragDepth = 22 , <nl> - BuiltInHelperInvocation = 23 , <nl> - BuiltInNumWorkgroups = 24 , <nl> - BuiltInWorkgroupSize = 25 , <nl> - BuiltInWorkgroupId = 26 , <nl> - BuiltInLocalInvocationId = 27 , <nl> - BuiltInGlobalInvocationId = 28 , <nl> - BuiltInLocalInvocationIndex = 29 , <nl> - BuiltInWorkDim = 30 , <nl> - BuiltInGlobalSize = 31 , <nl> - BuiltInEnqueuedWorkgroupSize = 32 , <nl> - BuiltInGlobalOffset = 33 , <nl> - BuiltInGlobalLinearId = 34 , <nl> - BuiltInSubgroupSize = 36 , <nl> - BuiltInSubgroupMaxSize = 37 , <nl> - BuiltInNumSubgroups = 38 , <nl> - BuiltInNumEnqueuedSubgroups = 39 , <nl> - BuiltInSubgroupId = 40 , <nl> - BuiltInSubgroupLocalInvocationId = 41 , <nl> - BuiltInVertexIndex = 42 , <nl> - BuiltInInstanceIndex = 43 , <nl> - BuiltInSubgroupEqMaskKHR = 4416 , <nl> - BuiltInSubgroupGeMaskKHR = 4417 , <nl> - BuiltInSubgroupGtMaskKHR = 4418 , <nl> - BuiltInSubgroupLeMaskKHR = 4419 , <nl> - BuiltInSubgroupLtMaskKHR = 4420 , <nl> - BuiltInBaseVertex = 4424 , <nl> - BuiltInBaseInstance = 4425 , <nl> - BuiltInDrawIndex = 4426 , <nl> - BuiltInDeviceIndex = 4438 , <nl> - BuiltInViewIndex = 4440 , <nl> - BuiltInBaryCoordNoPerspAMD = 4992 , <nl> - BuiltInBaryCoordNoPerspCentroidAMD = 4993 , <nl> - BuiltInBaryCoordNoPerspSampleAMD = 4994 , <nl> - BuiltInBaryCoordSmoothAMD = 4995 , <nl> - BuiltInBaryCoordSmoothCentroidAMD = 4996 , <nl> - BuiltInBaryCoordSmoothSampleAMD = 4997 , <nl> - BuiltInBaryCoordPullModelAMD = 4998 , <nl> - BuiltInFragStencilRefEXT = 5014 , <nl> - BuiltInViewportMaskNV = 5253 , <nl> - BuiltInSecondaryPositionNV = 5257 , <nl> - BuiltInSecondaryViewportMaskNV = 5258 , <nl> - BuiltInPositionPerViewNV = 5261 , <nl> - BuiltInViewportMaskPerViewNV = 5262 , <nl> - BuiltInFullyCoveredEXT = 5264 , <nl> - BuiltInMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum SelectionControlShift { <nl> - SelectionControlFlattenShift = 0 , <nl> - SelectionControlDontFlattenShift = 1 , <nl> - SelectionControlMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum SelectionControlMask { <nl> - SelectionControlMaskNone = 0 , <nl> - SelectionControlFlattenMask = 0x00000001 , <nl> - SelectionControlDontFlattenMask = 0x00000002 , <nl> - } ; <nl> - <nl> - enum LoopControlShift { <nl> - LoopControlUnrollShift = 0 , <nl> - LoopControlDontUnrollShift = 1 , <nl> - LoopControlDependencyInfiniteShift = 2 , <nl> - LoopControlDependencyLengthShift = 3 , <nl> - LoopControlMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum LoopControlMask { <nl> - LoopControlMaskNone = 0 , <nl> - LoopControlUnrollMask = 0x00000001 , <nl> - LoopControlDontUnrollMask = 0x00000002 , <nl> - LoopControlDependencyInfiniteMask = 0x00000004 , <nl> - LoopControlDependencyLengthMask = 0x00000008 , <nl> - } ; <nl> - <nl> - enum FunctionControlShift { <nl> - FunctionControlInlineShift = 0 , <nl> - FunctionControlDontInlineShift = 1 , <nl> - FunctionControlPureShift = 2 , <nl> - FunctionControlConstShift = 3 , <nl> - FunctionControlMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum FunctionControlMask { <nl> - FunctionControlMaskNone = 0 , <nl> - FunctionControlInlineMask = 0x00000001 , <nl> - FunctionControlDontInlineMask = 0x00000002 , <nl> - FunctionControlPureMask = 0x00000004 , <nl> - FunctionControlConstMask = 0x00000008 , <nl> - } ; <nl> - <nl> - enum MemorySemanticsShift { <nl> - MemorySemanticsAcquireShift = 1 , <nl> - MemorySemanticsReleaseShift = 2 , <nl> - MemorySemanticsAcquireReleaseShift = 3 , <nl> - MemorySemanticsSequentiallyConsistentShift = 4 , <nl> - MemorySemanticsUniformMemoryShift = 6 , <nl> - MemorySemanticsSubgroupMemoryShift = 7 , <nl> - MemorySemanticsWorkgroupMemoryShift = 8 , <nl> - MemorySemanticsCrossWorkgroupMemoryShift = 9 , <nl> - MemorySemanticsAtomicCounterMemoryShift = 10 , <nl> - MemorySemanticsImageMemoryShift = 11 , <nl> - MemorySemanticsMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum MemorySemanticsMask { <nl> - MemorySemanticsMaskNone = 0 , <nl> - MemorySemanticsAcquireMask = 0x00000002 , <nl> - MemorySemanticsReleaseMask = 0x00000004 , <nl> - MemorySemanticsAcquireReleaseMask = 0x00000008 , <nl> - MemorySemanticsSequentiallyConsistentMask = 0x00000010 , <nl> - MemorySemanticsUniformMemoryMask = 0x00000040 , <nl> - MemorySemanticsSubgroupMemoryMask = 0x00000080 , <nl> - MemorySemanticsWorkgroupMemoryMask = 0x00000100 , <nl> - MemorySemanticsCrossWorkgroupMemoryMask = 0x00000200 , <nl> - MemorySemanticsAtomicCounterMemoryMask = 0x00000400 , <nl> - MemorySemanticsImageMemoryMask = 0x00000800 , <nl> - } ; <nl> - <nl> - enum MemoryAccessShift { <nl> - MemoryAccessVolatileShift = 0 , <nl> - MemoryAccessAlignedShift = 1 , <nl> - MemoryAccessNontemporalShift = 2 , <nl> - MemoryAccessMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum MemoryAccessMask { <nl> - MemoryAccessMaskNone = 0 , <nl> - MemoryAccessVolatileMask = 0x00000001 , <nl> - MemoryAccessAlignedMask = 0x00000002 , <nl> - MemoryAccessNontemporalMask = 0x00000004 , <nl> - } ; <nl> - <nl> - enum Scope { <nl> - ScopeCrossDevice = 0 , <nl> - ScopeDevice = 1 , <nl> - ScopeWorkgroup = 2 , <nl> - ScopeSubgroup = 3 , <nl> - ScopeInvocation = 4 , <nl> - ScopeMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum GroupOperation { <nl> - GroupOperationReduce = 0 , <nl> - GroupOperationInclusiveScan = 1 , <nl> - GroupOperationExclusiveScan = 2 , <nl> - GroupOperationMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum KernelEnqueueFlags { <nl> - KernelEnqueueFlagsNoWait = 0 , <nl> - KernelEnqueueFlagsWaitKernel = 1 , <nl> - KernelEnqueueFlagsWaitWorkGroup = 2 , <nl> - KernelEnqueueFlagsMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum KernelProfilingInfoShift { <nl> - KernelProfilingInfoCmdExecTimeShift = 0 , <nl> - KernelProfilingInfoMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum KernelProfilingInfoMask { <nl> - KernelProfilingInfoMaskNone = 0 , <nl> - KernelProfilingInfoCmdExecTimeMask = 0x00000001 , <nl> - } ; <nl> - <nl> - enum Capability { <nl> - CapabilityMatrix = 0 , <nl> - CapabilityShader = 1 , <nl> - CapabilityGeometry = 2 , <nl> - CapabilityTessellation = 3 , <nl> - CapabilityAddresses = 4 , <nl> - CapabilityLinkage = 5 , <nl> - CapabilityKernel = 6 , <nl> - CapabilityVector16 = 7 , <nl> - CapabilityFloat16Buffer = 8 , <nl> - CapabilityFloat16 = 9 , <nl> - CapabilityFloat64 = 10 , <nl> - CapabilityInt64 = 11 , <nl> - CapabilityInt64Atomics = 12 , <nl> - CapabilityImageBasic = 13 , <nl> - CapabilityImageReadWrite = 14 , <nl> - CapabilityImageMipmap = 15 , <nl> - CapabilityPipes = 17 , <nl> - CapabilityGroups = 18 , <nl> - CapabilityDeviceEnqueue = 19 , <nl> - CapabilityLiteralSampler = 20 , <nl> - CapabilityAtomicStorage = 21 , <nl> - CapabilityInt16 = 22 , <nl> - CapabilityTessellationPointSize = 23 , <nl> - CapabilityGeometryPointSize = 24 , <nl> - CapabilityImageGatherExtended = 25 , <nl> - CapabilityStorageImageMultisample = 27 , <nl> - CapabilityUniformBufferArrayDynamicIndexing = 28 , <nl> - CapabilitySampledImageArrayDynamicIndexing = 29 , <nl> - CapabilityStorageBufferArrayDynamicIndexing = 30 , <nl> - CapabilityStorageImageArrayDynamicIndexing = 31 , <nl> - CapabilityClipDistance = 32 , <nl> - CapabilityCullDistance = 33 , <nl> - CapabilityImageCubeArray = 34 , <nl> - CapabilitySampleRateShading = 35 , <nl> - CapabilityImageRect = 36 , <nl> - CapabilitySampledRect = 37 , <nl> - CapabilityGenericPointer = 38 , <nl> - CapabilityInt8 = 39 , <nl> - CapabilityInputAttachment = 40 , <nl> - CapabilitySparseResidency = 41 , <nl> - CapabilityMinLod = 42 , <nl> - CapabilitySampled1D = 43 , <nl> - CapabilityImage1D = 44 , <nl> - CapabilitySampledCubeArray = 45 , <nl> - CapabilitySampledBuffer = 46 , <nl> - CapabilityImageBuffer = 47 , <nl> - CapabilityImageMSArray = 48 , <nl> - CapabilityStorageImageExtendedFormats = 49 , <nl> - CapabilityImageQuery = 50 , <nl> - CapabilityDerivativeControl = 51 , <nl> - CapabilityInterpolationFunction = 52 , <nl> - CapabilityTransformFeedback = 53 , <nl> - CapabilityGeometryStreams = 54 , <nl> - CapabilityStorageImageReadWithoutFormat = 55 , <nl> - CapabilityStorageImageWriteWithoutFormat = 56 , <nl> - CapabilityMultiViewport = 57 , <nl> - CapabilitySubgroupDispatch = 58 , <nl> - CapabilityNamedBarrier = 59 , <nl> - CapabilityPipeStorage = 60 , <nl> - CapabilitySubgroupBallotKHR = 4423 , <nl> - CapabilityDrawParameters = 4427 , <nl> - CapabilitySubgroupVoteKHR = 4431 , <nl> - CapabilityStorageBuffer16BitAccess = 4433 , <nl> - CapabilityStorageUniformBufferBlock16 = 4433 , <nl> - CapabilityStorageUniform16 = 4434 , <nl> - CapabilityUniformAndStorageBuffer16BitAccess = 4434 , <nl> - CapabilityStoragePushConstant16 = 4435 , <nl> - CapabilityStorageInputOutput16 = 4436 , <nl> - CapabilityDeviceGroup = 4437 , <nl> - CapabilityMultiView = 4439 , <nl> - CapabilityVariablePointersStorageBuffer = 4441 , <nl> - CapabilityVariablePointers = 4442 , <nl> - CapabilityAtomicStorageOps = 4445 , <nl> - CapabilitySampleMaskPostDepthCoverage = 4447 , <nl> - CapabilityImageGatherBiasLodAMD = 5009 , <nl> - CapabilityFragmentMaskAMD = 5010 , <nl> - CapabilityStencilExportEXT = 5013 , <nl> - CapabilityImageReadWriteLodAMD = 5015 , <nl> - CapabilitySampleMaskOverrideCoverageNV = 5249 , <nl> - CapabilityGeometryShaderPassthroughNV = 5251 , <nl> - CapabilityShaderViewportIndexLayerEXT = 5254 , <nl> - CapabilityShaderViewportIndexLayerNV = 5254 , <nl> - CapabilityShaderViewportMaskNV = 5255 , <nl> - CapabilityShaderStereoViewNV = 5259 , <nl> - CapabilityPerViewAttributesNV = 5260 , <nl> - CapabilityFragmentFullyCoveredEXT = 5265 , <nl> - CapabilitySubgroupShuffleINTEL = 5568 , <nl> - CapabilitySubgroupBufferBlockIOINTEL = 5569 , <nl> - CapabilitySubgroupImageBlockIOINTEL = 5570 , <nl> - CapabilityMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - enum Op { <nl> - OpNop = 0 , <nl> - OpUndef = 1 , <nl> - OpSourceContinued = 2 , <nl> - OpSource = 3 , <nl> - OpSourceExtension = 4 , <nl> - OpName = 5 , <nl> - OpMemberName = 6 , <nl> - OpString = 7 , <nl> - OpLine = 8 , <nl> - OpExtension = 10 , <nl> - OpExtInstImport = 11 , <nl> - OpExtInst = 12 , <nl> - OpMemoryModel = 14 , <nl> - OpEntryPoint = 15 , <nl> - OpExecutionMode = 16 , <nl> - OpCapability = 17 , <nl> - OpTypeVoid = 19 , <nl> - OpTypeBool = 20 , <nl> - OpTypeInt = 21 , <nl> - OpTypeFloat = 22 , <nl> - OpTypeVector = 23 , <nl> - OpTypeMatrix = 24 , <nl> - OpTypeImage = 25 , <nl> - OpTypeSampler = 26 , <nl> - OpTypeSampledImage = 27 , <nl> - OpTypeArray = 28 , <nl> - OpTypeRuntimeArray = 29 , <nl> - OpTypeStruct = 30 , <nl> - OpTypeOpaque = 31 , <nl> - OpTypePointer = 32 , <nl> - OpTypeFunction = 33 , <nl> - OpTypeEvent = 34 , <nl> - OpTypeDeviceEvent = 35 , <nl> - OpTypeReserveId = 36 , <nl> - OpTypeQueue = 37 , <nl> - OpTypePipe = 38 , <nl> - OpTypeForwardPointer = 39 , <nl> - OpConstantTrue = 41 , <nl> - OpConstantFalse = 42 , <nl> - OpConstant = 43 , <nl> - OpConstantComposite = 44 , <nl> - OpConstantSampler = 45 , <nl> - OpConstantNull = 46 , <nl> - OpSpecConstantTrue = 48 , <nl> - OpSpecConstantFalse = 49 , <nl> - OpSpecConstant = 50 , <nl> - OpSpecConstantComposite = 51 , <nl> - OpSpecConstantOp = 52 , <nl> - OpFunction = 54 , <nl> - OpFunctionParameter = 55 , <nl> - OpFunctionEnd = 56 , <nl> - OpFunctionCall = 57 , <nl> - OpVariable = 59 , <nl> - OpImageTexelPointer = 60 , <nl> - OpLoad = 61 , <nl> - OpStore = 62 , <nl> - OpCopyMemory = 63 , <nl> - OpCopyMemorySized = 64 , <nl> - OpAccessChain = 65 , <nl> - OpInBoundsAccessChain = 66 , <nl> - OpPtrAccessChain = 67 , <nl> - OpArrayLength = 68 , <nl> - OpGenericPtrMemSemantics = 69 , <nl> - OpInBoundsPtrAccessChain = 70 , <nl> - OpDecorate = 71 , <nl> - OpMemberDecorate = 72 , <nl> - OpDecorationGroup = 73 , <nl> - OpGroupDecorate = 74 , <nl> - OpGroupMemberDecorate = 75 , <nl> - OpVectorExtractDynamic = 77 , <nl> - OpVectorInsertDynamic = 78 , <nl> - OpVectorShuffle = 79 , <nl> - OpCompositeConstruct = 80 , <nl> - OpCompositeExtract = 81 , <nl> - OpCompositeInsert = 82 , <nl> - OpCopyObject = 83 , <nl> - OpTranspose = 84 , <nl> - OpSampledImage = 86 , <nl> - OpImageSampleImplicitLod = 87 , <nl> - OpImageSampleExplicitLod = 88 , <nl> - OpImageSampleDrefImplicitLod = 89 , <nl> - OpImageSampleDrefExplicitLod = 90 , <nl> - OpImageSampleProjImplicitLod = 91 , <nl> - OpImageSampleProjExplicitLod = 92 , <nl> - OpImageSampleProjDrefImplicitLod = 93 , <nl> - OpImageSampleProjDrefExplicitLod = 94 , <nl> - OpImageFetch = 95 , <nl> - OpImageGather = 96 , <nl> - OpImageDrefGather = 97 , <nl> - OpImageRead = 98 , <nl> - OpImageWrite = 99 , <nl> - OpImage = 100 , <nl> - OpImageQueryFormat = 101 , <nl> - OpImageQueryOrder = 102 , <nl> - OpImageQuerySizeLod = 103 , <nl> - OpImageQuerySize = 104 , <nl> - OpImageQueryLod = 105 , <nl> - OpImageQueryLevels = 106 , <nl> - OpImageQuerySamples = 107 , <nl> - OpConvertFToU = 109 , <nl> - OpConvertFToS = 110 , <nl> - OpConvertSToF = 111 , <nl> - OpConvertUToF = 112 , <nl> - OpUConvert = 113 , <nl> - OpSConvert = 114 , <nl> - OpFConvert = 115 , <nl> - OpQuantizeToF16 = 116 , <nl> - OpConvertPtrToU = 117 , <nl> - OpSatConvertSToU = 118 , <nl> - OpSatConvertUToS = 119 , <nl> - OpConvertUToPtr = 120 , <nl> - OpPtrCastToGeneric = 121 , <nl> - OpGenericCastToPtr = 122 , <nl> - OpGenericCastToPtrExplicit = 123 , <nl> - OpBitcast = 124 , <nl> - OpSNegate = 126 , <nl> - OpFNegate = 127 , <nl> - OpIAdd = 128 , <nl> - OpFAdd = 129 , <nl> - OpISub = 130 , <nl> - OpFSub = 131 , <nl> - OpIMul = 132 , <nl> - OpFMul = 133 , <nl> - OpUDiv = 134 , <nl> - OpSDiv = 135 , <nl> - OpFDiv = 136 , <nl> - OpUMod = 137 , <nl> - OpSRem = 138 , <nl> - OpSMod = 139 , <nl> - OpFRem = 140 , <nl> - OpFMod = 141 , <nl> - OpVectorTimesScalar = 142 , <nl> - OpMatrixTimesScalar = 143 , <nl> - OpVectorTimesMatrix = 144 , <nl> - OpMatrixTimesVector = 145 , <nl> - OpMatrixTimesMatrix = 146 , <nl> - OpOuterProduct = 147 , <nl> - OpDot = 148 , <nl> - OpIAddCarry = 149 , <nl> - OpISubBorrow = 150 , <nl> - OpUMulExtended = 151 , <nl> - OpSMulExtended = 152 , <nl> - OpAny = 154 , <nl> - OpAll = 155 , <nl> - OpIsNan = 156 , <nl> - OpIsInf = 157 , <nl> - OpIsFinite = 158 , <nl> - OpIsNormal = 159 , <nl> - OpSignBitSet = 160 , <nl> - OpLessOrGreater = 161 , <nl> - OpOrdered = 162 , <nl> - OpUnordered = 163 , <nl> - OpLogicalEqual = 164 , <nl> - OpLogicalNotEqual = 165 , <nl> - OpLogicalOr = 166 , <nl> - OpLogicalAnd = 167 , <nl> - OpLogicalNot = 168 , <nl> - OpSelect = 169 , <nl> - OpIEqual = 170 , <nl> - OpINotEqual = 171 , <nl> - OpUGreaterThan = 172 , <nl> - OpSGreaterThan = 173 , <nl> - OpUGreaterThanEqual = 174 , <nl> - OpSGreaterThanEqual = 175 , <nl> - OpULessThan = 176 , <nl> - OpSLessThan = 177 , <nl> - OpULessThanEqual = 178 , <nl> - OpSLessThanEqual = 179 , <nl> - OpFOrdEqual = 180 , <nl> - OpFUnordEqual = 181 , <nl> - OpFOrdNotEqual = 182 , <nl> - OpFUnordNotEqual = 183 , <nl> - OpFOrdLessThan = 184 , <nl> - OpFUnordLessThan = 185 , <nl> - OpFOrdGreaterThan = 186 , <nl> - OpFUnordGreaterThan = 187 , <nl> - OpFOrdLessThanEqual = 188 , <nl> - OpFUnordLessThanEqual = 189 , <nl> - OpFOrdGreaterThanEqual = 190 , <nl> - OpFUnordGreaterThanEqual = 191 , <nl> - OpShiftRightLogical = 194 , <nl> - OpShiftRightArithmetic = 195 , <nl> - OpShiftLeftLogical = 196 , <nl> - OpBitwiseOr = 197 , <nl> - OpBitwiseXor = 198 , <nl> - OpBitwiseAnd = 199 , <nl> - OpNot = 200 , <nl> - OpBitFieldInsert = 201 , <nl> - OpBitFieldSExtract = 202 , <nl> - OpBitFieldUExtract = 203 , <nl> - OpBitReverse = 204 , <nl> - OpBitCount = 205 , <nl> - OpDPdx = 207 , <nl> - OpDPdy = 208 , <nl> - OpFwidth = 209 , <nl> - OpDPdxFine = 210 , <nl> - OpDPdyFine = 211 , <nl> - OpFwidthFine = 212 , <nl> - OpDPdxCoarse = 213 , <nl> - OpDPdyCoarse = 214 , <nl> - OpFwidthCoarse = 215 , <nl> - OpEmitVertex = 218 , <nl> - OpEndPrimitive = 219 , <nl> - OpEmitStreamVertex = 220 , <nl> - OpEndStreamPrimitive = 221 , <nl> - OpControlBarrier = 224 , <nl> - OpMemoryBarrier = 225 , <nl> - OpAtomicLoad = 227 , <nl> - OpAtomicStore = 228 , <nl> - OpAtomicExchange = 229 , <nl> - OpAtomicCompareExchange = 230 , <nl> - OpAtomicCompareExchangeWeak = 231 , <nl> - OpAtomicIIncrement = 232 , <nl> - OpAtomicIDecrement = 233 , <nl> - OpAtomicIAdd = 234 , <nl> - OpAtomicISub = 235 , <nl> - OpAtomicSMin = 236 , <nl> - OpAtomicUMin = 237 , <nl> - OpAtomicSMax = 238 , <nl> - OpAtomicUMax = 239 , <nl> - OpAtomicAnd = 240 , <nl> - OpAtomicOr = 241 , <nl> - OpAtomicXor = 242 , <nl> - OpPhi = 245 , <nl> - OpLoopMerge = 246 , <nl> - OpSelectionMerge = 247 , <nl> - OpLabel = 248 , <nl> - OpBranch = 249 , <nl> - OpBranchConditional = 250 , <nl> - OpSwitch = 251 , <nl> - OpKill = 252 , <nl> - OpReturn = 253 , <nl> - OpReturnValue = 254 , <nl> - OpUnreachable = 255 , <nl> - OpLifetimeStart = 256 , <nl> - OpLifetimeStop = 257 , <nl> - OpGroupAsyncCopy = 259 , <nl> - OpGroupWaitEvents = 260 , <nl> - OpGroupAll = 261 , <nl> - OpGroupAny = 262 , <nl> - OpGroupBroadcast = 263 , <nl> - OpGroupIAdd = 264 , <nl> - OpGroupFAdd = 265 , <nl> - OpGroupFMin = 266 , <nl> - OpGroupUMin = 267 , <nl> - OpGroupSMin = 268 , <nl> - OpGroupFMax = 269 , <nl> - OpGroupUMax = 270 , <nl> - OpGroupSMax = 271 , <nl> - OpReadPipe = 274 , <nl> - OpWritePipe = 275 , <nl> - OpReservedReadPipe = 276 , <nl> - OpReservedWritePipe = 277 , <nl> - OpReserveReadPipePackets = 278 , <nl> - OpReserveWritePipePackets = 279 , <nl> - OpCommitReadPipe = 280 , <nl> - OpCommitWritePipe = 281 , <nl> - OpIsValidReserveId = 282 , <nl> - OpGetNumPipePackets = 283 , <nl> - OpGetMaxPipePackets = 284 , <nl> - OpGroupReserveReadPipePackets = 285 , <nl> - OpGroupReserveWritePipePackets = 286 , <nl> - OpGroupCommitReadPipe = 287 , <nl> - OpGroupCommitWritePipe = 288 , <nl> - OpEnqueueMarker = 291 , <nl> - OpEnqueueKernel = 292 , <nl> - OpGetKernelNDrangeSubGroupCount = 293 , <nl> - OpGetKernelNDrangeMaxSubGroupSize = 294 , <nl> - OpGetKernelWorkGroupSize = 295 , <nl> - OpGetKernelPreferredWorkGroupSizeMultiple = 296 , <nl> - OpRetainEvent = 297 , <nl> - OpReleaseEvent = 298 , <nl> - OpCreateUserEvent = 299 , <nl> - OpIsValidEvent = 300 , <nl> - OpSetUserEventStatus = 301 , <nl> - OpCaptureEventProfilingInfo = 302 , <nl> - OpGetDefaultQueue = 303 , <nl> - OpBuildNDRange = 304 , <nl> - OpImageSparseSampleImplicitLod = 305 , <nl> - OpImageSparseSampleExplicitLod = 306 , <nl> - OpImageSparseSampleDrefImplicitLod = 307 , <nl> - OpImageSparseSampleDrefExplicitLod = 308 , <nl> - OpImageSparseSampleProjImplicitLod = 309 , <nl> - OpImageSparseSampleProjExplicitLod = 310 , <nl> - OpImageSparseSampleProjDrefImplicitLod = 311 , <nl> - OpImageSparseSampleProjDrefExplicitLod = 312 , <nl> - OpImageSparseFetch = 313 , <nl> - OpImageSparseGather = 314 , <nl> - OpImageSparseDrefGather = 315 , <nl> - OpImageSparseTexelsResident = 316 , <nl> - OpNoLine = 317 , <nl> - OpAtomicFlagTestAndSet = 318 , <nl> - OpAtomicFlagClear = 319 , <nl> - OpImageSparseRead = 320 , <nl> - OpSizeOf = 321 , <nl> - OpTypePipeStorage = 322 , <nl> - OpConstantPipeStorage = 323 , <nl> - OpCreatePipeFromPipeStorage = 324 , <nl> - OpGetKernelLocalSizeForSubgroupCount = 325 , <nl> - OpGetKernelMaxNumSubgroups = 326 , <nl> - OpTypeNamedBarrier = 327 , <nl> - OpNamedBarrierInitialize = 328 , <nl> - OpMemoryNamedBarrier = 329 , <nl> - OpModuleProcessed = 330 , <nl> - OpExecutionModeId = 331 , <nl> - OpDecorateId = 332 , <nl> - OpSubgroupBallotKHR = 4421 , <nl> - OpSubgroupFirstInvocationKHR = 4422 , <nl> - OpSubgroupAllKHR = 4428 , <nl> - OpSubgroupAnyKHR = 4429 , <nl> - OpSubgroupAllEqualKHR = 4430 , <nl> - OpSubgroupReadInvocationKHR = 4432 , <nl> - OpGroupIAddNonUniformAMD = 5000 , <nl> - OpGroupFAddNonUniformAMD = 5001 , <nl> - OpGroupFMinNonUniformAMD = 5002 , <nl> - OpGroupUMinNonUniformAMD = 5003 , <nl> - OpGroupSMinNonUniformAMD = 5004 , <nl> - OpGroupFMaxNonUniformAMD = 5005 , <nl> - OpGroupUMaxNonUniformAMD = 5006 , <nl> - OpGroupSMaxNonUniformAMD = 5007 , <nl> - OpFragmentMaskFetchAMD = 5011 , <nl> - OpFragmentFetchAMD = 5012 , <nl> - OpSubgroupShuffleINTEL = 5571 , <nl> - OpSubgroupShuffleDownINTEL = 5572 , <nl> - OpSubgroupShuffleUpINTEL = 5573 , <nl> - OpSubgroupShuffleXorINTEL = 5574 , <nl> - OpSubgroupBlockReadINTEL = 5575 , <nl> - OpSubgroupBlockWriteINTEL = 5576 , <nl> - OpSubgroupImageBlockReadINTEL = 5577 , <nl> - OpSubgroupImageBlockWriteINTEL = 5578 , <nl> - OpMax = 0x7fffffff , <nl> - } ; <nl> - <nl> - / / Overload operator | for mask bit combining <nl> - <nl> - inline ImageOperandsMask operator | ( ImageOperandsMask a , ImageOperandsMask b ) { return ImageOperandsMask ( unsigned ( a ) | unsigned ( b ) ) ; } <nl> - inline FPFastMathModeMask operator | ( FPFastMathModeMask a , FPFastMathModeMask b ) { return FPFastMathModeMask ( unsigned ( a ) | unsigned ( b ) ) ; } <nl> - inline SelectionControlMask operator | ( SelectionControlMask a , SelectionControlMask b ) { return SelectionControlMask ( unsigned ( a ) | unsigned ( b ) ) ; } <nl> - inline LoopControlMask operator | ( LoopControlMask a , LoopControlMask b ) { return LoopControlMask ( unsigned ( a ) | unsigned ( b ) ) ; } <nl> - inline FunctionControlMask operator | ( FunctionControlMask a , FunctionControlMask b ) { return FunctionControlMask ( unsigned ( a ) | unsigned ( b ) ) ; } <nl> - inline MemorySemanticsMask operator | ( MemorySemanticsMask a , MemorySemanticsMask b ) { return MemorySemanticsMask ( unsigned ( a ) | unsigned ( b ) ) ; } <nl> - inline MemoryAccessMask operator | ( MemoryAccessMask a , MemoryAccessMask b ) { return MemoryAccessMask ( unsigned ( a ) | unsigned ( b ) ) ; } <nl> - inline KernelProfilingInfoMask operator | ( KernelProfilingInfoMask a , KernelProfilingInfoMask b ) { return KernelProfilingInfoMask ( unsigned ( a ) | unsigned ( b ) ) ; } <nl> - <nl> - } / / end namespace spv <nl> - <nl> - # endif / / # ifndef spirv_HPP <nl> - <nl> deleted file mode 100644 <nl> index faa2701f . . 00000000 <nl> mmm a / glslang / include / SPIRV / spvIR . h <nl> ppp / dev / null <nl> <nl> - / / <nl> - / / Copyright ( C ) 2014 LunarG , Inc . <nl> - / / <nl> - / / All rights reserved . <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions <nl> - / / are met : <nl> - / / <nl> - / / Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / <nl> - / / Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following <nl> - / / disclaimer in the documentation and / or other materials provided <nl> - / / with the distribution . <nl> - / / <nl> - / / Neither the name of 3Dlabs Inc . Ltd . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived <nl> - / / from this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS <nl> - / / FOR A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE <nl> - / / COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , <nl> - / / INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , <nl> - / / BUT NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; <nl> - / / LOSS OF USE , DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER <nl> - / / CAUSED AND ON ANY THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT <nl> - / / LIABILITY , OR TORT ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN <nl> - / / ANY WAY OUT OF THE USE OF THIS SOFTWARE , EVEN IF ADVISED OF THE <nl> - / / POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / SPIRV - IR <nl> - / / <nl> - / / Simple in - memory representation ( IR ) of SPIRV . Just for holding <nl> - / / Each function ' s CFG of blocks . Has this hierarchy : <nl> - / / - Module , which is a list of <nl> - / / - Function , which is a list of <nl> - / / - Block , which is a list of <nl> - / / - Instruction <nl> - / / <nl> - <nl> - # pragma once <nl> - # ifndef spvIR_H <nl> - # define spvIR_H <nl> - <nl> - # include " spirv . hpp " <nl> - <nl> - # include < algorithm > <nl> - # include < cassert > <nl> - # include < functional > <nl> - # include < iostream > <nl> - # include < memory > <nl> - # include < vector > <nl> - <nl> - namespace spv { <nl> - <nl> - class Block ; <nl> - class Function ; <nl> - class Module ; <nl> - <nl> - const Id NoResult = 0 ; <nl> - const Id NoType = 0 ; <nl> - <nl> - const Decoration NoPrecision = DecorationMax ; <nl> - <nl> - # ifdef __GNUC__ <nl> - # define POTENTIALLY_UNUSED __attribute__ ( ( unused ) ) <nl> - # else <nl> - # define POTENTIALLY_UNUSED <nl> - # endif <nl> - <nl> - POTENTIALLY_UNUSED <nl> - const MemorySemanticsMask MemorySemanticsAllMemory = <nl> - ( MemorySemanticsMask ) ( MemorySemanticsUniformMemoryMask | <nl> - MemorySemanticsWorkgroupMemoryMask | <nl> - MemorySemanticsAtomicCounterMemoryMask | <nl> - MemorySemanticsImageMemoryMask ) ; <nl> - <nl> - / / <nl> - / / SPIR - V IR instruction . <nl> - / / <nl> - <nl> - class Instruction { <nl> - public : <nl> - Instruction ( Id resultId , Id typeId , Op opCode ) : resultId ( resultId ) , typeId ( typeId ) , opCode ( opCode ) , block ( nullptr ) { } <nl> - explicit Instruction ( Op opCode ) : resultId ( NoResult ) , typeId ( NoType ) , opCode ( opCode ) , block ( nullptr ) { } <nl> - virtual ~ Instruction ( ) { } <nl> - void addIdOperand ( Id id ) { operands . push_back ( id ) ; } <nl> - void addImmediateOperand ( unsigned int immediate ) { operands . push_back ( immediate ) ; } <nl> - void addStringOperand ( const char * str ) <nl> - { <nl> - unsigned int word ; <nl> - char * wordString = ( char * ) & word ; <nl> - char * wordPtr = wordString ; <nl> - int charCount = 0 ; <nl> - char c ; <nl> - do { <nl> - c = * ( str + + ) ; <nl> - * ( wordPtr + + ) = c ; <nl> - + + charCount ; <nl> - if ( charCount = = 4 ) { <nl> - addImmediateOperand ( word ) ; <nl> - wordPtr = wordString ; <nl> - charCount = 0 ; <nl> - } <nl> - } while ( c ! = 0 ) ; <nl> - <nl> - / / deal with partial last word <nl> - if ( charCount > 0 ) { <nl> - / / pad with 0s <nl> - for ( ; charCount < 4 ; + + charCount ) <nl> - * ( wordPtr + + ) = 0 ; <nl> - addImmediateOperand ( word ) ; <nl> - } <nl> - } <nl> - void setBlock ( Block * b ) { block = b ; } <nl> - Block * getBlock ( ) const { return block ; } <nl> - Op getOpCode ( ) const { return opCode ; } <nl> - int getNumOperands ( ) const { return ( int ) operands . size ( ) ; } <nl> - Id getResultId ( ) const { return resultId ; } <nl> - Id getTypeId ( ) const { return typeId ; } <nl> - Id getIdOperand ( int op ) const { return operands [ op ] ; } <nl> - unsigned int getImmediateOperand ( int op ) const { return operands [ op ] ; } <nl> - <nl> - / / Write out the binary form . <nl> - void dump ( std : : vector < unsigned int > & out ) const <nl> - { <nl> - / / Compute the wordCount <nl> - unsigned int wordCount = 1 ; <nl> - if ( typeId ) <nl> - + + wordCount ; <nl> - if ( resultId ) <nl> - + + wordCount ; <nl> - wordCount + = ( unsigned int ) operands . size ( ) ; <nl> - <nl> - / / Write out the beginning of the instruction <nl> - out . push_back ( ( ( wordCount ) < < WordCountShift ) | opCode ) ; <nl> - if ( typeId ) <nl> - out . push_back ( typeId ) ; <nl> - if ( resultId ) <nl> - out . push_back ( resultId ) ; <nl> - <nl> - / / Write out the operands <nl> - for ( int op = 0 ; op < ( int ) operands . size ( ) ; + + op ) <nl> - out . push_back ( operands [ op ] ) ; <nl> - } <nl> - <nl> - protected : <nl> - Instruction ( const Instruction & ) ; <nl> - Id resultId ; <nl> - Id typeId ; <nl> - Op opCode ; <nl> - std : : vector < Id > operands ; <nl> - Block * block ; <nl> - } ; <nl> - <nl> - / / <nl> - / / SPIR - V IR block . <nl> - / / <nl> - <nl> - class Block { <nl> - public : <nl> - Block ( Id id , Function & parent ) ; <nl> - virtual ~ Block ( ) <nl> - { <nl> - } <nl> - <nl> - Id getId ( ) { return instructions . front ( ) - > getResultId ( ) ; } <nl> - <nl> - Function & getParent ( ) const { return parent ; } <nl> - void addInstruction ( std : : unique_ptr < Instruction > inst ) ; <nl> - void addPredecessor ( Block * pred ) { predecessors . push_back ( pred ) ; pred - > successors . push_back ( this ) ; } <nl> - void addLocalVariable ( std : : unique_ptr < Instruction > inst ) { localVariables . push_back ( std : : move ( inst ) ) ; } <nl> - const std : : vector < Block * > & getPredecessors ( ) const { return predecessors ; } <nl> - const std : : vector < Block * > & getSuccessors ( ) const { return successors ; } <nl> - const std : : vector < std : : unique_ptr < Instruction > > & getInstructions ( ) const { <nl> - return instructions ; <nl> - } <nl> - void setUnreachable ( ) { unreachable = true ; } <nl> - bool isUnreachable ( ) const { return unreachable ; } <nl> - / / Returns the block ' s merge instruction , if one exists ( otherwise null ) . <nl> - const Instruction * getMergeInstruction ( ) const { <nl> - if ( instructions . size ( ) < 2 ) return nullptr ; <nl> - const Instruction * nextToLast = ( instructions . cend ( ) - 2 ) - > get ( ) ; <nl> - switch ( nextToLast - > getOpCode ( ) ) { <nl> - case OpSelectionMerge : <nl> - case OpLoopMerge : <nl> - return nextToLast ; <nl> - default : <nl> - return nullptr ; <nl> - } <nl> - return nullptr ; <nl> - } <nl> - <nl> - bool isTerminated ( ) const <nl> - { <nl> - switch ( instructions . back ( ) - > getOpCode ( ) ) { <nl> - case OpBranch : <nl> - case OpBranchConditional : <nl> - case OpSwitch : <nl> - case OpKill : <nl> - case OpReturn : <nl> - case OpReturnValue : <nl> - return true ; <nl> - default : <nl> - return false ; <nl> - } <nl> - } <nl> - <nl> - void dump ( std : : vector < unsigned int > & out ) const <nl> - { <nl> - instructions [ 0 ] - > dump ( out ) ; <nl> - for ( int i = 0 ; i < ( int ) localVariables . size ( ) ; + + i ) <nl> - localVariables [ i ] - > dump ( out ) ; <nl> - for ( int i = 1 ; i < ( int ) instructions . size ( ) ; + + i ) <nl> - instructions [ i ] - > dump ( out ) ; <nl> - } <nl> - <nl> - protected : <nl> - Block ( const Block & ) ; <nl> - Block & operator = ( Block & ) ; <nl> - <nl> - / / To enforce keeping parent and ownership in sync : <nl> - friend Function ; <nl> - <nl> - std : : vector < std : : unique_ptr < Instruction > > instructions ; <nl> - std : : vector < Block * > predecessors , successors ; <nl> - std : : vector < std : : unique_ptr < Instruction > > localVariables ; <nl> - Function & parent ; <nl> - <nl> - / / track whether this block is known to be uncreachable ( not necessarily <nl> - / / true for all unreachable blocks , but should be set at least <nl> - / / for the extraneous ones introduced by the builder ) . <nl> - bool unreachable ; <nl> - } ; <nl> - <nl> - / / Traverses the control - flow graph rooted at root in an order suited for <nl> - / / readable code generation . Invokes callback at every node in the traversal <nl> - / / order . <nl> - void inReadableOrder ( Block * root , std : : function < void ( Block * ) > callback ) ; <nl> - <nl> - / / <nl> - / / SPIR - V IR Function . <nl> - / / <nl> - <nl> - class Function { <nl> - public : <nl> - Function ( Id id , Id resultType , Id functionType , Id firstParam , Module & parent ) ; <nl> - virtual ~ Function ( ) <nl> - { <nl> - for ( int i = 0 ; i < ( int ) parameterInstructions . size ( ) ; + + i ) <nl> - delete parameterInstructions [ i ] ; <nl> - <nl> - for ( int i = 0 ; i < ( int ) blocks . size ( ) ; + + i ) <nl> - delete blocks [ i ] ; <nl> - } <nl> - Id getId ( ) const { return functionInstruction . getResultId ( ) ; } <nl> - Id getParamId ( int p ) { return parameterInstructions [ p ] - > getResultId ( ) ; } <nl> - <nl> - void addBlock ( Block * block ) { blocks . push_back ( block ) ; } <nl> - void removeBlock ( Block * block ) <nl> - { <nl> - auto found = find ( blocks . begin ( ) , blocks . end ( ) , block ) ; <nl> - assert ( found ! = blocks . end ( ) ) ; <nl> - blocks . erase ( found ) ; <nl> - delete block ; <nl> - } <nl> - <nl> - Module & getParent ( ) const { return parent ; } <nl> - Block * getEntryBlock ( ) const { return blocks . front ( ) ; } <nl> - Block * getLastBlock ( ) const { return blocks . back ( ) ; } <nl> - const std : : vector < Block * > & getBlocks ( ) const { return blocks ; } <nl> - void addLocalVariable ( std : : unique_ptr < Instruction > inst ) ; <nl> - Id getReturnType ( ) const { return functionInstruction . getTypeId ( ) ; } <nl> - <nl> - void setImplicitThis ( ) { implicitThis = true ; } <nl> - bool hasImplicitThis ( ) const { return implicitThis ; } <nl> - <nl> - void dump ( std : : vector < unsigned int > & out ) const <nl> - { <nl> - / / OpFunction <nl> - functionInstruction . dump ( out ) ; <nl> - <nl> - / / OpFunctionParameter <nl> - for ( int p = 0 ; p < ( int ) parameterInstructions . size ( ) ; + + p ) <nl> - parameterInstructions [ p ] - > dump ( out ) ; <nl> - <nl> - / / Blocks <nl> - inReadableOrder ( blocks [ 0 ] , [ & out ] ( const Block * b ) { b - > dump ( out ) ; } ) ; <nl> - Instruction end ( 0 , 0 , OpFunctionEnd ) ; <nl> - end . dump ( out ) ; <nl> - } <nl> - <nl> - protected : <nl> - Function ( const Function & ) ; <nl> - Function & operator = ( Function & ) ; <nl> - <nl> - Module & parent ; <nl> - Instruction functionInstruction ; <nl> - std : : vector < Instruction * > parameterInstructions ; <nl> - std : : vector < Block * > blocks ; <nl> - bool implicitThis ; / / true if this is a member function expecting to be passed a ' this ' as the first argument <nl> - } ; <nl> - <nl> - / / <nl> - / / SPIR - V IR Module . <nl> - / / <nl> - <nl> - class Module { <nl> - public : <nl> - Module ( ) { } <nl> - virtual ~ Module ( ) <nl> - { <nl> - / / TODO delete things <nl> - } <nl> - <nl> - void addFunction ( Function * fun ) { functions . push_back ( fun ) ; } <nl> - <nl> - void mapInstruction ( Instruction * instruction ) <nl> - { <nl> - spv : : Id resultId = instruction - > getResultId ( ) ; <nl> - / / map the instruction ' s result id <nl> - if ( resultId > = idToInstruction . size ( ) ) <nl> - idToInstruction . resize ( resultId + 16 ) ; <nl> - idToInstruction [ resultId ] = instruction ; <nl> - } <nl> - <nl> - Instruction * getInstruction ( Id id ) const { return idToInstruction [ id ] ; } <nl> - const std : : vector < Function * > & getFunctions ( ) const { return functions ; } <nl> - spv : : Id getTypeId ( Id resultId ) const { return idToInstruction [ resultId ] - > getTypeId ( ) ; } <nl> - StorageClass getStorageClass ( Id typeId ) const <nl> - { <nl> - assert ( idToInstruction [ typeId ] - > getOpCode ( ) = = spv : : OpTypePointer ) ; <nl> - return ( StorageClass ) idToInstruction [ typeId ] - > getImmediateOperand ( 0 ) ; <nl> - } <nl> - <nl> - void dump ( std : : vector < unsigned int > & out ) const <nl> - { <nl> - for ( int f = 0 ; f < ( int ) functions . size ( ) ; + + f ) <nl> - functions [ f ] - > dump ( out ) ; <nl> - } <nl> - <nl> - protected : <nl> - Module ( const Module & ) ; <nl> - std : : vector < Function * > functions ; <nl> - <nl> - / / map from result id to instruction having that result id <nl> - std : : vector < Instruction * > idToInstruction ; <nl> - <nl> - / / map from a result id to its type id <nl> - } ; <nl> - <nl> - / / <nl> - / / Implementation ( it ' s here due to circular type definitions ) . <nl> - / / <nl> - <nl> - / / Add both <nl> - / / - the OpFunction instruction <nl> - / / - all the OpFunctionParameter instructions <nl> - __inline Function : : Function ( Id id , Id resultType , Id functionType , Id firstParamId , Module & parent ) <nl> - : parent ( parent ) , functionInstruction ( id , resultType , OpFunction ) , implicitThis ( false ) <nl> - { <nl> - / / OpFunction <nl> - functionInstruction . addImmediateOperand ( FunctionControlMaskNone ) ; <nl> - functionInstruction . addIdOperand ( functionType ) ; <nl> - parent . mapInstruction ( & functionInstruction ) ; <nl> - parent . addFunction ( this ) ; <nl> - <nl> - / / OpFunctionParameter <nl> - Instruction * typeInst = parent . getInstruction ( functionType ) ; <nl> - int numParams = typeInst - > getNumOperands ( ) - 1 ; <nl> - for ( int p = 0 ; p < numParams ; + + p ) { <nl> - Instruction * param = new Instruction ( firstParamId + p , typeInst - > getIdOperand ( p + 1 ) , OpFunctionParameter ) ; <nl> - parent . mapInstruction ( param ) ; <nl> - parameterInstructions . push_back ( param ) ; <nl> - } <nl> - } <nl> - <nl> - __inline void Function : : addLocalVariable ( std : : unique_ptr < Instruction > inst ) <nl> - { <nl> - Instruction * raw_instruction = inst . get ( ) ; <nl> - blocks [ 0 ] - > addLocalVariable ( std : : move ( inst ) ) ; <nl> - parent . mapInstruction ( raw_instruction ) ; <nl> - } <nl> - <nl> - __inline Block : : Block ( Id id , Function & parent ) : parent ( parent ) , unreachable ( false ) <nl> - { <nl> - instructions . push_back ( std : : unique_ptr < Instruction > ( new Instruction ( id , NoType , OpLabel ) ) ) ; <nl> - instructions . back ( ) - > setBlock ( this ) ; <nl> - parent . getParent ( ) . mapInstruction ( instructions . back ( ) . get ( ) ) ; <nl> - } <nl> - <nl> - __inline void Block : : addInstruction ( std : : unique_ptr < Instruction > inst ) <nl> - { <nl> - Instruction * raw_instruction = inst . get ( ) ; <nl> - instructions . push_back ( std : : move ( inst ) ) ; <nl> - raw_instruction - > setBlock ( this ) ; <nl> - if ( raw_instruction - > getResultId ( ) ) <nl> - parent . getParent ( ) . mapInstruction ( raw_instruction ) ; <nl> - } <nl> - <nl> - } ; / / end spv namespace <nl> - <nl> - # endif / / spvIR_H <nl> deleted file mode 100644 <nl> index 864b166a . . 00000000 <nl> Binary files a / glslang / lib / libHLSL . a and / dev / null differ <nl> deleted file mode 100644 <nl> index ec11f1ab . . 00000000 <nl> Binary files a / glslang / lib / libOGLCompiler . a and / dev / null differ <nl> deleted file mode 100644 <nl> index c129a68e . . 00000000 <nl> Binary files a / glslang / lib / libOSDependent . a and / dev / null differ <nl> deleted file mode 100644 <nl> index 458ca747 . . 00000000 <nl> Binary files a / glslang / lib / libSPIRV - Tools - opt . a and / dev / null differ <nl> deleted file mode 100644 <nl> index ee4257db . . 00000000 <nl> Binary files a / glslang / lib / libSPIRV - Tools . a and / dev / null differ <nl> deleted file mode 100644 <nl> index c75c7019 . . 00000000 <nl> Binary files a / glslang / lib / libSPIRV . a and / dev / null differ <nl> deleted file mode 100644 <nl> index c7a5bcc4 . . 00000000 <nl> Binary files a / glslang / lib / libSPVRemapper . a and / dev / null differ <nl> deleted file mode 100644 <nl> index 71002a4c . . 00000000 <nl> Binary files a / glslang / lib / libglslang . a and / dev / null differ <nl> mmm a / proton <nl> ppp b / proton <nl> class CompatData : <nl> self . prefix_dir + " drive_c / windows / syswow64 / " + f + " . dll " ) <nl> g_session . dlloverrides [ f ] = " n " <nl> <nl> + try_copy ( g_proton . lib64_dir + " wine / vkd3d - proton / d3d12 . dll " , <nl> + self . prefix_dir + " drive_c / windows / system32 / d3d12 . dll " ) <nl> + try_copy ( g_proton . lib_dir + " wine / vkd3d - proton / d3d12 . dll " , <nl> + self . prefix_dir + " drive_c / windows / syswow64 / d3d12 . dll " ) <nl> + <nl> def comma_escaped ( s ) : <nl> escaped = False <nl> idx = - 1 <nl> deleted file mode 160000 <nl> index e6857939 . . 00000000 <nl> mmm a / vkd3d <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - Subproject commit e6857939e7de69da02dfb277a0482905c133b1c3 <nl> new file mode 160000 <nl> index 00000000 . . debb93f3 <nl> mmm / dev / null <nl> ppp b / vkd3d - proton <nl> @ @ - 0 , 0 + 1 @ @ <nl> + Subproject commit debb93f38aa64b40b4fb8a0f3989c1d55391c349 <nl>
Fix up vkd3d - proton build
ValveSoftware/Proton
1c260866887fcb713ff2e89e41e93fcdfebbb122
2020-07-15T15:31:53Z
mmm a / src / core / core . vcxproj . filters <nl> ppp b / src / core / core . vcxproj . filters <nl> <nl> < Filter Include = " arm \ interpreter \ mmu " > <nl> < UniqueIdentifier > { 13ef9860 - 2ba0 - 47e9 - a93d - b4052adab269 } < / UniqueIdentifier > <nl> < / Filter > <nl> + < Filter Include = " hle \ kernel " > <nl> + < UniqueIdentifier > { 8089d94b - 5faa - 43dc - 854b - ffd2fa2e7fe3 } < / UniqueIdentifier > <nl> + < / Filter > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> < ClCompile Include = " arm \ disassembler \ arm_disasm . cpp " > <nl> <nl> < ClCompile Include = " arm \ interpreter \ mmu \ maverick . cpp " > <nl> < Filter > arm \ interpreter \ mmu < / Filter > <nl> < / ClCompile > <nl> + < ClCompile Include = " hle \ kernel \ kernel . cpp " > <nl> + < Filter > hle \ kernel < / Filter > <nl> + < / ClCompile > <nl> + < ClCompile Include = " hle \ kernel \ thread . cpp " > <nl> + < Filter > hle \ kernel < / Filter > <nl> + < / ClCompile > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> < ClInclude Include = " arm \ disassembler \ arm_disasm . h " > <nl> <nl> < ClInclude Include = " arm \ interpreter \ mmu \ sa_mmu . h " > <nl> < Filter > arm \ interpreter \ mmu < / Filter > <nl> < / ClInclude > <nl> + < ClInclude Include = " hle \ kernel \ kernel . h " > <nl> + < Filter > hle \ kernel < / Filter > <nl> + < / ClInclude > <nl> + < ClInclude Include = " hle \ kernel \ thread . h " > <nl> + < Filter > hle \ kernel < / Filter > <nl> + < / ClInclude > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> < Text Include = " CMakeLists . txt " / > <nl>
add kernel . * and thread . * to VS filters
yuzu-emu/yuzu
4faed70b40ae44a0a5c63366ad4e6dfa6340e73f
2014-05-17T03:24:39Z
mmm a / src / video_core / renderer_opengl / gl_rasterizer . cpp <nl> ppp b / src / video_core / renderer_opengl / gl_rasterizer . cpp <nl> void RasterizerOpenGL : : SyncViewport ( OpenGLState & current_state ) { <nl> viewport . y = viewport_rect . bottom ; <nl> viewport . width = viewport_rect . GetWidth ( ) ; <nl> viewport . height = viewport_rect . GetHeight ( ) ; <nl> - viewport . depth_range_far = regs . viewports [ i ] . depth_range_far ; <nl> - viewport . depth_range_near = regs . viewports [ i ] . depth_range_near ; <nl> + viewport . depth_range_far = src . depth_range_far ; <nl> + viewport . depth_range_near = src . depth_range_near ; <nl> } <nl> state . depth_clamp . far_plane = regs . view_volume_clip_control . depth_clamp_far ! = 0 ; <nl> state . depth_clamp . near_plane = regs . view_volume_clip_control . depth_clamp_near ! = 0 ; <nl> mmm a / src / video_core / shader / decode / texture . cpp <nl> ppp b / src / video_core / shader / decode / texture . cpp <nl> Node4 ShaderIR : : GetTld4Code ( Instruction instr , TextureType texture_type , bool de <nl> bool is_array , bool is_aoffi ) { <nl> const std : : size_t coord_count = GetCoordCount ( texture_type ) ; <nl> const std : : size_t total_coord_count = coord_count + ( is_array ? 1 : 0 ) ; <nl> - const std : : size_t total_reg_count = total_coord_count + ( depth_compare ? 1 : 0 ) ; <nl> <nl> / / If enabled arrays index is always stored in the gpr8 field <nl> const u64 array_register = instr . gpr8 . Value ( ) ; <nl>
Merge pull request from lioncash / unused - var
yuzu-emu/yuzu
a206418846281911dfb810c60382fc33d3540220
2019-05-07T08:50:59Z
mmm a / src / clientsession . cpp <nl> ppp b / src / clientsession . cpp <nl> void ClientSession : : in_recv ( const string & data ) { <nl> switch ( status ) { <nl> case HANDSHAKE : { <nl> if ( data . length ( ) < 2 | | data [ 0 ] ! = 5 | | data . length ( ) ! = data [ 1 ] + 2 ) { <nl> + Log : : log_with_endpoint ( in_endpoint , " unknown protocol " , Log : : ERROR ) ; <nl> destroy ( ) ; <nl> return ; <nl> } <nl> void ClientSession : : in_recv ( const string & data ) { <nl> } <nl> } <nl> if ( ! has_method ) { <nl> + Log : : log_with_endpoint ( in_endpoint , " unsupported auth method " , Log : : ERROR ) ; <nl> in_async_write ( string ( " \ x05 \ xff " , 2 ) ) ; <nl> status = INVALID ; <nl> return ; <nl> void ClientSession : : in_recv ( const string & data ) { <nl> } <nl> case REQUEST : { <nl> if ( data . length ( ) < 7 | | data [ 0 ] ! = 5 | | data [ 2 ] ! = 0 ) { <nl> + Log : : log_with_endpoint ( in_endpoint , " bad request " , Log : : ERROR ) ; <nl> destroy ( ) ; <nl> return ; <nl> } <nl> out_write_buf = data [ 1 ] + data . substr ( 3 ) ; <nl> TrojanRequest req ; <nl> if ( req . parse ( out_write_buf ) ! = out_write_buf . length ( ) ) { <nl> + Log : : log_with_endpoint ( in_endpoint , " unsupported command " , Log : : ERROR ) ; <nl> in_async_write ( string ( " \ x05 \ x07 \ x00 \ x01 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 " , 10 ) ) ; <nl> status = INVALID ; <nl> return ; <nl> } <nl> + Log : : log_with_endpoint ( in_endpoint , " requested connection to " + req . address . address + ' : ' + to_string ( req . address . port ) , Log : : INFO ) ; <nl> out_write_buf = config . password [ 0 ] + " \ r \ n " + out_write_buf + " \ r \ n " ; <nl> is_udp = req . command = = TrojanRequest : : UDP_ASSOCIATE ; <nl> if ( is_udp ) { <nl> void ClientSession : : in_sent ( ) { <nl> auto self = shared_from_this ( ) ; <nl> resolver . async_resolve ( query , [ this , self ] ( const boost : : system : : error_code error , tcp : : resolver : : iterator iterator ) { <nl> if ( error ) { <nl> + Log : : log_with_endpoint ( in_endpoint , " cannot resolve remote server hostname " + config . remote_addr , Log : : ERROR ) ; <nl> destroy ( ) ; <nl> return ; <nl> } <nl> out_socket . lowest_layer ( ) . async_connect ( * iterator , [ this , self ] ( const boost : : system : : error_code error ) { <nl> if ( error ) { <nl> + Log : : log_with_endpoint ( in_endpoint , " cannot establish connection to remote server " + config . remote_addr + ' : ' + to_string ( config . remote_port ) , Log : : ERROR ) ; <nl> destroy ( ) ; <nl> return ; <nl> } <nl> out_socket . async_handshake ( stream_base : : client , [ this , self ] ( const boost : : system : : error_code error ) { <nl> if ( error ) { <nl> + Log : : log_with_endpoint ( in_endpoint , " SSL handshake failed with " + config . remote_addr + ' : ' + to_string ( config . remote_port ) , Log : : ERROR ) ; <nl> destroy ( ) ; <nl> return ; <nl> } <nl> + Log : : log_with_endpoint ( in_endpoint , " tunnel established " ) ; <nl> if ( is_udp ) { <nl> if ( ! first_packet_recv ) { <nl> udp_socket . cancel ( ) ; <nl> void ClientSession : : destroy ( ) { <nl> if ( status = = DESTROY ) { <nl> return ; <nl> } <nl> + Log : : log_with_endpoint ( in_endpoint , " disconnected " ) ; <nl> status = DESTROY ; <nl> resolver . cancel ( ) ; <nl> boost : : system : : error_code ec ; <nl> mmm a / src / serversession . cpp <nl> ppp b / src / serversession . cpp <nl> void ServerSession : : start ( ) { <nl> auto self = shared_from_this ( ) ; <nl> in_socket . async_handshake ( stream_base : : server , [ this , self ] ( const boost : : system : : error_code error ) { <nl> if ( error ) { <nl> + Log : : log_with_endpoint ( in_endpoint , " SSL handshake failed " , Log : : ERROR ) ; <nl> destroy ( ) ; <nl> return ; <nl> } <nl> void ServerSession : : in_recv ( const string & data ) { <nl> tcp : : resolver : : query query ( valid ? req . address . address : config . remote_addr , <nl> to_string ( valid ? req . address . port : config . remote_port ) ) ; <nl> if ( valid ) { <nl> + Log : : log_with_endpoint ( in_endpoint , " requested connection to " + req . address . address + ' : ' + to_string ( req . address . port ) , Log : : INFO ) ; <nl> out_write_buf = tmp . substr ( req_len + 2 ) ; <nl> if ( req . command = = TrojanRequest : : UDP_ASSOCIATE ) { <nl> status = UDP_FORWARD ; <nl> void ServerSession : : in_recv ( const string & data ) { <nl> return ; <nl> } <nl> } else { <nl> + Log : : log_with_endpoint ( in_endpoint , " not trojan request , connecting to " + config . remote_addr + ' : ' + to_string ( config . remote_port ) , Log : : WARN ) ; <nl> out_write_buf = data ; <nl> } <nl> auto self = shared_from_this ( ) ; <nl> resolver . async_resolve ( query , [ this , self ] ( const boost : : system : : error_code error , tcp : : resolver : : iterator iterator ) { <nl> if ( error ) { <nl> + Log : : log_with_endpoint ( in_endpoint , " cannot resolve remote server hostname " , Log : : ERROR ) ; <nl> destroy ( ) ; <nl> return ; <nl> } <nl> out_socket . async_connect ( * iterator , [ this , self ] ( const boost : : system : : error_code error ) { <nl> if ( error ) { <nl> + Log : : log_with_endpoint ( in_endpoint , " cannot establish connection to remote server " , Log : : ERROR ) ; <nl> destroy ( ) ; <nl> return ; <nl> } <nl> + Log : : log_with_endpoint ( in_endpoint , " tunnel established " ) ; <nl> status = FORWARD ; <nl> out_async_read ( ) ; <nl> if ( out_write_buf ! = " " ) { <nl> void ServerSession : : destroy ( ) { <nl> if ( status = = DESTROY ) { <nl> return ; <nl> } <nl> + Log : : log_with_endpoint ( in_endpoint , " disconnected " ) ; <nl> status = DESTROY ; <nl> resolver . cancel ( ) ; <nl> udp_resolver . cancel ( ) ; <nl> mmm a / src / service . cpp <nl> ppp b / src / service . cpp <nl> Service : : Service ( Config & config ) : <nl> <nl> void Service : : run ( ) { <nl> async_accept ( ) ; <nl> + tcp : : endpoint local_endpoint = socket_acceptor . local_endpoint ( ) ; <nl> + Log : : log_with_date_time ( string ( " trojan service ( " ) + ( config . run_type = = Config : : SERVER ? " server " : " client " ) + " ) started at " + local_endpoint . address ( ) . to_string ( ) + ' : ' + to_string ( local_endpoint . port ( ) ) , Log : : FATAL ) ; <nl> io_service . run ( ) ; <nl> + Log : : log_with_date_time ( " trojan service stopped " , Log : : FATAL ) ; <nl> } <nl> <nl> void Service : : stop ( ) { <nl> void Service : : async_accept ( ) { <nl> boost : : system : : error_code ec ; <nl> auto endpoint = session - > accept_socket ( ) . remote_endpoint ( ec ) ; <nl> if ( ! ec ) { <nl> + Log : : log_with_endpoint ( endpoint , " incoming connection " ) ; <nl> session - > start ( ) ; <nl> } <nl> } <nl>
Part of log
trojan-gfw/trojan
cb4834542111e0367cc23989f141c9ec2e96eaa9
2018-04-12T18:32:05Z
mmm a / stdlib / public / runtime / Metadata . cpp <nl> ppp b / stdlib / public / runtime / Metadata . cpp <nl> _swift_initClassMetadataImpl ( ClassMetadata * self , <nl> <nl> initClassFieldOffsetVector ( self , numFields , fieldTypes , fieldOffsets ) ; <nl> <nl> - auto * description = self - > getDescription ( ) ; <nl> # if SWIFT_OBJC_INTEROP <nl> + auto * description = self - > getDescription ( ) ; <nl> if ( description - > isGeneric ( ) ) { <nl> assert ( ! description - > hasObjCResilientClassStub ( ) ) ; <nl> initGenericObjCClass ( self , numFields , fieldTypes , fieldOffsets ) ; <nl> _swift_initClassMetadataImpl ( ClassMetadata * self , <nl> } <nl> } <nl> # else <nl> - assert ( ! description - > hasObjCResilientClassStub ( ) ) ; <nl> + assert ( ! self - > getDescription ( ) - > hasObjCResilientClassStub ( ) ) ; <nl> # endif <nl> <nl> return MetadataDependency ( ) ; <nl>
Merge pull request from compnerd / unused - noise
apple/swift
836ae890c1075c013b2b9de62cf7145635f0c217
2019-06-02T21:12:03Z
mmm a / BUILD <nl> ppp b / BUILD <nl> g_stands_for = " green " <nl> <nl> core_version = " 3 . 0 . 0 - dev " <nl> <nl> - version = " 1 . 2 . 0 " <nl> + version = " 1 . 2 . 1 - pre2 " <nl> <nl> grpc_cc_library ( <nl> name = " gpr " , <nl> mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> <nl> cmake_minimum_required ( VERSION 2 . 8 ) <nl> <nl> set ( PACKAGE_NAME " grpc " ) <nl> - set ( PACKAGE_VERSION " 1 . 2 . 1 - pre1 " ) <nl> + set ( PACKAGE_VERSION " 1 . 2 . 1 - pre2 " ) <nl> set ( PACKAGE_STRING " $ { PACKAGE_NAME } $ { PACKAGE_VERSION } " ) <nl> set ( PACKAGE_TARNAME " $ { PACKAGE_NAME } - $ { PACKAGE_VERSION } " ) <nl> set ( PACKAGE_BUGREPORT " https : / / github . com / grpc / grpc / issues / " ) <nl> mmm a / Makefile <nl> ppp b / Makefile <nl> Q = @ <nl> endif <nl> <nl> CORE_VERSION = 3 . 0 . 0 - dev <nl> - CPP_VERSION = 1 . 2 . 1 - pre1 <nl> - CSHARP_VERSION = 1 . 2 . 1 - pre1 <nl> + CPP_VERSION = 1 . 2 . 1 - pre2 <nl> + CSHARP_VERSION = 1 . 2 . 1 - pre2 <nl> <nl> CPPFLAGS_NO_ARCH + = $ ( addprefix - I , $ ( INCLUDES ) ) $ ( addprefix - D , $ ( DEFINES ) ) <nl> CPPFLAGS + = $ ( CPPFLAGS_NO_ARCH ) $ ( ARCH_FLAGS ) <nl> mmm a / build . yaml <nl> ppp b / build . yaml <nl> settings : <nl> ' # 10 ' : See the expand_version . py for all the quirks here <nl> core_version : 3 . 0 . 0 - dev <nl> g_stands_for : green <nl> - version : 1 . 2 . 1 - pre1 <nl> + version : 1 . 2 . 1 - pre2 <nl> filegroups : <nl> - name : census <nl> public_headers : <nl> mmm a / gRPC - Core . podspec <nl> ppp b / gRPC - Core . podspec <nl> <nl> <nl> Pod : : Spec . new do | s | <nl> s . name = ' gRPC - Core ' <nl> - version = ' 1 . 2 . 1 - pre1 ' <nl> + version = ' 1 . 2 . 1 - pre2 ' <nl> s . version = version <nl> s . summary = ' Core cross - platform gRPC library , written in C ' <nl> s . homepage = ' http : / / www . grpc . io ' <nl> mmm a / gRPC - ProtoRPC . podspec <nl> ppp b / gRPC - ProtoRPC . podspec <nl> <nl> <nl> Pod : : Spec . new do | s | <nl> s . name = ' gRPC - ProtoRPC ' <nl> - version = ' 1 . 2 . 1 - pre1 ' <nl> + version = ' 1 . 2 . 1 - pre2 ' <nl> s . version = version <nl> s . summary = ' RPC library for Protocol Buffers , based on gRPC ' <nl> s . homepage = ' http : / / www . grpc . io ' <nl> mmm a / gRPC - RxLibrary . podspec <nl> ppp b / gRPC - RxLibrary . podspec <nl> <nl> <nl> Pod : : Spec . new do | s | <nl> s . name = ' gRPC - RxLibrary ' <nl> - version = ' 1 . 2 . 1 - pre1 ' <nl> + version = ' 1 . 2 . 1 - pre2 ' <nl> s . version = version <nl> s . summary = ' Reactive Extensions library for iOS / OSX . ' <nl> s . homepage = ' http : / / www . grpc . io ' <nl> mmm a / gRPC . podspec <nl> ppp b / gRPC . podspec <nl> <nl> <nl> Pod : : Spec . new do | s | <nl> s . name = ' gRPC ' <nl> - version = ' 1 . 2 . 1 - pre1 ' <nl> + version = ' 1 . 2 . 1 - pre2 ' <nl> s . version = version <nl> s . summary = ' gRPC client library for iOS / OSX ' <nl> s . homepage = ' http : / / www . grpc . io ' <nl> mmm a / package . json <nl> ppp b / package . json <nl> <nl> { <nl> " name " : " grpc " , <nl> - " version " : " 1 . 2 . 1 - pre1 " , <nl> + " version " : " 1 . 2 . 1 - pre2 " , <nl> " author " : " Google Inc . " , <nl> " description " : " gRPC Library for Node " , <nl> " homepage " : " http : / / www . grpc . io / " , <nl> mmm a / package . xml <nl> ppp b / package . xml <nl> <nl> < date > 2017 - 03 - 01 < / date > <nl> < time > 16 : 06 : 07 < / time > <nl> < version > <nl> - < release > 1 . 2 . 1RC1 < / release > <nl> - < api > 1 . 2 . 1RC1 < / api > <nl> + < release > 1 . 2 . 1RC2 < / release > <nl> + < api > 1 . 2 . 1RC2 < / api > <nl> < / version > <nl> < stability > <nl> < release > beta < / release > <nl> mmm a / src / cpp / common / version_cc . cc <nl> ppp b / src / cpp / common / version_cc . cc <nl> <nl> # include < grpc + + / grpc + + . h > <nl> <nl> namespace grpc { <nl> - grpc : : string Version ( ) { return " 1 . 2 . 1 - pre1 " ; } <nl> + grpc : : string Version ( ) { return " 1 . 2 . 1 - pre2 " ; } <nl> } <nl> mmm a / src / csharp / Grpc . Auth / project . json <nl> ppp b / src / csharp / Grpc . Auth / project . json <nl> <nl> { <nl> - " version " : " 1 . 2 . 1 - pre1 " , <nl> + " version " : " 1 . 2 . 1 - pre2 " , <nl> " title " : " gRPC C # Auth " , <nl> " authors " : [ " Google Inc . " ] , <nl> " copyright " : " Copyright 2015 , Google Inc . " , <nl> <nl> } <nl> } , <nl> " dependencies " : { <nl> - " Grpc . Core " : " 1 . 2 . 1 - pre1 " , <nl> + " Grpc . Core " : " 1 . 2 . 1 - pre2 " , <nl> " Google . Apis . Auth " : " 1 . 21 . 0 " <nl> } , <nl> " frameworks " : { <nl> mmm a / src / csharp / Grpc . Core . Testing / project . json <nl> ppp b / src / csharp / Grpc . Core . Testing / project . json <nl> <nl> { <nl> - " version " : " 1 . 2 . 1 - pre1 " , <nl> + " version " : " 1 . 2 . 1 - pre2 " , <nl> " title " : " gRPC C # Core Testing " , <nl> " authors " : [ " Google Inc . " ] , <nl> " copyright " : " Copyright 2017 , Google Inc . " , <nl> <nl> } <nl> } , <nl> " dependencies " : { <nl> - " Grpc . Core " : " 1 . 2 . 1 - pre1 " <nl> + " Grpc . Core " : " 1 . 2 . 1 - pre2 " <nl> } , <nl> " frameworks " : { <nl> " net45 " : { <nl> mmm a / src / csharp / Grpc . Core / VersionInfo . cs <nl> ppp b / src / csharp / Grpc . Core / VersionInfo . cs <nl> public static class VersionInfo <nl> / / / < summary > <nl> / / / Current version of gRPC C # <nl> / / / < / summary > <nl> - public const string CurrentVersion = " 1 . 2 . 1 - pre1 " ; <nl> + public const string CurrentVersion = " 1 . 2 . 1 - pre2 " ; <nl> } <nl> } <nl> mmm a / src / csharp / Grpc . Core / project . json <nl> ppp b / src / csharp / Grpc . Core / project . json <nl> <nl> { <nl> - " version " : " 1 . 2 . 1 - pre1 " , <nl> + " version " : " 1 . 2 . 1 - pre2 " , <nl> " title " : " gRPC C # Core " , <nl> " authors " : [ " Google Inc . " ] , <nl> " copyright " : " Copyright 2015 , Google Inc . " , <nl> mmm a / src / csharp / Grpc . HealthCheck / project . json <nl> ppp b / src / csharp / Grpc . HealthCheck / project . json <nl> <nl> { <nl> - " version " : " 1 . 2 . 1 - pre1 " , <nl> + " version " : " 1 . 2 . 1 - pre2 " , <nl> " title " : " gRPC C # Healthchecking " , <nl> " authors " : [ " Google Inc . " ] , <nl> " copyright " : " Copyright 2015 , Google Inc . " , <nl> <nl> } <nl> } , <nl> " dependencies " : { <nl> - " Grpc . Core " : " 1 . 2 . 1 - pre1 " , <nl> + " Grpc . Core " : " 1 . 2 . 1 - pre2 " , <nl> " Google . Protobuf " : " 3 . 2 . 0 " <nl> } , <nl> " frameworks " : { <nl> mmm a / src / csharp / Grpc . Reflection / project . json <nl> ppp b / src / csharp / Grpc . Reflection / project . json <nl> <nl> { <nl> - " version " : " 1 . 2 . 1 - pre1 " , <nl> + " version " : " 1 . 2 . 1 - pre2 " , <nl> " title " : " gRPC C # Reflection " , <nl> " authors " : [ " Google Inc . " ] , <nl> " copyright " : " Copyright 2016 , Google Inc . " , <nl> <nl> } <nl> } , <nl> " dependencies " : { <nl> - " Grpc . Core " : " 1 . 2 . 1 - pre1 " , <nl> + " Grpc . Core " : " 1 . 2 . 1 - pre2 " , <nl> " Google . Protobuf " : " 3 . 2 . 0 " <nl> } , <nl> " frameworks " : { <nl> mmm a / src / csharp / build_packages_dotnetcli . bat <nl> ppp b / src / csharp / build_packages_dotnetcli . bat <nl> <nl> @ rem OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> <nl> @ rem Current package versions <nl> - set VERSION = 1 . 2 . 1 - pre1 <nl> + set VERSION = 1 . 2 . 1 - pre2 <nl> set PROTOBUF_VERSION = 3 . 0 . 0 <nl> <nl> @ rem Adjust the location of nuget . exe <nl> mmm a / src / csharp / build_packages_dotnetcli . sh <nl> ppp b / src / csharp / build_packages_dotnetcli . sh <nl> dotnet pack - - configuration Release Grpc . Auth / project . json - - output . . / . . / artifa <nl> dotnet pack - - configuration Release Grpc . HealthCheck / project . json - - output . . / . . / artifacts <nl> dotnet pack - - configuration Release Grpc . Reflection / project . json - - output . . / . . / artifacts <nl> <nl> - nuget pack Grpc . nuspec - Version " 1 . 2 . 1 - pre1 " - OutputDirectory . . / . . / artifacts <nl> - nuget pack Grpc . Tools . nuspec - Version " 1 . 2 . 1 - pre1 " - OutputDirectory . . / . . / artifacts <nl> + nuget pack Grpc . nuspec - Version " 1 . 2 . 1 - pre2 " - OutputDirectory . . / . . / artifacts <nl> + nuget pack Grpc . Tools . nuspec - Version " 1 . 2 . 1 - pre2 " - OutputDirectory . . / . . / artifacts <nl> <nl> ( cd . . / . . / artifacts & & zip csharp_nugets_dotnetcli . zip * . nupkg ) <nl> mmm a / src / node / health_check / package . json <nl> ppp b / src / node / health_check / package . json <nl> <nl> { <nl> " name " : " grpc - health - check " , <nl> - " version " : " 1 . 2 . 1 - pre1 " , <nl> + " version " : " 1 . 2 . 1 - pre2 " , <nl> " author " : " Google Inc . " , <nl> " description " : " Health check service for use with gRPC " , <nl> " repository " : { <nl> <nl> } <nl> ] , <nl> " dependencies " : { <nl> - " grpc " : " ^ 1 . 2 . 1 - pre1 " , <nl> + " grpc " : " ^ 1 . 2 . 1 - pre2 " , <nl> " lodash " : " ^ 3 . 9 . 3 " , <nl> " google - protobuf " : " ^ 3 . 0 . 0 " <nl> } , <nl> mmm a / src / node / tools / package . json <nl> ppp b / src / node / tools / package . json <nl> <nl> { <nl> " name " : " grpc - tools " , <nl> - " version " : " 1 . 2 . 1 - pre1 " , <nl> + " version " : " 1 . 2 . 1 - pre2 " , <nl> " author " : " Google Inc . " , <nl> " description " : " Tools for developing with gRPC on Node . js " , <nl> " homepage " : " http : / / www . grpc . io / " , <nl> mmm a / src / objective - c / ! ProtoCompiler - gRPCPlugin . podspec <nl> ppp b / src / objective - c / ! ProtoCompiler - gRPCPlugin . podspec <nl> Pod : : Spec . new do | s | <nl> # exclamation mark ensures that other " regular " pods will be able to find it as it ' ll be installed <nl> # before them . <nl> s . name = ' ! ProtoCompiler - gRPCPlugin ' <nl> - v = ' 1 . 2 . 1 - pre1 ' <nl> + v = ' 1 . 2 . 1 - pre2 ' <nl> s . version = v <nl> s . summary = ' The gRPC ProtoC plugin generates Objective - C files from . proto services . ' <nl> s . description = < < - DESC <nl> mmm a / src / objective - c / GRPCClient / private / version . h <nl> ppp b / src / objective - c / GRPCClient / private / version . h <nl> <nl> / / ` tools / buildgen / generate_projects . sh ` . <nl> <nl> <nl> - # define GRPC_OBJC_VERSION_STRING @ " 1 . 2 . 1 - pre1 " <nl> + # define GRPC_OBJC_VERSION_STRING @ " 1 . 2 . 1 - pre2 " <nl> mmm a / src / python / grpcio / grpc_version . py <nl> ppp b / src / python / grpcio / grpc_version . py <nl> <nl> <nl> # AUTO - GENERATED FROM ` $ REPO_ROOT / templates / src / python / grpcio / grpc_version . py . template ` ! ! ! <nl> <nl> - VERSION = ' 1 . 2 . 1rc1 ' <nl> + VERSION = ' 1 . 2 . 1rc2 ' <nl> mmm a / src / python / grpcio_health_checking / grpc_version . py <nl> ppp b / src / python / grpcio_health_checking / grpc_version . py <nl> <nl> <nl> # AUTO - GENERATED FROM ` $ REPO_ROOT / templates / src / python / grpcio_health_checking / grpc_version . py . template ` ! ! ! <nl> <nl> - VERSION = ' 1 . 2 . 1rc1 ' <nl> + VERSION = ' 1 . 2 . 1rc2 ' <nl> mmm a / src / python / grpcio_reflection / grpc_version . py <nl> ppp b / src / python / grpcio_reflection / grpc_version . py <nl> <nl> <nl> # AUTO - GENERATED FROM ` $ REPO_ROOT / templates / src / python / grpcio_reflection / grpc_version . py . template ` ! ! ! <nl> <nl> - VERSION = ' 1 . 2 . 1rc1 ' <nl> + VERSION = ' 1 . 2 . 1rc2 ' <nl> mmm a / src / python / grpcio_tests / grpc_version . py <nl> ppp b / src / python / grpcio_tests / grpc_version . py <nl> <nl> <nl> # AUTO - GENERATED FROM ` $ REPO_ROOT / templates / src / python / grpcio_tests / grpc_version . py . template ` ! ! ! <nl> <nl> - VERSION = ' 1 . 2 . 1rc1 ' <nl> + VERSION = ' 1 . 2 . 1rc2 ' <nl> mmm a / src / ruby / lib / grpc / version . rb <nl> ppp b / src / ruby / lib / grpc / version . rb <nl> <nl> <nl> # GRPC contains the General RPC module . <nl> module GRPC <nl> - VERSION = ' 1 . 2 . 1 . pre1 ' <nl> + VERSION = ' 1 . 2 . 1 . pre2 ' <nl> end <nl> mmm a / src / ruby / tools / version . rb <nl> ppp b / src / ruby / tools / version . rb <nl> <nl> <nl> module GRPC <nl> module Tools <nl> - VERSION = ' 1 . 2 . 1 . pre1 ' <nl> + VERSION = ' 1 . 2 . 1 . pre2 ' <nl> end <nl> end <nl> mmm a / tools / distrib / python / grpcio_tools / grpc_version . py <nl> ppp b / tools / distrib / python / grpcio_tools / grpc_version . py <nl> <nl> <nl> # AUTO - GENERATED FROM ` $ REPO_ROOT / templates / tools / distrib / python / grpcio_tools / grpc_version . py . template ` ! ! ! <nl> <nl> - VERSION = ' 1 . 2 . 1rc1 ' <nl> + VERSION = ' 1 . 2 . 1rc2 ' <nl> mmm a / tools / doxygen / Doxyfile . c + + <nl> ppp b / tools / doxygen / Doxyfile . c + + <nl> PROJECT_NAME = " GRPC C + + " <nl> # could be handy for archiving the generated documentation or if some version <nl> # control system is used . <nl> <nl> - PROJECT_NUMBER = 1 . 2 . 1 - pre1 <nl> + PROJECT_NUMBER = 1 . 2 . 1 - pre2 <nl> <nl> # Using the PROJECT_BRIEF tag one can provide an optional one line description <nl> # for a project that appears at the top of each page and should give viewer a <nl> mmm a / tools / doxygen / Doxyfile . c + + . internal <nl> ppp b / tools / doxygen / Doxyfile . c + + . internal <nl> PROJECT_NAME = " GRPC C + + " <nl> # could be handy for archiving the generated documentation or if some version <nl> # control system is used . <nl> <nl> - PROJECT_NUMBER = 1 . 2 . 1 - pre1 <nl> + PROJECT_NUMBER = 1 . 2 . 1 - pre2 <nl> <nl> # Using the PROJECT_BRIEF tag one can provide an optional one line description <nl> # for a project that appears at the top of each page and should give viewer a <nl>
Merge pull request from apolcyn / bump_v12x_version
grpc/grpc
486f8d9ee8b17792a911e3d0ccd767e517b4c7e9
2017-03-27T16:13:06Z
mmm a / src / treelearner / serial_tree_learner . cpp <nl> ppp b / src / treelearner / serial_tree_learner . cpp <nl> void SerialTreeLearner : : FindBestThresholds ( ) { <nl> smaller_leaf_splits_ - > sum_gradients ( ) , smaller_leaf_splits_ - > sum_hessians ( ) , <nl> smaller_leaf_splits_ - > num_data_in_leaf ( ) , <nl> smaller_leaf_histogram_array_ [ feature_index ] . RawData ( ) ) ; <nl> - <nl> + int real_fidx = train_data_ - > RealFeatureIndex ( feature_index ) ; <nl> smaller_leaf_histogram_array_ [ feature_index ] . FindBestThreshold ( <nl> smaller_leaf_splits_ - > sum_gradients ( ) , <nl> smaller_leaf_splits_ - > sum_hessians ( ) , <nl> smaller_leaf_splits_ - > num_data_in_leaf ( ) , <nl> & smaller_split ) ; <nl> - if ( smaller_split . gain > smaller_best [ tid ] . gain ) { <nl> + smaller_split . feature = real_fidx ; <nl> + if ( smaller_split > smaller_best [ tid ] ) { <nl> smaller_best [ tid ] = smaller_split ; <nl> - smaller_best [ tid ] . feature = train_data_ - > RealFeatureIndex ( feature_index ) ; <nl> } <nl> / / only has root leaf <nl> if ( larger_leaf_splits_ = = nullptr | | larger_leaf_splits_ - > LeafIndex ( ) < 0 ) { continue ; } <nl> void SerialTreeLearner : : FindBestThresholds ( ) { <nl> larger_leaf_splits_ - > sum_hessians ( ) , <nl> larger_leaf_splits_ - > num_data_in_leaf ( ) , <nl> & larger_split ) ; <nl> - if ( larger_split . gain > larger_best [ tid ] . gain ) { <nl> + larger_split . feature = real_fidx ; <nl> + if ( larger_split > larger_best [ tid ] ) { <nl> larger_best [ tid ] = larger_split ; <nl> - larger_best [ tid ] . feature = train_data_ - > RealFeatureIndex ( feature_index ) ; <nl> - } <nl> + } <nl> OMP_LOOP_EX_END ( ) ; <nl> } <nl> OMP_THROW_EX ( ) ; <nl>
better reproducible across different compilers .
microsoft/LightGBM
7517eefaf2f7624462ae1d988b206428e5d0c24b
2017-05-29T02:56:08Z
new file mode 100644 <nl> index 0000000000 . . e11b56afd3 <nl> mmm / dev / null <nl> ppp b / code / bit - manipulation / lonely_integer / lonelyInteger . py <nl> <nl> + ' ' ' <nl> + Part of Cosmos by OpenGenus Foundation <nl> + The Lonely Integer Problem <nl> + Given an array in which all the no . are present twice except one , find that lonely integer . <nl> + ' ' ' <nl> + <nl> + def LonelyInteger ( a ) : <nl> + lonely = 0 <nl> + # finds the xor sum of the array . <nl> + for i in a : <nl> + lonely ^ = i <nl> + return lonely <nl> + <nl> + a = [ 2 , 3 , 4 , 5 , 3 , 2 , 4 ] <nl> + print ( LonelyInteger ( a ) ) <nl>
Added python code for Lonely Integer Problem
OpenGenus/cosmos
42cafdbec24d51fb207e16f83da08703c98fec7e
2017-10-03T15:04:12Z
mmm a / ports / jsoncpp / portfile . cmake <nl> ppp b / ports / jsoncpp / portfile . cmake <nl> vcpkg_download_distfile ( ARCHIVE <nl> ) <nl> vcpkg_extract_source_archive ( $ { ARCHIVE } ) <nl> <nl> + if ( VCPKG_LIBRARY_LINKAGE STREQUAL dynamic ) <nl> + set ( JSONCPP_STATIC OFF ) <nl> + set ( JSONCPP_DYNAMIC ON ) <nl> + else ( ) <nl> + set ( JSONCPP_STATIC ON ) <nl> + set ( JSONCPP_DYNAMIC OFF ) <nl> + endif ( ) <nl> + <nl> vcpkg_configure_cmake ( <nl> SOURCE_PATH $ { SOURCE_PATH } <nl> OPTIONS - DJSONCPP_WITH_CMAKE_PACKAGE : BOOL = ON <nl> - - DBUILD_STATIC_LIBS : BOOL = OFF <nl> - - DBUILD_SHARED_LIBS : BOOL = ON <nl> + - DBUILD_STATIC_LIBS : BOOL = $ { JSONCPP_STATIC } <nl> + - DBUILD_SHARED_LIBS : BOOL = $ { JSONCPP_DYNAMIC } <nl> ) <nl> <nl> vcpkg_install_cmake ( ) <nl>
[ jsoncpp ] Enable static linking
microsoft/vcpkg
4953992865d70341fe31dfbcc2a8a3453aedbb42
2016-11-16T21:13:08Z
mmm a / src / MainWindow . cpp <nl> ppp b / src / MainWindow . cpp <nl> void MainWindow : : populateTable ( ) <nl> <nl> QApplication : : setOverrideCursor ( Qt : : WaitCursor ) ; <nl> <nl> + / / Restore default value that could have been modified in updateFilter or browseTableHeaderClicked <nl> + ui - > dataTable - > verticalHeader ( ) - > setMinimumWidth ( 0 ) ; <nl> + <nl> / / Get current table name <nl> sqlb : : ObjectIdentifier tablename = currentlyBrowsedTableName ( ) ; <nl> <nl> void MainWindow : : browseTableHeaderClicked ( int logicalindex ) <nl> return ; <nl> } <nl> <nl> + / / Set minimum width to the vertical header in order to avoid flickering when sorting . <nl> + ui - > dataTable - > verticalHeader ( ) - > setMinimumWidth ( ui - > dataTable - > verticalHeader ( ) - > width ( ) ) ; <nl> + <nl> / / Get the current list of sort columns <nl> auto & columns = settings . query . orderBy ( ) ; <nl> <nl> void MainWindow : : fileAttach ( ) <nl> <nl> void MainWindow : : updateFilter ( int column , const QString & value ) <nl> { <nl> + / / Set minimum width to the vertical header in order to avoid flickering while a filter is being updated . <nl> + ui - > dataTable - > verticalHeader ( ) - > setMinimumWidth ( ui - > dataTable - > verticalHeader ( ) - > width ( ) ) ; <nl> + <nl> m_browseTableModel - > updateFilter ( column , value ) ; <nl> BrowseDataTableSettings & settings = browseTableSettings [ currentlyBrowsedTableName ( ) ] ; <nl> if ( value . isEmpty ( ) ) <nl>
Avoid flickering while sorting or filtering
sqlitebrowser/sqlitebrowser
32efd8f19f9cf4c472e476c766e3223b500f6a20
2019-08-03T23:11:13Z
mmm a / build / fbcode_builder / getdeps . py <nl> ppp b / build / fbcode_builder / getdeps . py <nl> <nl> from getdeps . buildopts import setup_build_options <nl> from getdeps . dyndeps import create_dyn_dep_munger <nl> from getdeps . errors import TransientFailure <nl> - from getdeps . fetcher import SystemPackageFetcher <nl> + from getdeps . fetcher import ( <nl> + SystemPackageFetcher , <nl> + file_name_is_cmake_file , <nl> + list_files_under_dir_newer_than_timestamp , <nl> + ) <nl> from getdeps . load import ManifestLoader <nl> from getdeps . manifest import ManifestParser <nl> from getdeps . platform import HostType <nl> def run_project_cmd ( self , args , loader , manifest ) : <nl> cached_project , fetcher , m , built_marker , project_hash <nl> ) <nl> <nl> + if os . path . exists ( built_marker ) : <nl> + # We ' ve previously built this . We may need to reconfigure if <nl> + # our deps have changed , so let ' s check them . <nl> + dep_reconfigure , dep_build = self . compute_dep_change_status ( <nl> + m , built_marker , loader <nl> + ) <nl> + if dep_reconfigure : <nl> + reconfigure = True <nl> + if dep_build : <nl> + sources_changed = True <nl> + <nl> if sources_changed or reconfigure or not os . path . exists ( built_marker ) : <nl> if os . path . exists ( built_marker ) : <nl> os . unlink ( built_marker ) <nl> def run_project_cmd ( self , args , loader , manifest ) : <nl> <nl> install_dirs . append ( inst_dir ) <nl> <nl> + def compute_dep_change_status ( self , m , built_marker , loader ) : <nl> + reconfigure = False <nl> + sources_changed = False <nl> + st = os . lstat ( built_marker ) <nl> + <nl> + ctx = loader . ctx_gen . get_context ( m . name ) <nl> + dep_list = sorted ( m . get_section_as_dict ( " dependencies " , ctx ) . keys ( ) ) <nl> + for dep in dep_list : <nl> + if reconfigure and sources_changed : <nl> + break <nl> + <nl> + dep_manifest = loader . load_manifest ( dep ) <nl> + dep_root = loader . get_project_install_dir ( dep_manifest ) <nl> + for dep_file in list_files_under_dir_newer_than_timestamp ( <nl> + dep_root , st . st_mtime <nl> + ) : <nl> + if os . path . basename ( dep_file ) = = " . built - by - getdeps " : <nl> + continue <nl> + if file_name_is_cmake_file ( dep_file ) : <nl> + if not reconfigure : <nl> + reconfigure = True <nl> + print ( <nl> + f " Will reconfigure cmake because { dep_file } is newer than { built_marker } " <nl> + ) <nl> + else : <nl> + if not sources_changed : <nl> + sources_changed = True <nl> + print ( <nl> + f " Will run build because { dep_file } is newer than { built_marker } " <nl> + ) <nl> + <nl> + if reconfigure and sources_changed : <nl> + break <nl> + <nl> + return reconfigure , sources_changed <nl> + <nl> def compute_source_change_status ( <nl> self , cached_project , fetcher , m , built_marker , project_hash <nl> ) : <nl> mmm a / build / fbcode_builder / getdeps / fetcher . py <nl> ppp b / build / fbcode_builder / getdeps / fetcher . py <nl> def copy_if_different ( src_name , dest_name ) : <nl> return True <nl> <nl> <nl> + def list_files_under_dir_newer_than_timestamp ( dir_to_scan , ts ) : <nl> + for root , _dirs , files in os . walk ( dir_to_scan ) : <nl> + for src_file in files : <nl> + full_name = os . path . join ( root , src_file ) <nl> + st = os . lstat ( full_name ) <nl> + if st . st_mtime > ts : <nl> + yield full_name <nl> + <nl> + <nl> class ShipitPathMap ( object ) : <nl> def __init__ ( self ) : <nl> self . roots = [ ] <nl>
getdeps : improve build invalidation for dependencies
facebook/watchman
73f4b2fa5b78731ed667394d2aa2cc336044c82b
2020-05-05T00:44:40Z
mmm a / lib / SILOptimizer / Analysis / EscapeAnalysis . cpp <nl> ppp b / lib / SILOptimizer / Analysis / EscapeAnalysis . cpp <nl> void EscapeAnalysis : : analyzeInstruction ( SILInstruction * I , <nl> ConGraph - > setNode ( TEI , ArrayElements ) ; <nl> return ; <nl> } <nl> - case SILInstructionKind : : UncheckedRefCastInst : <nl> - case SILInstructionKind : : ConvertFunctionInst : <nl> - case SILInstructionKind : : UpcastInst : <nl> - case SILInstructionKind : : InitExistentialRefInst : <nl> - case SILInstructionKind : : OpenExistentialRefInst : <nl> - case SILInstructionKind : : RawPointerToRefInst : <nl> - case SILInstructionKind : : RefToRawPointerInst : <nl> - case SILInstructionKind : : RefToBridgeObjectInst : <nl> - case SILInstructionKind : : BridgeObjectToRefInst : <nl> - case SILInstructionKind : : UncheckedAddrCastInst : <nl> - case SILInstructionKind : : UnconditionalCheckedCastInst : <nl> - / / DO NOT use LOADABLE_REF_STORAGE because unchecked references don ' t have <nl> - / / retain / release instructions that trigger the ' default ' case . <nl> - # define ALWAYS_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE ( Name , . . . ) \ <nl> - case SILInstructionKind : : RefTo # # Name # # Inst : \ <nl> - case SILInstructionKind : : Name # # ToRefInst : <nl> - # include " swift / AST / ReferenceStorage . def " <nl> - / / A cast is almost like a projection . <nl> - if ( CGNode * OpNode = ConGraph - > getNode ( I - > getOperand ( 0 ) ) ) { <nl> - ConGraph - > setNode ( cast < SingleValueInstruction > ( I ) , OpNode ) ; <nl> - } <nl> - break ; <nl> case SILInstructionKind : : UncheckedRefCastAddrInst : { <nl> auto * URCAI = cast < UncheckedRefCastAddrInst > ( I ) ; <nl> CGNode * SrcNode = ConGraph - > getNode ( URCAI - > getSrc ( ) ) ; <nl> mmm a / test / SILOptimizer / unsafebufferpointer . swift <nl> ppp b / test / SILOptimizer / unsafebufferpointer . swift <nl> public func testIteration ( _ p : UnsafeBufferPointer < Int > ) - > Int { <nl> / / Check for an optimal loop kernel <nl> / / CHECK : phi <nl> / / CHECK - NEXT : phi <nl> - / / CHECK - NEXT : getelementptr <nl> / / CHECK - NEXT : bitcast <nl> / / CHECK - NEXT : load <nl> + / / CHECK - NEXT : getelementptr <nl> / / CHECK - NEXT : add <nl> / / CHECK - NEXT : icmp <nl> / / CHECK - NEXT : br <nl>
EscapeAnalysis : remove unused cast handling from the main loop .
apple/swift
cb1e787f50614e41a8072f28dcf95f9894d16895
2019-11-06T23:15:39Z
new file mode 100644 <nl> index 00000000 . . 873bd600 <nl> mmm / dev / null <nl> ppp b / vrclient_x64 / openvr_v1 . 12 . 5 / ivrclientcore . h <nl> <nl> + / / = = = = = = = = = Copyright Valve Corporation = = = = = = = = = = = = / / <nl> + # include " openvr . h " <nl> + <nl> + namespace vr <nl> + { <nl> + <nl> + class IVRClientCore <nl> + { <nl> + public : <nl> + / * * Initializes the system * / <nl> + virtual EVRInitError Init ( vr : : EVRApplicationType eApplicationType , const char * pStartupInfo ) = 0 ; <nl> + <nl> + / * * cleans up everything in vrclient . dll and prepares the DLL to be unloaded * / <nl> + virtual void Cleanup ( ) = 0 ; <nl> + <nl> + / * * checks to see if the specified interface / version is supported in this vrclient . dll * / <nl> + virtual EVRInitError IsInterfaceVersionValid ( const char * pchInterfaceVersion ) = 0 ; <nl> + <nl> + / * * Retrieves any interface from vrclient . dll * / <nl> + virtual void * GetGenericInterface ( const char * pchNameAndVersion , EVRInitError * peError ) = 0 ; <nl> + <nl> + / * * Returns true if any driver has an HMD attached . Can be called outside of Init / Cleanup * / <nl> + virtual bool BIsHmdPresent ( ) = 0 ; <nl> + <nl> + / * * Returns an English error string from inside vrclient . dll which might be newer than the API DLL * / <nl> + virtual const char * GetEnglishStringForHmdError ( vr : : EVRInitError eError ) = 0 ; <nl> + <nl> + / * * Returns an error symbol from inside vrclient . dll which might be newer than the API DLL * / <nl> + virtual const char * GetIDForVRInitError ( vr : : EVRInitError eError ) = 0 ; <nl> + } ; <nl> + <nl> + static const char * const IVRClientCore_Version = " IVRClientCore_003 " ; <nl> + <nl> + <nl> + } <nl> new file mode 100644 <nl> index 00000000 . . 580967ed <nl> mmm / dev / null <nl> ppp b / vrclient_x64 / openvr_v1 . 12 . 5 / openvr . h <nl> <nl> + <nl> + / / openvr . h <nl> + / / = = = = = = = = = Copyright Valve Corporation = = = = = = = = = = = = / / <nl> + / / Dynamically generated file . Do not modify this file directly . <nl> + <nl> + # ifndef _OPENVR_API <nl> + # define _OPENVR_API <nl> + <nl> + # include < stdint . h > <nl> + <nl> + <nl> + <nl> + / / version . h <nl> + namespace vr <nl> + { <nl> + static const uint32_t k_nSteamVRVersionMajor = 1 ; <nl> + static const uint32_t k_nSteamVRVersionMinor = 12 ; <nl> + static const uint32_t k_nSteamVRVersionBuild = 5 ; <nl> + } / / namespace vr <nl> + <nl> + / / vrtypes . h <nl> + # ifndef _INCLUDE_VRTYPES_H <nl> + # define _INCLUDE_VRTYPES_H <nl> + <nl> + / / Forward declarations to avoid requiring vulkan . h <nl> + struct VkDevice_T ; <nl> + struct VkPhysicalDevice_T ; <nl> + struct VkInstance_T ; <nl> + struct VkQueue_T ; <nl> + <nl> + / / Forward declarations to avoid requiring d3d12 . h <nl> + struct ID3D12Resource ; <nl> + struct ID3D12CommandQueue ; <nl> + <nl> + namespace vr <nl> + { <nl> + # pragma pack ( push , 8 ) <nl> + <nl> + / * * A handle for a spatial anchor . This handle is only valid during the session it was created in . <nl> + * Anchors that live beyond one session should be saved by their string descriptors . * / <nl> + typedef uint32_t SpatialAnchorHandle_t ; <nl> + <nl> + typedef void * glSharedTextureHandle_t ; <nl> + typedef int32_t glInt_t ; <nl> + typedef uint32_t glUInt_t ; <nl> + <nl> + / / right - handed system <nl> + / / + y is up <nl> + / / + x is to the right <nl> + / / - z is forward <nl> + / / Distance unit is meters <nl> + struct HmdMatrix34_t <nl> + { <nl> + float m [ 3 ] [ 4 ] ; <nl> + } ; <nl> + <nl> + struct HmdMatrix33_t <nl> + { <nl> + float m [ 3 ] [ 3 ] ; <nl> + } ; <nl> + <nl> + struct HmdMatrix44_t <nl> + { <nl> + float m [ 4 ] [ 4 ] ; <nl> + } ; <nl> + <nl> + struct HmdVector3_t <nl> + { <nl> + float v [ 3 ] ; <nl> + } ; <nl> + <nl> + struct HmdVector4_t <nl> + { <nl> + float v [ 4 ] ; <nl> + } ; <nl> + <nl> + struct HmdVector3d_t <nl> + { <nl> + double v [ 3 ] ; <nl> + } ; <nl> + <nl> + struct HmdVector2_t <nl> + { <nl> + float v [ 2 ] ; <nl> + } ; <nl> + <nl> + struct HmdQuaternion_t <nl> + { <nl> + double w , x , y , z ; <nl> + } ; <nl> + <nl> + struct HmdQuaternionf_t <nl> + { <nl> + float w , x , y , z ; <nl> + } ; <nl> + <nl> + struct HmdColor_t <nl> + { <nl> + float r , g , b , a ; <nl> + } ; <nl> + <nl> + struct HmdQuad_t <nl> + { <nl> + HmdVector3_t vCorners [ 4 ] ; <nl> + } ; <nl> + <nl> + struct HmdRect2_t <nl> + { <nl> + HmdVector2_t vTopLeft ; <nl> + HmdVector2_t vBottomRight ; <nl> + } ; <nl> + <nl> + / * * Used to return the post - distortion UVs for each color channel . <nl> + * UVs range from 0 to 1 with 0 , 0 in the upper left corner of the <nl> + * source render target . The 0 , 0 to 1 , 1 range covers a single eye . * / <nl> + struct DistortionCoordinates_t <nl> + { <nl> + float rfRed [ 2 ] ; <nl> + float rfGreen [ 2 ] ; <nl> + float rfBlue [ 2 ] ; <nl> + } ; <nl> + <nl> + enum EVREye <nl> + { <nl> + Eye_Left = 0 , <nl> + Eye_Right = 1 <nl> + } ; <nl> + <nl> + enum ETextureType <nl> + { <nl> + TextureType_Invalid = - 1 , / / Handle has been invalidated <nl> + TextureType_DirectX = 0 , / / Handle is an ID3D11Texture <nl> + TextureType_OpenGL = 1 , / / Handle is an OpenGL texture name or an OpenGL render buffer name , depending on submit flags <nl> + TextureType_Vulkan = 2 , / / Handle is a pointer to a VRVulkanTextureData_t structure <nl> + TextureType_IOSurface = 3 , / / Handle is a macOS cross - process - sharable IOSurfaceRef , deprecated in favor of TextureType_Metal on supported platforms <nl> + TextureType_DirectX12 = 4 , / / Handle is a pointer to a D3D12TextureData_t structure <nl> + TextureType_DXGISharedHandle = 5 , / / Handle is a HANDLE DXGI share handle , only supported for Overlay render targets . <nl> + / / this texture is used directly by our renderer , so only perform atomic ( copyresource or resolve ) on it <nl> + TextureType_Metal = 6 , / / Handle is a MTLTexture conforming to the MTLSharedTexture protocol . Textures submitted to IVRCompositor : : Submit which <nl> + / / are of type MTLTextureType2DArray assume layer 0 is the left eye texture ( vr : : EVREye : : Eye_left ) , layer 1 is the right <nl> + / / eye texture ( vr : : EVREye : : Eye_Right ) <nl> + } ; <nl> + <nl> + enum EColorSpace <nl> + { <nl> + ColorSpace_Auto = 0 , / / Assumes ' gamma ' for 8 - bit per component formats , otherwise ' linear ' . This mirrors the DXGI formats which have _SRGB variants . <nl> + ColorSpace_Gamma = 1 , / / Texture data can be displayed directly on the display without any conversion ( a . k . a . display native format ) . <nl> + ColorSpace_Linear = 2 , / / Same as gamma but has been converted to a linear representation using DXGI ' s sRGB conversion algorithm . <nl> + } ; <nl> + <nl> + struct Texture_t <nl> + { <nl> + void * handle ; / / See ETextureType definition above <nl> + ETextureType eType ; <nl> + EColorSpace eColorSpace ; <nl> + } ; <nl> + <nl> + / / Handle to a shared texture ( HANDLE on Windows obtained using OpenSharedResource ) . <nl> + typedef uint64_t SharedTextureHandle_t ; <nl> + # define INVALID_SHARED_TEXTURE_HANDLE ( ( vr : : SharedTextureHandle_t ) 0 ) <nl> + <nl> + enum ETrackingResult <nl> + { <nl> + TrackingResult_Uninitialized = 1 , <nl> + <nl> + TrackingResult_Calibrating_InProgress = 100 , <nl> + TrackingResult_Calibrating_OutOfRange = 101 , <nl> + <nl> + TrackingResult_Running_OK = 200 , <nl> + TrackingResult_Running_OutOfRange = 201 , <nl> + <nl> + TrackingResult_Fallback_RotationOnly = 300 , <nl> + } ; <nl> + <nl> + typedef uint32_t DriverId_t ; <nl> + static const uint32_t k_nDriverNone = 0xFFFFFFFF ; <nl> + <nl> + static const uint32_t k_unMaxDriverDebugResponseSize = 32768 ; <nl> + <nl> + / * * Used to pass device IDs to API calls * / <nl> + typedef uint32_t TrackedDeviceIndex_t ; <nl> + static const uint32_t k_unTrackedDeviceIndex_Hmd = 0 ; <nl> + static const uint32_t k_unMaxTrackedDeviceCount = 64 ; <nl> + static const uint32_t k_unTrackedDeviceIndexOther = 0xFFFFFFFE ; <nl> + static const uint32_t k_unTrackedDeviceIndexInvalid = 0xFFFFFFFF ; <nl> + <nl> + / * * Describes what kind of object is being tracked at a given ID * / <nl> + enum ETrackedDeviceClass <nl> + { <nl> + TrackedDeviceClass_Invalid = 0 , / / the ID was not valid . <nl> + TrackedDeviceClass_HMD = 1 , / / Head - Mounted Displays <nl> + TrackedDeviceClass_Controller = 2 , / / Tracked controllers <nl> + TrackedDeviceClass_GenericTracker = 3 , / / Generic trackers , similar to controllers <nl> + TrackedDeviceClass_TrackingReference = 4 , / / Camera and base stations that serve as tracking reference points <nl> + TrackedDeviceClass_DisplayRedirect = 5 , / / Accessories that aren ' t necessarily tracked themselves , but may redirect video output from other tracked devices <nl> + <nl> + TrackedDeviceClass_Max <nl> + } ; <nl> + <nl> + <nl> + / * * Describes what specific role associated with a tracked device * / <nl> + enum ETrackedControllerRole <nl> + { <nl> + TrackedControllerRole_Invalid = 0 , / / Invalid value for controller type <nl> + TrackedControllerRole_LeftHand = 1 , / / Tracked device associated with the left hand <nl> + TrackedControllerRole_RightHand = 2 , / / Tracked device associated with the right hand <nl> + TrackedControllerRole_OptOut = 3 , / / Tracked device is opting out of left / right hand selection <nl> + TrackedControllerRole_Treadmill = 4 , / / Tracked device is a treadmill or other locomotion device <nl> + TrackedControllerRole_Stylus = 5 , / / Tracked device is a stylus <nl> + TrackedControllerRole_Max = 5 <nl> + } ; <nl> + <nl> + <nl> + / * * Returns true if the tracked controller role is allowed to be a hand * / <nl> + inline bool IsRoleAllowedAsHand ( ETrackedControllerRole eRole ) <nl> + { <nl> + switch ( eRole ) <nl> + { <nl> + case TrackedControllerRole_Invalid : <nl> + case TrackedControllerRole_LeftHand : <nl> + case TrackedControllerRole_RightHand : <nl> + return true ; <nl> + default : <nl> + return false ; <nl> + } <nl> + } <nl> + <nl> + <nl> + / * * describes a single pose for a tracked object * / <nl> + struct TrackedDevicePose_t <nl> + { <nl> + HmdMatrix34_t mDeviceToAbsoluteTracking ; <nl> + HmdVector3_t vVelocity ; / / velocity in tracker space in m / s <nl> + HmdVector3_t vAngularVelocity ; / / angular velocity in radians / s ( ? ) <nl> + ETrackingResult eTrackingResult ; <nl> + bool bPoseIsValid ; <nl> + <nl> + / / This indicates that there is a device connected for this spot in the pose array . <nl> + / / It could go from true to false if the user unplugs the device . <nl> + bool bDeviceIsConnected ; <nl> + } ; <nl> + <nl> + / * * Identifies which style of tracking origin the application wants to use <nl> + * for the poses it is requesting * / <nl> + enum ETrackingUniverseOrigin <nl> + { <nl> + TrackingUniverseSeated = 0 , / / Poses are provided relative to the seated zero pose <nl> + TrackingUniverseStanding = 1 , / / Poses are provided relative to the safe bounds configured by the user <nl> + TrackingUniverseRawAndUncalibrated = 2 , / / Poses are provided in the coordinate system defined by the driver . It has Y up and is unified for devices of the same driver . You usually don ' t want this one . <nl> + } ; <nl> + <nl> + enum EAdditionalRadioFeatures <nl> + { <nl> + AdditionalRadioFeatures_None = 0x00000000 , <nl> + AdditionalRadioFeatures_HTCLinkBox = 0x00000001 , <nl> + AdditionalRadioFeatures_InternalDongle = 0x00000002 , <nl> + AdditionalRadioFeatures_ExternalDongle = 0x00000004 , <nl> + } ; <nl> + <nl> + typedef uint64_t WebConsoleHandle_t ; <nl> + # define INVALID_WEB_CONSOLE_HANDLE ( ( vr : : WebConsoleHandle_t ) 0 ) <nl> + <nl> + / / Refers to a single container of properties <nl> + typedef uint64_t PropertyContainerHandle_t ; <nl> + typedef uint32_t PropertyTypeTag_t ; <nl> + <nl> + static const PropertyContainerHandle_t k_ulInvalidPropertyContainer = 0 ; <nl> + static const PropertyTypeTag_t k_unInvalidPropertyTag = 0 ; <nl> + <nl> + typedef PropertyContainerHandle_t DriverHandle_t ; <nl> + static const PropertyContainerHandle_t k_ulInvalidDriverHandle = 0 ; <nl> + <nl> + / / Use these tags to set / get common types as struct properties <nl> + static const PropertyTypeTag_t k_unFloatPropertyTag = 1 ; <nl> + static const PropertyTypeTag_t k_unInt32PropertyTag = 2 ; <nl> + static const PropertyTypeTag_t k_unUint64PropertyTag = 3 ; <nl> + static const PropertyTypeTag_t k_unBoolPropertyTag = 4 ; <nl> + static const PropertyTypeTag_t k_unStringPropertyTag = 5 ; <nl> + static const PropertyTypeTag_t k_unErrorPropertyTag = 6 ; <nl> + static const PropertyTypeTag_t k_unDoublePropertyTag = 7 ; <nl> + <nl> + static const PropertyTypeTag_t k_unHmdMatrix34PropertyTag = 20 ; <nl> + static const PropertyTypeTag_t k_unHmdMatrix44PropertyTag = 21 ; <nl> + static const PropertyTypeTag_t k_unHmdVector3PropertyTag = 22 ; <nl> + static const PropertyTypeTag_t k_unHmdVector4PropertyTag = 23 ; <nl> + static const PropertyTypeTag_t k_unHmdVector2PropertyTag = 24 ; <nl> + static const PropertyTypeTag_t k_unHmdQuadPropertyTag = 25 ; <nl> + <nl> + static const PropertyTypeTag_t k_unHiddenAreaPropertyTag = 30 ; <nl> + static const PropertyTypeTag_t k_unPathHandleInfoTag = 31 ; <nl> + static const PropertyTypeTag_t k_unActionPropertyTag = 32 ; <nl> + static const PropertyTypeTag_t k_unInputValuePropertyTag = 33 ; <nl> + static const PropertyTypeTag_t k_unWildcardPropertyTag = 34 ; <nl> + static const PropertyTypeTag_t k_unHapticVibrationPropertyTag = 35 ; <nl> + static const PropertyTypeTag_t k_unSkeletonPropertyTag = 36 ; <nl> + <nl> + static const PropertyTypeTag_t k_unSpatialAnchorPosePropertyTag = 40 ; <nl> + static const PropertyTypeTag_t k_unJsonPropertyTag = 41 ; <nl> + static const PropertyTypeTag_t k_unActiveActionSetPropertyTag = 42 ; <nl> + <nl> + static const PropertyTypeTag_t k_unOpenVRInternalReserved_Start = 1000 ; <nl> + static const PropertyTypeTag_t k_unOpenVRInternalReserved_End = 10000 ; <nl> + <nl> + <nl> + / * * Each entry in this enum represents a property that can be retrieved about a <nl> + * tracked device . Many fields are only valid for one ETrackedDeviceClass . * / <nl> + enum ETrackedDeviceProperty <nl> + { <nl> + Prop_Invalid = 0 , <nl> + <nl> + / / general properties that apply to all device classes <nl> + Prop_TrackingSystemName_String = 1000 , <nl> + Prop_ModelNumber_String = 1001 , <nl> + Prop_SerialNumber_String = 1002 , <nl> + Prop_RenderModelName_String = 1003 , <nl> + Prop_WillDriftInYaw_Bool = 1004 , <nl> + Prop_ManufacturerName_String = 1005 , <nl> + Prop_TrackingFirmwareVersion_String = 1006 , <nl> + Prop_HardwareRevision_String = 1007 , <nl> + Prop_AllWirelessDongleDescriptions_String = 1008 , <nl> + Prop_ConnectedWirelessDongle_String = 1009 , <nl> + Prop_DeviceIsWireless_Bool = 1010 , <nl> + Prop_DeviceIsCharging_Bool = 1011 , <nl> + Prop_DeviceBatteryPercentage_Float = 1012 , / / 0 is empty , 1 is full <nl> + Prop_StatusDisplayTransform_Matrix34 = 1013 , <nl> + Prop_Firmware_UpdateAvailable_Bool = 1014 , <nl> + Prop_Firmware_ManualUpdate_Bool = 1015 , <nl> + Prop_Firmware_ManualUpdateURL_String = 1016 , <nl> + Prop_HardwareRevision_Uint64 = 1017 , <nl> + Prop_FirmwareVersion_Uint64 = 1018 , <nl> + Prop_FPGAVersion_Uint64 = 1019 , <nl> + Prop_VRCVersion_Uint64 = 1020 , <nl> + Prop_RadioVersion_Uint64 = 1021 , <nl> + Prop_DongleVersion_Uint64 = 1022 , <nl> + Prop_BlockServerShutdown_Bool = 1023 , <nl> + Prop_CanUnifyCoordinateSystemWithHmd_Bool = 1024 , <nl> + Prop_ContainsProximitySensor_Bool = 1025 , <nl> + Prop_DeviceProvidesBatteryStatus_Bool = 1026 , <nl> + Prop_DeviceCanPowerOff_Bool = 1027 , <nl> + Prop_Firmware_ProgrammingTarget_String = 1028 , <nl> + Prop_DeviceClass_Int32 = 1029 , <nl> + Prop_HasCamera_Bool = 1030 , <nl> + Prop_DriverVersion_String = 1031 , <nl> + Prop_Firmware_ForceUpdateRequired_Bool = 1032 , <nl> + Prop_ViveSystemButtonFixRequired_Bool = 1033 , <nl> + Prop_ParentDriver_Uint64 = 1034 , <nl> + Prop_ResourceRoot_String = 1035 , <nl> + Prop_RegisteredDeviceType_String = 1036 , <nl> + Prop_InputProfilePath_String = 1037 , / / input profile to use for this device in the input system . Will default to tracking system name if this isn ' t provided <nl> + Prop_NeverTracked_Bool = 1038 , / / Used for devices that will never have a valid pose by design <nl> + Prop_NumCameras_Int32 = 1039 , <nl> + Prop_CameraFrameLayout_Int32 = 1040 , / / EVRTrackedCameraFrameLayout value <nl> + Prop_CameraStreamFormat_Int32 = 1041 , / / ECameraVideoStreamFormat value <nl> + Prop_AdditionalDeviceSettingsPath_String = 1042 , / / driver - relative path to additional device and global configuration settings <nl> + Prop_Identifiable_Bool = 1043 , / / Whether device supports being identified from vrmonitor ( e . g . blink LED , vibrate haptics , etc ) <nl> + Prop_BootloaderVersion_Uint64 = 1044 , <nl> + Prop_AdditionalSystemReportData_String = 1045 , / / additional string to include in system reports about a tracked device <nl> + Prop_CompositeFirmwareVersion_String = 1046 , / / additional FW components from a device that gets propagated into reports <nl> + Prop_Firmware_RemindUpdate_Bool = 1047 , <nl> + Prop_PeripheralApplicationVersion_Uint64 = 1048 , <nl> + Prop_ManufacturerSerialNumber_String = 1049 , <nl> + Prop_ComputedSerialNumber_String = 1050 , <nl> + Prop_EstimatedDeviceFirstUseTime_Int32 = 1051 , <nl> + <nl> + / / Properties that are unique to TrackedDeviceClass_HMD <nl> + Prop_ReportsTimeSinceVSync_Bool = 2000 , <nl> + Prop_SecondsFromVsyncToPhotons_Float = 2001 , <nl> + Prop_DisplayFrequency_Float = 2002 , <nl> + Prop_UserIpdMeters_Float = 2003 , <nl> + Prop_CurrentUniverseId_Uint64 = 2004 , <nl> + Prop_PreviousUniverseId_Uint64 = 2005 , <nl> + Prop_DisplayFirmwareVersion_Uint64 = 2006 , <nl> + Prop_IsOnDesktop_Bool = 2007 , <nl> + Prop_DisplayMCType_Int32 = 2008 , <nl> + Prop_DisplayMCOffset_Float = 2009 , <nl> + Prop_DisplayMCScale_Float = 2010 , <nl> + Prop_EdidVendorID_Int32 = 2011 , <nl> + Prop_DisplayMCImageLeft_String = 2012 , <nl> + Prop_DisplayMCImageRight_String = 2013 , <nl> + Prop_DisplayGCBlackClamp_Float = 2014 , <nl> + Prop_EdidProductID_Int32 = 2015 , <nl> + Prop_CameraToHeadTransform_Matrix34 = 2016 , <nl> + Prop_DisplayGCType_Int32 = 2017 , <nl> + Prop_DisplayGCOffset_Float = 2018 , <nl> + Prop_DisplayGCScale_Float = 2019 , <nl> + Prop_DisplayGCPrescale_Float = 2020 , <nl> + Prop_DisplayGCImage_String = 2021 , <nl> + Prop_LensCenterLeftU_Float = 2022 , <nl> + Prop_LensCenterLeftV_Float = 2023 , <nl> + Prop_LensCenterRightU_Float = 2024 , <nl> + Prop_LensCenterRightV_Float = 2025 , <nl> + Prop_UserHeadToEyeDepthMeters_Float = 2026 , <nl> + Prop_CameraFirmwareVersion_Uint64 = 2027 , <nl> + Prop_CameraFirmwareDescription_String = 2028 , <nl> + Prop_DisplayFPGAVersion_Uint64 = 2029 , <nl> + Prop_DisplayBootloaderVersion_Uint64 = 2030 , <nl> + Prop_DisplayHardwareVersion_Uint64 = 2031 , <nl> + Prop_AudioFirmwareVersion_Uint64 = 2032 , <nl> + Prop_CameraCompatibilityMode_Int32 = 2033 , <nl> + Prop_ScreenshotHorizontalFieldOfViewDegrees_Float = 2034 , <nl> + Prop_ScreenshotVerticalFieldOfViewDegrees_Float = 2035 , <nl> + Prop_DisplaySuppressed_Bool = 2036 , <nl> + Prop_DisplayAllowNightMode_Bool = 2037 , <nl> + Prop_DisplayMCImageWidth_Int32 = 2038 , <nl> + Prop_DisplayMCImageHeight_Int32 = 2039 , <nl> + Prop_DisplayMCImageNumChannels_Int32 = 2040 , <nl> + Prop_DisplayMCImageData_Binary = 2041 , <nl> + Prop_SecondsFromPhotonsToVblank_Float = 2042 , <nl> + Prop_DriverDirectModeSendsVsyncEvents_Bool = 2043 , <nl> + Prop_DisplayDebugMode_Bool = 2044 , <nl> + Prop_GraphicsAdapterLuid_Uint64 = 2045 , <nl> + Prop_DriverProvidedChaperonePath_String = 2048 , <nl> + Prop_ExpectedTrackingReferenceCount_Int32 = 2049 , / / expected number of sensors or basestations to reserve UI space for <nl> + Prop_ExpectedControllerCount_Int32 = 2050 , / / expected number of tracked controllers to reserve UI space for <nl> + Prop_NamedIconPathControllerLeftDeviceOff_String = 2051 , / / placeholder icon for " left " controller if not yet detected / loaded <nl> + Prop_NamedIconPathControllerRightDeviceOff_String = 2052 , / / placeholder icon for " right " controller if not yet detected / loaded <nl> + Prop_NamedIconPathTrackingReferenceDeviceOff_String = 2053 , / / placeholder icon for sensor / base if not yet detected / loaded <nl> + Prop_DoNotApplyPrediction_Bool = 2054 , / / currently no effect . was used to disable HMD pose prediction on MR , which is now done by MR driver setting velocity = 0 <nl> + Prop_CameraToHeadTransforms_Matrix34_Array = 2055 , <nl> + Prop_DistortionMeshResolution_Int32 = 2056 , / / custom resolution of compositor calls to IVRSystem : : ComputeDistortion <nl> + Prop_DriverIsDrawingControllers_Bool = 2057 , <nl> + Prop_DriverRequestsApplicationPause_Bool = 2058 , <nl> + Prop_DriverRequestsReducedRendering_Bool = 2059 , <nl> + Prop_MinimumIpdStepMeters_Float = 2060 , <nl> + Prop_AudioBridgeFirmwareVersion_Uint64 = 2061 , <nl> + Prop_ImageBridgeFirmwareVersion_Uint64 = 2062 , <nl> + Prop_ImuToHeadTransform_Matrix34 = 2063 , <nl> + Prop_ImuFactoryGyroBias_Vector3 = 2064 , <nl> + Prop_ImuFactoryGyroScale_Vector3 = 2065 , <nl> + Prop_ImuFactoryAccelerometerBias_Vector3 = 2066 , <nl> + Prop_ImuFactoryAccelerometerScale_Vector3 = 2067 , <nl> + / / reserved 2068 <nl> + Prop_ConfigurationIncludesLighthouse20Features_Bool = 2069 , <nl> + Prop_AdditionalRadioFeatures_Uint64 = 2070 , <nl> + Prop_CameraWhiteBalance_Vector4_Array = 2071 , / / Prop_NumCameras_Int32 - sized array of float [ 4 ] RGBG white balance calibration data ( max size is vr : : k_unMaxCameras ) <nl> + Prop_CameraDistortionFunction_Int32_Array = 2072 , / / Prop_NumCameras_Int32 - sized array of vr : : EVRDistortionFunctionType values ( max size is vr : : k_unMaxCameras ) <nl> + Prop_CameraDistortionCoefficients_Float_Array = 2073 , / / Prop_NumCameras_Int32 - sized array of double [ vr : : k_unMaxDistortionFunctionParameters ] ( max size is vr : : k_unMaxCameras ) <nl> + Prop_ExpectedControllerType_String = 2074 , <nl> + Prop_HmdTrackingStyle_Int32 = 2075 , / / one of EHmdTrackingStyle <nl> + Prop_DriverProvidedChaperoneVisibility_Bool = 2076 , <nl> + Prop_HmdColumnCorrectionSettingPrefix_String = 2077 , <nl> + Prop_CameraSupportsCompatibilityModes_Bool = 2078 , <nl> + <nl> + Prop_DisplayAvailableFrameRates_Float_Array = 2080 , / / populated by compositor from actual EDID list when available from GPU driver <nl> + Prop_DisplaySupportsMultipleFramerates_Bool = 2081 , / / if this is true but Prop_DisplayAvailableFrameRates_Float_Array is empty , explain to user <nl> + Prop_DisplayColorMultLeft_Vector3 = 2082 , <nl> + Prop_DisplayColorMultRight_Vector3 = 2083 , <nl> + Prop_DisplaySupportsRuntimeFramerateChange_Bool = 2084 , <nl> + Prop_DisplaySupportsAnalogGain_Bool = 2085 , <nl> + Prop_DisplayMinAnalogGain_Float = 2086 , <nl> + Prop_DisplayMaxAnalogGain_Float = 2087 , <nl> + <nl> + / / Prop_DashboardLayoutPathName_String = 2090 , / / DELETED <nl> + Prop_DashboardScale_Float = 2091 , <nl> + Prop_IpdUIRangeMinMeters_Float = 2100 , <nl> + Prop_IpdUIRangeMaxMeters_Float = 2101 , <nl> + <nl> + / / Driver requested mura correction properties <nl> + Prop_DriverRequestedMuraCorrectionMode_Int32 = 2200 , <nl> + Prop_DriverRequestedMuraFeather_InnerLeft_Int32 = 2201 , <nl> + Prop_DriverRequestedMuraFeather_InnerRight_Int32 = 2202 , <nl> + Prop_DriverRequestedMuraFeather_InnerTop_Int32 = 2203 , <nl> + Prop_DriverRequestedMuraFeather_InnerBottom_Int32 = 2204 , <nl> + Prop_DriverRequestedMuraFeather_OuterLeft_Int32 = 2205 , <nl> + Prop_DriverRequestedMuraFeather_OuterRight_Int32 = 2206 , <nl> + Prop_DriverRequestedMuraFeather_OuterTop_Int32 = 2207 , <nl> + Prop_DriverRequestedMuraFeather_OuterBottom_Int32 = 2208 , <nl> + <nl> + Prop_Audio_DefaultPlaybackDeviceId_String = 2300 , <nl> + Prop_Audio_DefaultRecordingDeviceId_String = 2301 , <nl> + Prop_Audio_DefaultPlaybackDeviceVolume_Float = 2302 , <nl> + <nl> + / / Properties that are unique to TrackedDeviceClass_Controller <nl> + Prop_AttachedDeviceId_String = 3000 , <nl> + Prop_SupportedButtons_Uint64 = 3001 , <nl> + Prop_Axis0Type_Int32 = 3002 , / / Return value is of type EVRControllerAxisType <nl> + Prop_Axis1Type_Int32 = 3003 , / / Return value is of type EVRControllerAxisType <nl> + Prop_Axis2Type_Int32 = 3004 , / / Return value is of type EVRControllerAxisType <nl> + Prop_Axis3Type_Int32 = 3005 , / / Return value is of type EVRControllerAxisType <nl> + Prop_Axis4Type_Int32 = 3006 , / / Return value is of type EVRControllerAxisType <nl> + Prop_ControllerRoleHint_Int32 = 3007 , / / Return value is of type ETrackedControllerRole <nl> + <nl> + / / Properties that are unique to TrackedDeviceClass_TrackingReference <nl> + Prop_FieldOfViewLeftDegrees_Float = 4000 , <nl> + Prop_FieldOfViewRightDegrees_Float = 4001 , <nl> + Prop_FieldOfViewTopDegrees_Float = 4002 , <nl> + Prop_FieldOfViewBottomDegrees_Float = 4003 , <nl> + Prop_TrackingRangeMinimumMeters_Float = 4004 , <nl> + Prop_TrackingRangeMaximumMeters_Float = 4005 , <nl> + Prop_ModeLabel_String = 4006 , <nl> + Prop_CanWirelessIdentify_Bool = 4007 , / / volatile , based on radio presence and fw discovery <nl> + Prop_Nonce_Int32 = 4008 , <nl> + <nl> + / / Properties that are used for user interface like icons names <nl> + Prop_IconPathName_String = 5000 , / / DEPRECATED . Value not referenced . Now expected to be part of icon path properties . <nl> + Prop_NamedIconPathDeviceOff_String = 5001 , / / { driver } / icons / icon_filename - PNG for static icon , or GIF for animation , 50x32 for headsets and 32x32 for others <nl> + Prop_NamedIconPathDeviceSearching_String = 5002 , / / { driver } / icons / icon_filename - PNG for static icon , or GIF for animation , 50x32 for headsets and 32x32 for others <nl> + Prop_NamedIconPathDeviceSearchingAlert_String = 5003 , / / { driver } / icons / icon_filename - PNG for static icon , or GIF for animation , 50x32 for headsets and 32x32 for others <nl> + Prop_NamedIconPathDeviceReady_String = 5004 , / / { driver } / icons / icon_filename - PNG for static icon , or GIF for animation , 50x32 for headsets and 32x32 for others <nl> + Prop_NamedIconPathDeviceReadyAlert_String = 5005 , / / { driver } / icons / icon_filename - PNG for static icon , or GIF for animation , 50x32 for headsets and 32x32 for others <nl> + Prop_NamedIconPathDeviceNotReady_String = 5006 , / / { driver } / icons / icon_filename - PNG for static icon , or GIF for animation , 50x32 for headsets and 32x32 for others <nl> + Prop_NamedIconPathDeviceStandby_String = 5007 , / / { driver } / icons / icon_filename - PNG for static icon , or GIF for animation , 50x32 for headsets and 32x32 for others <nl> + Prop_NamedIconPathDeviceAlertLow_String = 5008 , / / { driver } / icons / icon_filename - PNG for static icon , or GIF for animation , 50x32 for headsets and 32x32 for others <nl> + Prop_NamedIconPathDeviceStandbyAlert_String = 5009 , / / { driver } / icons / icon_filename - PNG for static icon , or GIF for animation , 50x32 for headsets and 32x32 for others <nl> + <nl> + / / Properties that are used by helpers , but are opaque to applications <nl> + Prop_DisplayHiddenArea_Binary_Start = 5100 , <nl> + Prop_DisplayHiddenArea_Binary_End = 5150 , <nl> + Prop_ParentContainer = 5151 , <nl> + Prop_OverrideContainer_Uint64 = 5152 , <nl> + <nl> + / / Properties that are unique to drivers <nl> + Prop_UserConfigPath_String = 6000 , <nl> + Prop_InstallPath_String = 6001 , <nl> + Prop_HasDisplayComponent_Bool = 6002 , <nl> + Prop_HasControllerComponent_Bool = 6003 , <nl> + Prop_HasCameraComponent_Bool = 6004 , <nl> + Prop_HasDriverDirectModeComponent_Bool = 6005 , <nl> + Prop_HasVirtualDisplayComponent_Bool = 6006 , <nl> + Prop_HasSpatialAnchorsSupport_Bool = 6007 , <nl> + <nl> + / / Properties that are set internally based on other information provided by drivers <nl> + Prop_ControllerType_String = 7000 , <nl> + / / Prop_LegacyInputProfile_String = 7001 , / / This is no longer used . See " legacy_binding " in the input profile instead . <nl> + Prop_ControllerHandSelectionPriority_Int32 = 7002 , / / Allows hand assignments to prefer some controllers over others . High numbers are selected over low numbers <nl> + <nl> + / / Vendors are free to expose private debug data in this reserved region <nl> + Prop_VendorSpecific_Reserved_Start = 10000 , <nl> + Prop_VendorSpecific_Reserved_End = 10999 , <nl> + <nl> + Prop_TrackedDeviceProperty_Max = 1000000 , <nl> + } ; <nl> + <nl> + / * * No string property will ever be longer than this length * / <nl> + static const uint32_t k_unMaxPropertyStringSize = 32 * 1024 ; <nl> + <nl> + / * * Used to return errors that occur when reading properties . * / <nl> + enum ETrackedPropertyError <nl> + { <nl> + TrackedProp_Success = 0 , <nl> + TrackedProp_WrongDataType = 1 , <nl> + TrackedProp_WrongDeviceClass = 2 , <nl> + TrackedProp_BufferTooSmall = 3 , <nl> + TrackedProp_UnknownProperty = 4 , / / Driver has not set the property ( and may not ever ) . <nl> + TrackedProp_InvalidDevice = 5 , <nl> + TrackedProp_CouldNotContactServer = 6 , <nl> + TrackedProp_ValueNotProvidedByDevice = 7 , <nl> + TrackedProp_StringExceedsMaximumLength = 8 , <nl> + TrackedProp_NotYetAvailable = 9 , / / The property value isn ' t known yet , but is expected soon . Call again later . <nl> + TrackedProp_PermissionDenied = 10 , <nl> + TrackedProp_InvalidOperation = 11 , <nl> + TrackedProp_CannotWriteToWildcards = 12 , <nl> + TrackedProp_IPCReadFailure = 13 , <nl> + TrackedProp_OutOfMemory = 14 , <nl> + TrackedProp_InvalidContainer = 15 , <nl> + } ; <nl> + <nl> + / * * Used to drive certain text in the UI when talking about the tracking system for the HMD * / <nl> + enum EHmdTrackingStyle <nl> + { <nl> + HmdTrackingStyle_Unknown = 0 , <nl> + <nl> + HmdTrackingStyle_Lighthouse = 1 , / / base stations and lasers <nl> + HmdTrackingStyle_OutsideInCameras = 2 , / / Cameras and LED , Rift 1 style <nl> + HmdTrackingStyle_InsideOutCameras = 3 , / / Cameras on HMD looking at the world <nl> + } ; <nl> + <nl> + typedef uint64_t VRActionHandle_t ; <nl> + typedef uint64_t VRActionSetHandle_t ; <nl> + typedef uint64_t VRInputValueHandle_t ; <nl> + <nl> + static const VRActionHandle_t k_ulInvalidActionHandle = 0 ; <nl> + static const VRActionSetHandle_t k_ulInvalidActionSetHandle = 0 ; <nl> + static const VRInputValueHandle_t k_ulInvalidInputValueHandle = 0 ; <nl> + <nl> + <nl> + / * * Allows the application to control what part of the provided texture will be used in the <nl> + * frame buffer . * / <nl> + struct VRTextureBounds_t <nl> + { <nl> + float uMin , vMin ; <nl> + float uMax , vMax ; <nl> + } ; <nl> + <nl> + / * * Allows specifying pose used to render provided scene texture ( if different from value returned by WaitGetPoses ) . * / <nl> + struct VRTextureWithPose_t : public Texture_t <nl> + { <nl> + HmdMatrix34_t mDeviceToAbsoluteTracking ; / / Actual pose used to render scene textures . <nl> + } ; <nl> + <nl> + struct VRTextureDepthInfo_t <nl> + { <nl> + void * handle ; / / See ETextureType definition above <nl> + HmdMatrix44_t mProjection ; <nl> + HmdVector2_t vRange ; / / 0 . . 1 <nl> + } ; <nl> + <nl> + struct VRTextureWithDepth_t : public Texture_t <nl> + { <nl> + VRTextureDepthInfo_t depth ; <nl> + } ; <nl> + <nl> + struct VRTextureWithPoseAndDepth_t : public VRTextureWithPose_t <nl> + { <nl> + VRTextureDepthInfo_t depth ; <nl> + } ; <nl> + <nl> + / * * Allows the application to control how scene textures are used by the compositor when calling Submit . * / <nl> + enum EVRSubmitFlags <nl> + { <nl> + / / Simple render path . App submits rendered left and right eye images with no lens distortion correction applied . <nl> + Submit_Default = 0x00 , <nl> + <nl> + / / App submits final left and right eye images with lens distortion already applied ( lens distortion makes the images appear <nl> + / / barrel distorted with chromatic aberration correction applied ) . The app would have used the data returned by <nl> + / / vr : : IVRSystem : : ComputeDistortion ( ) to apply the correct distortion to the rendered images before calling Submit ( ) . <nl> + Submit_LensDistortionAlreadyApplied = 0x01 , <nl> + <nl> + / / If the texture pointer passed in is actually a renderbuffer ( e . g . for MSAA in OpenGL ) then set this flag . <nl> + Submit_GlRenderBuffer = 0x02 , <nl> + <nl> + / / Do not use <nl> + Submit_Reserved = 0x04 , <nl> + <nl> + / / Set to indicate that pTexture is a pointer to a VRTextureWithPose_t . <nl> + / / This flag can be combined with Submit_TextureWithDepth to pass a VRTextureWithPoseAndDepth_t . <nl> + Submit_TextureWithPose = 0x08 , <nl> + <nl> + / / Set to indicate that pTexture is a pointer to a VRTextureWithDepth_t . <nl> + / / This flag can be combined with Submit_TextureWithPose to pass a VRTextureWithPoseAndDepth_t . <nl> + Submit_TextureWithDepth = 0x10 , <nl> + <nl> + / / Set to indicate a discontinuity between this and the last frame . <nl> + / / This will prevent motion smoothing from attempting to extrapolate using the pair . <nl> + Submit_FrameDiscontinuty = 0x20 , <nl> + <nl> + / / Set to indicate that pTexture - > handle is a contains VRVulkanTextureArrayData_t <nl> + Submit_VulkanTextureWithArrayData = 0x40 , <nl> + } ; <nl> + <nl> + / * * Data required for passing Vulkan textures to IVRCompositor : : Submit . <nl> + * Be sure to call OpenVR_Shutdown before destroying these resources . <nl> + * Please see https : / / github . com / ValveSoftware / openvr / wiki / Vulkan for Vulkan - specific documentation * / <nl> + struct VRVulkanTextureData_t <nl> + { <nl> + uint64_t m_nImage ; / / VkImage <nl> + VkDevice_T * m_pDevice ; <nl> + VkPhysicalDevice_T * m_pPhysicalDevice ; <nl> + VkInstance_T * m_pInstance ; <nl> + VkQueue_T * m_pQueue ; <nl> + uint32_t m_nQueueFamilyIndex ; <nl> + uint32_t m_nWidth , m_nHeight , m_nFormat , m_nSampleCount ; <nl> + } ; <nl> + <nl> + / * * Data required for passing Vulkan texture arrays to IVRCompositor : : Submit . <nl> + * Be sure to call OpenVR_Shutdown before destroying these resources . <nl> + * Please see https : / / github . com / ValveSoftware / openvr / wiki / Vulkan for Vulkan - specific documentation * / <nl> + struct VRVulkanTextureArrayData_t : public VRVulkanTextureData_t <nl> + { <nl> + uint32_t m_unArrayIndex ; <nl> + uint32_t m_unArraySize ; <nl> + } ; <nl> + <nl> + / * * Data required for passing D3D12 textures to IVRCompositor : : Submit . <nl> + * Be sure to call OpenVR_Shutdown before destroying these resources . * / <nl> + struct D3D12TextureData_t <nl> + { <nl> + ID3D12Resource * m_pResource ; <nl> + ID3D12CommandQueue * m_pCommandQueue ; <nl> + uint32_t m_nNodeMask ; <nl> + } ; <nl> + <nl> + / * * Status of the overall system or tracked objects * / <nl> + enum EVRState <nl> + { <nl> + VRState_Undefined = - 1 , <nl> + VRState_Off = 0 , <nl> + VRState_Searching = 1 , <nl> + VRState_Searching_Alert = 2 , <nl> + VRState_Ready = 3 , <nl> + VRState_Ready_Alert = 4 , <nl> + VRState_NotReady = 5 , <nl> + VRState_Standby = 6 , <nl> + VRState_Ready_Alert_Low = 7 , <nl> + } ; <nl> + <nl> + / * * The types of events that could be posted ( and what the parameters mean for each event type ) * / <nl> + enum EVREventType <nl> + { <nl> + VREvent_None = 0 , <nl> + <nl> + VREvent_TrackedDeviceActivated = 100 , <nl> + VREvent_TrackedDeviceDeactivated = 101 , <nl> + VREvent_TrackedDeviceUpdated = 102 , <nl> + VREvent_TrackedDeviceUserInteractionStarted = 103 , <nl> + VREvent_TrackedDeviceUserInteractionEnded = 104 , <nl> + VREvent_IpdChanged = 105 , <nl> + VREvent_EnterStandbyMode = 106 , <nl> + VREvent_LeaveStandbyMode = 107 , <nl> + VREvent_TrackedDeviceRoleChanged = 108 , <nl> + VREvent_WatchdogWakeUpRequested = 109 , <nl> + VREvent_LensDistortionChanged = 110 , <nl> + VREvent_PropertyChanged = 111 , <nl> + VREvent_WirelessDisconnect = 112 , <nl> + VREvent_WirelessReconnect = 113 , <nl> + <nl> + VREvent_ButtonPress = 200 , / / data is controller <nl> + VREvent_ButtonUnpress = 201 , / / data is controller <nl> + VREvent_ButtonTouch = 202 , / / data is controller <nl> + VREvent_ButtonUntouch = 203 , / / data is controller <nl> + <nl> + / / VREvent_DualAnalog_Press = 250 , / / No longer sent <nl> + / / VREvent_DualAnalog_Unpress = 251 , / / No longer sent <nl> + / / VREvent_DualAnalog_Touch = 252 , / / No longer sent <nl> + / / VREvent_DualAnalog_Untouch = 253 , / / No longer sent <nl> + / / VREvent_DualAnalog_Move = 254 , / / No longer sent <nl> + / / VREvent_DualAnalog_ModeSwitch1 = 255 , / / No longer sent <nl> + / / VREvent_DualAnalog_ModeSwitch2 = 256 , / / No longer sent <nl> + VREvent_Modal_Cancel = 257 , / / Sent to overlays with the <nl> + <nl> + VREvent_MouseMove = 300 , / / data is mouse <nl> + VREvent_MouseButtonDown = 301 , / / data is mouse <nl> + VREvent_MouseButtonUp = 302 , / / data is mouse <nl> + VREvent_FocusEnter = 303 , / / data is overlay <nl> + VREvent_FocusLeave = 304 , / / data is overlay <nl> + VREvent_ScrollDiscrete = 305 , / / data is scroll <nl> + VREvent_TouchPadMove = 306 , / / data is mouse <nl> + VREvent_OverlayFocusChanged = 307 , / / data is overlay , global event <nl> + VREvent_ReloadOverlays = 308 , <nl> + VREvent_ScrollSmooth = 309 , / / data is scroll <nl> + VREvent_LockMousePosition = 310 , <nl> + VREvent_UnlockMousePosition = 311 , <nl> + <nl> + VREvent_InputFocusCaptured = 400 , / / data is process DEPRECATED <nl> + VREvent_InputFocusReleased = 401 , / / data is process DEPRECATED <nl> + / / VREvent_SceneFocusLost = 402 , / / data is process <nl> + / / VREvent_SceneFocusGained = 403 , / / data is process <nl> + VREvent_SceneApplicationChanged = 404 , / / data is process - The App actually drawing the scene changed ( usually to or from the compositor ) <nl> + VREvent_SceneFocusChanged = 405 , / / data is process - New app got access to draw the scene <nl> + VREvent_InputFocusChanged = 406 , / / data is process <nl> + / / VREvent_SceneApplicationSecondaryRenderingStarted = 407 , <nl> + VREvent_SceneApplicationUsingWrongGraphicsAdapter = 408 , / / data is process <nl> + VREvent_ActionBindingReloaded = 409 , / / data is process - The App that action binds reloaded for <nl> + <nl> + VREvent_HideRenderModels = 410 , / / Sent to the scene application to request hiding render models temporarily <nl> + VREvent_ShowRenderModels = 411 , / / Sent to the scene application to request restoring render model visibility <nl> + <nl> + VREvent_SceneApplicationStateChanged = 412 , / / No data ; but query VRApplications ( ) - > GetSceneApplicationState ( ) ; <nl> + <nl> + VREvent_ConsoleOpened = 420 , <nl> + VREvent_ConsoleClosed = 421 , <nl> + <nl> + VREvent_OverlayShown = 500 , <nl> + VREvent_OverlayHidden = 501 , <nl> + VREvent_DashboardActivated = 502 , <nl> + VREvent_DashboardDeactivated = 503 , <nl> + / / VREvent_DashboardThumbSelected = 504 , / / Sent to the overlay manager - data is overlay - No longer sent <nl> + VREvent_DashboardRequested = 505 , / / Sent to the overlay manager - data is overlay <nl> + VREvent_ResetDashboard = 506 , / / Send to the overlay manager <nl> + / / VREvent_RenderToast = 507 , / / Send to the dashboard to render a toast - data is the notification ID - - no longer sent <nl> + VREvent_ImageLoaded = 508 , / / Sent to overlays when a SetOverlayRaw or SetOverlayFromFile call finishes loading <nl> + VREvent_ShowKeyboard = 509 , / / Sent to keyboard renderer in the dashboard to invoke it <nl> + VREvent_HideKeyboard = 510 , / / Sent to keyboard renderer in the dashboard to hide it <nl> + VREvent_OverlayGamepadFocusGained = 511 , / / Sent to an overlay when IVROverlay : : SetFocusOverlay is called on it <nl> + VREvent_OverlayGamepadFocusLost = 512 , / / Send to an overlay when it previously had focus and IVROverlay : : SetFocusOverlay is called on something else <nl> + VREvent_OverlaySharedTextureChanged = 513 , <nl> + / / VREvent_DashboardGuideButtonDown = 514 , / / These are no longer sent <nl> + / / VREvent_DashboardGuideButtonUp = 515 , <nl> + VREvent_ScreenshotTriggered = 516 , / / Screenshot button combo was pressed , Dashboard should request a screenshot <nl> + VREvent_ImageFailed = 517 , / / Sent to overlays when a SetOverlayRaw or SetOverlayfromFail fails to load <nl> + VREvent_DashboardOverlayCreated = 518 , <nl> + VREvent_SwitchGamepadFocus = 519 , <nl> + <nl> + / / Screenshot API <nl> + VREvent_RequestScreenshot = 520 , / / Sent by vrclient application to compositor to take a screenshot <nl> + VREvent_ScreenshotTaken = 521 , / / Sent by compositor to the application that the screenshot has been taken <nl> + VREvent_ScreenshotFailed = 522 , / / Sent by compositor to the application that the screenshot failed to be taken <nl> + VREvent_SubmitScreenshotToDashboard = 523 , / / Sent by compositor to the dashboard that a completed screenshot was submitted <nl> + VREvent_ScreenshotProgressToDashboard = 524 , / / Sent by compositor to the dashboard that a completed screenshot was submitted <nl> + <nl> + VREvent_PrimaryDashboardDeviceChanged = 525 , <nl> + VREvent_RoomViewShown = 526 , / / Sent by compositor whenever room - view is enabled <nl> + VREvent_RoomViewHidden = 527 , / / Sent by compositor whenever room - view is disabled <nl> + VREvent_ShowUI = 528 , / / data is showUi <nl> + VREvent_ShowDevTools = 529 , / / data is showDevTools <nl> + <nl> + VREvent_Notification_Shown = 600 , <nl> + VREvent_Notification_Hidden = 601 , <nl> + VREvent_Notification_BeginInteraction = 602 , <nl> + VREvent_Notification_Destroyed = 603 , <nl> + <nl> + VREvent_Quit = 700 , / / data is process <nl> + VREvent_ProcessQuit = 701 , / / data is process <nl> + / / VREvent_QuitAborted_UserPrompt = 702 , / / data is process <nl> + VREvent_QuitAcknowledged = 703 , / / data is process <nl> + VREvent_DriverRequestedQuit = 704 , / / The driver has requested that SteamVR shut down <nl> + VREvent_RestartRequested = 705 , / / A driver or other component wants the user to restart SteamVR <nl> + <nl> + VREvent_ChaperoneDataHasChanged = 800 , / / this will never happen with the new chaperone system <nl> + VREvent_ChaperoneUniverseHasChanged = 801 , <nl> + VREvent_ChaperoneTempDataHasChanged = 802 , / / this will never happen with the new chaperone system <nl> + VREvent_ChaperoneSettingsHaveChanged = 803 , <nl> + VREvent_SeatedZeroPoseReset = 804 , <nl> + VREvent_ChaperoneFlushCache = 805 , / / Sent when the process needs to reload any cached data it retrieved from VRChaperone ( ) <nl> + VREvent_ChaperoneRoomSetupStarting = 806 , / / Triggered by CVRChaperoneClient : : RoomSetupStarting <nl> + VREvent_ChaperoneRoomSetupFinished = 807 , / / Triggered by CVRChaperoneClient : : CommitWorkingCopy <nl> + <nl> + VREvent_AudioSettingsHaveChanged = 820 , <nl> + <nl> + VREvent_BackgroundSettingHasChanged = 850 , <nl> + VREvent_CameraSettingsHaveChanged = 851 , <nl> + VREvent_ReprojectionSettingHasChanged = 852 , <nl> + VREvent_ModelSkinSettingsHaveChanged = 853 , <nl> + VREvent_EnvironmentSettingsHaveChanged = 854 , <nl> + VREvent_PowerSettingsHaveChanged = 855 , <nl> + VREvent_EnableHomeAppSettingsHaveChanged = 856 , <nl> + VREvent_SteamVRSectionSettingChanged = 857 , <nl> + VREvent_LighthouseSectionSettingChanged = 858 , <nl> + VREvent_NullSectionSettingChanged = 859 , <nl> + VREvent_UserInterfaceSectionSettingChanged = 860 , <nl> + VREvent_NotificationsSectionSettingChanged = 861 , <nl> + VREvent_KeyboardSectionSettingChanged = 862 , <nl> + VREvent_PerfSectionSettingChanged = 863 , <nl> + VREvent_DashboardSectionSettingChanged = 864 , <nl> + VREvent_WebInterfaceSectionSettingChanged = 865 , <nl> + VREvent_TrackersSectionSettingChanged = 866 , <nl> + VREvent_LastKnownSectionSettingChanged = 867 , <nl> + VREvent_DismissedWarningsSectionSettingChanged = 868 , <nl> + VREvent_GpuSpeedSectionSettingChanged = 869 , <nl> + VREvent_WindowsMRSectionSettingChanged = 870 , <nl> + VREvent_OtherSectionSettingChanged = 871 , <nl> + <nl> + VREvent_StatusUpdate = 900 , <nl> + <nl> + VREvent_WebInterface_InstallDriverCompleted = 950 , <nl> + <nl> + VREvent_MCImageUpdated = 1000 , <nl> + <nl> + VREvent_FirmwareUpdateStarted = 1100 , <nl> + VREvent_FirmwareUpdateFinished = 1101 , <nl> + <nl> + VREvent_KeyboardClosed = 1200 , <nl> + VREvent_KeyboardCharInput = 1201 , <nl> + VREvent_KeyboardDone = 1202 , / / Sent when DONE button clicked on keyboard <nl> + <nl> + / / VREvent_ApplicationTransitionStarted = 1300 , <nl> + / / VREvent_ApplicationTransitionAborted = 1301 , <nl> + / / VREvent_ApplicationTransitionNewAppStarted = 1302 , <nl> + VREvent_ApplicationListUpdated = 1303 , <nl> + VREvent_ApplicationMimeTypeLoad = 1304 , <nl> + / / VREvent_ApplicationTransitionNewAppLaunchComplete = 1305 , <nl> + VREvent_ProcessConnected = 1306 , <nl> + VREvent_ProcessDisconnected = 1307 , <nl> + <nl> + / / VREvent_Compositor_MirrorWindowShown = 1400 , / / DEPRECATED <nl> + / / VREvent_Compositor_MirrorWindowHidden = 1401 , / / DEPRECATED <nl> + VREvent_Compositor_ChaperoneBoundsShown = 1410 , <nl> + VREvent_Compositor_ChaperoneBoundsHidden = 1411 , <nl> + VREvent_Compositor_DisplayDisconnected = 1412 , <nl> + VREvent_Compositor_DisplayReconnected = 1413 , <nl> + VREvent_Compositor_HDCPError = 1414 , / / data is hdcpError <nl> + VREvent_Compositor_ApplicationNotResponding = 1415 , <nl> + VREvent_Compositor_ApplicationResumed = 1416 , <nl> + VREvent_Compositor_OutOfVideoMemory = 1417 , <nl> + VREvent_Compositor_DisplayModeNotSupported = 1418 , / / k_pch_SteamVR_PreferredRefreshRate <nl> + VREvent_Compositor_StageOverrideReady = 1419 , <nl> + <nl> + VREvent_TrackedCamera_StartVideoStream = 1500 , <nl> + VREvent_TrackedCamera_StopVideoStream = 1501 , <nl> + VREvent_TrackedCamera_PauseVideoStream = 1502 , <nl> + VREvent_TrackedCamera_ResumeVideoStream = 1503 , <nl> + VREvent_TrackedCamera_EditingSurface = 1550 , <nl> + <nl> + VREvent_PerformanceTest_EnableCapture = 1600 , <nl> + VREvent_PerformanceTest_DisableCapture = 1601 , <nl> + VREvent_PerformanceTest_FidelityLevel = 1602 , <nl> + <nl> + VREvent_MessageOverlay_Closed = 1650 , <nl> + VREvent_MessageOverlayCloseRequested = 1651 , <nl> + <nl> + VREvent_Input_HapticVibration = 1700 , / / data is hapticVibration <nl> + VREvent_Input_BindingLoadFailed = 1701 , / / data is inputBinding <nl> + VREvent_Input_BindingLoadSuccessful = 1702 , / / data is inputBinding <nl> + VREvent_Input_ActionManifestReloaded = 1703 , / / no data <nl> + VREvent_Input_ActionManifestLoadFailed = 1704 , / / data is actionManifest <nl> + VREvent_Input_ProgressUpdate = 1705 , / / data is progressUpdate <nl> + VREvent_Input_TrackerActivated = 1706 , <nl> + VREvent_Input_BindingsUpdated = 1707 , <nl> + VREvent_Input_BindingSubscriptionChanged = 1708 , <nl> + <nl> + VREvent_SpatialAnchors_PoseUpdated = 1800 , / / data is spatialAnchor . broadcast <nl> + VREvent_SpatialAnchors_DescriptorUpdated = 1801 , / / data is spatialAnchor . broadcast <nl> + VREvent_SpatialAnchors_RequestPoseUpdate = 1802 , / / data is spatialAnchor . sent to specific driver <nl> + VREvent_SpatialAnchors_RequestDescriptorUpdate = 1803 , / / data is spatialAnchor . sent to specific driver <nl> + <nl> + VREvent_SystemReport_Started = 1900 , / / user or system initiated generation of a system report . broadcast <nl> + <nl> + VREvent_Monitor_ShowHeadsetView = 2000 , / / data is process <nl> + VREvent_Monitor_HideHeadsetView = 2001 , / / data is process <nl> + <nl> + / / Vendors are free to expose private events in this reserved region <nl> + VREvent_VendorSpecific_Reserved_Start = 10000 , <nl> + VREvent_VendorSpecific_Reserved_End = 19999 , <nl> + } ; <nl> + <nl> + <nl> + / * * Level of Hmd activity * / <nl> + / / UserInteraction_Timeout means the device is in the process of timing out . <nl> + / / InUse = ( k_EDeviceActivityLevel_UserInteraction | | k_EDeviceActivityLevel_UserInteraction_Timeout ) <nl> + / / VREvent_TrackedDeviceUserInteractionStarted fires when the devices transitions from Standby - > UserInteraction or Idle - > UserInteraction . <nl> + / / VREvent_TrackedDeviceUserInteractionEnded fires when the devices transitions from UserInteraction_Timeout - > Idle <nl> + enum EDeviceActivityLevel <nl> + { <nl> + k_EDeviceActivityLevel_Unknown = - 1 , <nl> + k_EDeviceActivityLevel_Idle = 0 , / / No activity for the last 10 seconds <nl> + k_EDeviceActivityLevel_UserInteraction = 1 , / / Activity ( movement or prox sensor ) is happening now <nl> + k_EDeviceActivityLevel_UserInteraction_Timeout = 2 , / / No activity for the last 0 . 5 seconds <nl> + k_EDeviceActivityLevel_Standby = 3 , / / Idle for at least 5 seconds ( configurable in Settings - > Power Management ) <nl> + k_EDeviceActivityLevel_Idle_Timeout = 4 , <nl> + } ; <nl> + <nl> + <nl> + / * * VR controller button and axis IDs * / <nl> + enum EVRButtonId <nl> + { <nl> + k_EButton_System = 0 , <nl> + k_EButton_ApplicationMenu = 1 , <nl> + k_EButton_Grip = 2 , <nl> + k_EButton_DPad_Left = 3 , <nl> + k_EButton_DPad_Up = 4 , <nl> + k_EButton_DPad_Right = 5 , <nl> + k_EButton_DPad_Down = 6 , <nl> + k_EButton_A = 7 , <nl> + <nl> + k_EButton_ProximitySensor = 31 , <nl> + <nl> + k_EButton_Axis0 = 32 , <nl> + k_EButton_Axis1 = 33 , <nl> + k_EButton_Axis2 = 34 , <nl> + k_EButton_Axis3 = 35 , <nl> + k_EButton_Axis4 = 36 , <nl> + <nl> + / / aliases for well known controllers <nl> + k_EButton_SteamVR_Touchpad = k_EButton_Axis0 , <nl> + k_EButton_SteamVR_Trigger = k_EButton_Axis1 , <nl> + <nl> + k_EButton_Dashboard_Back = k_EButton_Grip , <nl> + <nl> + k_EButton_IndexController_A = k_EButton_Grip , <nl> + k_EButton_IndexController_B = k_EButton_ApplicationMenu , <nl> + k_EButton_IndexController_JoyStick = k_EButton_Axis3 , <nl> + <nl> + k_EButton_Max = 64 <nl> + } ; <nl> + <nl> + inline uint64_t ButtonMaskFromId ( EVRButtonId id ) { return 1ull < < id ; } <nl> + <nl> + / * * used for controller button events * / <nl> + struct VREvent_Controller_t <nl> + { <nl> + uint32_t button ; / / EVRButtonId enum <nl> + } ; <nl> + <nl> + <nl> + / * * used for simulated mouse events in overlay space * / <nl> + enum EVRMouseButton <nl> + { <nl> + VRMouseButton_Left = 0x0001 , <nl> + VRMouseButton_Right = 0x0002 , <nl> + VRMouseButton_Middle = 0x0004 , <nl> + } ; <nl> + <nl> + <nl> + / * * used for simulated mouse events in overlay space * / <nl> + struct VREvent_Mouse_t <nl> + { <nl> + float x , y ; / / co - ords are in GL space , bottom left of the texture is 0 , 0 <nl> + uint32_t button ; / / EVRMouseButton enum <nl> + } ; <nl> + <nl> + / * * used for simulated mouse wheel scroll * / <nl> + struct VREvent_Scroll_t <nl> + { <nl> + float xdelta , ydelta ; <nl> + uint32_t unused ; <nl> + float viewportscale ; / / For scrolling on an overlay with laser mouse , this is the overlay ' s vertical size relative to the overlay height . Range : [ 0 , 1 ] <nl> + } ; <nl> + <nl> + / * * when in mouse input mode you can receive data from the touchpad , these events are only sent if the users finger <nl> + is on the touchpad ( or just released from it ) . These events are sent to overlays with the VROverlayFlags_SendVRTouchpadEvents <nl> + flag set . <nl> + * * / <nl> + struct VREvent_TouchPadMove_t <nl> + { <nl> + / / true if the users finger is detected on the touch pad <nl> + bool bFingerDown ; <nl> + <nl> + / / How long the finger has been down in seconds <nl> + float flSecondsFingerDown ; <nl> + <nl> + / / These values indicate the starting finger position ( so you can do some basic swipe stuff ) <nl> + float fValueXFirst ; <nl> + float fValueYFirst ; <nl> + <nl> + / / This is the raw sampled coordinate without deadzoning <nl> + float fValueXRaw ; <nl> + float fValueYRaw ; <nl> + } ; <nl> + <nl> + / * * notification related events . Details will still change at this point * / <nl> + struct VREvent_Notification_t <nl> + { <nl> + uint64_t ulUserValue ; <nl> + uint32_t notificationId ; <nl> + } ; <nl> + <nl> + / * * Used for events about processes * / <nl> + struct VREvent_Process_t <nl> + { <nl> + uint32_t pid ; <nl> + uint32_t oldPid ; <nl> + bool bForced ; <nl> + / / If the associated event was triggered by a connection loss <nl> + bool bConnectionLost ; <nl> + } ; <nl> + <nl> + <nl> + / * * Used for a few events about overlays * / <nl> + struct VREvent_Overlay_t <nl> + { <nl> + uint64_t overlayHandle ; <nl> + uint64_t devicePath ; <nl> + } ; <nl> + <nl> + <nl> + / * * Used for a few events about overlays * / <nl> + struct VREvent_Status_t <nl> + { <nl> + uint32_t statusState ; / / EVRState enum <nl> + } ; <nl> + <nl> + / * * Used for keyboard events * * / <nl> + struct VREvent_Keyboard_t <nl> + { <nl> + char cNewInput [ 8 ] ; / / Up to 11 bytes of new input <nl> + uint64_t uUserValue ; / / Possible flags about the new input <nl> + } ; <nl> + <nl> + struct VREvent_Ipd_t <nl> + { <nl> + float ipdMeters ; <nl> + } ; <nl> + <nl> + struct VREvent_Chaperone_t <nl> + { <nl> + uint64_t m_nPreviousUniverse ; <nl> + uint64_t m_nCurrentUniverse ; <nl> + } ; <nl> + <nl> + / * * Not actually used for any events * / <nl> + struct VREvent_Reserved_t <nl> + { <nl> + uint64_t reserved0 ; <nl> + uint64_t reserved1 ; <nl> + uint64_t reserved2 ; <nl> + uint64_t reserved3 ; <nl> + uint64_t reserved4 ; <nl> + uint64_t reserved5 ; <nl> + } ; <nl> + <nl> + struct VREvent_PerformanceTest_t <nl> + { <nl> + uint32_t m_nFidelityLevel ; <nl> + } ; <nl> + <nl> + struct VREvent_SeatedZeroPoseReset_t <nl> + { <nl> + bool bResetBySystemMenu ; <nl> + } ; <nl> + <nl> + struct VREvent_Screenshot_t <nl> + { <nl> + uint32_t handle ; <nl> + uint32_t type ; <nl> + } ; <nl> + <nl> + struct VREvent_ScreenshotProgress_t <nl> + { <nl> + float progress ; <nl> + } ; <nl> + <nl> + struct VREvent_ApplicationLaunch_t <nl> + { <nl> + uint32_t pid ; <nl> + uint32_t unArgsHandle ; <nl> + } ; <nl> + <nl> + struct VREvent_EditingCameraSurface_t <nl> + { <nl> + uint64_t overlayHandle ; <nl> + uint32_t nVisualMode ; <nl> + } ; <nl> + <nl> + struct VREvent_MessageOverlay_t <nl> + { <nl> + uint32_t unVRMessageOverlayResponse ; / / vr : : VRMessageOverlayResponse enum <nl> + } ; <nl> + <nl> + struct VREvent_Property_t <nl> + { <nl> + PropertyContainerHandle_t container ; <nl> + ETrackedDeviceProperty prop ; <nl> + } ; <nl> + <nl> + struct VREvent_HapticVibration_t <nl> + { <nl> + uint64_t containerHandle ; / / property container handle of the device with the haptic component <nl> + uint64_t componentHandle ; / / Which haptic component needs to vibrate <nl> + float fDurationSeconds ; <nl> + float fFrequency ; <nl> + float fAmplitude ; <nl> + } ; <nl> + <nl> + struct VREvent_WebConsole_t <nl> + { <nl> + WebConsoleHandle_t webConsoleHandle ; <nl> + } ; <nl> + <nl> + struct VREvent_InputBindingLoad_t <nl> + { <nl> + vr : : PropertyContainerHandle_t ulAppContainer ; <nl> + uint64_t pathMessage ; <nl> + uint64_t pathUrl ; <nl> + uint64_t pathControllerType ; <nl> + } ; <nl> + <nl> + struct VREvent_InputActionManifestLoad_t <nl> + { <nl> + uint64_t pathAppKey ; <nl> + uint64_t pathMessage ; <nl> + uint64_t pathMessageParam ; <nl> + uint64_t pathManifestPath ; <nl> + } ; <nl> + <nl> + struct VREvent_SpatialAnchor_t <nl> + { <nl> + SpatialAnchorHandle_t unHandle ; <nl> + } ; <nl> + <nl> + struct VREvent_ProgressUpdate_t <nl> + { <nl> + uint64_t ulApplicationPropertyContainer ; <nl> + uint64_t pathDevice ; <nl> + uint64_t pathInputSource ; <nl> + uint64_t pathProgressAction ; <nl> + uint64_t pathIcon ; <nl> + float fProgress ; <nl> + } ; <nl> + <nl> + enum EShowUIType <nl> + { <nl> + ShowUI_ControllerBinding = 0 , <nl> + ShowUI_ManageTrackers = 1 , <nl> + / / ShowUI_QuickStart = 2 , / / Deprecated <nl> + ShowUI_Pairing = 3 , <nl> + ShowUI_Settings = 4 , <nl> + ShowUI_DebugCommands = 5 , <nl> + ShowUI_FullControllerBinding = 6 , <nl> + ShowUI_ManageDrivers = 7 , <nl> + } ; <nl> + <nl> + struct VREvent_ShowUI_t <nl> + { <nl> + EShowUIType eType ; <nl> + } ; <nl> + <nl> + struct VREvent_ShowDevTools_t <nl> + { <nl> + int32_t nBrowserIdentifier ; <nl> + } ; <nl> + <nl> + enum EHDCPError <nl> + { <nl> + HDCPError_None = 0 , <nl> + HDCPError_LinkLost = 1 , <nl> + HDCPError_Tampered = 2 , <nl> + HDCPError_DeviceRevoked = 3 , <nl> + HDCPError_Unknown = 4 <nl> + } ; <nl> + <nl> + struct VREvent_HDCPError_t <nl> + { <nl> + EHDCPError eCode ; <nl> + } ; <nl> + <nl> + typedef union <nl> + { <nl> + VREvent_Reserved_t reserved ; <nl> + VREvent_Controller_t controller ; <nl> + VREvent_Mouse_t mouse ; <nl> + VREvent_Scroll_t scroll ; <nl> + VREvent_Process_t process ; <nl> + VREvent_Notification_t notification ; <nl> + VREvent_Overlay_t overlay ; <nl> + VREvent_Status_t status ; <nl> + VREvent_Keyboard_t keyboard ; <nl> + VREvent_Ipd_t ipd ; <nl> + VREvent_Chaperone_t chaperone ; <nl> + VREvent_PerformanceTest_t performanceTest ; <nl> + VREvent_TouchPadMove_t touchPadMove ; <nl> + VREvent_SeatedZeroPoseReset_t seatedZeroPoseReset ; <nl> + VREvent_Screenshot_t screenshot ; <nl> + VREvent_ScreenshotProgress_t screenshotProgress ; <nl> + VREvent_ApplicationLaunch_t applicationLaunch ; <nl> + VREvent_EditingCameraSurface_t cameraSurface ; <nl> + VREvent_MessageOverlay_t messageOverlay ; <nl> + VREvent_Property_t property ; <nl> + VREvent_HapticVibration_t hapticVibration ; <nl> + VREvent_WebConsole_t webConsole ; <nl> + VREvent_InputBindingLoad_t inputBinding ; <nl> + VREvent_InputActionManifestLoad_t actionManifest ; <nl> + VREvent_SpatialAnchor_t spatialAnchor ; <nl> + VREvent_ProgressUpdate_t progressUpdate ; <nl> + VREvent_ShowUI_t showUi ; <nl> + VREvent_ShowDevTools_t showDevTools ; <nl> + VREvent_HDCPError_t hdcpError ; <nl> + / * * NOTE ! ! ! If you change this you MUST manually update openvr_interop . cs . py * / <nl> + } VREvent_Data_t ; <nl> + <nl> + <nl> + # if defined ( __linux__ ) | | defined ( __APPLE__ ) <nl> + / / This structure was originally defined mis - packed on Linux , preserved for <nl> + / / compatibility . <nl> + # pragma pack ( push , 4 ) <nl> + # endif <nl> + <nl> + / * * An event posted by the server to all running applications * / <nl> + struct VREvent_t <nl> + { <nl> + uint32_t eventType ; / / EVREventType enum <nl> + TrackedDeviceIndex_t trackedDeviceIndex ; <nl> + float eventAgeSeconds ; <nl> + / / event data must be the end of the struct as its size is variable <nl> + VREvent_Data_t data ; <nl> + } ; <nl> + <nl> + # if defined ( __linux__ ) | | defined ( __APPLE__ ) <nl> + # pragma pack ( pop ) <nl> + # endif <nl> + <nl> + typedef uint32_t VRComponentProperties ; <nl> + <nl> + enum EVRComponentProperty <nl> + { <nl> + VRComponentProperty_IsStatic = ( 1 < < 0 ) , <nl> + VRComponentProperty_IsVisible = ( 1 < < 1 ) , <nl> + VRComponentProperty_IsTouched = ( 1 < < 2 ) , <nl> + VRComponentProperty_IsPressed = ( 1 < < 3 ) , <nl> + VRComponentProperty_IsScrolled = ( 1 < < 4 ) , <nl> + VRComponentProperty_IsHighlighted = ( 1 < < 5 ) , <nl> + } ; <nl> + <nl> + <nl> + / * * Describes state information about a render - model component , including transforms and other dynamic properties * / <nl> + struct RenderModel_ComponentState_t <nl> + { <nl> + HmdMatrix34_t mTrackingToComponentRenderModel ; / / Transform required when drawing the component render model <nl> + HmdMatrix34_t mTrackingToComponentLocal ; / / Transform available for attaching to a local component coordinate system ( - Z out from surface ) <nl> + VRComponentProperties uProperties ; <nl> + } ; <nl> + <nl> + <nl> + enum EVRInputError <nl> + { <nl> + VRInputError_None = 0 , <nl> + VRInputError_NameNotFound = 1 , <nl> + VRInputError_WrongType = 2 , <nl> + VRInputError_InvalidHandle = 3 , <nl> + VRInputError_InvalidParam = 4 , <nl> + VRInputError_NoSteam = 5 , <nl> + VRInputError_MaxCapacityReached = 6 , <nl> + VRInputError_IPCError = 7 , <nl> + VRInputError_NoActiveActionSet = 8 , <nl> + VRInputError_InvalidDevice = 9 , <nl> + VRInputError_InvalidSkeleton = 10 , <nl> + VRInputError_InvalidBoneCount = 11 , <nl> + VRInputError_InvalidCompressedData = 12 , <nl> + VRInputError_NoData = 13 , <nl> + VRInputError_BufferTooSmall = 14 , <nl> + VRInputError_MismatchedActionManifest = 15 , <nl> + VRInputError_MissingSkeletonData = 16 , <nl> + VRInputError_InvalidBoneIndex = 17 , <nl> + VRInputError_InvalidPriority = 18 , <nl> + VRInputError_PermissionDenied = 19 , <nl> + VRInputError_InvalidRenderModel = 20 , <nl> + } ; <nl> + <nl> + enum EVRSpatialAnchorError <nl> + { <nl> + VRSpatialAnchorError_Success = 0 , <nl> + VRSpatialAnchorError_Internal = 1 , <nl> + VRSpatialAnchorError_UnknownHandle = 2 , <nl> + VRSpatialAnchorError_ArrayTooSmall = 3 , <nl> + VRSpatialAnchorError_InvalidDescriptorChar = 4 , <nl> + VRSpatialAnchorError_NotYetAvailable = 5 , <nl> + VRSpatialAnchorError_NotAvailableInThisUniverse = 6 , <nl> + VRSpatialAnchorError_PermanentlyUnavailable = 7 , <nl> + VRSpatialAnchorError_WrongDriver = 8 , <nl> + VRSpatialAnchorError_DescriptorTooLong = 9 , <nl> + VRSpatialAnchorError_Unknown = 10 , <nl> + VRSpatialAnchorError_NoRoomCalibration = 11 , <nl> + VRSpatialAnchorError_InvalidArgument = 12 , <nl> + VRSpatialAnchorError_UnknownDriver = 13 , <nl> + } ; <nl> + <nl> + / * * The mesh to draw into the stencil ( or depth ) buffer to perform <nl> + * early stencil ( or depth ) kills of pixels that will never appear on the HMD . <nl> + * This mesh draws on all the pixels that will be hidden after distortion . <nl> + * <nl> + * If the HMD does not provide a visible area mesh pVertexData will be <nl> + * NULL and unTriangleCount will be 0 . * / <nl> + struct HiddenAreaMesh_t <nl> + { <nl> + const HmdVector2_t * pVertexData ; <nl> + uint32_t unTriangleCount ; <nl> + } ; <nl> + <nl> + <nl> + enum EHiddenAreaMeshType <nl> + { <nl> + k_eHiddenAreaMesh_Standard = 0 , <nl> + k_eHiddenAreaMesh_Inverse = 1 , <nl> + k_eHiddenAreaMesh_LineLoop = 2 , <nl> + <nl> + k_eHiddenAreaMesh_Max = 3 , <nl> + } ; <nl> + <nl> + <nl> + / * * Identifies what kind of axis is on the controller at index n . Read this type <nl> + * with pVRSystem - > Get ( nControllerDeviceIndex , Prop_Axis0Type_Int32 + n ) ; <nl> + * / <nl> + enum EVRControllerAxisType <nl> + { <nl> + k_eControllerAxis_None = 0 , <nl> + k_eControllerAxis_TrackPad = 1 , <nl> + k_eControllerAxis_Joystick = 2 , <nl> + k_eControllerAxis_Trigger = 3 , / / Analog trigger data is in the X axis <nl> + } ; <nl> + <nl> + <nl> + / * * contains information about one axis on the controller * / <nl> + struct VRControllerAxis_t <nl> + { <nl> + float x ; / / Ranges from - 1 . 0 to 1 . 0 for joysticks and track pads . Ranges from 0 . 0 to 1 . 0 for triggers were 0 is fully released . <nl> + float y ; / / Ranges from - 1 . 0 to 1 . 0 for joysticks and track pads . Is always 0 . 0 for triggers . <nl> + } ; <nl> + <nl> + <nl> + / * * the number of axes in the controller state * / <nl> + static const uint32_t k_unControllerStateAxisCount = 5 ; <nl> + <nl> + <nl> + # if defined ( __linux__ ) | | defined ( __APPLE__ ) <nl> + / / This structure was originally defined mis - packed on Linux , preserved for <nl> + / / compatibility . <nl> + # pragma pack ( push , 4 ) <nl> + # endif <nl> + <nl> + / * * Holds all the state of a controller at one moment in time . * / <nl> + struct VRControllerState001_t <nl> + { <nl> + / / If packet num matches that on your prior call , then the controller state hasn ' t been changed since <nl> + / / your last call and there is no need to process it <nl> + uint32_t unPacketNum ; <nl> + <nl> + / / bit flags for each of the buttons . Use ButtonMaskFromId to turn an ID into a mask <nl> + uint64_t ulButtonPressed ; <nl> + uint64_t ulButtonTouched ; <nl> + <nl> + / / Axis data for the controller ' s analog inputs <nl> + VRControllerAxis_t rAxis [ k_unControllerStateAxisCount ] ; <nl> + } ; <nl> + # if defined ( __linux__ ) | | defined ( __APPLE__ ) <nl> + # pragma pack ( pop ) <nl> + # endif <nl> + <nl> + <nl> + typedef VRControllerState001_t VRControllerState_t ; <nl> + <nl> + <nl> + / * * determines how to provide output to the application of various event processing functions . * / <nl> + enum EVRControllerEventOutputType <nl> + { <nl> + ControllerEventOutput_OSEvents = 0 , <nl> + ControllerEventOutput_VREvents = 1 , <nl> + } ; <nl> + <nl> + <nl> + <nl> + / * * Collision Bounds Style * / <nl> + enum ECollisionBoundsStyle <nl> + { <nl> + COLLISION_BOUNDS_STYLE_BEGINNER = 0 , <nl> + COLLISION_BOUNDS_STYLE_INTERMEDIATE , <nl> + COLLISION_BOUNDS_STYLE_SQUARES , <nl> + COLLISION_BOUNDS_STYLE_ADVANCED , <nl> + COLLISION_BOUNDS_STYLE_NONE , <nl> + <nl> + COLLISION_BOUNDS_STYLE_COUNT <nl> + } ; <nl> + <nl> + / * * used to refer to a single VR overlay * / <nl> + typedef uint64_t VROverlayHandle_t ; <nl> + <nl> + static const VROverlayHandle_t k_ulOverlayHandleInvalid = 0 ; <nl> + <nl> + / * * Errors that can occur around VR overlays * / <nl> + enum EVROverlayError <nl> + { <nl> + VROverlayError_None = 0 , <nl> + <nl> + VROverlayError_UnknownOverlay = 10 , <nl> + VROverlayError_InvalidHandle = 11 , <nl> + VROverlayError_PermissionDenied = 12 , <nl> + VROverlayError_OverlayLimitExceeded = 13 , / / No more overlays could be created because the maximum number already exist <nl> + VROverlayError_WrongVisibilityType = 14 , <nl> + VROverlayError_KeyTooLong = 15 , <nl> + VROverlayError_NameTooLong = 16 , <nl> + VROverlayError_KeyInUse = 17 , <nl> + VROverlayError_WrongTransformType = 18 , <nl> + VROverlayError_InvalidTrackedDevice = 19 , <nl> + VROverlayError_InvalidParameter = 20 , <nl> + VROverlayError_ThumbnailCantBeDestroyed = 21 , <nl> + VROverlayError_ArrayTooSmall = 22 , <nl> + VROverlayError_RequestFailed = 23 , <nl> + VROverlayError_InvalidTexture = 24 , <nl> + VROverlayError_UnableToLoadFile = 25 , <nl> + VROverlayError_KeyboardAlreadyInUse = 26 , <nl> + VROverlayError_NoNeighbor = 27 , <nl> + VROverlayError_TooManyMaskPrimitives = 29 , <nl> + VROverlayError_BadMaskPrimitive = 30 , <nl> + VROverlayError_TextureAlreadyLocked = 31 , <nl> + VROverlayError_TextureLockCapacityReached = 32 , <nl> + VROverlayError_TextureNotLocked = 33 , <nl> + } ; <nl> + <nl> + / * * enum values to pass in to VR_Init to identify whether the application will <nl> + * draw a 3D scene . * / <nl> + enum EVRApplicationType <nl> + { <nl> + VRApplication_Other = 0 , / / Some other kind of application that isn ' t covered by the other entries <nl> + VRApplication_Scene = 1 , / / Application will submit 3D frames <nl> + VRApplication_Overlay = 2 , / / Application only interacts with overlays <nl> + VRApplication_Background = 3 , / / Application should not start SteamVR if it ' s not already running , and should not <nl> + / / keep it running if everything else quits . <nl> + VRApplication_Utility = 4 , / / Init should not try to load any drivers . The application needs access to utility <nl> + / / interfaces ( like IVRSettings and IVRApplications ) but not hardware . <nl> + VRApplication_VRMonitor = 5 , / / Reserved for vrmonitor <nl> + VRApplication_SteamWatchdog = 6 , / / Reserved for Steam <nl> + VRApplication_Bootstrapper = 7 , / / reserved for vrstartup <nl> + VRApplication_WebHelper = 8 , / / reserved for vrwebhelper <nl> + <nl> + VRApplication_Max <nl> + } ; <nl> + <nl> + <nl> + / * * error codes for firmware * / <nl> + enum EVRFirmwareError <nl> + { <nl> + VRFirmwareError_None = 0 , <nl> + VRFirmwareError_Success = 1 , <nl> + VRFirmwareError_Fail = 2 , <nl> + } ; <nl> + <nl> + <nl> + / * * error codes for notifications * / <nl> + enum EVRNotificationError <nl> + { <nl> + VRNotificationError_OK = 0 , <nl> + VRNotificationError_InvalidNotificationId = 100 , <nl> + VRNotificationError_NotificationQueueFull = 101 , <nl> + VRNotificationError_InvalidOverlayHandle = 102 , <nl> + VRNotificationError_SystemWithUserValueAlreadyExists = 103 , <nl> + } ; <nl> + <nl> + <nl> + enum EVRSkeletalMotionRange <nl> + { <nl> + / / The range of motion of the skeleton takes into account any physical limits imposed by <nl> + / / the controller itself . This will tend to be the most accurate pose compared to the user ' s <nl> + / / actual hand pose , but might not allow a closed fist for example <nl> + VRSkeletalMotionRange_WithController = 0 , <nl> + <nl> + / / Retarget the range of motion provided by the input device to make the hand appear to move <nl> + / / as if it was not holding a controller . eg : map " hand grasping controller " to " closed fist " <nl> + VRSkeletalMotionRange_WithoutController = 1 , <nl> + } ; <nl> + <nl> + enum EVRSkeletalTrackingLevel <nl> + { <nl> + / / body part location can ' t be directly determined by the device . Any skeletal pose provided by <nl> + / / the device is estimated by assuming the position required to active buttons , triggers , joysticks , <nl> + / / or other input sensors . <nl> + / / E . g . Vive Controller , Gamepad <nl> + VRSkeletalTracking_Estimated = 0 , <nl> + <nl> + / / body part location can be measured directly but with fewer degrees of freedom than the actual body <nl> + / / part . Certain body part positions may be unmeasured by the device and estimated from other input data . <nl> + / / E . g . Index Controllers , gloves that only measure finger curl <nl> + VRSkeletalTracking_Partial = 1 , <nl> + <nl> + / / Body part location can be measured directly throughout the entire range of motion of the body part . <nl> + / / E . g . Mocap suit for the full body , gloves that measure rotation of each finger segment <nl> + VRSkeletalTracking_Full = 2 , <nl> + <nl> + VRSkeletalTrackingLevel_Count , <nl> + VRSkeletalTrackingLevel_Max = VRSkeletalTrackingLevel_Count - 1 <nl> + } ; <nl> + <nl> + <nl> + <nl> + / * * Holds the transform for a single bone * / <nl> + struct VRBoneTransform_t <nl> + { <nl> + HmdVector4_t position ; <nl> + HmdQuaternionf_t orientation ; <nl> + } ; <nl> + <nl> + / * * Type used for referring to bones by their index * / <nl> + typedef int32_t BoneIndex_t ; <nl> + const BoneIndex_t k_unInvalidBoneIndex = - 1 ; <nl> + <nl> + <nl> + / * * error codes returned by Vr_Init * / <nl> + <nl> + / / Please add adequate error description to https : / / developer . valvesoftware . com / w / index . php ? title = Category : SteamVRHelp <nl> + enum EVRInitError <nl> + { <nl> + VRInitError_None = 0 , <nl> + VRInitError_Unknown = 1 , <nl> + <nl> + VRInitError_Init_InstallationNotFound = 100 , <nl> + VRInitError_Init_InstallationCorrupt = 101 , <nl> + VRInitError_Init_VRClientDLLNotFound = 102 , <nl> + VRInitError_Init_FileNotFound = 103 , <nl> + VRInitError_Init_FactoryNotFound = 104 , <nl> + VRInitError_Init_InterfaceNotFound = 105 , <nl> + VRInitError_Init_InvalidInterface = 106 , <nl> + VRInitError_Init_UserConfigDirectoryInvalid = 107 , <nl> + VRInitError_Init_HmdNotFound = 108 , <nl> + VRInitError_Init_NotInitialized = 109 , <nl> + VRInitError_Init_PathRegistryNotFound = 110 , <nl> + VRInitError_Init_NoConfigPath = 111 , <nl> + VRInitError_Init_NoLogPath = 112 , <nl> + VRInitError_Init_PathRegistryNotWritable = 113 , <nl> + VRInitError_Init_AppInfoInitFailed = 114 , <nl> + VRInitError_Init_Retry = 115 , / / Used internally to cause retries to vrserver <nl> + VRInitError_Init_InitCanceledByUser = 116 , / / The calling application should silently exit . The user canceled app startup <nl> + VRInitError_Init_AnotherAppLaunching = 117 , <nl> + VRInitError_Init_SettingsInitFailed = 118 , <nl> + VRInitError_Init_ShuttingDown = 119 , <nl> + VRInitError_Init_TooManyObjects = 120 , <nl> + VRInitError_Init_NoServerForBackgroundApp = 121 , <nl> + VRInitError_Init_NotSupportedWithCompositor = 122 , <nl> + VRInitError_Init_NotAvailableToUtilityApps = 123 , <nl> + VRInitError_Init_Internal = 124 , <nl> + VRInitError_Init_HmdDriverIdIsNone = 125 , <nl> + VRInitError_Init_HmdNotFoundPresenceFailed = 126 , <nl> + VRInitError_Init_VRMonitorNotFound = 127 , <nl> + VRInitError_Init_VRMonitorStartupFailed = 128 , <nl> + VRInitError_Init_LowPowerWatchdogNotSupported = 129 , <nl> + VRInitError_Init_InvalidApplicationType = 130 , <nl> + VRInitError_Init_NotAvailableToWatchdogApps = 131 , <nl> + VRInitError_Init_WatchdogDisabledInSettings = 132 , <nl> + VRInitError_Init_VRDashboardNotFound = 133 , <nl> + VRInitError_Init_VRDashboardStartupFailed = 134 , <nl> + VRInitError_Init_VRHomeNotFound = 135 , <nl> + VRInitError_Init_VRHomeStartupFailed = 136 , <nl> + VRInitError_Init_RebootingBusy = 137 , <nl> + VRInitError_Init_FirmwareUpdateBusy = 138 , <nl> + VRInitError_Init_FirmwareRecoveryBusy = 139 , <nl> + VRInitError_Init_USBServiceBusy = 140 , <nl> + VRInitError_Init_VRWebHelperStartupFailed = 141 , <nl> + VRInitError_Init_TrackerManagerInitFailed = 142 , <nl> + VRInitError_Init_AlreadyRunning = 143 , <nl> + VRInitError_Init_FailedForVrMonitor = 144 , <nl> + VRInitError_Init_PropertyManagerInitFailed = 145 , <nl> + VRInitError_Init_WebServerFailed = 146 , <nl> + <nl> + VRInitError_Driver_Failed = 200 , <nl> + VRInitError_Driver_Unknown = 201 , <nl> + VRInitError_Driver_HmdUnknown = 202 , <nl> + VRInitError_Driver_NotLoaded = 203 , <nl> + VRInitError_Driver_RuntimeOutOfDate = 204 , <nl> + VRInitError_Driver_HmdInUse = 205 , <nl> + VRInitError_Driver_NotCalibrated = 206 , <nl> + VRInitError_Driver_CalibrationInvalid = 207 , <nl> + VRInitError_Driver_HmdDisplayNotFound = 208 , <nl> + VRInitError_Driver_TrackedDeviceInterfaceUnknown = 209 , <nl> + / / VRInitError_Driver_HmdDisplayNotFoundAfterFix = 210 , / / not needed : here for historic reasons <nl> + VRInitError_Driver_HmdDriverIdOutOfBounds = 211 , <nl> + VRInitError_Driver_HmdDisplayMirrored = 212 , <nl> + VRInitError_Driver_HmdDisplayNotFoundLaptop = 213 , <nl> + / / Never make error 259 because we return it from main and it would conflict with STILL_ACTIVE <nl> + <nl> + VRInitError_IPC_ServerInitFailed = 300 , <nl> + VRInitError_IPC_ConnectFailed = 301 , <nl> + VRInitError_IPC_SharedStateInitFailed = 302 , <nl> + VRInitError_IPC_CompositorInitFailed = 303 , <nl> + VRInitError_IPC_MutexInitFailed = 304 , <nl> + VRInitError_IPC_Failed = 305 , <nl> + VRInitError_IPC_CompositorConnectFailed = 306 , <nl> + VRInitError_IPC_CompositorInvalidConnectResponse = 307 , <nl> + VRInitError_IPC_ConnectFailedAfterMultipleAttempts = 308 , <nl> + VRInitError_IPC_ConnectFailedAfterTargetExited = 309 , <nl> + VRInitError_IPC_NamespaceUnavailable = 310 , <nl> + <nl> + VRInitError_Compositor_Failed = 400 , <nl> + VRInitError_Compositor_D3D11HardwareRequired = 401 , <nl> + VRInitError_Compositor_FirmwareRequiresUpdate = 402 , <nl> + VRInitError_Compositor_OverlayInitFailed = 403 , <nl> + VRInitError_Compositor_ScreenshotsInitFailed = 404 , <nl> + VRInitError_Compositor_UnableToCreateDevice = 405 , <nl> + VRInitError_Compositor_SharedStateIsNull = 406 , <nl> + VRInitError_Compositor_NotificationManagerIsNull = 407 , <nl> + VRInitError_Compositor_ResourceManagerClientIsNull = 408 , <nl> + VRInitError_Compositor_MessageOverlaySharedStateInitFailure = 409 , <nl> + VRInitError_Compositor_PropertiesInterfaceIsNull = 410 , <nl> + VRInitError_Compositor_CreateFullscreenWindowFailed = 411 , <nl> + VRInitError_Compositor_SettingsInterfaceIsNull = 412 , <nl> + VRInitError_Compositor_FailedToShowWindow = 413 , <nl> + VRInitError_Compositor_DistortInterfaceIsNull = 414 , <nl> + VRInitError_Compositor_DisplayFrequencyFailure = 415 , <nl> + VRInitError_Compositor_RendererInitializationFailed = 416 , <nl> + VRInitError_Compositor_DXGIFactoryInterfaceIsNull = 417 , <nl> + VRInitError_Compositor_DXGIFactoryCreateFailed = 418 , <nl> + VRInitError_Compositor_DXGIFactoryQueryFailed = 419 , <nl> + VRInitError_Compositor_InvalidAdapterDesktop = 420 , <nl> + VRInitError_Compositor_InvalidHmdAttachment = 421 , <nl> + VRInitError_Compositor_InvalidOutputDesktop = 422 , <nl> + VRInitError_Compositor_InvalidDeviceProvided = 423 , <nl> + VRInitError_Compositor_D3D11RendererInitializationFailed = 424 , <nl> + VRInitError_Compositor_FailedToFindDisplayMode = 425 , <nl> + VRInitError_Compositor_FailedToCreateSwapChain = 426 , <nl> + VRInitError_Compositor_FailedToGetBackBuffer = 427 , <nl> + VRInitError_Compositor_FailedToCreateRenderTarget = 428 , <nl> + VRInitError_Compositor_FailedToCreateDXGI2SwapChain = 429 , <nl> + VRInitError_Compositor_FailedtoGetDXGI2BackBuffer = 430 , <nl> + VRInitError_Compositor_FailedToCreateDXGI2RenderTarget = 431 , <nl> + VRInitError_Compositor_FailedToGetDXGIDeviceInterface = 432 , <nl> + VRInitError_Compositor_SelectDisplayMode = 433 , <nl> + VRInitError_Compositor_FailedToCreateNvAPIRenderTargets = 434 , <nl> + VRInitError_Compositor_NvAPISetDisplayMode = 435 , <nl> + VRInitError_Compositor_FailedToCreateDirectModeDisplay = 436 , <nl> + VRInitError_Compositor_InvalidHmdPropertyContainer = 437 , <nl> + VRInitError_Compositor_UpdateDisplayFrequency = 438 , <nl> + VRInitError_Compositor_CreateRasterizerState = 439 , <nl> + VRInitError_Compositor_CreateWireframeRasterizerState = 440 , <nl> + VRInitError_Compositor_CreateSamplerState = 441 , <nl> + VRInitError_Compositor_CreateClampToBorderSamplerState = 442 , <nl> + VRInitError_Compositor_CreateAnisoSamplerState = 443 , <nl> + VRInitError_Compositor_CreateOverlaySamplerState = 444 , <nl> + VRInitError_Compositor_CreatePanoramaSamplerState = 445 , <nl> + VRInitError_Compositor_CreateFontSamplerState = 446 , <nl> + VRInitError_Compositor_CreateNoBlendState = 447 , <nl> + VRInitError_Compositor_CreateBlendState = 448 , <nl> + VRInitError_Compositor_CreateAlphaBlendState = 449 , <nl> + VRInitError_Compositor_CreateBlendStateMaskR = 450 , <nl> + VRInitError_Compositor_CreateBlendStateMaskG = 451 , <nl> + VRInitError_Compositor_CreateBlendStateMaskB = 452 , <nl> + VRInitError_Compositor_CreateDepthStencilState = 453 , <nl> + VRInitError_Compositor_CreateDepthStencilStateNoWrite = 454 , <nl> + VRInitError_Compositor_CreateDepthStencilStateNoDepth = 455 , <nl> + VRInitError_Compositor_CreateFlushTexture = 456 , <nl> + VRInitError_Compositor_CreateDistortionSurfaces = 457 , <nl> + VRInitError_Compositor_CreateConstantBuffer = 458 , <nl> + VRInitError_Compositor_CreateHmdPoseConstantBuffer = 459 , <nl> + VRInitError_Compositor_CreateHmdPoseStagingConstantBuffer = 460 , <nl> + VRInitError_Compositor_CreateSharedFrameInfoConstantBuffer = 461 , <nl> + VRInitError_Compositor_CreateOverlayConstantBuffer = 462 , <nl> + VRInitError_Compositor_CreateSceneTextureIndexConstantBuffer = 463 , <nl> + VRInitError_Compositor_CreateReadableSceneTextureIndexConstantBuffer = 464 , <nl> + VRInitError_Compositor_CreateLayerGraphicsTextureIndexConstantBuffer = 465 , <nl> + VRInitError_Compositor_CreateLayerComputeTextureIndexConstantBuffer = 466 , <nl> + VRInitError_Compositor_CreateLayerComputeSceneTextureIndexConstantBuffer = 467 , <nl> + VRInitError_Compositor_CreateComputeHmdPoseConstantBuffer = 468 , <nl> + VRInitError_Compositor_CreateGeomConstantBuffer = 469 , <nl> + VRInitError_Compositor_CreatePanelMaskConstantBuffer = 470 , <nl> + VRInitError_Compositor_CreatePixelSimUBO = 471 , <nl> + VRInitError_Compositor_CreateMSAARenderTextures = 472 , <nl> + VRInitError_Compositor_CreateResolveRenderTextures = 473 , <nl> + VRInitError_Compositor_CreateComputeResolveRenderTextures = 474 , <nl> + VRInitError_Compositor_CreateDriverDirectModeResolveTextures = 475 , <nl> + VRInitError_Compositor_OpenDriverDirectModeResolveTextures = 476 , <nl> + VRInitError_Compositor_CreateFallbackSyncTexture = 477 , <nl> + VRInitError_Compositor_ShareFallbackSyncTexture = 478 , <nl> + VRInitError_Compositor_CreateOverlayIndexBuffer = 479 , <nl> + VRInitError_Compositor_CreateOverlayVertexBuffer = 480 , <nl> + VRInitError_Compositor_CreateTextVertexBuffer = 481 , <nl> + VRInitError_Compositor_CreateTextIndexBuffer = 482 , <nl> + VRInitError_Compositor_CreateMirrorTextures = 483 , <nl> + VRInitError_Compositor_CreateLastFrameRenderTexture = 484 , <nl> + VRInitError_Compositor_CreateMirrorOverlay = 485 , <nl> + VRInitError_Compositor_FailedToCreateVirtualDisplayBackbuffer = 486 , <nl> + VRInitError_Compositor_DisplayModeNotSupported = 487 , <nl> + VRInitError_Compositor_CreateOverlayInvalidCall = 488 , <nl> + VRInitError_Compositor_CreateOverlayAlreadyInitialized = 489 , <nl> + VRInitError_Compositor_FailedToCreateMailbox = 490 , <nl> + <nl> + VRInitError_VendorSpecific_UnableToConnectToOculusRuntime = 1000 , <nl> + VRInitError_VendorSpecific_WindowsNotInDevMode = 1001 , <nl> + <nl> + VRInitError_VendorSpecific_HmdFound_CantOpenDevice = 1101 , <nl> + VRInitError_VendorSpecific_HmdFound_UnableToRequestConfigStart = 1102 , <nl> + VRInitError_VendorSpecific_HmdFound_NoStoredConfig = 1103 , <nl> + VRInitError_VendorSpecific_HmdFound_ConfigTooBig = 1104 , <nl> + VRInitError_VendorSpecific_HmdFound_ConfigTooSmall = 1105 , <nl> + VRInitError_VendorSpecific_HmdFound_UnableToInitZLib = 1106 , <nl> + VRInitError_VendorSpecific_HmdFound_CantReadFirmwareVersion = 1107 , <nl> + VRInitError_VendorSpecific_HmdFound_UnableToSendUserDataStart = 1108 , <nl> + VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataStart = 1109 , <nl> + VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataNext = 1110 , <nl> + VRInitError_VendorSpecific_HmdFound_UserDataAddressRange = 1111 , <nl> + VRInitError_VendorSpecific_HmdFound_UserDataError = 1112 , <nl> + VRInitError_VendorSpecific_HmdFound_ConfigFailedSanityCheck = 1113 , <nl> + VRInitError_VendorSpecific_OculusRuntimeBadInstall = 1114 , <nl> + <nl> + VRInitError_Steam_SteamInstallationNotFound = 2000 , <nl> + <nl> + / / Strictly a placeholder <nl> + VRInitError_LastError <nl> + } ; <nl> + <nl> + enum EVRScreenshotType <nl> + { <nl> + VRScreenshotType_None = 0 , <nl> + VRScreenshotType_Mono = 1 , / / left eye only <nl> + VRScreenshotType_Stereo = 2 , <nl> + VRScreenshotType_Cubemap = 3 , <nl> + VRScreenshotType_MonoPanorama = 4 , <nl> + VRScreenshotType_StereoPanorama = 5 <nl> + } ; <nl> + <nl> + enum EVRScreenshotPropertyFilenames <nl> + { <nl> + VRScreenshotPropertyFilenames_Preview = 0 , <nl> + VRScreenshotPropertyFilenames_VR = 1 , <nl> + } ; <nl> + <nl> + enum EVRTrackedCameraError <nl> + { <nl> + VRTrackedCameraError_None = 0 , <nl> + VRTrackedCameraError_OperationFailed = 100 , <nl> + VRTrackedCameraError_InvalidHandle = 101 , <nl> + VRTrackedCameraError_InvalidFrameHeaderVersion = 102 , <nl> + VRTrackedCameraError_OutOfHandles = 103 , <nl> + VRTrackedCameraError_IPCFailure = 104 , <nl> + VRTrackedCameraError_NotSupportedForThisDevice = 105 , <nl> + VRTrackedCameraError_SharedMemoryFailure = 106 , <nl> + VRTrackedCameraError_FrameBufferingFailure = 107 , <nl> + VRTrackedCameraError_StreamSetupFailure = 108 , <nl> + VRTrackedCameraError_InvalidGLTextureId = 109 , <nl> + VRTrackedCameraError_InvalidSharedTextureHandle = 110 , <nl> + VRTrackedCameraError_FailedToGetGLTextureId = 111 , <nl> + VRTrackedCameraError_SharedTextureFailure = 112 , <nl> + VRTrackedCameraError_NoFrameAvailable = 113 , <nl> + VRTrackedCameraError_InvalidArgument = 114 , <nl> + VRTrackedCameraError_InvalidFrameBufferSize = 115 , <nl> + } ; <nl> + <nl> + enum EVRTrackedCameraFrameLayout <nl> + { <nl> + EVRTrackedCameraFrameLayout_Mono = 0x0001 , <nl> + EVRTrackedCameraFrameLayout_Stereo = 0x0002 , <nl> + EVRTrackedCameraFrameLayout_VerticalLayout = 0x0010 , / / Stereo frames are Top / Bottom ( left / right ) <nl> + EVRTrackedCameraFrameLayout_HorizontalLayout = 0x0020 , / / Stereo frames are Left / Right <nl> + } ; <nl> + <nl> + enum EVRTrackedCameraFrameType <nl> + { <nl> + VRTrackedCameraFrameType_Distorted = 0 , / / This is the camera video frame size in pixels , still distorted . <nl> + VRTrackedCameraFrameType_Undistorted , / / In pixels , an undistorted inscribed rectangle region without invalid regions . This size is subject to changes shortly . <nl> + VRTrackedCameraFrameType_MaximumUndistorted , / / In pixels , maximum undistorted with invalid regions . Non zero alpha component identifies valid regions . <nl> + MAX_CAMERA_FRAME_TYPES <nl> + } ; <nl> + <nl> + enum EVRDistortionFunctionType <nl> + { <nl> + VRDistortionFunctionType_None , <nl> + VRDistortionFunctionType_FTheta , <nl> + VRDistortionFunctionType_Extended_FTheta , <nl> + MAX_DISTORTION_FUNCTION_TYPES , <nl> + } ; <nl> + <nl> + static const uint32_t k_unMaxDistortionFunctionParameters = 8 ; <nl> + <nl> + typedef uint64_t TrackedCameraHandle_t ; <nl> + # define INVALID_TRACKED_CAMERA_HANDLE ( ( vr : : TrackedCameraHandle_t ) 0 ) <nl> + <nl> + struct CameraVideoStreamFrameHeader_t <nl> + { <nl> + EVRTrackedCameraFrameType eFrameType ; <nl> + <nl> + uint32_t nWidth ; <nl> + uint32_t nHeight ; <nl> + uint32_t nBytesPerPixel ; <nl> + <nl> + uint32_t nFrameSequence ; <nl> + <nl> + TrackedDevicePose_t trackedDevicePose ; <nl> + <nl> + uint64_t ulFrameExposureTime ; / / mid - point of the exposure of the image in host system ticks <nl> + } ; <nl> + <nl> + / / Screenshot types <nl> + typedef uint32_t ScreenshotHandle_t ; <nl> + <nl> + static const uint32_t k_unScreenshotHandleInvalid = 0 ; <nl> + <nl> + / * * Compositor frame timing reprojection flags . * / <nl> + const uint32_t VRCompositor_ReprojectionReason_Cpu = 0x01 ; <nl> + const uint32_t VRCompositor_ReprojectionReason_Gpu = 0x02 ; <nl> + const uint32_t VRCompositor_ReprojectionAsync = 0x04 ; / / This flag indicates the async reprojection mode is active , <nl> + / / but does not indicate if reprojection actually happened or not . <nl> + / / Use the ReprojectionReason flags above to check if reprojection <nl> + / / was actually applied ( i . e . scene texture was reused ) . <nl> + / / NumFramePresents > 1 also indicates the scene texture was reused , <nl> + / / and also the number of times that it was presented in total . <nl> + <nl> + const uint32_t VRCompositor_ReprojectionMotion = 0x08 ; / / This flag indicates whether or not motion smoothing was triggered for this frame <nl> + <nl> + const uint32_t VRCompositor_PredictionMask = 0x30 ; / / The runtime may predict more than one frame ( up to four ) ahead if <nl> + / / it detects the application is taking too long to render . These two <nl> + / / bits will contain the count of additional frames ( normally zero ) . <nl> + / / Use the VR_COMPOSITOR_ADDITIONAL_PREDICTED_FRAMES macro to read from <nl> + / / the latest frame timing entry . <nl> + <nl> + const uint32_t VRCompositor_ThrottleMask = 0xC0 ; / / Number of frames the compositor is throttling the application . <nl> + / / Use the VR_COMPOSITOR_NUMBER_OF_THROTTLED_FRAMES macro to read from <nl> + / / the latest frame timing entry . <nl> + <nl> + # define VR_COMPOSITOR_ADDITIONAL_PREDICTED_FRAMES ( timing ) ( ( ( timing ) . m_nReprojectionFlags & vr : : VRCompositor_PredictionMask ) > > 4 ) <nl> + # define VR_COMPOSITOR_NUMBER_OF_THROTTLED_FRAMES ( timing ) ( ( ( timing ) . m_nReprojectionFlags & vr : : VRCompositor_ThrottleMask ) > > 6 ) <nl> + <nl> + / * * Provides a single frame ' s timing information to the app * / <nl> + struct Compositor_FrameTiming <nl> + { <nl> + uint32_t m_nSize ; / / Set to sizeof ( Compositor_FrameTiming ) <nl> + uint32_t m_nFrameIndex ; <nl> + uint32_t m_nNumFramePresents ; / / number of times this frame was presented <nl> + uint32_t m_nNumMisPresented ; / / number of times this frame was presented on a vsync other than it was originally predicted to <nl> + uint32_t m_nNumDroppedFrames ; / / number of additional times previous frame was scanned out <nl> + uint32_t m_nReprojectionFlags ; <nl> + <nl> + / * * Absolute time reference for comparing frames . This aligns with the vsync that running start is relative to . * / <nl> + double m_flSystemTimeInSeconds ; <nl> + <nl> + / * * These times may include work from other processes due to OS scheduling . <nl> + * The fewer packets of work these are broken up into , the less likely this will happen . <nl> + * GPU work can be broken up by calling Flush . This can sometimes be useful to get the GPU started <nl> + * processing that work earlier in the frame . * / <nl> + float m_flPreSubmitGpuMs ; / / time spent rendering the scene ( gpu work submitted between WaitGetPoses and second Submit ) <nl> + float m_flPostSubmitGpuMs ; / / additional time spent rendering by application ( e . g . companion window ) <nl> + float m_flTotalRenderGpuMs ; / / time between work submitted immediately after present ( ideally vsync ) until the end of compositor submitted work <nl> + float m_flCompositorRenderGpuMs ; / / time spend performing distortion correction , rendering chaperone , overlays , etc . <nl> + float m_flCompositorRenderCpuMs ; / / time spent on cpu submitting the above work for this frame <nl> + float m_flCompositorIdleCpuMs ; / / time spent waiting for running start ( application could have used this much more time ) <nl> + <nl> + / * * Miscellaneous measured intervals . * / <nl> + float m_flClientFrameIntervalMs ; / / time between calls to WaitGetPoses <nl> + float m_flPresentCallCpuMs ; / / time blocked on call to present ( usually 0 . 0 , but can go long ) <nl> + float m_flWaitForPresentCpuMs ; / / time spent spin - waiting for frame index to change ( not near - zero indicates wait object failure ) <nl> + float m_flSubmitFrameMs ; / / time spent in IVRCompositor : : Submit ( not near - zero indicates driver issue ) <nl> + <nl> + / * * The following are all relative to this frame ' s SystemTimeInSeconds * / <nl> + float m_flWaitGetPosesCalledMs ; <nl> + float m_flNewPosesReadyMs ; <nl> + float m_flNewFrameReadyMs ; / / second call to IVRCompositor : : Submit <nl> + float m_flCompositorUpdateStartMs ; <nl> + float m_flCompositorUpdateEndMs ; <nl> + float m_flCompositorRenderStartMs ; <nl> + <nl> + vr : : TrackedDevicePose_t m_HmdPose ; / / pose used by app to render this frame <nl> + <nl> + uint32_t m_nNumVSyncsReadyForUse ; <nl> + uint32_t m_nNumVSyncsToFirstView ; <nl> + } ; <nl> + <nl> + / * * Provides compositor benchmark results to the app * / <nl> + struct Compositor_BenchmarkResults <nl> + { <nl> + float m_flMegaPixelsPerSecond ; / / Measurement of GPU MP / s performed by compositor benchmark <nl> + float m_flHmdRecommendedMegaPixelsPerSecond ; / / Recommended default MP / s given the HMD resolution , refresh , and panel mask . <nl> + } ; <nl> + <nl> + / * * Frame timing data provided by direct mode drivers . * / <nl> + struct DriverDirectMode_FrameTiming <nl> + { <nl> + uint32_t m_nSize ; / / Set to sizeof ( DriverDirectMode_FrameTiming ) <nl> + uint32_t m_nNumFramePresents ; / / number of times frame was presented <nl> + uint32_t m_nNumMisPresented ; / / number of times frame was presented on a vsync other than it was originally predicted to <nl> + uint32_t m_nNumDroppedFrames ; / / number of additional times previous frame was scanned out ( i . e . compositor missed vsync ) <nl> + uint32_t m_nReprojectionFlags ; <nl> + } ; <nl> + <nl> + / * * These flags will be set on DriverDirectMode_FrameTiming : : m_nReprojectionFlags when IVRDriverDirectModeComponent : : GetFrameTiming is called for drivers to optionally respond to . * / <nl> + const uint32_t VRCompositor_ReprojectionMotion_Enabled = 0x100 ; / / Motion Smoothing is enabled in the UI for the currently running application <nl> + const uint32_t VRCompositor_ReprojectionMotion_ForcedOn = 0x200 ; / / Motion Smoothing is forced on in the UI for the currently running application <nl> + const uint32_t VRCompositor_ReprojectionMotion_AppThrottled = 0x400 ; / / Application is requesting throttling via ForceInterleavedReprojectionOn <nl> + <nl> + <nl> + enum EVSync <nl> + { <nl> + VSync_None , <nl> + VSync_WaitRender , / / block following render work until vsync <nl> + VSync_NoWaitRender , / / do not block following render work ( allow to get started early ) <nl> + } ; <nl> + <nl> + enum EVRMuraCorrectionMode <nl> + { <nl> + EVRMuraCorrectionMode_Default = 0 , <nl> + EVRMuraCorrectionMode_NoCorrection <nl> + } ; <nl> + <nl> + / * * raw IMU data provided by IVRIOBuffer from paths to tracked devices with IMUs * / <nl> + enum Imu_OffScaleFlags <nl> + { <nl> + OffScale_AccelX = 0x01 , <nl> + OffScale_AccelY = 0x02 , <nl> + OffScale_AccelZ = 0x04 , <nl> + OffScale_GyroX = 0x08 , <nl> + OffScale_GyroY = 0x10 , <nl> + OffScale_GyroZ = 0x20 , <nl> + } ; <nl> + <nl> + struct ImuSample_t <nl> + { <nl> + double fSampleTime ; <nl> + HmdVector3d_t vAccel ; <nl> + HmdVector3d_t vGyro ; <nl> + uint32_t unOffScaleFlags ; <nl> + } ; <nl> + <nl> + # pragma pack ( pop ) <nl> + <nl> + / / figure out how to import from the VR API dll <nl> + # if defined ( _WIN32 ) <nl> + <nl> + # if ! defined ( OPENVR_BUILD_STATIC ) <nl> + # ifdef VR_API_EXPORT <nl> + # define VR_INTERFACE extern " C " __declspec ( dllexport ) <nl> + # else <nl> + # define VR_INTERFACE extern " C " __declspec ( dllimport ) <nl> + # endif <nl> + # else <nl> + # define VR_INTERFACE extern " C " <nl> + # endif <nl> + <nl> + # elif defined ( __GNUC__ ) | | defined ( COMPILER_GCC ) | | defined ( __APPLE__ ) <nl> + <nl> + # ifdef VR_API_EXPORT <nl> + # define VR_INTERFACE extern " C " __attribute__ ( ( visibility ( " default " ) ) ) <nl> + # else <nl> + # define VR_INTERFACE extern " C " <nl> + # endif <nl> + <nl> + # else <nl> + # error " Unsupported Platform . " <nl> + # endif <nl> + <nl> + <nl> + # if defined ( _WIN32 ) <nl> + # define VR_CALLTYPE __cdecl <nl> + # else <nl> + # define VR_CALLTYPE <nl> + # endif <nl> + <nl> + } / / namespace vr <nl> + <nl> + # endif / / _INCLUDE_VRTYPES_H <nl> + <nl> + <nl> + / / vrannotation . h <nl> + # ifdef API_GEN <nl> + # define VR_CLANG_ATTR ( ATTR ) __attribute__ ( ( annotate ( ATTR ) ) ) <nl> + # else <nl> + # define VR_CLANG_ATTR ( ATTR ) <nl> + # endif <nl> + <nl> + # define VR_METHOD_DESC ( DESC ) VR_CLANG_ATTR ( " desc : " # DESC " ; " ) <nl> + # define VR_IGNOREATTR ( ) VR_CLANG_ATTR ( " ignore " ) <nl> + # define VR_OUT_STRUCT ( ) VR_CLANG_ATTR ( " out_struct : ; " ) <nl> + # define VR_OUT_STRING ( ) VR_CLANG_ATTR ( " out_string : ; " ) <nl> + # define VR_OUT_ARRAY_CALL ( COUNTER , FUNCTION , PARAMS ) VR_CLANG_ATTR ( " out_array_call : " # COUNTER " , " # FUNCTION " , " # PARAMS " ; " ) <nl> + # define VR_OUT_ARRAY_COUNT ( COUNTER ) VR_CLANG_ATTR ( " out_array_count : " # COUNTER " ; " ) <nl> + # define VR_ARRAY_COUNT ( COUNTER ) VR_CLANG_ATTR ( " array_count : " # COUNTER " ; " ) <nl> + # define VR_ARRAY_COUNT_D ( COUNTER , DESC ) VR_CLANG_ATTR ( " array_count : " # COUNTER " ; desc : " # DESC ) <nl> + # define VR_BUFFER_COUNT ( COUNTER ) VR_CLANG_ATTR ( " buffer_count : " # COUNTER " ; " ) <nl> + # define VR_OUT_BUFFER_COUNT ( COUNTER ) VR_CLANG_ATTR ( " out_buffer_count : " # COUNTER " ; " ) <nl> + # define VR_OUT_STRING_COUNT ( COUNTER ) VR_CLANG_ATTR ( " out_string_count : " # COUNTER " ; " ) <nl> + <nl> + / / ivrsystem . h <nl> + namespace vr <nl> + { <nl> + <nl> + class IVRSystem <nl> + { <nl> + public : <nl> + <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / Display Methods <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + <nl> + / * * Suggested size for the intermediate render target that the distortion pulls from . * / <nl> + virtual void GetRecommendedRenderTargetSize ( uint32_t * pnWidth , uint32_t * pnHeight ) = 0 ; <nl> + <nl> + / * * The projection matrix for the specified eye * / <nl> + virtual HmdMatrix44_t GetProjectionMatrix ( EVREye eEye , float fNearZ , float fFarZ ) = 0 ; <nl> + <nl> + / * * The components necessary to build your own projection matrix in case your <nl> + * application is doing something fancy like infinite Z * / <nl> + virtual void GetProjectionRaw ( EVREye eEye , float * pfLeft , float * pfRight , float * pfTop , float * pfBottom ) = 0 ; <nl> + <nl> + / * * Gets the result of the distortion function for the specified eye and input UVs . UVs go from 0 , 0 in <nl> + * the upper left of that eye ' s viewport and 1 , 1 in the lower right of that eye ' s viewport . <nl> + * Returns true for success . Otherwise , returns false , and distortion coordinates are not suitable . * / <nl> + virtual bool ComputeDistortion ( EVREye eEye , float fU , float fV , DistortionCoordinates_t * pDistortionCoordinates ) = 0 ; <nl> + <nl> + / * * Returns the transform from eye space to the head space . Eye space is the per - eye flavor of head <nl> + * space that provides stereo disparity . Instead of Model * View * Projection the sequence is Model * View * Eye ^ - 1 * Projection . <nl> + * Normally View and Eye ^ - 1 will be multiplied together and treated as View in your application . <nl> + * / <nl> + virtual HmdMatrix34_t GetEyeToHeadTransform ( EVREye eEye ) = 0 ; <nl> + <nl> + / * * Returns the number of elapsed seconds since the last recorded vsync event . This <nl> + * will come from a vsync timer event in the timer if possible or from the application - reported <nl> + * time if that is not available . If no vsync times are available the function will <nl> + * return zero for vsync time and frame counter and return false from the method . * / <nl> + virtual bool GetTimeSinceLastVsync ( float * pfSecondsSinceLastVsync , uint64_t * pulFrameCounter ) = 0 ; <nl> + <nl> + / * * [ D3D9 Only ] <nl> + * Returns the adapter index that the user should pass into CreateDevice to set up D3D9 in such <nl> + * a way that it can go full screen exclusive on the HMD . Returns - 1 if there was an error . <nl> + * / <nl> + virtual int32_t GetD3D9AdapterIndex ( ) = 0 ; <nl> + <nl> + / * * [ D3D10 / 11 Only ] <nl> + * Returns the adapter index that the user should pass into EnumAdapters to create the device <nl> + * and swap chain in DX10 and DX11 . If an error occurs the index will be set to - 1 . <nl> + * / <nl> + virtual void GetDXGIOutputInfo ( int32_t * pnAdapterIndex ) = 0 ; <nl> + <nl> + / * * <nl> + * Returns platform - and texture - type specific adapter identification so that applications and the <nl> + * compositor are creating textures and swap chains on the same GPU . If an error occurs the device <nl> + * will be set to 0 . <nl> + * pInstance is an optional parameter that is required only when textureType is TextureType_Vulkan . <nl> + * [ D3D10 / 11 / 12 Only ( D3D9 Not Supported ) ] <nl> + * Returns the adapter LUID that identifies the GPU attached to the HMD . The user should <nl> + * enumerate all adapters using IDXGIFactory : : EnumAdapters and IDXGIAdapter : : GetDesc to find <nl> + * the adapter with the matching LUID , or use IDXGIFactory4 : : EnumAdapterByLuid . <nl> + * The discovered IDXGIAdapter should be used to create the device and swap chain . <nl> + * [ Vulkan Only ] <nl> + * Returns the VkPhysicalDevice that should be used by the application . <nl> + * pInstance must be the instance the application will use to query for the VkPhysicalDevice . The application <nl> + * must create the VkInstance with extensions returned by IVRCompositor : : GetVulkanInstanceExtensionsRequired enabled . <nl> + * [ macOS Only ] <nl> + * For TextureType_IOSurface returns the id < MTLDevice > that should be used by the application . <nl> + * On 10 . 13 + for TextureType_OpenGL returns the ' registryId ' of the renderer which should be used <nl> + * by the application . See Apple Technical Q & A QA1168 for information on enumerating GL Renderers , and the <nl> + * new kCGLRPRegistryIDLow and kCGLRPRegistryIDHigh CGLRendererProperty values in the 10 . 13 SDK . <nl> + * Pre 10 . 13 for TextureType_OpenGL returns 0 , as there is no dependable way to correlate the HMDs MTLDevice <nl> + * with a GL Renderer . <nl> + * / <nl> + virtual void GetOutputDevice ( uint64_t * pnDevice , ETextureType textureType , VkInstance_T * pInstance = nullptr ) = 0 ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / Display Mode methods <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + <nl> + / * * Use to determine if the headset display is part of the desktop ( i . e . extended ) or hidden ( i . e . direct mode ) . * / <nl> + virtual bool IsDisplayOnDesktop ( ) = 0 ; <nl> + <nl> + / * * Set the display visibility ( true = extended , false = direct mode ) . Return value of true indicates that the change was successful . * / <nl> + virtual bool SetDisplayVisibility ( bool bIsVisibleOnDesktop ) = 0 ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / Tracking Methods <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + <nl> + / * * The pose that the tracker thinks that the HMD will be in at the specified number of seconds into the <nl> + * future . Pass 0 to get the state at the instant the method is called . Most of the time the application should <nl> + * calculate the time until the photons will be emitted from the display and pass that time into the method . <nl> + * <nl> + * This is roughly analogous to the inverse of the view matrix in most applications , though <nl> + * many games will need to do some additional rotation or translation on top of the rotation <nl> + * and translation provided by the head pose . <nl> + * <nl> + * For devices where bPoseIsValid is true the application can use the pose to position the device <nl> + * in question . The provided array can be any size up to k_unMaxTrackedDeviceCount . <nl> + * <nl> + * Seated experiences should call this method with TrackingUniverseSeated and receive poses relative <nl> + * to the seated zero pose . Standing experiences should call this method with TrackingUniverseStanding <nl> + * and receive poses relative to the Chaperone Play Area . TrackingUniverseRawAndUncalibrated should <nl> + * probably not be used unless the application is the Chaperone calibration tool itself , but will provide <nl> + * poses relative to the hardware - specific coordinate system in the driver . <nl> + * / <nl> + virtual void GetDeviceToAbsoluteTrackingPose ( ETrackingUniverseOrigin eOrigin , float fPredictedSecondsToPhotonsFromNow , VR_ARRAY_COUNT ( unTrackedDevicePoseArrayCount ) TrackedDevicePose_t * pTrackedDevicePoseArray , uint32_t unTrackedDevicePoseArrayCount ) = 0 ; <nl> + <nl> + / * * Sets the zero pose for the seated tracker coordinate system to the current position and yaw of the HMD . After <nl> + * ResetSeatedZeroPose all GetDeviceToAbsoluteTrackingPose calls that pass TrackingUniverseSeated as the origin <nl> + * will be relative to this new zero pose . The new zero coordinate system will not change the fact that the Y axis <nl> + * is up in the real world , so the next pose returned from GetDeviceToAbsoluteTrackingPose after a call to <nl> + * ResetSeatedZeroPose may not be exactly an identity matrix . <nl> + * <nl> + * NOTE : This function overrides the user ' s previously saved seated zero pose and should only be called as the result of a user action . <nl> + * Users are also able to set their seated zero pose via the OpenVR Dashboard . <nl> + * * / <nl> + virtual void ResetSeatedZeroPose ( ) = 0 ; <nl> + <nl> + / * * Returns the transform from the seated zero pose to the standing absolute tracking system . This allows <nl> + * applications to represent the seated origin to used or transform object positions from one coordinate <nl> + * system to the other . <nl> + * <nl> + * The seated origin may or may not be inside the Play Area or Collision Bounds returned by IVRChaperone . Its position <nl> + * depends on what the user has set from the Dashboard settings and previous calls to ResetSeatedZeroPose . * / <nl> + virtual HmdMatrix34_t GetSeatedZeroPoseToStandingAbsoluteTrackingPose ( ) = 0 ; <nl> + <nl> + / * * Returns the transform from the tracking origin to the standing absolute tracking system . This allows <nl> + * applications to convert from raw tracking space to the calibrated standing coordinate system . * / <nl> + virtual HmdMatrix34_t GetRawZeroPoseToStandingAbsoluteTrackingPose ( ) = 0 ; <nl> + <nl> + / * * Get a sorted array of device indices of a given class of tracked devices ( e . g . controllers ) . Devices are sorted right to left <nl> + * relative to the specified tracked device ( default : hmd - - pass in - 1 for absolute tracking space ) . Returns the number of devices <nl> + * in the list , or the size of the array needed if not large enough . * / <nl> + virtual uint32_t GetSortedTrackedDeviceIndicesOfClass ( ETrackedDeviceClass eTrackedDeviceClass , VR_ARRAY_COUNT ( unTrackedDeviceIndexArrayCount ) vr : : TrackedDeviceIndex_t * punTrackedDeviceIndexArray , uint32_t unTrackedDeviceIndexArrayCount , vr : : TrackedDeviceIndex_t unRelativeToTrackedDeviceIndex = k_unTrackedDeviceIndex_Hmd ) = 0 ; <nl> + <nl> + / * * Returns the level of activity on the device . * / <nl> + virtual EDeviceActivityLevel GetTrackedDeviceActivityLevel ( vr : : TrackedDeviceIndex_t unDeviceId ) = 0 ; <nl> + <nl> + / * * Convenience utility to apply the specified transform to the specified pose . <nl> + * This properly transforms all pose components , including velocity and angular velocity <nl> + * / <nl> + virtual void ApplyTransform ( TrackedDevicePose_t * pOutputPose , const TrackedDevicePose_t * pTrackedDevicePose , const HmdMatrix34_t * pTransform ) = 0 ; <nl> + <nl> + / * * Returns the device index associated with a specific role , for example the left hand or the right hand . This function is deprecated in favor of the new IVRInput system . * / <nl> + virtual vr : : TrackedDeviceIndex_t GetTrackedDeviceIndexForControllerRole ( vr : : ETrackedControllerRole unDeviceType ) = 0 ; <nl> + <nl> + / * * Returns the controller type associated with a device index . This function is deprecated in favor of the new IVRInput system . * / <nl> + virtual vr : : ETrackedControllerRole GetControllerRoleForTrackedDeviceIndex ( vr : : TrackedDeviceIndex_t unDeviceIndex ) = 0 ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / Property methods <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + <nl> + / * * Returns the device class of a tracked device . If there has not been a device connected in this slot <nl> + * since the application started this function will return TrackedDevice_Invalid . For previous detected <nl> + * devices the function will return the previously observed device class . <nl> + * <nl> + * To determine which devices exist on the system , just loop from 0 to k_unMaxTrackedDeviceCount and check <nl> + * the device class . Every device with something other than TrackedDevice_Invalid is associated with an <nl> + * actual tracked device . * / <nl> + virtual ETrackedDeviceClass GetTrackedDeviceClass ( vr : : TrackedDeviceIndex_t unDeviceIndex ) = 0 ; <nl> + <nl> + / * * Returns true if there is a device connected in this slot . * / <nl> + virtual bool IsTrackedDeviceConnected ( vr : : TrackedDeviceIndex_t unDeviceIndex ) = 0 ; <nl> + <nl> + / * * Returns a bool property . If the device index is not valid or the property is not a bool type this function will return false . * / <nl> + virtual bool GetBoolTrackedDeviceProperty ( vr : : TrackedDeviceIndex_t unDeviceIndex , ETrackedDeviceProperty prop , ETrackedPropertyError * pError = 0L ) = 0 ; <nl> + <nl> + / * * Returns a float property . If the device index is not valid or the property is not a float type this function will return 0 . * / <nl> + virtual float GetFloatTrackedDeviceProperty ( vr : : TrackedDeviceIndex_t unDeviceIndex , ETrackedDeviceProperty prop , ETrackedPropertyError * pError = 0L ) = 0 ; <nl> + <nl> + / * * Returns an int property . If the device index is not valid or the property is not a int type this function will return 0 . * / <nl> + virtual int32_t GetInt32TrackedDeviceProperty ( vr : : TrackedDeviceIndex_t unDeviceIndex , ETrackedDeviceProperty prop , ETrackedPropertyError * pError = 0L ) = 0 ; <nl> + <nl> + / * * Returns a uint64 property . If the device index is not valid or the property is not a uint64 type this function will return 0 . * / <nl> + virtual uint64_t GetUint64TrackedDeviceProperty ( vr : : TrackedDeviceIndex_t unDeviceIndex , ETrackedDeviceProperty prop , ETrackedPropertyError * pError = 0L ) = 0 ; <nl> + <nl> + / * * Returns a matrix property . If the device index is not valid or the property is not a matrix type , this function will return identity . * / <nl> + virtual HmdMatrix34_t GetMatrix34TrackedDeviceProperty ( vr : : TrackedDeviceIndex_t unDeviceIndex , ETrackedDeviceProperty prop , ETrackedPropertyError * pError = 0L ) = 0 ; <nl> + <nl> + / * * Returns an array of one type of property . If the device index is not valid or the property is not a single value or an array of the specified type , <nl> + * this function will return 0 . Otherwise it returns the number of bytes necessary to hold the array of properties . If unBufferSize is <nl> + * greater than the returned size and pBuffer is non - NULL , pBuffer is filled with the contents of array of properties . * / <nl> + virtual uint32_t GetArrayTrackedDeviceProperty ( vr : : TrackedDeviceIndex_t unDeviceIndex , ETrackedDeviceProperty prop , PropertyTypeTag_t propType , void * pBuffer , uint32_t unBufferSize , ETrackedPropertyError * pError = 0L ) = 0 ; <nl> + <nl> + / * * Returns a string property . If the device index is not valid or the property is not a string type this function will <nl> + * return 0 . Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing <nl> + * null . Strings will always fit in buffers of k_unMaxPropertyStringSize characters . * / <nl> + virtual uint32_t GetStringTrackedDeviceProperty ( vr : : TrackedDeviceIndex_t unDeviceIndex , ETrackedDeviceProperty prop , VR_OUT_STRING ( ) char * pchValue , uint32_t unBufferSize , ETrackedPropertyError * pError = 0L ) = 0 ; <nl> + <nl> + / * * returns a string that corresponds with the specified property error . The string will be the name <nl> + * of the error enum value for all valid error codes * / <nl> + virtual const char * GetPropErrorNameFromEnum ( ETrackedPropertyError error ) = 0 ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / Event methods <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + <nl> + / * * Returns true and fills the event with the next event on the queue if there is one . If there are no events <nl> + * this method returns false . uncbVREvent should be the size in bytes of the VREvent_t struct * / <nl> + virtual bool PollNextEvent ( VREvent_t * pEvent , uint32_t uncbVREvent ) = 0 ; <nl> + <nl> + / * * Returns true and fills the event with the next event on the queue if there is one . If there are no events <nl> + * this method returns false . Fills in the pose of the associated tracked device in the provided pose struct . <nl> + * This pose will always be older than the call to this function and should not be used to render the device . <nl> + uncbVREvent should be the size in bytes of the VREvent_t struct * / <nl> + virtual bool PollNextEventWithPose ( ETrackingUniverseOrigin eOrigin , VREvent_t * pEvent , uint32_t uncbVREvent , vr : : TrackedDevicePose_t * pTrackedDevicePose ) = 0 ; <nl> + <nl> + / * * returns the name of an EVREvent enum value * / <nl> + virtual const char * GetEventTypeNameFromEnum ( EVREventType eType ) = 0 ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / Rendering helper methods <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + <nl> + / * * Returns the hidden area mesh for the current HMD . The pixels covered by this mesh will never be seen by the user after the lens distortion is <nl> + * applied based on visibility to the panels . If this HMD does not have a hidden area mesh , the vertex data and count will be NULL and 0 respectively . <nl> + * This mesh is meant to be rendered into the stencil buffer ( or into the depth buffer setting nearz ) before rendering each eye ' s view . <nl> + * This will improve performance by letting the GPU early - reject pixels the user will never see before running the pixel shader . <nl> + * NOTE : Render this mesh with backface culling disabled since the winding order of the vertices can be different per - HMD or per - eye . <nl> + * Setting the bInverse argument to true will produce the visible area mesh that is commonly used in place of full - screen quads . The visible area mesh covers all of the pixels the hidden area mesh does not cover . <nl> + * Setting the bLineLoop argument will return a line loop of vertices in HiddenAreaMesh_t - > pVertexData with HiddenAreaMesh_t - > unTriangleCount set to the number of vertices . <nl> + * / <nl> + virtual HiddenAreaMesh_t GetHiddenAreaMesh ( EVREye eEye , EHiddenAreaMeshType type = k_eHiddenAreaMesh_Standard ) = 0 ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / Controller methods <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + <nl> + / * * Fills the supplied struct with the current state of the controller . Returns false if the controller index <nl> + * is invalid . This function is deprecated in favor of the new IVRInput system . * / <nl> + virtual bool GetControllerState ( vr : : TrackedDeviceIndex_t unControllerDeviceIndex , vr : : VRControllerState_t * pControllerState , uint32_t unControllerStateSize ) = 0 ; <nl> + <nl> + / * * fills the supplied struct with the current state of the controller and the provided pose with the pose of <nl> + * the controller when the controller state was updated most recently . Use this form if you need a precise controller <nl> + * pose as input to your application when the user presses or releases a button . This function is deprecated in favor of the new IVRInput system . * / <nl> + virtual bool GetControllerStateWithPose ( ETrackingUniverseOrigin eOrigin , vr : : TrackedDeviceIndex_t unControllerDeviceIndex , vr : : VRControllerState_t * pControllerState , uint32_t unControllerStateSize , TrackedDevicePose_t * pTrackedDevicePose ) = 0 ; <nl> + <nl> + / * * Trigger a single haptic pulse on a controller . After this call the application may not trigger another haptic pulse on this controller <nl> + * and axis combination for 5ms . This function is deprecated in favor of the new IVRInput system . * / <nl> + virtual void TriggerHapticPulse ( vr : : TrackedDeviceIndex_t unControllerDeviceIndex , uint32_t unAxisId , unsigned short usDurationMicroSec ) = 0 ; <nl> + <nl> + / * * returns the name of an EVRButtonId enum value . This function is deprecated in favor of the new IVRInput system . * / <nl> + virtual const char * GetButtonIdNameFromEnum ( EVRButtonId eButtonId ) = 0 ; <nl> + <nl> + / * * returns the name of an EVRControllerAxisType enum value . This function is deprecated in favor of the new IVRInput system . * / <nl> + virtual const char * GetControllerAxisTypeNameFromEnum ( EVRControllerAxisType eAxisType ) = 0 ; <nl> + <nl> + / * * Returns true if this application is receiving input from the system . This would return false if <nl> + * system - related functionality is consuming the input stream . * / <nl> + virtual bool IsInputAvailable ( ) = 0 ; <nl> + <nl> + / * * Returns true SteamVR is drawing controllers on top of the application . Applications should consider <nl> + * not drawing anything attached to the user ' s hands in this case . * / <nl> + virtual bool IsSteamVRDrawingControllers ( ) = 0 ; <nl> + <nl> + / * * Returns true if the user has put SteamVR into a mode that is distracting them from the application . <nl> + * For applications where this is appropriate , the application should pause ongoing activity . * / <nl> + virtual bool ShouldApplicationPause ( ) = 0 ; <nl> + <nl> + / * * Returns true if SteamVR is doing significant rendering work and the game should do what it can to reduce <nl> + * its own workload . One common way to do this is to reduce the size of the render target provided for each eye . * / <nl> + virtual bool ShouldApplicationReduceRenderingWork ( ) = 0 ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / Firmware methods <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + <nl> + / * * Performs the actual firmware update if applicable . <nl> + * The following events will be sent , if VRFirmwareError_None was returned : VREvent_FirmwareUpdateStarted , VREvent_FirmwareUpdateFinished <nl> + * Use the properties Prop_Firmware_UpdateAvailable_Bool , Prop_Firmware_ManualUpdate_Bool , and Prop_Firmware_ManualUpdateURL_String <nl> + * to figure our whether a firmware update is available , and to figure out whether its a manual update <nl> + * Prop_Firmware_ManualUpdateURL_String should point to an URL describing the manual update process * / <nl> + virtual vr : : EVRFirmwareError PerformFirmwareUpdate ( vr : : TrackedDeviceIndex_t unDeviceIndex ) = 0 ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / Application life cycle methods <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + <nl> + / * * Call this to acknowledge to the system that VREvent_Quit has been received and that the process is exiting . <nl> + * This extends the timeout until the process is killed . * / <nl> + virtual void AcknowledgeQuit_Exiting ( ) = 0 ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + / / App container sandbox methods <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + <nl> + / * * Retrieves a null - terminated , semicolon - delimited list of UTF8 file paths that an application <nl> + * must have read access to when running inside of an app container . Returns the number of bytes <nl> + * needed to hold the list . * / <nl> + virtual uint32_t GetAppContainerFilePaths ( VR_OUT_STRING ( ) char * pchBuffer , uint32_t unBufferSize ) = 0 ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + / / System methods <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + <nl> + / * * Returns the current version of the SteamVR runtime . The returned string will remain valid until VR_Shutdown is called . <nl> + * <nl> + * NOTE : Is it not appropriate to use this version to test for the presence of any SteamVR feature . Only use this version <nl> + * number for logging or showing to a user , and not to try to detect anything at runtime . When appropriate , feature - specific <nl> + * presence information is provided by other APIs . * / <nl> + virtual const char * GetRuntimeVersion ( ) = 0 ; <nl> + <nl> + } ; <nl> + <nl> + static const char * const IVRSystem_Version = " IVRSystem_021 " ; <nl> + <nl> + } <nl> + <nl> + <nl> + / / ivrapplications . h <nl> + namespace vr <nl> + { <nl> + <nl> + / * * Used for all errors reported by the IVRApplications interface * / <nl> + enum EVRApplicationError <nl> + { <nl> + VRApplicationError_None = 0 , <nl> + <nl> + VRApplicationError_AppKeyAlreadyExists = 100 , / / Only one application can use any given key <nl> + VRApplicationError_NoManifest = 101 , / / the running application does not have a manifest <nl> + VRApplicationError_NoApplication = 102 , / / No application is running <nl> + VRApplicationError_InvalidIndex = 103 , <nl> + VRApplicationError_UnknownApplication = 104 , / / the application could not be found <nl> + VRApplicationError_IPCFailed = 105 , / / An IPC failure caused the request to fail <nl> + VRApplicationError_ApplicationAlreadyRunning = 106 , <nl> + VRApplicationError_InvalidManifest = 107 , <nl> + VRApplicationError_InvalidApplication = 108 , <nl> + VRApplicationError_LaunchFailed = 109 , / / the process didn ' t start <nl> + VRApplicationError_ApplicationAlreadyStarting = 110 , / / the system was already starting the same application <nl> + VRApplicationError_LaunchInProgress = 111 , / / The system was already starting a different application <nl> + VRApplicationError_OldApplicationQuitting = 112 , <nl> + VRApplicationError_TransitionAborted = 113 , <nl> + VRApplicationError_IsTemplate = 114 , / / error when you try to call LaunchApplication ( ) on a template type app ( use LaunchTemplateApplication ) <nl> + VRApplicationError_SteamVRIsExiting = 115 , <nl> + <nl> + VRApplicationError_BufferTooSmall = 200 , / / The provided buffer was too small to fit the requested data <nl> + VRApplicationError_PropertyNotSet = 201 , / / The requested property was not set <nl> + VRApplicationError_UnknownProperty = 202 , <nl> + VRApplicationError_InvalidParameter = 203 , <nl> + } ; <nl> + <nl> + / * * The maximum length of an application key * / <nl> + static const uint32_t k_unMaxApplicationKeyLength = 128 ; <nl> + <nl> + / * * these are the properties available on applications . * / <nl> + enum EVRApplicationProperty <nl> + { <nl> + VRApplicationProperty_Name_String = 0 , <nl> + <nl> + VRApplicationProperty_LaunchType_String = 11 , <nl> + VRApplicationProperty_WorkingDirectory_String = 12 , <nl> + VRApplicationProperty_BinaryPath_String = 13 , <nl> + VRApplicationProperty_Arguments_String = 14 , <nl> + VRApplicationProperty_URL_String = 15 , <nl> + <nl> + VRApplicationProperty_Description_String = 50 , <nl> + VRApplicationProperty_NewsURL_String = 51 , <nl> + VRApplicationProperty_ImagePath_String = 52 , <nl> + VRApplicationProperty_Source_String = 53 , <nl> + VRApplicationProperty_ActionManifestURL_String = 54 , <nl> + <nl> + VRApplicationProperty_IsDashboardOverlay_Bool = 60 , <nl> + VRApplicationProperty_IsTemplate_Bool = 61 , <nl> + VRApplicationProperty_IsInstanced_Bool = 62 , <nl> + VRApplicationProperty_IsInternal_Bool = 63 , <nl> + VRApplicationProperty_WantsCompositorPauseInStandby_Bool = 64 , <nl> + VRApplicationProperty_IsHidden_Bool = 65 , <nl> + <nl> + VRApplicationProperty_LastLaunchTime_Uint64 = 70 , <nl> + } ; <nl> + <nl> + enum EVRSceneApplicationState <nl> + { <nl> + EVRSceneApplicationState_None = 0 , / / Scene Application is not running <nl> + EVRSceneApplicationState_Starting = 1 , / / Scene Application is starting <nl> + EVRSceneApplicationState_Quitting = 2 , / / Scene Application is quitting <nl> + EVRSceneApplicationState_Running = 3 , / / Scene Application is running , and submitting frames , a custom skybox , or a visible overlay <nl> + EVRSceneApplicationState_Waiting = 4 , / / Scene Application is running , but not drawing anything <nl> + } ; <nl> + <nl> + struct AppOverrideKeys_t <nl> + { <nl> + const char * pchKey ; <nl> + const char * pchValue ; <nl> + } ; <nl> + <nl> + / * * Currently recognized mime types * / <nl> + static const char * const k_pch_MimeType_HomeApp = " vr / home " ; <nl> + static const char * const k_pch_MimeType_GameTheater = " vr / game_theater " ; <nl> + <nl> + class IVRApplications <nl> + { <nl> + public : <nl> + <nl> + / / mmmmmmmmmmmmmmm Application management mmmmmmmmmmmmmmm / / <nl> + <nl> + / * * Adds an application manifest to the list to load when building the list of installed applications . <nl> + * Temporary manifests are not automatically loaded * / <nl> + virtual EVRApplicationError AddApplicationManifest ( const char * pchApplicationManifestFullPath , bool bTemporary = false ) = 0 ; <nl> + <nl> + / * * Removes an application manifest from the list to load when building the list of installed applications . * / <nl> + virtual EVRApplicationError RemoveApplicationManifest ( const char * pchApplicationManifestFullPath ) = 0 ; <nl> + <nl> + / * * Returns true if an application is installed * / <nl> + virtual bool IsApplicationInstalled ( const char * pchAppKey ) = 0 ; <nl> + <nl> + / * * Returns the number of applications available in the list * / <nl> + virtual uint32_t GetApplicationCount ( ) = 0 ; <nl> + <nl> + / * * Returns the key of the specified application . The index is at least 0 and is less than the return <nl> + * value of GetApplicationCount ( ) . The buffer should be at least k_unMaxApplicationKeyLength in order to <nl> + * fit the key . * / <nl> + virtual EVRApplicationError GetApplicationKeyByIndex ( uint32_t unApplicationIndex , VR_OUT_STRING ( ) char * pchAppKeyBuffer , uint32_t unAppKeyBufferLen ) = 0 ; <nl> + <nl> + / * * Returns the key of the application for the specified Process Id . The buffer should be at least <nl> + * k_unMaxApplicationKeyLength in order to fit the key . * / <nl> + virtual EVRApplicationError GetApplicationKeyByProcessId ( uint32_t unProcessId , VR_OUT_STRING ( ) char * pchAppKeyBuffer , uint32_t unAppKeyBufferLen ) = 0 ; <nl> + <nl> + / * * Launches the application . The existing scene application will exit and then the new application will start . <nl> + * This call is not valid for dashboard overlay applications . * / <nl> + virtual EVRApplicationError LaunchApplication ( const char * pchAppKey ) = 0 ; <nl> + <nl> + / * * Launches an instance of an application of type template , with its app key being pchNewAppKey ( which must be unique ) and optionally override sections <nl> + * from the manifest file via AppOverrideKeys_t <nl> + * / <nl> + virtual EVRApplicationError LaunchTemplateApplication ( const char * pchTemplateAppKey , const char * pchNewAppKey , VR_ARRAY_COUNT ( unKeys ) const AppOverrideKeys_t * pKeys , uint32_t unKeys ) = 0 ; <nl> + <nl> + / * * launches the application currently associated with this mime type and passes it the option args , typically the filename or object name of the item being launched * / <nl> + virtual vr : : EVRApplicationError LaunchApplicationFromMimeType ( const char * pchMimeType , const char * pchArgs ) = 0 ; <nl> + <nl> + / * * Launches the dashboard overlay application if it is not already running . This call is only valid for <nl> + * dashboard overlay applications . * / <nl> + virtual EVRApplicationError LaunchDashboardOverlay ( const char * pchAppKey ) = 0 ; <nl> + <nl> + / * * Cancel a pending launch for an application * / <nl> + virtual bool CancelApplicationLaunch ( const char * pchAppKey ) = 0 ; <nl> + <nl> + / * * Identifies a running application . OpenVR can ' t always tell which process started in response <nl> + * to a URL . This function allows a URL handler ( or the process itself ) to identify the app key <nl> + * for the now running application . Passing a process ID of 0 identifies the calling process . <nl> + * The application must be one that ' s known to the system via a call to AddApplicationManifest . * / <nl> + virtual EVRApplicationError IdentifyApplication ( uint32_t unProcessId , const char * pchAppKey ) = 0 ; <nl> + <nl> + / * * Returns the process ID for an application . Return 0 if the application was not found or is not running . * / <nl> + virtual uint32_t GetApplicationProcessId ( const char * pchAppKey ) = 0 ; <nl> + <nl> + / * * Returns a string for an applications error * / <nl> + virtual const char * GetApplicationsErrorNameFromEnum ( EVRApplicationError error ) = 0 ; <nl> + <nl> + / / mmmmmmmmmmmmmmm Application properties mmmmmmmmmmmmmmm / / <nl> + <nl> + / * * Returns a value for an application property . The required buffer size to fit this value will be returned . * / <nl> + virtual uint32_t GetApplicationPropertyString ( const char * pchAppKey , EVRApplicationProperty eProperty , VR_OUT_STRING ( ) char * pchPropertyValueBuffer , uint32_t unPropertyValueBufferLen , EVRApplicationError * peError = nullptr ) = 0 ; <nl> + <nl> + / * * Returns a bool value for an application property . Returns false in all error cases . * / <nl> + virtual bool GetApplicationPropertyBool ( const char * pchAppKey , EVRApplicationProperty eProperty , EVRApplicationError * peError = nullptr ) = 0 ; <nl> + <nl> + / * * Returns a uint64 value for an application property . Returns 0 in all error cases . * / <nl> + virtual uint64_t GetApplicationPropertyUint64 ( const char * pchAppKey , EVRApplicationProperty eProperty , EVRApplicationError * peError = nullptr ) = 0 ; <nl> + <nl> + / * * Sets the application auto - launch flag . This is only valid for applications which return true for VRApplicationProperty_IsDashboardOverlay_Bool . * / <nl> + virtual EVRApplicationError SetApplicationAutoLaunch ( const char * pchAppKey , bool bAutoLaunch ) = 0 ; <nl> + <nl> + / * * Gets the application auto - launch flag . This is only valid for applications which return true for VRApplicationProperty_IsDashboardOverlay_Bool . * / <nl> + virtual bool GetApplicationAutoLaunch ( const char * pchAppKey ) = 0 ; <nl> + <nl> + / * * Adds this mime - type to the list of supported mime types for this application * / <nl> + virtual EVRApplicationError SetDefaultApplicationForMimeType ( const char * pchAppKey , const char * pchMimeType ) = 0 ; <nl> + <nl> + / * * return the app key that will open this mime type * / <nl> + virtual bool GetDefaultApplicationForMimeType ( const char * pchMimeType , VR_OUT_STRING ( ) char * pchAppKeyBuffer , uint32_t unAppKeyBufferLen ) = 0 ; <nl> + <nl> + / * * Get the list of supported mime types for this application , comma - delimited * / <nl> + virtual bool GetApplicationSupportedMimeTypes ( const char * pchAppKey , VR_OUT_STRING ( ) char * pchMimeTypesBuffer , uint32_t unMimeTypesBuffer ) = 0 ; <nl> + <nl> + / * * Get the list of app - keys that support this mime type , comma - delimited , the return value is number of bytes you need to return the full string * / <nl> + virtual uint32_t GetApplicationsThatSupportMimeType ( const char * pchMimeType , VR_OUT_STRING ( ) char * pchAppKeysThatSupportBuffer , uint32_t unAppKeysThatSupportBuffer ) = 0 ; <nl> + <nl> + / * * Get the args list from an app launch that had the process already running , you call this when you get a VREvent_ApplicationMimeTypeLoad * / <nl> + virtual uint32_t GetApplicationLaunchArguments ( uint32_t unHandle , VR_OUT_STRING ( ) char * pchArgs , uint32_t unArgs ) = 0 ; <nl> + <nl> + / / mmmmmmmmmmmmmmm Transition methods mmmmmmmmmmmmmmm / / <nl> + <nl> + / * * Returns the app key for the application that is starting up * / <nl> + virtual EVRApplicationError GetStartingApplication ( VR_OUT_STRING ( ) char * pchAppKeyBuffer , uint32_t unAppKeyBufferLen ) = 0 ; <nl> + <nl> + / * * Returns the application transition state * / <nl> + virtual EVRSceneApplicationState GetSceneApplicationState ( ) = 0 ; <nl> + <nl> + / * * Returns errors that would prevent the specified application from launching immediately . Calling this function will <nl> + * cause the current scene application to quit , so only call it when you are actually about to launch something else . <nl> + * What the caller should do about these failures depends on the failure : <nl> + * VRApplicationError_OldApplicationQuitting - An existing application has been told to quit . Wait for a VREvent_ProcessQuit <nl> + * and try again . <nl> + * VRApplicationError_ApplicationAlreadyStarting - This application is already starting . This is a permanent failure . <nl> + * VRApplicationError_LaunchInProgress - A different application is already starting . This is a permanent failure . <nl> + * VRApplicationError_None - Go ahead and launch . Everything is clear . <nl> + * / <nl> + virtual EVRApplicationError PerformApplicationPrelaunchCheck ( const char * pchAppKey ) = 0 ; <nl> + <nl> + / * * Returns a string for an application transition state * / <nl> + virtual const char * GetSceneApplicationStateNameFromEnum ( EVRSceneApplicationState state ) = 0 ; <nl> + <nl> + / * * Starts a subprocess within the calling application . This <nl> + * suppresses all application transition UI and automatically identifies the new executable <nl> + * as part of the same application . On success the calling process should exit immediately . <nl> + * If working directory is NULL or " " the directory portion of the binary path will be <nl> + * the working directory . * / <nl> + virtual EVRApplicationError LaunchInternalProcess ( const char * pchBinaryPath , const char * pchArguments , const char * pchWorkingDirectory ) = 0 ; <nl> + <nl> + / * * Returns the current scene process ID according to the application system . A scene process will get scene <nl> + * focus once it starts rendering , but it will appear here once it calls VR_Init with the Scene application <nl> + * type . * / <nl> + virtual uint32_t GetCurrentSceneProcessId ( ) = 0 ; <nl> + } ; <nl> + <nl> + static const char * const IVRApplications_Version = " IVRApplications_007 " ; <nl> + <nl> + } / / namespace vr <nl> + <nl> + / / ivrsettings . h <nl> + # include < string > <nl> + <nl> + namespace vr <nl> + { <nl> + enum EVRSettingsError <nl> + { <nl> + VRSettingsError_None = 0 , <nl> + VRSettingsError_IPCFailed = 1 , <nl> + VRSettingsError_WriteFailed = 2 , <nl> + VRSettingsError_ReadFailed = 3 , <nl> + VRSettingsError_JsonParseFailed = 4 , <nl> + VRSettingsError_UnsetSettingHasNoDefault = 5 , / / This will be returned if the setting does not appear in the appropriate default file and has not been set <nl> + } ; <nl> + <nl> + / / The maximum length of a settings key <nl> + static const uint32_t k_unMaxSettingsKeyLength = 128 ; <nl> + <nl> + class IVRSettings <nl> + { <nl> + public : <nl> + virtual const char * GetSettingsErrorNameFromEnum ( EVRSettingsError eError ) = 0 ; <nl> + <nl> + virtual void SetBool ( const char * pchSection , const char * pchSettingsKey , bool bValue , EVRSettingsError * peError = nullptr ) = 0 ; <nl> + virtual void SetInt32 ( const char * pchSection , const char * pchSettingsKey , int32_t nValue , EVRSettingsError * peError = nullptr ) = 0 ; <nl> + virtual void SetFloat ( const char * pchSection , const char * pchSettingsKey , float flValue , EVRSettingsError * peError = nullptr ) = 0 ; <nl> + virtual void SetString ( const char * pchSection , const char * pchSettingsKey , const char * pchValue , EVRSettingsError * peError = nullptr ) = 0 ; <nl> + <nl> + / / Users of the system need to provide a proper default in default . vrsettings in the resources / settings / directory <nl> + / / of either the runtime or the driver_xxx directory . Otherwise the default will be false , 0 , 0 . 0 or " " <nl> + virtual bool GetBool ( const char * pchSection , const char * pchSettingsKey , EVRSettingsError * peError = nullptr ) = 0 ; <nl> + virtual int32_t GetInt32 ( const char * pchSection , const char * pchSettingsKey , EVRSettingsError * peError = nullptr ) = 0 ; <nl> + virtual float GetFloat ( const char * pchSection , const char * pchSettingsKey , EVRSettingsError * peError = nullptr ) = 0 ; <nl> + virtual void GetString ( const char * pchSection , const char * pchSettingsKey , VR_OUT_STRING ( ) char * pchValue , uint32_t unValueLen , EVRSettingsError * peError = nullptr ) = 0 ; <nl> + <nl> + virtual void RemoveSection ( const char * pchSection , EVRSettingsError * peError = nullptr ) = 0 ; <nl> + virtual void RemoveKeyInSection ( const char * pchSection , const char * pchSettingsKey , EVRSettingsError * peError = nullptr ) = 0 ; <nl> + } ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + static const char * const IVRSettings_Version = " IVRSettings_003 " ; <nl> + <nl> + class CVRSettingHelper <nl> + { <nl> + IVRSettings * m_pSettings ; <nl> + public : <nl> + CVRSettingHelper ( IVRSettings * pSettings ) <nl> + { <nl> + m_pSettings = pSettings ; <nl> + } <nl> + <nl> + const char * GetSettingsErrorNameFromEnum ( EVRSettingsError eError ) <nl> + { <nl> + return m_pSettings - > GetSettingsErrorNameFromEnum ( eError ) ; <nl> + } <nl> + <nl> + void SetBool ( const char * pchSection , const char * pchSettingsKey , bool bValue , EVRSettingsError * peError = nullptr ) <nl> + { <nl> + m_pSettings - > SetBool ( pchSection , pchSettingsKey , bValue , peError ) ; <nl> + } <nl> + <nl> + void SetInt32 ( const char * pchSection , const char * pchSettingsKey , int32_t nValue , EVRSettingsError * peError = nullptr ) <nl> + { <nl> + m_pSettings - > SetInt32 ( pchSection , pchSettingsKey , nValue , peError ) ; <nl> + } <nl> + void SetFloat ( const char * pchSection , const char * pchSettingsKey , float flValue , EVRSettingsError * peError = nullptr ) <nl> + { <nl> + m_pSettings - > SetFloat ( pchSection , pchSettingsKey , flValue , peError ) ; <nl> + } <nl> + void SetString ( const char * pchSection , const char * pchSettingsKey , const char * pchValue , EVRSettingsError * peError = nullptr ) <nl> + { <nl> + m_pSettings - > SetString ( pchSection , pchSettingsKey , pchValue , peError ) ; <nl> + } <nl> + void SetString ( const std : : string & sSection , const std : : string & sSettingsKey , const std : : string & sValue , EVRSettingsError * peError = nullptr ) <nl> + { <nl> + m_pSettings - > SetString ( sSection . c_str ( ) , sSettingsKey . c_str ( ) , sValue . c_str ( ) , peError ) ; <nl> + } <nl> + <nl> + bool GetBool ( const char * pchSection , const char * pchSettingsKey , EVRSettingsError * peError = nullptr ) <nl> + { <nl> + return m_pSettings - > GetBool ( pchSection , pchSettingsKey , peError ) ; <nl> + } <nl> + int32_t GetInt32 ( const char * pchSection , const char * pchSettingsKey , EVRSettingsError * peError = nullptr ) <nl> + { <nl> + return m_pSettings - > GetInt32 ( pchSection , pchSettingsKey , peError ) ; <nl> + } <nl> + float GetFloat ( const char * pchSection , const char * pchSettingsKey , EVRSettingsError * peError = nullptr ) <nl> + { <nl> + return m_pSettings - > GetFloat ( pchSection , pchSettingsKey , peError ) ; <nl> + } <nl> + void GetString ( const char * pchSection , const char * pchSettingsKey , VR_OUT_STRING ( ) char * pchValue , uint32_t unValueLen , EVRSettingsError * peError = nullptr ) <nl> + { <nl> + m_pSettings - > GetString ( pchSection , pchSettingsKey , pchValue , unValueLen , peError ) ; <nl> + } <nl> + std : : string GetString ( const std : : string & sSection , const std : : string & sSettingsKey , EVRSettingsError * peError = nullptr ) <nl> + { <nl> + char buf [ 4096 ] ; <nl> + vr : : EVRSettingsError eError ; <nl> + m_pSettings - > GetString ( sSection . c_str ( ) , sSettingsKey . c_str ( ) , buf , sizeof ( buf ) , & eError ) ; <nl> + if ( peError ) <nl> + * peError = eError ; <nl> + if ( eError = = vr : : VRSettingsError_None ) <nl> + return buf ; <nl> + else <nl> + return " " ; <nl> + } <nl> + <nl> + void RemoveSection ( const char * pchSection , EVRSettingsError * peError = nullptr ) <nl> + { <nl> + m_pSettings - > RemoveSection ( pchSection , peError ) ; <nl> + } <nl> + void RemoveKeyInSection ( const char * pchSection , const char * pchSettingsKey , EVRSettingsError * peError = nullptr ) <nl> + { <nl> + m_pSettings - > RemoveKeyInSection ( pchSection , pchSettingsKey , peError ) ; <nl> + } <nl> + } ; <nl> + <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / steamvr keys <nl> + static const char * const k_pch_SteamVR_Section = " steamvr " ; <nl> + static const char * const k_pch_SteamVR_RequireHmd_String = " requireHmd " ; <nl> + static const char * const k_pch_SteamVR_ForcedDriverKey_String = " forcedDriver " ; <nl> + static const char * const k_pch_SteamVR_ForcedHmdKey_String = " forcedHmd " ; <nl> + static const char * const k_pch_SteamVR_DisplayDebug_Bool = " displayDebug " ; <nl> + static const char * const k_pch_SteamVR_DebugProcessPipe_String = " debugProcessPipe " ; <nl> + static const char * const k_pch_SteamVR_DisplayDebugX_Int32 = " displayDebugX " ; <nl> + static const char * const k_pch_SteamVR_DisplayDebugY_Int32 = " displayDebugY " ; <nl> + static const char * const k_pch_SteamVR_SendSystemButtonToAllApps_Bool = " sendSystemButtonToAllApps " ; <nl> + static const char * const k_pch_SteamVR_LogLevel_Int32 = " loglevel " ; <nl> + static const char * const k_pch_SteamVR_IPD_Float = " ipd " ; <nl> + static const char * const k_pch_SteamVR_Background_String = " background " ; <nl> + static const char * const k_pch_SteamVR_BackgroundUseDomeProjection_Bool = " backgroundUseDomeProjection " ; <nl> + static const char * const k_pch_SteamVR_BackgroundCameraHeight_Float = " backgroundCameraHeight " ; <nl> + static const char * const k_pch_SteamVR_BackgroundDomeRadius_Float = " backgroundDomeRadius " ; <nl> + static const char * const k_pch_SteamVR_GridColor_String = " gridColor " ; <nl> + static const char * const k_pch_SteamVR_PlayAreaColor_String = " playAreaColor " ; <nl> + static const char * const k_pch_SteamVR_TrackingLossColor_String = " trackingLossColor " ; <nl> + static const char * const k_pch_SteamVR_ShowStage_Bool = " showStage " ; <nl> + static const char * const k_pch_SteamVR_ActivateMultipleDrivers_Bool = " activateMultipleDrivers " ; <nl> + static const char * const k_pch_SteamVR_UsingSpeakers_Bool = " usingSpeakers " ; <nl> + static const char * const k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float = " speakersForwardYawOffsetDegrees " ; <nl> + static const char * const k_pch_SteamVR_BaseStationPowerManagement_Int32 = " basestationPowerManagement " ; <nl> + static const char * const k_pch_SteamVR_ShowBaseStationPowerManagementTip_Int32 = " ShowBaseStationPowerManagementTip " ; <nl> + static const char * const k_pch_SteamVR_NeverKillProcesses_Bool = " neverKillProcesses " ; <nl> + static const char * const k_pch_SteamVR_SupersampleScale_Float = " supersampleScale " ; <nl> + static const char * const k_pch_SteamVR_MaxRecommendedResolution_Int32 = " maxRecommendedResolution " ; <nl> + static const char * const k_pch_SteamVR_MotionSmoothing_Bool = " motionSmoothing " ; <nl> + static const char * const k_pch_SteamVR_MotionSmoothingOverride_Int32 = " motionSmoothingOverride " ; <nl> + static const char * const k_pch_SteamVR_DisableAsyncReprojection_Bool = " disableAsync " ; <nl> + static const char * const k_pch_SteamVR_ForceFadeOnBadTracking_Bool = " forceFadeOnBadTracking " ; <nl> + static const char * const k_pch_SteamVR_DefaultMirrorView_Int32 = " mirrorView " ; <nl> + static const char * const k_pch_SteamVR_ShowLegacyMirrorView_Bool = " showLegacyMirrorView " ; <nl> + static const char * const k_pch_SteamVR_MirrorViewVisibility_Bool = " showMirrorView " ; <nl> + static const char * const k_pch_SteamVR_MirrorViewDisplayMode_Int32 = " mirrorViewDisplayMode " ; <nl> + static const char * const k_pch_SteamVR_MirrorViewEye_Int32 = " mirrorViewEye " ; <nl> + static const char * const k_pch_SteamVR_MirrorViewGeometry_String = " mirrorViewGeometry " ; <nl> + static const char * const k_pch_SteamVR_MirrorViewGeometryMaximized_String = " mirrorViewGeometryMaximized " ; <nl> + static const char * const k_pch_SteamVR_PerfGraphVisibility_Bool = " showPerfGraph " ; <nl> + static const char * const k_pch_SteamVR_StartMonitorFromAppLaunch = " startMonitorFromAppLaunch " ; <nl> + static const char * const k_pch_SteamVR_StartCompositorFromAppLaunch_Bool = " startCompositorFromAppLaunch " ; <nl> + static const char * const k_pch_SteamVR_StartDashboardFromAppLaunch_Bool = " startDashboardFromAppLaunch " ; <nl> + static const char * const k_pch_SteamVR_StartOverlayAppsFromDashboard_Bool = " startOverlayAppsFromDashboard " ; <nl> + static const char * const k_pch_SteamVR_EnableHomeApp = " enableHomeApp " ; <nl> + static const char * const k_pch_SteamVR_CycleBackgroundImageTimeSec_Int32 = " CycleBackgroundImageTimeSec " ; <nl> + static const char * const k_pch_SteamVR_RetailDemo_Bool = " retailDemo " ; <nl> + static const char * const k_pch_SteamVR_IpdOffset_Float = " ipdOffset " ; <nl> + static const char * const k_pch_SteamVR_AllowSupersampleFiltering_Bool = " allowSupersampleFiltering " ; <nl> + static const char * const k_pch_SteamVR_SupersampleManualOverride_Bool = " supersampleManualOverride " ; <nl> + static const char * const k_pch_SteamVR_EnableLinuxVulkanAsync_Bool = " enableLinuxVulkanAsync " ; <nl> + static const char * const k_pch_SteamVR_AllowDisplayLockedMode_Bool = " allowDisplayLockedMode " ; <nl> + static const char * const k_pch_SteamVR_HaveStartedTutorialForNativeChaperoneDriver_Bool = " haveStartedTutorialForNativeChaperoneDriver " ; <nl> + static const char * const k_pch_SteamVR_ForceWindows32bitVRMonitor = " forceWindows32BitVRMonitor " ; <nl> + static const char * const k_pch_SteamVR_DebugInputBinding = " debugInputBinding " ; <nl> + static const char * const k_pch_SteamVR_DoNotFadeToGrid = " doNotFadeToGrid " ; <nl> + static const char * const k_pch_SteamVR_RenderCameraMode = " renderCameraMode " ; <nl> + static const char * const k_pch_SteamVR_EnableSharedResourceJournaling = " enableSharedResourceJournaling " ; <nl> + static const char * const k_pch_SteamVR_EnableSafeMode = " enableSafeMode " ; <nl> + static const char * const k_pch_SteamVR_PreferredRefreshRate = " preferredRefreshRate " ; <nl> + static const char * const k_pch_SteamVR_LastVersionNotice = " lastVersionNotice " ; <nl> + static const char * const k_pch_SteamVR_LastVersionNoticeDate = " lastVersionNoticeDate " ; <nl> + static const char * const k_pch_SteamVR_HmdDisplayColorGainR_Float = " hmdDisplayColorGainR " ; <nl> + static const char * const k_pch_SteamVR_HmdDisplayColorGainG_Float = " hmdDisplayColorGainG " ; <nl> + static const char * const k_pch_SteamVR_HmdDisplayColorGainB_Float = " hmdDisplayColorGainB " ; <nl> + static const char * const k_pch_SteamVR_CustomIconStyle_String = " customIconStyle " ; <nl> + static const char * const k_pch_SteamVR_CustomOffIconStyle_String = " customOffIconStyle " ; <nl> + static const char * const k_pch_SteamVR_CustomIconForceUpdate_String = " customIconForceUpdate " ; <nl> + static const char * const k_pch_SteamVR_AllowGlobalActionSetPriority = " globalActionSetPriority " ; <nl> + static const char * const k_pch_SteamVR_OverlayRenderQuality = " overlayRenderQuality_2 " ; <nl> + static const char * const k_pch_SteamVR_BlockOculusSDKOnOpenVRLaunchOption_Bool = " blockOculusSDKOnOpenVRLaunchOption " ; <nl> + static const char * const k_pch_SteamVR_BlockOculusSDKOnAllLaunches_Bool = " blockOculusSDKOnAllLaunches " ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / direct mode keys <nl> + static const char * const k_pch_DirectMode_Section = " direct_mode " ; <nl> + static const char * const k_pch_DirectMode_Enable_Bool = " enable " ; <nl> + static const char * const k_pch_DirectMode_Count_Int32 = " count " ; <nl> + static const char * const k_pch_DirectMode_EdidVid_Int32 = " edidVid " ; <nl> + static const char * const k_pch_DirectMode_EdidPid_Int32 = " edidPid " ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / lighthouse keys <nl> + static const char * const k_pch_Lighthouse_Section = " driver_lighthouse " ; <nl> + static const char * const k_pch_Lighthouse_DisableIMU_Bool = " disableimu " ; <nl> + static const char * const k_pch_Lighthouse_DisableIMUExceptHMD_Bool = " disableimuexcepthmd " ; <nl> + static const char * const k_pch_Lighthouse_UseDisambiguation_String = " usedisambiguation " ; <nl> + static const char * const k_pch_Lighthouse_DisambiguationDebug_Int32 = " disambiguationdebug " ; <nl> + static const char * const k_pch_Lighthouse_PrimaryBasestation_Int32 = " primarybasestation " ; <nl> + static const char * const k_pch_Lighthouse_DBHistory_Bool = " dbhistory " ; <nl> + static const char * const k_pch_Lighthouse_EnableBluetooth_Bool = " enableBluetooth " ; <nl> + static const char * const k_pch_Lighthouse_PowerManagedBaseStations_String = " PowerManagedBaseStations " ; <nl> + static const char * const k_pch_Lighthouse_PowerManagedBaseStations2_String = " PowerManagedBaseStations2 " ; <nl> + static const char * const k_pch_Lighthouse_InactivityTimeoutForBaseStations_Int32 = " InactivityTimeoutForBaseStations " ; <nl> + static const char * const k_pch_Lighthouse_EnableImuFallback_Bool = " enableImuFallback " ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / null keys <nl> + static const char * const k_pch_Null_Section = " driver_null " ; <nl> + static const char * const k_pch_Null_SerialNumber_String = " serialNumber " ; <nl> + static const char * const k_pch_Null_ModelNumber_String = " modelNumber " ; <nl> + static const char * const k_pch_Null_WindowX_Int32 = " windowX " ; <nl> + static const char * const k_pch_Null_WindowY_Int32 = " windowY " ; <nl> + static const char * const k_pch_Null_WindowWidth_Int32 = " windowWidth " ; <nl> + static const char * const k_pch_Null_WindowHeight_Int32 = " windowHeight " ; <nl> + static const char * const k_pch_Null_RenderWidth_Int32 = " renderWidth " ; <nl> + static const char * const k_pch_Null_RenderHeight_Int32 = " renderHeight " ; <nl> + static const char * const k_pch_Null_SecondsFromVsyncToPhotons_Float = " secondsFromVsyncToPhotons " ; <nl> + static const char * const k_pch_Null_DisplayFrequency_Float = " displayFrequency " ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / Windows MR keys <nl> + static const char * const k_pch_WindowsMR_Section = " driver_holographic " ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / user interface keys <nl> + static const char * const k_pch_UserInterface_Section = " userinterface " ; <nl> + static const char * const k_pch_UserInterface_StatusAlwaysOnTop_Bool = " StatusAlwaysOnTop " ; <nl> + static const char * const k_pch_UserInterface_MinimizeToTray_Bool = " MinimizeToTray " ; <nl> + static const char * const k_pch_UserInterface_HidePopupsWhenStatusMinimized_Bool = " HidePopupsWhenStatusMinimized " ; <nl> + static const char * const k_pch_UserInterface_Screenshots_Bool = " screenshots " ; <nl> + static const char * const k_pch_UserInterface_ScreenshotType_Int = " screenshotType " ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / notification keys <nl> + static const char * const k_pch_Notifications_Section = " notifications " ; <nl> + static const char * const k_pch_Notifications_DoNotDisturb_Bool = " DoNotDisturb " ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / keyboard keys <nl> + static const char * const k_pch_Keyboard_Section = " keyboard " ; <nl> + static const char * const k_pch_Keyboard_TutorialCompletions = " TutorialCompletions " ; <nl> + static const char * const k_pch_Keyboard_ScaleX = " ScaleX " ; <nl> + static const char * const k_pch_Keyboard_ScaleY = " ScaleY " ; <nl> + static const char * const k_pch_Keyboard_OffsetLeftX = " OffsetLeftX " ; <nl> + static const char * const k_pch_Keyboard_OffsetRightX = " OffsetRightX " ; <nl> + static const char * const k_pch_Keyboard_OffsetY = " OffsetY " ; <nl> + static const char * const k_pch_Keyboard_Smoothing = " Smoothing " ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / perf keys <nl> + static const char * const k_pch_Perf_Section = " perfcheck " ; <nl> + static const char * const k_pch_Perf_PerfGraphInHMD_Bool = " perfGraphInHMD " ; <nl> + static const char * const k_pch_Perf_AllowTimingStore_Bool = " allowTimingStore " ; <nl> + static const char * const k_pch_Perf_SaveTimingsOnExit_Bool = " saveTimingsOnExit " ; <nl> + static const char * const k_pch_Perf_TestData_Float = " perfTestData " ; <nl> + static const char * const k_pch_Perf_GPUProfiling_Bool = " GPUProfiling " ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / collision bounds keys <nl> + static const char * const k_pch_CollisionBounds_Section = " collisionBounds " ; <nl> + static const char * const k_pch_CollisionBounds_Style_Int32 = " CollisionBoundsStyle " ; <nl> + static const char * const k_pch_CollisionBounds_GroundPerimeterOn_Bool = " CollisionBoundsGroundPerimeterOn " ; <nl> + static const char * const k_pch_CollisionBounds_CenterMarkerOn_Bool = " CollisionBoundsCenterMarkerOn " ; <nl> + static const char * const k_pch_CollisionBounds_PlaySpaceOn_Bool = " CollisionBoundsPlaySpaceOn " ; <nl> + static const char * const k_pch_CollisionBounds_FadeDistance_Float = " CollisionBoundsFadeDistance " ; <nl> + static const char * const k_pch_CollisionBounds_WallHeight_Float = " CollisionBoundsWallHeight " ; <nl> + static const char * const k_pch_CollisionBounds_ColorGammaR_Int32 = " CollisionBoundsColorGammaR " ; <nl> + static const char * const k_pch_CollisionBounds_ColorGammaG_Int32 = " CollisionBoundsColorGammaG " ; <nl> + static const char * const k_pch_CollisionBounds_ColorGammaB_Int32 = " CollisionBoundsColorGammaB " ; <nl> + static const char * const k_pch_CollisionBounds_ColorGammaA_Int32 = " CollisionBoundsColorGammaA " ; <nl> + static const char * const k_pch_CollisionBounds_EnableDriverImport = " enableDriverBoundsImport " ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / camera keys <nl> + static const char * const k_pch_Camera_Section = " camera " ; <nl> + static const char * const k_pch_Camera_EnableCamera_Bool = " enableCamera " ; <nl> + static const char * const k_pch_Camera_EnableCameraInDashboard_Bool = " enableCameraInDashboard " ; <nl> + static const char * const k_pch_Camera_EnableCameraForCollisionBounds_Bool = " enableCameraForCollisionBounds " ; <nl> + static const char * const k_pch_Camera_EnableCameraForRoomView_Bool = " enableCameraForRoomView " ; <nl> + static const char * const k_pch_Camera_BoundsColorGammaR_Int32 = " cameraBoundsColorGammaR " ; <nl> + static const char * const k_pch_Camera_BoundsColorGammaG_Int32 = " cameraBoundsColorGammaG " ; <nl> + static const char * const k_pch_Camera_BoundsColorGammaB_Int32 = " cameraBoundsColorGammaB " ; <nl> + static const char * const k_pch_Camera_BoundsColorGammaA_Int32 = " cameraBoundsColorGammaA " ; <nl> + static const char * const k_pch_Camera_BoundsStrength_Int32 = " cameraBoundsStrength " ; <nl> + static const char * const k_pch_Camera_RoomViewMode_Int32 = " cameraRoomViewMode " ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / audio keys <nl> + static const char * const k_pch_audio_Section = " audio " ; <nl> + static const char * const k_pch_audio_SetOsDefaultPlaybackDevice_Bool = " setOsDefaultPlaybackDevice " ; <nl> + static const char * const k_pch_audio_EnablePlaybackDeviceOverride_Bool = " enablePlaybackDeviceOverride " ; <nl> + static const char * const k_pch_audio_PlaybackDeviceOverride_String = " playbackDeviceOverride " ; <nl> + static const char * const k_pch_audio_PlaybackDeviceOverrideName_String = " playbackDeviceOverrideName " ; <nl> + static const char * const k_pch_audio_SetOsDefaultRecordingDevice_Bool = " setOsDefaultRecordingDevice " ; <nl> + static const char * const k_pch_audio_EnableRecordingDeviceOverride_Bool = " enableRecordingDeviceOverride " ; <nl> + static const char * const k_pch_audio_RecordingDeviceOverride_String = " recordingDeviceOverride " ; <nl> + static const char * const k_pch_audio_RecordingDeviceOverrideName_String = " recordingDeviceOverrideName " ; <nl> + static const char * const k_pch_audio_EnablePlaybackMirror_Bool = " enablePlaybackMirror " ; <nl> + static const char * const k_pch_audio_PlaybackMirrorDevice_String = " playbackMirrorDevice " ; <nl> + static const char * const k_pch_audio_PlaybackMirrorDeviceName_String = " playbackMirrorDeviceName " ; <nl> + static const char * const k_pch_audio_OldPlaybackMirrorDevice_String = " onPlaybackMirrorDevice " ; <nl> + static const char * const k_pch_audio_ActiveMirrorDevice_String = " activePlaybackMirrorDevice " ; <nl> + static const char * const k_pch_audio_EnablePlaybackMirrorIndependentVolume_Bool = " enablePlaybackMirrorIndependentVolume " ; <nl> + static const char * const k_pch_audio_LastHmdPlaybackDeviceId_String = " lastHmdPlaybackDeviceId " ; <nl> + static const char * const k_pch_audio_VIVEHDMIGain = " viveHDMIGain " ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / power management keys <nl> + static const char * const k_pch_Power_Section = " power " ; <nl> + static const char * const k_pch_Power_PowerOffOnExit_Bool = " powerOffOnExit " ; <nl> + static const char * const k_pch_Power_TurnOffScreensTimeout_Float = " turnOffScreensTimeout " ; <nl> + static const char * const k_pch_Power_TurnOffControllersTimeout_Float = " turnOffControllersTimeout " ; <nl> + static const char * const k_pch_Power_ReturnToWatchdogTimeout_Float = " returnToWatchdogTimeout " ; <nl> + static const char * const k_pch_Power_AutoLaunchSteamVROnButtonPress = " autoLaunchSteamVROnButtonPress " ; <nl> + static const char * const k_pch_Power_PauseCompositorOnStandby_Bool = " pauseCompositorOnStandby " ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / dashboard keys <nl> + static const char * const k_pch_Dashboard_Section = " dashboard " ; <nl> + static const char * const k_pch_Dashboard_EnableDashboard_Bool = " enableDashboard " ; <nl> + static const char * const k_pch_Dashboard_ArcadeMode_Bool = " arcadeMode " ; <nl> + static const char * const k_pch_Dashboard_Position = " position " ; <nl> + static const char * const k_pch_Dashboard_DesktopScale = " desktopScale " ; <nl> + static const char * const k_pch_Dashboard_DashboardScale = " dashboardScale " ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / model skin keys <nl> + static const char * const k_pch_modelskin_Section = " modelskins " ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / driver keys - These could be checked in any driver_ < name > section <nl> + static const char * const k_pch_Driver_Enable_Bool = " enable " ; <nl> + static const char * const k_pch_Driver_BlockedBySafemode_Bool = " blocked_by_safe_mode " ; <nl> + static const char * const k_pch_Driver_LoadPriority_Int32 = " loadPriority " ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / web interface keys <nl> + static const char * const k_pch_WebInterface_Section = " WebInterface " ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / vrwebhelper keys <nl> + static const char * const k_pch_VRWebHelper_Section = " VRWebHelper " ; <nl> + static const char * const k_pch_VRWebHelper_DebuggerEnabled_Bool = " DebuggerEnabled " ; <nl> + static const char * const k_pch_VRWebHelper_DebuggerPort_Int32 = " DebuggerPort " ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / tracking overrides - keys are device paths , values are the device paths their <nl> + / / tracking / pose information overrides <nl> + static const char * const k_pch_TrackingOverride_Section = " TrackingOverrides " ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / per - app keys - the section name for these is the app key itself . Some of these are prefixed by the controller type <nl> + static const char * const k_pch_App_BindingAutosaveURLSuffix_String = " AutosaveURL " ; <nl> + static const char * const k_pch_App_BindingLegacyAPISuffix_String = " _legacy " ; <nl> + static const char * const k_pch_App_BindingSteamVRInputAPISuffix_String = " _steamvrinput " ; <nl> + static const char * const k_pch_App_BindingCurrentURLSuffix_String = " CurrentURL " ; <nl> + static const char * const k_pch_App_BindingPreviousURLSuffix_String = " PreviousURL " ; <nl> + static const char * const k_pch_App_NeedToUpdateAutosaveSuffix_Bool = " NeedToUpdateAutosave " ; <nl> + static const char * const k_pch_App_DominantHand_Int32 = " DominantHand " ; <nl> + static const char * const k_pch_App_BlockOculusSDK_Bool = " blockOculusSDK " ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / configuration for trackers <nl> + static const char * const k_pch_Trackers_Section = " trackers " ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / configuration for desktop UI windows <nl> + static const char * const k_pch_DesktopUI_Section = " DesktopUI " ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / Last known keys for righting recovery <nl> + static const char * const k_pch_LastKnown_Section = " LastKnown " ; <nl> + static const char * const k_pch_LastKnown_HMDManufacturer_String = " HMDManufacturer " ; <nl> + static const char * const k_pch_LastKnown_HMDModel_String = " HMDModel " ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / Dismissed warnings <nl> + static const char * const k_pch_DismissedWarnings_Section = " DismissedWarnings " ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / Input Settings <nl> + static const char * const k_pch_Input_Section = " input " ; <nl> + static const char * const k_pch_Input_LeftThumbstickRotation_Float = " leftThumbstickRotation " ; <nl> + static const char * const k_pch_Input_RightThumbstickRotation_Float = " rightThumbstickRotation " ; <nl> + static const char * const k_pch_Input_ThumbstickDeadzone_Float = " thumbstickDeadzone " ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / Log of GPU performance <nl> + static const char * const k_pch_GpuSpeed_Section = " GpuSpeed " ; <nl> + <nl> + } / / namespace vr <nl> + <nl> + / / ivrchaperone . h <nl> + namespace vr <nl> + { <nl> + <nl> + # pragma pack ( push , 8 ) <nl> + <nl> + enum ChaperoneCalibrationState <nl> + { <nl> + / / OK ! <nl> + ChaperoneCalibrationState_OK = 1 , / / Chaperone is fully calibrated and working correctly <nl> + <nl> + / / Warnings <nl> + ChaperoneCalibrationState_Warning = 100 , <nl> + ChaperoneCalibrationState_Warning_BaseStationMayHaveMoved = 101 , / / A base station thinks that it might have moved <nl> + ChaperoneCalibrationState_Warning_BaseStationRemoved = 102 , / / There are less base stations than when calibrated <nl> + ChaperoneCalibrationState_Warning_SeatedBoundsInvalid = 103 , / / Seated bounds haven ' t been calibrated for the current tracking center <nl> + <nl> + / / Errors <nl> + ChaperoneCalibrationState_Error = 200 , / / The UniverseID is invalid <nl> + ChaperoneCalibrationState_Error_BaseStationUninitialized = 201 , / / Tracking center hasn ' t be calibrated for at least one of the base stations <nl> + ChaperoneCalibrationState_Error_BaseStationConflict = 202 , / / Tracking center is calibrated , but base stations disagree on the tracking space <nl> + ChaperoneCalibrationState_Error_PlayAreaInvalid = 203 , / / Play Area hasn ' t been calibrated for the current tracking center <nl> + ChaperoneCalibrationState_Error_CollisionBoundsInvalid = 204 , / / Collision Bounds haven ' t been calibrated for the current tracking center <nl> + } ; <nl> + <nl> + <nl> + / * * HIGH LEVEL TRACKING SPACE ASSUMPTIONS : <nl> + * 0 , 0 , 0 is the preferred standing area center . <nl> + * 0Y is the floor height . <nl> + * - Z is the preferred forward facing direction . * / <nl> + class IVRChaperone <nl> + { <nl> + public : <nl> + <nl> + / * * Get the current state of Chaperone calibration . This state can change at any time during a session due to physical base station changes . * * / <nl> + virtual ChaperoneCalibrationState GetCalibrationState ( ) = 0 ; <nl> + <nl> + / * * Returns the width and depth of the Play Area ( formerly named Soft Bounds ) in X and Z . <nl> + * Tracking space center ( 0 , 0 , 0 ) is the center of the Play Area . * * / <nl> + virtual bool GetPlayAreaSize ( float * pSizeX , float * pSizeZ ) = 0 ; <nl> + <nl> + / * * Returns the 4 corner positions of the Play Area ( formerly named Soft Bounds ) . <nl> + * Corners are in counter - clockwise order . <nl> + * Standing center ( 0 , 0 , 0 ) is the center of the Play Area . <nl> + * It ' s a rectangle . <nl> + * 2 sides are parallel to the X axis and 2 sides are parallel to the Z axis . <nl> + * Height of every corner is 0Y ( on the floor ) . * * / <nl> + virtual bool GetPlayAreaRect ( HmdQuad_t * rect ) = 0 ; <nl> + <nl> + / * * Reload Chaperone data from the . vrchap file on disk . * / <nl> + virtual void ReloadInfo ( void ) = 0 ; <nl> + <nl> + / * * Optionally give the chaperone system a hit about the color and brightness in the scene * * / <nl> + virtual void SetSceneColor ( HmdColor_t color ) = 0 ; <nl> + <nl> + / * * Get the current chaperone bounds draw color and brightness * * / <nl> + virtual void GetBoundsColor ( HmdColor_t * pOutputColorArray , int nNumOutputColors , float flCollisionBoundsFadeDistance , HmdColor_t * pOutputCameraColor ) = 0 ; <nl> + <nl> + / * * Determine whether the bounds are showing right now * * / <nl> + virtual bool AreBoundsVisible ( ) = 0 ; <nl> + <nl> + / * * Force the bounds to show , mostly for utilities * * / <nl> + virtual void ForceBoundsVisible ( bool bForce ) = 0 ; <nl> + } ; <nl> + <nl> + static const char * const IVRChaperone_Version = " IVRChaperone_003 " ; <nl> + <nl> + # pragma pack ( pop ) <nl> + <nl> + } <nl> + <nl> + / / ivrchaperonesetup . h <nl> + namespace vr <nl> + { <nl> + <nl> + enum EChaperoneConfigFile <nl> + { <nl> + EChaperoneConfigFile_Live = 1 , / / The live chaperone config , used by most applications and games <nl> + EChaperoneConfigFile_Temp = 2 , / / The temporary chaperone config , used to live - preview collision bounds in room setup <nl> + } ; <nl> + <nl> + enum EChaperoneImportFlags <nl> + { <nl> + EChaperoneImport_BoundsOnly = 0x0001 , <nl> + } ; <nl> + <nl> + / * * Manages the working copy of the chaperone info . By default this will be the same as the <nl> + * live copy . Any changes made with this interface will stay in the working copy until <nl> + * CommitWorkingCopy ( ) is called , at which point the working copy and the live copy will be <nl> + * the same again . * / <nl> + class IVRChaperoneSetup <nl> + { <nl> + public : <nl> + <nl> + / * * Saves the current working copy to disk * / <nl> + virtual bool CommitWorkingCopy ( EChaperoneConfigFile configFile ) = 0 ; <nl> + <nl> + / * * Reverts the working copy to match the live chaperone calibration . <nl> + * To modify existing data this MUST be do WHILE getting a non - error ChaperoneCalibrationStatus . <nl> + * Only after this should you do gets and sets on the existing data . * / <nl> + virtual void RevertWorkingCopy ( ) = 0 ; <nl> + <nl> + / * * Returns the width and depth of the Play Area ( formerly named Soft Bounds ) in X and Z from the working copy . <nl> + * Tracking space center ( 0 , 0 , 0 ) is the center of the Play Area . * / <nl> + virtual bool GetWorkingPlayAreaSize ( float * pSizeX , float * pSizeZ ) = 0 ; <nl> + <nl> + / * * Returns the 4 corner positions of the Play Area ( formerly named Soft Bounds ) from the working copy . <nl> + * Corners are in clockwise order . <nl> + * Tracking space center ( 0 , 0 , 0 ) is the center of the Play Area . <nl> + * It ' s a rectangle . <nl> + * 2 sides are parallel to the X axis and 2 sides are parallel to the Z axis . <nl> + * Height of every corner is 0Y ( on the floor ) . * * / <nl> + virtual bool GetWorkingPlayAreaRect ( HmdQuad_t * rect ) = 0 ; <nl> + <nl> + / * * Returns the number of Quads if the buffer points to null . Otherwise it returns Quads <nl> + * into the buffer up to the max specified from the working copy . * / <nl> + virtual bool GetWorkingCollisionBoundsInfo ( VR_OUT_ARRAY_COUNT ( punQuadsCount ) HmdQuad_t * pQuadsBuffer , uint32_t * punQuadsCount ) = 0 ; <nl> + <nl> + / * * Returns the number of Quads if the buffer points to null . Otherwise it returns Quads <nl> + * into the buffer up to the max specified . * / <nl> + virtual bool GetLiveCollisionBoundsInfo ( VR_OUT_ARRAY_COUNT ( punQuadsCount ) HmdQuad_t * pQuadsBuffer , uint32_t * punQuadsCount ) = 0 ; <nl> + <nl> + / * * Returns the preferred seated position from the working copy . * / <nl> + virtual bool GetWorkingSeatedZeroPoseToRawTrackingPose ( HmdMatrix34_t * pmatSeatedZeroPoseToRawTrackingPose ) = 0 ; <nl> + <nl> + / * * Returns the standing origin from the working copy . * / <nl> + virtual bool GetWorkingStandingZeroPoseToRawTrackingPose ( HmdMatrix34_t * pmatStandingZeroPoseToRawTrackingPose ) = 0 ; <nl> + <nl> + / * * Sets the Play Area in the working copy . * / <nl> + virtual void SetWorkingPlayAreaSize ( float sizeX , float sizeZ ) = 0 ; <nl> + <nl> + / * * Sets the Collision Bounds in the working copy . Note : ceiling height is ignored . * / <nl> + virtual void SetWorkingCollisionBoundsInfo ( VR_ARRAY_COUNT ( unQuadsCount ) HmdQuad_t * pQuadsBuffer , uint32_t unQuadsCount ) = 0 ; <nl> + <nl> + / * * Sets the Collision Bounds in the working copy . * / <nl> + virtual void SetWorkingPerimeter ( VR_ARRAY_COUNT ( unPointCount ) HmdVector2_t * pPointBuffer , uint32_t unPointCount ) = 0 ; <nl> + <nl> + / * * Sets the preferred seated position in the working copy . * / <nl> + virtual void SetWorkingSeatedZeroPoseToRawTrackingPose ( const HmdMatrix34_t * pMatSeatedZeroPoseToRawTrackingPose ) = 0 ; <nl> + <nl> + / * * Sets the preferred standing position in the working copy . * / <nl> + virtual void SetWorkingStandingZeroPoseToRawTrackingPose ( const HmdMatrix34_t * pMatStandingZeroPoseToRawTrackingPose ) = 0 ; <nl> + <nl> + / * * Tear everything down and reload it from the file on disk * / <nl> + virtual void ReloadFromDisk ( EChaperoneConfigFile configFile ) = 0 ; <nl> + <nl> + / * * Returns the preferred seated position . * / <nl> + virtual bool GetLiveSeatedZeroPoseToRawTrackingPose ( HmdMatrix34_t * pmatSeatedZeroPoseToRawTrackingPose ) = 0 ; <nl> + <nl> + virtual bool ExportLiveToBuffer ( VR_OUT_STRING ( ) char * pBuffer , uint32_t * pnBufferLength ) = 0 ; <nl> + virtual bool ImportFromBufferToWorking ( const char * pBuffer , uint32_t nImportFlags ) = 0 ; <nl> + <nl> + / * * Shows the chaperone data in the working set to preview in the compositor . * / <nl> + virtual void ShowWorkingSetPreview ( ) = 0 ; <nl> + <nl> + / * * Hides the chaperone data in the working set to preview in the compositor ( if it was visible ) . * / <nl> + virtual void HideWorkingSetPreview ( ) = 0 ; <nl> + <nl> + / * * Fire an event that the tracking system can use to know room setup is about to begin . This lets the tracking <nl> + * system make any last minute adjustments that should be incorporated into the new setup . If the user is adjusting <nl> + * live in HMD using a tweak tool , keep in mind that calling this might cause the user to see the room jump . * / <nl> + virtual void RoomSetupStarting ( ) = 0 ; <nl> + } ; <nl> + <nl> + static const char * const IVRChaperoneSetup_Version = " IVRChaperoneSetup_006 " ; <nl> + <nl> + <nl> + } <nl> + <nl> + / / ivrcompositor . h <nl> + namespace vr <nl> + { <nl> + <nl> + # pragma pack ( push , 8 ) <nl> + <nl> + / * * Errors that can occur with the VR compositor * / <nl> + enum EVRCompositorError <nl> + { <nl> + VRCompositorError_None = 0 , <nl> + VRCompositorError_RequestFailed = 1 , <nl> + VRCompositorError_IncompatibleVersion = 100 , <nl> + VRCompositorError_DoNotHaveFocus = 101 , <nl> + VRCompositorError_InvalidTexture = 102 , <nl> + VRCompositorError_IsNotSceneApplication = 103 , <nl> + VRCompositorError_TextureIsOnWrongDevice = 104 , <nl> + VRCompositorError_TextureUsesUnsupportedFormat = 105 , <nl> + VRCompositorError_SharedTexturesNotSupported = 106 , <nl> + VRCompositorError_IndexOutOfRange = 107 , <nl> + VRCompositorError_AlreadySubmitted = 108 , <nl> + VRCompositorError_InvalidBounds = 109 , <nl> + VRCompositorError_AlreadySet = 110 , <nl> + } ; <nl> + <nl> + / * * Timing mode passed to SetExplicitTimingMode ( ) ; see that function for documentation * / <nl> + enum EVRCompositorTimingMode <nl> + { <nl> + VRCompositorTimingMode_Implicit = 0 , <nl> + VRCompositorTimingMode_Explicit_RuntimePerformsPostPresentHandoff = 1 , <nl> + VRCompositorTimingMode_Explicit_ApplicationPerformsPostPresentHandoff = 2 , <nl> + } ; <nl> + <nl> + / * * Cumulative stats for current application . These are not cleared until a new app connects , <nl> + * but they do stop accumulating once the associated app disconnects . * / <nl> + struct Compositor_CumulativeStats <nl> + { <nl> + uint32_t m_nPid ; / / Process id associated with these stats ( may no longer be running ) . <nl> + uint32_t m_nNumFramePresents ; / / total number of times we called present ( includes reprojected frames ) <nl> + uint32_t m_nNumDroppedFrames ; / / total number of times an old frame was re - scanned out ( without reprojection ) <nl> + uint32_t m_nNumReprojectedFrames ; / / total number of times a frame was scanned out a second time ( with reprojection ) <nl> + <nl> + / * * Values recorded at startup before application has fully faded in the first time . * / <nl> + uint32_t m_nNumFramePresentsOnStartup ; <nl> + uint32_t m_nNumDroppedFramesOnStartup ; <nl> + uint32_t m_nNumReprojectedFramesOnStartup ; <nl> + <nl> + / * * Applications may explicitly fade to the compositor . This is usually to handle level transitions , and loading often causes <nl> + * system wide hitches . The following stats are collected during this period . Does not include values recorded during startup . * / <nl> + uint32_t m_nNumLoading ; <nl> + uint32_t m_nNumFramePresentsLoading ; <nl> + uint32_t m_nNumDroppedFramesLoading ; <nl> + uint32_t m_nNumReprojectedFramesLoading ; <nl> + <nl> + / * * If we don ' t get a new frame from the app in less than 2 . 5 frames , then we assume the app has hung and start <nl> + * fading back to the compositor . The following stats are a result of this , and are a subset of those recorded above . <nl> + * Does not include values recorded during start up or loading . * / <nl> + uint32_t m_nNumTimedOut ; <nl> + uint32_t m_nNumFramePresentsTimedOut ; <nl> + uint32_t m_nNumDroppedFramesTimedOut ; <nl> + uint32_t m_nNumReprojectedFramesTimedOut ; <nl> + } ; <nl> + <nl> + struct Compositor_StageRenderSettings <nl> + { <nl> + / * * Primary color is applied as a tint to ( i . e . multiplied with ) the model ' s texture * / <nl> + HmdColor_t m_PrimaryColor ; <nl> + HmdColor_t m_SecondaryColor ; <nl> + <nl> + / * * Vignette radius is in meters and is used to fade to the specified secondary solid color over <nl> + * that 3D distance from the origin of the playspace . * / <nl> + float m_flVignetteInnerRadius ; <nl> + float m_flVignetteOuterRadius ; <nl> + <nl> + / * * Fades to the secondary color based on view incidence . This variable controls the linearity <nl> + * of the effect . It is mutually exclusive with vignette . Additionally , it treats the mesh as faceted . * / <nl> + float m_flFresnelStrength ; <nl> + <nl> + / * * Controls backface culling . * / <nl> + bool m_bBackfaceCulling ; <nl> + <nl> + / * * Converts the render model ' s texture to luma and applies to rgb equally . This is useful to <nl> + * combat compression artifacts that can occur on desaturated source material . * / <nl> + bool m_bGreyscale ; <nl> + <nl> + / * * Renders mesh as a wireframe . * / <nl> + bool m_bWireframe ; <nl> + } ; <nl> + <nl> + static inline Compositor_StageRenderSettings DefaultStageRenderSettings ( ) <nl> + { <nl> + Compositor_StageRenderSettings settings ; <nl> + settings . m_PrimaryColor . r = 1 . 0f ; <nl> + settings . m_PrimaryColor . g = 1 . 0f ; <nl> + settings . m_PrimaryColor . b = 1 . 0f ; <nl> + settings . m_PrimaryColor . a = 1 . 0f ; <nl> + settings . m_SecondaryColor . r = 1 . 0f ; <nl> + settings . m_SecondaryColor . g = 1 . 0f ; <nl> + settings . m_SecondaryColor . b = 1 . 0f ; <nl> + settings . m_SecondaryColor . a = 1 . 0f ; <nl> + settings . m_flVignetteInnerRadius = 0 . 0f ; <nl> + settings . m_flVignetteOuterRadius = 0 . 0f ; <nl> + settings . m_flFresnelStrength = 0 . 0f ; <nl> + settings . m_bBackfaceCulling = false ; <nl> + settings . m_bGreyscale = false ; <nl> + settings . m_bWireframe = false ; <nl> + return settings ; <nl> + } <nl> + <nl> + # pragma pack ( pop ) <nl> + <nl> + / * * Allows the application to interact with the compositor * / <nl> + class IVRCompositor <nl> + { <nl> + public : <nl> + / * * Sets tracking space returned by WaitGetPoses * / <nl> + virtual void SetTrackingSpace ( ETrackingUniverseOrigin eOrigin ) = 0 ; <nl> + <nl> + / * * Gets current tracking space returned by WaitGetPoses * / <nl> + virtual ETrackingUniverseOrigin GetTrackingSpace ( ) = 0 ; <nl> + <nl> + / * * Scene applications should call this function to get poses to render with ( and optionally poses predicted an additional frame out to use for gameplay ) . <nl> + * This function will block until " running start " milliseconds before the start of the frame , and should be called at the last moment before needing to <nl> + * start rendering . <nl> + * <nl> + * Return codes : <nl> + * - IsNotSceneApplication ( make sure to call VR_Init with VRApplicaiton_Scene ) <nl> + * - DoNotHaveFocus ( some other app has taken focus - this will throttle the call to 10hz to reduce the impact on that app ) <nl> + * / <nl> + virtual EVRCompositorError WaitGetPoses ( VR_ARRAY_COUNT ( unRenderPoseArrayCount ) TrackedDevicePose_t * pRenderPoseArray , uint32_t unRenderPoseArrayCount , <nl> + VR_ARRAY_COUNT ( unGamePoseArrayCount ) TrackedDevicePose_t * pGamePoseArray , uint32_t unGamePoseArrayCount ) = 0 ; <nl> + <nl> + / * * Get the last set of poses returned by WaitGetPoses . * / <nl> + virtual EVRCompositorError GetLastPoses ( VR_ARRAY_COUNT ( unRenderPoseArrayCount ) TrackedDevicePose_t * pRenderPoseArray , uint32_t unRenderPoseArrayCount , <nl> + VR_ARRAY_COUNT ( unGamePoseArrayCount ) TrackedDevicePose_t * pGamePoseArray , uint32_t unGamePoseArrayCount ) = 0 ; <nl> + <nl> + / * * Interface for accessing last set of poses returned by WaitGetPoses one at a time . <nl> + * Returns VRCompositorError_IndexOutOfRange if unDeviceIndex not less than k_unMaxTrackedDeviceCount otherwise VRCompositorError_None . <nl> + * It is okay to pass NULL for either pose if you only want one of the values . * / <nl> + virtual EVRCompositorError GetLastPoseForTrackedDeviceIndex ( TrackedDeviceIndex_t unDeviceIndex , TrackedDevicePose_t * pOutputPose , TrackedDevicePose_t * pOutputGamePose ) = 0 ; <nl> + <nl> + / * * Updated scene texture to display . If pBounds is NULL the entire texture will be used . If called from an OpenGL app , consider adding a glFlush after <nl> + * Submitting both frames to signal the driver to start processing , otherwise it may wait until the command buffer fills up , causing the app to miss frames . <nl> + * <nl> + * OpenGL dirty state : <nl> + * glBindTexture <nl> + * <nl> + * Return codes : <nl> + * - IsNotSceneApplication ( make sure to call VR_Init with VRApplicaiton_Scene ) <nl> + * - DoNotHaveFocus ( some other app has taken focus ) <nl> + * - TextureIsOnWrongDevice ( application did not use proper AdapterIndex - see IVRSystem . GetDXGIOutputInfo ) <nl> + * - SharedTexturesNotSupported ( application needs to call CreateDXGIFactory1 or later before creating DX device ) <nl> + * - TextureUsesUnsupportedFormat ( scene textures must be compatible with DXGI sharing rules - e . g . uncompressed , no mips , etc . ) <nl> + * - InvalidTexture ( usually means bad arguments passed in ) <nl> + * - AlreadySubmitted ( app has submitted two left textures or two right textures in a single frame - i . e . before calling WaitGetPoses again ) <nl> + * / <nl> + virtual EVRCompositorError Submit ( EVREye eEye , const Texture_t * pTexture , const VRTextureBounds_t * pBounds = 0 , EVRSubmitFlags nSubmitFlags = Submit_Default ) = 0 ; <nl> + <nl> + / * * Clears the frame that was sent with the last call to Submit . This will cause the <nl> + * compositor to show the grid until Submit is called again . * / <nl> + virtual void ClearLastSubmittedFrame ( ) = 0 ; <nl> + <nl> + / * * Call immediately after presenting your app ' s window ( i . e . companion window ) to unblock the compositor . <nl> + * This is an optional call , which only needs to be used if you can ' t instead call WaitGetPoses immediately after Present . <nl> + * For example , if your engine ' s render and game loop are not on separate threads , or blocking the render thread until 3ms before the next vsync would <nl> + * introduce a deadlock of some sort . This function tells the compositor that you have finished all rendering after having Submitted buffers for both <nl> + * eyes , and it is free to start its rendering work . This should only be called from the same thread you are rendering on . * / <nl> + virtual void PostPresentHandoff ( ) = 0 ; <nl> + <nl> + / * * Returns true if timing data is filled it . Sets oldest timing info if nFramesAgo is larger than the stored history . <nl> + * Be sure to set timing . size = sizeof ( Compositor_FrameTiming ) on struct passed in before calling this function . * / <nl> + virtual bool GetFrameTiming ( Compositor_FrameTiming * pTiming , uint32_t unFramesAgo = 0 ) = 0 ; <nl> + <nl> + / * * Interface for copying a range of timing data . Frames are returned in ascending order ( oldest to newest ) with the last being the most recent frame . <nl> + * Only the first entry ' s m_nSize needs to be set , as the rest will be inferred from that . Returns total number of entries filled out . * / <nl> + virtual uint32_t GetFrameTimings ( VR_ARRAY_COUNT ( nFrames ) Compositor_FrameTiming * pTiming , uint32_t nFrames ) = 0 ; <nl> + <nl> + / * * Returns the time in seconds left in the current ( as identified by FrameTiming ' s frameIndex ) frame . <nl> + * Due to " running start " , this value may roll over to the next frame before ever reaching 0 . 0 . * / <nl> + virtual float GetFrameTimeRemaining ( ) = 0 ; <nl> + <nl> + / * * Fills out stats accumulated for the last connected application . Pass in sizeof ( Compositor_CumulativeStats ) as second parameter . * / <nl> + virtual void GetCumulativeStats ( Compositor_CumulativeStats * pStats , uint32_t nStatsSizeInBytes ) = 0 ; <nl> + <nl> + / * * Fades the view on the HMD to the specified color . The fade will take fSeconds , and the color values are between <nl> + * 0 . 0 and 1 . 0 . This color is faded on top of the scene based on the alpha parameter . Removing the fade color instantly <nl> + * would be FadeToColor ( 0 . 0 , 0 . 0 , 0 . 0 , 0 . 0 , 0 . 0 ) . Values are in un - premultiplied alpha space . * / <nl> + virtual void FadeToColor ( float fSeconds , float fRed , float fGreen , float fBlue , float fAlpha , bool bBackground = false ) = 0 ; <nl> + <nl> + / * * Get current fade color value . * / <nl> + virtual HmdColor_t GetCurrentFadeColor ( bool bBackground = false ) = 0 ; <nl> + <nl> + / * * Fading the Grid in or out in fSeconds * / <nl> + virtual void FadeGrid ( float fSeconds , bool bFadeIn ) = 0 ; <nl> + <nl> + / * * Get current alpha value of grid . * / <nl> + virtual float GetCurrentGridAlpha ( ) = 0 ; <nl> + <nl> + / * * Override the skybox used in the compositor ( e . g . for during level loads when the app can ' t feed scene images fast enough ) <nl> + * Order is Front , Back , Left , Right , Top , Bottom . If only a single texture is passed , it is assumed in lat - long format . <nl> + * If two are passed , it is assumed a lat - long stereo pair . * / <nl> + virtual EVRCompositorError SetSkyboxOverride ( VR_ARRAY_COUNT ( unTextureCount ) const Texture_t * pTextures , uint32_t unTextureCount ) = 0 ; <nl> + <nl> + / * * Resets compositor skybox back to defaults . * / <nl> + virtual void ClearSkyboxOverride ( ) = 0 ; <nl> + <nl> + / * * Brings the compositor window to the front . This is useful for covering any other window that may be on the HMD <nl> + * and is obscuring the compositor window . * / <nl> + virtual void CompositorBringToFront ( ) = 0 ; <nl> + <nl> + / * * Pushes the compositor window to the back . This is useful for allowing other applications to draw directly to the HMD . * / <nl> + virtual void CompositorGoToBack ( ) = 0 ; <nl> + <nl> + / * * Tells the compositor process to clean up and exit . You do not need to call this function at shutdown . Under normal <nl> + * circumstances the compositor will manage its own life cycle based on what applications are running . * / <nl> + virtual void CompositorQuit ( ) = 0 ; <nl> + <nl> + / * * Return whether the compositor is fullscreen * / <nl> + virtual bool IsFullscreen ( ) = 0 ; <nl> + <nl> + / * * Returns the process ID of the process that is currently rendering the scene * / <nl> + virtual uint32_t GetCurrentSceneFocusProcess ( ) = 0 ; <nl> + <nl> + / * * Returns the process ID of the process that rendered the last frame ( or 0 if the compositor itself rendered the frame . ) <nl> + * Returns 0 when fading out from an app and the app ' s process Id when fading into an app . * / <nl> + virtual uint32_t GetLastFrameRenderer ( ) = 0 ; <nl> + <nl> + / * * Returns true if the current process has the scene focus * / <nl> + virtual bool CanRenderScene ( ) = 0 ; <nl> + <nl> + / * * DEPRECATED : Opens the headset view ( as either a window or docked widget depending on user ' s preferences ) that displays what the user <nl> + * sees in the headset . * / <nl> + virtual void ShowMirrorWindow ( ) = 0 ; <nl> + <nl> + / * * DEPRECATED : Closes the headset view , either as a window or docked widget . * / <nl> + virtual void HideMirrorWindow ( ) = 0 ; <nl> + <nl> + / * * DEPRECATED : Returns true if the headset view ( either as a window or docked widget ) is shown . * / <nl> + virtual bool IsMirrorWindowVisible ( ) = 0 ; <nl> + <nl> + / * * Writes back buffer and stereo left / right pair from the application to a ' screenshots ' folder in the SteamVR runtime root . * / <nl> + virtual void CompositorDumpImages ( ) = 0 ; <nl> + <nl> + / * * Let an app know it should be rendering with low resources . * / <nl> + virtual bool ShouldAppRenderWithLowResources ( ) = 0 ; <nl> + <nl> + / * * Override interleaved reprojection logic to force on . * / <nl> + virtual void ForceInterleavedReprojectionOn ( bool bOverride ) = 0 ; <nl> + <nl> + / * * Force reconnecting to the compositor process . * / <nl> + virtual void ForceReconnectProcess ( ) = 0 ; <nl> + <nl> + / * * Temporarily suspends rendering ( useful for finer control over scene transitions ) . * / <nl> + virtual void SuspendRendering ( bool bSuspend ) = 0 ; <nl> + <nl> + / * * Opens a shared D3D11 texture with the undistorted composited image for each eye . Use ReleaseMirrorTextureD3D11 when finished <nl> + * instead of calling Release on the resource itself . * / <nl> + virtual vr : : EVRCompositorError GetMirrorTextureD3D11 ( vr : : EVREye eEye , void * pD3D11DeviceOrResource , void * * ppD3D11ShaderResourceView ) = 0 ; <nl> + virtual void ReleaseMirrorTextureD3D11 ( void * pD3D11ShaderResourceView ) = 0 ; <nl> + <nl> + / * * Access to mirror textures from OpenGL . * / <nl> + virtual vr : : EVRCompositorError GetMirrorTextureGL ( vr : : EVREye eEye , vr : : glUInt_t * pglTextureId , vr : : glSharedTextureHandle_t * pglSharedTextureHandle ) = 0 ; <nl> + virtual bool ReleaseSharedGLTexture ( vr : : glUInt_t glTextureId , vr : : glSharedTextureHandle_t glSharedTextureHandle ) = 0 ; <nl> + virtual void LockGLSharedTextureForAccess ( vr : : glSharedTextureHandle_t glSharedTextureHandle ) = 0 ; <nl> + virtual void UnlockGLSharedTextureForAccess ( vr : : glSharedTextureHandle_t glSharedTextureHandle ) = 0 ; <nl> + <nl> + / * * [ Vulkan Only ] <nl> + * return 0 . Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing <nl> + * null . The string will be a space separated list of - required instance extensions to enable in VkCreateInstance * / <nl> + virtual uint32_t GetVulkanInstanceExtensionsRequired ( VR_OUT_STRING ( ) char * pchValue , uint32_t unBufferSize ) = 0 ; <nl> + <nl> + / * * [ Vulkan only ] <nl> + * return 0 . Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing <nl> + * null . The string will be a space separated list of required device extensions to enable in VkCreateDevice * / <nl> + virtual uint32_t GetVulkanDeviceExtensionsRequired ( VkPhysicalDevice_T * pPhysicalDevice , VR_OUT_STRING ( ) char * pchValue , uint32_t unBufferSize ) = 0 ; <nl> + <nl> + / * * [ Vulkan / D3D12 Only ] <nl> + * There are two purposes for SetExplicitTimingMode : <nl> + * 1 . To get a more accurate GPU timestamp for when the frame begins in Vulkan / D3D12 applications . <nl> + * 2 . ( Optional ) To avoid having WaitGetPoses access the Vulkan queue so that the queue can be accessed from <nl> + * another thread while WaitGetPoses is executing . <nl> + * <nl> + * More accurate GPU timestamp for the start of the frame is achieved by the application calling <nl> + * SubmitExplicitTimingData immediately before its first submission to the Vulkan / D3D12 queue . <nl> + * This is more accurate because normally this GPU timestamp is recorded during WaitGetPoses . In D3D11 , <nl> + * WaitGetPoses queues a GPU timestamp write , but it does not actually get submitted to the GPU until the <nl> + * application flushes . By using SubmitExplicitTimingData , the timestamp is recorded at the same place for <nl> + * Vulkan / D3D12 as it is for D3D11 , resulting in a more accurate GPU time measurement for the frame . <nl> + * <nl> + * Avoiding WaitGetPoses accessing the Vulkan queue can be achieved using SetExplicitTimingMode as well . If this is desired , <nl> + * the application should set the timing mode to Explicit_ApplicationPerformsPostPresentHandoff and * MUST * call PostPresentHandoff <nl> + * itself . If these conditions are met , then WaitGetPoses is guaranteed not to access the queue . Note that PostPresentHandoff <nl> + * and SubmitExplicitTimingData will access the queue , so only WaitGetPoses becomes safe for accessing the queue from another <nl> + * thread . * / <nl> + virtual void SetExplicitTimingMode ( EVRCompositorTimingMode eTimingMode ) = 0 ; <nl> + <nl> + / * * [ Vulkan / D3D12 Only ] <nl> + * Submit explicit timing data . When SetExplicitTimingMode is true , this must be called immediately before <nl> + * the application ' s first vkQueueSubmit ( Vulkan ) or ID3D12CommandQueue : : ExecuteCommandLists ( D3D12 ) of each frame . <nl> + * This function will insert a GPU timestamp write just before the application starts its rendering . This function <nl> + * will perform a vkQueueSubmit on Vulkan so must not be done simultaneously with VkQueue operations on another thread . <nl> + * Returns VRCompositorError_RequestFailed if SetExplicitTimingMode is not enabled . * / <nl> + virtual EVRCompositorError SubmitExplicitTimingData ( ) = 0 ; <nl> + <nl> + / * * Indicates whether or not motion smoothing is enabled by the user settings . <nl> + * If you want to know if motion smoothing actually triggered due to a late frame , check Compositor_FrameTiming <nl> + * m_nReprojectionFlags & VRCompositor_ReprojectionMotion instead . * / <nl> + virtual bool IsMotionSmoothingEnabled ( ) = 0 ; <nl> + <nl> + / * * Indicates whether or not motion smoothing is supported by the current hardware . * / <nl> + virtual bool IsMotionSmoothingSupported ( ) = 0 ; <nl> + <nl> + / * * Indicates whether or not the current scene focus app is currently loading . This is inferred from its use of FadeGrid to <nl> + * explicitly fade to the compositor to cover up the fact that it cannot render at a sustained full framerate during this time . * / <nl> + virtual bool IsCurrentSceneFocusAppLoading ( ) = 0 ; <nl> + <nl> + / * * Override the stage model used in the compositor to replace the grid . RenderModelPath is a full path the an OBJ file to load . <nl> + * This file will be loaded asynchronously from disk and uploaded to the gpu by the runtime . Once ready for rendering , the <nl> + * VREvent StageOverrideReady will be sent . Use FadeToGrid to reveal . Call ClearStageOverride to free the associated resources when finished . * / <nl> + virtual EVRCompositorError SetStageOverride_Async ( const char * pchRenderModelPath , const HmdMatrix34_t * pTransform = 0 , <nl> + const Compositor_StageRenderSettings * pRenderSettings = 0 , uint32_t nSizeOfRenderSettings = 0 ) = 0 ; <nl> + <nl> + / * * Resets the stage to its default user specified setting . * / <nl> + virtual void ClearStageOverride ( ) = 0 ; <nl> + <nl> + / * * Returns true if pBenchmarkResults is filled it . Sets pBenchmarkResults with the result of the compositor benchmark . <nl> + * nSizeOfBenchmarkResults should be set to sizeof ( Compositor_BenchmarkResults ) * / <nl> + virtual bool GetCompositorBenchmarkResults ( Compositor_BenchmarkResults * pBenchmarkResults , uint32_t nSizeOfBenchmarkResults ) = 0 ; <nl> + <nl> + / * * Returns the frame id associated with the poses last returned by WaitGetPoses . Deltas between IDs correspond to number of headset vsync intervals . * / <nl> + virtual EVRCompositorError GetLastPosePredictionIDs ( uint32_t * pRenderPosePredictionID , uint32_t * pGamePosePredictionID ) = 0 ; <nl> + <nl> + / * * Get the most up - to - date predicted ( or recorded - up to 100ms old ) set of poses for a given frame id . * / <nl> + virtual EVRCompositorError GetPosesForFrame ( uint32_t unPosePredictionID , VR_ARRAY_COUNT ( unPoseArrayCount ) TrackedDevicePose_t * pPoseArray , uint32_t unPoseArrayCount ) = 0 ; <nl> + } ; <nl> + <nl> + static const char * const IVRCompositor_Version = " IVRCompositor_026 " ; <nl> + <nl> + } / / namespace vr <nl> + <nl> + <nl> + <nl> + / / ivrheadsetview . h <nl> + namespace vr <nl> + { <nl> + enum HeadsetViewMode_t <nl> + { <nl> + HeadsetViewMode_Left = 0 , <nl> + HeadsetViewMode_Right , <nl> + HeadsetViewMode_Both <nl> + } ; <nl> + <nl> + class IVRHeadsetView <nl> + { <nl> + public : <nl> + / * * Sets the resolution in pixels to render the headset view . These values are clamped to k_unHeadsetViewMaxWidth <nl> + * and k_unHeadsetViewMaxHeight respectively . For cropped views , the rendered output will be fit to aspect ratio <nl> + * defined by the the specified dimensions . For uncropped views , the caller should use GetHeadsetViewAspectRation <nl> + * to adjust the requested render size to avoid squashing or stretching , and then apply letterboxing to compensate <nl> + * when displaying the results . * / <nl> + virtual void SetHeadsetViewSize ( uint32_t nWidth , uint32_t nHeight ) = 0 ; <nl> + <nl> + / * * Gets the current resolution used to render the headset view . * / <nl> + virtual void GetHeadsetViewSize ( uint32_t * pnWidth , uint32_t * pnHeight ) = 0 ; <nl> + <nl> + / * * Set the mode used to render the headset view . * / <nl> + virtual void SetHeadsetViewMode ( HeadsetViewMode_t eHeadsetViewMode ) = 0 ; <nl> + <nl> + / * * Get the current mode used to render the headset view . * / <nl> + virtual HeadsetViewMode_t GetHeadsetViewMode ( ) = 0 ; <nl> + <nl> + / * * Set whether or not the headset view should be rendered cropped to hide the hidden area mesh or not . * / <nl> + virtual void SetHeadsetViewCropped ( bool bCropped ) = 0 ; <nl> + <nl> + / * * Get the current cropping status of the headset view . * / <nl> + virtual bool GetHeadsetViewCropped ( ) = 0 ; <nl> + <nl> + / * * Get the aspect ratio ( width : height ) of the uncropped headset view ( accounting for the current set mode ) . * / <nl> + virtual float GetHeadsetViewAspectRatio ( ) = 0 ; <nl> + <nl> + / * * Set the range [ 0 . . 1 ] that the headset view blends across the stereo overlapped area in cropped both mode . * / <nl> + virtual void SetHeadsetViewBlendRange ( float flStartPct , float flEndPct ) = 0 ; <nl> + <nl> + / * * Get the current range [ 0 . . 1 ] that the headset view blends across the stereo overlapped area in cropped both mode . * / <nl> + virtual void GetHeadsetViewBlendRange ( float * pStartPct , float * pEndPct ) = 0 ; <nl> + } ; <nl> + <nl> + static const uint32_t k_unHeadsetViewMaxWidth = 3840 ; <nl> + static const uint32_t k_unHeadsetViewMaxHeight = 2160 ; <nl> + static const char * const k_pchHeadsetViewOverlayKey = " system . HeadsetView " ; <nl> + <nl> + static const char * const IVRHeadsetView_Version = " IVRHeadsetView_001 " ; <nl> + <nl> + / * * Returns the current IVRHeadsetView pointer or NULL the interface could not be found . * / <nl> + VR_INTERFACE vr : : IVRHeadsetView * VR_CALLTYPE VRHeadsetView ( ) ; <nl> + <nl> + } / / namespace vr <nl> + <nl> + <nl> + / / ivrnotifications . h <nl> + namespace vr <nl> + { <nl> + <nl> + # pragma pack ( push , 8 ) <nl> + <nl> + / / Used for passing graphic data <nl> + struct NotificationBitmap_t <nl> + { <nl> + NotificationBitmap_t ( ) <nl> + : m_pImageData ( nullptr ) <nl> + , m_nWidth ( 0 ) <nl> + , m_nHeight ( 0 ) <nl> + , m_nBytesPerPixel ( 0 ) <nl> + { <nl> + } <nl> + <nl> + void * m_pImageData ; <nl> + int32_t m_nWidth ; <nl> + int32_t m_nHeight ; <nl> + int32_t m_nBytesPerPixel ; <nl> + } ; <nl> + <nl> + <nl> + / * * Be aware that the notification type is used as ' priority ' to pick the next notification * / <nl> + enum EVRNotificationType <nl> + { <nl> + / * * Transient notifications are automatically hidden after a period of time set by the user . <nl> + * They are used for things like information and chat messages that do not require user interaction . * / <nl> + EVRNotificationType_Transient = 0 , <nl> + <nl> + / * * Persistent notifications are shown to the user until they are hidden by calling RemoveNotification ( ) . <nl> + * They are used for things like phone calls and alarms that require user interaction . * / <nl> + EVRNotificationType_Persistent = 1 , <nl> + <nl> + / * * System notifications are shown no matter what . It is expected , that the ulUserValue is used as ID . <nl> + * If there is already a system notification in the queue with that ID it is not accepted into the queue <nl> + * to prevent spamming with system notification * / <nl> + EVRNotificationType_Transient_SystemWithUserValue = 2 , <nl> + } ; <nl> + <nl> + enum EVRNotificationStyle <nl> + { <nl> + / * * Creates a notification with minimal external styling . * / <nl> + EVRNotificationStyle_None = 0 , <nl> + <nl> + / * * Used for notifications about overlay - level status . In Steam this is used for events like downloads completing . * / <nl> + EVRNotificationStyle_Application = 100 , <nl> + <nl> + / * * Used for notifications about contacts that are unknown or not available . In Steam this is used for friend invitations and offline friends . * / <nl> + EVRNotificationStyle_Contact_Disabled = 200 , <nl> + <nl> + / * * Used for notifications about contacts that are available but inactive . In Steam this is used for friends that are online but not playing a game . * / <nl> + EVRNotificationStyle_Contact_Enabled = 201 , <nl> + <nl> + / * * Used for notifications about contacts that are available and active . In Steam this is used for friends that are online and currently running a game . * / <nl> + EVRNotificationStyle_Contact_Active = 202 , <nl> + } ; <nl> + <nl> + static const uint32_t k_unNotificationTextMaxSize = 256 ; <nl> + <nl> + typedef uint32_t VRNotificationId ; <nl> + <nl> + <nl> + <nl> + # pragma pack ( pop ) <nl> + <nl> + / * * Allows notification sources to interact with the VR system <nl> + This current interface is not yet implemented . Do not use yet . * / <nl> + class IVRNotifications <nl> + { <nl> + public : <nl> + / * * Create a notification and enqueue it to be shown to the user . <nl> + * An overlay handle is required to create a notification , as otherwise it would be impossible for a user to act on it . <nl> + * To create a two - line notification , use a line break ( ' \ n ' ) to split the text into two lines . <nl> + * The pImage argument may be NULL , in which case the specified overlay ' s icon will be used instead . * / <nl> + virtual EVRNotificationError CreateNotification ( VROverlayHandle_t ulOverlayHandle , uint64_t ulUserValue , EVRNotificationType type , const char * pchText , EVRNotificationStyle style , const NotificationBitmap_t * pImage , / * out * / VRNotificationId * pNotificationId ) = 0 ; <nl> + <nl> + / * * Destroy a notification , hiding it first if it currently shown to the user . * / <nl> + virtual EVRNotificationError RemoveNotification ( VRNotificationId notificationId ) = 0 ; <nl> + <nl> + } ; <nl> + <nl> + static const char * const IVRNotifications_Version = " IVRNotifications_002 " ; <nl> + <nl> + } / / namespace vr <nl> + <nl> + <nl> + <nl> + / / ivroverlay . h <nl> + namespace vr <nl> + { <nl> + <nl> + / * * The maximum length of an overlay key in bytes , counting the terminating null character . * / <nl> + static const uint32_t k_unVROverlayMaxKeyLength = 128 ; <nl> + <nl> + / * * The maximum length of an overlay name in bytes , counting the terminating null character . * / <nl> + static const uint32_t k_unVROverlayMaxNameLength = 128 ; <nl> + <nl> + / * * The maximum number of overlays that can exist in the system at one time . * / <nl> + static const uint32_t k_unMaxOverlayCount = 128 ; <nl> + <nl> + / * * The maximum number of overlay intersection mask primitives per overlay * / <nl> + static const uint32_t k_unMaxOverlayIntersectionMaskPrimitivesCount = 32 ; <nl> + <nl> + / * * Types of input supported by VR Overlays * / <nl> + enum VROverlayInputMethod <nl> + { <nl> + VROverlayInputMethod_None = 0 , / / No input events will be generated automatically for this overlay <nl> + VROverlayInputMethod_Mouse = 1 , / / Tracked controllers will get mouse events automatically <nl> + / / VROverlayInputMethod_DualAnalog = 2 , / / No longer supported <nl> + } ; <nl> + <nl> + / * * Allows the caller to figure out which overlay transform getter to call . * / <nl> + enum VROverlayTransformType <nl> + { <nl> + VROverlayTransform_Invalid = - 1 , <nl> + VROverlayTransform_Absolute = 0 , <nl> + VROverlayTransform_TrackedDeviceRelative = 1 , <nl> + VROverlayTransform_SystemOverlay = 2 , <nl> + VROverlayTransform_TrackedComponent = 3 , <nl> + VROverlayTransform_Cursor = 4 , <nl> + VROverlayTransform_DashboardTab = 5 , <nl> + VROverlayTransform_DashboardThumb = 6 , <nl> + VROverlayTransform_Mountable = 7 , <nl> + } ; <nl> + <nl> + / * * Overlay control settings * / <nl> + enum VROverlayFlags <nl> + { <nl> + / / Set this flag on a dashboard overlay to prevent a tab from showing up for that overlay <nl> + VROverlayFlags_NoDashboardTab = 1 < < 3 , <nl> + <nl> + / / When this is set the overlay will receive VREvent_ScrollDiscrete events like a mouse wheel . <nl> + / / Requires mouse input mode . <nl> + VROverlayFlags_SendVRDiscreteScrollEvents = 1 < < 6 , <nl> + <nl> + / / Indicates that the overlay would like to receive <nl> + VROverlayFlags_SendVRTouchpadEvents = 1 < < 7 , <nl> + <nl> + / / If set this will render a vertical scroll wheel on the primary controller , <nl> + / / only needed if not using VROverlayFlags_SendVRScrollEvents but you still want to represent a scroll wheel <nl> + VROverlayFlags_ShowTouchPadScrollWheel = 1 < < 8 , <nl> + <nl> + / / If this is set ownership and render access to the overlay are transferred <nl> + / / to the new scene process on a call to IVRApplications : : LaunchInternalProcess <nl> + VROverlayFlags_TransferOwnershipToInternalProcess = 1 < < 9 , <nl> + <nl> + / / If set , renders 50 % of the texture in each eye , side by side <nl> + VROverlayFlags_SideBySide_Parallel = 1 < < 10 , / / Texture is left / right <nl> + VROverlayFlags_SideBySide_Crossed = 1 < < 11 , / / Texture is crossed and right / left <nl> + <nl> + VROverlayFlags_Panorama = 1 < < 12 , / / Texture is a panorama <nl> + VROverlayFlags_StereoPanorama = 1 < < 13 , / / Texture is a stereo panorama <nl> + <nl> + / / If this is set on an overlay owned by the scene application that overlay <nl> + / / will be sorted with the " Other " overlays on top of all other scene overlays <nl> + VROverlayFlags_SortWithNonSceneOverlays = 1 < < 14 , <nl> + <nl> + / / If set , the overlay will be shown in the dashboard , otherwise it will be hidden . <nl> + VROverlayFlags_VisibleInDashboard = 1 < < 15 , <nl> + <nl> + / / If this is set and the overlay ' s input method is not none , the system - wide laser mouse <nl> + / / mode will be activated whenever this overlay is visible . <nl> + VROverlayFlags_MakeOverlaysInteractiveIfVisible = 1 < < 16 , <nl> + <nl> + / / If this is set the overlay will receive smooth VREvent_ScrollSmooth that emulate trackpad scrolling . <nl> + / / Requires mouse input mode . <nl> + VROverlayFlags_SendVRSmoothScrollEvents = 1 < < 17 , <nl> + <nl> + / / If this is set , the overlay texture will be protected content , preventing unauthorized reads . <nl> + VROverlayFlags_ProtectedContent = 1 < < 18 , <nl> + <nl> + / / If this is set , the laser mouse splat will not be drawn over this overlay . The overlay will <nl> + / / be responsible for drawing its own " cursor " . <nl> + VROverlayFlags_HideLaserIntersection = 1 < < 19 , <nl> + <nl> + / / If this is set , clicking away from the overlay will cause it to receive a VREvent_Modal_Cancel event . <nl> + / / This is ignored for dashboard overlays . <nl> + VROverlayFlags_WantsModalBehavior = 1 < < 20 , <nl> + <nl> + / / If this is set , alpha composition assumes the texture is pre - multiplied <nl> + VROverlayFlags_IsPremultiplied = 1 < < 21 , <nl> + } ; <nl> + <nl> + enum VRMessageOverlayResponse <nl> + { <nl> + VRMessageOverlayResponse_ButtonPress_0 = 0 , <nl> + VRMessageOverlayResponse_ButtonPress_1 = 1 , <nl> + VRMessageOverlayResponse_ButtonPress_2 = 2 , <nl> + VRMessageOverlayResponse_ButtonPress_3 = 3 , <nl> + VRMessageOverlayResponse_CouldntFindSystemOverlay = 4 , <nl> + VRMessageOverlayResponse_CouldntFindOrCreateClientOverlay = 5 , <nl> + VRMessageOverlayResponse_ApplicationQuit = 6 <nl> + } ; <nl> + <nl> + struct VROverlayIntersectionParams_t <nl> + { <nl> + HmdVector3_t vSource ; <nl> + HmdVector3_t vDirection ; <nl> + ETrackingUniverseOrigin eOrigin ; <nl> + } ; <nl> + <nl> + struct VROverlayIntersectionResults_t <nl> + { <nl> + HmdVector3_t vPoint ; <nl> + HmdVector3_t vNormal ; <nl> + HmdVector2_t vUVs ; <nl> + float fDistance ; <nl> + } ; <nl> + <nl> + / / Input modes for the Big Picture gamepad text entry <nl> + enum EGamepadTextInputMode <nl> + { <nl> + k_EGamepadTextInputModeNormal = 0 , <nl> + k_EGamepadTextInputModePassword = 1 , <nl> + k_EGamepadTextInputModeSubmit = 2 , <nl> + } ; <nl> + <nl> + / / Controls number of allowed lines for the Big Picture gamepad text entry <nl> + enum EGamepadTextInputLineMode <nl> + { <nl> + k_EGamepadTextInputLineModeSingleLine = 0 , <nl> + k_EGamepadTextInputLineModeMultipleLines = 1 <nl> + } ; <nl> + <nl> + enum EVROverlayIntersectionMaskPrimitiveType <nl> + { <nl> + OverlayIntersectionPrimitiveType_Rectangle , <nl> + OverlayIntersectionPrimitiveType_Circle , <nl> + } ; <nl> + <nl> + struct IntersectionMaskRectangle_t <nl> + { <nl> + float m_flTopLeftX ; <nl> + float m_flTopLeftY ; <nl> + float m_flWidth ; <nl> + float m_flHeight ; <nl> + } ; <nl> + <nl> + struct IntersectionMaskCircle_t <nl> + { <nl> + float m_flCenterX ; <nl> + float m_flCenterY ; <nl> + float m_flRadius ; <nl> + } ; <nl> + <nl> + / * * NOTE ! ! ! If you change this you MUST manually update openvr_interop . cs . py and openvr_api_flat . h . py * / <nl> + typedef union <nl> + { <nl> + IntersectionMaskRectangle_t m_Rectangle ; <nl> + IntersectionMaskCircle_t m_Circle ; <nl> + } VROverlayIntersectionMaskPrimitive_Data_t ; <nl> + <nl> + struct VROverlayIntersectionMaskPrimitive_t <nl> + { <nl> + EVROverlayIntersectionMaskPrimitiveType m_nPrimitiveType ; <nl> + VROverlayIntersectionMaskPrimitive_Data_t m_Primitive ; <nl> + } ; <nl> + <nl> + enum EKeyboardFlags <nl> + { <nl> + KeyboardFlag_Minimal = 1 < < 0 , / / makes the keyboard send key events immediately instead of accumulating a buffer <nl> + KeyboardFlag_Modal = 2 < < 0 , / / makes the keyboard take all focus and dismiss when clicking off the panel <nl> + } ; <nl> + <nl> + <nl> + class IVROverlay <nl> + { <nl> + public : <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / Overlay management methods <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + <nl> + / * * Finds an existing overlay with the specified key . * / <nl> + virtual EVROverlayError FindOverlay ( const char * pchOverlayKey , VROverlayHandle_t * pOverlayHandle ) = 0 ; <nl> + <nl> + / * * Creates a new named overlay . All overlays start hidden and with default settings . * / <nl> + virtual EVROverlayError CreateOverlay ( const char * pchOverlayKey , const char * pchOverlayName , VROverlayHandle_t * pOverlayHandle ) = 0 ; <nl> + <nl> + / * * Destroys the specified overlay . When an application calls VR_Shutdown all overlays created by that app are <nl> + * automatically destroyed . * / <nl> + virtual EVROverlayError DestroyOverlay ( VROverlayHandle_t ulOverlayHandle ) = 0 ; <nl> + <nl> + / * * Fills the provided buffer with the string key of the overlay . Returns the size of buffer required to store the key , including <nl> + * the terminating null character . k_unVROverlayMaxKeyLength will be enough bytes to fit the string . * / <nl> + virtual uint32_t GetOverlayKey ( VROverlayHandle_t ulOverlayHandle , VR_OUT_STRING ( ) char * pchValue , uint32_t unBufferSize , EVROverlayError * pError = 0L ) = 0 ; <nl> + <nl> + / * * Fills the provided buffer with the friendly name of the overlay . Returns the size of buffer required to store the key , including <nl> + * the terminating null character . k_unVROverlayMaxNameLength will be enough bytes to fit the string . * / <nl> + virtual uint32_t GetOverlayName ( VROverlayHandle_t ulOverlayHandle , VR_OUT_STRING ( ) char * pchValue , uint32_t unBufferSize , EVROverlayError * pError = 0L ) = 0 ; <nl> + <nl> + / * * set the name to use for this overlay * / <nl> + virtual EVROverlayError SetOverlayName ( VROverlayHandle_t ulOverlayHandle , const char * pchName ) = 0 ; <nl> + <nl> + / * * Gets the raw image data from an overlay . Overlay image data is always returned as RGBA data , 4 bytes per pixel . If the buffer is not large enough , width and height <nl> + * will be set and VROverlayError_ArrayTooSmall is returned . * / <nl> + virtual EVROverlayError GetOverlayImageData ( VROverlayHandle_t ulOverlayHandle , void * pvBuffer , uint32_t unBufferSize , uint32_t * punWidth , uint32_t * punHeight ) = 0 ; <nl> + <nl> + / * * returns a string that corresponds with the specified overlay error . The string will be the name <nl> + * of the error enum value for all valid error codes * / <nl> + virtual const char * GetOverlayErrorNameFromEnum ( EVROverlayError error ) = 0 ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / Overlay rendering methods <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + <nl> + / * * Sets the pid that is allowed to render to this overlay ( the creator pid is always allow to render ) , <nl> + * by default this is the pid of the process that made the overlay * / <nl> + virtual EVROverlayError SetOverlayRenderingPid ( VROverlayHandle_t ulOverlayHandle , uint32_t unPID ) = 0 ; <nl> + <nl> + / * * Gets the pid that is allowed to render to this overlay * / <nl> + virtual uint32_t GetOverlayRenderingPid ( VROverlayHandle_t ulOverlayHandle ) = 0 ; <nl> + <nl> + / * * Specify flag setting for a given overlay * / <nl> + virtual EVROverlayError SetOverlayFlag ( VROverlayHandle_t ulOverlayHandle , VROverlayFlags eOverlayFlag , bool bEnabled ) = 0 ; <nl> + <nl> + / * * Sets flag setting for a given overlay * / <nl> + virtual EVROverlayError GetOverlayFlag ( VROverlayHandle_t ulOverlayHandle , VROverlayFlags eOverlayFlag , bool * pbEnabled ) = 0 ; <nl> + <nl> + / * * Gets all the flags for a given overlay * / <nl> + virtual EVROverlayError GetOverlayFlags ( VROverlayHandle_t ulOverlayHandle , uint32_t * pFlags ) = 0 ; <nl> + <nl> + / * * Sets the color tint of the overlay quad . Use 0 . 0 to 1 . 0 per channel . * / <nl> + virtual EVROverlayError SetOverlayColor ( VROverlayHandle_t ulOverlayHandle , float fRed , float fGreen , float fBlue ) = 0 ; <nl> + <nl> + / * * Gets the color tint of the overlay quad . * / <nl> + virtual EVROverlayError GetOverlayColor ( VROverlayHandle_t ulOverlayHandle , float * pfRed , float * pfGreen , float * pfBlue ) = 0 ; <nl> + <nl> + / * * Sets the alpha of the overlay quad . Use 1 . 0 for 100 percent opacity to 0 . 0 for 0 percent opacity . * / <nl> + virtual EVROverlayError SetOverlayAlpha ( VROverlayHandle_t ulOverlayHandle , float fAlpha ) = 0 ; <nl> + <nl> + / * * Gets the alpha of the overlay quad . By default overlays are rendering at 100 percent alpha ( 1 . 0 ) . * / <nl> + virtual EVROverlayError GetOverlayAlpha ( VROverlayHandle_t ulOverlayHandle , float * pfAlpha ) = 0 ; <nl> + <nl> + / * * Sets the aspect ratio of the texels in the overlay . 1 . 0 means the texels are square . 2 . 0 means the texels <nl> + * are twice as wide as they are tall . Defaults to 1 . 0 . * / <nl> + virtual EVROverlayError SetOverlayTexelAspect ( VROverlayHandle_t ulOverlayHandle , float fTexelAspect ) = 0 ; <nl> + <nl> + / * * Gets the aspect ratio of the texels in the overlay . Defaults to 1 . 0 * / <nl> + virtual EVROverlayError GetOverlayTexelAspect ( VROverlayHandle_t ulOverlayHandle , float * pfTexelAspect ) = 0 ; <nl> + <nl> + / * * Sets the rendering sort order for the overlay . Overlays are rendered this order : <nl> + * Overlays owned by the scene application <nl> + * Overlays owned by some other application <nl> + * <nl> + * Within a category overlays are rendered lowest sort order to highest sort order . Overlays with the same <nl> + * sort order are rendered back to front base on distance from the HMD . <nl> + * <nl> + * Sort order defaults to 0 . * / <nl> + virtual EVROverlayError SetOverlaySortOrder ( VROverlayHandle_t ulOverlayHandle , uint32_t unSortOrder ) = 0 ; <nl> + <nl> + / * * Gets the sort order of the overlay . See SetOverlaySortOrder for how this works . * / <nl> + virtual EVROverlayError GetOverlaySortOrder ( VROverlayHandle_t ulOverlayHandle , uint32_t * punSortOrder ) = 0 ; <nl> + <nl> + / * * Sets the width of the overlay quad in meters . By default overlays are rendered on a quad that is 1 meter across * / <nl> + virtual EVROverlayError SetOverlayWidthInMeters ( VROverlayHandle_t ulOverlayHandle , float fWidthInMeters ) = 0 ; <nl> + <nl> + / * * Returns the width of the overlay quad in meters . By default overlays are rendered on a quad that is 1 meter across * / <nl> + virtual EVROverlayError GetOverlayWidthInMeters ( VROverlayHandle_t ulOverlayHandle , float * pfWidthInMeters ) = 0 ; <nl> + <nl> + / * * Use to draw overlay as a curved surface . Curvature is a percentage from ( 0 . . 1 ] where 1 is a fully closed cylinder . <nl> + * For a specific radius , curvature can be computed as : overlay . width / ( 2 PI r ) . * / <nl> + virtual EVROverlayError SetOverlayCurvature ( VROverlayHandle_t ulOverlayHandle , float fCurvature ) = 0 ; <nl> + <nl> + / * * Returns the curvature of the overlay as a percentage from ( 0 . . 1 ] where 1 is a fully closed cylinder . * / <nl> + virtual EVROverlayError GetOverlayCurvature ( VROverlayHandle_t ulOverlayHandle , float * pfCurvature ) = 0 ; <nl> + <nl> + / * * Sets the colorspace the overlay texture ' s data is in . Defaults to ' auto ' . <nl> + * If the texture needs to be resolved , you should call SetOverlayTexture with the appropriate colorspace instead . * / <nl> + virtual EVROverlayError SetOverlayTextureColorSpace ( VROverlayHandle_t ulOverlayHandle , EColorSpace eTextureColorSpace ) = 0 ; <nl> + <nl> + / * * Gets the overlay ' s current colorspace setting . * / <nl> + virtual EVROverlayError GetOverlayTextureColorSpace ( VROverlayHandle_t ulOverlayHandle , EColorSpace * peTextureColorSpace ) = 0 ; <nl> + <nl> + / * * Sets the part of the texture to use for the overlay . UV Min is the upper left corner and UV Max is the lower right corner . * / <nl> + virtual EVROverlayError SetOverlayTextureBounds ( VROverlayHandle_t ulOverlayHandle , const VRTextureBounds_t * pOverlayTextureBounds ) = 0 ; <nl> + <nl> + / * * Gets the part of the texture to use for the overlay . UV Min is the upper left corner and UV Max is the lower right corner . * / <nl> + virtual EVROverlayError GetOverlayTextureBounds ( VROverlayHandle_t ulOverlayHandle , VRTextureBounds_t * pOverlayTextureBounds ) = 0 ; <nl> + <nl> + / * * Returns the transform type of this overlay . * / <nl> + virtual EVROverlayError GetOverlayTransformType ( VROverlayHandle_t ulOverlayHandle , VROverlayTransformType * peTransformType ) = 0 ; <nl> + <nl> + / * * Sets the transform to absolute tracking origin . * / <nl> + virtual EVROverlayError SetOverlayTransformAbsolute ( VROverlayHandle_t ulOverlayHandle , ETrackingUniverseOrigin eTrackingOrigin , const HmdMatrix34_t * pmatTrackingOriginToOverlayTransform ) = 0 ; <nl> + <nl> + / * * Gets the transform if it is absolute . Returns an error if the transform is some other type . * / <nl> + virtual EVROverlayError GetOverlayTransformAbsolute ( VROverlayHandle_t ulOverlayHandle , ETrackingUniverseOrigin * peTrackingOrigin , HmdMatrix34_t * pmatTrackingOriginToOverlayTransform ) = 0 ; <nl> + <nl> + / * * Sets the transform to relative to the transform of the specified tracked device . * / <nl> + virtual EVROverlayError SetOverlayTransformTrackedDeviceRelative ( VROverlayHandle_t ulOverlayHandle , TrackedDeviceIndex_t unTrackedDevice , const HmdMatrix34_t * pmatTrackedDeviceToOverlayTransform ) = 0 ; <nl> + <nl> + / * * Gets the transform if it is relative to a tracked device . Returns an error if the transform is some other type . * / <nl> + virtual EVROverlayError GetOverlayTransformTrackedDeviceRelative ( VROverlayHandle_t ulOverlayHandle , TrackedDeviceIndex_t * punTrackedDevice , HmdMatrix34_t * pmatTrackedDeviceToOverlayTransform ) = 0 ; <nl> + <nl> + / * * Sets the transform to draw the overlay on a rendermodel component mesh instead of a quad . This will only draw when the system is <nl> + * drawing the device . Overlays with this transform type cannot receive mouse events . * / <nl> + virtual EVROverlayError SetOverlayTransformTrackedDeviceComponent ( VROverlayHandle_t ulOverlayHandle , TrackedDeviceIndex_t unDeviceIndex , const char * pchComponentName ) = 0 ; <nl> + <nl> + / * * Gets the transform information when the overlay is rendering on a component . * / <nl> + virtual EVROverlayError GetOverlayTransformTrackedDeviceComponent ( VROverlayHandle_t ulOverlayHandle , TrackedDeviceIndex_t * punDeviceIndex , VR_OUT_STRING ( ) char * pchComponentName , uint32_t unComponentNameSize ) = 0 ; <nl> + <nl> + / * * Gets the transform if it is relative to another overlay . Returns an error if the transform is some other type . * / <nl> + virtual vr : : EVROverlayError GetOverlayTransformOverlayRelative ( VROverlayHandle_t ulOverlayHandle , VROverlayHandle_t * ulOverlayHandleParent , HmdMatrix34_t * pmatParentOverlayToOverlayTransform ) = 0 ; <nl> + <nl> + / * * Sets the transform to relative to the transform of the specified overlay . This overlays visibility will also track the parents visibility * / <nl> + virtual vr : : EVROverlayError SetOverlayTransformOverlayRelative ( VROverlayHandle_t ulOverlayHandle , VROverlayHandle_t ulOverlayHandleParent , const HmdMatrix34_t * pmatParentOverlayToOverlayTransform ) = 0 ; <nl> + <nl> + / * * Sets the hotspot for the specified overlay when that overlay is used as a cursor . These are in texture space with 0 , 0 in the upper left corner of <nl> + * the texture and 1 , 1 in the lower right corner of the texture . * / <nl> + virtual EVROverlayError SetOverlayTransformCursor ( VROverlayHandle_t ulCursorOverlayHandle , const HmdVector2_t * pvHotspot ) = 0 ; <nl> + <nl> + / * * Gets cursor hotspot / transform for the specified overlay * / <nl> + virtual vr : : EVROverlayError GetOverlayTransformCursor ( VROverlayHandle_t ulOverlayHandle , HmdVector2_t * pvHotspot ) = 0 ; <nl> + <nl> + / * * Shows the VR overlay . For dashboard overlays , only the Dashboard Manager is allowed to call this . * / <nl> + virtual EVROverlayError ShowOverlay ( VROverlayHandle_t ulOverlayHandle ) = 0 ; <nl> + <nl> + / * * Hides the VR overlay . For dashboard overlays , only the Dashboard Manager is allowed to call this . * / <nl> + virtual EVROverlayError HideOverlay ( VROverlayHandle_t ulOverlayHandle ) = 0 ; <nl> + <nl> + / * * Returns true if the overlay is visible . * / <nl> + virtual bool IsOverlayVisible ( VROverlayHandle_t ulOverlayHandle ) = 0 ; <nl> + <nl> + / * * Get the transform in 3d space associated with a specific 2d point in the overlay ' s coordinate space ( where 0 , 0 is the lower left ) . - Z points out of the overlay * / <nl> + virtual EVROverlayError GetTransformForOverlayCoordinates ( VROverlayHandle_t ulOverlayHandle , ETrackingUniverseOrigin eTrackingOrigin , HmdVector2_t coordinatesInOverlay , HmdMatrix34_t * pmatTransform ) = 0 ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / Overlay input methods <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + <nl> + / * * Returns true and fills the event with the next event on the overlay ' s event queue , if there is one . <nl> + * If there are no events this method returns false . uncbVREvent should be the size in bytes of the VREvent_t struct * / <nl> + virtual bool PollNextOverlayEvent ( VROverlayHandle_t ulOverlayHandle , VREvent_t * pEvent , uint32_t uncbVREvent ) = 0 ; <nl> + <nl> + / * * Returns the current input settings for the specified overlay . * / <nl> + virtual EVROverlayError GetOverlayInputMethod ( VROverlayHandle_t ulOverlayHandle , VROverlayInputMethod * peInputMethod ) = 0 ; <nl> + <nl> + / * * Sets the input settings for the specified overlay . * / <nl> + virtual EVROverlayError SetOverlayInputMethod ( VROverlayHandle_t ulOverlayHandle , VROverlayInputMethod eInputMethod ) = 0 ; <nl> + <nl> + / * * Gets the mouse scaling factor that is used for mouse events . The actual texture may be a different size , but this is <nl> + * typically the size of the underlying UI in pixels . * / <nl> + virtual EVROverlayError GetOverlayMouseScale ( VROverlayHandle_t ulOverlayHandle , HmdVector2_t * pvecMouseScale ) = 0 ; <nl> + <nl> + / * * Sets the mouse scaling factor that is used for mouse events . The actual texture may be a different size , but this is <nl> + * typically the size of the underlying UI in pixels ( not in world space ) . * / <nl> + virtual EVROverlayError SetOverlayMouseScale ( VROverlayHandle_t ulOverlayHandle , const HmdVector2_t * pvecMouseScale ) = 0 ; <nl> + <nl> + / * * Computes the overlay - space pixel coordinates of where the ray intersects the overlay with the <nl> + * specified settings . Returns false if there is no intersection . * / <nl> + virtual bool ComputeOverlayIntersection ( VROverlayHandle_t ulOverlayHandle , const VROverlayIntersectionParams_t * pParams , VROverlayIntersectionResults_t * pResults ) = 0 ; <nl> + <nl> + / * * Returns true if the specified overlay is the hover target . An overlay is the hover target when it is the last overlay " moused over " <nl> + * by the virtual mouse pointer * / <nl> + virtual bool IsHoverTargetOverlay ( VROverlayHandle_t ulOverlayHandle ) = 0 ; <nl> + <nl> + / * * Sets a list of primitives to be used for controller ray intersection <nl> + * typically the size of the underlying UI in pixels ( not in world space ) . * / <nl> + virtual EVROverlayError SetOverlayIntersectionMask ( VROverlayHandle_t ulOverlayHandle , VROverlayIntersectionMaskPrimitive_t * pMaskPrimitives , uint32_t unNumMaskPrimitives , uint32_t unPrimitiveSize = sizeof ( VROverlayIntersectionMaskPrimitive_t ) ) = 0 ; <nl> + <nl> + / * * Triggers a haptic event on the laser mouse controller for the specified overlay * / <nl> + virtual EVROverlayError TriggerLaserMouseHapticVibration ( VROverlayHandle_t ulOverlayHandle , float fDurationSeconds , float fFrequency , float fAmplitude ) = 0 ; <nl> + <nl> + / * * Sets the cursor to use for the specified overlay . This will be drawn instead of the generic blob when the laser mouse is pointed at the specified overlay * / <nl> + virtual EVROverlayError SetOverlayCursor ( VROverlayHandle_t ulOverlayHandle , VROverlayHandle_t ulCursorHandle ) = 0 ; <nl> + <nl> + / * * Sets the override cursor position to use for this overlay in overlay mouse coordinates . This position will be used to draw the cursor <nl> + * instead of whatever the laser mouse cursor position is . * / <nl> + virtual EVROverlayError SetOverlayCursorPositionOverride ( VROverlayHandle_t ulOverlayHandle , const HmdVector2_t * pvCursor ) = 0 ; <nl> + <nl> + / * * Clears the override cursor position for this overlay * / <nl> + virtual EVROverlayError ClearOverlayCursorPositionOverride ( VROverlayHandle_t ulOverlayHandle ) = 0 ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / Overlay texture methods <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + <nl> + / * * Texture to draw for the overlay . This function can only be called by the overlay ' s creator or renderer process ( see SetOverlayRenderingPid ) . <nl> + * <nl> + * OpenGL dirty state : <nl> + * glBindTexture <nl> + * / <nl> + virtual EVROverlayError SetOverlayTexture ( VROverlayHandle_t ulOverlayHandle , const Texture_t * pTexture ) = 0 ; <nl> + <nl> + / * * Use this to tell the overlay system to release the texture set for this overlay . * / <nl> + virtual EVROverlayError ClearOverlayTexture ( VROverlayHandle_t ulOverlayHandle ) = 0 ; <nl> + <nl> + / * * Separate interface for providing the data as a stream of bytes , but there is an upper bound on data <nl> + * that can be sent . This function can only be called by the overlay ' s renderer process . * / <nl> + virtual EVROverlayError SetOverlayRaw ( VROverlayHandle_t ulOverlayHandle , void * pvBuffer , uint32_t unWidth , uint32_t unHeight , uint32_t unBytesPerPixel ) = 0 ; <nl> + <nl> + / * * Separate interface for providing the image through a filename : can be png or jpg , and should not be bigger than 1920x1080 . <nl> + * This function can only be called by the overlay ' s renderer process * / <nl> + virtual EVROverlayError SetOverlayFromFile ( VROverlayHandle_t ulOverlayHandle , const char * pchFilePath ) = 0 ; <nl> + <nl> + / * * Get the native texture handle / device for an overlay you have created . <nl> + * On windows this handle will be a ID3D11ShaderResourceView with a ID3D11Texture2D bound . <nl> + * <nl> + * The texture will always be sized to match the backing texture you supplied in SetOverlayTexture above . <nl> + * <nl> + * You MUST call ReleaseNativeOverlayHandle ( ) with pNativeTextureHandle once you are done with this texture . <nl> + * <nl> + * pNativeTextureHandle is an OUTPUT , it will be a pointer to a ID3D11ShaderResourceView * . <nl> + * pNativeTextureRef is an INPUT and should be a ID3D11Resource * . The device used by pNativeTextureRef will be used to bind pNativeTextureHandle . <nl> + * / <nl> + virtual EVROverlayError GetOverlayTexture ( VROverlayHandle_t ulOverlayHandle , void * * pNativeTextureHandle , void * pNativeTextureRef , uint32_t * pWidth , uint32_t * pHeight , uint32_t * pNativeFormat , ETextureType * pAPIType , EColorSpace * pColorSpace , VRTextureBounds_t * pTextureBounds ) = 0 ; <nl> + <nl> + / * * Release the pNativeTextureHandle provided from the GetOverlayTexture call , this allows the system to free the underlying GPU resources for this object , <nl> + * so only do it once you stop rendering this texture . <nl> + * / <nl> + virtual EVROverlayError ReleaseNativeOverlayHandle ( VROverlayHandle_t ulOverlayHandle , void * pNativeTextureHandle ) = 0 ; <nl> + <nl> + / * * Get the size of the overlay texture * / <nl> + virtual EVROverlayError GetOverlayTextureSize ( VROverlayHandle_t ulOverlayHandle , uint32_t * pWidth , uint32_t * pHeight ) = 0 ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + / / Dashboard Overlay Methods <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + <nl> + / * * Creates a dashboard overlay and returns its handle * / <nl> + virtual EVROverlayError CreateDashboardOverlay ( const char * pchOverlayKey , const char * pchOverlayFriendlyName , VROverlayHandle_t * pMainHandle , VROverlayHandle_t * pThumbnailHandle ) = 0 ; <nl> + <nl> + / * * Returns true if the dashboard is visible * / <nl> + virtual bool IsDashboardVisible ( ) = 0 ; <nl> + <nl> + / * * returns true if the dashboard is visible and the specified overlay is the active system Overlay * / <nl> + virtual bool IsActiveDashboardOverlay ( VROverlayHandle_t ulOverlayHandle ) = 0 ; <nl> + <nl> + / * * Sets the dashboard overlay to only appear when the specified process ID has scene focus * / <nl> + virtual EVROverlayError SetDashboardOverlaySceneProcess ( VROverlayHandle_t ulOverlayHandle , uint32_t unProcessId ) = 0 ; <nl> + <nl> + / * * Gets the process ID that this dashboard overlay requires to have scene focus * / <nl> + virtual EVROverlayError GetDashboardOverlaySceneProcess ( VROverlayHandle_t ulOverlayHandle , uint32_t * punProcessId ) = 0 ; <nl> + <nl> + / * * Shows the dashboard . * / <nl> + virtual void ShowDashboard ( const char * pchOverlayToShow ) = 0 ; <nl> + <nl> + / * * Returns the tracked device that has the laser pointer in the dashboard * / <nl> + virtual vr : : TrackedDeviceIndex_t GetPrimaryDashboardDevice ( ) = 0 ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / Keyboard methods <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + <nl> + / * * Show the virtual keyboard to accept input . In most cases , you should pass KeyboardFlag_Modal to enable modal overlay <nl> + * behavior on the keyboard itself . See EKeyboardFlags for more . * / <nl> + virtual EVROverlayError ShowKeyboard ( EGamepadTextInputMode eInputMode , EGamepadTextInputLineMode eLineInputMode , uint32_t unFlags , <nl> + const char * pchDescription , uint32_t unCharMax , const char * pchExistingText , uint64_t uUserValue ) = 0 ; <nl> + <nl> + / * * Show the virtual keyboard to accept input for an overlay . In most cases , you should pass KeyboardFlag_Modal to enable modal <nl> + * overlay behavior on the keyboard itself . See EKeyboardFlags for more . * / <nl> + virtual EVROverlayError ShowKeyboardForOverlay ( VROverlayHandle_t ulOverlayHandle , EGamepadTextInputMode eInputMode , <nl> + EGamepadTextInputLineMode eLineInputMode , uint32_t unFlags , const char * pchDescription , uint32_t unCharMax , <nl> + const char * pchExistingText , uint64_t uUserValue ) = 0 ; <nl> + <nl> + / * * Get the text that was entered into the text input * * / <nl> + virtual uint32_t GetKeyboardText ( VR_OUT_STRING ( ) char * pchText , uint32_t cchText ) = 0 ; <nl> + <nl> + / * * Hide the virtual keyboard * * / <nl> + virtual void HideKeyboard ( ) = 0 ; <nl> + <nl> + / * * Set the position of the keyboard in world space * * / <nl> + virtual void SetKeyboardTransformAbsolute ( ETrackingUniverseOrigin eTrackingOrigin , const HmdMatrix34_t * pmatTrackingOriginToKeyboardTransform ) = 0 ; <nl> + <nl> + / * * Set the position of the keyboard in overlay space by telling it to avoid a rectangle in the overlay . Rectangle coords have ( 0 , 0 ) in the bottom left * * / <nl> + virtual void SetKeyboardPositionForOverlay ( VROverlayHandle_t ulOverlayHandle , HmdRect2_t avoidRect ) = 0 ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / Message box methods <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + <nl> + / * * Show the message overlay . This will block and return you a result . * * / <nl> + virtual VRMessageOverlayResponse ShowMessageOverlay ( const char * pchText , const char * pchCaption , const char * pchButton0Text , const char * pchButton1Text = nullptr , const char * pchButton2Text = nullptr , const char * pchButton3Text = nullptr ) = 0 ; <nl> + <nl> + / * * If the calling process owns the overlay and it ' s open , this will close it . * * / <nl> + virtual void CloseMessageOverlay ( ) = 0 ; <nl> + } ; <nl> + <nl> + static const char * const IVROverlay_Version = " IVROverlay_024 " ; <nl> + <nl> + } / / namespace vr <nl> + <nl> + / / ivroverlayview . h <nl> + namespace vr <nl> + { <nl> + struct VROverlayView_t <nl> + { <nl> + VROverlayHandle_t overlayHandle ; <nl> + Texture_t texture ; <nl> + VRTextureBounds_t textureBounds ; <nl> + } ; <nl> + <nl> + enum EDeviceType <nl> + { <nl> + DeviceType_Invalid = - 1 , / / Invalid handle <nl> + DeviceType_DirectX11 = 0 , / / Handle is an ID3D11Device <nl> + DeviceType_Vulkan = 1 , / / Handle is a pointer to a VRVulkanDevice_t structure <nl> + } ; <nl> + <nl> + struct VRVulkanDevice_t <nl> + { <nl> + VkInstance_T * m_pInstance ; <nl> + VkDevice_T * m_pDevice ; <nl> + VkPhysicalDevice_T * m_pPhysicalDevice ; <nl> + VkQueue_T * m_pQueue ; <nl> + uint32_t m_uQueueFamilyIndex ; <nl> + } ; <nl> + <nl> + struct VRNativeDevice_t <nl> + { <nl> + void * handle ; / / See EDeviceType definition above <nl> + EDeviceType eType ; <nl> + } ; <nl> + <nl> + class IVROverlayView <nl> + { <nl> + public : <nl> + / * * Acquire an OverlayView_t from an overlay handle <nl> + * <nl> + * The overlay view can be used to sample the contents directly by a native API . The <nl> + * contents of the OverlayView_t will remain unchanged through the lifetime of the <nl> + * OverlayView_t . <nl> + * <nl> + * The caller acquires read privileges over the OverlayView_t , but should not <nl> + * write to it . <nl> + * <nl> + * AcquireOverlayView ( ) may be called on the same ulOverlayHandle multiple times to <nl> + * refresh the image contents . In this case the caller is strongly encouraged to re - use <nl> + * the same pOverlayView for all re - acquisition calls . <nl> + * <nl> + * If the producer has not yet queued an image , AcquireOverlayView will return success , <nl> + * and the Texture_t will have the expected ETextureType . However , the Texture_t - > handle <nl> + * will be nullptr . Once the producer generates the first overlay frame , Texture_t - > handle <nl> + * will become a valid handle . <nl> + * / <nl> + virtual EVROverlayError AcquireOverlayView ( VROverlayHandle_t ulOverlayHandle , VRNativeDevice_t * pNativeDevice , VROverlayView_t * pOverlayView , uint32_t unOverlayViewSize ) = 0 ; <nl> + <nl> + / * * Release an acquired OverlayView_t <nl> + * <nl> + * Denotes that pOverlayView will no longer require access to the resources it acquired in <nl> + * all previous calls to AcquireOverlayView ( ) . <nl> + * <nl> + * All OverlayView_t * ' s provided to AcquireOverlayView ( ) as pOverlayViews must be <nl> + * passed into ReleaseOverlayView ( ) in order for the underlying GPU resources to be freed . <nl> + * / <nl> + virtual EVROverlayError ReleaseOverlayView ( VROverlayView_t * pOverlayView ) = 0 ; <nl> + <nl> + / * * Posts an overlay event * / <nl> + virtual void PostOverlayEvent ( VROverlayHandle_t ulOverlayHandle , const VREvent_t * pvrEvent ) = 0 ; <nl> + <nl> + / * * Determines whether this process is permitted to view an overlay ' s content . * / <nl> + virtual bool IsViewingPermitted ( VROverlayHandle_t ulOverlayHandle ) = 0 ; <nl> + <nl> + } ; <nl> + <nl> + static const char * const IVROverlayView_Version = " IVROverlayView_003 " ; <nl> + <nl> + } <nl> + <nl> + / / ivrrendermodels . h <nl> + namespace vr <nl> + { <nl> + <nl> + static const char * const k_pch_Controller_Component_GDC2015 = " gdc2015 " ; / / Canonical coordinate system of the gdc 2015 wired controller , provided for backwards compatibility <nl> + static const char * const k_pch_Controller_Component_Base = " base " ; / / For controllers with an unambiguous ' base ' . <nl> + static const char * const k_pch_Controller_Component_Tip = " tip " ; / / For controllers with an unambiguous ' tip ' ( used for ' laser - pointing ' ) <nl> + static const char * const k_pch_Controller_Component_HandGrip = " handgrip " ; / / Neutral , ambidextrous hand - pose when holding controller . On plane between neutrally posed index finger and thumb <nl> + static const char * const k_pch_Controller_Component_Status = " status " ; / / 1 : 1 aspect ratio status area , with canonical [ 0 , 1 ] uv mapping <nl> + <nl> + # pragma pack ( push , 8 ) <nl> + <nl> + / * * Errors that can occur with the VR compositor * / <nl> + enum EVRRenderModelError <nl> + { <nl> + VRRenderModelError_None = 0 , <nl> + VRRenderModelError_Loading = 100 , <nl> + VRRenderModelError_NotSupported = 200 , <nl> + VRRenderModelError_InvalidArg = 300 , <nl> + VRRenderModelError_InvalidModel = 301 , <nl> + VRRenderModelError_NoShapes = 302 , <nl> + VRRenderModelError_MultipleShapes = 303 , <nl> + VRRenderModelError_TooManyVertices = 304 , <nl> + VRRenderModelError_MultipleTextures = 305 , <nl> + VRRenderModelError_BufferTooSmall = 306 , <nl> + VRRenderModelError_NotEnoughNormals = 307 , <nl> + VRRenderModelError_NotEnoughTexCoords = 308 , <nl> + <nl> + VRRenderModelError_InvalidTexture = 400 , <nl> + } ; <nl> + <nl> + enum EVRRenderModelTextureFormat <nl> + { <nl> + VRRenderModelTextureFormat_RGBA8_SRGB = 0 , / / RGBA with 8 bits per channel per pixel . Data size is width * height * 4ub <nl> + VRRenderModelTextureFormat_BC2 , <nl> + VRRenderModelTextureFormat_BC4 , <nl> + VRRenderModelTextureFormat_BC7 , <nl> + VRRenderModelTextureFormat_BC7_SRGB <nl> + } ; <nl> + <nl> + / * * A single vertex in a render model * / <nl> + struct RenderModel_Vertex_t <nl> + { <nl> + HmdVector3_t vPosition ; / / position in meters in device space <nl> + HmdVector3_t vNormal ; <nl> + float rfTextureCoord [ 2 ] ; <nl> + } ; <nl> + <nl> + / * * A texture map for use on a render model * / <nl> + # if defined ( __linux__ ) | | defined ( __APPLE__ ) <nl> + / / This structure was originally defined mis - packed on Linux , preserved for <nl> + / / compatibility . <nl> + # pragma pack ( push , 4 ) <nl> + # endif <nl> + <nl> + struct RenderModel_TextureMap_t <nl> + { <nl> + uint16_t unWidth , unHeight ; / / width and height of the texture map in pixels <nl> + const uint8_t * rubTextureMapData ; / / Map texture data . <nl> + EVRRenderModelTextureFormat format ; / / Refer to EVRRenderModelTextureFormat <nl> + } ; <nl> + # if defined ( __linux__ ) | | defined ( __APPLE__ ) <nl> + # pragma pack ( pop ) <nl> + # endif <nl> + <nl> + / * * Session unique texture identifier . Rendermodels which share the same texture will have the same id . <nl> + IDs < 0 denote the texture is not present * / <nl> + <nl> + typedef int32_t TextureID_t ; <nl> + <nl> + const TextureID_t INVALID_TEXTURE_ID = - 1 ; <nl> + <nl> + # if defined ( __linux__ ) | | defined ( __APPLE__ ) <nl> + / / This structure was originally defined mis - packed on Linux , preserved for <nl> + / / compatibility . <nl> + # pragma pack ( push , 4 ) <nl> + # endif <nl> + <nl> + struct RenderModel_t <nl> + { <nl> + const RenderModel_Vertex_t * rVertexData ; / / Vertex data for the mesh <nl> + uint32_t unVertexCount ; / / Number of vertices in the vertex data <nl> + const uint16_t * rIndexData ; / / Indices into the vertex data for each triangle <nl> + uint32_t unTriangleCount ; / / Number of triangles in the mesh . Index count is 3 * TriangleCount <nl> + TextureID_t diffuseTextureId ; / / Session unique texture identifier . Rendermodels which share the same texture will have the same id . < 0 = = texture not present <nl> + } ; <nl> + # if defined ( __linux__ ) | | defined ( __APPLE__ ) <nl> + # pragma pack ( pop ) <nl> + # endif <nl> + <nl> + <nl> + struct RenderModel_ControllerMode_State_t <nl> + { <nl> + bool bScrollWheelVisible ; / / is this controller currently set to be in a scroll wheel mode <nl> + } ; <nl> + <nl> + # pragma pack ( pop ) <nl> + <nl> + class IVRRenderModels <nl> + { <nl> + public : <nl> + <nl> + / * * Loads and returns a render model for use in the application . pchRenderModelName should be a render model name <nl> + * from the Prop_RenderModelName_String property or an absolute path name to a render model on disk . <nl> + * <nl> + * The resulting render model is valid until VR_Shutdown ( ) is called or until FreeRenderModel ( ) is called . When the <nl> + * application is finished with the render model it should call FreeRenderModel ( ) to free the memory associated <nl> + * with the model . <nl> + * <nl> + * The method returns VRRenderModelError_Loading while the render model is still being loaded . <nl> + * The method returns VRRenderModelError_None once loaded successfully , otherwise will return an error . * / <nl> + virtual EVRRenderModelError LoadRenderModel_Async ( const char * pchRenderModelName , RenderModel_t * * ppRenderModel ) = 0 ; <nl> + <nl> + / * * Frees a previously returned render model <nl> + * It is safe to call this on a null ptr . * / <nl> + virtual void FreeRenderModel ( RenderModel_t * pRenderModel ) = 0 ; <nl> + <nl> + / * * Loads and returns a texture for use in the application . * / <nl> + virtual EVRRenderModelError LoadTexture_Async ( TextureID_t textureId , RenderModel_TextureMap_t * * ppTexture ) = 0 ; <nl> + <nl> + / * * Frees a previously returned texture <nl> + * It is safe to call this on a null ptr . * / <nl> + virtual void FreeTexture ( RenderModel_TextureMap_t * pTexture ) = 0 ; <nl> + <nl> + / * * Creates a D3D11 texture and loads data into it . * / <nl> + virtual EVRRenderModelError LoadTextureD3D11_Async ( TextureID_t textureId , void * pD3D11Device , void * * ppD3D11Texture2D ) = 0 ; <nl> + <nl> + / * * Helper function to copy the bits into an existing texture . * / <nl> + virtual EVRRenderModelError LoadIntoTextureD3D11_Async ( TextureID_t textureId , void * pDstTexture ) = 0 ; <nl> + <nl> + / * * Use this to free textures created with LoadTextureD3D11_Async instead of calling Release on them . * / <nl> + virtual void FreeTextureD3D11 ( void * pD3D11Texture2D ) = 0 ; <nl> + <nl> + / * * Use this to get the names of available render models . Index does not correlate to a tracked device index , but <nl> + * is only used for iterating over all available render models . If the index is out of range , this function will return 0 . <nl> + * Otherwise , it will return the size of the buffer required for the name . * / <nl> + virtual uint32_t GetRenderModelName ( uint32_t unRenderModelIndex , VR_OUT_STRING ( ) char * pchRenderModelName , uint32_t unRenderModelNameLen ) = 0 ; <nl> + <nl> + / * * Returns the number of available render models . * / <nl> + virtual uint32_t GetRenderModelCount ( ) = 0 ; <nl> + <nl> + <nl> + / * * Returns the number of components of the specified render model . <nl> + * Components are useful when client application wish to draw , label , or otherwise interact with components of tracked objects . <nl> + * Examples controller components : <nl> + * renderable things such as triggers , buttons <nl> + * non - renderable things which include coordinate systems such as ' tip ' , ' base ' , a neutral controller agnostic hand - pose <nl> + * If all controller components are enumerated and rendered , it will be equivalent to drawing the traditional render model <nl> + * Returns 0 if components not supported , > 0 otherwise * / <nl> + virtual uint32_t GetComponentCount ( const char * pchRenderModelName ) = 0 ; <nl> + <nl> + / * * Use this to get the names of available components . Index does not correlate to a tracked device index , but <nl> + * is only used for iterating over all available components . If the index is out of range , this function will return 0 . <nl> + * Otherwise , it will return the size of the buffer required for the name . * / <nl> + virtual uint32_t GetComponentName ( const char * pchRenderModelName , uint32_t unComponentIndex , VR_OUT_STRING ( ) char * pchComponentName , uint32_t unComponentNameLen ) = 0 ; <nl> + <nl> + / * * Get the button mask for all buttons associated with this component <nl> + * If no buttons ( or axes ) are associated with this component , return 0 <nl> + * Note : multiple components may be associated with the same button . Ex : two grip buttons on a single controller . <nl> + * Note : A single component may be associated with multiple buttons . Ex : A trackpad which also provides " D - pad " functionality * / <nl> + virtual uint64_t GetComponentButtonMask ( const char * pchRenderModelName , const char * pchComponentName ) = 0 ; <nl> + <nl> + / * * Use this to get the render model name for the specified rendermode / component combination , to be passed to LoadRenderModel . <nl> + * If the component name is out of range , this function will return 0 . <nl> + * Otherwise , it will return the size of the buffer required for the name . * / <nl> + virtual uint32_t GetComponentRenderModelName ( const char * pchRenderModelName , const char * pchComponentName , VR_OUT_STRING ( ) char * pchComponentRenderModelName , uint32_t unComponentRenderModelNameLen ) = 0 ; <nl> + <nl> + / * * Use this to query information about the component , as a function of the controller state . <nl> + * <nl> + * For dynamic controller components ( ex : trigger ) values will reflect component motions <nl> + * For static components this will return a consistent value independent of the VRControllerState_t <nl> + * <nl> + * If the pchRenderModelName or pchComponentName is invalid , this will return false ( and transforms will be set to identity ) . <nl> + * Otherwise , return true <nl> + * Note : For dynamic objects , visibility may be dynamic . ( I . e . , true / false will be returned based on controller state and controller mode state ) * / <nl> + virtual bool GetComponentStateForDevicePath ( const char * pchRenderModelName , const char * pchComponentName , vr : : VRInputValueHandle_t devicePath , const vr : : RenderModel_ControllerMode_State_t * pState , vr : : RenderModel_ComponentState_t * pComponentState ) = 0 ; <nl> + <nl> + / * * This version of GetComponentState takes a controller state block instead of an action origin . This function is deprecated . You should use the new input system and GetComponentStateForDevicePath instead . * / <nl> + virtual bool GetComponentState ( const char * pchRenderModelName , const char * pchComponentName , const vr : : VRControllerState_t * pControllerState , const RenderModel_ControllerMode_State_t * pState , RenderModel_ComponentState_t * pComponentState ) = 0 ; <nl> + <nl> + / * * Returns true if the render model has a component with the specified name * / <nl> + virtual bool RenderModelHasComponent ( const char * pchRenderModelName , const char * pchComponentName ) = 0 ; <nl> + <nl> + / * * Returns the URL of the thumbnail image for this rendermodel * / <nl> + virtual uint32_t GetRenderModelThumbnailURL ( const char * pchRenderModelName , VR_OUT_STRING ( ) char * pchThumbnailURL , uint32_t unThumbnailURLLen , vr : : EVRRenderModelError * peError ) = 0 ; <nl> + <nl> + / * * Provides a render model path that will load the unskinned model if the model name provided has been replace by the user . If the model <nl> + * hasn ' t been replaced the path value will still be a valid path to load the model . Pass this to LoadRenderModel_Async , etc . to load the <nl> + * model . * / <nl> + virtual uint32_t GetRenderModelOriginalPath ( const char * pchRenderModelName , VR_OUT_STRING ( ) char * pchOriginalPath , uint32_t unOriginalPathLen , vr : : EVRRenderModelError * peError ) = 0 ; <nl> + <nl> + / * * Returns a string for a render model error * / <nl> + virtual const char * GetRenderModelErrorNameFromEnum ( vr : : EVRRenderModelError error ) = 0 ; <nl> + } ; <nl> + <nl> + static const char * const IVRRenderModels_Version = " IVRRenderModels_006 " ; <nl> + <nl> + } <nl> + <nl> + <nl> + / / ivrextendeddisplay . h <nl> + namespace vr <nl> + { <nl> + <nl> + / * * NOTE : Use of this interface is not recommended in production applications . It will not work for displays which use <nl> + * direct - to - display mode . Creating our own window is also incompatible with the VR compositor and is not available when the compositor is running . * / <nl> + class IVRExtendedDisplay <nl> + { <nl> + public : <nl> + <nl> + / * * Size and position that the window needs to be on the VR display . * / <nl> + virtual void GetWindowBounds ( int32_t * pnX , int32_t * pnY , uint32_t * pnWidth , uint32_t * pnHeight ) = 0 ; <nl> + <nl> + / * * Gets the viewport in the frame buffer to draw the output of the distortion into * / <nl> + virtual void GetEyeOutputViewport ( EVREye eEye , uint32_t * pnX , uint32_t * pnY , uint32_t * pnWidth , uint32_t * pnHeight ) = 0 ; <nl> + <nl> + / * * [ D3D10 / 11 Only ] <nl> + * Returns the adapter index and output index that the user should pass into EnumAdapters and EnumOutputs <nl> + * to create the device and swap chain in DX10 and DX11 . If an error occurs both indices will be set to - 1 . <nl> + * / <nl> + virtual void GetDXGIOutputInfo ( int32_t * pnAdapterIndex , int32_t * pnAdapterOutputIndex ) = 0 ; <nl> + <nl> + } ; <nl> + <nl> + static const char * const IVRExtendedDisplay_Version = " IVRExtendedDisplay_001 " ; <nl> + <nl> + } <nl> + <nl> + <nl> + / / ivrtrackedcamera . h <nl> + namespace vr <nl> + { <nl> + <nl> + class IVRTrackedCamera <nl> + { <nl> + public : <nl> + / * * Returns a string for an error * / <nl> + virtual const char * GetCameraErrorNameFromEnum ( vr : : EVRTrackedCameraError eCameraError ) = 0 ; <nl> + <nl> + / * * For convenience , same as tracked property request Prop_HasCamera_Bool * / <nl> + virtual vr : : EVRTrackedCameraError HasCamera ( vr : : TrackedDeviceIndex_t nDeviceIndex , bool * pHasCamera ) = 0 ; <nl> + <nl> + / * * Gets size of the image frame . * / <nl> + virtual vr : : EVRTrackedCameraError GetCameraFrameSize ( vr : : TrackedDeviceIndex_t nDeviceIndex , vr : : EVRTrackedCameraFrameType eFrameType , uint32_t * pnWidth , uint32_t * pnHeight , uint32_t * pnFrameBufferSize ) = 0 ; <nl> + <nl> + virtual vr : : EVRTrackedCameraError GetCameraIntrinsics ( vr : : TrackedDeviceIndex_t nDeviceIndex , uint32_t nCameraIndex , vr : : EVRTrackedCameraFrameType eFrameType , vr : : HmdVector2_t * pFocalLength , vr : : HmdVector2_t * pCenter ) = 0 ; <nl> + <nl> + virtual vr : : EVRTrackedCameraError GetCameraProjection ( vr : : TrackedDeviceIndex_t nDeviceIndex , uint32_t nCameraIndex , vr : : EVRTrackedCameraFrameType eFrameType , float flZNear , float flZFar , vr : : HmdMatrix44_t * pProjection ) = 0 ; <nl> + <nl> + / * * Acquiring streaming service permits video streaming for the caller . Releasing hints the system that video services do not need to be maintained for this client . <nl> + * If the camera has not already been activated , a one time spin up may incur some auto exposure as well as initial streaming frame delays . <nl> + * The camera should be considered a global resource accessible for shared consumption but not exclusive to any caller . <nl> + * The camera may go inactive due to lack of active consumers or headset idleness . * / <nl> + virtual vr : : EVRTrackedCameraError AcquireVideoStreamingService ( vr : : TrackedDeviceIndex_t nDeviceIndex , vr : : TrackedCameraHandle_t * pHandle ) = 0 ; <nl> + virtual vr : : EVRTrackedCameraError ReleaseVideoStreamingService ( vr : : TrackedCameraHandle_t hTrackedCamera ) = 0 ; <nl> + <nl> + / * * Copies the image frame into a caller ' s provided buffer . The image data is currently provided as RGBA data , 4 bytes per pixel . <nl> + * A caller can provide null for the framebuffer or frameheader if not desired . Requesting the frame header first , followed by the frame buffer allows <nl> + * the caller to determine if the frame as advanced per the frame header sequence . <nl> + * If there is no frame available yet , due to initial camera spinup or re - activation , the error will be VRTrackedCameraError_NoFrameAvailable . <nl> + * Ideally a caller should be polling at ~ 16ms intervals * / <nl> + virtual vr : : EVRTrackedCameraError GetVideoStreamFrameBuffer ( vr : : TrackedCameraHandle_t hTrackedCamera , vr : : EVRTrackedCameraFrameType eFrameType , void * pFrameBuffer , uint32_t nFrameBufferSize , vr : : CameraVideoStreamFrameHeader_t * pFrameHeader , uint32_t nFrameHeaderSize ) = 0 ; <nl> + <nl> + / * * Gets size of the image frame . * / <nl> + virtual vr : : EVRTrackedCameraError GetVideoStreamTextureSize ( vr : : TrackedDeviceIndex_t nDeviceIndex , vr : : EVRTrackedCameraFrameType eFrameType , vr : : VRTextureBounds_t * pTextureBounds , uint32_t * pnWidth , uint32_t * pnHeight ) = 0 ; <nl> + <nl> + / * * Access a shared D3D11 texture for the specified tracked camera stream . <nl> + * The camera frame type VRTrackedCameraFrameType_Undistorted is not supported directly as a shared texture . It is an interior subregion of the shared texture VRTrackedCameraFrameType_MaximumUndistorted . <nl> + * Instead , use GetVideoStreamTextureSize ( ) with VRTrackedCameraFrameType_Undistorted to determine the proper interior subregion bounds along with GetVideoStreamTextureD3D11 ( ) with <nl> + * VRTrackedCameraFrameType_MaximumUndistorted to provide the texture . The VRTrackedCameraFrameType_MaximumUndistorted will yield an image where the invalid regions are decoded <nl> + * by the alpha channel having a zero component . The valid regions all have a non - zero alpha component . The subregion as described by VRTrackedCameraFrameType_Undistorted <nl> + * guarantees a rectangle where all pixels are valid . * / <nl> + virtual vr : : EVRTrackedCameraError GetVideoStreamTextureD3D11 ( vr : : TrackedCameraHandle_t hTrackedCamera , vr : : EVRTrackedCameraFrameType eFrameType , void * pD3D11DeviceOrResource , void * * ppD3D11ShaderResourceView , vr : : CameraVideoStreamFrameHeader_t * pFrameHeader , uint32_t nFrameHeaderSize ) = 0 ; <nl> + <nl> + / * * Access a shared GL texture for the specified tracked camera stream * / <nl> + virtual vr : : EVRTrackedCameraError GetVideoStreamTextureGL ( vr : : TrackedCameraHandle_t hTrackedCamera , vr : : EVRTrackedCameraFrameType eFrameType , vr : : glUInt_t * pglTextureId , vr : : CameraVideoStreamFrameHeader_t * pFrameHeader , uint32_t nFrameHeaderSize ) = 0 ; <nl> + virtual vr : : EVRTrackedCameraError ReleaseVideoStreamTextureGL ( vr : : TrackedCameraHandle_t hTrackedCamera , vr : : glUInt_t glTextureId ) = 0 ; <nl> + virtual void SetCameraTrackingSpace ( vr : : ETrackingUniverseOrigin eUniverse ) = 0 ; <nl> + virtual vr : : ETrackingUniverseOrigin GetCameraTrackingSpace ( ) = 0 ; <nl> + } ; <nl> + <nl> + static const char * const IVRTrackedCamera_Version = " IVRTrackedCamera_006 " ; <nl> + <nl> + } / / namespace vr <nl> + <nl> + <nl> + / / ivrscreenshots . h <nl> + namespace vr <nl> + { <nl> + <nl> + / * * Errors that can occur with the VR compositor * / <nl> + enum EVRScreenshotError <nl> + { <nl> + VRScreenshotError_None = 0 , <nl> + VRScreenshotError_RequestFailed = 1 , <nl> + VRScreenshotError_IncompatibleVersion = 100 , <nl> + VRScreenshotError_NotFound = 101 , <nl> + VRScreenshotError_BufferTooSmall = 102 , <nl> + VRScreenshotError_ScreenshotAlreadyInProgress = 108 , <nl> + } ; <nl> + <nl> + / * * Allows the application to generate screenshots * / <nl> + class IVRScreenshots <nl> + { <nl> + public : <nl> + / * * Request a screenshot of the requested type . <nl> + * A request of the VRScreenshotType_Stereo type will always <nl> + * work . Other types will depend on the underlying application <nl> + * support . <nl> + * The first file name is for the preview image and should be a <nl> + * regular screenshot ( ideally from the left eye ) . The second <nl> + * is the VR screenshot in the correct format . They should be <nl> + * in the same aspect ratio . Formats per type : <nl> + * VRScreenshotType_Mono : the VR filename is ignored ( can be <nl> + * nullptr ) , this is a normal flat single shot . <nl> + * VRScreenshotType_Stereo : The VR image should be a <nl> + * side - by - side with the left eye image on the left . <nl> + * VRScreenshotType_Cubemap : The VR image should be six square <nl> + * images composited horizontally . <nl> + * VRScreenshotType_StereoPanorama : above / below with left eye <nl> + * panorama being the above image . Image is typically square <nl> + * with the panorama being 2x horizontal . <nl> + * <nl> + * Note that the VR dashboard will call this function when <nl> + * the user presses the screenshot binding ( currently System <nl> + * Button + Trigger ) . If Steam is running , the destination <nl> + * file names will be in % TEMP % and will be copied into <nl> + * Steam ' s screenshot library for the running application <nl> + * once SubmitScreenshot ( ) is called . <nl> + * If Steam is not running , the paths will be in the user ' s <nl> + * documents folder under Documents \ SteamVR \ Screenshots . <nl> + * Other VR applications can call this to initiate a <nl> + * screenshot outside of user control . <nl> + * The destination file names do not need an extension , <nl> + * will be replaced with the correct one for the format <nl> + * which is currently . png . * / <nl> + virtual vr : : EVRScreenshotError RequestScreenshot ( vr : : ScreenshotHandle_t * pOutScreenshotHandle , vr : : EVRScreenshotType type , const char * pchPreviewFilename , const char * pchVRFilename ) = 0 ; <nl> + <nl> + / * * Called by the running VR application to indicate that it <nl> + * wishes to be in charge of screenshots . If the <nl> + * application does not call this , the Compositor will only <nl> + * support VRScreenshotType_Stereo screenshots that will be <nl> + * captured without notification to the running app . <nl> + * Once hooked your application will receive a <nl> + * VREvent_RequestScreenshot event when the user presses the <nl> + * buttons to take a screenshot . * / <nl> + virtual vr : : EVRScreenshotError HookScreenshot ( VR_ARRAY_COUNT ( numTypes ) const vr : : EVRScreenshotType * pSupportedTypes , int numTypes ) = 0 ; <nl> + <nl> + / * * When your application receives a <nl> + * VREvent_RequestScreenshot event , call these functions to get <nl> + * the details of the screenshot request . * / <nl> + virtual vr : : EVRScreenshotType GetScreenshotPropertyType ( vr : : ScreenshotHandle_t screenshotHandle , vr : : EVRScreenshotError * pError ) = 0 ; <nl> + <nl> + / * * Get the filename for the preview or vr image ( see <nl> + * vr : : EScreenshotPropertyFilenames ) . The return value is <nl> + * the size of the string . * / <nl> + virtual uint32_t GetScreenshotPropertyFilename ( vr : : ScreenshotHandle_t screenshotHandle , vr : : EVRScreenshotPropertyFilenames filenameType , VR_OUT_STRING ( ) char * pchFilename , uint32_t cchFilename , vr : : EVRScreenshotError * pError ) = 0 ; <nl> + <nl> + / * * Call this if the application is taking the screen shot <nl> + * will take more than a few ms processing . This will result <nl> + * in an overlay being presented that shows a completion <nl> + * bar . * / <nl> + virtual vr : : EVRScreenshotError UpdateScreenshotProgress ( vr : : ScreenshotHandle_t screenshotHandle , float flProgress ) = 0 ; <nl> + <nl> + / * * Tells the compositor to take an internal screenshot of <nl> + * type VRScreenshotType_Stereo . It will take the current <nl> + * submitted scene textures of the running application and <nl> + * write them into the preview image and a side - by - side file <nl> + * for the VR image . <nl> + * This is similar to request screenshot , but doesn ' t ever <nl> + * talk to the application , just takes the shot and submits . * / <nl> + virtual vr : : EVRScreenshotError TakeStereoScreenshot ( vr : : ScreenshotHandle_t * pOutScreenshotHandle , const char * pchPreviewFilename , const char * pchVRFilename ) = 0 ; <nl> + <nl> + / * * Submit the completed screenshot . If Steam is running <nl> + * this will call into the Steam client and upload the <nl> + * screenshot to the screenshots section of the library for <nl> + * the running application . If Steam is not running , this <nl> + * function will display a notification to the user that the <nl> + * screenshot was taken . The paths should be full paths with <nl> + * extensions . <nl> + * File paths should be absolute including extensions . <nl> + * screenshotHandle can be k_unScreenshotHandleInvalid if this <nl> + * was a new shot taking by the app to be saved and not <nl> + * initiated by a user ( achievement earned or something ) * / <nl> + virtual vr : : EVRScreenshotError SubmitScreenshot ( vr : : ScreenshotHandle_t screenshotHandle , vr : : EVRScreenshotType type , const char * pchSourcePreviewFilename , const char * pchSourceVRFilename ) = 0 ; <nl> + } ; <nl> + <nl> + static const char * const IVRScreenshots_Version = " IVRScreenshots_001 " ; <nl> + <nl> + } / / namespace vr <nl> + <nl> + <nl> + <nl> + / / ivrresources . h <nl> + namespace vr <nl> + { <nl> + <nl> + class IVRResources <nl> + { <nl> + public : <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / Shared Resource Methods <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + <nl> + / * * Loads the specified resource into the provided buffer if large enough . <nl> + * Returns the size in bytes of the buffer required to hold the specified resource . * / <nl> + virtual uint32_t LoadSharedResource ( const char * pchResourceName , char * pchBuffer , uint32_t unBufferLen ) = 0 ; <nl> + <nl> + / * * Provides the full path to the specified resource . Resource names can include named directories for <nl> + * drivers and other things , and this resolves all of those and returns the actual physical path . <nl> + * pchResourceTypeDirectory is the subdirectory of resources to look in . * / <nl> + virtual uint32_t GetResourceFullPath ( const char * pchResourceName , const char * pchResourceTypeDirectory , VR_OUT_STRING ( ) char * pchPathBuffer , uint32_t unBufferLen ) = 0 ; <nl> + } ; <nl> + <nl> + static const char * const IVRResources_Version = " IVRResources_001 " ; <nl> + <nl> + <nl> + } <nl> + / / ivrdrivermanager . h <nl> + namespace vr <nl> + { <nl> + <nl> + class IVRDriverManager <nl> + { <nl> + public : <nl> + virtual uint32_t GetDriverCount ( ) const = 0 ; <nl> + <nl> + / * * Returns the length of the number of bytes necessary to hold this string including the trailing null . * / <nl> + virtual uint32_t GetDriverName ( vr : : DriverId_t nDriver , VR_OUT_STRING ( ) char * pchValue , uint32_t unBufferSize ) = 0 ; <nl> + <nl> + virtual DriverHandle_t GetDriverHandle ( const char * pchDriverName ) = 0 ; <nl> + <nl> + virtual bool IsEnabled ( vr : : DriverId_t nDriver ) const = 0 ; <nl> + } ; <nl> + <nl> + static const char * const IVRDriverManager_Version = " IVRDriverManager_001 " ; <nl> + <nl> + } / / namespace vr <nl> + <nl> + <nl> + <nl> + / / ivrinput . h <nl> + namespace vr <nl> + { <nl> + / / Maximum number of characters in an action name , including the trailing null <nl> + static const uint32_t k_unMaxActionNameLength = 64 ; <nl> + <nl> + / / Maximum number of characters in an action set name , including the trailing null <nl> + static const uint32_t k_unMaxActionSetNameLength = 64 ; <nl> + <nl> + / / Maximum number of origins for an action <nl> + static const uint32_t k_unMaxActionOriginCount = 16 ; <nl> + <nl> + / / Maximum number of characters in a bone name , including the trailing null <nl> + static const uint32_t k_unMaxBoneNameLength = 32 ; <nl> + <nl> + enum EVRSkeletalTransformSpace <nl> + { <nl> + VRSkeletalTransformSpace_Model = 0 , <nl> + VRSkeletalTransformSpace_Parent = 1 <nl> + } ; <nl> + <nl> + enum EVRSkeletalReferencePose <nl> + { <nl> + VRSkeletalReferencePose_BindPose = 0 , <nl> + VRSkeletalReferencePose_OpenHand , <nl> + VRSkeletalReferencePose_Fist , <nl> + VRSkeletalReferencePose_GripLimit <nl> + } ; <nl> + <nl> + enum EVRFinger <nl> + { <nl> + VRFinger_Thumb = 0 , <nl> + VRFinger_Index , <nl> + VRFinger_Middle , <nl> + VRFinger_Ring , <nl> + VRFinger_Pinky , <nl> + VRFinger_Count <nl> + } ; <nl> + <nl> + enum EVRFingerSplay <nl> + { <nl> + VRFingerSplay_Thumb_Index = 0 , <nl> + VRFingerSplay_Index_Middle , <nl> + VRFingerSplay_Middle_Ring , <nl> + VRFingerSplay_Ring_Pinky , <nl> + VRFingerSplay_Count <nl> + } ; <nl> + <nl> + enum EVRSummaryType <nl> + { <nl> + / / The skeletal summary data will match the animated bone transforms for the action . <nl> + VRSummaryType_FromAnimation = 0 , <nl> + <nl> + / / The skeletal summary data will include unprocessed data directly from the device when available . <nl> + / / This data is generally less latent than the data that is computed from the animations . <nl> + VRSummaryType_FromDevice = 1 , <nl> + } ; <nl> + <nl> + enum EVRInputFilterCancelType <nl> + { <nl> + VRInputFilterCancel_Timers = 0 , <nl> + VRInputFilterCancel_Momentum = 1 , <nl> + } ; <nl> + <nl> + enum EVRInputStringBits <nl> + { <nl> + VRInputString_Hand = 0x01 , <nl> + VRInputString_ControllerType = 0x02 , <nl> + VRInputString_InputSource = 0x04 , <nl> + <nl> + VRInputString_All = 0xFFFFFFFF <nl> + } ; <nl> + <nl> + struct InputAnalogActionData_t <nl> + { <nl> + / * * Whether or not this action is currently available to be bound in the active action set * / <nl> + bool bActive ; <nl> + <nl> + / * * The origin that caused this action ' s current state * / <nl> + VRInputValueHandle_t activeOrigin ; <nl> + <nl> + / * * The current state of this action ; will be delta updates for mouse actions * / <nl> + float x , y , z ; <nl> + <nl> + / * * Deltas since the previous call to UpdateActionState ( ) * / <nl> + float deltaX , deltaY , deltaZ ; <nl> + <nl> + / * * Time relative to now when this event happened . Will be negative to indicate a past time . * / <nl> + float fUpdateTime ; <nl> + } ; <nl> + <nl> + struct InputDigitalActionData_t <nl> + { <nl> + / * * Whether or not this action is currently available to be bound in the active action set * / <nl> + bool bActive ; <nl> + <nl> + / * * The origin that caused this action ' s current state * / <nl> + VRInputValueHandle_t activeOrigin ; <nl> + <nl> + / * * The current state of this action ; will be true if currently pressed * / <nl> + bool bState ; <nl> + <nl> + / * * This is true if the state has changed since the last frame * / <nl> + bool bChanged ; <nl> + <nl> + / * * Time relative to now when this event happened . Will be negative to indicate a past time . * / <nl> + float fUpdateTime ; <nl> + } ; <nl> + <nl> + struct InputPoseActionData_t <nl> + { <nl> + / * * Whether or not this action is currently available to be bound in the active action set * / <nl> + bool bActive ; <nl> + <nl> + / * * The origin that caused this action ' s current state * / <nl> + VRInputValueHandle_t activeOrigin ; <nl> + <nl> + / * * The current state of this action * / <nl> + TrackedDevicePose_t pose ; <nl> + } ; <nl> + <nl> + struct InputSkeletalActionData_t <nl> + { <nl> + / * * Whether or not this action is currently available to be bound in the active action set * / <nl> + bool bActive ; <nl> + <nl> + / * * The origin that caused this action ' s current state * / <nl> + VRInputValueHandle_t activeOrigin ; <nl> + } ; <nl> + <nl> + struct InputOriginInfo_t <nl> + { <nl> + VRInputValueHandle_t devicePath ; <nl> + TrackedDeviceIndex_t trackedDeviceIndex ; <nl> + char rchRenderModelComponentName [ 128 ] ; <nl> + } ; <nl> + <nl> + struct InputBindingInfo_t <nl> + { <nl> + char rchDevicePathName [ 128 ] ; <nl> + char rchInputPathName [ 128 ] ; <nl> + char rchModeName [ 128 ] ; <nl> + char rchSlotName [ 128 ] ; <nl> + char rchInputSourceType [ 32 ] ; <nl> + } ; <nl> + <nl> + / / * Experimental global action set priority * <nl> + / / These constants are part of the experimental support in SteamVR for overlay <nl> + / / apps selectively overriding input in the base scene application . This may be <nl> + / / useful for overlay applications that need to use part or all of a controller <nl> + / / without taking away all input to the game . This system must be enabled by the <nl> + / / " Experimental overlay input overrides " setting in the developer section of <nl> + / / SteamVR settings . <nl> + / / <nl> + / / To use this system , set the nPriority field of an action set to any number in <nl> + / / this range . <nl> + static const int32_t k_nActionSetOverlayGlobalPriorityMin = 0x01000000 ; <nl> + static const int32_t k_nActionSetOverlayGlobalPriorityMax = 0x01FFFFFF ; <nl> + <nl> + static const int32_t k_nActionSetPriorityReservedMin = 0x02000000 ; <nl> + <nl> + struct VRActiveActionSet_t <nl> + { <nl> + / * * This is the handle of the action set to activate for this frame . * / <nl> + VRActionSetHandle_t ulActionSet ; <nl> + <nl> + / * * This is the handle of a device path that this action set should be active for . To <nl> + * activate for all devices , set this to k_ulInvalidInputValueHandle . * / <nl> + VRInputValueHandle_t ulRestrictedToDevice ; <nl> + <nl> + / * * The action set to activate for all devices other than ulRestrictedDevice . If <nl> + * ulRestrictedToDevice is set to k_ulInvalidInputValueHandle , this parameter is <nl> + * ignored . * / <nl> + VRActionSetHandle_t ulSecondaryActionSet ; <nl> + <nl> + / / This field is ignored <nl> + uint32_t unPadding ; <nl> + <nl> + / * * The priority of this action set relative to other action sets . Any inputs <nl> + * bound to a source ( e . g . trackpad , joystick , trigger ) will disable bindings in <nl> + * other active action sets with a smaller priority . <nl> + * <nl> + * Overlay applications ( i . e . ApplicationType_Overlay ) may set their action set priority <nl> + * to a value between k_nActionSetOverlayGlobalPriorityMin and k_nActionSetOverlayGlobalPriorityMax <nl> + * to cause any inputs bound to a source used by that action set to be disabled in scene applications . <nl> + * <nl> + * No action set priority may value may be larger than k_nActionSetPriorityReservedMin <nl> + * / <nl> + int32_t nPriority ; <nl> + } ; <nl> + <nl> + / * * Contains summary information about the current skeletal pose * / <nl> + struct VRSkeletalSummaryData_t <nl> + { <nl> + / * * The amount that each finger is ' curled ' inwards towards the palm . In the case of the thumb , <nl> + * this represents how much the thumb is wrapped around the fist . <nl> + * 0 means straight , 1 means fully curled * / <nl> + float flFingerCurl [ VRFinger_Count ] ; <nl> + <nl> + / * * The amount that each pair of adjacent fingers are separated . <nl> + * 0 means the digits are touching , 1 means they are fully separated . <nl> + * / <nl> + float flFingerSplay [ VRFingerSplay_Count ] ; <nl> + } ; <nl> + <nl> + <nl> + class IVRInput <nl> + { <nl> + public : <nl> + <nl> + / / mmmmmmmmmmmmmmm Handle management mmmmmmmmmmmmmmm / / <nl> + <nl> + / * * Sets the path to the action manifest JSON file that is used by this application . If this information <nl> + * was set on the Steam partner site , calls to this function are ignored . If the Steam partner site <nl> + * setting and the path provided by this call are different , VRInputError_MismatchedActionManifest is returned . <nl> + * This call must be made before the first call to UpdateActionState or IVRSystem : : PollNextEvent . * / <nl> + virtual EVRInputError SetActionManifestPath ( const char * pchActionManifestPath ) = 0 ; <nl> + <nl> + / * * Returns a handle for an action set . This handle is used for all performance - sensitive calls . * / <nl> + virtual EVRInputError GetActionSetHandle ( const char * pchActionSetName , VRActionSetHandle_t * pHandle ) = 0 ; <nl> + <nl> + / * * Returns a handle for an action . This handle is used for all performance - sensitive calls . * / <nl> + virtual EVRInputError GetActionHandle ( const char * pchActionName , VRActionHandle_t * pHandle ) = 0 ; <nl> + <nl> + / * * Returns a handle for any path in the input system . E . g . / user / hand / right * / <nl> + virtual EVRInputError GetInputSourceHandle ( const char * pchInputSourcePath , VRInputValueHandle_t * pHandle ) = 0 ; <nl> + <nl> + <nl> + <nl> + / / mmmmmmmmmmmmmmm Reading action state mmmmmmmmmmmmmmmmmm - / / <nl> + <nl> + / * * Reads the current state into all actions . After this call , the results of Get * Action calls <nl> + * will be the same until the next call to UpdateActionState . * / <nl> + virtual EVRInputError UpdateActionState ( VR_ARRAY_COUNT ( unSetCount ) VRActiveActionSet_t * pSets , uint32_t unSizeOfVRSelectedActionSet_t , uint32_t unSetCount ) = 0 ; <nl> + <nl> + / * * Reads the state of a digital action given its handle . This will return VRInputError_WrongType if the type of <nl> + * action is something other than digital * / <nl> + virtual EVRInputError GetDigitalActionData ( VRActionHandle_t action , InputDigitalActionData_t * pActionData , uint32_t unActionDataSize , VRInputValueHandle_t ulRestrictToDevice ) = 0 ; <nl> + <nl> + / * * Reads the state of an analog action given its handle . This will return VRInputError_WrongType if the type of <nl> + * action is something other than analog * / <nl> + virtual EVRInputError GetAnalogActionData ( VRActionHandle_t action , InputAnalogActionData_t * pActionData , uint32_t unActionDataSize , VRInputValueHandle_t ulRestrictToDevice ) = 0 ; <nl> + <nl> + / * * Reads the state of a pose action given its handle for the number of seconds relative to now . This <nl> + * will generally be called with negative times from the fUpdateTime fields in other actions . * / <nl> + virtual EVRInputError GetPoseActionDataRelativeToNow ( VRActionHandle_t action , ETrackingUniverseOrigin eOrigin , float fPredictedSecondsFromNow , InputPoseActionData_t * pActionData , uint32_t unActionDataSize , VRInputValueHandle_t ulRestrictToDevice ) = 0 ; <nl> + <nl> + / * * Reads the state of a pose action given its handle . The returned values will match the values returned <nl> + * by the last call to IVRCompositor : : WaitGetPoses ( ) . * / <nl> + virtual EVRInputError GetPoseActionDataForNextFrame ( VRActionHandle_t action , ETrackingUniverseOrigin eOrigin , InputPoseActionData_t * pActionData , uint32_t unActionDataSize , VRInputValueHandle_t ulRestrictToDevice ) = 0 ; <nl> + <nl> + / * * Reads the state of a skeletal action given its handle . * / <nl> + virtual EVRInputError GetSkeletalActionData ( VRActionHandle_t action , InputSkeletalActionData_t * pActionData , uint32_t unActionDataSize ) = 0 ; <nl> + <nl> + / * * Returns the current dominant hand for the user for this application . This function will only return success for applications <nl> + * which include " supports_dominant_hand_setting " : true in their action manifests . The dominant hand will only change after <nl> + * a call to UpdateActionState , and the action data returned after that point will use the new dominant hand . * / <nl> + virtual EVRInputError GetDominantHand ( ETrackedControllerRole * peDominantHand ) = 0 ; <nl> + <nl> + / * * Sets the dominant hand for the user for this application . * / <nl> + virtual EVRInputError SetDominantHand ( ETrackedControllerRole eDominantHand ) = 0 ; <nl> + <nl> + / / mmmmmmmmmmmmmmm Static Skeletal Data mmmmmmmmmmmmmmmmmm - / / <nl> + <nl> + / * * Reads the number of bones in skeleton associated with the given action * / <nl> + virtual EVRInputError GetBoneCount ( VRActionHandle_t action , uint32_t * pBoneCount ) = 0 ; <nl> + <nl> + / * * Fills the given array with the index of each bone ' s parent in the skeleton associated with the given action * / <nl> + virtual EVRInputError GetBoneHierarchy ( VRActionHandle_t action , VR_ARRAY_COUNT ( unIndexArayCount ) BoneIndex_t * pParentIndices , uint32_t unIndexArayCount ) = 0 ; <nl> + <nl> + / * * Fills the given buffer with the name of the bone at the given index in the skeleton associated with the given action * / <nl> + virtual EVRInputError GetBoneName ( VRActionHandle_t action , BoneIndex_t nBoneIndex , VR_OUT_STRING ( ) char * pchBoneName , uint32_t unNameBufferSize ) = 0 ; <nl> + <nl> + / * * Fills the given buffer with the transforms for a specific static skeletal reference pose * / <nl> + virtual EVRInputError GetSkeletalReferenceTransforms ( VRActionHandle_t action , EVRSkeletalTransformSpace eTransformSpace , EVRSkeletalReferencePose eReferencePose , VR_ARRAY_COUNT ( unTransformArrayCount ) VRBoneTransform_t * pTransformArray , uint32_t unTransformArrayCount ) = 0 ; <nl> + <nl> + / * * Reads the level of accuracy to which the controller is able to track the user to recreate a skeletal pose * / <nl> + virtual EVRInputError GetSkeletalTrackingLevel ( VRActionHandle_t action , EVRSkeletalTrackingLevel * pSkeletalTrackingLevel ) = 0 ; <nl> + <nl> + / / mmmmmmmmmmmmmmm Dynamic Skeletal Data mmmmmmmmmmmmmmmmmm - / / <nl> + <nl> + / * * Reads the state of the skeletal bone data associated with this action and copies it into the given buffer . * / <nl> + virtual EVRInputError GetSkeletalBoneData ( VRActionHandle_t action , EVRSkeletalTransformSpace eTransformSpace , EVRSkeletalMotionRange eMotionRange , VR_ARRAY_COUNT ( unTransformArrayCount ) VRBoneTransform_t * pTransformArray , uint32_t unTransformArrayCount ) = 0 ; <nl> + <nl> + / * * Reads summary information about the current pose of the skeleton associated with the given action . * / <nl> + virtual EVRInputError GetSkeletalSummaryData ( VRActionHandle_t action , EVRSummaryType eSummaryType , VRSkeletalSummaryData_t * pSkeletalSummaryData ) = 0 ; <nl> + <nl> + / * * Reads the state of the skeletal bone data in a compressed form that is suitable for <nl> + * sending over the network . The required buffer size will never exceed ( sizeof ( VR_BoneTransform_t ) * boneCount + 2 ) . <nl> + * Usually the size will be much smaller . * / <nl> + virtual EVRInputError GetSkeletalBoneDataCompressed ( VRActionHandle_t action , EVRSkeletalMotionRange eMotionRange , VR_OUT_BUFFER_COUNT ( unCompressedSize ) void * pvCompressedData , uint32_t unCompressedSize , uint32_t * punRequiredCompressedSize ) = 0 ; <nl> + <nl> + / * * Turns a compressed buffer from GetSkeletalBoneDataCompressed and turns it back into a bone transform array . * / <nl> + virtual EVRInputError DecompressSkeletalBoneData ( const void * pvCompressedBuffer , uint32_t unCompressedBufferSize , EVRSkeletalTransformSpace eTransformSpace , VR_ARRAY_COUNT ( unTransformArrayCount ) VRBoneTransform_t * pTransformArray , uint32_t unTransformArrayCount ) = 0 ; <nl> + <nl> + / / mmmmmmmmmmmmmmm Haptics mmmmmmmmmmmmmmmmmm - / / <nl> + <nl> + / * * Triggers a haptic event as described by the specified action * / <nl> + virtual EVRInputError TriggerHapticVibrationAction ( VRActionHandle_t action , float fStartSecondsFromNow , float fDurationSeconds , float fFrequency , float fAmplitude , VRInputValueHandle_t ulRestrictToDevice ) = 0 ; <nl> + <nl> + / / mmmmmmmmmmmmmmm Action Origins mmmmmmmmmmmmmmm - / / <nl> + <nl> + / * * Retrieve origin handles for an action * / <nl> + virtual EVRInputError GetActionOrigins ( VRActionSetHandle_t actionSetHandle , VRActionHandle_t digitalActionHandle , VR_ARRAY_COUNT ( originOutCount ) VRInputValueHandle_t * originsOut , uint32_t originOutCount ) = 0 ; <nl> + <nl> + / * * Retrieves the name of the origin in the current language . unStringSectionsToInclude is a bitfield of values in EVRInputStringBits that allows the <nl> + application to specify which parts of the origin ' s information it wants a string for . * / <nl> + virtual EVRInputError GetOriginLocalizedName ( VRInputValueHandle_t origin , VR_OUT_STRING ( ) char * pchNameArray , uint32_t unNameArraySize , int32_t unStringSectionsToInclude ) = 0 ; <nl> + <nl> + / * * Retrieves useful information for the origin of this action * / <nl> + virtual EVRInputError GetOriginTrackedDeviceInfo ( VRInputValueHandle_t origin , InputOriginInfo_t * pOriginInfo , uint32_t unOriginInfoSize ) = 0 ; <nl> + <nl> + / * * Retrieves useful information about the bindings for an action * / <nl> + virtual EVRInputError GetActionBindingInfo ( VRActionHandle_t action , InputBindingInfo_t * pOriginInfo , uint32_t unBindingInfoSize , uint32_t unBindingInfoCount , uint32_t * punReturnedBindingInfoCount ) = 0 ; <nl> + <nl> + / * * Shows the current binding for the action in - headset * / <nl> + virtual EVRInputError ShowActionOrigins ( VRActionSetHandle_t actionSetHandle , VRActionHandle_t ulActionHandle ) = 0 ; <nl> + <nl> + / * * Shows the current binding all the actions in the specified action sets * / <nl> + virtual EVRInputError ShowBindingsForActionSet ( VR_ARRAY_COUNT ( unSetCount ) VRActiveActionSet_t * pSets , uint32_t unSizeOfVRSelectedActionSet_t , uint32_t unSetCount , VRInputValueHandle_t originToHighlight ) = 0 ; <nl> + <nl> + / * * Use this to query what action on the component returned by GetOriginTrackedDeviceInfo would trigger this binding . * / <nl> + virtual EVRInputError GetComponentStateForBinding ( const char * pchRenderModelName , const char * pchComponentName , <nl> + const InputBindingInfo_t * pOriginInfo , uint32_t unBindingInfoSize , uint32_t unBindingInfoCount , <nl> + vr : : RenderModel_ComponentState_t * pComponentState ) = 0 ; <nl> + <nl> + <nl> + / / mmmmmmmmmmmmmmm Legacy Input mmmmmmmmmmmmmmmmmm - / / <nl> + virtual bool IsUsingLegacyInput ( ) = 0 ; <nl> + <nl> + <nl> + / / mmmmmmmmmmmmmmm Utilities mmmmmmmmmmmmmmmmmm - / / <nl> + <nl> + / * * Opens the binding user interface . If no app key is provided it will use the key from the calling process . <nl> + * If no set is provided it will open to the root of the app binding page . * / <nl> + virtual EVRInputError OpenBindingUI ( const char * pchAppKey , VRActionSetHandle_t ulActionSetHandle , VRInputValueHandle_t ulDeviceHandle , bool bShowOnDesktop ) = 0 ; <nl> + <nl> + / * * Returns the variant set in the current bindings . If the binding doesn ' t include a variant setting , this function <nl> + * will return an empty string * / <nl> + virtual EVRInputError GetBindingVariant ( vr : : VRInputValueHandle_t ulDevicePath , <nl> + VR_OUT_STRING ( ) char * pchVariantArray , uint32_t unVariantArraySize ) = 0 ; <nl> + <nl> + } ; <nl> + <nl> + static const char * const IVRInput_Version = " IVRInput_010 " ; <nl> + <nl> + } / / namespace vr <nl> + <nl> + / / ivriobuffer . h <nl> + namespace vr <nl> + { <nl> + <nl> + typedef uint64_t IOBufferHandle_t ; <nl> + static const uint64_t k_ulInvalidIOBufferHandle = 0 ; <nl> + <nl> + enum EIOBufferError <nl> + { <nl> + IOBuffer_Success = 0 , <nl> + IOBuffer_OperationFailed = 100 , <nl> + IOBuffer_InvalidHandle = 101 , <nl> + IOBuffer_InvalidArgument = 102 , <nl> + IOBuffer_PathExists = 103 , <nl> + IOBuffer_PathDoesNotExist = 104 , <nl> + IOBuffer_Permission = 105 , <nl> + } ; <nl> + <nl> + enum EIOBufferMode <nl> + { <nl> + IOBufferMode_Read = 0x0001 , <nl> + IOBufferMode_Write = 0x0002 , <nl> + IOBufferMode_Create = 0x0200 , <nl> + } ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + / / Purpose : <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + class IVRIOBuffer <nl> + { <nl> + public : <nl> + / * * opens an existing or creates a new IOBuffer of unSize bytes * / <nl> + virtual vr : : EIOBufferError Open ( const char * pchPath , vr : : EIOBufferMode mode , uint32_t unElementSize , uint32_t unElements , vr : : IOBufferHandle_t * pulBuffer ) = 0 ; <nl> + <nl> + / * * closes a previously opened or created buffer * / <nl> + virtual vr : : EIOBufferError Close ( vr : : IOBufferHandle_t ulBuffer ) = 0 ; <nl> + <nl> + / * * reads up to unBytes from buffer into * pDst , returning number of bytes read in * punRead * / <nl> + virtual vr : : EIOBufferError Read ( vr : : IOBufferHandle_t ulBuffer , void * pDst , uint32_t unBytes , uint32_t * punRead ) = 0 ; <nl> + <nl> + / * * writes unBytes of data from * pSrc into a buffer . * / <nl> + virtual vr : : EIOBufferError Write ( vr : : IOBufferHandle_t ulBuffer , void * pSrc , uint32_t unBytes ) = 0 ; <nl> + <nl> + / * * retrieves the property container of an buffer . * / <nl> + virtual vr : : PropertyContainerHandle_t PropertyContainer ( vr : : IOBufferHandle_t ulBuffer ) = 0 ; <nl> + <nl> + / * * inexpensively checks for readers to allow writers to fast - fail potentially expensive copies and writes . * / <nl> + virtual bool HasReaders ( vr : : IOBufferHandle_t ulBuffer ) = 0 ; <nl> + } ; <nl> + <nl> + static const char * IVRIOBuffer_Version = " IVRIOBuffer_002 " ; <nl> + } <nl> + <nl> + / / ivrspatialanchors . h <nl> + namespace vr <nl> + { <nl> + static const SpatialAnchorHandle_t k_ulInvalidSpatialAnchorHandle = 0 ; <nl> + <nl> + struct SpatialAnchorPose_t <nl> + { <nl> + HmdMatrix34_t mAnchorToAbsoluteTracking ; <nl> + } ; <nl> + <nl> + class IVRSpatialAnchors <nl> + { <nl> + public : <nl> + <nl> + / * * Returns a handle for an spatial anchor described by " descriptor " . On success , pHandle <nl> + * will contain a handle valid for this session . Caller can wait for an event or occasionally <nl> + * poll GetSpatialAnchorPose ( ) to find the virtual coordinate associated with this anchor . * / <nl> + virtual EVRSpatialAnchorError CreateSpatialAnchorFromDescriptor ( const char * pchDescriptor , SpatialAnchorHandle_t * pHandleOut ) = 0 ; <nl> + <nl> + / * * Returns a handle for an new spatial anchor at pPose . On success , pHandle <nl> + * will contain a handle valid for this session . Caller can wait for an event or occasionally <nl> + * poll GetSpatialAnchorDescriptor ( ) to find the permanent descriptor for this pose . <nl> + * The result of GetSpatialAnchorPose ( ) may evolve from this initial position if the driver chooses <nl> + * to update it . <nl> + * The anchor will be associated with the driver that provides unDeviceIndex , and the driver may use that specific <nl> + * device as a hint for how to best create the anchor . <nl> + * The eOrigin must match whatever tracking origin you are working in ( seated / standing / raw ) . <nl> + * This should be called when the user is close to ( and ideally looking at / interacting with ) the target physical <nl> + * location . At that moment , the driver will have the most information about how to recover that physical point <nl> + * in the future , and the quality of the anchor ( when the descriptor is re - used ) will be highest . <nl> + * The caller may decide to apply offsets from this initial pose , but is advised to stay relatively close to the <nl> + * original pose location for highest fidelity . * / <nl> + virtual EVRSpatialAnchorError CreateSpatialAnchorFromPose ( TrackedDeviceIndex_t unDeviceIndex , ETrackingUniverseOrigin eOrigin , SpatialAnchorPose_t * pPose , SpatialAnchorHandle_t * pHandleOut ) = 0 ; <nl> + <nl> + / * * Get the pose for a given handle . This is intended to be cheap enough to call every frame ( or fairly often ) <nl> + * so that the driver can refine this position when it has more information available . * / <nl> + virtual EVRSpatialAnchorError GetSpatialAnchorPose ( SpatialAnchorHandle_t unHandle , ETrackingUniverseOrigin eOrigin , SpatialAnchorPose_t * pPoseOut ) = 0 ; <nl> + <nl> + / * * Get the descriptor for a given handle . This will be empty for handles where the driver has not <nl> + * yet built a descriptor . It will be the application - supplied descriptor for previously saved anchors <nl> + * that the application is requesting poses for . If the driver has called UpdateSpatialAnchorDescriptor ( ) <nl> + * already in this session , it will be the descriptor provided by the driver . <nl> + * Returns true if the descriptor fits into the buffer , else false . Buffer size should be at least <nl> + * k_unMaxSpatialAnchorDescriptorSize . * / <nl> + virtual EVRSpatialAnchorError GetSpatialAnchorDescriptor ( SpatialAnchorHandle_t unHandle , VR_OUT_STRING ( ) char * pchDescriptorOut , uint32_t * punDescriptorBufferLenInOut ) = 0 ; <nl> + <nl> + } ; <nl> + <nl> + static const char * const IVRSpatialAnchors_Version = " IVRSpatialAnchors_001 " ; <nl> + <nl> + } / / namespace vr <nl> + <nl> + / / ivrdebug . h <nl> + namespace vr <nl> + { <nl> + enum EVRDebugError <nl> + { <nl> + VRDebugError_Success = 0 , <nl> + VRDebugError_BadParameter <nl> + } ; <nl> + <nl> + / * * Handle for vr profiler events * / <nl> + typedef uint64_t VrProfilerEventHandle_t ; <nl> + <nl> + class IVRDebug <nl> + { <nl> + public : <nl> + <nl> + / * * Create a vr profiler discrete event ( point ) <nl> + * The event will be associated with the message provided in pchMessage , and the current <nl> + * time will be used as the event timestamp . * / <nl> + virtual EVRDebugError EmitVrProfilerEvent ( const char * pchMessage ) = 0 ; <nl> + <nl> + / * * Create an vr profiler duration event ( line ) <nl> + * The current time will be used as the timestamp for the start of the line . <nl> + * On success , pHandleOut will contain a handle valid for terminating this event . * / <nl> + virtual EVRDebugError BeginVrProfilerEvent ( VrProfilerEventHandle_t * pHandleOut ) = 0 ; <nl> + <nl> + / * * Terminate a vr profiler event <nl> + * The event associated with hHandle will be considered completed when this method is called . <nl> + * The current time will be used assocaited to the termination time of the event , and <nl> + * pchMessage will be used as the event title . * / <nl> + virtual EVRDebugError FinishVrProfilerEvent ( VrProfilerEventHandle_t hHandle , const char * pchMessage ) = 0 ; <nl> + <nl> + / * * Sends a request to the driver for the specified device and returns the response . The maximum response size is 32k , <nl> + * but this method can be called with a smaller buffer . If the response exceeds the size of the buffer , it is truncated . <nl> + * The size of the response including its terminating null is returned . * / <nl> + virtual uint32_t DriverDebugRequest ( vr : : TrackedDeviceIndex_t unDeviceIndex , const char * pchRequest , VR_OUT_STRING ( ) char * pchResponseBuffer , uint32_t unResponseBufferSize ) = 0 ; <nl> + <nl> + } ; <nl> + <nl> + static const char * const IVRDebug_Version = " IVRDebug_001 " ; <nl> + <nl> + } / / namespace vr <nl> + / / End <nl> + <nl> + # endif / / _OPENVR_API <nl> + <nl> + <nl> + <nl> + namespace vr <nl> + { <nl> + # if ! defined ( OPENVR_INTERFACE_INTERNAL ) <nl> + <nl> + / * * Finds the active installation of the VR API and initializes it . The provided path must be absolute <nl> + * or relative to the current working directory . These are the local install versions of the equivalent <nl> + * functions in steamvr . h and will work without a local Steam install . <nl> + * <nl> + * This path is to the " root " of the VR API install . That ' s the directory with <nl> + * the " drivers " directory and a platform ( i . e . " win32 " ) directory in it , not the directory with the DLL itself . <nl> + * <nl> + * pStartupInfo is reserved for future use . <nl> + * / <nl> + inline IVRSystem * VR_Init ( EVRInitError * peError , EVRApplicationType eApplicationType , const char * pStartupInfo = nullptr ) ; <nl> + <nl> + / * * unloads vrclient . dll . Any interface pointers from the interface are <nl> + * invalid after this point * / <nl> + inline void VR_Shutdown ( ) ; <nl> + <nl> + / * * Returns true if there is an HMD attached . This check is as lightweight as possible and <nl> + * can be called outside of VR_Init / VR_Shutdown . It should be used when an application wants <nl> + * to know if initializing VR is a possibility but isn ' t ready to take that step yet . <nl> + * / <nl> + VR_INTERFACE bool VR_CALLTYPE VR_IsHmdPresent ( ) ; <nl> + <nl> + / * * Returns true if the OpenVR runtime is installed . * / <nl> + VR_INTERFACE bool VR_CALLTYPE VR_IsRuntimeInstalled ( ) ; <nl> + <nl> + / * * Returns where the OpenVR runtime is installed . * / <nl> + VR_INTERFACE bool VR_GetRuntimePath ( VR_OUT_STRING ( ) char * pchPathBuffer , uint32_t unBufferSize , uint32_t * punRequiredBufferSize ) ; <nl> + <nl> + / * * Returns the name of the enum value for an EVRInitError . This function may be called outside of VR_Init ( ) / VR_Shutdown ( ) . * / <nl> + VR_INTERFACE const char * VR_CALLTYPE VR_GetVRInitErrorAsSymbol ( EVRInitError error ) ; <nl> + <nl> + / * * Returns an English string for an EVRInitError . Applications should call VR_GetVRInitErrorAsSymbol instead and <nl> + * use that as a key to look up their own localized error message . This function may be called outside of VR_Init ( ) / VR_Shutdown ( ) . * / <nl> + VR_INTERFACE const char * VR_CALLTYPE VR_GetVRInitErrorAsEnglishDescription ( EVRInitError error ) ; <nl> + <nl> + / * * Returns the interface of the specified version . This method must be called after VR_Init . The <nl> + * pointer returned is valid until VR_Shutdown is called . <nl> + * / <nl> + VR_INTERFACE void * VR_CALLTYPE VR_GetGenericInterface ( const char * pchInterfaceVersion , EVRInitError * peError ) ; <nl> + <nl> + / * * Returns whether the interface of the specified version exists . <nl> + * / <nl> + VR_INTERFACE bool VR_CALLTYPE VR_IsInterfaceVersionValid ( const char * pchInterfaceVersion ) ; <nl> + <nl> + / * * Returns a token that represents whether the VR interface handles need to be reloaded * / <nl> + VR_INTERFACE uint32_t VR_CALLTYPE VR_GetInitToken ( ) ; <nl> + <nl> + / / These typedefs allow old enum names from SDK 0 . 9 . 11 to be used in applications . <nl> + / / They will go away in the future . <nl> + typedef EVRInitError HmdError ; <nl> + typedef EVREye Hmd_Eye ; <nl> + typedef EColorSpace ColorSpace ; <nl> + typedef ETrackingResult HmdTrackingResult ; <nl> + typedef ETrackedDeviceClass TrackedDeviceClass ; <nl> + typedef ETrackingUniverseOrigin TrackingUniverseOrigin ; <nl> + typedef ETrackedDeviceProperty TrackedDeviceProperty ; <nl> + typedef ETrackedPropertyError TrackedPropertyError ; <nl> + typedef EVRSubmitFlags VRSubmitFlags_t ; <nl> + typedef EVRState VRState_t ; <nl> + typedef ECollisionBoundsStyle CollisionBoundsStyle_t ; <nl> + typedef EVROverlayError VROverlayError ; <nl> + typedef EVRFirmwareError VRFirmwareError ; <nl> + typedef EVRCompositorError VRCompositorError ; <nl> + typedef EVRScreenshotError VRScreenshotsError ; <nl> + <nl> + inline uint32_t & VRToken ( ) <nl> + { <nl> + static uint32_t token ; <nl> + return token ; <nl> + } <nl> + <nl> + class COpenVRContext <nl> + { <nl> + public : <nl> + COpenVRContext ( ) { Clear ( ) ; } <nl> + void Clear ( ) ; <nl> + <nl> + inline void CheckClear ( ) <nl> + { <nl> + if ( VRToken ( ) ! = VR_GetInitToken ( ) ) <nl> + { <nl> + Clear ( ) ; <nl> + VRToken ( ) = VR_GetInitToken ( ) ; <nl> + } <nl> + } <nl> + <nl> + IVRSystem * VRSystem ( ) <nl> + { <nl> + CheckClear ( ) ; <nl> + if ( m_pVRSystem = = nullptr ) <nl> + { <nl> + EVRInitError eError ; <nl> + m_pVRSystem = ( IVRSystem * ) VR_GetGenericInterface ( IVRSystem_Version , & eError ) ; <nl> + } <nl> + return m_pVRSystem ; <nl> + } <nl> + IVRChaperone * VRChaperone ( ) <nl> + { <nl> + CheckClear ( ) ; <nl> + if ( m_pVRChaperone = = nullptr ) <nl> + { <nl> + EVRInitError eError ; <nl> + m_pVRChaperone = ( IVRChaperone * ) VR_GetGenericInterface ( IVRChaperone_Version , & eError ) ; <nl> + } <nl> + return m_pVRChaperone ; <nl> + } <nl> + <nl> + IVRChaperoneSetup * VRChaperoneSetup ( ) <nl> + { <nl> + CheckClear ( ) ; <nl> + if ( m_pVRChaperoneSetup = = nullptr ) <nl> + { <nl> + EVRInitError eError ; <nl> + m_pVRChaperoneSetup = ( IVRChaperoneSetup * ) VR_GetGenericInterface ( IVRChaperoneSetup_Version , & eError ) ; <nl> + } <nl> + return m_pVRChaperoneSetup ; <nl> + } <nl> + <nl> + IVRCompositor * VRCompositor ( ) <nl> + { <nl> + CheckClear ( ) ; <nl> + if ( m_pVRCompositor = = nullptr ) <nl> + { <nl> + EVRInitError eError ; <nl> + m_pVRCompositor = ( IVRCompositor * ) VR_GetGenericInterface ( IVRCompositor_Version , & eError ) ; <nl> + } <nl> + return m_pVRCompositor ; <nl> + } <nl> + <nl> + IVROverlay * VROverlay ( ) <nl> + { <nl> + CheckClear ( ) ; <nl> + if ( m_pVROverlay = = nullptr ) <nl> + { <nl> + EVRInitError eError ; <nl> + m_pVROverlay = ( IVROverlay * ) VR_GetGenericInterface ( IVROverlay_Version , & eError ) ; <nl> + } <nl> + return m_pVROverlay ; <nl> + } <nl> + <nl> + IVROverlayView * VROverlayView ( ) <nl> + { <nl> + CheckClear ( ) ; <nl> + if ( m_pVROverlayView = = nullptr ) <nl> + { <nl> + EVRInitError eError ; <nl> + m_pVROverlayView = ( IVROverlayView * ) VR_GetGenericInterface ( IVROverlayView_Version , & eError ) ; <nl> + } <nl> + return m_pVROverlayView ; <nl> + } <nl> + <nl> + IVRHeadsetView * VRHeadsetView ( ) <nl> + { <nl> + CheckClear ( ) ; <nl> + if ( m_pVRHeadsetView = = nullptr ) <nl> + { <nl> + EVRInitError eError ; <nl> + m_pVRHeadsetView = ( IVRHeadsetView * ) VR_GetGenericInterface ( IVRHeadsetView_Version , & eError ) ; <nl> + } <nl> + return m_pVRHeadsetView ; <nl> + } <nl> + <nl> + IVRResources * VRResources ( ) <nl> + { <nl> + CheckClear ( ) ; <nl> + if ( m_pVRResources = = nullptr ) <nl> + { <nl> + EVRInitError eError ; <nl> + m_pVRResources = ( IVRResources * ) VR_GetGenericInterface ( IVRResources_Version , & eError ) ; <nl> + } <nl> + return m_pVRResources ; <nl> + } <nl> + <nl> + IVRScreenshots * VRScreenshots ( ) <nl> + { <nl> + CheckClear ( ) ; <nl> + if ( m_pVRScreenshots = = nullptr ) <nl> + { <nl> + EVRInitError eError ; <nl> + m_pVRScreenshots = ( IVRScreenshots * ) VR_GetGenericInterface ( IVRScreenshots_Version , & eError ) ; <nl> + } <nl> + return m_pVRScreenshots ; <nl> + } <nl> + <nl> + IVRRenderModels * VRRenderModels ( ) <nl> + { <nl> + CheckClear ( ) ; <nl> + if ( m_pVRRenderModels = = nullptr ) <nl> + { <nl> + EVRInitError eError ; <nl> + m_pVRRenderModels = ( IVRRenderModels * ) VR_GetGenericInterface ( IVRRenderModels_Version , & eError ) ; <nl> + } <nl> + return m_pVRRenderModels ; <nl> + } <nl> + <nl> + IVRExtendedDisplay * VRExtendedDisplay ( ) <nl> + { <nl> + CheckClear ( ) ; <nl> + if ( m_pVRExtendedDisplay = = nullptr ) <nl> + { <nl> + EVRInitError eError ; <nl> + m_pVRExtendedDisplay = ( IVRExtendedDisplay * ) VR_GetGenericInterface ( IVRExtendedDisplay_Version , & eError ) ; <nl> + } <nl> + return m_pVRExtendedDisplay ; <nl> + } <nl> + <nl> + IVRSettings * VRSettings ( ) <nl> + { <nl> + CheckClear ( ) ; <nl> + if ( m_pVRSettings = = nullptr ) <nl> + { <nl> + EVRInitError eError ; <nl> + m_pVRSettings = ( IVRSettings * ) VR_GetGenericInterface ( IVRSettings_Version , & eError ) ; <nl> + } <nl> + return m_pVRSettings ; <nl> + } <nl> + <nl> + IVRApplications * VRApplications ( ) <nl> + { <nl> + CheckClear ( ) ; <nl> + if ( m_pVRApplications = = nullptr ) <nl> + { <nl> + EVRInitError eError ; <nl> + m_pVRApplications = ( IVRApplications * ) VR_GetGenericInterface ( IVRApplications_Version , & eError ) ; <nl> + } <nl> + return m_pVRApplications ; <nl> + } <nl> + <nl> + IVRTrackedCamera * VRTrackedCamera ( ) <nl> + { <nl> + CheckClear ( ) ; <nl> + if ( m_pVRTrackedCamera = = nullptr ) <nl> + { <nl> + EVRInitError eError ; <nl> + m_pVRTrackedCamera = ( IVRTrackedCamera * ) VR_GetGenericInterface ( IVRTrackedCamera_Version , & eError ) ; <nl> + } <nl> + return m_pVRTrackedCamera ; <nl> + } <nl> + <nl> + IVRDriverManager * VRDriverManager ( ) <nl> + { <nl> + CheckClear ( ) ; <nl> + if ( ! m_pVRDriverManager ) <nl> + { <nl> + EVRInitError eError ; <nl> + m_pVRDriverManager = ( IVRDriverManager * ) VR_GetGenericInterface ( IVRDriverManager_Version , & eError ) ; <nl> + } <nl> + return m_pVRDriverManager ; <nl> + } <nl> + <nl> + IVRInput * VRInput ( ) <nl> + { <nl> + CheckClear ( ) ; <nl> + if ( ! m_pVRInput ) <nl> + { <nl> + EVRInitError eError ; <nl> + m_pVRInput = ( IVRInput * ) VR_GetGenericInterface ( IVRInput_Version , & eError ) ; <nl> + } <nl> + return m_pVRInput ; <nl> + } <nl> + <nl> + IVRIOBuffer * VRIOBuffer ( ) <nl> + { <nl> + if ( ! m_pVRIOBuffer ) <nl> + { <nl> + EVRInitError eError ; <nl> + m_pVRIOBuffer = ( IVRIOBuffer * ) VR_GetGenericInterface ( IVRIOBuffer_Version , & eError ) ; <nl> + } <nl> + return m_pVRIOBuffer ; <nl> + } <nl> + <nl> + IVRSpatialAnchors * VRSpatialAnchors ( ) <nl> + { <nl> + CheckClear ( ) ; <nl> + if ( ! m_pVRSpatialAnchors ) <nl> + { <nl> + EVRInitError eError ; <nl> + m_pVRSpatialAnchors = ( IVRSpatialAnchors * ) VR_GetGenericInterface ( IVRSpatialAnchors_Version , & eError ) ; <nl> + } <nl> + return m_pVRSpatialAnchors ; <nl> + } <nl> + <nl> + IVRDebug * VRDebug ( ) <nl> + { <nl> + CheckClear ( ) ; <nl> + if ( ! m_pVRDebug ) <nl> + { <nl> + EVRInitError eError ; <nl> + m_pVRDebug = ( IVRDebug * ) VR_GetGenericInterface ( IVRDebug_Version , & eError ) ; <nl> + } <nl> + return m_pVRDebug ; <nl> + } <nl> + <nl> + IVRNotifications * VRNotifications ( ) <nl> + { <nl> + CheckClear ( ) ; <nl> + if ( ! m_pVRNotifications ) <nl> + { <nl> + EVRInitError eError ; <nl> + m_pVRNotifications = ( IVRNotifications * ) VR_GetGenericInterface ( IVRNotifications_Version , & eError ) ; <nl> + } <nl> + return m_pVRNotifications ; <nl> + } <nl> + <nl> + private : <nl> + IVRSystem * m_pVRSystem ; <nl> + IVRChaperone * m_pVRChaperone ; <nl> + IVRChaperoneSetup * m_pVRChaperoneSetup ; <nl> + IVRCompositor * m_pVRCompositor ; <nl> + IVRHeadsetView * m_pVRHeadsetView ; <nl> + IVROverlay * m_pVROverlay ; <nl> + IVROverlayView * m_pVROverlayView ; <nl> + IVRResources * m_pVRResources ; <nl> + IVRRenderModels * m_pVRRenderModels ; <nl> + IVRExtendedDisplay * m_pVRExtendedDisplay ; <nl> + IVRSettings * m_pVRSettings ; <nl> + IVRApplications * m_pVRApplications ; <nl> + IVRTrackedCamera * m_pVRTrackedCamera ; <nl> + IVRScreenshots * m_pVRScreenshots ; <nl> + IVRDriverManager * m_pVRDriverManager ; <nl> + IVRInput * m_pVRInput ; <nl> + IVRIOBuffer * m_pVRIOBuffer ; <nl> + IVRSpatialAnchors * m_pVRSpatialAnchors ; <nl> + IVRDebug * m_pVRDebug ; <nl> + IVRNotifications * m_pVRNotifications ; <nl> + } ; <nl> + <nl> + inline COpenVRContext & OpenVRInternal_ModuleContext ( ) <nl> + { <nl> + static void * ctx [ sizeof ( COpenVRContext ) / sizeof ( void * ) ] ; <nl> + return * ( COpenVRContext * ) ctx ; / / bypass zero - init constructor <nl> + } <nl> + <nl> + inline IVRSystem * VR_CALLTYPE VRSystem ( ) { return OpenVRInternal_ModuleContext ( ) . VRSystem ( ) ; } <nl> + inline IVRChaperone * VR_CALLTYPE VRChaperone ( ) { return OpenVRInternal_ModuleContext ( ) . VRChaperone ( ) ; } <nl> + inline IVRChaperoneSetup * VR_CALLTYPE VRChaperoneSetup ( ) { return OpenVRInternal_ModuleContext ( ) . VRChaperoneSetup ( ) ; } <nl> + inline IVRCompositor * VR_CALLTYPE VRCompositor ( ) { return OpenVRInternal_ModuleContext ( ) . VRCompositor ( ) ; } <nl> + inline IVROverlay * VR_CALLTYPE VROverlay ( ) { return OpenVRInternal_ModuleContext ( ) . VROverlay ( ) ; } <nl> + inline IVROverlayView * VR_CALLTYPE VROverlayView ( ) { return OpenVRInternal_ModuleContext ( ) . VROverlayView ( ) ; } <nl> + inline IVRHeadsetView * VR_CALLTYPE VRHeadsetView ( ) { return OpenVRInternal_ModuleContext ( ) . VRHeadsetView ( ) ; } <nl> + inline IVRScreenshots * VR_CALLTYPE VRScreenshots ( ) { return OpenVRInternal_ModuleContext ( ) . VRScreenshots ( ) ; } <nl> + inline IVRRenderModels * VR_CALLTYPE VRRenderModels ( ) { return OpenVRInternal_ModuleContext ( ) . VRRenderModels ( ) ; } <nl> + inline IVRApplications * VR_CALLTYPE VRApplications ( ) { return OpenVRInternal_ModuleContext ( ) . VRApplications ( ) ; } <nl> + inline IVRSettings * VR_CALLTYPE VRSettings ( ) { return OpenVRInternal_ModuleContext ( ) . VRSettings ( ) ; } <nl> + inline IVRResources * VR_CALLTYPE VRResources ( ) { return OpenVRInternal_ModuleContext ( ) . VRResources ( ) ; } <nl> + inline IVRExtendedDisplay * VR_CALLTYPE VRExtendedDisplay ( ) { return OpenVRInternal_ModuleContext ( ) . VRExtendedDisplay ( ) ; } <nl> + inline IVRTrackedCamera * VR_CALLTYPE VRTrackedCamera ( ) { return OpenVRInternal_ModuleContext ( ) . VRTrackedCamera ( ) ; } <nl> + inline IVRDriverManager * VR_CALLTYPE VRDriverManager ( ) { return OpenVRInternal_ModuleContext ( ) . VRDriverManager ( ) ; } <nl> + inline IVRInput * VR_CALLTYPE VRInput ( ) { return OpenVRInternal_ModuleContext ( ) . VRInput ( ) ; } <nl> + inline IVRIOBuffer * VR_CALLTYPE VRIOBuffer ( ) { return OpenVRInternal_ModuleContext ( ) . VRIOBuffer ( ) ; } <nl> + inline IVRSpatialAnchors * VR_CALLTYPE VRSpatialAnchors ( ) { return OpenVRInternal_ModuleContext ( ) . VRSpatialAnchors ( ) ; } <nl> + inline IVRNotifications * VR_CALLTYPE VRNotifications ( ) { return OpenVRInternal_ModuleContext ( ) . VRNotifications ( ) ; } <nl> + inline IVRDebug * VR_CALLTYPE VRDebug ( ) { return OpenVRInternal_ModuleContext ( ) . VRDebug ( ) ; } <nl> + <nl> + inline void COpenVRContext : : Clear ( ) <nl> + { <nl> + m_pVRSystem = nullptr ; <nl> + m_pVRChaperone = nullptr ; <nl> + m_pVRChaperoneSetup = nullptr ; <nl> + m_pVRCompositor = nullptr ; <nl> + m_pVROverlay = nullptr ; <nl> + m_pVROverlayView = nullptr ; <nl> + m_pVRHeadsetView = nullptr ; <nl> + m_pVRRenderModels = nullptr ; <nl> + m_pVRExtendedDisplay = nullptr ; <nl> + m_pVRSettings = nullptr ; <nl> + m_pVRApplications = nullptr ; <nl> + m_pVRTrackedCamera = nullptr ; <nl> + m_pVRResources = nullptr ; <nl> + m_pVRScreenshots = nullptr ; <nl> + m_pVRDriverManager = nullptr ; <nl> + m_pVRInput = nullptr ; <nl> + m_pVRIOBuffer = nullptr ; <nl> + m_pVRSpatialAnchors = nullptr ; <nl> + m_pVRNotifications = nullptr ; <nl> + m_pVRDebug = nullptr ; <nl> + } <nl> + <nl> + VR_INTERFACE uint32_t VR_CALLTYPE VR_InitInternal2 ( EVRInitError * peError , EVRApplicationType eApplicationType , const char * pStartupInfo ) ; <nl> + VR_INTERFACE void VR_CALLTYPE VR_ShutdownInternal ( ) ; <nl> + <nl> + / * * Finds the active installation of vrclient . dll and initializes it * / <nl> + inline IVRSystem * VR_Init ( EVRInitError * peError , EVRApplicationType eApplicationType , const char * pStartupInfo ) <nl> + { <nl> + IVRSystem * pVRSystem = nullptr ; <nl> + <nl> + EVRInitError eError ; <nl> + VRToken ( ) = VR_InitInternal2 ( & eError , eApplicationType , pStartupInfo ) ; <nl> + COpenVRContext & ctx = OpenVRInternal_ModuleContext ( ) ; <nl> + ctx . Clear ( ) ; <nl> + <nl> + if ( eError = = VRInitError_None ) <nl> + { <nl> + if ( VR_IsInterfaceVersionValid ( IVRSystem_Version ) ) <nl> + { <nl> + pVRSystem = VRSystem ( ) ; <nl> + } <nl> + else <nl> + { <nl> + VR_ShutdownInternal ( ) ; <nl> + eError = VRInitError_Init_InterfaceNotFound ; <nl> + } <nl> + } <nl> + <nl> + if ( peError ) <nl> + * peError = eError ; <nl> + return pVRSystem ; <nl> + } <nl> + <nl> + / * * unloads vrclient . dll . Any interface pointers from the interface are <nl> + * invalid after this point * / <nl> + inline void VR_Shutdown ( ) <nl> + { <nl> + VR_ShutdownInternal ( ) ; <nl> + } <nl> + <nl> + # endif / / OPENVR_INTERFACE_INTERNAL <nl> + } <nl>
vrclient : Import openvr v1 . 12 . 5
ValveSoftware/Proton
8ae9804ee27b602f32a0a841fe6989c7df91ad10
2020-09-29T19:29:06Z
mmm a / tensorflow / core / platform / cloud / file_block_cache . cc <nl> ppp b / tensorflow / core / platform / cloud / file_block_cache . cc <nl> Status FileBlockCache : : Read ( const string & filename , size_t offset , size_t n , <nl> / / Record the block timestamp , update the cache size , and add the block to <nl> / / the cache . <nl> block - > timestamp = env_ - > NowSeconds ( ) ; <nl> + lra_list_ . push_front ( key ) ; <nl> + block - > lra_iterator = lra_list_ . begin ( ) ; <nl> cache_size_ + = block - > data . size ( ) ; <nl> entry = block_map_ . emplace ( std : : make_pair ( key , std : : move ( block ) ) ) . first ; <nl> } else { <nl> Status FileBlockCache : : Read ( const string & filename , size_t offset , size_t n , <nl> return Status : : OK ( ) ; <nl> } <nl> <nl> + size_t FileBlockCache : : CacheSize ( ) const { <nl> + mutex_lock lock ( mu_ ) ; <nl> + return cache_size_ ; <nl> + } <nl> + <nl> + void FileBlockCache : : Prune ( ) { <nl> + while ( ! WaitForNotificationWithTimeout ( & stop_pruning_thread_ , 1000000 ) ) { <nl> + mutex_lock lock ( mu_ ) ; <nl> + uint64 now = env_ - > NowSeconds ( ) ; <nl> + while ( ! lra_list_ . empty ( ) ) { <nl> + auto it = block_map_ . find ( lra_list_ . back ( ) ) ; <nl> + if ( now - it - > second - > timestamp < = max_staleness_ ) { <nl> + / / The oldest block is not yet expired . Come back later . <nl> + break ; <nl> + } <nl> + / / We need to make a copy of the filename here , since it could otherwise <nl> + / / be used within RemoveFile_Locked after ` it ` is deleted . <nl> + RemoveFile_Locked ( std : : string ( it - > first . first ) ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> void FileBlockCache : : RemoveFile ( const string & filename ) { <nl> mutex_lock lock ( mu_ ) ; <nl> RemoveFile_Locked ( filename ) ; <nl> void FileBlockCache : : RemoveFile_Locked ( const string & filename ) { <nl> <nl> void FileBlockCache : : RemoveBlock ( BlockMap : : iterator entry ) { <nl> lru_list_ . erase ( entry - > second - > lru_iterator ) ; <nl> + lra_list_ . erase ( entry - > second - > lra_iterator ) ; <nl> cache_size_ - = entry - > second - > data . size ( ) ; <nl> block_map_ . erase ( entry ) ; <nl> } <nl> mmm a / tensorflow / core / platform / cloud / file_block_cache . h <nl> ppp b / tensorflow / core / platform / cloud / file_block_cache . h <nl> limitations under the License . <nl> # include " tensorflow / core / lib / core / stringpiece . h " <nl> # include " tensorflow / core / platform / env . h " <nl> # include " tensorflow / core / platform / mutex . h " <nl> + # include " tensorflow / core / platform / notification . h " <nl> # include " tensorflow / core / platform / thread_annotations . h " <nl> # include " tensorflow / core / platform / types . h " <nl> <nl> class FileBlockCache { <nl> max_bytes_ ( max_bytes ) , <nl> max_staleness_ ( max_staleness ) , <nl> block_fetcher_ ( block_fetcher ) , <nl> - env_ ( env ) { } <nl> + env_ ( env ) { <nl> + if ( max_staleness_ > 0 ) { <nl> + pruning_thread_ . reset ( env_ - > StartThread ( ThreadOptions ( ) , " TF_prune_FBC " , <nl> + [ this ] { Prune ( ) ; } ) ) ; <nl> + } <nl> + } <nl> + <nl> + ~ FileBlockCache ( ) { <nl> + if ( pruning_thread_ ) { <nl> + stop_pruning_thread_ . Notify ( ) ; <nl> + / / Destroying pruning_thread_ will block until Prune ( ) receives the above <nl> + / / notification and returns . <nl> + pruning_thread_ . reset ( ) ; <nl> + } <nl> + } <nl> <nl> / / / Read ` n ` bytes from ` filename ` starting at ` offset ` into ` out ` . This <nl> / / / method will return : <nl> class FileBlockCache { <nl> size_t max_bytes ( ) const { return max_bytes_ ; } <nl> uint64 max_staleness ( ) const { return max_staleness_ ; } <nl> <nl> + / / / The current size ( in bytes ) of the cache . <nl> + size_t CacheSize ( ) const LOCKS_EXCLUDED ( mu_ ) ; <nl> + <nl> private : <nl> / / / The size of the blocks stored in the LRU cache , as well as the size of the <nl> / / / reads from the underlying filesystem . <nl> class FileBlockCache { <nl> std : : vector < char > data ; <nl> / / / A list iterator pointing to the block ' s position in the LRU list . <nl> std : : list < Key > : : iterator lru_iterator ; <nl> + / / / A list iterator pointing to the block ' s position in the LRA list . <nl> + std : : list < Key > : : iterator lra_iterator ; <nl> / / / The timestamp ( seconds since epoch ) at which the block was cached . <nl> uint64 timestamp ; <nl> } ; <nl> class FileBlockCache { <nl> / / / The block map is an ordered map from Key to Block . <nl> typedef std : : map < Key , std : : unique_ptr < Block > > BlockMap ; <nl> <nl> + / / / Prune the cache by removing files with expired blocks . <nl> + void Prune ( ) LOCKS_EXCLUDED ( mu_ ) ; <nl> + <nl> / / / Remove all blocks of a file , with mu_ already held . <nl> void RemoveFile_Locked ( const string & filename ) EXCLUSIVE_LOCKS_REQUIRED ( mu_ ) ; <nl> <nl> class FileBlockCache { <nl> / / / cache size accordingly . <nl> void RemoveBlock ( BlockMap : : iterator entry ) EXCLUSIVE_LOCKS_REQUIRED ( mu_ ) ; <nl> <nl> + / / / The cache pruning thread that removes files with expired blocks . <nl> + std : : unique_ptr < Thread > pruning_thread_ ; <nl> + <nl> + / / / Notification for stopping the cache pruning thread . <nl> + Notification stop_pruning_thread_ ; <nl> + <nl> / / / Guards access to the block map , LRU list , and cached byte count . <nl> - mutex mu_ ; <nl> + mutable mutex mu_ ; <nl> <nl> / / / The block map ( map from Key to Block ) . <nl> BlockMap block_map_ GUARDED_BY ( mu_ ) ; <nl> class FileBlockCache { <nl> / / / recently accessed block . <nl> std : : list < Key > lru_list_ GUARDED_BY ( mu_ ) ; <nl> <nl> + / / / The LRA ( least recently added ) list of block keys . The front of the list <nl> + / / / identifies the most recently added block . <nl> + std : : list < Key > lra_list_ GUARDED_BY ( mu_ ) ; <nl> + <nl> / / / The combined number of bytes in all of the cached blocks . <nl> size_t cache_size_ GUARDED_BY ( mu_ ) = 0 ; <nl> } ; <nl> mmm a / tensorflow / core / platform / cloud / file_block_cache_test . cc <nl> ppp b / tensorflow / core / platform / cloud / file_block_cache_test . cc <nl> limitations under the License . <nl> namespace tensorflow { <nl> namespace { <nl> <nl> + / / This Env wrapper lets us control the NowSeconds ( ) return value . <nl> + class FakeEnv : public EnvWrapper { <nl> + public : <nl> + FakeEnv ( ) : EnvWrapper ( Env : : Default ( ) ) { } <nl> + <nl> + uint64 NowSeconds ( ) override { <nl> + mutex_lock lock ( mu_ ) ; <nl> + return now_ ; <nl> + } <nl> + <nl> + void SetNowSeconds ( uint64 now ) { <nl> + mutex_lock lock ( mu_ ) ; <nl> + now_ = now ; <nl> + } <nl> + <nl> + mutex mu_ ; <nl> + uint64 now_ = 1 ; <nl> + } ; <nl> + <nl> TEST ( FileBlockCacheTest , PassThrough ) { <nl> const string want_filename = " foo / bar " ; <nl> const size_t want_offset = 42 ; <nl> TEST ( FileBlockCacheTest , LRU ) { <nl> } <nl> <nl> TEST ( FileBlockCacheTest , MaxStaleness ) { <nl> - / / This Env wrapper lets us control the NowSeconds ( ) return value . <nl> - class FakeEnv : public EnvWrapper { <nl> - public : <nl> - FakeEnv ( ) : EnvWrapper ( Env : : Default ( ) ) { } <nl> - uint64 NowSeconds ( ) override { return now_ ; } ; <nl> - uint64 now_ = 1 ; <nl> - } ; <nl> int calls = 0 ; <nl> auto fetcher = [ & calls ] ( const string & filename , size_t offset , size_t n , <nl> std : : vector < char > * out ) { <nl> TEST ( FileBlockCacheTest , MaxStaleness ) { <nl> / / count should advance every 3 seconds ( i . e . every time the staleness is <nl> / / greater than 2 ) . <nl> for ( int i = 1 ; i < = 10 ; i + + ) { <nl> - env - > now_ = i + 1 ; <nl> + env - > SetNowSeconds ( i + 1 ) ; <nl> TF_EXPECT_OK ( cache1 . Read ( " " , 0 , 1 , & out ) ) ; <nl> EXPECT_EQ ( calls , 1 + i / 3 ) ; <nl> } <nl> / / Now create a cache with max staleness of 0 , and verify that it also works <nl> / / as expected . <nl> calls = 0 ; <nl> - env - > now_ = 0 ; <nl> + env - > SetNowSeconds ( 0 ) ; <nl> FileBlockCache cache2 ( 8 , 16 , 0 / * max staleness * / , fetcher , env . get ( ) ) ; <nl> / / Execute the first read to load the block . <nl> TF_EXPECT_OK ( cache2 . Read ( " " , 0 , 1 , & out ) ) ; <nl> EXPECT_EQ ( calls , 1 ) ; <nl> / / Advance the clock by a huge amount and verify that the cached block is <nl> / / used to satisfy the read . <nl> - env - > now_ = 365 * 24 * 60 * 60 ; / / ~ 1 year , just for fun . <nl> + env - > SetNowSeconds ( 365 * 24 * 60 * 60 ) ; / / ~ 1 year , just for fun . <nl> TF_EXPECT_OK ( cache2 . Read ( " " , 0 , 1 , & out ) ) ; <nl> EXPECT_EQ ( calls , 1 ) ; <nl> } <nl> TEST ( FileBlockCacheTest , RemoveFile ) { <nl> EXPECT_EQ ( calls , 6 ) ; <nl> } <nl> <nl> + TEST ( FileBlockCacheTest , Prune ) { <nl> + int calls = 0 ; <nl> + auto fetcher = [ & calls ] ( const string & filename , size_t offset , size_t n , <nl> + std : : vector < char > * out ) { <nl> + calls + + ; <nl> + out - > clear ( ) ; <nl> + out - > resize ( n , ' x ' ) ; <nl> + return Status : : OK ( ) ; <nl> + } ; <nl> + std : : vector < char > out ; <nl> + / / Our fake environment is initialized with the current timestamp . <nl> + std : : unique_ptr < FakeEnv > env ( new FakeEnv ) ; <nl> + uint64 now = Env : : Default ( ) - > NowSeconds ( ) ; <nl> + env - > SetNowSeconds ( now ) ; <nl> + FileBlockCache cache ( 8 , 32 , 1 / * max staleness * / , fetcher , env . get ( ) ) ; <nl> + / / Read three blocks into the cache , and advance the timestamp by one second <nl> + / / with each read . Start with a block of " a " at the current timestamp ` now ` . <nl> + TF_EXPECT_OK ( cache . Read ( " a " , 0 , 1 , & out ) ) ; <nl> + / / Now load a block of a different file " b " at timestamp ` now ` + 1 <nl> + env - > SetNowSeconds ( now + 1 ) ; <nl> + TF_EXPECT_OK ( cache . Read ( " b " , 0 , 1 , & out ) ) ; <nl> + / / Now load a different block of file " a " at timestamp ` now ` + 1 . When the <nl> + / / first block of " a " expires , this block should also be removed because it <nl> + / / also belongs to file " a " . <nl> + TF_EXPECT_OK ( cache . Read ( " a " , 8 , 1 , & out ) ) ; <nl> + / / Ensure that all blocks are in the cache ( i . e . reads are cache hits ) . <nl> + EXPECT_EQ ( cache . CacheSize ( ) , 24 ) ; <nl> + EXPECT_EQ ( calls , 3 ) ; <nl> + TF_EXPECT_OK ( cache . Read ( " a " , 0 , 1 , & out ) ) ; <nl> + TF_EXPECT_OK ( cache . Read ( " b " , 0 , 1 , & out ) ) ; <nl> + TF_EXPECT_OK ( cache . Read ( " a " , 8 , 1 , & out ) ) ; <nl> + EXPECT_EQ ( calls , 3 ) ; <nl> + / / Advance the fake timestamp so that " a " becomes stale via its first block . <nl> + env - > SetNowSeconds ( now + 2 ) ; <nl> + / / The pruning thread periodically compares env - > NowSeconds ( ) with the oldest <nl> + / / block ' s timestamp to see if it should evict any files . At the current fake <nl> + / / timestamp of ` now ` + 2 , file " a " is stale because its first block is stale , <nl> + / / but file " b " is not stale yet . Thus , once the pruning thread wakes up ( in <nl> + / / one second of wall time ) , it should remove " a " and leave " b " alone . <nl> + uint64 start = Env : : Default ( ) - > NowSeconds ( ) ; <nl> + do { <nl> + Env : : Default ( ) - > SleepForMicroseconds ( 100000 ) ; <nl> + } while ( cache . CacheSize ( ) = = 24 & & Env : : Default ( ) - > NowSeconds ( ) - start < 3 ) ; <nl> + / / There should be one block left in the cache , and it should be the first <nl> + / / block of " b " . <nl> + EXPECT_EQ ( cache . CacheSize ( ) , 8 ) ; <nl> + TF_EXPECT_OK ( cache . Read ( " b " , 0 , 1 , & out ) ) ; <nl> + EXPECT_EQ ( calls , 3 ) ; <nl> + / / Advance the fake time to ` now ` + 3 , at which point " b " becomes stale . <nl> + env - > SetNowSeconds ( now + 3 ) ; <nl> + / / Wait for the pruner to remove " b " . <nl> + start = Env : : Default ( ) - > NowSeconds ( ) ; <nl> + do { <nl> + Env : : Default ( ) - > SleepForMicroseconds ( 100000 ) ; <nl> + } while ( cache . CacheSize ( ) = = 8 & & Env : : Default ( ) - > NowSeconds ( ) - start < 3 ) ; <nl> + / / The cache should now be empty . <nl> + EXPECT_EQ ( cache . CacheSize ( ) , 0 ) ; <nl> + } <nl> + <nl> } / / namespace <nl> } / / namespace tensorflow <nl>
FileBlockCache will now run a thread to prune files with expired blocks , if configured with a nonzero max staleness .
tensorflow/tensorflow
ed3b2bc8274046ad71630a060e615ad4f78becb9
2017-07-18T23:00:37Z
mmm a / hphp / util / cronoutils . cpp <nl> ppp b / hphp / util / cronoutils . cpp <nl> create_subdirs ( char * filename ) <nl> else <nl> { <nl> CRONO_DEBUG ( ( " Directory \ " % s \ " does not exist - - creating \ n " , dirname ) ) ; <nl> - # ifndef _MSC_VER <nl> if ( ( mkdir ( dirname , DIR_MODE ) < 0 ) & & ( errno ! = EEXIST ) ) <nl> - # else <nl> - if ( ( mkdir ( dirname ) < 0 ) & & ( errno ! = EEXIST ) ) <nl> - # endif <nl> { <nl> perror ( dirname ) ; <nl> return ; <nl>
Remove an MSVC fix in chronutils
facebook/hhvm
752299c8eded3ee6999415757eebce31fc8bf267
2015-08-25T18:00:54Z
mmm a / src / array . js <nl> ppp b / src / array . js <nl> function ArrayToLocaleString ( ) { <nl> <nl> <nl> function ArrayJoin ( separator ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " Array . prototype . join " ] ) ; <nl> - } <nl> - <nl> if ( IS_UNDEFINED ( separator ) ) { <nl> separator = ' , ' ; <nl> } else if ( ! IS_STRING ( separator ) ) { <nl> function ArrayJoin ( separator ) { <nl> / / Removes the last element from the array and returns it . See <nl> / / ECMA - 262 , section 15 . 4 . 4 . 6 . <nl> function ArrayPop ( ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " Array . prototype . pop " ] ) ; <nl> - } <nl> - <nl> var n = TO_UINT32 ( this . length ) ; <nl> if ( n = = 0 ) { <nl> this . length = n ; <nl> function ArrayPop ( ) { <nl> / / Appends the arguments to the end of the array and returns the new <nl> / / length of the array . See ECMA - 262 , section 15 . 4 . 4 . 7 . <nl> function ArrayPush ( ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " Array . prototype . push " ] ) ; <nl> - } <nl> - <nl> var n = TO_UINT32 ( this . length ) ; <nl> var m = % _ArgumentsLength ( ) ; <nl> for ( var i = 0 ; i < m ; i + + ) { <nl> function ArrayPush ( ) { <nl> <nl> <nl> function ArrayConcat ( arg1 ) { / / length = = 1 <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " Array . prototype . concat " ] ) ; <nl> - } <nl> - <nl> var arg_count = % _ArgumentsLength ( ) ; <nl> var arrays = new InternalArray ( 1 + arg_count ) ; <nl> arrays [ 0 ] = this ; <nl> function SparseReverse ( array , len ) { <nl> <nl> <nl> function ArrayReverse ( ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " Array . prototype . reverse " ] ) ; <nl> - } <nl> - <nl> var j = TO_UINT32 ( this . length ) - 1 ; <nl> <nl> if ( UseSparseVariant ( this , j , IS_ARRAY ( this ) ) ) { <nl> function ArrayReverse ( ) { <nl> <nl> <nl> function ArrayShift ( ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " Array . prototype . shift " ] ) ; <nl> - } <nl> - <nl> var len = TO_UINT32 ( this . length ) ; <nl> <nl> if ( len = = = 0 ) { <nl> function ArrayShift ( ) { <nl> <nl> <nl> function ArrayUnshift ( arg1 ) { / / length = = 1 <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " Array . prototype . unshift " ] ) ; <nl> - } <nl> - <nl> var len = TO_UINT32 ( this . length ) ; <nl> var num_arguments = % _ArgumentsLength ( ) ; <nl> <nl> function ArrayUnshift ( arg1 ) { / / length = = 1 <nl> <nl> <nl> function ArraySlice ( start , end ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " Array . prototype . slice " ] ) ; <nl> - } <nl> - <nl> var len = TO_UINT32 ( this . length ) ; <nl> var start_i = TO_INTEGER ( start ) ; <nl> var end_i = len ; <nl> function ArraySlice ( start , end ) { <nl> <nl> <nl> function ArraySplice ( start , delete_count ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " Array . prototype . splice " ] ) ; <nl> - } <nl> - <nl> var num_arguments = % _ArgumentsLength ( ) ; <nl> <nl> var len = TO_UINT32 ( this . length ) ; <nl> function ArraySplice ( start , delete_count ) { <nl> <nl> <nl> function ArraySort ( comparefn ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " Array . prototype . sort " ] ) ; <nl> - } <nl> - <nl> / / In - place QuickSort algorithm . <nl> / / For short ( length < = 22 ) arrays , insertion sort is used for efficiency . <nl> <nl> function ArraySort ( comparefn ) { <nl> / / preserving the semantics , since the calls to the receiver function can add <nl> / / or delete elements from the array . <nl> function ArrayFilter ( f , receiver ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " Array . prototype . filter " ] ) ; <nl> - } <nl> - <nl> if ( ! IS_FUNCTION ( f ) ) { <nl> throw MakeTypeError ( ' called_non_callable ' , [ f ] ) ; <nl> } <nl> function ArrayFilter ( f , receiver ) { <nl> <nl> <nl> function ArrayForEach ( f , receiver ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " Array . prototype . forEach " ] ) ; <nl> - } <nl> - <nl> if ( ! IS_FUNCTION ( f ) ) { <nl> throw MakeTypeError ( ' called_non_callable ' , [ f ] ) ; <nl> } <nl> function ArrayForEach ( f , receiver ) { <nl> / / Executes the function once for each element present in the <nl> / / array until it finds one where callback returns true . <nl> function ArraySome ( f , receiver ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " Array . prototype . some " ] ) ; <nl> - } <nl> - <nl> if ( ! IS_FUNCTION ( f ) ) { <nl> throw MakeTypeError ( ' called_non_callable ' , [ f ] ) ; <nl> } <nl> function ArraySome ( f , receiver ) { <nl> <nl> <nl> function ArrayEvery ( f , receiver ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " Array . prototype . every " ] ) ; <nl> - } <nl> - <nl> if ( ! IS_FUNCTION ( f ) ) { <nl> throw MakeTypeError ( ' called_non_callable ' , [ f ] ) ; <nl> } <nl> function ArrayEvery ( f , receiver ) { <nl> } <nl> <nl> function ArrayMap ( f , receiver ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " Array . prototype . map " ] ) ; <nl> - } <nl> - <nl> if ( ! IS_FUNCTION ( f ) ) { <nl> throw MakeTypeError ( ' called_non_callable ' , [ f ] ) ; <nl> } <nl> function ArrayMap ( f , receiver ) { <nl> <nl> <nl> function ArrayIndexOf ( element , index ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " Array . prototype . indexOf " ] ) ; <nl> - } <nl> - <nl> var length = TO_UINT32 ( this . length ) ; <nl> if ( length = = 0 ) return - 1 ; <nl> if ( IS_UNDEFINED ( index ) ) { <nl> function ArrayIndexOf ( element , index ) { <nl> <nl> <nl> function ArrayLastIndexOf ( element , index ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " Array . prototype . lastIndexOf " ] ) ; <nl> - } <nl> - <nl> var length = TO_UINT32 ( this . length ) ; <nl> if ( length = = 0 ) return - 1 ; <nl> if ( % _ArgumentsLength ( ) < 2 ) { <nl> function ArrayLastIndexOf ( element , index ) { <nl> <nl> <nl> function ArrayReduce ( callback , current ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " Array . prototype . reduce " ] ) ; <nl> - } <nl> - <nl> if ( ! IS_FUNCTION ( callback ) ) { <nl> throw MakeTypeError ( ' called_non_callable ' , [ callback ] ) ; <nl> } <nl> function ArrayReduce ( callback , current ) { <nl> } <nl> <nl> function ArrayReduceRight ( callback , current ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " Array . prototype . reduceRight " ] ) ; <nl> - } <nl> - <nl> if ( ! IS_FUNCTION ( callback ) ) { <nl> throw MakeTypeError ( ' called_non_callable ' , [ callback ] ) ; <nl> } <nl> mmm a / src / date . js <nl> ppp b / src / date . js <nl> function DateGetUTCDate ( ) { <nl> <nl> / / ECMA 262 - 15 . 9 . 5 . 16 <nl> function DateGetDay ( ) { <nl> - var t = DATE_VALUE ( this ) ; <nl> + var t = % _ValueOf ( this ) ; <nl> if ( NUMBER_IS_NAN ( t ) ) return t ; <nl> return WeekDay ( LocalTimeNoCheck ( t ) ) ; <nl> } <nl> function DateGetDay ( ) { <nl> <nl> / / ECMA 262 - 15 . 9 . 5 . 17 <nl> function DateGetUTCDay ( ) { <nl> - var t = DATE_VALUE ( this ) ; <nl> + var t = % _ValueOf ( this ) ; <nl> if ( NUMBER_IS_NAN ( t ) ) return t ; <nl> return WeekDay ( t ) ; <nl> } <nl> mmm a / src / ia32 / builtins - ia32 . cc <nl> ppp b / src / ia32 / builtins - ia32 . cc <nl> void Builtins : : Generate_FunctionCall ( MacroAssembler * masm ) { <nl> 1 < < SharedFunctionInfo : : kStrictModeBitWithinByte ) ; <nl> __ j ( not_equal , & shift_arguments ) ; <nl> <nl> - / / Do not transform the receiver for natives ( shared already in ebx ) . <nl> - __ mov ( ebx , FieldOperand ( ebx , SharedFunctionInfo : : kScriptOffset ) ) ; <nl> - __ cmp ( ebx , factory - > undefined_value ( ) ) ; <nl> - __ j ( equal , & shift_arguments ) ; <nl> - __ mov ( ebx , FieldOperand ( ebx , Script : : kTypeOffset ) ) ; <nl> - __ SmiUntag ( ebx ) ; <nl> - __ cmp ( ebx , Script : : TYPE_NATIVE ) ; <nl> - __ j ( equal , & shift_arguments ) ; <nl> - <nl> / / Compute the receiver in non - strict mode . <nl> __ mov ( ebx , Operand ( esp , eax , times_4 , 0 ) ) ; / / First argument . <nl> __ test ( ebx , Immediate ( kSmiTagMask ) ) ; <nl> void Builtins : : Generate_FunctionApply ( MacroAssembler * masm ) { <nl> 1 < < SharedFunctionInfo : : kStrictModeBitWithinByte ) ; <nl> __ j ( not_equal , & push_receiver ) ; <nl> <nl> - Factory * factory = masm - > isolate ( ) - > factory ( ) ; <nl> - <nl> - / / Do not transform the receiver for natives ( shared already in ecx ) . <nl> - __ mov ( ecx , FieldOperand ( ecx , SharedFunctionInfo : : kScriptOffset ) ) ; <nl> - __ cmp ( ecx , factory - > undefined_value ( ) ) ; <nl> - __ j ( equal , & push_receiver ) ; <nl> - __ mov ( ecx , FieldOperand ( ecx , Script : : kTypeOffset ) ) ; <nl> - __ SmiUntag ( ecx ) ; <nl> - __ cmp ( ecx , Script : : TYPE_NATIVE ) ; <nl> - __ j ( equal , & push_receiver ) ; <nl> - <nl> / / Compute the receiver in non - strict mode . <nl> __ test ( ebx , Immediate ( kSmiTagMask ) ) ; <nl> __ j ( zero , & call_to_object ) ; <nl> + Factory * factory = masm - > isolate ( ) - > factory ( ) ; <nl> __ cmp ( ebx , factory - > null_value ( ) ) ; <nl> __ j ( equal , & use_global_receiver ) ; <nl> __ cmp ( ebx , factory - > undefined_value ( ) ) ; <nl> mmm a / src / messages . js <nl> ppp b / src / messages . js <nl> function FormatMessage ( message ) { <nl> invalid_json : [ " String ' " , " % 0 " , " ' is not valid JSON " ] , <nl> circular_structure : [ " Converting circular structure to JSON " ] , <nl> obj_ctor_property_non_object : [ " Object . " , " % 0 " , " called on non - object " ] , <nl> - called_on_null_or_undefined : [ " % 0 " , " called on null or undefined " ] , <nl> array_indexof_not_defined : [ " Array . getIndexOf : Argument undefined " ] , <nl> object_not_extensible : [ " Can ' t add property " , " % 0 " , " , object is not extensible " ] , <nl> illegal_access : [ " Illegal access " ] , <nl> function errorToStringDetectCycle ( ) { <nl> } <nl> <nl> function errorToString ( ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " Error . prototype . toString " ] ) ; <nl> - } <nl> / / This helper function is needed because access to properties on <nl> / / the builtins object do not work inside of a catch clause . <nl> function isCyclicErrorMarker ( o ) { return o = = = cyclic_error_marker ; } <nl> mmm a / src / string . js <nl> ppp b / src / string . js <nl> function StringValueOf ( ) { <nl> <nl> / / ECMA - 262 , section 15 . 5 . 4 . 4 <nl> function StringCharAt ( pos ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " String . prototype . charAt " ] ) ; <nl> - } <nl> var result = % _StringCharAt ( this , pos ) ; <nl> if ( % _IsSmi ( result ) ) { <nl> result = % _StringCharAt ( TO_STRING_INLINE ( this ) , TO_INTEGER ( pos ) ) ; <nl> function StringCharAt ( pos ) { <nl> <nl> / / ECMA - 262 section 15 . 5 . 4 . 5 <nl> function StringCharCodeAt ( pos ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " String . prototype . charCodeAt " ] ) ; <nl> - } <nl> var result = % _StringCharCodeAt ( this , pos ) ; <nl> if ( ! % _IsSmi ( result ) ) { <nl> result = % _StringCharCodeAt ( TO_STRING_INLINE ( this ) , TO_INTEGER ( pos ) ) ; <nl> function StringCharCodeAt ( pos ) { <nl> <nl> / / ECMA - 262 , section 15 . 5 . 4 . 6 <nl> function StringConcat ( ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , [ " String . prototype . concat " ] ) ; <nl> - } <nl> var len = % _ArgumentsLength ( ) ; <nl> var this_as_string = TO_STRING_INLINE ( this ) ; <nl> if ( len = = = 1 ) { <nl> function StringConcat ( ) { <nl> <nl> / / ECMA - 262 section 15 . 5 . 4 . 7 <nl> function StringIndexOf ( pattern / * position * / ) { / / length = = 1 <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " String . prototype . indexOf " ] ) ; <nl> - } <nl> var subject = TO_STRING_INLINE ( this ) ; <nl> pattern = TO_STRING_INLINE ( pattern ) ; <nl> var index = 0 ; <nl> function StringIndexOf ( pattern / * position * / ) { / / length = = 1 <nl> <nl> / / ECMA - 262 section 15 . 5 . 4 . 8 <nl> function StringLastIndexOf ( pat / * position * / ) { / / length = = 1 <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " String . prototype . lastIndexOf " ] ) ; <nl> - } <nl> var sub = TO_STRING_INLINE ( this ) ; <nl> var subLength = sub . length ; <nl> var pat = TO_STRING_INLINE ( pat ) ; <nl> function StringLastIndexOf ( pat / * position * / ) { / / length = = 1 <nl> / / This function is implementation specific . For now , we do not <nl> / / do anything locale specific . <nl> function StringLocaleCompare ( other ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " String . prototype . localeCompare " ] ) ; <nl> - } <nl> if ( % _ArgumentsLength ( ) = = = 0 ) return 0 ; <nl> return % StringLocaleCompare ( TO_STRING_INLINE ( this ) , <nl> TO_STRING_INLINE ( other ) ) ; <nl> function StringLocaleCompare ( other ) { <nl> <nl> / / ECMA - 262 section 15 . 5 . 4 . 10 <nl> function StringMatch ( regexp ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " String . prototype . match " ] ) ; <nl> - } <nl> var subject = TO_STRING_INLINE ( this ) ; <nl> if ( IS_REGEXP ( regexp ) ) { <nl> if ( ! regexp . global ) return RegExpExecNoTests ( regexp , subject , 0 ) ; <nl> var reusableMatchInfo = [ 2 , " " , " " , - 1 , - 1 ] ; <nl> <nl> / / ECMA - 262 , section 15 . 5 . 4 . 11 <nl> function StringReplace ( search , replace ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " String . prototype . replace " ] ) ; <nl> - } <nl> var subject = TO_STRING_INLINE ( this ) ; <nl> <nl> / / Delegate to one of the regular expression variants if necessary . <nl> function StringReplaceNonGlobalRegExpWithFunction ( subject , regexp , replace ) { <nl> <nl> / / ECMA - 262 section 15 . 5 . 4 . 12 <nl> function StringSearch ( re ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " String . prototype . search " ] ) ; <nl> - } <nl> var regexp ; <nl> if ( IS_STRING ( re ) ) { <nl> regexp = % _GetFromCache ( STRING_TO_REGEXP_CACHE_ID , re ) ; <nl> function StringSearch ( re ) { <nl> <nl> / / ECMA - 262 section 15 . 5 . 4 . 13 <nl> function StringSlice ( start , end ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " String . prototype . slice " ] ) ; <nl> - } <nl> var s = TO_STRING_INLINE ( this ) ; <nl> var s_len = s . length ; <nl> var start_i = TO_INTEGER ( start ) ; <nl> function StringSlice ( start , end ) { <nl> <nl> / / ECMA - 262 section 15 . 5 . 4 . 14 <nl> function StringSplit ( separator , limit ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " String . prototype . split " ] ) ; <nl> - } <nl> var subject = TO_STRING_INLINE ( this ) ; <nl> limit = ( IS_UNDEFINED ( limit ) ) ? 0xffffffff : TO_UINT32 ( limit ) ; <nl> if ( limit = = = 0 ) return [ ] ; <nl> function StringSplit ( separator , limit ) { <nl> <nl> / / ECMA - 262 section 15 . 5 . 4 . 15 <nl> function StringSubstring ( start , end ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " String . prototype . subString " ] ) ; <nl> - } <nl> var s = TO_STRING_INLINE ( this ) ; <nl> var s_len = s . length ; <nl> <nl> function StringSubstring ( start , end ) { <nl> <nl> / / This is not a part of ECMA - 262 . <nl> function StringSubstr ( start , n ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " String . prototype . substr " ] ) ; <nl> - } <nl> var s = TO_STRING_INLINE ( this ) ; <nl> var len ; <nl> <nl> function StringSubstr ( start , n ) { <nl> <nl> / / ECMA - 262 , 15 . 5 . 4 . 16 <nl> function StringToLowerCase ( ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " String . prototype . toLowerCase " ] ) ; <nl> - } <nl> return % StringToLowerCase ( TO_STRING_INLINE ( this ) ) ; <nl> } <nl> <nl> <nl> / / ECMA - 262 , 15 . 5 . 4 . 17 <nl> function StringToLocaleLowerCase ( ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " String . prototype . toLocaleLowerCase " ] ) ; <nl> - } <nl> return % StringToLowerCase ( TO_STRING_INLINE ( this ) ) ; <nl> } <nl> <nl> <nl> / / ECMA - 262 , 15 . 5 . 4 . 18 <nl> function StringToUpperCase ( ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " String . prototype . toUpperCase " ] ) ; <nl> - } <nl> return % StringToUpperCase ( TO_STRING_INLINE ( this ) ) ; <nl> } <nl> <nl> <nl> / / ECMA - 262 , 15 . 5 . 4 . 19 <nl> function StringToLocaleUpperCase ( ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " String . prototype . toLocaleUpperCase " ] ) ; <nl> - } <nl> return % StringToUpperCase ( TO_STRING_INLINE ( this ) ) ; <nl> } <nl> <nl> / / ES5 , 15 . 5 . 4 . 20 <nl> function StringTrim ( ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " String . prototype . trim " ] ) ; <nl> - } <nl> return % StringTrim ( TO_STRING_INLINE ( this ) , true , true ) ; <nl> } <nl> <nl> function StringTrimLeft ( ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " String . prototype . trimLeft " ] ) ; <nl> - } <nl> return % StringTrim ( TO_STRING_INLINE ( this ) , true , false ) ; <nl> } <nl> <nl> function StringTrimRight ( ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " String . prototype . trimRight " ] ) ; <nl> - } <nl> return % StringTrim ( TO_STRING_INLINE ( this ) , false , true ) ; <nl> } <nl> <nl> mmm a / src / v8natives . js <nl> ppp b / src / v8natives . js <nl> $ Object . prototype . constructor = $ Object ; <nl> <nl> / / ECMA - 262 - 15 . 2 . 4 . 2 <nl> function ObjectToString ( ) { <nl> - if ( IS_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - return ' [ object Undefined ] ' ; <nl> - } <nl> - if ( IS_NULL ( this ) ) return ' [ object Null ] ' ; <nl> return " [ object " + % _ClassOf ( ToObject ( this ) ) + " ] " ; <nl> } <nl> <nl> <nl> / / ECMA - 262 - 15 . 2 . 4 . 3 <nl> function ObjectToLocaleString ( ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " Object . prototype . toLocaleString " ] ) ; <nl> - } <nl> return this . toString ( ) ; <nl> } <nl> <nl> function ObjectHasOwnProperty ( V ) { <nl> <nl> / / ECMA - 262 - 15 . 2 . 4 . 6 <nl> function ObjectIsPrototypeOf ( V ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " Object . prototype . isPrototypeOf " ] ) ; <nl> - } <nl> if ( ! IS_SPEC_OBJECT ( V ) ) return false ; <nl> return % IsInPrototypeChain ( this , V ) ; <nl> } <nl> function NumberToString ( radix ) { <nl> <nl> / / ECMA - 262 section 15 . 7 . 4 . 3 <nl> function NumberToLocaleString ( ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " Number . prototype . toLocaleString " ] ) ; <nl> - } <nl> return this . toString ( ) ; <nl> } <nl> <nl> function NumberToFixed ( fractionDigits ) { <nl> if ( f < 0 | | f > 20 ) { <nl> throw new $ RangeError ( " toFixed ( ) digits argument must be between 0 and 20 " ) ; <nl> } <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " Number . prototype . toFixed " ] ) ; <nl> - } <nl> var x = ToNumber ( this ) ; <nl> return % NumberToFixed ( x , f ) ; <nl> } <nl> function NumberToExponential ( fractionDigits ) { <nl> throw new $ RangeError ( " toExponential ( ) argument must be between 0 and 20 " ) ; <nl> } <nl> } <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " Number . prototype . toExponential " ] ) ; <nl> - } <nl> var x = ToNumber ( this ) ; <nl> return % NumberToExponential ( x , f ) ; <nl> } <nl> function NumberToExponential ( fractionDigits ) { <nl> <nl> / / ECMA - 262 section 15 . 7 . 4 . 7 <nl> function NumberToPrecision ( precision ) { <nl> - if ( IS_NULL_OR_UNDEFINED ( this ) & & ! IS_UNDETECTABLE ( this ) ) { <nl> - throw MakeTypeError ( " called_on_null_or_undefined " , <nl> - [ " Number . prototype . toPrecision " ] ) ; <nl> - } <nl> if ( IS_UNDEFINED ( precision ) ) return ToString ( % _ValueOf ( this ) ) ; <nl> var p = TO_INTEGER ( precision ) ; <nl> if ( p < 1 | | p > 21 ) { <nl> mmm a / test / es5conform / es5conform . status <nl> ppp b / test / es5conform / es5conform . status <nl> chapter15 / 15 . 2 / 15 . 2 . 3 / 15 . 2 . 3 . 4 / 15 . 2 . 3 . 4 - 4 - 34 : FAIL_OK <nl> # SUBSETFAIL <nl> chapter15 / 15 . 2 / 15 . 2 . 3 / 15 . 2 . 3 . 4 / 15 . 2 . 3 . 4 - 4 - 35 : FAIL_OK <nl> <nl> + # Bad test - the spec does not say anything about throwing errors <nl> + # on calling Array . prototype . indexOf with undefined as argument . <nl> + chapter15 / 15 . 4 / 15 . 4 . 4 / 15 . 4 . 4 . 14 / 15 . 4 . 4 . 14 - 1 - 1 : FAIL_OK <nl> + <nl> + # Bad test - the spec does not say anything about throwing errors <nl> + # on calling Array . prototype . indexOf with null as argument . <nl> + chapter15 / 15 . 4 / 15 . 4 . 4 / 15 . 4 . 4 . 14 / 15 . 4 . 4 . 14 - 1 - 2 : FAIL_OK <nl> + <nl> # Bad test - the test at the end should be " i = = = true " . <nl> chapter15 / 15 . 4 / 15 . 4 . 4 / 15 . 4 . 4 . 17 / 15 . 4 . 4 . 17 - 8 - 10 : FAIL_OK <nl> <nl> chapter15 / 15 . 4 / 15 . 4 . 4 / 15 . 4 . 4 . 22 / 15 . 4 . 4 . 22 - 9 - c - ii - 4 - s : SKIP <nl> # have no effect on the actual array on which reduceRight is called . <nl> chapter15 / 15 . 4 / 15 . 4 . 4 / 15 . 4 . 4 . 22 / 15 . 4 . 4 . 22 - 9 - 7 : FAIL_OK <nl> <nl> + # We do not implement trim correctly on null and undefined . <nl> + chapter15 / 15 . 5 / 15 . 5 . 4 / 15 . 5 . 4 . 20 / 15 . 5 . 4 . 20 - 1 - 1 : FAIL <nl> + chapter15 / 15 . 5 / 15 . 5 . 4 / 15 . 5 . 4 . 20 / 15 . 5 . 4 . 20 - 1 - 2 : FAIL <nl> + <nl> # We do not correctly recognize \ uFEFF as whitespace <nl> chapter15 / 15 . 5 / 15 . 5 . 4 / 15 . 5 . 4 . 20 / 15 . 5 . 4 . 20 - 4 - 10 : FAIL <nl> chapter15 / 15 . 5 / 15 . 5 . 4 / 15 . 5 . 4 . 20 / 15 . 5 . 4 . 20 - 4 - 18 : FAIL <nl> mmm a / test / mjsunit / function - call . js <nl> ppp b / test / mjsunit / function - call . js <nl> <nl> - / / Copyright 2011 the V8 project authors . All rights reserved . <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following <nl> - / / disclaimer in the documentation and / or other materials provided <nl> - / / with the distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived <nl> - / / from this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - <nl> - var should_throw_on_null_and_undefined = <nl> - [ Object . prototype . toLocaleString , <nl> - Object . prototype . valueOf , <nl> - Object . prototype . hasOwnProperty , <nl> - Object . prototype . isPrototypeOf , <nl> - Object . prototype . propertyIsEnumerable , <nl> - Array . prototype . toString , <nl> - Array . prototype . toLocaleString , <nl> - Array . prototype . concat , <nl> - Array . prototype . join , <nl> - Array . prototype . pop , <nl> - Array . prototype . push , <nl> - Array . prototype . reverse , <nl> - Array . prototype . shift , <nl> - Array . prototype . slice , <nl> - Array . prototype . sort , <nl> - Array . prototype . splice , <nl> - Array . prototype . unshift , <nl> - Array . prototype . indexOf , <nl> - Array . prototype . lastIndexOf , <nl> - Array . prototype . every , <nl> - Array . prototype . some , <nl> - Array . prototype . forEach , <nl> - Array . prototype . map , <nl> - Array . prototype . filter , <nl> - Array . prototype . reduce , <nl> - Array . prototype . reduceRight , <nl> - String . prototype . charAt , <nl> - String . prototype . charCodeAt , <nl> - String . prototype . concat , <nl> - String . prototype . indexOf , <nl> - String . prototype . lastIndexOf , <nl> - String . prototype . localeCompare , <nl> - String . prototype . match , <nl> - String . prototype . replace , <nl> - String . prototype . search , <nl> - String . prototype . slice , <nl> - String . prototype . split , <nl> - String . prototype . substring , <nl> - String . prototype . toLowerCase , <nl> - String . prototype . toLocaleLowerCase , <nl> - String . prototype . toUpperCase , <nl> - String . prototype . toLocaleUpperCase , <nl> - String . prototype . trim , <nl> - Number . prototype . toLocaleString , <nl> - Error . prototype . toString ] ; <nl> - <nl> - / / Non generic natives does not work on any input other than the specific <nl> - / / type , but since this change will allow call to be invoked with undefined <nl> - / / or null as this we still explicitly test that we throw on these here . <nl> - var non_generic = <nl> - [ Function . prototype . toString , <nl> - Function . prototype . call , <nl> - Function . prototype . apply , <nl> - String . prototype . toString , <nl> - String . prototype . valueOf , <nl> - Boolean . prototype . toString , <nl> - Boolean . prototype . valueOf , <nl> - Number . prototype . toString , <nl> - Number . prototype . valueOf , <nl> - Number . prototype . toFixed , <nl> - Number . prototype . toExponential , <nl> - Number . prototype . toPrecision , <nl> - Date . prototype . toString , <nl> - Date . prototype . toDateString , <nl> - Date . prototype . toTimeString , <nl> - Date . prototype . toLocaleString , <nl> - Date . prototype . toLocaleDateString , <nl> - Date . prototype . toLocaleTimeString , <nl> - Date . prototype . valueOf , <nl> - Date . prototype . getTime , <nl> - Date . prototype . getFullYear , <nl> - Date . prototype . getUTCFullYear , <nl> - Date . prototype . getMonth , <nl> - Date . prototype . getUTCMonth , <nl> - Date . prototype . getDate , <nl> - Date . prototype . getUTCDate , <nl> - Date . prototype . getDay , <nl> - Date . prototype . getUTCDay , <nl> - Date . prototype . getHours , <nl> - Date . prototype . getUTCHours , <nl> - Date . prototype . getMinutes , <nl> - Date . prototype . getUTCMinutes , <nl> - Date . prototype . getSeconds , <nl> - Date . prototype . getUTCSeconds , <nl> - Date . prototype . getMilliseconds , <nl> - Date . prototype . getUTCMilliseconds , <nl> - Date . prototype . getTimezoneOffset , <nl> - Date . prototype . setTime , <nl> - Date . prototype . setMilliseconds , <nl> - Date . prototype . setUTCMilliseconds , <nl> - Date . prototype . setSeconds , <nl> - Date . prototype . setUTCSeconds , <nl> - Date . prototype . setMinutes , <nl> - Date . prototype . setUTCMinutes , <nl> - Date . prototype . setHours , <nl> - Date . prototype . setUTCHours , <nl> - Date . prototype . setDate , <nl> - Date . prototype . setUTCDate , <nl> - Date . prototype . setMonth , <nl> - Date . prototype . setUTCMonth , <nl> - Date . prototype . setFullYear , <nl> - Date . prototype . setUTCFullYear , <nl> - Date . prototype . toUTCString , <nl> - Date . prototype . toISOString , <nl> - Date . prototype . toJSON , <nl> - RegExp . prototype . exec , <nl> - RegExp . prototype . test , <nl> - RegExp . prototype . toString ] ; <nl> - <nl> - <nl> - / / Mapping functions . <nl> - var mapping_functions = <nl> - [ Array . prototype . every , <nl> - Array . prototype . some , <nl> - Array . prototype . forEach , <nl> - Array . prototype . map , <nl> - Array . prototype . filter ] ; <nl> - <nl> - / / Reduce functions . <nl> - var reducing_functions = <nl> - [ Array . prototype . reduce , <nl> - Array . prototype . reduceRight ] ; <nl> - <nl> - / / Test that all natives using the ToObject call throws the right exception . <nl> - for ( var i = 0 ; i < should_throw_on_null_and_undefined . length ; i + + ) { <nl> - / / Sanity check that all functions are correct <nl> - assertEquals ( typeof ( should_throw_on_null_and_undefined [ i ] ) , " function " ) ; <nl> - <nl> - try { <nl> - / / We call all functions with no parameters , which means that essential <nl> - / / parameters will have the undefined value . <nl> - / / The test for whether the " this " value is null or undefined is always <nl> - / / performed before access to the other parameters , so even if the <nl> - / / undefined value is an invalid argument value , it mustn ' t change <nl> - / / the result of the test . <nl> - should_throw_on_null_and_undefined [ i ] . call ( null ) ; <nl> - assertUnreachable ( ) ; <nl> - } catch ( e ) { <nl> - assertTrue ( " called_on_null_or_undefined " = = e . type | | <nl> - " null_to_object " = = e . type ) ; <nl> - } <nl> - <nl> - try { <nl> - should_throw_on_null_and_undefined [ i ] . call ( undefined ) ; <nl> - assertUnreachable ( ) ; <nl> - } catch ( e ) { <nl> - assertTrue ( " called_on_null_or_undefined " = = e . type | | <nl> - " null_to_object " = = e . type ) ; <nl> - } <nl> - <nl> - try { <nl> - should_throw_on_null_and_undefined [ i ] . apply ( null ) ; <nl> - assertUnreachable ( ) ; <nl> - } catch ( e ) { <nl> - assertTrue ( " called_on_null_or_undefined " = = e . type | | <nl> - " null_to_object " = = e . type ) ; <nl> - } <nl> - <nl> - try { <nl> - should_throw_on_null_and_undefined [ i ] . apply ( undefined ) ; <nl> - assertUnreachable ( ) ; <nl> - } catch ( e ) { <nl> - assertTrue ( " called_on_null_or_undefined " = = e . type | | <nl> - " null_to_object " = = e . type ) ; <nl> - } <nl> - } <nl> - <nl> - / / Test that all natives that are non generic throws on null and undefined . <nl> - for ( var i = 0 ; i < non_generic . length ; i + + ) { <nl> - / / Sanity check that all functions are correct <nl> - assertEquals ( typeof ( non_generic [ i ] ) , " function " ) ; <nl> - try { <nl> - non_generic [ i ] . call ( null ) ; <nl> - assertUnreachable ( ) ; <nl> - } catch ( e ) { <nl> - assertTrue ( e instanceof TypeError ) ; <nl> - } <nl> - <nl> - try { <nl> - non_generic [ i ] . call ( null ) ; <nl> - assertUnreachable ( ) ; <nl> - } catch ( e ) { <nl> - assertTrue ( e instanceof TypeError ) ; <nl> - } <nl> - <nl> - try { <nl> - non_generic [ i ] . apply ( null ) ; <nl> - assertUnreachable ( ) ; <nl> - } catch ( e ) { <nl> - assertTrue ( e instanceof TypeError ) ; <nl> - } <nl> - <nl> - try { <nl> - non_generic [ i ] . apply ( null ) ; <nl> - assertUnreachable ( ) ; <nl> - } catch ( e ) { <nl> - assertTrue ( e instanceof TypeError ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - / / Test that we still throw when calling with thisArg null or undefined <nl> - / / through an array mapping function . <nl> - var array = [ 1 , 2 , 3 , 4 , 5 ] ; <nl> - for ( var j = 0 ; j < mapping_functions . length ; j + + ) { <nl> - for ( var i = 0 ; i < should_throw_on_null_and_undefined . length ; i + + ) { <nl> - try { <nl> - mapping_functions [ j ] . call ( array , <nl> - should_throw_on_null_and_undefined [ i ] , <nl> - null ) ; <nl> - assertUnreachable ( ) ; <nl> - } catch ( e ) { <nl> - assertTrue ( " called_on_null_or_undefined " = = e . type | | <nl> - " null_to_object " = = e . type ) ; <nl> - } <nl> - <nl> - try { <nl> - mapping_functions [ j ] . call ( array , <nl> - should_throw_on_null_and_undefined [ i ] , <nl> - undefined ) ; <nl> - assertUnreachable ( ) ; <nl> - } catch ( e ) { <nl> - assertTrue ( " called_on_null_or_undefined " = = e . type | | <nl> - " null_to_object " = = e . type ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - for ( var j = 0 ; j < mapping_functions . length ; j + + ) { <nl> - for ( var i = 0 ; i < non_generic . length ; i + + ) { <nl> - try { <nl> - mapping_functions [ j ] . call ( array , <nl> - non_generic [ i ] , <nl> - null ) ; <nl> - assertUnreachable ( ) ; <nl> - } catch ( e ) { <nl> - assertTrue ( e instanceof TypeError ) ; <nl> - } <nl> - <nl> - try { <nl> - mapping_functions [ j ] . call ( array , <nl> - non_generic [ i ] , <nl> - undefined ) ; <nl> - assertUnreachable ( ) ; <nl> - } catch ( e ) { <nl> - assertTrue ( e instanceof TypeError ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - <nl> - / / Reduce functions do a call with null as this argument . <nl> - for ( var j = 0 ; j < reducing_functions . length ; j + + ) { <nl> - for ( var i = 0 ; i < should_throw_on_null_and_undefined . length ; i + + ) { <nl> - try { <nl> - reducing_functions [ j ] . call ( array , should_throw_on_null_and_undefined [ i ] ) ; <nl> - assertUnreachable ( ) ; <nl> - } catch ( e ) { <nl> - assertTrue ( " called_on_null_or_undefined " = = e . type | | <nl> - " null_to_object " = = e . type ) ; <nl> - } <nl> - <nl> - try { <nl> - reducing_functions [ j ] . call ( array , should_throw_on_null_and_undefined [ i ] ) ; <nl> - assertUnreachable ( ) ; <nl> - } catch ( e ) { <nl> - assertTrue ( " called_on_null_or_undefined " = = e . type | | <nl> - " null_to_object " = = e . type ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - for ( var j = 0 ; j < reducing_functions . length ; j + + ) { <nl> - for ( var i = 0 ; i < non_generic . length ; i + + ) { <nl> - try { <nl> - reducing_functions [ j ] . call ( array , non_generic [ i ] ) ; <nl> - assertUnreachable ( ) ; <nl> - } catch ( e ) { <nl> - assertTrue ( e instanceof TypeError ) ; <nl> - } <nl> - <nl> - try { <nl> - reducing_functions [ j ] . call ( array , non_generic [ i ] ) ; <nl> - assertUnreachable ( ) ; <nl> - } catch ( e ) { <nl> - assertTrue ( e instanceof TypeError ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - <nl> - / / Object . prototype . toString ( ) <nl> - assertEquals ( Object . prototype . toString . call ( null ) , <nl> - ' [ object Null ] ' ) <nl> - <nl> - assertEquals ( Object . prototype . toString . call ( undefined ) , <nl> - ' [ object Undefined ] ' ) <nl> mmm a / test / mjsunit / regress / regress - 485 . js <nl> ppp b / test / mjsunit / regress / regress - 485 . js <nl> var builtin = Object . prototype . valueOf ; / / Builtin function that returns this . <nl> <nl> assertEquals ( global , builtin ( ) , " Direct call to builtin " ) ; <nl> <nl> + assertEquals ( global , builtin . call ( ) , " call ( ) to builtin " ) ; <nl> + assertEquals ( global , builtin . call ( null ) , " call ( null ) to builtin " ) ; <nl> + assertEquals ( global , builtin . call ( undefined ) , " call ( undefined ) to builtin " ) ; <nl> + <nl> + assertEquals ( global , builtin . apply ( ) , " apply ( ) to builtin " ) ; <nl> + assertEquals ( global , builtin . apply ( null ) , " apply ( null ) to builtin " ) ; <nl> + assertEquals ( global , builtin . apply ( undefined ) , " apply ( undefined ) to builtin " ) ; <nl> + <nl> + assertEquals ( global , builtin . call . call ( builtin ) , " call . call ( ) to builtin " ) ; <nl> + assertEquals ( global , builtin . call . apply ( builtin ) , " call . apply ( ) to builtin " ) ; <nl> + assertEquals ( global , builtin . apply . call ( builtin ) , " apply . call ( ) to builtin " ) ; <nl> + assertEquals ( global , builtin . apply . apply ( builtin ) , " apply . apply ( ) to builtin " ) ; <nl> + <nl> <nl> / / Builtin that depends on value of this to compute result . <nl> var builtin2 = Object . prototype . toString ; <nl> mmm a / test / mozilla / mozilla . status <nl> ppp b / test / mozilla / mozilla . status <nl> js1_5 / Regress / regress - 306633 : FAIL <nl> # We fail on out of memory . The important thing is not to crash . <nl> js1_5 / Regress / regress - 303213 : FAIL | | TIMEOUT if $ mode = = debug <nl> <nl> - # This test fails since we now throw in String . prototype . match when apply <nl> - # is given null or undefined as this argument ( and so does firefox nightly ) . <nl> - js1_5 / Regress / regress - 295052 : FAIL <nl> <nl> # Bug 1202592 : New ecma_3 / String / 15 . 5 . 4 . 11 is failing . <nl> ecma_3 / String / 15 . 5 . 4 . 11 : FAIL <nl> mmm a / test / sputnik / sputnik . status <nl> ppp b / test / sputnik / sputnik . status <nl> S11 . 1 . 5_A4 . 2 : FAIL_OK <nl> S9 . 9_A1 : FAIL_OK <nl> S9 . 9_A2 : FAIL_OK <nl> <nl> + <nl> # # # # # # # # # # # # # # # # # # # # # SKIPPED TESTS # # # # # # # # # # # # # # # # # # # # # <nl> <nl> # These tests take a looong time to run in debug mode . <nl> S15 . 1 . 3 . 1_A2 . 5_T1 : PASS , SKIP if $ mode = = debug <nl> # V8 Bug : http : / / code . google . com / p / v8 / issues / detail ? id = 1196 <nl> S8 . 7_A5_T2 : FAIL <nl> <nl> + # V8 bugs : http : / / code . google . com / p / v8 / issues / detail ? id = 1198 <nl> + # V8 should not wrap this when calling builtin functions <nl> + S15 . 2 . 4 . 3_A12 : FAIL <nl> + S15 . 2 . 4 . 7_A13 : FAIL <nl> + # Object . prototype . toString <nl> + S15 . 2 . 4 . 2_A12 : FAIL <nl> + S15 . 2 . 4 . 2_A13 : FAIL <nl> + # Object . prototype . toLocaleString <nl> + S15 . 2 . 4 . 3_A13 : FAIL <nl> + S15 . 2 . 4 . 4_A13 : FAIL <nl> + S15 . 2 . 4 . 4_A12 : FAIL <nl> + # Object . prototype . propertyIsEnumerable <nl> + S15 . 2 . 4 . 7_A12 : FAIL <nl> + # Object . prototype . hasOwnProperty <nl> + S15 . 2 . 4 . 5_A12 : FAIL <nl> + S15 . 2 . 4 . 5_A13 : FAIL <nl> + # Object . prototype . isPrototypeOf <nl> + S15 . 2 . 4 . 6_A13 : FAIL <nl> + S15 . 2 . 4 . 6_A12 : FAIL <nl> + <nl> # Invalid test case ( recent change adding var changes semantics ) <nl> S8 . 3_A1_T1 : FAIL <nl> # Test bug : http : / / code . google . com / p / sputniktests / issues / detail ? id = 35 <nl> S11 . 4 . 3_A3 . 6 : FAIL_OK <nl> S15 . 10 . 7_A3_T2 : FAIL_OK <nl> S15 . 10 . 7_A3_T1 : FAIL_OK <nl> <nl> - <nl> [ $ arch = = arm ] <nl> <nl> # BUG ( 3251225 ) : Tests that timeout with - - nocrankshaft . <nl>
Revert 7763 , missing implementation on x64 and arm for call and apply with null or undefined .
v8/v8
4d890da19139bb044f71b054c7079a51b9dcb9dd
2011-05-03T13:45:19Z
mmm a / xbmc / guilib / GUIBaseContainer . cpp <nl> ppp b / xbmc / guilib / GUIBaseContainer . cpp <nl> <nl> # include " utils / MathUtils . h " <nl> # include " utils / XBMCTinyXML . h " <nl> # include " listproviders / IListProvider . h " <nl> + # include " settings / Settings . h " <nl> <nl> using namespace std ; <nl> <nl> void CGUIBaseContainer : : OnJumpLetter ( char letter , bool skip / * = false * / ) <nl> do <nl> { <nl> CGUIListItemPtr item = m_items [ i ] ; <nl> - if ( 0 = = strnicmp ( SortUtils : : RemoveArticles ( item - > GetLabel ( ) ) . c_str ( ) , m_match . c_str ( ) , m_match . size ( ) ) ) <nl> + std : : string label = item - > GetLabel ( ) ; <nl> + if ( CSettings : : Get ( ) . GetBool ( " filelists . ignorethewhensorting " ) ) <nl> + label = SortUtils : : RemoveArticles ( label ) ; <nl> + if ( 0 = = strnicmp ( label . c_str ( ) , m_match . c_str ( ) , m_match . size ( ) ) ) <nl> { <nl> SelectItem ( i ) ; <nl> return ; <nl>
Merge pull request from phate89 / jumptoletter
xbmc/xbmc
93b5bc6f82e44ddc27ee028d88ac0fb74c8e96dc
2014-11-07T07:33:12Z
mmm a / dbms / src / Parsers / CommonParsers . h <nl> ppp b / dbms / src / Parsers / CommonParsers . h <nl> class ParserToken : public IParserBase <nl> } <nl> } ; <nl> <nl> + class ParserInterval : public IParserBase <nl> + { <nl> + public : <nl> + enum class IntervalKind <nl> + { <nl> + Incorrect , <nl> + Second , <nl> + Minute , <nl> + Hour , <nl> + Day , <nl> + Week , <nl> + Month , <nl> + Quarter , <nl> + Year <nl> + } ; <nl> + <nl> + IntervalKind interval_kind ; <nl> + <nl> + ParserInterval ( ) : interval_kind ( IntervalKind : : Incorrect ) { } <nl> + <nl> + protected : <nl> + const char * getName ( ) const override { return " interval " ; } <nl> + <nl> + bool parseImpl ( Pos & pos , ASTPtr & / * node * / , Expected & expected ) override <nl> + { <nl> + if ( ParserKeyword ( " SECOND " ) . ignore ( pos , expected ) | | ParserKeyword ( " SQL_TSI_SECOND " ) . ignore ( pos , expected ) <nl> + | | ParserKeyword ( " SS " ) . ignore ( pos , expected ) | | ParserKeyword ( " S " ) . ignore ( pos , expected ) ) <nl> + interval_kind = IntervalKind : : Second ; <nl> + else if ( <nl> + ParserKeyword ( " MINUTE " ) . ignore ( pos , expected ) | | ParserKeyword ( " SQL_TSI_MINUTE " ) . ignore ( pos , expected ) <nl> + | | ParserKeyword ( " MI " ) . ignore ( pos , expected ) | | ParserKeyword ( " N " ) . ignore ( pos , expected ) ) <nl> + interval_kind = IntervalKind : : Minute ; <nl> + else if ( <nl> + ParserKeyword ( " HOUR " ) . ignore ( pos , expected ) | | ParserKeyword ( " SQL_TSI_HOUR " ) . ignore ( pos , expected ) <nl> + | | ParserKeyword ( " HH " ) . ignore ( pos , expected ) ) <nl> + interval_kind = IntervalKind : : Hour ; <nl> + else if ( <nl> + ParserKeyword ( " DAY " ) . ignore ( pos , expected ) | | ParserKeyword ( " SQL_TSI_DAY " ) . ignore ( pos , expected ) <nl> + | | ParserKeyword ( " DD " ) . ignore ( pos , expected ) | | ParserKeyword ( " D " ) . ignore ( pos , expected ) ) <nl> + interval_kind = IntervalKind : : Day ; <nl> + else if ( <nl> + ParserKeyword ( " WEEK " ) . ignore ( pos , expected ) | | ParserKeyword ( " SQL_TSI_WEEK " ) . ignore ( pos , expected ) <nl> + | | ParserKeyword ( " WK " ) . ignore ( pos , expected ) | | ParserKeyword ( " WW " ) . ignore ( pos , expected ) ) <nl> + interval_kind = IntervalKind : : Week ; <nl> + else if ( <nl> + ParserKeyword ( " MONTH " ) . ignore ( pos , expected ) | | ParserKeyword ( " SQL_TSI_MONTH " ) . ignore ( pos , expected ) <nl> + | | ParserKeyword ( " MM " ) . ignore ( pos , expected ) | | ParserKeyword ( " M " ) . ignore ( pos , expected ) ) <nl> + interval_kind = IntervalKind : : Month ; <nl> + else if ( <nl> + ParserKeyword ( " QUARTER " ) . ignore ( pos , expected ) | | ParserKeyword ( " SQL_TSI_QUARTER " ) . ignore ( pos , expected ) <nl> + | | ParserKeyword ( " QQ " ) . ignore ( pos , expected ) | | ParserKeyword ( " Q " ) . ignore ( pos , expected ) ) <nl> + interval_kind = IntervalKind : : Quarter ; <nl> + else if ( <nl> + ParserKeyword ( " YEAR " ) . ignore ( pos , expected ) | | ParserKeyword ( " SQL_TSI_YEAR " ) . ignore ( pos , expected ) <nl> + | | ParserKeyword ( " YYYY " ) . ignore ( pos , expected ) | | ParserKeyword ( " YY " ) . ignore ( pos , expected ) ) <nl> + interval_kind = IntervalKind : : Year ; <nl> + else <nl> + interval_kind = IntervalKind : : Incorrect ; <nl> + <nl> + if ( interval_kind = = IntervalKind : : Incorrect ) <nl> + { <nl> + expected . add ( pos , " YEAR , QUARTER , MONTH , WEEK , DAY , HOUR , MINUTE or SECOND " ) ; <nl> + return false ; <nl> + } <nl> + / / / one of ParserKeyword already made + + pos <nl> + return true ; <nl> + } <nl> + } ; <nl> + <nl> } <nl> mmm a / dbms / src / Parsers / ExpressionElementParsers . cpp <nl> ppp b / dbms / src / Parsers / ExpressionElementParsers . cpp <nl> bool ParserExtractExpression : : parseImpl ( Pos & pos , ASTPtr & node , Expected & exp <nl> ASTPtr expr ; <nl> const char * function_name = nullptr ; <nl> <nl> - if ( ParserKeyword ( " SECOND " ) . ignore ( pos , expected ) ) <nl> - function_name = " toSecond " ; <nl> - else if ( ParserKeyword ( " MINUTE " ) . ignore ( pos , expected ) ) <nl> - function_name = " toMinute " ; <nl> - else if ( ParserKeyword ( " HOUR " ) . ignore ( pos , expected ) ) <nl> - function_name = " toHour " ; <nl> - else if ( ParserKeyword ( " DAY " ) . ignore ( pos , expected ) ) <nl> - function_name = " toDayOfMonth " ; <nl> - <nl> - / / TODO : SELECT toRelativeWeekNum ( toDate ( ' 2017 - 06 - 15 ' ) ) - toRelativeWeekNum ( toStartOfYear ( toDate ( ' 2017 - 06 - 15 ' ) ) ) <nl> - / / else if ( ParserKeyword ( " WEEK " ) . ignore ( pos , expected ) ) <nl> - / / function_name = " toRelativeWeekNum " ; <nl> - <nl> - else if ( ParserKeyword ( " MONTH " ) . ignore ( pos , expected ) ) <nl> - function_name = " toMonth " ; <nl> - else if ( ParserKeyword ( " YEAR " ) . ignore ( pos , expected ) ) <nl> - function_name = " toYear " ; <nl> - else <nl> + ParserInterval interval_parser ; <nl> + if ( ! interval_parser . ignore ( pos , expected ) ) <nl> return false ; <nl> <nl> + switch ( interval_parser . interval_kind ) <nl> + { <nl> + case ParserInterval : : IntervalKind : : Second : <nl> + function_name = " toSecond " ; <nl> + break ; <nl> + case ParserInterval : : IntervalKind : : Minute : <nl> + function_name = " toMinute " ; <nl> + break ; <nl> + case ParserInterval : : IntervalKind : : Hour : <nl> + function_name = " toHour " ; <nl> + break ; <nl> + case ParserInterval : : IntervalKind : : Day : <nl> + function_name = " toDayOfMonth " ; <nl> + break ; <nl> + case ParserInterval : : IntervalKind : : Week : <nl> + / / TODO : SELECT toRelativeWeekNum ( toDate ( ' 2017 - 06 - 15 ' ) ) - toRelativeWeekNum ( toStartOfYear ( toDate ( ' 2017 - 06 - 15 ' ) ) ) <nl> + / / else if ( ParserKeyword ( " WEEK " ) . ignore ( pos , expected ) ) <nl> + / / function_name = " toRelativeWeekNum " ; <nl> + return false ; <nl> + case ParserInterval : : IntervalKind : : Month : <nl> + function_name = " toMonth " ; <nl> + break ; <nl> + case ParserInterval : : IntervalKind : : Quarter : <nl> + function_name = " toQuarter " ; <nl> + break ; <nl> + case ParserInterval : : IntervalKind : : Year : <nl> + function_name = " toYear " ; <nl> + break ; <nl> + default : <nl> + return false ; <nl> + } <nl> + <nl> ParserKeyword s_from ( " FROM " ) ; <nl> if ( ! s_from . ignore ( pos , expected ) ) <nl> return false ; <nl> bool ParserDateDiffExpression : : parseImpl ( Pos & pos , ASTPtr & node , Expected & ex <nl> return false ; <nl> + + pos ; <nl> <nl> - if ( ParserKeyword ( " SECOND " ) . ignore ( pos , expected ) | | ParserKeyword ( " SQL_TSI_SECOND " ) . ignore ( pos , expected ) <nl> - | | ParserKeyword ( " SS " ) . ignore ( pos , expected ) | | ParserKeyword ( " S " ) . ignore ( pos , expected ) ) <nl> - interval_name = " second " ; <nl> - else if ( <nl> - ParserKeyword ( " MINUTE " ) . ignore ( pos , expected ) | | ParserKeyword ( " SQL_TSI_MINUTE " ) . ignore ( pos , expected ) <nl> - | | ParserKeyword ( " MI " ) . ignore ( pos , expected ) | | ParserKeyword ( " N " ) . ignore ( pos , expected ) ) <nl> - interval_name = " minute " ; <nl> - else if ( <nl> - ParserKeyword ( " HOUR " ) . ignore ( pos , expected ) | | ParserKeyword ( " SQL_TSI_HOUR " ) . ignore ( pos , expected ) <nl> - | | ParserKeyword ( " HH " ) . ignore ( pos , expected ) ) <nl> - interval_name = " hour " ; <nl> - else if ( <nl> - ParserKeyword ( " DAY " ) . ignore ( pos , expected ) | | ParserKeyword ( " SQL_TSI_DAY " ) . ignore ( pos , expected ) <nl> - | | ParserKeyword ( " DD " ) . ignore ( pos , expected ) | | ParserKeyword ( " D " ) . ignore ( pos , expected ) ) <nl> - interval_name = " day " ; <nl> - else if ( <nl> - ParserKeyword ( " WEEK " ) . ignore ( pos , expected ) | | ParserKeyword ( " SQL_TSI_WEEK " ) . ignore ( pos , expected ) <nl> - | | ParserKeyword ( " WK " ) . ignore ( pos , expected ) | | ParserKeyword ( " WW " ) . ignore ( pos , expected ) ) <nl> - interval_name = " week " ; <nl> - else if ( <nl> - ParserKeyword ( " MONTH " ) . ignore ( pos , expected ) | | ParserKeyword ( " SQL_TSI_MONTH " ) . ignore ( pos , expected ) <nl> - | | ParserKeyword ( " MM " ) . ignore ( pos , expected ) | | ParserKeyword ( " M " ) . ignore ( pos , expected ) ) <nl> - interval_name = " month " ; <nl> - else if ( <nl> - ParserKeyword ( " QUARTER " ) . ignore ( pos , expected ) | | ParserKeyword ( " SQL_TSI_QUARTER " ) . ignore ( pos , expected ) <nl> - | | ParserKeyword ( " QQ " ) . ignore ( pos , expected ) | | ParserKeyword ( " Q " ) . ignore ( pos , expected ) ) <nl> - interval_name = " quarter " ; <nl> - else if ( <nl> - ParserKeyword ( " YEAR " ) . ignore ( pos , expected ) | | ParserKeyword ( " SQL_TSI_YEAR " ) . ignore ( pos , expected ) <nl> - | | ParserKeyword ( " YYYY " ) . ignore ( pos , expected ) | | ParserKeyword ( " YY " ) . ignore ( pos , expected ) ) <nl> - interval_name = " year " ; <nl> - else <nl> + ParserInterval interval_parser ; <nl> + if ( ! interval_parser . ignore ( pos , expected ) ) <nl> return false ; <nl> <nl> + switch ( interval_parser . interval_kind ) <nl> + { <nl> + case ParserInterval : : IntervalKind : : Second : <nl> + interval_name = " second " ; <nl> + break ; <nl> + case ParserInterval : : IntervalKind : : Minute : <nl> + interval_name = " minute " ; <nl> + break ; <nl> + case ParserInterval : : IntervalKind : : Hour : <nl> + interval_name = " hour " ; <nl> + break ; <nl> + case ParserInterval : : IntervalKind : : Day : <nl> + interval_name = " day " ; <nl> + break ; <nl> + case ParserInterval : : IntervalKind : : Week : <nl> + interval_name = " week " ; <nl> + break ; <nl> + case ParserInterval : : IntervalKind : : Month : <nl> + interval_name = " month " ; <nl> + break ; <nl> + case ParserInterval : : IntervalKind : : Quarter : <nl> + interval_name = " quarter " ; <nl> + break ; <nl> + case ParserInterval : : IntervalKind : : Year : <nl> + interval_name = " year " ; <nl> + break ; <nl> + default : <nl> + return false ; <nl> + } <nl> + <nl> if ( pos - > type ! = TokenType : : Comma ) <nl> return false ; <nl> + + pos ; <nl> mmm a / dbms / src / Parsers / ExpressionListParsers . cpp <nl> ppp b / dbms / src / Parsers / ExpressionListParsers . cpp <nl> bool ParserIntervalOperatorExpression : : parseImpl ( Pos & pos , ASTPtr & node , Expec <nl> <nl> const char * function_name = nullptr ; <nl> <nl> - if ( ParserKeyword ( " SECOND " ) . ignore ( pos , expected ) ) <nl> - function_name = " toIntervalSecond " ; <nl> - else if ( ParserKeyword ( " MINUTE " ) . ignore ( pos , expected ) ) <nl> - function_name = " toIntervalMinute " ; <nl> - else if ( ParserKeyword ( " HOUR " ) . ignore ( pos , expected ) ) <nl> - function_name = " toIntervalHour " ; <nl> - else if ( ParserKeyword ( " DAY " ) . ignore ( pos , expected ) ) <nl> - function_name = " toIntervalDay " ; <nl> - else if ( ParserKeyword ( " WEEK " ) . ignore ( pos , expected ) ) <nl> - function_name = " toIntervalWeek " ; <nl> - else if ( ParserKeyword ( " MONTH " ) . ignore ( pos , expected ) ) <nl> - function_name = " toIntervalMonth " ; <nl> - else if ( ParserKeyword ( " QUARTER " ) . ignore ( pos , expected ) ) <nl> - function_name = " toIntervalQuarter " ; <nl> - else if ( ParserKeyword ( " YEAR " ) . ignore ( pos , expected ) ) <nl> - function_name = " toIntervalYear " ; <nl> - else <nl> + ParserInterval interval_parser ; <nl> + if ( ! interval_parser . ignore ( pos , expected ) ) <nl> return false ; <nl> <nl> + switch ( interval_parser . interval_kind ) <nl> + { <nl> + case ParserInterval : : IntervalKind : : Second : <nl> + function_name = " toIntervalSecond " ; <nl> + break ; <nl> + case ParserInterval : : IntervalKind : : Minute : <nl> + function_name = " toIntervalMinute " ; <nl> + break ; <nl> + case ParserInterval : : IntervalKind : : Hour : <nl> + function_name = " toIntervalHour " ; <nl> + break ; <nl> + case ParserInterval : : IntervalKind : : Day : <nl> + function_name = " toIntervalDay " ; <nl> + break ; <nl> + case ParserInterval : : IntervalKind : : Week : <nl> + function_name = " toIntervalWeek " ; <nl> + break ; <nl> + case ParserInterval : : IntervalKind : : Month : <nl> + function_name = " toIntervalMonth " ; <nl> + break ; <nl> + case ParserInterval : : IntervalKind : : Quarter : <nl> + function_name = " toIntervalQuarter " ; <nl> + break ; <nl> + case ParserInterval : : IntervalKind : : Year : <nl> + function_name = " toIntervalYear " ; <nl> + break ; <nl> + default : <nl> + return false ; <nl> + } <nl> / / / the function corresponding to the operator <nl> auto function = std : : make_shared < ASTFunction > ( ) ; <nl> <nl> mmm a / dbms / tests / queries / 0_stateless / 00619_extract . sql <nl> ppp b / dbms / tests / queries / 0_stateless / 00619_extract . sql <nl> SELECT EXTRACT ( year FROM toDateTime ( ' 2017 - 12 - 31 18 : 59 : 58 ' ) ) ; <nl> DROP TABLE IF EXISTS test . Orders ; <nl> CREATE TABLE test . Orders ( OrderId UInt64 , OrderName String , OrderDate DateTime ) engine = Log ; <nl> insert into test . Orders values ( 1 , ' Jarlsberg Cheese ' , toDateTime ( ' 2008 - 10 - 11 13 : 23 : 44 ' ) ) ; <nl> - SELECT EXTRACT ( YEAR FROM OrderDate ) AS OrderYear , EXTRACT ( MONTH FROM OrderDate ) AS OrderMonth , EXTRACT ( DAY FROM OrderDate ) AS OrderDay , <nl> + SELECT EXTRACT ( YYYY FROM OrderDate ) AS OrderYear , EXTRACT ( MONTH FROM OrderDate ) AS OrderMonth , EXTRACT ( DAY FROM OrderDate ) AS OrderDay , <nl> EXTRACT ( HOUR FROM OrderDate ) , EXTRACT ( MINUTE FROM OrderDate ) , EXTRACT ( SECOND FROM OrderDate ) FROM test . Orders WHERE OrderId = 1 ; <nl> DROP TABLE test . Orders ; <nl> <nl>
Introduce common parser for interval kind names and use it for DATE_DIFF , EXTRACT and INTERVAL ( allows to use same set of aliases in them )
ClickHouse/ClickHouse
f88b4975556066c5089a0802f826bee0770e311e
2018-12-19T10:27:07Z
mmm a / src / core / ext / transport / chttp2 / transport / chttp2_transport . cc <nl> ppp b / src / core / ext / transport / chttp2 / transport / chttp2_transport . cc <nl> bool g_flow_control_enabled = true ; <nl> static void destruct_transport ( grpc_chttp2_transport * t ) { <nl> size_t i ; <nl> <nl> + if ( t - > channelz_socket ! = nullptr ) { <nl> + t - > channelz_socket . reset ( ) ; <nl> + } <nl> + <nl> grpc_endpoint_destroy ( t - > ep ) ; <nl> <nl> grpc_slice_buffer_destroy_internal ( & t - > qbuf ) ; <nl>
fix asan
grpc/grpc
805b8db33ced4888b325fdaf8980afdb7c155769
2018-09-25T05:07:56Z
mmm a / xbmc / filesystem / HTTPDirectory . cpp <nl> ppp b / xbmc / filesystem / HTTPDirectory . cpp <nl> bool CHTTPDirectory : : GetDirectory ( const CStdString & strPath , CFileItemList & item <nl> if ( ! pItem - > m_bIsFolder & & pItem - > m_dwSize = = 0 ) <nl> { <nl> CRegExp reSize ; <nl> - reSize . RegComp ( " > ( [ 0 - 9 . ] + ) ( K | M | G ) < / td > " ) ; <nl> + reSize . RegComp ( " > * ( [ 0 - 9 . ] + ) ( K | M | G ) < / td > " ) ; <nl> if ( reSize . RegFind ( strBuffer . c_str ( ) ) > = 0 ) <nl> { <nl> double Size = atof ( reSize . GetReplaceString ( " \ \ 1 " ) ) ; <nl>
fixed : missing HTTPDirectory filesizes in some circumstances
xbmc/xbmc
cfc85fb8569c288249242ca1003c9b8a7e30df72
2011-12-08T20:58:43Z
mmm a / src / mongo / db / commands / fsync . cpp <nl> ppp b / src / mongo / db / commands / fsync . cpp <nl> void FSyncLockThread : : run ( ) { <nl> fsyncCmd . acquireFsyncLockSyncCV . notify_one ( ) ; <nl> <nl> while ( fsyncCmd . getLockCount_inLock ( ) > 0 ) { <nl> - fsyncCmd . releaseFsyncLockSyncCV . wait ( lk ) ; <nl> + warning ( ) < < " WARNING : instance is locked , blocking all writes . The fsync command has " <nl> + " finished execution , remember to unlock the instance using fsyncUnlock ( ) . " ; <nl> + fsyncCmd . releaseFsyncLockSyncCV . wait_for ( lk , Seconds ( 60 ) . toSystemDuration ( ) ) ; <nl> } <nl> <nl> if ( successfulFsyncLock ) { <nl>
SERVER - 14396 Issue periodic warnings to the log while instance is locked
mongodb/mongo
29db842551e2c032567406be94ba6575b5f997e2
2019-05-08T13:12:16Z
new file mode 100644 <nl> index 00000000000 . . 2bfb7131bb3 <nl> mmm / dev / null <nl> ppp b / hphp / hack / hhi / stdlib / builtins_exit . idl . hhi <nl> <nl> + < ? hh / / decl <nl> + / * * <nl> + * Copyright ( c ) 2014 , Facebook , Inc . <nl> + * All rights reserved . <nl> + * <nl> + * This source code is licensed under the BSD - style license found in the <nl> + * LICENSE file in the " hack " directory of this source tree . An additional grant <nl> + * of patent rights can be found in the PATENTS file in the same directory . <nl> + * <nl> + * / <nl> + function exit ( $ status = 0 ) { } <nl>
provide support for exit as a function
facebook/hhvm
7475ff9d914d488ede28d9cd5887c0fd20a8b21e
2014-05-13T22:54:29Z
mmm a / tensorflow / core / kernels / extract_image_patches_op . cc <nl> ppp b / tensorflow / core / kernels / extract_image_patches_op . cc <nl> TF_CALL_REAL_NUMBER_TYPES ( REGISTER ) ; <nl> <nl> # undef REGISTER <nl> <nl> - # if GOOGLE_CUDA <nl> + # if GOOGLE_CUDA | | TENSORFLOW_USE_ROCM <nl> <nl> / / Forward declarations of the functor specializations for GPU . <nl> namespace functor { <nl> TF_CALL_GPU_NUMBER_TYPES ( REGISTER ) ; <nl> <nl> # undef REGISTER <nl> <nl> - # endif / / GOOGLE_CUDA <nl> + # endif / / GOOGLE_CUDA | | TENSORFLOW_USE_ROCM <nl> <nl> } / / namespace tensorflow <nl> mmm a / tensorflow / core / kernels / extract_image_patches_op_gpu . cu . cc <nl> ppp b / tensorflow / core / kernels / extract_image_patches_op_gpu . cu . cc <nl> See the License for the specific language governing permissions and <nl> limitations under the License . <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> <nl> - # if GOOGLE_CUDA <nl> + # if GOOGLE_CUDA | | TENSORFLOW_USE_ROCM <nl> <nl> # define EIGEN_USE_GPU <nl> <nl> TF_CALL_GPU_NUMBER_TYPES ( REGISTER ) ; <nl> } / / end namespace functor <nl> } / / end namespace tensorflow <nl> <nl> - # endif / / GOOGLE_CUDA <nl> + # endif / / GOOGLE_CUDA | | TENSORFLOW_USE_ROCM <nl>
Merge pull request from ROCmSoftwarePlatform : google_upstream_extract_image_patches_op
tensorflow/tensorflow
14fbe25f3e929ab67de806c857de0d5021b6621d
2019-03-19T23:49:18Z
mmm a / README . md <nl> ppp b / README . md <nl> LeetCode <nl> <nl> | # | Title | Solution | Difficulty | <nl> | mmm | mmm - - | mmmmmm - - | mmmmmmmmm - | <nl> + | 392 | [ Is Subsequence ] ( https : / / leetcode . com / problems / is - subsequence / ) | [ C + + ] ( . / algorithms / cpp / isSubsequence / IsSubsequence . cpp ) | Medium | <nl> | 391 | [ Perfect Rectangle ] ( https : / / leetcode . com / problems / perfect - rectangle / ) | [ C + + ] ( . / algorithms / cpp / perfectRectangle / PerfectRectangle . cpp ) | Hard | <nl> | 390 | [ Elimination Game ] ( https : / / leetcode . com / contest / 2 / problems / elimination - game / ) | [ C + + ] ( . / algorithms / cpp / eliminationGame / EliminationGame . cpp ) | Medium | <nl> | 389 | [ Find the Difference ] ( https : / / leetcode . com / problems / find - the - difference / ) | [ C + + ] ( . / algorithms / cpp / findTheDifference / FindTheDifference . cpp ) | Easy | <nl> new file mode 100644 <nl> index 00000000 . . e2cd8837 <nl> mmm / dev / null <nl> ppp b / algorithms / cpp / isSubsequence / IsSubsequence . cpp <nl> <nl> + / / Source : https : / / leetcode . com / problems / is - subsequence / <nl> + / / Author : Hao Chen <nl> + / / Date : 2016 - 09 - 08 <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * <nl> + * Given a string s and a string t , check if s is subsequence of t . <nl> + * <nl> + * You may assume that there is only lower case English letters in both s and t . t is <nl> + * potentially a very long ( length ~ = 500 , 000 ) string , and s is a short string ( <nl> + * <nl> + * A subsequence of a string is a new string which is formed from the original string <nl> + * by deleting some ( can be none ) of the characters without disturbing the relative <nl> + * positions of the remaining characters . ( ie , " ace " is a subsequence of " abcde " while <nl> + * " aec " is not ) . <nl> + * <nl> + * Example 1 : <nl> + * s = " abc " , t = " ahbgdc " <nl> + * <nl> + * Return true . <nl> + * <nl> + * Example 2 : <nl> + * s = " axc " , t = " ahbgdc " <nl> + * <nl> + * Return false . <nl> + * <nl> + * Follow up : <nl> + * If there are lots of incoming S , say S1 , S2 , . . . , Sk where k > = 1B , and you want to <nl> + * check one by one to see if T has its subsequence . In this scenario , how would you <nl> + * change your code ? <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + class Solution { <nl> + public : <nl> + bool isSubsequence ( string s , string t ) { <nl> + if ( s . size ( ) < = 0 ) return true ; <nl> + <nl> + int ps = 0 , pt = 0 ; <nl> + while ( pt < t . size ( ) ) { <nl> + if ( s [ ps ] = = t [ pt ] ) { <nl> + ps + + ; pt + + ; <nl> + if ( ps > = s . size ( ) ) return true ; <nl> + } else { <nl> + pt + + ; <nl> + } <nl> + } <nl> + <nl> + return false ; <nl> + } <nl> + } ; <nl>
New Problem " Is Subsequence "
haoel/leetcode
638bc71b7f27518e049c0b44cc3421949385b8ca
2016-09-07T17:42:00Z
mmm a / CHANGELOG . md <nl> ppp b / CHANGELOG . md <nl> Swift Next <nl> print ( s [ 0 ] ) <nl> ` ` ` <nl> <nl> + * * Add new entries to the top of this section , not here ! * * <nl> + <nl> Swift 5 . 1 <nl> mmmmmmmmm <nl> <nl> Swift 5 . 1 <nl> Code that calls the function can use the interface of the protocol , but <nl> does not have visibility into the underlying type . <nl> <nl> - * [ SE - 0256 ] [ ] : <nl> + * [ SE - 0254 ] [ ] : <nl> <nl> Subscripts can now be declared ` static ` or ( inside classes ) ` class ` . <nl> <nl> Swift 5 . 1 <nl> Swift 5 . 0 <nl> mmmmmmmmm <nl> <nl> + # # # 2019 - 03 - 25 ( Xcode 10 . 2 ) <nl> + <nl> * [ SE - 0235 ] [ ] : <nl> <nl> The standard library now contains a ` Result ` type for manually propagating errors . <nl> Swift 5 . 0 <nl> } <nl> ` ` ` <nl> <nl> - * * Add new entries to the top of this section , not here ! * * <nl> - <nl> Swift 4 . 2 <nl> mmmmmmmmm <nl> <nl> Swift 1 . 0 <nl> [ SE - 0230 ] : < https : / / github . com / apple / swift - evolution / blob / master / proposals / 0230 - flatten - optional - try . md > <nl> [ SE - 0235 ] : < https : / / github . com / apple / swift - evolution / blob / master / proposals / 0235 - add - result . md > <nl> [ SE - 0242 ] : < https : / / github . com / apple / swift - evolution / blob / master / proposals / 0242 - default - values - memberwise . md > <nl> + [ SE - 0244 ] : < https : / / github . com / apple / swift - evolution / blob / master / proposals / 0244 - opaque - result - types . md > <nl> [ SE - 0245 ] : < https : / / github . com / apple / swift - evolution / blob / master / proposals / 0245 - array - uninitialized - initializer . md > <nl> + [ SE - 0252 ] : < https : / / github . com / apple / swift - evolution / blob / master / proposals / 0252 - keypath - dynamic - member - lookup . md > <nl> + [ SE - 0254 ] : < https : / / github . com / apple / swift - evolution / blob / master / proposals / 0254 - static - subscripts . md > <nl> <nl> [ SR - 106 ] : < https : / / bugs . swift . org / browse / SR - 106 > <nl> [ SR - 419 ] : < https : / / bugs . swift . org / browse / SR - 419 > <nl> Swift 1 . 0 <nl> [ SR - 4248 ] : < https : / / bugs . swift . org / browse / SR - 4248 > <nl> [ SR - 5581 ] : < https : / / bugs . swift . org / browse / SR - 5581 > <nl> [ SR - 5719 ] : < https : / / bugs . swift . org / browse / SR - 5719 > <nl> + [ SR - 6118 ] : < https : / / bugs . swift . org / browse / SR - 6118 > <nl> [ SR - 7139 ] : < https : / / bugs . swift . org / browse / SR - 7139 > <nl> [ SR - 7251 ] : < https : / / bugs . swift . org / browse / SR - 7251 > <nl> [ SR - 7601 ] : < https : / / bugs . swift . org / browse / SR - 7601 > <nl>
Merge pull request from benrimmington / patch - 1
apple/swift
5c941e0e2168132c3a8f2455ef4ed857adc6c71e
2019-04-20T00:57:18Z
mmm a / plugins / wallet_plugin / wallet_manager . cpp <nl> ppp b / plugins / wallet_plugin / wallet_manager . cpp <nl> void wallet_manager : : set_timeout ( const std : : chrono : : seconds & t ) { <nl> timeout = t ; <nl> auto now = std : : chrono : : system_clock : : now ( ) ; <nl> timeout_time = now + timeout ; <nl> - EOS_ASSERT ( timeout_time > = now , invalid_lock_timeout_exception , " Overflow on timeout_time , specified $ { t } , now $ { now } , timeout_time $ { timeout_time } " , <nl> + EOS_ASSERT ( timeout_time > = now & & timeout_time . time_since_epoch ( ) . count ( ) > 0 , invalid_lock_timeout_exception , " Overflow on timeout_time , specified $ { t } , now $ { now } , timeout_time $ { timeout_time } " , <nl> ( " t " , t . count ( ) ) ( " now " , now . time_since_epoch ( ) . count ( ) ) ( " timeout_time " , timeout_time . time_since_epoch ( ) . count ( ) ) ) ; <nl> } <nl> <nl>
Merge pull request from EugeneChung / patch - 1
EOSIO/eos
b95ad0a216aaad980bed3c4ae21c395aa04908ab
2018-09-14T19:08:17Z
new file mode 100644 <nl> index 000000000000 . . 5150fbe1c724 <nl> mmm / dev / null <nl> ppp b / doc / release - notes - 19133 . md <nl> <nl> + # # CLI <nl> + <nl> + A new ` bitcoin - cli - generate ` command , equivalent to RPC ` generatenewaddress ` <nl> + followed by ` generatetoaddress ` , can generate blocks for command line testing <nl> + purposes . This is a client - side version of the <nl> + [ former ] ( https : / / github . com / bitcoin / bitcoin / issues / 14299 ) ` generate ` RPC . See <nl> + the help for details . ( # 19133 ) <nl>
Merge : doc : add release note for bitcoin - cli - generate
bitcoin/bitcoin
205b87d2f6bd01285de50ba742e32e4ab1298b13
2020-06-24T12:21:34Z
mmm a / ports / ecsutil / CONTROL <nl> ppp b / ports / ecsutil / CONTROL <nl> <nl> Source : ecsutil <nl> - Version : 0 . 9 . 0 . 6 <nl> + Version : 0 . 9 . 0 . 7 <nl> Description : Native Windows SDK for accessing ECS via the S3 HTTP protocol . <nl> mmm a / ports / ecsutil / portfile . cmake <nl> ppp b / ports / ecsutil / portfile . cmake <nl> <nl> <nl> include ( vcpkg_common_functions ) <nl> <nl> - set ( ECSUTIL_VERSION " 0 . 9 . 0 . 6 " ) <nl> - set ( ECSUtil_HASH 5c609275a1f7b4d31890a63fd2a19b4abb8e3aeaef09bd0e8617f50a2922564f68461c6cf7d0f044a2e3749ebe549cd47fed5852193f1763748d7e4c2bd763da ) <nl> + set ( ECSUTIL_VERSION " 0 . 9 . 0 . 7 " ) <nl> + set ( ECSUtil_HASH f3f28c12f959dbbd8d4413bb4e7cca26933677d87078faf995a7db92d78fba51300d901b376a2ff2633fb0b02af6a46654e042afa5e24f14a2ace3b7ec205468 ) <nl> set ( SOURCE_PATH $ { CURRENT_BUILDTREES_DIR } / src ) <nl> <nl> # architecture detection <nl>
ECSUtil 0 . 9 . 0 . 7
microsoft/vcpkg
fb4feebf73081fbda1130beade099c3c192765b1
2018-07-02T18:55:42Z
mmm a / dbms / include / DB / Storages / MergeTree / ReplicatedMergeTreePartCheckThread . h <nl> ppp b / dbms / include / DB / Storages / MergeTree / ReplicatedMergeTreePartCheckThread . h <nl> class ReplicatedMergeTreePartCheckThread <nl> } <nl> } ; <nl> <nl> - TemporarilyStop temporarilyStop ( ) { return std : : move ( TemporarilyStop ( this ) ) ; } <nl> + TemporarilyStop temporarilyStop ( ) { return TemporarilyStop ( this ) ; } <nl> <nl> / / / Добавить кусок ( для которого есть подозрения , что он отсутствует , повреждён или не нужен ) в очередь для проверки . <nl> / / / delay_to_check_seconds - проверять не раньше чем через указанное количество секунд . <nl> mmm a / dbms / src / ODBC / ResultSet . h <nl> ppp b / dbms / src / ODBC / ResultSet . h <nl> class ResultSet <nl> + + rows ; <nl> const Row & row = * iterator ; <nl> + + iterator ; <nl> - return std : : move ( row ) ; <nl> + return row ; <nl> } <nl> <nl> private : <nl> mmm a / dbms / src / Storages / StorageLog . cpp <nl> ppp b / dbms / src / Storages / StorageLog . cpp <nl> class LogBlockInputStream : public IProfilingBlockInputStream <nl> mark_number ( mark_number_ ) , <nl> null_mark_number ( 0 ) , <nl> rows_limit ( rows_limit_ ) , <nl> - current_mark ( mark_number_ ) , <nl> max_read_buffer_size ( max_read_buffer_size_ ) <nl> { <nl> } <nl> class LogBlockInputStream : public IProfilingBlockInputStream <nl> mark_number ( mark_number_ ) , <nl> null_mark_number ( null_mark_number_ ) , <nl> rows_limit ( rows_limit_ ) , <nl> - current_mark ( mark_number_ ) , <nl> max_read_buffer_size ( max_read_buffer_size_ ) <nl> { <nl> } <nl> class LogBlockInputStream : public IProfilingBlockInputStream <nl> size_t null_mark_number ; <nl> size_t rows_limit ; / / / Максимальное количество строк , которых можно прочитать <nl> size_t rows_read = 0 ; <nl> - size_t current_mark ; <nl> size_t max_read_buffer_size ; <nl> <nl> struct Stream <nl>
Fixed build on clang [ # METR - 2944 ] .
ClickHouse/ClickHouse
e2ed20999cb81046900a634d5ad4eceebc0809be
2016-12-12T05:53:37Z
mmm a / . travis . yml <nl> ppp b / . travis . yml <nl> jobs : <nl> FILE_ENV = " . / ci / test / 00_setup_env_mac . sh " <nl> <nl> - stage : test <nl> - name : ' macOS 10 . 14 native [ GOAL : install ] [ GUI : BIP70 enabled ] [ no depends ] ' <nl> + name : ' macOS 10 . 14 native [ GOAL : install ] [ GUI ] [ no depends ] ' <nl> os : osx <nl> # Use the most recent version : <nl> # Xcode 11 , macOS 10 . 14 , JDK 12 . 0 . 1 <nl> mmm a / ci / test / 00_setup_env_mac_host . sh <nl> ppp b / ci / test / 00_setup_env_mac_host . sh <nl> <nl> export LC_ALL = C . UTF - 8 <nl> <nl> export HOST = x86_64 - apple - darwin14 <nl> - export BREW_PACKAGES = " automake berkeley - db4 libtool boost miniupnpc pkg - config protobuf qt qrencode python3 ccache zeromq " <nl> + export BREW_PACKAGES = " automake berkeley - db4 libtool boost miniupnpc pkg - config qt qrencode python3 ccache zeromq " <nl> export PIP_PACKAGES = " zmq " <nl> export RUN_CI_ON_HOST = true <nl> export RUN_UNIT_TESTS = true <nl> export RUN_FUNCTIONAL_TESTS = false <nl> export GOAL = " install " <nl> - export BITCOIN_CONFIG = " - - enable - gui - - enable - bip70 - - enable - reduce - exports - - enable - werror " <nl> + export BITCOIN_CONFIG = " - - enable - gui - - enable - reduce - exports - - enable - werror " <nl> # Run without depends <nl> export NO_DEPENDS = 1 <nl> export OSX_SDK = " " <nl> mmm a / configure . ac <nl> ppp b / configure . ac <nl> AC_ARG_ENABLE ( [ zmq ] , <nl> [ disable ZMQ notifications ] ) ] , <nl> [ use_zmq = $ enableval ] , <nl> [ use_zmq = yes ] ) <nl> + <nl> AC_ARG_ENABLE ( [ bip70 ] , <nl> [ AS_HELP_STRING ( [ - - enable - bip70 ] , <nl> - [ enable BIP70 ( payment protocol ) support in the GUI ( default is to disable ) ] ) ] , <nl> + [ BIP70 ( payment protocol ) support in the GUI ( no longer supported ) ] ) ] , <nl> [ enable_bip70 = $ enableval ] , <nl> [ enable_bip70 = no ] ) <nl> <nl> - AC_ARG_WITH ( [ protoc - bindir ] , [ AS_HELP_STRING ( [ - - with - protoc - bindir = BIN_DIR ] , [ specify protoc bin path ] ) ] , [ protoc_bin_path = $ withval ] , [ ] ) <nl> + if test x $ enable_bip70 ! = xno ; then <nl> + AC_MSG_ERROR ( [ BIP70 is no longer supported ! ] ) <nl> + fi <nl> <nl> AC_ARG_ENABLE ( man , <nl> [ AS_HELP_STRING ( [ - - disable - man ] , <nl> if test x $ use_pkgconfig = xyes ; then <nl> [ <nl> PKG_CHECK_MODULES ( [ SSL ] , [ libssl ] , , [ AC_MSG_ERROR ( openssl not found . ) ] ) <nl> PKG_CHECK_MODULES ( [ CRYPTO ] , [ libcrypto ] , , [ AC_MSG_ERROR ( libcrypto not found . ) ] ) <nl> - if test x $ enable_bip70 ! = xno ; then <nl> - BITCOIN_QT_CHECK ( [ PKG_CHECK_MODULES ( [ PROTOBUF ] , [ protobuf ] , [ have_protobuf = yes ] , [ have_protobuf = no ] ) ] ) <nl> - fi <nl> if test x $ use_qr ! = xno ; then <nl> BITCOIN_QT_CHECK ( [ PKG_CHECK_MODULES ( [ QR ] , [ libqrencode ] , [ have_qrencode = yes ] , [ have_qrencode = no ] ) ] ) <nl> fi <nl> else <nl> esac <nl> fi <nl> <nl> - if test x $ enable_bip70 ! = xno ; then <nl> - BITCOIN_QT_CHECK ( AC_CHECK_LIB ( [ protobuf ] , [ main ] , [ PROTOBUF_LIBS = - lprotobuf ] , [ have_protobuf = no ] ) ) <nl> - fi <nl> if test x $ use_qr ! = xno ; then <nl> BITCOIN_QT_CHECK ( [ AC_CHECK_LIB ( [ qrencode ] , [ main ] , [ QR_LIBS = - lqrencode ] , [ have_qrencode = no ] ) ] ) <nl> BITCOIN_QT_CHECK ( [ AC_CHECK_HEADER ( [ qrencode . h ] , , have_qrencode = no ) ] ) <nl> AM_CONDITIONAL ( [ EMBEDDED_UNIVALUE ] , [ test x $ need_bundled_univalue = xyes ] ) <nl> AC_SUBST ( UNIVALUE_CFLAGS ) <nl> AC_SUBST ( UNIVALUE_LIBS ) <nl> <nl> - <nl> - if test x $ have_protobuf ! = xno & & <nl> - test x $ enable_bip70 ! = xno ; then <nl> - BITCOIN_QT_PATH_PROGS ( [ PROTOC ] , [ protoc ] , $ protoc_bin_path ) <nl> - fi <nl> - <nl> AC_MSG_CHECKING ( [ whether to build bitcoind ] ) <nl> AM_CONDITIONAL ( [ BUILD_BITCOIND ] , [ test x $ build_bitcoind = xyes ] ) <nl> AC_MSG_RESULT ( $ build_bitcoind ) <nl> if test x $ bitcoin_enable_qt ! = xno ; then <nl> else <nl> AC_MSG_RESULT ( [ no ] ) <nl> fi <nl> - <nl> - AC_MSG_CHECKING ( [ whether to build BIP70 support ] ) <nl> - if test x $ have_protobuf = xno ; then <nl> - if test x $ enable_bip70 = xyes ; then <nl> - AC_MSG_ERROR ( protobuf missing ) <nl> - fi <nl> - enable_bip70 = no <nl> - AC_MSG_RESULT ( no ) <nl> - else <nl> - if test x $ enable_bip70 ! = xno ; then <nl> - AC_DEFINE ( [ ENABLE_BIP70 ] , [ 1 ] , [ Define if BIP70 support should be compiled in ] ) <nl> - enable_bip70 = yes <nl> - AC_MSG_RESULT ( [ yes ] ) <nl> - else <nl> - AC_MSG_RESULT ( [ no ] ) <nl> - fi <nl> - fi <nl> fi <nl> <nl> AM_CONDITIONAL ( [ ENABLE_ZMQ ] , [ test " x $ use_zmq " = " xyes " ] ) <nl> AM_CONDITIONAL ( [ ENABLE_TESTS ] , [ test x $ BUILD_TEST = xyes ] ) <nl> AM_CONDITIONAL ( [ ENABLE_FUZZ ] , [ test x $ enable_fuzz = xyes ] ) <nl> AM_CONDITIONAL ( [ ENABLE_QT ] , [ test x $ bitcoin_enable_qt = xyes ] ) <nl> AM_CONDITIONAL ( [ ENABLE_QT_TESTS ] , [ test x $ BUILD_TEST_QT = xyes ] ) <nl> - AM_CONDITIONAL ( [ ENABLE_BIP70 ] , [ test x $ enable_bip70 = xyes ] ) <nl> AM_CONDITIONAL ( [ ENABLE_BENCH ] , [ test x $ use_bench = xyes ] ) <nl> AM_CONDITIONAL ( [ USE_QRCODE ] , [ test x $ use_qr = xyes ] ) <nl> AM_CONDITIONAL ( [ USE_LCOV ] , [ test x $ use_lcov = xyes ] ) <nl> AC_SUBST ( SSL_LIBS ) <nl> AC_SUBST ( EVENT_LIBS ) <nl> AC_SUBST ( EVENT_PTHREADS_LIBS ) <nl> AC_SUBST ( ZMQ_LIBS ) <nl> - AC_SUBST ( PROTOBUF_LIBS ) <nl> AC_SUBST ( QR_LIBS ) <nl> AC_CONFIG_FILES ( [ Makefile src / Makefile doc / man / Makefile share / setup . nsi share / qt / Info . plist test / config . ini ] ) <nl> AC_CONFIG_FILES ( [ contrib / devtools / split - debug . sh ] , [ chmod + x contrib / devtools / split - debug . sh ] ) <nl> echo " Options used to compile and link : " <nl> echo " with wallet = $ enable_wallet " <nl> echo " with gui / qt = $ bitcoin_enable_qt " <nl> if test x $ bitcoin_enable_qt ! = xno ; then <nl> - echo " with bip70 = $ enable_bip70 " <nl> echo " with qr = $ use_qr " <nl> fi <nl> echo " with zmq = $ use_zmq " <nl> mmm a / contrib / bitcoind . bash - completion <nl> ppp b / contrib / bitcoind . bash - completion <nl> _bitcoind ( ) { <nl> _get_comp_words_by_ref - n = cur prev words cword <nl> <nl> case " $ cur " in <nl> - - conf = * | - pid = * | - loadblock = * | - rootcertificates = * | - rpccookiefile = * | - wallet = * ) <nl> + - conf = * | - pid = * | - loadblock = * | - rpccookiefile = * | - wallet = * ) <nl> cur = " $ { cur # * = } " <nl> _filedir <nl> return 0 <nl> mmm a / src / Makefile . am <nl> ppp b / src / Makefile . am <nl> if HARDEN <nl> $ ( AM_V_at ) READELF = $ ( READELF ) OBJDUMP = $ ( OBJDUMP ) $ ( PYTHON ) $ ( top_srcdir ) / contrib / devtools / security - check . py < $ ( bin_PROGRAMS ) <nl> endif <nl> <nl> - if ENABLE_BIP70 <nl> - % . pb . cc % . pb . h : % . proto <nl> - @ test - f $ ( PROTOC ) <nl> - $ ( AM_V_GEN ) $ ( PROTOC ) - - cpp_out = $ ( @ D ) - - proto_path = $ ( < D ) $ < <nl> - endif <nl> - <nl> if EMBEDDED_LEVELDB <nl> include Makefile . leveldb . include <nl> endif <nl> mmm a / src / Makefile . qt . include <nl> ppp b / src / Makefile . qt . include <nl> QT_QRC = qt / bitcoin . qrc <nl> QT_QRC_LOCALE_CPP = qt / qrc_bitcoin_locale . cpp <nl> QT_QRC_LOCALE = qt / bitcoin_locale . qrc <nl> <nl> - if ENABLE_BIP70 <nl> - PROTOBUF_CC = qt / paymentrequest . pb . cc <nl> - PROTOBUF_H = qt / paymentrequest . pb . h <nl> - PROTOBUF_PROTO = qt / paymentrequest . proto <nl> - else <nl> - PROTOBUF_CC = <nl> - PROTOBUF_H = <nl> - PROTOBUF_PROTO = <nl> - endif <nl> - <nl> BITCOIN_QT_H = \ <nl> qt / addressbookpage . h \ <nl> qt / addresstablemodel . h \ <nl> BITCOIN_QT_H = \ <nl> qt / optionsdialog . h \ <nl> qt / optionsmodel . h \ <nl> qt / overviewpage . h \ <nl> - qt / paymentrequestplus . h \ <nl> qt / paymentserver . h \ <nl> qt / peertablemodel . h \ <nl> qt / platformstyle . h \ <nl> BITCOIN_QT_WALLET_CPP = \ <nl> qt / walletmodeltransaction . cpp \ <nl> qt / walletview . cpp <nl> <nl> - BITCOIN_QT_WALLET_BIP70_CPP = \ <nl> - qt / paymentrequestplus . cpp <nl> - <nl> BITCOIN_QT_CPP = $ ( BITCOIN_QT_BASE_CPP ) <nl> if TARGET_WINDOWS <nl> BITCOIN_QT_CPP + = $ ( BITCOIN_QT_WINDOWS_CPP ) <nl> endif <nl> if ENABLE_WALLET <nl> BITCOIN_QT_CPP + = $ ( BITCOIN_QT_WALLET_CPP ) <nl> - if ENABLE_BIP70 <nl> - BITCOIN_QT_CPP + = $ ( BITCOIN_QT_WALLET_BIP70_CPP ) <nl> - endif # ENABLE_BIP70 <nl> endif # ENABLE_WALLET <nl> <nl> RES_IMAGES = <nl> BITCOIN_RC = qt / res / bitcoin - qt - res . rc <nl> BITCOIN_QT_INCLUDES = - DQT_NO_KEYWORDS <nl> <nl> qt_libbitcoinqt_a_CPPFLAGS = $ ( AM_CPPFLAGS ) $ ( BITCOIN_INCLUDES ) $ ( BITCOIN_QT_INCLUDES ) \ <nl> - $ ( QT_INCLUDES ) $ ( QT_DBUS_INCLUDES ) $ ( PROTOBUF_CFLAGS ) $ ( QR_CFLAGS ) <nl> + $ ( QT_INCLUDES ) $ ( QT_DBUS_INCLUDES ) $ ( QR_CFLAGS ) <nl> qt_libbitcoinqt_a_CXXFLAGS = $ ( AM_CXXFLAGS ) $ ( QT_PIE_FLAGS ) <nl> qt_libbitcoinqt_a_OBJCXXFLAGS = $ ( AM_OBJCXXFLAGS ) $ ( QT_PIE_FLAGS ) <nl> <nl> qt_libbitcoinqt_a_SOURCES = $ ( BITCOIN_QT_CPP ) $ ( BITCOIN_QT_H ) $ ( QT_FORMS_UI ) \ <nl> - $ ( QT_QRC ) $ ( QT_QRC_LOCALE ) $ ( QT_TS ) $ ( PROTOBUF_PROTO ) $ ( RES_ICONS ) $ ( RES_IMAGES ) $ ( RES_MOVIES ) <nl> + $ ( QT_QRC ) $ ( QT_QRC_LOCALE ) $ ( QT_TS ) $ ( RES_ICONS ) $ ( RES_IMAGES ) $ ( RES_MOVIES ) <nl> if TARGET_DARWIN <nl> qt_libbitcoinqt_a_SOURCES + = $ ( BITCOIN_MM ) <nl> endif <nl> <nl> - nodist_qt_libbitcoinqt_a_SOURCES = $ ( QT_MOC_CPP ) $ ( QT_MOC ) $ ( PROTOBUF_CC ) \ <nl> - $ ( PROTOBUF_H ) $ ( QT_QRC_CPP ) $ ( QT_QRC_LOCALE_CPP ) <nl> + nodist_qt_libbitcoinqt_a_SOURCES = $ ( QT_MOC_CPP ) $ ( QT_MOC ) $ ( QT_QRC_CPP ) $ ( QT_QRC_LOCALE_CPP ) <nl> <nl> # forms / foo . h - > forms / ui_foo . h <nl> QT_FORMS_H = $ ( join $ ( dir $ ( QT_FORMS_UI ) ) , $ ( addprefix ui_ , $ ( notdir $ ( QT_FORMS_UI : . ui = . h ) ) ) ) <nl> QT_FORMS_H = $ ( join $ ( dir $ ( QT_FORMS_UI ) ) , $ ( addprefix ui_ , $ ( notdir $ ( QT_FORMS_UI : <nl> $ ( QT_MOC ) : $ ( QT_FORMS_H ) <nl> $ ( qt_libbitcoinqt_a_OBJECTS ) $ ( qt_bitcoin_qt_OBJECTS ) : | $ ( QT_MOC ) <nl> <nl> - # Generating these with a half - written protobuf header leads to wacky results . <nl> - # This makes sure it ' s done . <nl> - $ ( QT_MOC ) : $ ( PROTOBUF_H ) <nl> - $ ( QT_MOC_CPP ) : $ ( PROTOBUF_H ) <nl> - <nl> # bitcoin - qt binary # <nl> qt_bitcoin_qt_CPPFLAGS = $ ( AM_CPPFLAGS ) $ ( BITCOIN_INCLUDES ) $ ( BITCOIN_QT_INCLUDES ) \ <nl> - $ ( QT_INCLUDES ) $ ( PROTOBUF_CFLAGS ) $ ( QR_CFLAGS ) <nl> + $ ( QT_INCLUDES ) $ ( QR_CFLAGS ) <nl> qt_bitcoin_qt_CXXFLAGS = $ ( AM_CXXFLAGS ) $ ( QT_PIE_FLAGS ) <nl> <nl> qt_bitcoin_qt_SOURCES = qt / main . cpp <nl> if ENABLE_ZMQ <nl> qt_bitcoin_qt_LDADD + = $ ( LIBBITCOIN_ZMQ ) $ ( ZMQ_LIBS ) <nl> endif <nl> qt_bitcoin_qt_LDADD + = $ ( LIBBITCOIN_CLI ) $ ( LIBBITCOIN_COMMON ) $ ( LIBBITCOIN_UTIL ) $ ( LIBBITCOIN_CONSENSUS ) $ ( LIBBITCOIN_CRYPTO ) $ ( LIBUNIVALUE ) $ ( LIBLEVELDB ) $ ( LIBLEVELDB_SSE42 ) $ ( LIBMEMENV ) \ <nl> - $ ( BOOST_LIBS ) $ ( QT_LIBS ) $ ( QT_DBUS_LIBS ) $ ( QR_LIBS ) $ ( PROTOBUF_LIBS ) $ ( BDB_LIBS ) $ ( MINIUPNPC_LIBS ) $ ( LIBSECP256K1 ) \ <nl> + $ ( BOOST_LIBS ) $ ( QT_LIBS ) $ ( QT_DBUS_LIBS ) $ ( QR_LIBS ) $ ( BDB_LIBS ) $ ( MINIUPNPC_LIBS ) $ ( LIBSECP256K1 ) \ <nl> $ ( EVENT_PTHREADS_LIBS ) $ ( EVENT_LIBS ) <nl> - if ENABLE_BIP70 <nl> - qt_bitcoin_qt_LDADD + = $ ( SSL_LIBS ) <nl> - else <nl> - if TARGET_WINDOWS <nl> - qt_bitcoin_qt_LDADD + = $ ( SSL_LIBS ) <nl> - endif <nl> - endif <nl> qt_bitcoin_qt_LDADD + = $ ( CRYPTO_LIBS ) <nl> qt_bitcoin_qt_LDFLAGS = $ ( RELDFLAGS ) $ ( AM_LDFLAGS ) $ ( QT_LDFLAGS ) $ ( LIBTOOL_APP_LDFLAGS ) <nl> qt_bitcoin_qt_LIBTOOLFLAGS = $ ( AM_LIBTOOLFLAGS ) - - tag CXX <nl> $ ( QT_QRC_LOCALE_CPP ) : $ ( QT_QRC_LOCALE ) $ ( QT_QM ) <nl> $ ( SED ) - e ' / ^ \ * \ * . * Created : / d ' - e ' / ^ \ * \ * . * by : / d ' > $ @ <nl> @ rm $ ( @ D ) / temp_ $ ( < F ) <nl> <nl> - $ ( QT_QRC_CPP ) : $ ( QT_QRC ) $ ( QT_FORMS_H ) $ ( RES_ICONS ) $ ( RES_IMAGES ) $ ( RES_MOVIES ) $ ( PROTOBUF_H ) <nl> + $ ( QT_QRC_CPP ) : $ ( QT_QRC ) $ ( QT_FORMS_H ) $ ( RES_ICONS ) $ ( RES_IMAGES ) $ ( RES_MOVIES ) <nl> @ test - f $ ( RCC ) <nl> $ ( AM_V_GEN ) QT_SELECT = $ ( QT_SELECT ) $ ( RCC ) - name bitcoin $ < | \ <nl> $ ( SED ) - e ' / ^ \ * \ * . * Created : / d ' - e ' / ^ \ * \ * . * by : / d ' > $ @ <nl> mmm a / src / Makefile . qttest . include <nl> ppp b / src / Makefile . qttest . include <nl> if ENABLE_WALLET <nl> TEST_QT_MOC_CPP + = \ <nl> qt / test / moc_addressbooktests . cpp \ <nl> qt / test / moc_wallettests . cpp <nl> - if ENABLE_BIP70 <nl> - TEST_QT_MOC_CPP + = \ <nl> - qt / test / moc_paymentservertests . cpp <nl> - endif # ENABLE_BIP70 <nl> endif # ENABLE_WALLET <nl> <nl> TEST_QT_H = \ <nl> TEST_QT_H = \ <nl> qt / test / rpcnestedtests . h \ <nl> qt / test / uritests . h \ <nl> qt / test / util . h \ <nl> - qt / test / paymentrequestdata . h \ <nl> - qt / test / paymentservertests . h \ <nl> qt / test / wallettests . h <nl> <nl> TEST_BITCOIN_CPP = \ <nl> TEST_BITCOIN_H = \ <nl> test / setup_common . h <nl> <nl> qt_test_test_bitcoin_qt_CPPFLAGS = $ ( AM_CPPFLAGS ) $ ( BITCOIN_INCLUDES ) $ ( BITCOIN_QT_INCLUDES ) \ <nl> - $ ( QT_INCLUDES ) $ ( QT_TEST_INCLUDES ) $ ( PROTOBUF_CFLAGS ) <nl> + $ ( QT_INCLUDES ) $ ( QT_TEST_INCLUDES ) <nl> <nl> qt_test_test_bitcoin_qt_SOURCES = \ <nl> qt / test / apptests . cpp \ <nl> qt_test_test_bitcoin_qt_SOURCES + = \ <nl> qt / test / addressbooktests . cpp \ <nl> qt / test / wallettests . cpp \ <nl> wallet / test / wallet_test_fixture . cpp <nl> - if ENABLE_BIP70 <nl> - qt_test_test_bitcoin_qt_SOURCES + = \ <nl> - qt / test / paymentservertests . cpp <nl> - endif # ENABLE_BIP70 <nl> endif # ENABLE_WALLET <nl> <nl> nodist_qt_test_test_bitcoin_qt_SOURCES = $ ( TEST_QT_MOC_CPP ) <nl> qt_test_test_bitcoin_qt_LDADD + = $ ( LIBBITCOIN_ZMQ ) $ ( ZMQ_LIBS ) <nl> endif <nl> qt_test_test_bitcoin_qt_LDADD + = $ ( LIBBITCOIN_CLI ) $ ( LIBBITCOIN_COMMON ) $ ( LIBBITCOIN_UTIL ) $ ( LIBBITCOIN_CONSENSUS ) $ ( LIBBITCOIN_CRYPTO ) $ ( LIBUNIVALUE ) $ ( LIBLEVELDB ) \ <nl> $ ( LIBLEVELDB_SSE42 ) $ ( LIBMEMENV ) $ ( BOOST_LIBS ) $ ( QT_DBUS_LIBS ) $ ( QT_TEST_LIBS ) $ ( QT_LIBS ) \ <nl> - $ ( QR_LIBS ) $ ( PROTOBUF_LIBS ) $ ( BDB_LIBS ) $ ( SSL_LIBS ) $ ( CRYPTO_LIBS ) $ ( MINIUPNPC_LIBS ) $ ( LIBSECP256K1 ) \ <nl> + $ ( QR_LIBS ) $ ( BDB_LIBS ) $ ( CRYPTO_LIBS ) $ ( MINIUPNPC_LIBS ) $ ( LIBSECP256K1 ) \ <nl> $ ( EVENT_PTHREADS_LIBS ) $ ( EVENT_LIBS ) <nl> qt_test_test_bitcoin_qt_LDFLAGS = $ ( RELDFLAGS ) $ ( AM_LDFLAGS ) $ ( QT_LDFLAGS ) $ ( LIBTOOL_APP_LDFLAGS ) <nl> qt_test_test_bitcoin_qt_CXXFLAGS = $ ( AM_CXXFLAGS ) $ ( QT_PIE_FLAGS ) <nl> mmm a / src / init . cpp <nl> ppp b / src / init . cpp <nl> void SetupServerArgs ( ) <nl> std : : vector < std : : string > hidden_args = { <nl> " - dbcrashratio " , " - forcecompactdb " , <nl> / / GUI args . These will be overwritten by SetupUIArgs for the GUI <nl> - " - allowselfsignedrootcertificates " , " - choosedatadir " , " - lang = < lang > " , " - min " , " - resetguisettings " , " - rootcertificates = < file > " , " - splash " , " - uiplatform " } ; <nl> + " - choosedatadir " , " - lang = < lang > " , " - min " , " - resetguisettings " , " - splash " , " - uiplatform " } ; <nl> <nl> gArgs . AddArg ( " - version " , " Print version and exit " , ArgsManager : : ALLOW_ANY , OptionsCategory : : OPTIONS ) ; <nl> # if HAVE_SYSTEM <nl> mmm a / src / qt / README . md <nl> ppp b / src / qt / README . md <nl> Various dialogs , e . g . to open a URL . Inherit from [ QDialog ] ( https : / / doc . qt . io / qt <nl> <nl> # # # paymentserver . ( h / cpp ) <nl> <nl> - Used to process BIP21 and BIP70 ( see https : / / github . com / bitcoin / bitcoin / pull / 11622 ) payment URI / requests . Also handles URI based application switching ( e . g . when following a bitcoin : . . . link from a browser ) . <nl> + Used to process BIP21 payment URI requests . Also handles URI based application switching ( e . g . when following a bitcoin : . . . link from a browser ) . <nl> <nl> # # # walletview . ( h / cpp ) <nl> <nl> mmm a / src / qt / bitcoin . cpp <nl> ppp b / src / qt / bitcoin . cpp <nl> void BitcoinApplication : : initializeResult ( bool success ) <nl> window - > setWalletController ( m_wallet_controller ) ; <nl> if ( paymentServer ) { <nl> paymentServer - > setOptionsModel ( optionsModel ) ; <nl> - # ifdef ENABLE_BIP70 <nl> - PaymentServer : : LoadRootCAs ( ) ; <nl> - connect ( m_wallet_controller , & WalletController : : coinsSent , paymentServer , & PaymentServer : : fetchPaymentACK ) ; <nl> - # endif <nl> } <nl> } <nl> # endif / / ENABLE_WALLET <nl> WId BitcoinApplication : : getMainWinId ( ) const <nl> <nl> static void SetupUIArgs ( ) <nl> { <nl> - # if defined ( ENABLE_WALLET ) & & defined ( ENABLE_BIP70 ) <nl> - gArgs . AddArg ( " - allowselfsignedrootcertificates " , strprintf ( " Allow self signed root certificates ( default : % u ) " , DEFAULT_SELFSIGNED_ROOTCERTS ) , ArgsManager : : ALLOW_ANY | ArgsManager : : DEBUG_ONLY , OptionsCategory : : GUI ) ; <nl> - # endif <nl> gArgs . AddArg ( " - choosedatadir " , strprintf ( " Choose data directory on startup ( default : % u ) " , DEFAULT_CHOOSE_DATADIR ) , ArgsManager : : ALLOW_ANY , OptionsCategory : : GUI ) ; <nl> gArgs . AddArg ( " - lang = < lang > " , " Set language , for example \ " de_DE \ " ( default : system locale ) " , ArgsManager : : ALLOW_ANY , OptionsCategory : : GUI ) ; <nl> gArgs . AddArg ( " - min " , " Start minimized " , ArgsManager : : ALLOW_ANY , OptionsCategory : : GUI ) ; <nl> gArgs . AddArg ( " - resetguisettings " , " Reset all settings changed in the GUI " , ArgsManager : : ALLOW_ANY , OptionsCategory : : GUI ) ; <nl> - gArgs . AddArg ( " - rootcertificates = < file > " , " Set SSL root certificates for payment request ( default : - system - ) " , ArgsManager : : ALLOW_ANY , OptionsCategory : : GUI ) ; <nl> gArgs . AddArg ( " - splash " , strprintf ( " Show splash screen on startup ( default : % u ) " , DEFAULT_SPLASHSCREEN ) , ArgsManager : : ALLOW_ANY , OptionsCategory : : GUI ) ; <nl> gArgs . AddArg ( " - uiplatform " , strprintf ( " Select platform to customize UI for ( one of windows , macosx , other ; default : % s ) " , BitcoinGUI : : DEFAULT_UIPLATFORM ) , ArgsManager : : ALLOW_ANY | ArgsManager : : DEBUG_ONLY , OptionsCategory : : GUI ) ; <nl> } <nl> mmm a / src / qt / optionsmodel . cpp <nl> ppp b / src / qt / optionsmodel . cpp <nl> <nl> # include < netbase . h > <nl> # include < txdb . h > / / for - dbcache defaults <nl> <nl> - # include < QNetworkProxy > <nl> + # include < QDebug > <nl> # include < QSettings > <nl> # include < QStringList > <nl> <nl> void OptionsModel : : setDisplayUnit ( const QVariant & value ) <nl> } <nl> } <nl> <nl> - bool OptionsModel : : getProxySettings ( QNetworkProxy & proxy ) const <nl> - { <nl> - / / Directly query current base proxy , because <nl> - / / GUI settings can be overridden with - proxy . <nl> - proxyType curProxy ; <nl> - if ( m_node . getProxy ( NET_IPV4 , curProxy ) ) { <nl> - proxy . setType ( QNetworkProxy : : Socks5Proxy ) ; <nl> - proxy . setHostName ( QString : : fromStdString ( curProxy . proxy . ToStringIP ( ) ) ) ; <nl> - proxy . setPort ( curProxy . proxy . GetPort ( ) ) ; <nl> - <nl> - return true ; <nl> - } <nl> - else <nl> - proxy . setType ( QNetworkProxy : : NoProxy ) ; <nl> - <nl> - return false ; <nl> - } <nl> - <nl> void OptionsModel : : setRestartRequired ( bool fRequired ) <nl> { <nl> QSettings settings ; <nl> mmm a / src / qt / optionsmodel . h <nl> ppp b / src / qt / optionsmodel . h <nl> namespace interfaces { <nl> class Node ; <nl> } <nl> <nl> - QT_BEGIN_NAMESPACE <nl> - class QNetworkProxy ; <nl> - QT_END_NAMESPACE <nl> - <nl> extern const char * DEFAULT_GUI_PROXY_HOST ; <nl> static constexpr unsigned short DEFAULT_GUI_PROXY_PORT = 9050 ; <nl> <nl> class OptionsModel : public QAbstractListModel <nl> bool getMinimizeOnClose ( ) const { return fMinimizeOnClose ; } <nl> int getDisplayUnit ( ) const { return nDisplayUnit ; } <nl> QString getThirdPartyTxUrls ( ) const { return strThirdPartyTxUrls ; } <nl> - bool getProxySettings ( QNetworkProxy & proxy ) const ; <nl> bool getCoinControlFeatures ( ) const { return fCoinControlFeatures ; } <nl> const QString & getOverriddenByCommandLine ( ) { return strOverriddenByCommandLine ; } <nl> <nl> deleted file mode 100644 <nl> index d2721a34bde8 . . 000000000000 <nl> mmm a / src / qt / paymentrequest . proto <nl> ppp / dev / null <nl> <nl> - / / <nl> - / / Simple Bitcoin Payment Protocol messages <nl> - / / <nl> - / / Use fields 100 + for extensions ; <nl> - / / to avoid conflicts , register extensions at : <nl> - / / https : / / en . bitcoin . it / wiki / Payment_Request <nl> - / / <nl> - <nl> - syntax = " proto2 " ; <nl> - <nl> - package payments ; <nl> - option java_package = " org . bitcoin . protocols . payments " ; <nl> - option java_outer_classname = " Protos " ; <nl> - <nl> - / / Generalized form of " send payment to this / these bitcoin addresses " <nl> - message Output { <nl> - optional uint64 amount = 1 [ default = 0 ] ; / / amount is integer - number - of - satoshis <nl> - required bytes script = 2 ; / / usually one of the standard Script forms <nl> - } <nl> - message PaymentDetails { <nl> - optional string network = 1 [ default = " main " ] ; / / " main " or " test " <nl> - repeated Output outputs = 2 ; / / Where payment should be sent <nl> - required uint64 time = 3 ; / / Timestamp ; when payment request created <nl> - optional uint64 expires = 4 ; / / Timestamp ; when this request should be considered invalid <nl> - optional string memo = 5 ; / / Human - readable description of request for the customer <nl> - optional string payment_url = 6 ; / / URL to send Payment and get PaymentACK <nl> - optional bytes merchant_data = 7 ; / / Arbitrary data to include in the Payment message <nl> - } <nl> - message PaymentRequest { <nl> - optional uint32 payment_details_version = 1 [ default = 1 ] ; <nl> - optional string pki_type = 2 [ default = " none " ] ; / / none / x509 + sha256 / x509 + sha1 <nl> - optional bytes pki_data = 3 ; / / depends on pki_type <nl> - required bytes serialized_payment_details = 4 ; / / PaymentDetails <nl> - optional bytes signature = 5 ; / / pki - dependent signature <nl> - } <nl> - message X509Certificates { <nl> - repeated bytes certificate = 1 ; / / DER - encoded X . 509 certificate chain <nl> - } <nl> - message Payment { <nl> - optional bytes merchant_data = 1 ; / / From PaymentDetails . merchant_data <nl> - repeated bytes transactions = 2 ; / / Signed transactions that satisfy PaymentDetails . outputs <nl> - repeated Output refund_to = 3 ; / / Where to send refunds , if a refund is necessary <nl> - optional string memo = 4 ; / / Human - readable message for the merchant <nl> - } <nl> - message PaymentACK { <nl> - required Payment payment = 1 ; / / Payment message that triggered this ACK <nl> - optional string memo = 2 ; / / human - readable message for customer <nl> - } <nl> deleted file mode 100644 <nl> index b962ab1ef210 . . 000000000000 <nl> mmm a / src / qt / paymentrequestplus . cpp <nl> ppp / dev / null <nl> <nl> - / / Copyright ( c ) 2011 - 2018 The Bitcoin Core developers <nl> - / / Distributed under the MIT software license , see the accompanying <nl> - / / file COPYING or http : / / www . opensource . org / licenses / mit - license . php . <nl> - <nl> - / / <nl> - / / Wraps dumb protocol buffer paymentRequest <nl> - / / with some extra methods <nl> - / / <nl> - <nl> - # include < qt / paymentrequestplus . h > <nl> - <nl> - # include < util / system . h > <nl> - <nl> - # include < stdexcept > <nl> - <nl> - # include < openssl / x509_vfy . h > <nl> - <nl> - # include < QDateTime > <nl> - # include < QDebug > <nl> - # include < QSslCertificate > <nl> - <nl> - class SSLVerifyError : public std : : runtime_error <nl> - { <nl> - public : <nl> - explicit SSLVerifyError ( std : : string err ) : std : : runtime_error ( err ) { } <nl> - } ; <nl> - <nl> - bool PaymentRequestPlus : : parse ( const QByteArray & data ) <nl> - { <nl> - bool parseOK = paymentRequest . ParseFromArray ( data . data ( ) , data . size ( ) ) ; <nl> - if ( ! parseOK ) { <nl> - qWarning ( ) < < " PaymentRequestPlus : : parse : Error parsing payment request " ; <nl> - return false ; <nl> - } <nl> - if ( paymentRequest . payment_details_version ( ) > 1 ) { <nl> - qWarning ( ) < < " PaymentRequestPlus : : parse : Received up - version payment details , version = " < < paymentRequest . payment_details_version ( ) ; <nl> - return false ; <nl> - } <nl> - <nl> - parseOK = details . ParseFromString ( paymentRequest . serialized_payment_details ( ) ) ; <nl> - if ( ! parseOK ) <nl> - { <nl> - qWarning ( ) < < " PaymentRequestPlus : : parse : Error parsing payment details " ; <nl> - paymentRequest . Clear ( ) ; <nl> - return false ; <nl> - } <nl> - return true ; <nl> - } <nl> - <nl> - bool PaymentRequestPlus : : SerializeToString ( std : : string * output ) const <nl> - { <nl> - return paymentRequest . SerializeToString ( output ) ; <nl> - } <nl> - <nl> - bool PaymentRequestPlus : : IsInitialized ( ) const <nl> - { <nl> - return paymentRequest . IsInitialized ( ) ; <nl> - } <nl> - <nl> - bool PaymentRequestPlus : : getMerchant ( X509_STORE * certStore , QString & merchant ) const <nl> - { <nl> - merchant . clear ( ) ; <nl> - <nl> - if ( ! IsInitialized ( ) ) <nl> - return false ; <nl> - <nl> - / / One day we ' ll support more PKI types , but just <nl> - / / x509 for now : <nl> - const EVP_MD * digestAlgorithm = nullptr ; <nl> - if ( paymentRequest . pki_type ( ) = = " x509 + sha256 " ) { <nl> - digestAlgorithm = EVP_sha256 ( ) ; <nl> - } <nl> - else if ( paymentRequest . pki_type ( ) = = " x509 + sha1 " ) { <nl> - digestAlgorithm = EVP_sha1 ( ) ; <nl> - } <nl> - else if ( paymentRequest . pki_type ( ) = = " none " ) { <nl> - qWarning ( ) < < " PaymentRequestPlus : : getMerchant : Payment request : pki_type = = none " ; <nl> - return false ; <nl> - } <nl> - else { <nl> - qWarning ( ) < < " PaymentRequestPlus : : getMerchant : Payment request : unknown pki_type " < < QString : : fromStdString ( paymentRequest . pki_type ( ) ) ; <nl> - return false ; <nl> - } <nl> - <nl> - payments : : X509Certificates certChain ; <nl> - if ( ! certChain . ParseFromString ( paymentRequest . pki_data ( ) ) ) { <nl> - qWarning ( ) < < " PaymentRequestPlus : : getMerchant : Payment request : error parsing pki_data " ; <nl> - return false ; <nl> - } <nl> - <nl> - std : : vector < X509 * > certs ; <nl> - const QDateTime currentTime = QDateTime : : currentDateTime ( ) ; <nl> - for ( int i = 0 ; i < certChain . certificate_size ( ) ; i + + ) { <nl> - QByteArray certData ( certChain . certificate ( i ) . data ( ) , certChain . certificate ( i ) . size ( ) ) ; <nl> - QSslCertificate qCert ( certData , QSsl : : Der ) ; <nl> - if ( currentTime < qCert . effectiveDate ( ) | | currentTime > qCert . expiryDate ( ) ) { <nl> - qWarning ( ) < < " PaymentRequestPlus : : getMerchant : Payment request : certificate expired or not yet active : " < < qCert ; <nl> - return false ; <nl> - } <nl> - if ( qCert . isBlacklisted ( ) ) { <nl> - qWarning ( ) < < " PaymentRequestPlus : : getMerchant : Payment request : certificate blacklisted : " < < qCert ; <nl> - return false ; <nl> - } <nl> - const unsigned char * data = ( const unsigned char * ) certChain . certificate ( i ) . data ( ) ; <nl> - X509 * cert = d2i_X509 ( nullptr , & data , certChain . certificate ( i ) . size ( ) ) ; <nl> - if ( cert ) <nl> - certs . push_back ( cert ) ; <nl> - } <nl> - if ( certs . empty ( ) ) { <nl> - qWarning ( ) < < " PaymentRequestPlus : : getMerchant : Payment request : empty certificate chain " ; <nl> - return false ; <nl> - } <nl> - <nl> - / / The first cert is the signing cert , the rest are untrusted certs that chain <nl> - / / to a valid root authority . OpenSSL needs them separately . <nl> - STACK_OF ( X509 ) * chain = sk_X509_new_null ( ) ; <nl> - for ( int i = certs . size ( ) - 1 ; i > 0 ; i - - ) { <nl> - sk_X509_push ( chain , certs [ i ] ) ; <nl> - } <nl> - X509 * signing_cert = certs [ 0 ] ; <nl> - <nl> - / / Now create a " store context " , which is a single use object for checking , <nl> - / / load the signing cert into it and verify . <nl> - X509_STORE_CTX * store_ctx = X509_STORE_CTX_new ( ) ; <nl> - if ( ! store_ctx ) { <nl> - qWarning ( ) < < " PaymentRequestPlus : : getMerchant : Payment request : error creating X509_STORE_CTX " ; <nl> - return false ; <nl> - } <nl> - <nl> - char * website = nullptr ; <nl> - bool fResult = true ; <nl> - try <nl> - { <nl> - if ( ! X509_STORE_CTX_init ( store_ctx , certStore , signing_cert , chain ) ) <nl> - { <nl> - int error = X509_STORE_CTX_get_error ( store_ctx ) ; <nl> - throw SSLVerifyError ( X509_verify_cert_error_string ( error ) ) ; <nl> - } <nl> - <nl> - / / Now do the verification ! <nl> - int result = X509_verify_cert ( store_ctx ) ; <nl> - if ( result ! = 1 ) { <nl> - int error = X509_STORE_CTX_get_error ( store_ctx ) ; <nl> - / / For testing payment requests , we allow self signed root certs ! <nl> - if ( ! ( error = = X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT & & gArgs . GetBoolArg ( " - allowselfsignedrootcertificates " , DEFAULT_SELFSIGNED_ROOTCERTS ) ) ) { <nl> - throw SSLVerifyError ( X509_verify_cert_error_string ( error ) ) ; <nl> - } else { <nl> - qDebug ( ) < < " PaymentRequestPlus : : getMerchant : Allowing self signed root certificate , because - allowselfsignedrootcertificates is true . " ; <nl> - } <nl> - } <nl> - X509_NAME * certname = X509_get_subject_name ( signing_cert ) ; <nl> - <nl> - / / Valid cert ; check signature : <nl> - payments : : PaymentRequest rcopy ( paymentRequest ) ; / / Copy <nl> - rcopy . set_signature ( std : : string ( " " ) ) ; <nl> - std : : string data_to_verify ; / / Everything but the signature <nl> - rcopy . SerializeToString ( & data_to_verify ) ; <nl> - <nl> - # if HAVE_DECL_EVP_MD_CTX_NEW <nl> - EVP_MD_CTX * ctx = EVP_MD_CTX_new ( ) ; <nl> - if ( ! ctx ) throw SSLVerifyError ( " Error allocating OpenSSL context . " ) ; <nl> - # else <nl> - EVP_MD_CTX _ctx ; <nl> - EVP_MD_CTX * ctx ; <nl> - ctx = & _ctx ; <nl> - # endif <nl> - EVP_PKEY * pubkey = X509_get_pubkey ( signing_cert ) ; <nl> - EVP_MD_CTX_init ( ctx ) ; <nl> - if ( ! EVP_VerifyInit_ex ( ctx , digestAlgorithm , nullptr ) | | <nl> - ! EVP_VerifyUpdate ( ctx , data_to_verify . data ( ) , data_to_verify . size ( ) ) | | <nl> - ! EVP_VerifyFinal ( ctx , ( const unsigned char * ) paymentRequest . signature ( ) . data ( ) , ( unsigned int ) paymentRequest . signature ( ) . size ( ) , pubkey ) ) { <nl> - throw SSLVerifyError ( " Bad signature , invalid payment request . " ) ; <nl> - } <nl> - # if HAVE_DECL_EVP_MD_CTX_NEW <nl> - EVP_MD_CTX_free ( ctx ) ; <nl> - # endif <nl> - <nl> - / / OpenSSL API for getting human printable strings from certs is baroque . <nl> - int textlen = X509_NAME_get_text_by_NID ( certname , NID_commonName , nullptr , 0 ) ; <nl> - website = new char [ textlen + 1 ] ; <nl> - if ( X509_NAME_get_text_by_NID ( certname , NID_commonName , website , textlen + 1 ) = = textlen & & textlen > 0 ) { <nl> - merchant = website ; <nl> - } <nl> - else { <nl> - throw SSLVerifyError ( " Bad certificate , missing common name . " ) ; <nl> - } <nl> - / / TODO : detect EV certificates and set merchant = business name instead of unfriendly NID_commonName ? <nl> - } <nl> - catch ( const SSLVerifyError & err ) { <nl> - fResult = false ; <nl> - qWarning ( ) < < " PaymentRequestPlus : : getMerchant : SSL error : " < < err . what ( ) ; <nl> - } <nl> - <nl> - delete [ ] website ; <nl> - X509_STORE_CTX_free ( store_ctx ) ; <nl> - for ( unsigned int i = 0 ; i < certs . size ( ) ; i + + ) <nl> - X509_free ( certs [ i ] ) ; <nl> - <nl> - return fResult ; <nl> - } <nl> - <nl> - QList < std : : pair < CScript , CAmount > > PaymentRequestPlus : : getPayTo ( ) const <nl> - { <nl> - QList < std : : pair < CScript , CAmount > > result ; <nl> - for ( int i = 0 ; i < details . outputs_size ( ) ; i + + ) <nl> - { <nl> - const unsigned char * scriptStr = ( const unsigned char * ) details . outputs ( i ) . script ( ) . data ( ) ; <nl> - CScript s ( scriptStr , scriptStr + details . outputs ( i ) . script ( ) . size ( ) ) ; <nl> - <nl> - result . append ( std : : make_pair ( s , details . outputs ( i ) . amount ( ) ) ) ; <nl> - } <nl> - return result ; <nl> - } <nl> deleted file mode 100644 <nl> index 30146288070e . . 000000000000 <nl> mmm a / src / qt / paymentrequestplus . h <nl> ppp / dev / null <nl> <nl> - / / Copyright ( c ) 2011 - 2018 The Bitcoin Core developers <nl> - / / Distributed under the MIT software license , see the accompanying <nl> - / / file COPYING or http : / / www . opensource . org / licenses / mit - license . php . <nl> - <nl> - # ifndef BITCOIN_QT_PAYMENTREQUESTPLUS_H <nl> - # define BITCOIN_QT_PAYMENTREQUESTPLUS_H <nl> - <nl> - # pragma GCC diagnostic push <nl> - # pragma GCC diagnostic ignored " - Wdeprecated - declarations " <nl> - # include < qt / paymentrequest . pb . h > <nl> - # pragma GCC diagnostic pop <nl> - <nl> - # include < amount . h > <nl> - # include < script / script . h > <nl> - <nl> - # include < openssl / x509 . h > <nl> - <nl> - # include < QByteArray > <nl> - # include < QList > <nl> - # include < QString > <nl> - <nl> - static const bool DEFAULT_SELFSIGNED_ROOTCERTS = false ; <nl> - <nl> - / / <nl> - / / Wraps dumb protocol buffer paymentRequest <nl> - / / with extra methods <nl> - / / <nl> - <nl> - class PaymentRequestPlus <nl> - { <nl> - public : <nl> - PaymentRequestPlus ( ) { } <nl> - <nl> - bool parse ( const QByteArray & data ) ; <nl> - bool SerializeToString ( std : : string * output ) const ; <nl> - <nl> - bool IsInitialized ( ) const ; <nl> - / / Returns true if merchant ' s identity is authenticated , and <nl> - / / returns human - readable merchant identity in merchant <nl> - bool getMerchant ( X509_STORE * certStore , QString & merchant ) const ; <nl> - <nl> - / / Returns list of outputs , amount <nl> - QList < std : : pair < CScript , CAmount > > getPayTo ( ) const ; <nl> - <nl> - const payments : : PaymentDetails & getDetails ( ) const { return details ; } <nl> - <nl> - private : <nl> - payments : : PaymentRequest paymentRequest ; <nl> - payments : : PaymentDetails details ; <nl> - } ; <nl> - <nl> - # endif / / BITCOIN_QT_PAYMENTREQUESTPLUS_H <nl> mmm a / src / qt / paymentserver . cpp <nl> ppp b / src / qt / paymentserver . cpp <nl> <nl> # include < cstdlib > <nl> # include < memory > <nl> <nl> - # include < openssl / x509_vfy . h > <nl> - <nl> # include < QApplication > <nl> # include < QByteArray > <nl> # include < QDataStream > <nl> <nl> # include < QList > <nl> # include < QLocalServer > <nl> # include < QLocalSocket > <nl> - # include < QNetworkAccessManager > <nl> - # include < QNetworkProxy > <nl> - # include < QNetworkReply > <nl> - # include < QNetworkRequest > <nl> - # include < QSslCertificate > <nl> - # include < QSslConfiguration > <nl> - # include < QSslError > <nl> # include < QStringList > <nl> - # include < QTextDocument > <nl> # include < QUrlQuery > <nl> <nl> const int BITCOIN_IPC_CONNECT_TIMEOUT = 1000 ; / / milliseconds <nl> const QString BITCOIN_IPC_PREFIX ( " bitcoin : " ) ; <nl> - # ifdef ENABLE_BIP70 <nl> - / / BIP70 payment protocol messages <nl> - const char * BIP70_MESSAGE_PAYMENTACK = " PaymentACK " ; <nl> - const char * BIP70_MESSAGE_PAYMENTREQUEST = " PaymentRequest " ; <nl> - / / BIP71 payment protocol media types <nl> - const char * BIP71_MIMETYPE_PAYMENT = " application / bitcoin - payment " ; <nl> - const char * BIP71_MIMETYPE_PAYMENTACK = " application / bitcoin - paymentack " ; <nl> - const char * BIP71_MIMETYPE_PAYMENTREQUEST = " application / bitcoin - paymentrequest " ; <nl> - # endif <nl> <nl> / / <nl> / / Create a name that is unique for : <nl> void PaymentServer : : ipcParseCommandLine ( interfaces : : Node & node , int argc , char * <nl> } <nl> } <nl> } <nl> - # ifdef ENABLE_BIP70 <nl> - else if ( QFile : : exists ( arg ) ) / / Filename <nl> - { <nl> - if ( savedPaymentRequests . contains ( arg ) ) continue ; <nl> - savedPaymentRequests . insert ( arg ) ; <nl> - <nl> - PaymentRequestPlus request ; <nl> - if ( readPaymentRequestFromFile ( arg , request ) ) <nl> - { <nl> - if ( request . getDetails ( ) . network ( ) = = " main " ) <nl> - { <nl> - node . selectParams ( CBaseChainParams : : MAIN ) ; <nl> - } <nl> - else if ( request . getDetails ( ) . network ( ) = = " test " ) <nl> - { <nl> - node . selectParams ( CBaseChainParams : : TESTNET ) ; <nl> - } <nl> - } <nl> - } <nl> - else <nl> - { <nl> - / / Printing to debug . log is about the best we can do here , the <nl> - / / GUI hasn ' t started yet so we can ' t pop up a message box . <nl> - qWarning ( ) < < " PaymentServer : : ipcSendCommandLine : Payment request file does not exist : " < < arg ; <nl> - } <nl> - # endif <nl> } <nl> } <nl> <nl> PaymentServer : : PaymentServer ( QObject * parent , bool startLocalServer ) : <nl> saveURIs ( true ) , <nl> uriServer ( nullptr ) , <nl> optionsModel ( nullptr ) <nl> - # ifdef ENABLE_BIP70 <nl> - , netManager ( nullptr ) <nl> - # endif <nl> { <nl> - # ifdef ENABLE_BIP70 <nl> - / / Verify that the version of the library that we linked against is <nl> - / / compatible with the version of the headers we compiled against . <nl> - GOOGLE_PROTOBUF_VERIFY_VERSION ; <nl> - # endif <nl> - <nl> / / Install global event filter to catch QFileOpenEvents <nl> / / on Mac : sent when you click bitcoin : links <nl> / / other OSes : helpful when dealing with payment request files <nl> PaymentServer : : PaymentServer ( QObject * parent , bool startLocalServer ) : <nl> } <nl> else { <nl> connect ( uriServer , & QLocalServer : : newConnection , this , & PaymentServer : : handleURIConnection ) ; <nl> - # ifdef ENABLE_BIP70 <nl> - connect ( this , & PaymentServer : : receivedPaymentACK , this , & PaymentServer : : handlePaymentACK ) ; <nl> - # endif <nl> } <nl> } <nl> } <nl> <nl> PaymentServer : : ~ PaymentServer ( ) <nl> { <nl> - # ifdef ENABLE_BIP70 <nl> - google : : protobuf : : ShutdownProtobufLibrary ( ) ; <nl> - # endif <nl> } <nl> <nl> / / <nl> bool PaymentServer : : eventFilter ( QObject * object , QEvent * event ) <nl> <nl> void PaymentServer : : uiReady ( ) <nl> { <nl> - # ifdef ENABLE_BIP70 <nl> - initNetManager ( ) ; <nl> - # endif <nl> - <nl> saveURIs = false ; <nl> for ( const QString & s : savedPaymentRequests ) <nl> { <nl> void PaymentServer : : handleURIOrFile ( const QString & s ) <nl> else if ( s . startsWith ( BITCOIN_IPC_PREFIX , Qt : : CaseInsensitive ) ) / / bitcoin : URI <nl> { <nl> QUrlQuery uri ( ( QUrl ( s ) ) ) ; <nl> - # ifdef ENABLE_BIP70 <nl> - if ( uri . hasQueryItem ( " r " ) ) / / payment request URI <nl> - { <nl> - Q_EMIT message ( tr ( " URI handling " ) , <nl> - tr ( " You are using a BIP70 URL which will be unsupported in the future . " ) , <nl> - CClientUIInterface : : ICON_WARNING ) ; <nl> - QByteArray temp ; <nl> - temp . append ( uri . queryItemValue ( " r " ) ) ; <nl> - QString decoded = QUrl : : fromPercentEncoding ( temp ) ; <nl> - QUrl fetchUrl ( decoded , QUrl : : StrictMode ) ; <nl> - <nl> - if ( fetchUrl . isValid ( ) ) <nl> - { <nl> - qDebug ( ) < < " PaymentServer : : handleURIOrFile : fetchRequest ( " < < fetchUrl < < " ) " ; <nl> - fetchRequest ( fetchUrl ) ; <nl> - } <nl> - else <nl> - { <nl> - qWarning ( ) < < " PaymentServer : : handleURIOrFile : Invalid URL : " < < fetchUrl ; <nl> - Q_EMIT message ( tr ( " URI handling " ) , <nl> - tr ( " Payment request fetch URL is invalid : % 1 " ) . arg ( fetchUrl . toString ( ) ) , <nl> - CClientUIInterface : : ICON_WARNING ) ; <nl> - } <nl> - return ; <nl> - } <nl> - else <nl> - # endif <nl> / / normal URI <nl> { <nl> SendCoinsRecipient recipient ; <nl> if ( GUIUtil : : parseBitcoinURI ( s , & recipient ) ) <nl> { <nl> if ( ! IsValidDestinationString ( recipient . address . toStdString ( ) ) ) { <nl> - # ifndef ENABLE_BIP70 <nl> if ( uri . hasQueryItem ( " r " ) ) { / / payment request <nl> Q_EMIT message ( tr ( " URI handling " ) , <nl> tr ( " Cannot process payment request because BIP70 support was not compiled in . " ) + <nl> void PaymentServer : : handleURIOrFile ( const QString & s ) <nl> tr ( " If you are receiving this error you should request the merchant provide a BIP21 compatible URI . " ) , <nl> CClientUIInterface : : ICON_WARNING ) ; <nl> } <nl> - # endif <nl> Q_EMIT message ( tr ( " URI handling " ) , tr ( " Invalid payment address % 1 " ) . arg ( recipient . address ) , <nl> CClientUIInterface : : MSG_ERROR ) ; <nl> } <nl> void PaymentServer : : handleURIOrFile ( const QString & s ) <nl> <nl> if ( QFile : : exists ( s ) ) / / payment request file <nl> { <nl> - # ifdef ENABLE_BIP70 <nl> - PaymentRequestPlus request ; <nl> - SendCoinsRecipient recipient ; <nl> - if ( ! readPaymentRequestFromFile ( s , request ) ) <nl> - { <nl> - Q_EMIT message ( tr ( " Payment request file handling " ) , <nl> - tr ( " Payment request file cannot be read ! This can be caused by an invalid payment request file . " ) , <nl> - CClientUIInterface : : ICON_WARNING ) ; <nl> - } <nl> - else if ( processPaymentRequest ( request , recipient ) ) <nl> - Q_EMIT receivedPaymentRequest ( recipient ) ; <nl> - <nl> - return ; <nl> - # else <nl> Q_EMIT message ( tr ( " Payment request file handling " ) , <nl> tr ( " Cannot process payment request because BIP70 support was not compiled in . " ) + <nl> tr ( " Due to widespread security flaws in BIP70 it ' s strongly recommended that any merchant instructions to switch wallets be ignored . " ) + <nl> tr ( " If you are receiving this error you should request the merchant provide a BIP21 compatible URI . " ) , <nl> CClientUIInterface : : ICON_WARNING ) ; <nl> - # endif <nl> } <nl> } <nl> <nl> void PaymentServer : : setOptionsModel ( OptionsModel * _optionsModel ) <nl> { <nl> this - > optionsModel = _optionsModel ; <nl> } <nl> - <nl> - # ifdef ENABLE_BIP70 <nl> - struct X509StoreDeleter { <nl> - void operator ( ) ( X509_STORE * b ) { <nl> - X509_STORE_free ( b ) ; <nl> - } <nl> - } ; <nl> - <nl> - struct X509Deleter { <nl> - void operator ( ) ( X509 * b ) { X509_free ( b ) ; } <nl> - } ; <nl> - <nl> - namespace / / Anon namespace <nl> - { <nl> - std : : unique_ptr < X509_STORE , X509StoreDeleter > certStore ; <nl> - } <nl> - <nl> - static void ReportInvalidCertificate ( const QSslCertificate & cert ) <nl> - { <nl> - qDebug ( ) < < QString ( " % 1 : Payment server found an invalid certificate : " ) . arg ( __func__ ) < < cert . serialNumber ( ) < < cert . subjectInfo ( QSslCertificate : : CommonName ) < < cert . subjectInfo ( QSslCertificate : : DistinguishedNameQualifier ) < < cert . subjectInfo ( QSslCertificate : : OrganizationalUnitName ) ; <nl> - } <nl> - <nl> - / / <nl> - / / Load OpenSSL ' s list of root certificate authorities <nl> - / / <nl> - void PaymentServer : : LoadRootCAs ( X509_STORE * _store ) <nl> - { <nl> - / / Unit tests mostly use this , to pass in fake root CAs : <nl> - if ( _store ) <nl> - { <nl> - certStore . reset ( _store ) ; <nl> - return ; <nl> - } <nl> - <nl> - / / Normal execution , use either - rootcertificates or system certs : <nl> - certStore . reset ( X509_STORE_new ( ) ) ; <nl> - <nl> - / / Note : use " - system - " default here so that users can pass - rootcertificates = " " <nl> - / / and get ' I don ' t like X . 509 certificates , don ' t trust anybody ' behavior : <nl> - QString certFile = QString : : fromStdString ( gArgs . GetArg ( " - rootcertificates " , " - system - " ) ) ; <nl> - <nl> - / / Empty store <nl> - if ( certFile . isEmpty ( ) ) { <nl> - qDebug ( ) < < QString ( " PaymentServer : : % 1 : Payment request authentication via X . 509 certificates disabled . " ) . arg ( __func__ ) ; <nl> - return ; <nl> - } <nl> - <nl> - QList < QSslCertificate > certList ; <nl> - <nl> - if ( certFile ! = " - system - " ) { <nl> - qDebug ( ) < < QString ( " PaymentServer : : % 1 : Using \ " % 2 \ " as trusted root certificate . " ) . arg ( __func__ ) . arg ( certFile ) ; <nl> - <nl> - certList = QSslCertificate : : fromPath ( certFile ) ; <nl> - / / Use those certificates when fetching payment requests , too : <nl> - QSslConfiguration : : defaultConfiguration ( ) . setCaCertificates ( certList ) ; <nl> - } else <nl> - certList = QSslConfiguration : : systemCaCertificates ( ) ; <nl> - <nl> - int nRootCerts = 0 ; <nl> - const QDateTime currentTime = QDateTime : : currentDateTime ( ) ; <nl> - <nl> - for ( const QSslCertificate & cert : certList ) { <nl> - / / Don ' t log NULL certificates <nl> - if ( cert . isNull ( ) ) <nl> - continue ; <nl> - <nl> - / / Not yet active / valid , or expired certificate <nl> - if ( currentTime < cert . effectiveDate ( ) | | currentTime > cert . expiryDate ( ) ) { <nl> - ReportInvalidCertificate ( cert ) ; <nl> - continue ; <nl> - } <nl> - <nl> - / / Blacklisted certificate <nl> - if ( cert . isBlacklisted ( ) ) { <nl> - ReportInvalidCertificate ( cert ) ; <nl> - continue ; <nl> - } <nl> - <nl> - QByteArray certData = cert . toDer ( ) ; <nl> - const unsigned char * data = ( const unsigned char * ) certData . data ( ) ; <nl> - <nl> - std : : unique_ptr < X509 , X509Deleter > x509 ( d2i_X509 ( 0 , & data , certData . size ( ) ) ) ; <nl> - if ( x509 & & X509_STORE_add_cert ( certStore . get ( ) , x509 . get ( ) ) ) <nl> - { <nl> - / / Note : X509_STORE increases the reference count to the X509 object , <nl> - / / we still have to release our reference to it . <nl> - + + nRootCerts ; <nl> - } <nl> - else <nl> - { <nl> - ReportInvalidCertificate ( cert ) ; <nl> - continue ; <nl> - } <nl> - } <nl> - qInfo ( ) < < " PaymentServer : : LoadRootCAs : Loaded " < < nRootCerts < < " root certificates " ; <nl> - <nl> - / / Project for another day : <nl> - / / Fetch certificate revocation lists , and add them to certStore . <nl> - / / Issues to consider : <nl> - / / performance ( start a thread to fetch in background ? ) <nl> - / / privacy ( fetch through tor / proxy so IP address isn ' t revealed ) <nl> - / / would it be easier to just use a compiled - in blacklist ? <nl> - / / or use Qt ' s blacklist ? <nl> - / / " certificate stapling " with server - side caching is more efficient <nl> - } <nl> - <nl> - void PaymentServer : : initNetManager ( ) <nl> - { <nl> - if ( ! optionsModel ) <nl> - return ; <nl> - delete netManager ; <nl> - <nl> - / / netManager is used to fetch paymentrequests given in bitcoin : URIs <nl> - netManager = new QNetworkAccessManager ( this ) ; <nl> - <nl> - QNetworkProxy proxy ; <nl> - <nl> - / / Query active SOCKS5 proxy <nl> - if ( optionsModel - > getProxySettings ( proxy ) ) { <nl> - netManager - > setProxy ( proxy ) ; <nl> - <nl> - qDebug ( ) < < " PaymentServer : : initNetManager : Using SOCKS5 proxy " < < proxy . hostName ( ) < < " : " < < proxy . port ( ) ; <nl> - } <nl> - else <nl> - qDebug ( ) < < " PaymentServer : : initNetManager : No active proxy server found . " ; <nl> - <nl> - connect ( netManager , & QNetworkAccessManager : : finished , this , & PaymentServer : : netRequestFinished ) ; <nl> - connect ( netManager , & QNetworkAccessManager : : sslErrors , this , & PaymentServer : : reportSslErrors ) ; <nl> - } <nl> - <nl> - / / <nl> - / / Warning : readPaymentRequestFromFile ( ) is used in ipcSendCommandLine ( ) <nl> - / / so don ' t use " Q_EMIT message ( ) " , but " QMessageBox : : " ! <nl> - / / <nl> - bool PaymentServer : : readPaymentRequestFromFile ( const QString & filename , PaymentRequestPlus & request ) <nl> - { <nl> - QFile f ( filename ) ; <nl> - if ( ! f . open ( QIODevice : : ReadOnly ) ) { <nl> - qWarning ( ) < < QString ( " PaymentServer : : % 1 : Failed to open % 2 " ) . arg ( __func__ ) . arg ( filename ) ; <nl> - return false ; <nl> - } <nl> - <nl> - / / BIP70 DoS protection <nl> - if ( ! verifySize ( f . size ( ) ) ) { <nl> - return false ; <nl> - } <nl> - <nl> - QByteArray data = f . readAll ( ) ; <nl> - <nl> - return request . parse ( data ) ; <nl> - } <nl> - <nl> - bool PaymentServer : : processPaymentRequest ( const PaymentRequestPlus & request , SendCoinsRecipient & recipient ) <nl> - { <nl> - if ( ! optionsModel ) <nl> - return false ; <nl> - <nl> - if ( request . IsInitialized ( ) ) { <nl> - / / Payment request network matches client network ? <nl> - if ( ! verifyNetwork ( optionsModel - > node ( ) , request . getDetails ( ) ) ) { <nl> - Q_EMIT message ( tr ( " Payment request rejected " ) , tr ( " Payment request network doesn ' t match client network . " ) , <nl> - CClientUIInterface : : MSG_ERROR ) ; <nl> - <nl> - return false ; <nl> - } <nl> - <nl> - / / Make sure any payment requests involved are still valid . <nl> - / / This is re - checked just before sending coins in WalletModel : : sendCoins ( ) . <nl> - if ( verifyExpired ( request . getDetails ( ) ) ) { <nl> - Q_EMIT message ( tr ( " Payment request rejected " ) , tr ( " Payment request expired . " ) , <nl> - CClientUIInterface : : MSG_ERROR ) ; <nl> - <nl> - return false ; <nl> - } <nl> - } else { <nl> - Q_EMIT message ( tr ( " Payment request error " ) , tr ( " Payment request is not initialized . " ) , <nl> - CClientUIInterface : : MSG_ERROR ) ; <nl> - <nl> - return false ; <nl> - } <nl> - <nl> - recipient . paymentRequest = request ; <nl> - recipient . message = GUIUtil : : HtmlEscape ( request . getDetails ( ) . memo ( ) ) ; <nl> - <nl> - request . getMerchant ( certStore . get ( ) , recipient . authenticatedMerchant ) ; <nl> - <nl> - QList < std : : pair < CScript , CAmount > > sendingTos = request . getPayTo ( ) ; <nl> - QStringList addresses ; <nl> - <nl> - for ( const std : : pair < CScript , CAmount > & sendingTo : sendingTos ) { <nl> - / / Extract and check destination addresses <nl> - CTxDestination dest ; <nl> - if ( ExtractDestination ( sendingTo . first , dest ) ) { <nl> - / / Append destination address <nl> - addresses . append ( QString : : fromStdString ( EncodeDestination ( dest ) ) ) ; <nl> - } <nl> - else if ( ! recipient . authenticatedMerchant . isEmpty ( ) ) { <nl> - / / Unauthenticated payment requests to custom bitcoin addresses are not supported <nl> - / / ( there is no good way to tell the user where they are paying in a way they ' d <nl> - / / have a chance of understanding ) . <nl> - Q_EMIT message ( tr ( " Payment request rejected " ) , <nl> - tr ( " Unverified payment requests to custom payment scripts are unsupported . " ) , <nl> - CClientUIInterface : : MSG_ERROR ) ; <nl> - return false ; <nl> - } <nl> - <nl> - / / Bitcoin amounts are stored as ( optional ) uint64 in the protobuf messages ( see paymentrequest . proto ) , <nl> - / / but CAmount is defined as int64_t . Because of that we need to verify that amounts are in a valid range <nl> - / / and no overflow has happened . <nl> - if ( ! verifyAmount ( sendingTo . second ) ) { <nl> - Q_EMIT message ( tr ( " Payment request rejected " ) , tr ( " Invalid payment request . " ) , CClientUIInterface : : MSG_ERROR ) ; <nl> - return false ; <nl> - } <nl> - <nl> - / / Extract and check amounts <nl> - CTxOut txOut ( sendingTo . second , sendingTo . first ) ; <nl> - if ( IsDust ( txOut , optionsModel - > node ( ) . getDustRelayFee ( ) ) ) { <nl> - Q_EMIT message ( tr ( " Payment request error " ) , tr ( " Requested payment amount of % 1 is too small ( considered dust ) . " ) <nl> - . arg ( BitcoinUnits : : formatWithUnit ( optionsModel - > getDisplayUnit ( ) , sendingTo . second ) ) , <nl> - CClientUIInterface : : MSG_ERROR ) ; <nl> - <nl> - return false ; <nl> - } <nl> - <nl> - recipient . amount + = sendingTo . second ; <nl> - / / Also verify that the final amount is still in a valid range after adding additional amounts . <nl> - if ( ! verifyAmount ( recipient . amount ) ) { <nl> - Q_EMIT message ( tr ( " Payment request rejected " ) , tr ( " Invalid payment request . " ) , CClientUIInterface : : MSG_ERROR ) ; <nl> - return false ; <nl> - } <nl> - } <nl> - / / Store addresses and format them to fit nicely into the GUI <nl> - recipient . address = addresses . join ( " < br / > " ) ; <nl> - <nl> - if ( ! recipient . authenticatedMerchant . isEmpty ( ) ) { <nl> - qDebug ( ) < < " PaymentServer : : processPaymentRequest : Secure payment request from " < < recipient . authenticatedMerchant ; <nl> - } <nl> - else { <nl> - qDebug ( ) < < " PaymentServer : : processPaymentRequest : Insecure payment request to " < < addresses . join ( " , " ) ; <nl> - } <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - void PaymentServer : : fetchRequest ( const QUrl & url ) <nl> - { <nl> - QNetworkRequest netRequest ; <nl> - netRequest . setAttribute ( QNetworkRequest : : User , BIP70_MESSAGE_PAYMENTREQUEST ) ; <nl> - netRequest . setUrl ( url ) ; <nl> - netRequest . setRawHeader ( " User - Agent " , CLIENT_NAME . c_str ( ) ) ; <nl> - netRequest . setRawHeader ( " Accept " , BIP71_MIMETYPE_PAYMENTREQUEST ) ; <nl> - netManager - > get ( netRequest ) ; <nl> - } <nl> - <nl> - void PaymentServer : : fetchPaymentACK ( WalletModel * walletModel , const SendCoinsRecipient & recipient , QByteArray transaction ) <nl> - { <nl> - const payments : : PaymentDetails & details = recipient . paymentRequest . getDetails ( ) ; <nl> - if ( ! details . has_payment_url ( ) ) <nl> - return ; <nl> - <nl> - QNetworkRequest netRequest ; <nl> - netRequest . setAttribute ( QNetworkRequest : : User , BIP70_MESSAGE_PAYMENTACK ) ; <nl> - netRequest . setUrl ( QString : : fromStdString ( details . payment_url ( ) ) ) ; <nl> - netRequest . setHeader ( QNetworkRequest : : ContentTypeHeader , BIP71_MIMETYPE_PAYMENT ) ; <nl> - netRequest . setRawHeader ( " User - Agent " , CLIENT_NAME . c_str ( ) ) ; <nl> - netRequest . setRawHeader ( " Accept " , BIP71_MIMETYPE_PAYMENTACK ) ; <nl> - <nl> - payments : : Payment payment ; <nl> - payment . set_merchant_data ( details . merchant_data ( ) ) ; <nl> - payment . add_transactions ( transaction . data ( ) , transaction . size ( ) ) ; <nl> - <nl> - / / Create a new refund address , or re - use : <nl> - CTxDestination dest ; <nl> - const OutputType change_type = walletModel - > wallet ( ) . getDefaultChangeType ( ) ! = OutputType : : CHANGE_AUTO ? walletModel - > wallet ( ) . getDefaultChangeType ( ) : walletModel - > wallet ( ) . getDefaultAddressType ( ) ; <nl> - if ( walletModel - > wallet ( ) . getNewDestination ( change_type , " " , dest ) ) { <nl> - / / BIP70 requests encode the scriptPubKey directly , so we are not restricted to address <nl> - / / types supported by the receiver . As a result , we choose the address format we also <nl> - / / use for change . Despite an actual payment and not change , this is a close match : <nl> - / / it ' s the output type we use subject to privacy issues , but not restricted by what <nl> - / / other software supports . <nl> - std : : string label = tr ( " Refund from % 1 " ) . arg ( recipient . authenticatedMerchant ) . toStdString ( ) ; <nl> - walletModel - > wallet ( ) . setAddressBook ( dest , label , " refund " ) ; <nl> - <nl> - CScript s = GetScriptForDestination ( dest ) ; <nl> - payments : : Output * refund_to = payment . add_refund_to ( ) ; <nl> - refund_to - > set_script ( & s [ 0 ] , s . size ( ) ) ; <nl> - } else { <nl> - / / This should never happen , because sending coins should have <nl> - / / just unlocked the wallet and refilled the keypool . <nl> - qWarning ( ) < < " PaymentServer : : fetchPaymentACK : Error getting refund key , refund_to not set " ; <nl> - } <nl> - <nl> - int length = payment . ByteSize ( ) ; <nl> - netRequest . setHeader ( QNetworkRequest : : ContentLengthHeader , length ) ; <nl> - QByteArray serData ( length , ' \ 0 ' ) ; <nl> - if ( payment . SerializeToArray ( serData . data ( ) , length ) ) { <nl> - netManager - > post ( netRequest , serData ) ; <nl> - } <nl> - else { <nl> - / / This should never happen , either . <nl> - qWarning ( ) < < " PaymentServer : : fetchPaymentACK : Error serializing payment message " ; <nl> - } <nl> - } <nl> - <nl> - void PaymentServer : : netRequestFinished ( QNetworkReply * reply ) <nl> - { <nl> - reply - > deleteLater ( ) ; <nl> - <nl> - / / BIP70 DoS protection <nl> - if ( ! verifySize ( reply - > size ( ) ) ) { <nl> - Q_EMIT message ( tr ( " Payment request rejected " ) , <nl> - tr ( " Payment request % 1 is too large ( % 2 bytes , allowed % 3 bytes ) . " ) <nl> - . arg ( reply - > request ( ) . url ( ) . toString ( ) ) <nl> - . arg ( reply - > size ( ) ) <nl> - . arg ( BIP70_MAX_PAYMENTREQUEST_SIZE ) , <nl> - CClientUIInterface : : MSG_ERROR ) ; <nl> - return ; <nl> - } <nl> - <nl> - if ( reply - > error ( ) ! = QNetworkReply : : NoError ) { <nl> - QString msg = tr ( " Error communicating with % 1 : % 2 " ) <nl> - . arg ( reply - > request ( ) . url ( ) . toString ( ) ) <nl> - . arg ( reply - > errorString ( ) ) ; <nl> - <nl> - qWarning ( ) < < " PaymentServer : : netRequestFinished : " < < msg ; <nl> - Q_EMIT message ( tr ( " Payment request error " ) , msg , CClientUIInterface : : MSG_ERROR ) ; <nl> - return ; <nl> - } <nl> - <nl> - QByteArray data = reply - > readAll ( ) ; <nl> - <nl> - QString requestType = reply - > request ( ) . attribute ( QNetworkRequest : : User ) . toString ( ) ; <nl> - if ( requestType = = BIP70_MESSAGE_PAYMENTREQUEST ) <nl> - { <nl> - PaymentRequestPlus request ; <nl> - SendCoinsRecipient recipient ; <nl> - if ( ! request . parse ( data ) ) <nl> - { <nl> - qWarning ( ) < < " PaymentServer : : netRequestFinished : Error parsing payment request " ; <nl> - Q_EMIT message ( tr ( " Payment request error " ) , <nl> - tr ( " Payment request cannot be parsed ! " ) , <nl> - CClientUIInterface : : MSG_ERROR ) ; <nl> - } <nl> - else if ( processPaymentRequest ( request , recipient ) ) <nl> - Q_EMIT receivedPaymentRequest ( recipient ) ; <nl> - <nl> - return ; <nl> - } <nl> - else if ( requestType = = BIP70_MESSAGE_PAYMENTACK ) <nl> - { <nl> - payments : : PaymentACK paymentACK ; <nl> - if ( ! paymentACK . ParseFromArray ( data . data ( ) , data . size ( ) ) ) <nl> - { <nl> - QString msg = tr ( " Bad response from server % 1 " ) <nl> - . arg ( reply - > request ( ) . url ( ) . toString ( ) ) ; <nl> - <nl> - qWarning ( ) < < " PaymentServer : : netRequestFinished : " < < msg ; <nl> - Q_EMIT message ( tr ( " Payment request error " ) , msg , CClientUIInterface : : MSG_ERROR ) ; <nl> - } <nl> - else <nl> - { <nl> - Q_EMIT receivedPaymentACK ( GUIUtil : : HtmlEscape ( paymentACK . memo ( ) ) ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - void PaymentServer : : reportSslErrors ( QNetworkReply * reply , const QList < QSslError > & errs ) <nl> - { <nl> - Q_UNUSED ( reply ) ; <nl> - <nl> - QString errString ; <nl> - for ( const QSslError & err : errs ) { <nl> - qWarning ( ) < < " PaymentServer : : reportSslErrors : " < < err ; <nl> - errString + = err . errorString ( ) + " \ n " ; <nl> - } <nl> - Q_EMIT message ( tr ( " Network request error " ) , errString , CClientUIInterface : : MSG_ERROR ) ; <nl> - } <nl> - <nl> - void PaymentServer : : handlePaymentACK ( const QString & paymentACKMsg ) <nl> - { <nl> - / / currently we don ' t further process or store the paymentACK message <nl> - Q_EMIT message ( tr ( " Payment acknowledged " ) , paymentACKMsg , CClientUIInterface : : ICON_INFORMATION | CClientUIInterface : : MODAL ) ; <nl> - } <nl> - <nl> - bool PaymentServer : : verifyNetwork ( interfaces : : Node & node , const payments : : PaymentDetails & requestDetails ) <nl> - { <nl> - bool fVerified = requestDetails . network ( ) = = node . getNetwork ( ) ; <nl> - if ( ! fVerified ) { <nl> - qWarning ( ) < < QString ( " PaymentServer : : % 1 : Payment request network \ " % 2 \ " doesn ' t match client network \ " % 3 \ " . " ) <nl> - . arg ( __func__ ) <nl> - . arg ( QString : : fromStdString ( requestDetails . network ( ) ) ) <nl> - . arg ( QString : : fromStdString ( node . getNetwork ( ) ) ) ; <nl> - } <nl> - return fVerified ; <nl> - } <nl> - <nl> - bool PaymentServer : : verifyExpired ( const payments : : PaymentDetails & requestDetails ) <nl> - { <nl> - bool fVerified = ( requestDetails . has_expires ( ) & & ( int64_t ) requestDetails . expires ( ) < GetTime ( ) ) ; <nl> - if ( fVerified ) { <nl> - const QString requestExpires = QString : : fromStdString ( FormatISO8601DateTime ( ( int64_t ) requestDetails . expires ( ) ) ) ; <nl> - qWarning ( ) < < QString ( " PaymentServer : : % 1 : Payment request expired \ " % 2 \ " . " ) <nl> - . arg ( __func__ ) <nl> - . arg ( requestExpires ) ; <nl> - } <nl> - return fVerified ; <nl> - } <nl> - <nl> - bool PaymentServer : : verifySize ( qint64 requestSize ) <nl> - { <nl> - bool fVerified = ( requestSize < = BIP70_MAX_PAYMENTREQUEST_SIZE ) ; <nl> - if ( ! fVerified ) { <nl> - qWarning ( ) < < QString ( " PaymentServer : : % 1 : Payment request too large ( % 2 bytes , allowed % 3 bytes ) . " ) <nl> - . arg ( __func__ ) <nl> - . arg ( requestSize ) <nl> - . arg ( BIP70_MAX_PAYMENTREQUEST_SIZE ) ; <nl> - } <nl> - return fVerified ; <nl> - } <nl> - <nl> - bool PaymentServer : : verifyAmount ( const CAmount & requestAmount ) <nl> - { <nl> - bool fVerified = MoneyRange ( requestAmount ) ; <nl> - if ( ! fVerified ) { <nl> - qWarning ( ) < < QString ( " PaymentServer : : % 1 : Payment request amount out of allowed range ( % 2 , allowed 0 - % 3 ) . " ) <nl> - . arg ( __func__ ) <nl> - . arg ( requestAmount ) <nl> - . arg ( MAX_MONEY ) ; <nl> - } <nl> - return fVerified ; <nl> - } <nl> - <nl> - X509_STORE * PaymentServer : : getCertStore ( ) <nl> - { <nl> - return certStore . get ( ) ; <nl> - } <nl> - # endif <nl> mmm a / src / qt / paymentserver . h <nl> ppp b / src / qt / paymentserver . h <nl> <nl> # include < config / bitcoin - config . h > <nl> # endif <nl> <nl> - # ifdef ENABLE_BIP70 <nl> - # include < qt / paymentrequestplus . h > <nl> - # endif <nl> # include < qt / walletmodel . h > <nl> <nl> # include < QObject > <nl> QT_BEGIN_NAMESPACE <nl> class QApplication ; <nl> class QByteArray ; <nl> class QLocalServer ; <nl> - class QNetworkAccessManager ; <nl> - class QNetworkReply ; <nl> - class QSslError ; <nl> class QUrl ; <nl> QT_END_NAMESPACE <nl> <nl> - / / BIP70 max payment request size in bytes ( DoS protection ) <nl> - static const qint64 BIP70_MAX_PAYMENTREQUEST_SIZE = 50000 ; <nl> - <nl> class PaymentServer : public QObject <nl> { <nl> Q_OBJECT <nl> class PaymentServer : public QObject <nl> / / OptionsModel is used for getting proxy settings and display unit <nl> void setOptionsModel ( OptionsModel * optionsModel ) ; <nl> <nl> - # ifdef ENABLE_BIP70 <nl> - / / Load root certificate authorities . Pass nullptr ( default ) <nl> - / / to read from the file specified in the - rootcertificates setting , <nl> - / / or , if that ' s not set , to use the system default root certificates . <nl> - / / If you pass in a store , you should not X509_STORE_free it : it will be <nl> - / / freed either at exit or when another set of CAs are loaded . <nl> - static void LoadRootCAs ( X509_STORE * store = nullptr ) ; <nl> - <nl> - / / Return certificate store <nl> - static X509_STORE * getCertStore ( ) ; <nl> - <nl> - / / Verify that the payment request network matches the client network <nl> - static bool verifyNetwork ( interfaces : : Node & node , const payments : : PaymentDetails & requestDetails ) ; <nl> - / / Verify if the payment request is expired <nl> - static bool verifyExpired ( const payments : : PaymentDetails & requestDetails ) ; <nl> - / / Verify the payment request size is valid as per BIP70 <nl> - static bool verifySize ( qint64 requestSize ) ; <nl> - / / Verify the payment request amount is valid <nl> - static bool verifyAmount ( const CAmount & requestAmount ) ; <nl> - # endif <nl> - <nl> Q_SIGNALS : <nl> / / Fired when a valid payment request is received <nl> void receivedPaymentRequest ( SendCoinsRecipient ) ; <nl> class PaymentServer : public QObject <nl> / / Fired when a message should be reported to the user <nl> void message ( const QString & title , const QString & message , unsigned int style ) ; <nl> <nl> - # ifdef ENABLE_BIP70 <nl> - / / Fired when a valid PaymentACK is received <nl> - void receivedPaymentACK ( const QString & paymentACKMsg ) ; <nl> - # endif <nl> - <nl> public Q_SLOTS : <nl> / / Signal this when the main window ' s UI is ready <nl> / / to display payment requests to the user <nl> public Q_SLOTS : <nl> / / Handle an incoming URI , URI with local file scheme or file <nl> void handleURIOrFile ( const QString & s ) ; <nl> <nl> - # ifdef ENABLE_BIP70 <nl> - / / Submit Payment message to a merchant , get back PaymentACK : <nl> - void fetchPaymentACK ( WalletModel * walletModel , const SendCoinsRecipient & recipient , QByteArray transaction ) ; <nl> - # endif <nl> - <nl> private Q_SLOTS : <nl> void handleURIConnection ( ) ; <nl> - # ifdef ENABLE_BIP70 <nl> - void netRequestFinished ( QNetworkReply * ) ; <nl> - void reportSslErrors ( QNetworkReply * , const QList < QSslError > & ) ; <nl> - void handlePaymentACK ( const QString & paymentACKMsg ) ; <nl> - # endif <nl> <nl> protected : <nl> / / Constructor registers this on the parent QApplication to <nl> private Q_SLOTS : <nl> bool saveURIs ; / / true during startup <nl> QLocalServer * uriServer ; <nl> OptionsModel * optionsModel ; <nl> - <nl> - # ifdef ENABLE_BIP70 <nl> - static bool readPaymentRequestFromFile ( const QString & filename , PaymentRequestPlus & request ) ; <nl> - bool processPaymentRequest ( const PaymentRequestPlus & request , SendCoinsRecipient & recipient ) ; <nl> - void fetchRequest ( const QUrl & url ) ; <nl> - <nl> - / / Setup networking <nl> - void initNetManager ( ) ; <nl> - QNetworkAccessManager * netManager ; / / Used to fetch payment requests <nl> - # endif <nl> } ; <nl> <nl> # endif / / BITCOIN_QT_PAYMENTSERVER_H <nl> mmm a / src / qt / sendcoinsdialog . cpp <nl> ppp b / src / qt / sendcoinsdialog . cpp <nl> void SendCoinsDialog : : on_sendButton_clicked ( ) <nl> <nl> QString recipientElement ; <nl> <nl> - # ifdef ENABLE_BIP70 <nl> - if ( ! rcp . paymentRequest . IsInitialized ( ) ) / / normal payment <nl> - # endif <nl> { <nl> if ( rcp . label . length ( ) > 0 ) / / label with address <nl> { <nl> void SendCoinsDialog : : on_sendButton_clicked ( ) <nl> recipientElement . append ( tr ( " % 1 to % 2 " ) . arg ( amount , address ) ) ; <nl> } <nl> } <nl> - # ifdef ENABLE_BIP70 <nl> - else if ( ! rcp . authenticatedMerchant . isEmpty ( ) ) / / authenticated payment request <nl> - { <nl> - recipientElement . append ( tr ( " % 1 to ' % 2 ' " ) . arg ( amount , rcp . authenticatedMerchant ) ) ; <nl> - } <nl> - else / / unauthenticated payment request <nl> - { <nl> - recipientElement . append ( tr ( " % 1 to % 2 " ) . arg ( amount , address ) ) ; <nl> - } <nl> - # endif <nl> - <nl> formatted . append ( recipientElement ) ; <nl> } <nl> <nl> mmm a / src / qt / sendcoinsentry . cpp <nl> ppp b / src / qt / sendcoinsentry . cpp <nl> bool SendCoinsEntry : : validate ( interfaces : : Node & node ) <nl> / / Check input validity <nl> bool retval = true ; <nl> <nl> - # ifdef ENABLE_BIP70 <nl> - / / Skip checks for payment request <nl> - if ( recipient . paymentRequest . IsInitialized ( ) ) <nl> - return retval ; <nl> - # endif <nl> - <nl> if ( ! model - > validateAddress ( ui - > payTo - > text ( ) ) ) <nl> { <nl> ui - > payTo - > setValid ( false ) ; <nl> bool SendCoinsEntry : : validate ( interfaces : : Node & node ) <nl> <nl> SendCoinsRecipient SendCoinsEntry : : getValue ( ) <nl> { <nl> - # ifdef ENABLE_BIP70 <nl> - / / Payment request <nl> - if ( recipient . paymentRequest . IsInitialized ( ) ) <nl> - return recipient ; <nl> - # endif <nl> - <nl> - / / Normal payment <nl> recipient . address = ui - > payTo - > text ( ) ; <nl> recipient . label = ui - > addAsLabel - > text ( ) ; <nl> recipient . amount = ui - > payAmount - > value ( ) ; <nl> QWidget * SendCoinsEntry : : setupTabChain ( QWidget * prev ) <nl> void SendCoinsEntry : : setValue ( const SendCoinsRecipient & value ) <nl> { <nl> recipient = value ; <nl> - <nl> - # ifdef ENABLE_BIP70 <nl> - if ( recipient . paymentRequest . IsInitialized ( ) ) / / payment request <nl> - { <nl> - if ( recipient . authenticatedMerchant . isEmpty ( ) ) / / unauthenticated <nl> - { <nl> - ui - > payTo_is - > setText ( recipient . address ) ; <nl> - ui - > memoTextLabel_is - > setText ( recipient . message ) ; <nl> - ui - > payAmount_is - > setValue ( recipient . amount ) ; <nl> - ui - > payAmount_is - > setReadOnly ( true ) ; <nl> - setCurrentWidget ( ui - > SendCoins_UnauthenticatedPaymentRequest ) ; <nl> - } <nl> - else / / authenticated <nl> - { <nl> - ui - > payTo_s - > setText ( recipient . authenticatedMerchant ) ; <nl> - ui - > memoTextLabel_s - > setText ( recipient . message ) ; <nl> - ui - > payAmount_s - > setValue ( recipient . amount ) ; <nl> - ui - > payAmount_s - > setReadOnly ( true ) ; <nl> - setCurrentWidget ( ui - > SendCoins_AuthenticatedPaymentRequest ) ; <nl> - } <nl> - } <nl> - else / / normal payment <nl> - # endif <nl> { <nl> / / message <nl> ui - > messageTextLabel - > setText ( recipient . message ) ; <nl> mmm a / src / qt / test / compattests . cpp <nl> ppp b / src / qt / test / compattests . cpp <nl> <nl> # include < config / bitcoin - config . h > <nl> # endif <nl> <nl> - # if defined ( ENABLE_WALLET ) & & defined ( ENABLE_BIP70 ) <nl> - # include < qt / paymentrequestplus . h > / / this includes protobuf ' s port . h which defines its own bswap macos <nl> - # endif <nl> - <nl> # include < qt / test / compattests . h > <nl> <nl> # include < compat / byteswap . h > <nl> deleted file mode 100644 <nl> index 7f45d30973a4 . . 000000000000 <nl> mmm a / src / qt / test / paymentrequestdata . h <nl> ppp / dev / null <nl> <nl> - / / Copyright ( c ) 2009 - 2018 The Bitcoin Core developers <nl> - / / Distributed under the MIT software license , see the accompanying <nl> - / / file COPYING or http : / / www . opensource . org / licenses / mit - license . php . <nl> - <nl> - # ifndef BITCOIN_QT_TEST_PAYMENTREQUESTDATA_H <nl> - # define BITCOIN_QT_TEST_PAYMENTREQUESTDATA_H <nl> - <nl> - / / <nl> - / / Data for paymentservertests . cpp <nl> - / / <nl> - <nl> - / / Base64 / DER - encoded fake certificate authority certificates . <nl> - / / Convert pem to base64 / der with : <nl> - / / openssl x509 - in cert . pem - inform PEM - outform DER | openssl enc - base64 <nl> - <nl> - / / Serial Number : 10302349811211485352 ( 0x8ef94c91b112c0a8 ) <nl> - / / Issuer : CN = PaymentRequest Test CA <nl> - / / Subject : CN = PaymentRequest Test CA <nl> - / / Not Valid After : Dec 8 16 : 37 : 24 2022 GMT <nl> - / / <nl> - const char * caCert1_BASE64 = <nl> - " \ <nl> - MIIB0DCCATmgAwIBAgIJAI75TJGxEsCoMA0GCSqGSIb3DQEBCwUAMCExHzAdBgNV \ <nl> - BAMTFlBheW1lbnRSZXF1ZXN0IFRlc3QgQ0EwHhcNMTIxMjEwMTYzNzI0WhcNMjIx \ <nl> - MjA4MTYzNzI0WjAhMR8wHQYDVQQDExZQYXltZW50UmVxdWVzdCBUZXN0IENBMIGf \ <nl> - MA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCvua59nX9radoqDYyplcns5qdVDTN1 \ <nl> - 7tmcGixmMYOYU3UYMU55VSsJs0dWKnMm3COQDY + N63c0XSbRqarBcsLTkaNASuPX \ <nl> - FCv1VWuEKSyy5xe4zeoDU7CVSzlxtQD9wbZW / s3ISjgaXBpwn6eVmntb0JwYxxPc \ <nl> - M1u / hrMD8BDbSQIDAQABoxAwDjAMBgNVHRMEBTADAQH / MA0GCSqGSIb3DQEBCwUA \ <nl> - A4GBADSaRgK5xe47XxycXBhHhr0Wgl4pAsFsufqA9aB9r8KNEHJ0yUvvbD / jaJJM \ <nl> - RtQcf0AJ9olzUMY4syehxbzUJP6aeXhZEYiMvdvcv9D55clq6 + WLLlNT3jBgAaVn \ <nl> - p3waRjPD4bUX3nv + ojz5s4puw7Qq5QUZlhGsMzPvwDGCmZkL \ <nl> - " ; <nl> - <nl> - / / Serial Number : f0 : da : 97 : e4 : 38 : d7 : 64 : 16 <nl> - / / Issuer : CN = PaymentRequest Test CA <nl> - / / Subject : CN = PaymentRequest Test CA <nl> - / / Not Valid After : Jan 8 18 : 21 : 06 2025 GMT <nl> - / / <nl> - const char * caCert2_BASE64 = <nl> - " \ <nl> - MIIC1TCCAb2gAwIBAgIJAPDal + Q412QWMA0GCSqGSIb3DQEBCwUAMCExHzAdBgNV \ <nl> - BAMMFlBheW1lbnRSZXF1ZXN0IFRlc3QgQ0EwHhcNMTUwMTExMTgyMTA2WhcNMjUw \ <nl> - MTA4MTgyMTA2WjAhMR8wHQYDVQQDDBZQYXltZW50UmVxdWVzdCBUZXN0IENBMIIB \ <nl> - IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1S9wVLfTplJuT / 1OaaBgl / Mb \ <nl> - I392v8S9kHbzYz7B4OTMslaO7piz0v3SO3TKMh0dswjiRdHrIgpO7XdIUQiU / ugg \ <nl> - xDw0kuNehfz1ycaGedlFFtFHTNXqLyIUF3dlwHhQwaomM6RXoJmxLny5BhYHEcmk \ <nl> - yWwr3Cdjd9gAZpblugVJB9C1e40uyL8ao4PHdLzOqO27iSe6riP8SwwisJZEbMaz \ <nl> - AZpgNEEMbIXPJEFvm5HTRXSMtQCOTSZYMFF0M2yrtmlECnz7hWP19b9bcoDzZQB4 \ <nl> - ylIsFG / 7q2jV7MC / e2STZv + niJiHL08RUdoFpAgzaxMgqj63C7B55HgNDNHJYQID \ <nl> - AQABoxAwDjAMBgNVHRMEBTADAQH / MA0GCSqGSIb3DQEBCwUAA4IBAQBGejPxLxj9 \ <nl> - + crv6gUeEBMZPiUx7pUgcI22Wm5yymP96B4fwI3Y0DBehq20d76vbWGPN17Z6pH3 \ <nl> - ge7PVY1SYqXtS6hXTo4olCm / BZADli + 2Bs2xCiaa + Ltve4ufVej + bKJXN / YnrhvO \ <nl> - Kq + klQkuuHywU + GJV / NQeBqToIrSOBgi477NgLFCCCmmx2QWsxHoCFGfuRCBVseT \ <nl> - z2k / tMuALCDXGeZBRPTsGHu1y4cj84swAeoDK5QSQcI + Ub7GKc + zkoj02sdDLiMo \ <nl> - 3wokYPcIy47oclhmb4xubHc + y7nF610yZBoC / zgbhbawnZ65hDDWkdQ / SVAnWZD7 \ <nl> - 9PFfmNnYPTQH \ <nl> - " ; <nl> - <nl> - / / <nl> - / / This payment request validates directly against the <nl> - / / caCert1 certificate authority . <nl> - / / <nl> - const char * paymentrequest1_cert1_BASE64 = <nl> - " \ <nl> - Egt4NTA5K3NoYTI1NhrxAwruAzCCAeowggFToAMCAQICAQEwDQYJKoZIhvcNAQEL \ <nl> - BQAwITEfMB0GA1UEAxMWUGF5bWVudFJlcXVlc3QgVGVzdCBDQTAeFw0xMjEyMTAx \ <nl> - NjM3MjRaFw0yMjEyMDgxNjM3MjRaMEMxGTAXBgNVBAMMEHRlc3RtZXJjaGFudC5v \ <nl> - cmcxJjAkBgNVBAoMHVBheW1lbnQgUmVxdWVzdCBUZXN0IE1lcmNoYW50MIGfMA0G \ <nl> - CSqGSIb3DQEBAQUAA4GNADCBiQKBgQDHkMy8W1u6HsWlSqdWTmMKf54gICxNfxbY \ <nl> - + rcMtAftr62hCYx2d2QiSRd1pCUzmo12IiSX3WxSHwaTnT3MFD6jRx6 + zM6XdGar \ <nl> - I2zpYle11ANzu4gAthN17uRQHV2O5QxVtzNaMdKeJLXT2L9tfEdyL + + 9ZUqoQmdA \ <nl> - YG9ix330hQIDAQABoxAwDjAMBgNVHRMEBTADAQH / MA0GCSqGSIb3DQEBCwUAA4GB \ <nl> - AIkyO99KC68bi9PFRyQQ7nvn5GlQEb3Ca1bRG5 + AKN9N5vc8rZ9G2hejtM8wEXni \ <nl> - eGBP + chVMsbTPEHKLrwREn7IvcyCcbAStaklPC3w0B / 2idQSHskb6P3X13OR2bTH \ <nl> - a2 + 6wuhsOZRUrVNr24rM95DKx / eCC6JN1VW + qRPU6fqzIjQSHwiw2wYSGXapFJVg \ <nl> - igPI + 6XpExtNLO / i1WFV8ZmoiKwYsuHFiwUqC1VuaXRUZXN0T25lKoABS0j59iMU \ <nl> - Uc9MdIfwsO1BskIET0eJSGNZ7eXb9N62u + qf831PMpEHkmlGpk8rHy92nPcgua / U \ <nl> - Yt8oZMn3QaTZ5A6HjJbc3A73eLylp1a0SwCl + KDMEvDQhqMn1jAVu2v92AH3uB7n \ <nl> - SiWVbw0tX / 68iSQEGGfh9n6ee / 8Myb3ICdw = \ <nl> - " ; <nl> - <nl> - / / <nl> - / / Signed , but expired , merchant cert in the request <nl> - / / <nl> - const char * paymentrequest2_cert1_BASE64 = <nl> - " \ <nl> - Egt4NTA5K3NoYTI1NhrsAwrpAzCCAeUwggFOoAMCAQICAQMwDQYJKoZIhvcNAQEL \ <nl> - BQAwITEfMB0GA1UEAxMWUGF5bWVudFJlcXVlc3QgVGVzdCBDQTAeFw0xMzAyMjMy \ <nl> - MTI2NDNaFw0xMzAyMjQyMTI2NDNaMD4xHDAaBgNVBAMME2V4cGlyZWRtZXJjaGFu \ <nl> - dC5vcmcxHjAcBgNVBAoMFUV4cGlyZWQgVGVzdCBNZXJjaGFudDCBnzANBgkqhkiG \ <nl> - 9w0BAQEFAAOBjQAwgYkCgYEAx5DMvFtbuh7FpUqnVk5jCn + eICAsTX8W2Pq3DLQH \ <nl> - 7a + toQmMdndkIkkXdaQlM5qNdiIkl91sUh8Gk509zBQ + o0cevszOl3RmqyNs6WJX \ <nl> - tdQDc7uIALYTde7kUB1djuUMVbczWjHSniS109i / bXxHci / vvWVKqEJnQGBvYsd9 \ <nl> - 9IUCAwEAAaMQMA4wDAYDVR0TBAUwAwEB / zANBgkqhkiG9w0BAQsFAAOBgQAaU137 \ <nl> - j53rvSjlmYZpZ4RWTP7EdD6fl5ZxBeXHytN6DQL33H0eD7OFHt + ofc7E6D7keubl \ <nl> - UfCu + jOvt / MvvPUmtCI9yXZ0dNC4sjyETv + wQpxO0UNZwOM4uegdCzlo6Bi3pD4 / \ <nl> - KKLdMkWuUfuPBmoammny74lZaOVr5deKXztTuCI0Eh8IsNsGEhl2qRSVYIoDyPul \ <nl> - 6RMbTSzv4tVhVfGZqIisGLLhxYsFKgtVbml0VGVzdFR3byqAAXHuo4nZEPniLpkd \ <nl> - y30TkwBxVgprWJ18a9z / 7Py35Qss / JMbOXbnBhJtmJCdIowHRI0aa + zqt3KKKAXi \ <nl> - mm + V4seMgxTcxMS + eDDkiTcB / RtWWSyRcS2ANjFeY0T4SLMwiCL9qWPi03hr8j96 \ <nl> - tejrSPOBNSJ3Mi / q5u2Yl4gJZY2b \ <nl> - " ; <nl> - <nl> - / / <nl> - / / 10 - long certificate chain , all intermediates valid <nl> - / / <nl> - const char * paymentrequest3_cert1_BASE64 = <nl> - " \ <nl> - Egt4NTA5K3NoYTI1Nhq8JAr / AzCCAfswggFkoAMCAQICAQEwDQYJKoZIhvcNAQEL \ <nl> - BQAwPzEUMBIGA1UEAwwLdGVzdGNhOC5vcmcxJzAlBgNVBAoMHlBheW1lbnQgUmVx \ <nl> - dWVzdCBJbnRlcm1lZGlhdGUgODAeFw0xMzAyMjMyMjQyMzFaFw0yMzAyMjEyMjQy \ <nl> - MzFaMDYxGjAYBgNVBAMMEXRlc3RtZXJjaGFudDgub3JnMRgwFgYDVQQKDA9UZXN0 \ <nl> - IE1lcmNoYW50IDgwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMMCHA3hiHbS \ <nl> - TKZ5K9jHRwE8NxkGp3IOx56PDB2diNkldG8XweTcRq7bBm7pdiBt4IVggtfs + 6hE \ <nl> - hDYIOecyoAnVzPFTdvQ7KQdQ / fD9YLe6lk + o0edOqutPMyrxLFjSluXxEQyk7fdt \ <nl> - URloMMYfp3p1 / hFCboA1rAsQ2RW38hR5AgMBAAGjEDAOMAwGA1UdEwQFMAMBAf8w \ <nl> - DQYJKoZIhvcNAQELBQADgYEAPsdFatnc2RJSpvZsw + nCiPVsllycw5ELglq9vfJz \ <nl> - nJJucRxgzmqI2iuas1ugwbXn0BEIRLK7vMF / qBzQR6M / nTxttah + KEu + okjps9vJ \ <nl> - cIyhfTyGPC5xkHaHZ7sG + UHOFhPw0 / kXn0x + pbVgBZ5315axqcp1R + DTSj / whMAr \ <nl> - n0AKiAQwggIEMIIBbaADAgECAgECMA0GCSqGSIb3DQEBCwUAMD8xFDASBgNVBAMM \ <nl> - C3Rlc3RjYTcub3JnMScwJQYDVQQKDB5QYXltZW50IFJlcXVlc3QgSW50ZXJtZWRp \ <nl> - YXRlIDcwHhcNMTMwMjIzMjI0MjMxWhcNMjMwMjIxMjI0MjMxWjA / MRQwEgYDVQQD \ <nl> - DAt0ZXN0Y2E4Lm9yZzEnMCUGA1UECgweUGF5bWVudCBSZXF1ZXN0IEludGVybWVk \ <nl> - aWF0ZSA4MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDexUFfxb1sThvabp7u \ <nl> - dZz59ciThGmmAW0nP4tjrgEACgvWIInr2dZpTHbiQNF34ycsk0le1JD93D7Qb8rd \ <nl> - 25OrpaO8XS2Li2zjR9cleixXjSLwV / zv8zJ8yPl / 27XL + + PDTKBXVpJ8 / Syp + 9Ty \ <nl> - plV1BqDhqtIHb / QSHEkTQXjeYQIDAQABoxAwDjAMBgNVHRMEBTADAQH / MA0GCSqG \ <nl> - SIb3DQEBCwUAA4GBACMooQVbkbIZ2DaPwHDc4ULwguG3VI2Kzj50UdExmHtzm2S4 \ <nl> - MQei + n + HEPjtJAx5OY520 + 10nfuP + 12H2DRLQmWmdvDpeQ / Cv0yavlw4ZRejRFo7 \ <nl> - KS83C0wo5rd + qTvvOmAN4UTArWkzYcEUulPdiXnRamb0WQHTeVdIbHVkMormCogE \ <nl> - MIICBDCCAW2gAwIBAgIBAjANBgkqhkiG9w0BAQsFADA / MRQwEgYDVQQDDAt0ZXN0 \ <nl> - Y2E2Lm9yZzEnMCUGA1UECgweUGF5bWVudCBSZXF1ZXN0IEludGVybWVkaWF0ZSA2 \ <nl> - MB4XDTEzMDIyMzIyNDIzMVoXDTIzMDIyMTIyNDIzMVowPzEUMBIGA1UEAwwLdGVz \ <nl> - dGNhNy5vcmcxJzAlBgNVBAoMHlBheW1lbnQgUmVxdWVzdCBJbnRlcm1lZGlhdGUg \ <nl> - NzCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAtjBRazrkebXAhXsbjimrMIRm \ <nl> - W / f9SwAHwXfc042keNtl0t2z6XE6UPcR2v / KrssXuCZgodeYxz6IM6lWosCM1xot \ <nl> - C3ChKKFBfVO30reuKBRUxXfKAFqxaG0YOAEzdZkkY9AGhqWloeSmgxpIfhInU0EF \ <nl> - JjCwrJ6IkijBatGoAAECAwEAAaMQMA4wDAYDVR0TBAUwAwEB / zANBgkqhkiG9w0B \ <nl> - AQsFAAOBgQDBRTi1MolmOA0niHYX0A2lN5QWHkCfX0A7GwyoMA3dvM45m / NYd4WB \ <nl> - X + HwfnfYcI6X9jOgNo5OWmc4GGsld0HlxwMYEKISBS9PbSHPBrb3TBOlw5ztQpXZ \ <nl> - 91 + bOhLux52Fr03sK7v9qExmBM12M8UR2ltpzAMiUgLLMHyPfiWkvQqIBDCCAgQw \ <nl> - ggFtoAMCAQICAQIwDQYJKoZIhvcNAQELBQAwPzEUMBIGA1UEAwwLdGVzdGNhNS5v \ <nl> - cmcxJzAlBgNVBAoMHlBheW1lbnQgUmVxdWVzdCBJbnRlcm1lZGlhdGUgNTAeFw0x \ <nl> - MzAyMjMyMjQyMzBaFw0yMzAyMjEyMjQyMzBaMD8xFDASBgNVBAMMC3Rlc3RjYTYu \ <nl> - b3JnMScwJQYDVQQKDB5QYXltZW50IFJlcXVlc3QgSW50ZXJtZWRpYXRlIDYwgZ8w \ <nl> - DQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANJSH3xivX1t9olIdHsznI1aE9SD7t9i \ <nl> - SZJsIB0otoETHZRVv9M9LvyzBNK98ZV + kTOlST7PJgC0d9BQM9sgYApSRq5oqKDM \ <nl> - 9FXbOm / yaReAbU3mkFNFw5roTlJ5ThEy0yOGT / DS0YBRaGIvRPRj2DiqDVdCZZ + w \ <nl> - 4jo1IYHkZt4FAgMBAAGjEDAOMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQAD \ <nl> - gYEATm6 + J1OmbrothO60xALKonWMBKr6hudb4amkFBqKbA9wMeM3jl + I / yKfz / Uf \ <nl> - xWuJ071IhiNv6Gxx5YwNvhUe1xMhUqHv0gpyK1Z47bD + kYS2se5sWNPNo3Y9qZDG \ <nl> - IXiGQxwHmrzaFk79Uy1xsmvsEz42w6hr25Yaw7HkIgrFveoKiAQwggIEMIIBbaAD \ <nl> - AgECAgECMA0GCSqGSIb3DQEBCwUAMD8xFDASBgNVBAMMC3Rlc3RjYTQub3JnMScw \ <nl> - JQYDVQQKDB5QYXltZW50IFJlcXVlc3QgSW50ZXJtZWRpYXRlIDQwHhcNMTMwMjIz \ <nl> - MjI0MjMwWhcNMjMwMjIxMjI0MjMwWjA / MRQwEgYDVQQDDAt0ZXN0Y2E1Lm9yZzEn \ <nl> - MCUGA1UECgweUGF5bWVudCBSZXF1ZXN0IEludGVybWVkaWF0ZSA1MIGfMA0GCSqG \ <nl> - SIb3DQEBAQUAA4GNADCBiQKBgQC7vVUFpxHzz2Tr / xij3k58s8d / BPA0R6D5RXTV \ <nl> - vmhAzc1Zuin4zUKRFs / aCj / 0yED8Wu / COfNGF4tVlRNMdl9EcFsxa8XGEL4eAZa + \ <nl> - H / rOHH + 7 / 1EINrrVWhZlUecyhilN8jmCZmqEM3ecuD0NAViqyMrgmaiFmsLoQZpE \ <nl> - GepDUQIDAQABoxAwDjAMBgNVHRMEBTADAQH / MA0GCSqGSIb3DQEBCwUAA4GBAEdJ \ <nl> - Ss8jWiooja3WZzHXeF95QkBJNjIlpDLGcpl4opOYLSuEl9Uxp / / LaQQiXuzpj4 / I \ <nl> - pkWGQmMy5HOyH1lqDyiMgXpcG8PE0jEQAoEUGZ0QEqB1mZ6BCrYvmUuf / 5aSVd8Y \ <nl> - 6lKMR3WzFDYU9Zy0nzuHB / 3nvp6MeDRQeRMtYvz4CogEMIICBDCCAW2gAwIBAgIB \ <nl> - AjANBgkqhkiG9w0BAQsFADA / MRQwEgYDVQQDDAt0ZXN0Y2EzLm9yZzEnMCUGA1UE \ <nl> - CgweUGF5bWVudCBSZXF1ZXN0IEludGVybWVkaWF0ZSAzMB4XDTEzMDIyMzIyNDIy \ <nl> - OVoXDTIzMDIyMTIyNDIyOVowPzEUMBIGA1UEAwwLdGVzdGNhNC5vcmcxJzAlBgNV \ <nl> - BAoMHlBheW1lbnQgUmVxdWVzdCBJbnRlcm1lZGlhdGUgNDCBnzANBgkqhkiG9w0B \ <nl> - AQEFAAOBjQAwgYkCgYEAxYYo3w2UXiYg6O8b4QgwN / vgreTkiW122Ep / z2TiDrhV \ <nl> - MhfOOiKdwYESPflfnXnVaQQzCGexYTQqsvqvzHSyna5hL0zPTRJxSKmTVrXRsWtp \ <nl> - dCRhjxCGipS3tlQBDi7vb + 7SNRIBK4dBjjGzALNk7gMCpy + yM8f6I043jTlmGb0C \ <nl> - AwEAAaMQMA4wDAYDVR0TBAUwAwEB / zANBgkqhkiG9w0BAQsFAAOBgQDU + IQxt3Oh \ <nl> - KqaUYWC23 + cB2gekvWqwMBnrCNrX / Dp + kjoJKUoR2Fs3qw53raHES4SIhpGT9l9l \ <nl> - rppNQgFe / JMHeYqOZMZO + 6kuU0olJanBJ14tPIc7zlMTQ9OfmZ6v07IpyFbsQDtR \ <nl> - hpe80DpuvSFPfJ4fh0WrQf6kn3KDVpGDnAqIBDCCAgQwggFtoAMCAQICAQIwDQYJ \ <nl> - KoZIhvcNAQELBQAwPzEUMBIGA1UEAwwLdGVzdGNhMi5vcmcxJzAlBgNVBAoMHlBh \ <nl> - eW1lbnQgUmVxdWVzdCBJbnRlcm1lZGlhdGUgMjAeFw0xMzAyMjMyMjQyMjlaFw0y \ <nl> - MzAyMjEyMjQyMjlaMD8xFDASBgNVBAMMC3Rlc3RjYTMub3JnMScwJQYDVQQKDB5Q \ <nl> - YXltZW50IFJlcXVlc3QgSW50ZXJtZWRpYXRlIDMwgZ8wDQYJKoZIhvcNAQEBBQAD \ <nl> - gY0AMIGJAoGBANzgVP99Qg98e6NsKEz1v5KqRB7NTBRRsYnBvb / TSWipvMQaCYuE \ <nl> - yk1xG57x + + QuASKeR3QHRQJOoAhQaj9JLUhSSv9GQ5PrFLLsOFv7L1tpzXHh2dOB \ <nl> - IW92X2yFRW2s39q + Q21yvN + N8uoKdqXhzRA + dDoXh3cavaVeHX1G + IrlAgMBAAGj \ <nl> - EDAOMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQADgYEASTwg84cX + 1UhOG9s \ <nl> - ejFV3m34QuI1hPZ + qhqVJlRYUtego8Wng1BburDSwqVAv4ch2wi3c2s4e8J7AXyL \ <nl> - tzSbSQG4RN0oZi0mR8EtTTN + Mix / hBIk79dMZg85 + I29uFA6Zj2d9oAhQv2qkHhc \ <nl> - 6tcaheNvkQRlCyH68k3iF1Fqf + 4KiAQwggIEMIIBbaADAgECAgECMA0GCSqGSIb3 \ <nl> - DQEBCwUAMD8xFDASBgNVBAMMC3Rlc3RjYTEub3JnMScwJQYDVQQKDB5QYXltZW50 \ <nl> - IFJlcXVlc3QgSW50ZXJtZWRpYXRlIDEwHhcNMTMwMjIzMjI0MjI5WhcNMjMwMjIx \ <nl> - MjI0MjI5WjA / MRQwEgYDVQQDDAt0ZXN0Y2EyLm9yZzEnMCUGA1UECgweUGF5bWVu \ <nl> - dCBSZXF1ZXN0IEludGVybWVkaWF0ZSAyMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCB \ <nl> - iQKBgQDaV8zhfyQuSf / f + fauMfgs3g / RnWy9yxxUkvQneQQPH3uZzCyk3A6q72ip \ <nl> - TtwNqiibG9455L9A7SaUjGtnpUz0NKT / VWUdqbfCl1PqXjEZbDobbAQ5hxLGOTyL \ <nl> - RQhLIcgeq2 / BnmeCqHsC4md04nUp + nBo1HwKyygvK + 9sMbCp / wIDAQABoxAwDjAM \ <nl> - BgNVHRMEBTADAQH / MA0GCSqGSIb3DQEBCwUAA4GBACvYyE + PPmWFkbjyRu9LAt8D \ <nl> - crtyYYLRClKSg6tVvutwukLG2l / / kDOohYkJtgTqr6LnCIIIwYdXN + 4wxugmw4cn \ <nl> - PIZmP6kovxjhhVM95okilor1zniTAo3RN7JDIfTGNgxLdGu1btt7DOFL4zTbeSJM \ <nl> - b8M1JpPftehH + x / VLyuUCuoDMIIB5jCCAU + gAwIBAgIBBTANBgkqhkiG9w0BAQsF \ <nl> - ADAhMR8wHQYDVQQDExZQYXltZW50UmVxdWVzdCBUZXN0IENBMB4XDTEzMDIyMzIy \ <nl> - NDIyOFoXDTIzMDIyMTIyNDIyOFowPzEUMBIGA1UEAwwLdGVzdGNhMS5vcmcxJzAl \ <nl> - BgNVBAoMHlBheW1lbnQgUmVxdWVzdCBJbnRlcm1lZGlhdGUgMTCBnzANBgkqhkiG \ <nl> - 9w0BAQEFAAOBjQAwgYkCgYEAo5Vy9H3nA / OOkF5Ap89yfVNSiTay / LYCaB0eALpc \ <nl> - U690U75O9Q3w2M + 2AN8wpbbHsJHZMIjEeBRoQfjlYXW1ucQTxWKyT + liu0D25mGX \ <nl> - X27CBXBd4iXTxVII / iX + u3lcjORjoHOBy7QgeIDIIS9y0vYu8eArpjh7m4thrVgI \ <nl> - RtMCAwEAAaMQMA4wDAYDVR0TBAUwAwEB / zANBgkqhkiG9w0BAQsFAAOBgQB9LKcV \ <nl> - JK9sjASNzpQlpUp7nCiw5FSjVY + XMRIKK / kavzlKjZ + InsmmyRVGjDoZi9GrqG9P \ <nl> - VHgLBxi2VtVjmokZoNPqao3OfhqORAubC + JR / JLepM7aDaxDdTHVhSUk4lgNAvi2 \ <nl> - 6dGY7nZMsnHlPQ2tPp / HvRRiMq1oDjlylc8VTCI2Eh8IsNsGEhl2qRSVYIoDyPul \ <nl> - 6RMbTSzv4tVhVfGZqIisGLLhxYsFKg1Vbml0VGVzdFRocmVlKoABn2HTsUQtMNI4 \ <nl> - yNvkfkFNka3pRvTUTydJrvyfmEeLzImfM1BWddZjnywku9RToNFZZNgow5QnljmF \ <nl> - chhR / aHOuEMTxmc12K4rNlgYtHCsxLP9zd + 6u0cva3TucZ6EzS8PKEib / + r12 / 52 \ <nl> - 664NuWA9WtsK7QCFrK2K95PnVCRmWl0 = \ <nl> - " ; <nl> - <nl> - / / <nl> - / / Long certificate chain , with an expired certificate in the middle <nl> - / / <nl> - const char * paymentrequest4_cert1_BASE64 = <nl> - " \ <nl> - Egt4NTA5K3NoYTI1NhqeJAr / AzCCAfswggFkoAMCAQICAQEwDQYJKoZIhvcNAQEL \ <nl> - BQAwPzEUMBIGA1UEAwwLdGVzdGNhOC5vcmcxJzAlBgNVBAoMHlBheW1lbnQgUmVx \ <nl> - dWVzdCBJbnRlcm1lZGlhdGUgODAeFw0xMzAyMjMyMjQyMzFaFw0yMzAyMjEyMjQy \ <nl> - MzFaMDYxGjAYBgNVBAMMEXRlc3RtZXJjaGFudDgub3JnMRgwFgYDVQQKDA9UZXN0 \ <nl> - IE1lcmNoYW50IDgwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMMCHA3hiHbS \ <nl> - TKZ5K9jHRwE8NxkGp3IOx56PDB2diNkldG8XweTcRq7bBm7pdiBt4IVggtfs + 6hE \ <nl> - hDYIOecyoAnVzPFTdvQ7KQdQ / fD9YLe6lk + o0edOqutPMyrxLFjSluXxEQyk7fdt \ <nl> - URloMMYfp3p1 / hFCboA1rAsQ2RW38hR5AgMBAAGjEDAOMAwGA1UdEwQFMAMBAf8w \ <nl> - DQYJKoZIhvcNAQELBQADgYEAPsdFatnc2RJSpvZsw + nCiPVsllycw5ELglq9vfJz \ <nl> - nJJucRxgzmqI2iuas1ugwbXn0BEIRLK7vMF / qBzQR6M / nTxttah + KEu + okjps9vJ \ <nl> - cIyhfTyGPC5xkHaHZ7sG + UHOFhPw0 / kXn0x + pbVgBZ5315axqcp1R + DTSj / whMAr \ <nl> - n0AKiAQwggIEMIIBbaADAgECAgECMA0GCSqGSIb3DQEBCwUAMD8xFDASBgNVBAMM \ <nl> - C3Rlc3RjYTcub3JnMScwJQYDVQQKDB5QYXltZW50IFJlcXVlc3QgSW50ZXJtZWRp \ <nl> - YXRlIDcwHhcNMTMwMjIzMjI0MjMxWhcNMjMwMjIxMjI0MjMxWjA / MRQwEgYDVQQD \ <nl> - DAt0ZXN0Y2E4Lm9yZzEnMCUGA1UECgweUGF5bWVudCBSZXF1ZXN0IEludGVybWVk \ <nl> - aWF0ZSA4MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDexUFfxb1sThvabp7u \ <nl> - dZz59ciThGmmAW0nP4tjrgEACgvWIInr2dZpTHbiQNF34ycsk0le1JD93D7Qb8rd \ <nl> - 25OrpaO8XS2Li2zjR9cleixXjSLwV / zv8zJ8yPl / 27XL + + PDTKBXVpJ8 / Syp + 9Ty \ <nl> - plV1BqDhqtIHb / QSHEkTQXjeYQIDAQABoxAwDjAMBgNVHRMEBTADAQH / MA0GCSqG \ <nl> - SIb3DQEBCwUAA4GBACMooQVbkbIZ2DaPwHDc4ULwguG3VI2Kzj50UdExmHtzm2S4 \ <nl> - MQei + n + HEPjtJAx5OY520 + 10nfuP + 12H2DRLQmWmdvDpeQ / Cv0yavlw4ZRejRFo7 \ <nl> - KS83C0wo5rd + qTvvOmAN4UTArWkzYcEUulPdiXnRamb0WQHTeVdIbHVkMormCogE \ <nl> - MIICBDCCAW2gAwIBAgIBAjANBgkqhkiG9w0BAQsFADA / MRQwEgYDVQQDDAt0ZXN0 \ <nl> - Y2E2Lm9yZzEnMCUGA1UECgweUGF5bWVudCBSZXF1ZXN0IEludGVybWVkaWF0ZSA2 \ <nl> - MB4XDTEzMDIyMzIyNDIzMVoXDTIzMDIyMTIyNDIzMVowPzEUMBIGA1UEAwwLdGVz \ <nl> - dGNhNy5vcmcxJzAlBgNVBAoMHlBheW1lbnQgUmVxdWVzdCBJbnRlcm1lZGlhdGUg \ <nl> - NzCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAtjBRazrkebXAhXsbjimrMIRm \ <nl> - W / f9SwAHwXfc042keNtl0t2z6XE6UPcR2v / KrssXuCZgodeYxz6IM6lWosCM1xot \ <nl> - C3ChKKFBfVO30reuKBRUxXfKAFqxaG0YOAEzdZkkY9AGhqWloeSmgxpIfhInU0EF \ <nl> - JjCwrJ6IkijBatGoAAECAwEAAaMQMA4wDAYDVR0TBAUwAwEB / zANBgkqhkiG9w0B \ <nl> - AQsFAAOBgQDBRTi1MolmOA0niHYX0A2lN5QWHkCfX0A7GwyoMA3dvM45m / NYd4WB \ <nl> - X + HwfnfYcI6X9jOgNo5OWmc4GGsld0HlxwMYEKISBS9PbSHPBrb3TBOlw5ztQpXZ \ <nl> - 91 + bOhLux52Fr03sK7v9qExmBM12M8UR2ltpzAMiUgLLMHyPfiWkvQqIBDCCAgQw \ <nl> - ggFtoAMCAQICAQIwDQYJKoZIhvcNAQELBQAwPzEUMBIGA1UEAwwLdGVzdGNhNS5v \ <nl> - cmcxJzAlBgNVBAoMHlBheW1lbnQgUmVxdWVzdCBJbnRlcm1lZGlhdGUgNTAeFw0x \ <nl> - MzAyMjMyMjQyMzBaFw0yMzAyMjEyMjQyMzBaMD8xFDASBgNVBAMMC3Rlc3RjYTYu \ <nl> - b3JnMScwJQYDVQQKDB5QYXltZW50IFJlcXVlc3QgSW50ZXJtZWRpYXRlIDYwgZ8w \ <nl> - DQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANJSH3xivX1t9olIdHsznI1aE9SD7t9i \ <nl> - SZJsIB0otoETHZRVv9M9LvyzBNK98ZV + kTOlST7PJgC0d9BQM9sgYApSRq5oqKDM \ <nl> - 9FXbOm / yaReAbU3mkFNFw5roTlJ5ThEy0yOGT / DS0YBRaGIvRPRj2DiqDVdCZZ + w \ <nl> - 4jo1IYHkZt4FAgMBAAGjEDAOMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQAD \ <nl> - gYEATm6 + J1OmbrothO60xALKonWMBKr6hudb4amkFBqKbA9wMeM3jl + I / yKfz / Uf \ <nl> - xWuJ071IhiNv6Gxx5YwNvhUe1xMhUqHv0gpyK1Z47bD + kYS2se5sWNPNo3Y9qZDG \ <nl> - IXiGQxwHmrzaFk79Uy1xsmvsEz42w6hr25Yaw7HkIgrFveoK6gMwggHmMIIBT6AD \ <nl> - AgECAgEGMA0GCSqGSIb3DQEBCwUAMCExHzAdBgNVBAMTFlBheW1lbnRSZXF1ZXN0 \ <nl> - IFRlc3QgQ0EwHhcNMTMwMjIzMjI1OTUxWhcNMTMwMjI0MjI1OTUxWjA / MRQwEgYD \ <nl> - VQQDDAt0ZXN0Y2E1Lm9yZzEnMCUGA1UECgweUGF5bWVudCBSZXF1ZXN0IEludGVy \ <nl> - bWVkaWF0ZSA1MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC7vVUFpxHzz2Tr \ <nl> - / xij3k58s8d / BPA0R6D5RXTVvmhAzc1Zuin4zUKRFs / aCj / 0yED8Wu / COfNGF4tV \ <nl> - lRNMdl9EcFsxa8XGEL4eAZa + H / rOHH + 7 / 1EINrrVWhZlUecyhilN8jmCZmqEM3ec \ <nl> - uD0NAViqyMrgmaiFmsLoQZpEGepDUQIDAQABoxAwDjAMBgNVHRMEBTADAQH / MA0G \ <nl> - CSqGSIb3DQEBCwUAA4GBAEmcUEnhua / oiXy1fwScLgMqt + jk9mHRpE6SVsIop23Q \ <nl> - CY2JfpG6RxhMMzzzhGklEGN6cxG0HCi6B3HJx6PYrFEfTB0rW4K6m0Tvx3WpS9mN \ <nl> - uoEuJHLy18ausI / sYAPDHCL + SfBVcqorpaIG2sSpZouRBjRHAyqFAYlwlW87uq5n \ <nl> - CogEMIICBDCCAW2gAwIBAgIBAjANBgkqhkiG9w0BAQsFADA / MRQwEgYDVQQDDAt0 \ <nl> - ZXN0Y2EzLm9yZzEnMCUGA1UECgweUGF5bWVudCBSZXF1ZXN0IEludGVybWVkaWF0 \ <nl> - ZSAzMB4XDTEzMDIyMzIyNDIyOVoXDTIzMDIyMTIyNDIyOVowPzEUMBIGA1UEAwwL \ <nl> - dGVzdGNhNC5vcmcxJzAlBgNVBAoMHlBheW1lbnQgUmVxdWVzdCBJbnRlcm1lZGlh \ <nl> - dGUgNDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAxYYo3w2UXiYg6O8b4Qgw \ <nl> - N / vgreTkiW122Ep / z2TiDrhVMhfOOiKdwYESPflfnXnVaQQzCGexYTQqsvqvzHSy \ <nl> - na5hL0zPTRJxSKmTVrXRsWtpdCRhjxCGipS3tlQBDi7vb + 7SNRIBK4dBjjGzALNk \ <nl> - 7gMCpy + yM8f6I043jTlmGb0CAwEAAaMQMA4wDAYDVR0TBAUwAwEB / zANBgkqhkiG \ <nl> - 9w0BAQsFAAOBgQDU + IQxt3OhKqaUYWC23 + cB2gekvWqwMBnrCNrX / Dp + kjoJKUoR \ <nl> - 2Fs3qw53raHES4SIhpGT9l9lrppNQgFe / JMHeYqOZMZO + 6kuU0olJanBJ14tPIc7 \ <nl> - zlMTQ9OfmZ6v07IpyFbsQDtRhpe80DpuvSFPfJ4fh0WrQf6kn3KDVpGDnAqIBDCC \ <nl> - AgQwggFtoAMCAQICAQIwDQYJKoZIhvcNAQELBQAwPzEUMBIGA1UEAwwLdGVzdGNh \ <nl> - Mi5vcmcxJzAlBgNVBAoMHlBheW1lbnQgUmVxdWVzdCBJbnRlcm1lZGlhdGUgMjAe \ <nl> - Fw0xMzAyMjMyMjQyMjlaFw0yMzAyMjEyMjQyMjlaMD8xFDASBgNVBAMMC3Rlc3Rj \ <nl> - YTMub3JnMScwJQYDVQQKDB5QYXltZW50IFJlcXVlc3QgSW50ZXJtZWRpYXRlIDMw \ <nl> - gZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANzgVP99Qg98e6NsKEz1v5KqRB7N \ <nl> - TBRRsYnBvb / TSWipvMQaCYuEyk1xG57x + + QuASKeR3QHRQJOoAhQaj9JLUhSSv9G \ <nl> - Q5PrFLLsOFv7L1tpzXHh2dOBIW92X2yFRW2s39q + Q21yvN + N8uoKdqXhzRA + dDoX \ <nl> - h3cavaVeHX1G + IrlAgMBAAGjEDAOMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEL \ <nl> - BQADgYEASTwg84cX + 1UhOG9sejFV3m34QuI1hPZ + qhqVJlRYUtego8Wng1BburDS \ <nl> - wqVAv4ch2wi3c2s4e8J7AXyLtzSbSQG4RN0oZi0mR8EtTTN + Mix / hBIk79dMZg85 \ <nl> - + I29uFA6Zj2d9oAhQv2qkHhc6tcaheNvkQRlCyH68k3iF1Fqf + 4KiAQwggIEMIIB \ <nl> - baADAgECAgECMA0GCSqGSIb3DQEBCwUAMD8xFDASBgNVBAMMC3Rlc3RjYTEub3Jn \ <nl> - MScwJQYDVQQKDB5QYXltZW50IFJlcXVlc3QgSW50ZXJtZWRpYXRlIDEwHhcNMTMw \ <nl> - MjIzMjI0MjI5WhcNMjMwMjIxMjI0MjI5WjA / MRQwEgYDVQQDDAt0ZXN0Y2EyLm9y \ <nl> - ZzEnMCUGA1UECgweUGF5bWVudCBSZXF1ZXN0IEludGVybWVkaWF0ZSAyMIGfMA0G \ <nl> - CSqGSIb3DQEBAQUAA4GNADCBiQKBgQDaV8zhfyQuSf / f + fauMfgs3g / RnWy9yxxU \ <nl> - kvQneQQPH3uZzCyk3A6q72ipTtwNqiibG9455L9A7SaUjGtnpUz0NKT / VWUdqbfC \ <nl> - l1PqXjEZbDobbAQ5hxLGOTyLRQhLIcgeq2 / BnmeCqHsC4md04nUp + nBo1HwKyygv \ <nl> - K + 9sMbCp / wIDAQABoxAwDjAMBgNVHRMEBTADAQH / MA0GCSqGSIb3DQEBCwUAA4GB \ <nl> - ACvYyE + PPmWFkbjyRu9LAt8DcrtyYYLRClKSg6tVvutwukLG2l / / kDOohYkJtgTq \ <nl> - r6LnCIIIwYdXN + 4wxugmw4cnPIZmP6kovxjhhVM95okilor1zniTAo3RN7JDIfTG \ <nl> - NgxLdGu1btt7DOFL4zTbeSJMb8M1JpPftehH + x / VLyuUCuoDMIIB5jCCAU + gAwIB \ <nl> - AgIBBTANBgkqhkiG9w0BAQsFADAhMR8wHQYDVQQDExZQYXltZW50UmVxdWVzdCBU \ <nl> - ZXN0IENBMB4XDTEzMDIyMzIyNDIyOFoXDTIzMDIyMTIyNDIyOFowPzEUMBIGA1UE \ <nl> - AwwLdGVzdGNhMS5vcmcxJzAlBgNVBAoMHlBheW1lbnQgUmVxdWVzdCBJbnRlcm1l \ <nl> - ZGlhdGUgMTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAo5Vy9H3nA / OOkF5A \ <nl> - p89yfVNSiTay / LYCaB0eALpcU690U75O9Q3w2M + 2AN8wpbbHsJHZMIjEeBRoQfjl \ <nl> - YXW1ucQTxWKyT + liu0D25mGXX27CBXBd4iXTxVII / iX + u3lcjORjoHOBy7QgeIDI \ <nl> - IS9y0vYu8eArpjh7m4thrVgIRtMCAwEAAaMQMA4wDAYDVR0TBAUwAwEB / zANBgkq \ <nl> - hkiG9w0BAQsFAAOBgQB9LKcVJK9sjASNzpQlpUp7nCiw5FSjVY + XMRIKK / kavzlK \ <nl> - jZ + InsmmyRVGjDoZi9GrqG9PVHgLBxi2VtVjmokZoNPqao3OfhqORAubC + JR / JLe \ <nl> - pM7aDaxDdTHVhSUk4lgNAvi26dGY7nZMsnHlPQ2tPp / HvRRiMq1oDjlylc8VTCI1 \ <nl> - Eh8IsNsGEhl2qRSVYIoDyPul6RMbTSzv4tVhVfGZqIisGLLhxYsFKgxVbml0VGVz \ <nl> - dEZvdXIqgAEBE1PP93Tkpif35F + dYmXn9kLA / 1djcPjCs2o2rwRMM4Uk356O5dgu \ <nl> - HXQjsfdR58qZQS9CS5DAtRUf0R8 + 43 / wijO / hb49VNaNXmY + / cPHMkahP2aV3tZi \ <nl> - FAyZblLik9A7ZvF + UsjeFQiHB5wzWQvbqk5wQ4yabHIXoYv / E0q + eQ = = \ <nl> - " ; <nl> - <nl> - / / <nl> - / / Validly signed , but by a CA not in our root CA list <nl> - / / <nl> - const char * paymentrequest5_cert1_BASE64 = <nl> - " \ <nl> - Egt4NTA5K3NoYTI1NhrxAwruAzCCAeowggFToAMCAQICAQEwDQYJKoZIhvcNAQEL \ <nl> - BQAwITEfMB0GA1UEAxMWUGF5bWVudFJlcXVlc3QgVGVzdCBDQTAeFw0xMzA0MTkx \ <nl> - NzIwMDZaFw0yMzA0MTcxNzIwMDZaMEMxGTAXBgNVBAMMEHRlc3RtZXJjaGFudC5v \ <nl> - cmcxJjAkBgNVBAoMHVBheW1lbnQgUmVxdWVzdCBUZXN0IE1lcmNoYW50MIGfMA0G \ <nl> - CSqGSIb3DQEBAQUAA4GNADCBiQKBgQDhV6Yn47aEEmbl50YLvXoqGEJA51I / 40wr \ <nl> - Z6VQGdXYaRqYktagrWDlgYY9h0JQ1bQhm8HgW7ju0R4NaDTXUqxg4HjprF0z3Mfm \ <nl> - / 6mmebkLOOptfkVD7ceAteNI7cyuqWGIAZA7D9mV97mXoCAtTlBUycvkmoiClCCS \ <nl> - h0EpF / UTaQIDAQABoxAwDjAMBgNVHRMEBTADAQH / MA0GCSqGSIb3DQEBCwUAA4GB \ <nl> - AGIRwW7I0QvLga + RnJoJSZNZQbtu4rQW3xmoz8WfZMBYXX3QBYg5ftycbdK + / IbP \ <nl> - qozfjGW2AS6DNArvpveSPDTK9 + GJBNo1paiNtVqwXkC3Ddscv5AIms1eZGiIOQNC \ <nl> - mUvdLkpoXo48WAer3EGsZ3B15GyNEELc0q9W5yUebba1IjUSHwiw2wYSGXapFJVg \ <nl> - igPI + 6XpExtNLO / i1WFV8ZmoiKwYuPvFiwUqDFVuaXRUZXN0Rml2ZSqAAXdsMgdG \ <nl> - ssymvca1S / 1KeM3n8Ydi2fi1JUzAAr59xPvNJRUeqCLP9upHn5z7br3P12Oz9A20 \ <nl> - 5 / 4wL4ClPRPVnOHgij0bEg + y0tGESqmF1rfOfXDszlo2U92wCxS07kq79YAZJ1Zo \ <nl> - XYh860 / Q4wvc7lfiTe + dXBzPKAKhMy91yETY \ <nl> - " ; <nl> - <nl> - / / <nl> - / / Contains a testnet paytoaddress , so payment request network doesn ' t match client network <nl> - / / <nl> - const char * paymentrequest1_cert2_BASE64 = <nl> - " \ <nl> - Egt4NTA5K3NoYTI1NhrQBArNBDCCAkkwggExoAMCAQICAQEwDQYJKoZIhvcNAQEL \ <nl> - BQAwITEfMB0GA1UEAwwWUGF5bWVudFJlcXVlc3QgVGVzdCBDQTAeFw0xNTAxMTEx \ <nl> - ODIxMDhaFw0yNTAxMDgxODIxMDhaMCExHzAdBgNVBAMMFlBheW1lbnRSZXF1ZXN0 \ <nl> - IFRlc3QgQ0EwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMsZqzkzeBGo + i2N \ <nl> - mUak3Ciodr1V7S062VOy7N0OQYNDQHYkgDFAUET7cEb5VJaHPv5m3ppTBpU9xBcf \ <nl> - wbHHUt4VjA + mhRmYrl1khjvZM + X8kEqvWn20BtcM9R6r0yIYec8UERDDHBleL / P8 \ <nl> - RkxEnVLjYTV9zigCXfMsgYb3EQShAgMBAAGjEDAOMAwGA1UdEwQFMAMBAf8wDQYJ \ <nl> - KoZIhvcNAQELBQADggEBABUJpl3QCqsoDSxAsQdV6zKT4VGV76AzoGj7etQsQY + r \ <nl> - + S26VfWh / fMobEzuxFChr0USgLJ6FoK78hAtoZvt1lrye9yqFv / ig3WLWsJKWHHb \ <nl> - 3RT6oR03CIwZXFSUasi08QDVLxafwsU5OMcPLucF3a1lRL1ccYrNgVCCx1 + X7Bos \ <nl> - tIgDGRQQ4AyoHTcfVd2hEGeUv7k14mOxFsAp6851yosHq9Q2kwmdH + rHEJbjof87 \ <nl> - yyKLagc4owyXBZYkQmkeHWCNqnuRmO5vUsfVb0UUrkD64o7Th / NjwooA7SCiUXl6 \ <nl> - dfygT1b7ggpx7GC + sP2DsIM47IAZ55drjqX5u2f + Ba0iPQoEdGVzdBIhCIDWwowE \ <nl> - Ehl2qRQErGqUUwSsaMpDvWIaGnJGNQqi8oisGNeMy6UFKgxKdXN0IFRlc3Rpbmcq \ <nl> - gAFwThsozZxkZxzCn4R8WxNiLFV6m0ye9fEtSbolfaW + EjBMpO03lr / dwNnrclhg \ <nl> - ew + A05xfZztrAt16XKEY7qKJ / eY2nLd0fVAIu / nIt + 7 / VYVXT83zLrWc150aRS7W \ <nl> - AdJbL3JOJLs6Eyp5zrPbfI8faRttFAdONKDrJgIpuW1E3g = = \ <nl> - " ; <nl> - <nl> - / / <nl> - / / Expired payment request ( expires is set to 1 = 1970 - 01 - 01 00 : 00 : 01 ) <nl> - / / <nl> - const char * paymentrequest2_cert2_BASE64 = <nl> - " \ <nl> - Egt4NTA5K3NoYTI1NhrQBArNBDCCAkkwggExoAMCAQICAQEwDQYJKoZIhvcNAQEL \ <nl> - BQAwITEfMB0GA1UEAwwWUGF5bWVudFJlcXVlc3QgVGVzdCBDQTAeFw0xNTAxMTEx \ <nl> - ODIxMDhaFw0yNTAxMDgxODIxMDhaMCExHzAdBgNVBAMMFlBheW1lbnRSZXF1ZXN0 \ <nl> - IFRlc3QgQ0EwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMsZqzkzeBGo + i2N \ <nl> - mUak3Ciodr1V7S062VOy7N0OQYNDQHYkgDFAUET7cEb5VJaHPv5m3ppTBpU9xBcf \ <nl> - wbHHUt4VjA + mhRmYrl1khjvZM + X8kEqvWn20BtcM9R6r0yIYec8UERDDHBleL / P8 \ <nl> - RkxEnVLjYTV9zigCXfMsgYb3EQShAgMBAAGjEDAOMAwGA1UdEwQFMAMBAf8wDQYJ \ <nl> - KoZIhvcNAQELBQADggEBABUJpl3QCqsoDSxAsQdV6zKT4VGV76AzoGj7etQsQY + r \ <nl> - + S26VfWh / fMobEzuxFChr0USgLJ6FoK78hAtoZvt1lrye9yqFv / ig3WLWsJKWHHb \ <nl> - 3RT6oR03CIwZXFSUasi08QDVLxafwsU5OMcPLucF3a1lRL1ccYrNgVCCx1 + X7Bos \ <nl> - tIgDGRQQ4AyoHTcfVd2hEGeUv7k14mOxFsAp6851yosHq9Q2kwmdH + rHEJbjof87 \ <nl> - yyKLagc4owyXBZYkQmkeHWCNqnuRmO5vUsfVb0UUrkD64o7Th / NjwooA7SCiUXl6 \ <nl> - dfygT1b7ggpx7GC + sP2DsIM47IAZ55drjqX5u2f + Ba0iQgoEdGVzdBIgCICt4gQS \ <nl> - GXapFASsapRTBKxoykO9YhoackY1CqLyiKwYiNLUpQUgASoQVGVzdGluZyB0ZXN0 \ <nl> - bmV0ISqAATXq9A5nmJgtmee / bQTeHeif4w1YYFPBlKghwx6qbVgXTWnwBJtOQhhV \ <nl> - sZdzbTl95ENR7 / Y7VJupW9kDWobCK7zUUhLAzUlwmLlcx6itHw8LTUF5HK + AwsZm \ <nl> - Zs85lISGvOS0NZW / ENa6l + oQRnL87oqVZr / EDGiuqjz6T0ThQi0l \ <nl> - " ; <nl> - <nl> - / / <nl> - / / Unexpired payment request ( expires is set to 0x7FFFFFFFFFFFFFFF = max . int64_t ) <nl> - / / <nl> - const char * paymentrequest3_cert2_BASE64 = <nl> - " \ <nl> - Egt4NTA5K3NoYTI1NhrQBArNBDCCAkkwggExoAMCAQICAQEwDQYJKoZIhvcNAQEL \ <nl> - BQAwITEfMB0GA1UEAwwWUGF5bWVudFJlcXVlc3QgVGVzdCBDQTAeFw0xNTAxMTEx \ <nl> - ODIxMDhaFw0yNTAxMDgxODIxMDhaMCExHzAdBgNVBAMMFlBheW1lbnRSZXF1ZXN0 \ <nl> - IFRlc3QgQ0EwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMsZqzkzeBGo + i2N \ <nl> - mUak3Ciodr1V7S062VOy7N0OQYNDQHYkgDFAUET7cEb5VJaHPv5m3ppTBpU9xBcf \ <nl> - wbHHUt4VjA + mhRmYrl1khjvZM + X8kEqvWn20BtcM9R6r0yIYec8UERDDHBleL / P8 \ <nl> - RkxEnVLjYTV9zigCXfMsgYb3EQShAgMBAAGjEDAOMAwGA1UdEwQFMAMBAf8wDQYJ \ <nl> - KoZIhvcNAQELBQADggEBABUJpl3QCqsoDSxAsQdV6zKT4VGV76AzoGj7etQsQY + r \ <nl> - + S26VfWh / fMobEzuxFChr0USgLJ6FoK78hAtoZvt1lrye9yqFv / ig3WLWsJKWHHb \ <nl> - 3RT6oR03CIwZXFSUasi08QDVLxafwsU5OMcPLucF3a1lRL1ccYrNgVCCx1 + X7Bos \ <nl> - tIgDGRQQ4AyoHTcfVd2hEGeUv7k14mOxFsAp6851yosHq9Q2kwmdH + rHEJbjof87 \ <nl> - yyKLagc4owyXBZYkQmkeHWCNqnuRmO5vUsfVb0UUrkD64o7Th / NjwooA7SCiUXl6 \ <nl> - dfygT1b7ggpx7GC + sP2DsIM47IAZ55drjqX5u2f + Ba0iSgoEdGVzdBIgCICt4gQS \ <nl> - GXapFASsapRTBKxoykO9YhoackY1CqLyiKwYyNfZpQUg / / / / / / / / / / 9 / KhBUZXN0 \ <nl> - aW5nIHRlc3RuZXQhKoABNwi8WnMW4aMvbmvorTiiWJLFhofLFnsoWCJnj3rWLnLh \ <nl> - n3w6q / fZ26p50ERL / noxdTUfeFsKnlECkUu / fOcOrqyYDiwvxI0SZ034DleVyFU1 \ <nl> - Z3T + X0zcL8oe7bX01Yf + s2V + 5JXQXarKnKBrZCGgv2ARjFNSZe7E7vGg5K4Q6Q8 = \ <nl> - " ; <nl> - <nl> - / / <nl> - / / Unexpired payment request ( expires is set to 0x8000000000000000 > max . int64_t , allowed uint64 ) <nl> - / / <nl> - const char * paymentrequest4_cert2_BASE64 = <nl> - " \ <nl> - Egt4NTA5K3NoYTI1NhrQBArNBDCCAkkwggExoAMCAQICAQEwDQYJKoZIhvcNAQEL \ <nl> - BQAwITEfMB0GA1UEAwwWUGF5bWVudFJlcXVlc3QgVGVzdCBDQTAeFw0xNTAxMTEx \ <nl> - ODIxMDhaFw0yNTAxMDgxODIxMDhaMCExHzAdBgNVBAMMFlBheW1lbnRSZXF1ZXN0 \ <nl> - IFRlc3QgQ0EwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMsZqzkzeBGo + i2N \ <nl> - mUak3Ciodr1V7S062VOy7N0OQYNDQHYkgDFAUET7cEb5VJaHPv5m3ppTBpU9xBcf \ <nl> - wbHHUt4VjA + mhRmYrl1khjvZM + X8kEqvWn20BtcM9R6r0yIYec8UERDDHBleL / P8 \ <nl> - RkxEnVLjYTV9zigCXfMsgYb3EQShAgMBAAGjEDAOMAwGA1UdEwQFMAMBAf8wDQYJ \ <nl> - KoZIhvcNAQELBQADggEBABUJpl3QCqsoDSxAsQdV6zKT4VGV76AzoGj7etQsQY + r \ <nl> - + S26VfWh / fMobEzuxFChr0USgLJ6FoK78hAtoZvt1lrye9yqFv / ig3WLWsJKWHHb \ <nl> - 3RT6oR03CIwZXFSUasi08QDVLxafwsU5OMcPLucF3a1lRL1ccYrNgVCCx1 + X7Bos \ <nl> - tIgDGRQQ4AyoHTcfVd2hEGeUv7k14mOxFsAp6851yosHq9Q2kwmdH + rHEJbjof87 \ <nl> - yyKLagc4owyXBZYkQmkeHWCNqnuRmO5vUsfVb0UUrkD64o7Th / NjwooA7SCiUXl6 \ <nl> - dfygT1b7ggpx7GC + sP2DsIM47IAZ55drjqX5u2f + Ba0iSwoEdGVzdBIgCICt4gQS \ <nl> - GXapFASsapRTBKxoykO9YhoackY1CqLyiKwYt + HZpQUggICAgICAgICAASoQVGVz \ <nl> - dGluZyB0ZXN0bmV0ISqAAXSQG8 + GFA18VaKarlYrOz293rNMIub0swKGcQm8jAGX \ <nl> - HSLaRgHfUDeEPr4hydy4dtfu59KNwe2xsHOHu / SpO4L8SrA4Dm9A7SlNBVWdcLbw \ <nl> - d2hj739GDLz0b5KuJ2SG6VknMRQM976w / m2qlq0ccVGaaZ2zMIGfpzL3p6adwx / 5 \ <nl> - " ; <nl> - <nl> - / / <nl> - / / Payment request with amount overflow ( amount is set to 21000001 BTC ) <nl> - / / <nl> - const char * paymentrequest5_cert2_BASE64 = <nl> - " \ <nl> - Egt4NTA5K3NoYTI1NhrQBArNBDCCAkkwggExoAMCAQICAQEwDQYJKoZIhvcNAQEL \ <nl> - BQAwITEfMB0GA1UEAwwWUGF5bWVudFJlcXVlc3QgVGVzdCBDQTAeFw0xNTAxMTEx \ <nl> - ODIxMDhaFw0yNTAxMDgxODIxMDhaMCExHzAdBgNVBAMMFlBheW1lbnRSZXF1ZXN0 \ <nl> - IFRlc3QgQ0EwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMsZqzkzeBGo + i2N \ <nl> - mUak3Ciodr1V7S062VOy7N0OQYNDQHYkgDFAUET7cEb5VJaHPv5m3ppTBpU9xBcf \ <nl> - wbHHUt4VjA + mhRmYrl1khjvZM + X8kEqvWn20BtcM9R6r0yIYec8UERDDHBleL / P8 \ <nl> - RkxEnVLjYTV9zigCXfMsgYb3EQShAgMBAAGjEDAOMAwGA1UdEwQFMAMBAf8wDQYJ \ <nl> - KoZIhvcNAQELBQADggEBABUJpl3QCqsoDSxAsQdV6zKT4VGV76AzoGj7etQsQY + r \ <nl> - + S26VfWh / fMobEzuxFChr0USgLJ6FoK78hAtoZvt1lrye9yqFv / ig3WLWsJKWHHb \ <nl> - 3RT6oR03CIwZXFSUasi08QDVLxafwsU5OMcPLucF3a1lRL1ccYrNgVCCx1 + X7Bos \ <nl> - tIgDGRQQ4AyoHTcfVd2hEGeUv7k14mOxFsAp6851yosHq9Q2kwmdH + rHEJbjof87 \ <nl> - yyKLagc4owyXBZYkQmkeHWCNqnuRmO5vUsfVb0UUrkD64o7Th / NjwooA7SCiUXl6 \ <nl> - dfygT1b7ggpx7GC + sP2DsIM47IAZ55drjqX5u2f + Ba0iTAoEdGVzdBIkCIDC9P + F \ <nl> - vt0DEhl2qRQErGqUUwSsaMpDvWIaGnJGNQqi8oisGLzcrKYFKhhUZXN0aW5nIGFt \ <nl> - b3VudCBvdmVyZmxvdyEqgAG8S7WEDUC6tCL6q2CTBjop / AitgEy31RL9IqYruytR \ <nl> - iEBFUrBDJZU + UEezGwr7 / zoECjo5ZY3PmtZcM2sILNjyweJF6XVzGqTxUw6pN6sW \ <nl> - XR2T3Gy2LzRvhVA25QgGqpz0 / juS2BtmNbsZPkN9gMMwKimgzc + PuCzmEKwPK9cQ \ <nl> - YQ = = \ <nl> - " ; <nl> - <nl> - # endif / / BITCOIN_QT_TEST_PAYMENTREQUESTDATA_H <nl> deleted file mode 100644 <nl> index ef0808054de7 . . 000000000000 <nl> mmm a / src / qt / test / paymentservertests . cpp <nl> ppp / dev / null <nl> <nl> - / / Copyright ( c ) 2009 - 2018 The Bitcoin Core developers <nl> - / / Distributed under the MIT software license , see the accompanying <nl> - / / file COPYING or http : / / www . opensource . org / licenses / mit - license . php . <nl> - <nl> - # include < qt / test / paymentservertests . h > <nl> - <nl> - # include < qt / optionsmodel . h > <nl> - # include < qt / test / paymentrequestdata . h > <nl> - <nl> - # include < amount . h > <nl> - # include < interfaces / node . h > <nl> - # include < random . h > <nl> - # include < script / script . h > <nl> - # include < script / standard . h > <nl> - # include < test / setup_common . h > <nl> - # include < util / strencodings . h > <nl> - <nl> - # include < openssl / ssl . h > <nl> - # include < openssl / x509 . h > <nl> - # include < openssl / x509_vfy . h > <nl> - <nl> - # include < QFileOpenEvent > <nl> - # include < QTemporaryFile > <nl> - <nl> - X509 * parse_b64der_cert ( const char * cert_data ) <nl> - { <nl> - std : : vector < unsigned char > data = DecodeBase64 ( cert_data ) ; <nl> - assert ( data . size ( ) > 0 ) ; <nl> - const unsigned char * dptr = data . data ( ) ; <nl> - X509 * cert = d2i_X509 ( nullptr , & dptr , data . size ( ) ) ; <nl> - assert ( cert ) ; <nl> - return cert ; <nl> - } <nl> - <nl> - / / <nl> - / / Test payment request handling <nl> - / / <nl> - <nl> - static SendCoinsRecipient handleRequest ( PaymentServer * server , std : : vector < unsigned char > & data ) <nl> - { <nl> - RecipientCatcher sigCatcher ; <nl> - QObject : : connect ( server , & PaymentServer : : receivedPaymentRequest , <nl> - & sigCatcher , & RecipientCatcher : : getRecipient ) ; <nl> - <nl> - / / Write data to a temp file : <nl> - QTemporaryFile f ; <nl> - f . open ( ) ; <nl> - f . write ( ( const char * ) data . data ( ) , data . size ( ) ) ; <nl> - f . close ( ) ; <nl> - <nl> - / / Create a QObject , install event filter from PaymentServer <nl> - / / and send a file open event to the object <nl> - QObject object ; <nl> - object . installEventFilter ( server ) ; <nl> - QFileOpenEvent event ( f . fileName ( ) ) ; <nl> - / / If sending the event fails , this will cause sigCatcher to be empty , <nl> - / / which will lead to a test failure anyway . <nl> - QCoreApplication : : sendEvent ( & object , & event ) ; <nl> - <nl> - QObject : : disconnect ( server , & PaymentServer : : receivedPaymentRequest , <nl> - & sigCatcher , & RecipientCatcher : : getRecipient ) ; <nl> - <nl> - / / Return results from sigCatcher <nl> - return sigCatcher . recipient ; <nl> - } <nl> - <nl> - void PaymentServerTests : : paymentServerTests ( ) <nl> - { <nl> - SSL_library_init ( ) ; <nl> - BasicTestingSetup testing_setup ( CBaseChainParams : : MAIN ) ; <nl> - auto node = interfaces : : MakeNode ( ) ; <nl> - OptionsModel optionsModel ( * node ) ; <nl> - PaymentServer * server = new PaymentServer ( nullptr , false ) ; <nl> - X509_STORE * caStore = X509_STORE_new ( ) ; <nl> - X509_STORE_add_cert ( caStore , parse_b64der_cert ( caCert1_BASE64 ) ) ; <nl> - PaymentServer : : LoadRootCAs ( caStore ) ; <nl> - server - > setOptionsModel ( & optionsModel ) ; <nl> - server - > uiReady ( ) ; <nl> - <nl> - std : : vector < unsigned char > data ; <nl> - SendCoinsRecipient r ; <nl> - QString merchant ; <nl> - <nl> - / / Now feed PaymentRequests to server , and observe signals it produces <nl> - <nl> - / / This payment request validates directly against the <nl> - / / caCert1 certificate authority : <nl> - data = DecodeBase64 ( paymentrequest1_cert1_BASE64 ) ; <nl> - r = handleRequest ( server , data ) ; <nl> - r . paymentRequest . getMerchant ( caStore , merchant ) ; <nl> - QCOMPARE ( merchant , QString ( " testmerchant . org " ) ) ; <nl> - <nl> - / / Signed , but expired , merchant cert in the request : <nl> - data = DecodeBase64 ( paymentrequest2_cert1_BASE64 ) ; <nl> - r = handleRequest ( server , data ) ; <nl> - r . paymentRequest . getMerchant ( caStore , merchant ) ; <nl> - QCOMPARE ( merchant , QString ( " " ) ) ; <nl> - <nl> - / / 10 - long certificate chain , all intermediates valid : <nl> - data = DecodeBase64 ( paymentrequest3_cert1_BASE64 ) ; <nl> - r = handleRequest ( server , data ) ; <nl> - r . paymentRequest . getMerchant ( caStore , merchant ) ; <nl> - QCOMPARE ( merchant , QString ( " testmerchant8 . org " ) ) ; <nl> - <nl> - / / Long certificate chain , with an expired certificate in the middle : <nl> - data = DecodeBase64 ( paymentrequest4_cert1_BASE64 ) ; <nl> - r = handleRequest ( server , data ) ; <nl> - r . paymentRequest . getMerchant ( caStore , merchant ) ; <nl> - QCOMPARE ( merchant , QString ( " " ) ) ; <nl> - <nl> - / / Validly signed , but by a CA not in our root CA list : <nl> - data = DecodeBase64 ( paymentrequest5_cert1_BASE64 ) ; <nl> - r = handleRequest ( server , data ) ; <nl> - r . paymentRequest . getMerchant ( caStore , merchant ) ; <nl> - QCOMPARE ( merchant , QString ( " " ) ) ; <nl> - <nl> - / / Try again with no root CA ' s , verifiedMerchant should be empty : <nl> - caStore = X509_STORE_new ( ) ; <nl> - PaymentServer : : LoadRootCAs ( caStore ) ; <nl> - data = DecodeBase64 ( paymentrequest1_cert1_BASE64 ) ; <nl> - r = handleRequest ( server , data ) ; <nl> - r . paymentRequest . getMerchant ( caStore , merchant ) ; <nl> - QCOMPARE ( merchant , QString ( " " ) ) ; <nl> - <nl> - / / Load second root certificate <nl> - caStore = X509_STORE_new ( ) ; <nl> - X509_STORE_add_cert ( caStore , parse_b64der_cert ( caCert2_BASE64 ) ) ; <nl> - PaymentServer : : LoadRootCAs ( caStore ) ; <nl> - <nl> - QByteArray byteArray ; <nl> - <nl> - / / For the tests below we just need the payment request data from <nl> - / / paymentrequestdata . h parsed + stored in r . paymentRequest . <nl> - / / <nl> - / / These tests require us to bypass the following normal client execution flow <nl> - / / shown below to be able to explicitly just trigger a certain condition ! <nl> - / / <nl> - / / handleRequest ( ) <nl> - / / - > PaymentServer : : eventFilter ( ) <nl> - / / - > PaymentServer : : handleURIOrFile ( ) <nl> - / / - > PaymentServer : : readPaymentRequestFromFile ( ) <nl> - / / - > PaymentServer : : processPaymentRequest ( ) <nl> - <nl> - / / Contains a testnet paytoaddress , so payment request network doesn ' t match client network : <nl> - data = DecodeBase64 ( paymentrequest1_cert2_BASE64 ) ; <nl> - byteArray = QByteArray ( ( const char * ) data . data ( ) , data . size ( ) ) ; <nl> - r . paymentRequest . parse ( byteArray ) ; <nl> - / / Ensure the request is initialized , because network " main " is default , even for <nl> - / / uninitialized payment requests and that will fail our test here . <nl> - QVERIFY ( r . paymentRequest . IsInitialized ( ) ) ; <nl> - QCOMPARE ( PaymentServer : : verifyNetwork ( * node , r . paymentRequest . getDetails ( ) ) , false ) ; <nl> - <nl> - / / Expired payment request ( expires is set to 1 = 1970 - 01 - 01 00 : 00 : 01 ) : <nl> - data = DecodeBase64 ( paymentrequest2_cert2_BASE64 ) ; <nl> - byteArray = QByteArray ( ( const char * ) data . data ( ) , data . size ( ) ) ; <nl> - r . paymentRequest . parse ( byteArray ) ; <nl> - / / Ensure the request is initialized <nl> - QVERIFY ( r . paymentRequest . IsInitialized ( ) ) ; <nl> - / / compares 1 < GetTime ( ) = = false ( treated as expired payment request ) <nl> - QCOMPARE ( PaymentServer : : verifyExpired ( r . paymentRequest . getDetails ( ) ) , true ) ; <nl> - <nl> - / / Unexpired payment request ( expires is set to 0x7FFFFFFFFFFFFFFF = max . int64_t ) : <nl> - / / 9223372036854775807 ( uint64 ) , 9223372036854775807 ( int64_t ) and - 1 ( int32_t ) <nl> - / / - 1 is 1969 - 12 - 31 23 : 59 : 59 ( for a 32 bit time values ) <nl> - data = DecodeBase64 ( paymentrequest3_cert2_BASE64 ) ; <nl> - byteArray = QByteArray ( ( const char * ) data . data ( ) , data . size ( ) ) ; <nl> - r . paymentRequest . parse ( byteArray ) ; <nl> - / / Ensure the request is initialized <nl> - QVERIFY ( r . paymentRequest . IsInitialized ( ) ) ; <nl> - / / compares 9223372036854775807 < GetTime ( ) = = false ( treated as unexpired payment request ) <nl> - QCOMPARE ( PaymentServer : : verifyExpired ( r . paymentRequest . getDetails ( ) ) , false ) ; <nl> - <nl> - / / Unexpired payment request ( expires is set to 0x8000000000000000 > max . int64_t , allowed uint64 ) : <nl> - / / 9223372036854775808 ( uint64 ) , - 9223372036854775808 ( int64_t ) and 0 ( int32_t ) <nl> - / / 0 is 1970 - 01 - 01 00 : 00 : 00 ( for a 32 bit time values ) <nl> - data = DecodeBase64 ( paymentrequest4_cert2_BASE64 ) ; <nl> - byteArray = QByteArray ( ( const char * ) data . data ( ) , data . size ( ) ) ; <nl> - r . paymentRequest . parse ( byteArray ) ; <nl> - / / Ensure the request is initialized <nl> - QVERIFY ( r . paymentRequest . IsInitialized ( ) ) ; <nl> - / / compares - 9223372036854775808 < GetTime ( ) = = true ( treated as expired payment request ) <nl> - QCOMPARE ( PaymentServer : : verifyExpired ( r . paymentRequest . getDetails ( ) ) , true ) ; <nl> - <nl> - / / Test BIP70 DoS protection : <nl> - auto randdata = FastRandomContext ( ) . randbytes ( BIP70_MAX_PAYMENTREQUEST_SIZE + 1 ) ; <nl> - <nl> - / / Write data to a temp file : <nl> - QTemporaryFile tempFile ; <nl> - tempFile . open ( ) ; <nl> - tempFile . write ( ( const char * ) randdata . data ( ) , randdata . size ( ) ) ; <nl> - tempFile . close ( ) ; <nl> - / / compares 50001 < = BIP70_MAX_PAYMENTREQUEST_SIZE = = false <nl> - QCOMPARE ( PaymentServer : : verifySize ( tempFile . size ( ) ) , false ) ; <nl> - <nl> - / / Payment request with amount overflow ( amount is set to 21000001 BTC ) : <nl> - data = DecodeBase64 ( paymentrequest5_cert2_BASE64 ) ; <nl> - byteArray = QByteArray ( ( const char * ) data . data ( ) , data . size ( ) ) ; <nl> - r . paymentRequest . parse ( byteArray ) ; <nl> - / / Ensure the request is initialized <nl> - QVERIFY ( r . paymentRequest . IsInitialized ( ) ) ; <nl> - / / Extract address and amount from the request <nl> - QList < std : : pair < CScript , CAmount > > sendingTos = r . paymentRequest . getPayTo ( ) ; <nl> - for ( const std : : pair < CScript , CAmount > & sendingTo : sendingTos ) { <nl> - CTxDestination dest ; <nl> - if ( ExtractDestination ( sendingTo . first , dest ) ) <nl> - QCOMPARE ( PaymentServer : : verifyAmount ( sendingTo . second ) , false ) ; <nl> - } <nl> - <nl> - delete server ; <nl> - } <nl> - <nl> - void RecipientCatcher : : getRecipient ( const SendCoinsRecipient & r ) <nl> - { <nl> - recipient = r ; <nl> - } <nl> deleted file mode 100644 <nl> index 7ef7a0a6411e . . 000000000000 <nl> mmm a / src / qt / test / paymentservertests . h <nl> ppp / dev / null <nl> <nl> - / / Copyright ( c ) 2009 - 2018 The Bitcoin Core developers <nl> - / / Distributed under the MIT software license , see the accompanying <nl> - / / file COPYING or http : / / www . opensource . org / licenses / mit - license . php . <nl> - <nl> - # ifndef BITCOIN_QT_TEST_PAYMENTSERVERTESTS_H <nl> - # define BITCOIN_QT_TEST_PAYMENTSERVERTESTS_H <nl> - <nl> - # include < qt / paymentserver . h > <nl> - <nl> - # include < QObject > <nl> - # include < QTest > <nl> - <nl> - class PaymentServerTests : public QObject <nl> - { <nl> - Q_OBJECT <nl> - <nl> - private Q_SLOTS : <nl> - void paymentServerTests ( ) ; <nl> - } ; <nl> - <nl> - / / Dummy class to receive paymentserver signals . <nl> - / / If SendCoinsRecipient was a proper QObject , then <nl> - / / we could use QSignalSpy . . . but it ' s not . <nl> - class RecipientCatcher : public QObject <nl> - { <nl> - Q_OBJECT <nl> - <nl> - public Q_SLOTS : <nl> - void getRecipient ( const SendCoinsRecipient & r ) ; <nl> - <nl> - public : <nl> - SendCoinsRecipient recipient ; <nl> - } ; <nl> - <nl> - # endif / / BITCOIN_QT_TEST_PAYMENTSERVERTESTS_H <nl> mmm a / src / qt / test / test_main . cpp <nl> ppp b / src / qt / test / test_main . cpp <nl> <nl> <nl> # ifdef ENABLE_WALLET <nl> # include < qt / test / addressbooktests . h > <nl> - # ifdef ENABLE_BIP70 <nl> - # include < qt / test / paymentservertests . h > <nl> - # endif / / ENABLE_BIP70 <nl> # include < qt / test / wallettests . h > <nl> # endif / / ENABLE_WALLET <nl> <nl> int main ( int argc , char * argv [ ] ) <nl> if ( QTest : : qExec ( & test1 ) ! = 0 ) { <nl> fInvalid = true ; <nl> } <nl> - # if defined ( ENABLE_WALLET ) & & defined ( ENABLE_BIP70 ) <nl> - PaymentServerTests test2 ; <nl> - if ( QTest : : qExec ( & test2 ) ! = 0 ) { <nl> - fInvalid = true ; <nl> - } <nl> - # endif <nl> RPCNestedTests test3 ; <nl> if ( QTest : : qExec ( & test3 ) ! = 0 ) { <nl> fInvalid = true ; <nl> mmm a / src / qt / transactiondesc . cpp <nl> ppp b / src / qt / transactiondesc . cpp <nl> QString TransactionDesc : : FormatTxStatus ( const interfaces : : WalletTx & wtx , const i <nl> } <nl> } <nl> <nl> - # ifndef ENABLE_BIP70 <nl> / / Takes an encoded PaymentRequest as a string and tries to find the Common Name of the X . 509 certificate <nl> / / used to sign the PaymentRequest . <nl> bool GetPaymentRequestMerchant ( const std : : string & pr , QString & merchant ) <nl> bool GetPaymentRequestMerchant ( const std : : string & pr , QString & merchant ) <nl> } <nl> return false ; <nl> } <nl> - # endif <nl> <nl> QString TransactionDesc : : toHTML ( interfaces : : Node & node , interfaces : : Wallet & wallet , TransactionRecord * rec , int unit ) <nl> { <nl> QString TransactionDesc : : toHTML ( interfaces : : Node & node , interfaces : : Wallet & wall <nl> if ( r . first = = " PaymentRequest " ) <nl> { <nl> QString merchant ; <nl> - # ifdef ENABLE_BIP70 <nl> - PaymentRequestPlus req ; <nl> - req . parse ( QByteArray : : fromRawData ( r . second . data ( ) , r . second . size ( ) ) ) ; <nl> - if ( ! req . getMerchant ( PaymentServer : : getCertStore ( ) , merchant ) ) { <nl> - merchant . clear ( ) ; <nl> - } <nl> - # else <nl> if ( ! GetPaymentRequestMerchant ( r . second , merchant ) ) { <nl> merchant . clear ( ) ; <nl> } else { <nl> merchant + = tr ( " ( Certificate was not verified ) " ) ; <nl> } <nl> - # endif <nl> if ( ! merchant . isNull ( ) ) { <nl> strHTML + = " < b > " + tr ( " Merchant " ) + " : < / b > " + GUIUtil : : HtmlEscape ( merchant ) + " < br > " ; <nl> } <nl> mmm a / src / qt / utilitydialog . cpp <nl> ppp b / src / qt / utilitydialog . cpp <nl> <nl> # include < qt / forms / ui_helpmessagedialog . h > <nl> <nl> # include < qt / bitcoingui . h > <nl> - # ifdef ENABLE_BIP70 <nl> - # include < qt / paymentrequestplus . h > <nl> - # endif <nl> <nl> # include < clientversion . h > <nl> # include < init . h > <nl> mmm a / src / qt / walletmodel . cpp <nl> ppp b / src / qt / walletmodel . cpp <nl> WalletModel : : SendCoinsReturn WalletModel : : prepareTransaction ( WalletModelTransact <nl> { <nl> if ( rcp . fSubtractFeeFromAmount ) <nl> fSubtractFeeFromAmount = true ; <nl> - <nl> - # ifdef ENABLE_BIP70 <nl> - if ( rcp . paymentRequest . IsInitialized ( ) ) <nl> - { / / PaymentRequest . . . <nl> - CAmount subtotal = 0 ; <nl> - const payments : : PaymentDetails & details = rcp . paymentRequest . getDetails ( ) ; <nl> - for ( int i = 0 ; i < details . outputs_size ( ) ; i + + ) <nl> - { <nl> - const payments : : Output & out = details . outputs ( i ) ; <nl> - if ( out . amount ( ) < = 0 ) continue ; <nl> - subtotal + = out . amount ( ) ; <nl> - const unsigned char * scriptStr = ( const unsigned char * ) out . script ( ) . data ( ) ; <nl> - CScript scriptPubKey ( scriptStr , scriptStr + out . script ( ) . size ( ) ) ; <nl> - CAmount nAmount = out . amount ( ) ; <nl> - CRecipient recipient = { scriptPubKey , nAmount , rcp . fSubtractFeeFromAmount } ; <nl> - vecSend . push_back ( recipient ) ; <nl> - } <nl> - if ( subtotal < = 0 ) <nl> - { <nl> - return InvalidAmount ; <nl> - } <nl> - total + = subtotal ; <nl> - } <nl> - else <nl> - # endif <nl> { / / User - entered bitcoin address / amount : <nl> if ( ! validateAddress ( rcp . address ) ) <nl> { <nl> WalletModel : : SendCoinsReturn WalletModel : : sendCoins ( WalletModelTransaction & tran <nl> std : : vector < std : : pair < std : : string , std : : string > > vOrderForm ; <nl> for ( const SendCoinsRecipient & rcp : transaction . getRecipients ( ) ) <nl> { <nl> - # ifdef ENABLE_BIP70 <nl> - if ( rcp . paymentRequest . IsInitialized ( ) ) <nl> - { <nl> - / / Make sure any payment requests involved are still valid . <nl> - if ( PaymentServer : : verifyExpired ( rcp . paymentRequest . getDetails ( ) ) ) { <nl> - return PaymentRequestExpired ; <nl> - } <nl> - <nl> - / / Store PaymentRequests in wtx . vOrderForm in wallet . <nl> - std : : string value ; <nl> - rcp . paymentRequest . SerializeToString ( & value ) ; <nl> - vOrderForm . emplace_back ( " PaymentRequest " , std : : move ( value ) ) ; <nl> - } <nl> - else <nl> - # endif <nl> if ( ! rcp . message . isEmpty ( ) ) / / Message from normal bitcoin : URI ( bitcoin : 123 . . . ? message = example ) <nl> vOrderForm . emplace_back ( " Message " , rcp . message . toStdString ( ) ) ; <nl> } <nl> WalletModel : : SendCoinsReturn WalletModel : : sendCoins ( WalletModelTransaction & tran <nl> / / and emit coinsSent signal for each recipient <nl> for ( const SendCoinsRecipient & rcp : transaction . getRecipients ( ) ) <nl> { <nl> - / / Don ' t touch the address book when we have a payment request <nl> - # ifdef ENABLE_BIP70 <nl> - if ( ! rcp . paymentRequest . IsInitialized ( ) ) <nl> - # endif <nl> { <nl> std : : string strAddress = rcp . address . toStdString ( ) ; <nl> CTxDestination dest = DecodeDestination ( strAddress ) ; <nl> mmm a / src / qt / walletmodel . h <nl> ppp b / src / qt / walletmodel . h <nl> <nl> # ifndef BITCOIN_QT_WALLETMODEL_H <nl> # define BITCOIN_QT_WALLETMODEL_H <nl> <nl> + # if defined ( HAVE_CONFIG_H ) <nl> + # include < config / bitcoin - config . h > <nl> + # endif <nl> + <nl> # include < amount . h > <nl> # include < key . h > <nl> # include < serialize . h > <nl> # include < script / standard . h > <nl> <nl> - # if defined ( HAVE_CONFIG_H ) <nl> - # include < config / bitcoin - config . h > <nl> - # endif <nl> - <nl> - # ifdef ENABLE_BIP70 <nl> - # include < qt / paymentrequestplus . h > <nl> - # endif <nl> # include < qt / walletmodeltransaction . h > <nl> <nl> # include < interfaces / wallet . h > <nl> class SendCoinsRecipient <nl> CAmount amount ; <nl> / / If from a payment request , this is used for storing the memo <nl> QString message ; <nl> - <nl> - # ifdef ENABLE_BIP70 <nl> - / / If from a payment request , paymentRequest . IsInitialized ( ) will be true <nl> - PaymentRequestPlus paymentRequest ; <nl> - # else <nl> / / If building with BIP70 is disabled , keep the payment request around as <nl> / / serialized string to ensure load / store is lossless <nl> std : : string sPaymentRequest ; <nl> - # endif <nl> / / Empty if no authentication or invalid signature / cert / etc . <nl> QString authenticatedMerchant ; <nl> <nl> class SendCoinsRecipient <nl> std : : string sAddress = address . toStdString ( ) ; <nl> std : : string sLabel = label . toStdString ( ) ; <nl> std : : string sMessage = message . toStdString ( ) ; <nl> - # ifdef ENABLE_BIP70 <nl> - std : : string sPaymentRequest ; <nl> - if ( ! ser_action . ForRead ( ) & & paymentRequest . IsInitialized ( ) ) <nl> - paymentRequest . SerializeToString ( & sPaymentRequest ) ; <nl> - # endif <nl> std : : string sAuthenticatedMerchant = authenticatedMerchant . toStdString ( ) ; <nl> <nl> READWRITE ( this - > nVersion ) ; <nl> class SendCoinsRecipient <nl> address = QString : : fromStdString ( sAddress ) ; <nl> label = QString : : fromStdString ( sLabel ) ; <nl> message = QString : : fromStdString ( sMessage ) ; <nl> - # ifdef ENABLE_BIP70 <nl> - if ( ! sPaymentRequest . empty ( ) ) <nl> - paymentRequest . parse ( QByteArray : : fromRawData ( sPaymentRequest . data ( ) , sPaymentRequest . size ( ) ) ) ; <nl> - # endif <nl> authenticatedMerchant = QString : : fromStdString ( sAuthenticatedMerchant ) ; <nl> } <nl> } <nl> mmm a / src / qt / walletmodeltransaction . cpp <nl> ppp b / src / qt / walletmodeltransaction . cpp <nl> void WalletModelTransaction : : reassignAmounts ( int nChangePosRet ) <nl> for ( QList < SendCoinsRecipient > : : iterator it = recipients . begin ( ) ; it ! = recipients . end ( ) ; + + it ) <nl> { <nl> SendCoinsRecipient & rcp = ( * it ) ; <nl> - <nl> - # ifdef ENABLE_BIP70 <nl> - if ( rcp . paymentRequest . IsInitialized ( ) ) <nl> - { <nl> - CAmount subtotal = 0 ; <nl> - const payments : : PaymentDetails & details = rcp . paymentRequest . getDetails ( ) ; <nl> - for ( int j = 0 ; j < details . outputs_size ( ) ; j + + ) <nl> - { <nl> - const payments : : Output & out = details . outputs ( j ) ; <nl> - if ( out . amount ( ) < = 0 ) continue ; <nl> - if ( i = = nChangePosRet ) <nl> - i + + ; <nl> - subtotal + = walletTransaction - > vout [ i ] . nValue ; <nl> - i + + ; <nl> - } <nl> - rcp . amount = subtotal ; <nl> - } <nl> - else / / normal recipient ( no payment request ) <nl> - # endif <nl> { <nl> if ( i = = nChangePosRet ) <nl> i + + ; <nl>
Remove BIP70 Support
bitcoin/bitcoin
3548e4aac72e9148d41b440052a89d89328f7661
2019-10-24T20:01:43Z
mmm a / lib / ClangImporter / ImportDecl . cpp <nl> ppp b / lib / ClangImporter / ImportDecl . cpp <nl> namespace { <nl> continue ; <nl> <nl> / / Set function override . <nl> - / / FIXME : Proper type checking here ! <nl> if ( auto func = dyn_cast < FuncDecl > ( decl ) ) { <nl> - func - > setOverriddenDecl ( cast < FuncDecl > ( member ) ) ; <nl> + auto foundFunc = cast < FuncDecl > ( member ) ; <nl> + <nl> + / / Require a selector match . <nl> + if ( func - > getObjCSelector ( ) ! = foundFunc - > getObjCSelector ( ) ) <nl> + continue ; <nl> + <nl> + func - > setOverriddenDecl ( foundFunc ) ; <nl> return ; <nl> } <nl> <nl> / / Set constructor override . <nl> auto ctor = cast < ConstructorDecl > ( decl ) ; <nl> auto memberCtor = cast < ConstructorDecl > ( member ) ; <nl> + <nl> + / / Require a selector match . <nl> + if ( ctor - > getObjCSelector ( ) ! = memberCtor - > getObjCSelector ( ) ) <nl> + continue ; <nl> + <nl> ctor - > setOverriddenDecl ( memberCtor ) ; <nl> <nl> / / Propagate ' required ' to subclass initializers . <nl> namespace { <nl> result - > getFullName ( ) . getArgumentNames ( ) . empty ( ) ) <nl> return nullptr ; <nl> <nl> - if ( auto var = dyn_cast < VarDecl > ( result ) ) <nl> - overridden = var ; <nl> + if ( auto var = dyn_cast < VarDecl > ( result ) ) { <nl> + / / If the selectors of the getter match in Objective - C , we have an <nl> + / / override . <nl> + if ( var - > getObjCGetterSelector ( ) = = <nl> + Impl . importSelector ( decl - > getGetterName ( ) ) ) <nl> + overridden = var ; <nl> + } <nl> } <nl> <nl> if ( overridden ) { <nl> new file mode 100644 <nl> index 000000000000 . . 10bb549698c2 <nl> mmm / dev / null <nl> ppp b / test / Interpreter / SDK / archiving_generic_swift_class_renamed . swift <nl> <nl> + / / RUN : % target - build - swift - Xfrontend - enable - swift - name - lookup - tables - parse % s - F % S / Inputs - Xfrontend - enable - omit - needless - words - Xfrontend - verify <nl> + <nl> + / / REQUIRES : objc_interop <nl> + / / UNSUPPORTED : OS = tvos <nl> + / / UNSUPPORTED : OS = watchos <nl> + <nl> + import Foundation <nl> + <nl> + final class Foo < T : NSCoding > : NSObject , NSCoding { <nl> + var one , two : T <nl> + <nl> + init ( one : T , two : T ) { <nl> + self . one = one <nl> + self . two = two <nl> + } <nl> + <nl> + @ objc required convenience init ( coder : NSCoder ) { <nl> + let one = coder . decodeObjectForKey ( " one " ) as ! T <nl> + let two = coder . decodeObjectForKey ( " two " ) as ! T <nl> + self . init ( one : one , two : two ) <nl> + } <nl> + <nl> + @ objc ( encodeWithCoder : ) func encodeWith ( encoder : NSCoder ) { <nl> + encoder . encode ( one , forKey : " one " ) <nl> + encoder . encode ( two , forKey : " two " ) <nl> + } <nl> + } <nl> + <nl> + / / FIXME : W * macro equivalents should be in the Darwin / Glibc overlay <nl> + func WIFEXITED ( status : Int32 ) - > Bool { <nl> + return ( status & 0o177 ) = = 0 <nl> + } <nl> + func WEXITSTATUS ( status : Int32 ) - > Int32 { <nl> + return ( status > > 8 ) & 0xFF <nl> + } <nl> + <nl> + / / FIXME : " environ " should be in the Darwin overlay too <nl> + @ _silgen_name ( " _NSGetEnviron " ) <nl> + func _NSGetEnviron ( ) - > UnsafeMutablePointer < UnsafeMutablePointer < UnsafeMutablePointer < CChar > > > <nl> + <nl> + var environ : UnsafeMutablePointer < UnsafeMutablePointer < CChar > > { <nl> + return _NSGetEnviron ( ) . memory <nl> + } <nl> + <nl> + func driver ( ) { <nl> + / / Create a pipe to connect the archiver to the unarchiver . <nl> + var pipes : [ Int32 ] = [ 0 , 0 ] <nl> + guard pipe ( & pipes ) = = 0 else { fatalError ( " pipe failed " ) } <nl> + <nl> + let pipeRead = pipes [ 0 ] , pipeWrite = pipes [ 1 ] <nl> + <nl> + var archiver : pid_t = 0 , unarchiver : pid_t = 0 <nl> + <nl> + let envp = environ <nl> + <nl> + do { <nl> + / / Set up the archiver ' s stdout to feed into our pipe . <nl> + var archiverActions = posix_spawn_file_actions_t ( ) <nl> + guard posix_spawn_file_actions_init ( & archiverActions ) = = 0 else { <nl> + fatalError ( " posix_spawn_file_actions_init failed " ) <nl> + } <nl> + defer { posix_spawn_file_actions_destroy ( & archiverActions ) } <nl> + guard posix_spawn_file_actions_adddup2 ( & archiverActions , <nl> + pipeWrite , <nl> + STDOUT_FILENO ) = = 0 <nl> + & & posix_spawn_file_actions_addclose ( & archiverActions , <nl> + pipeRead ) = = 0 <nl> + else { <nl> + fatalError ( " posix_spawn_file_actions_add failed " ) <nl> + } <nl> + <nl> + / / Spawn the archiver process . <nl> + let archiverArgv : [ UnsafeMutablePointer < Int8 > ] = [ <nl> + Process . unsafeArgv [ 0 ] , <nl> + UnsafeMutablePointer ( ( " - archive " as StaticString ) . utf8Start ) , <nl> + nil <nl> + ] <nl> + guard posix_spawn ( & archiver , Process . unsafeArgv [ 0 ] , <nl> + & archiverActions , nil , <nl> + archiverArgv , envp ) = = 0 else { <nl> + fatalError ( " posix_spawn failed " ) <nl> + } <nl> + } <nl> + <nl> + do { <nl> + / / Set up the unarchiver ' s stdin to read from our pipe . <nl> + var unarchiverActions = posix_spawn_file_actions_t ( ) <nl> + guard posix_spawn_file_actions_init ( & unarchiverActions ) = = 0 else { <nl> + fatalError ( " posix_spawn_file_actions_init failed " ) <nl> + } <nl> + defer { posix_spawn_file_actions_destroy ( & unarchiverActions ) } <nl> + guard posix_spawn_file_actions_adddup2 ( & unarchiverActions , <nl> + pipeRead , <nl> + STDIN_FILENO ) = = 0 <nl> + & & posix_spawn_file_actions_addclose ( & unarchiverActions , <nl> + pipeWrite ) = = 0 <nl> + else { <nl> + fatalError ( " posix_spawn_file_actions_add failed " ) <nl> + } <nl> + <nl> + / / Spawn the unarchiver process . <nl> + var unarchiver : pid_t = 0 <nl> + let unarchiverArgv : [ UnsafeMutablePointer < Int8 > ] = [ <nl> + Process . unsafeArgv [ 0 ] , <nl> + UnsafeMutablePointer ( ( " - unarchive " as StaticString ) . utf8Start ) , <nl> + nil <nl> + ] <nl> + guard posix_spawn ( & unarchiver , Process . unsafeArgv [ 0 ] , <nl> + & unarchiverActions , nil , <nl> + unarchiverArgv , envp ) = = 0 else { <nl> + fatalError ( " posix_spawn failed " ) <nl> + } <nl> + } <nl> + <nl> + / / Wash our hands of the pipe , now that the subprocesses have started . <nl> + close ( pipeRead ) <nl> + close ( pipeWrite ) <nl> + <nl> + / / Wait for the subprocesses to finish . <nl> + var waiting : Set < pid_t > = [ archiver , unarchiver ] <nl> + while ! waiting . isEmpty { <nl> + var status : Int32 = 0 <nl> + let pid = wait ( & status ) <nl> + if pid = = - 1 { <nl> + / / If the error was EINTR , just wait again . <nl> + if errno = = EINTR { continue } <nl> + / / If we have no children to wait for , stop . <nl> + if errno = = ECHILD { break } <nl> + fatalError ( " wait failed " ) <nl> + } <nl> + waiting . remove ( pid ) <nl> + / / Ensure the process exited successfully . <nl> + guard WIFEXITED ( status ) & & WEXITSTATUS ( status ) = = 0 else { <nl> + fatalError ( " subprocess exited abnormally " ) <nl> + } <nl> + } <nl> + } <nl> + <nl> + func archive ( ) { <nl> + let data = NSMutableData ( ) <nl> + let archiver = NSKeyedArchiver ( forWritingWith : data ) <nl> + archiver . encode ( Foo < NSString > ( one : " one " , two : " two " ) , forKey : " strings " ) <nl> + archiver . encode ( Foo < NSNumber > ( one : 1 , two : 2 ) , forKey : " numbers " ) <nl> + archiver . finishEncoding ( ) <nl> + <nl> + / / Output the archived data over stdout , which should be piped to stdin <nl> + / / on the unarchiver process . <nl> + while true { <nl> + let status = write ( STDOUT_FILENO , data . bytes , data . length ) <nl> + if status = = data . length { break } <nl> + if errno = = EINTR { continue } <nl> + fatalError ( " write failed " ) <nl> + } <nl> + } <nl> + <nl> + func unarchive ( ) { <nl> + / / FIXME : Pre - instantiate the generic classes that were archived , since <nl> + / / the ObjC runtime doesn ' t know how . <nl> + NSStringFromClass ( Foo < NSNumber > . self ) <nl> + NSStringFromClass ( Foo < NSString > . self ) <nl> + <nl> + / / Read in the data from stdin , where the archiver process should have <nl> + / / written it . <nl> + var rawData : [ UInt8 ] = [ ] <nl> + <nl> + var buffer = [ UInt8 ] ( count : 4096 , repeatedValue : 0 ) <nl> + <nl> + while true { <nl> + let count = read ( STDIN_FILENO , & buffer , 4096 ) <nl> + if count = = 0 { break } <nl> + if count = = - 1 { <nl> + if errno = = EINTR { continue } <nl> + fatalError ( " read failed " ) <nl> + } <nl> + rawData + = buffer [ 0 . . < count ] <nl> + } <nl> + <nl> + / / Feed it into an unarchiver . <nl> + let data = NSData ( bytes : rawData , length : rawData . count ) <nl> + let unarchiver = NSKeyedUnarchiver ( forReadingWith : data ) <nl> + <nl> + guard let strings <nl> + = unarchiver . decodeObjectForKey ( " strings " ) as ? Foo < NSString > else { <nl> + fatalError ( " unable to unarchive Foo < NSString > " ) <nl> + } <nl> + guard let numbers <nl> + = unarchiver . decodeObjectForKey ( " numbers " ) as ? Foo < NSNumber > else { <nl> + fatalError ( " unable to unarchive Foo < NSNumber > " ) <nl> + } <nl> + <nl> + / / CHECK - LABEL : Foo < NSString > <nl> + / / CHECK : one : one <nl> + / / CHECK : two : two <nl> + / / CHECK - LABEL : Foo < NSNumber > <nl> + / / CHECK : one : 1 <nl> + / / CHECK : two : 2 <nl> + dump ( strings ) <nl> + dump ( numbers ) <nl> + } <nl> + <nl> + / / Pick a mode based on the command - line arguments . <nl> + / / The test launches as a " driver " which then respawns itself into reader <nl> + / / and writer subprocesses . <nl> + if Process . arguments . count < 2 { <nl> + driver ( ) <nl> + } else if Process . arguments [ 1 ] = = " - archive " { <nl> + archive ( ) <nl> + } else if Process . arguments [ 1 ] = = " - unarchive " { <nl> + unarchive ( ) <nl> + } else { <nl> + fatalError ( " invalid commandline argument " ) <nl> + } <nl> + <nl>
Clang importer : do selector matches to more carefully wire up overrides .
apple/swift
8fc9bb56de955183279f13c5dcd6b099fff42f17
2015-12-18T23:09:29Z
mmm a / tools / shared . py <nl> ppp b / tools / shared . py <nl> def normalize_config_settings ( ) : <nl> PORTS = os . path . join ( CACHE , ' ports ' ) <nl> <nl> if CLOSURE_COMPILER is None : <nl> - CLOSURE_COMPILER = get_npm_cmd ( ' google - closure - compiler ' ) <nl> - if not WINDOWS : <nl> + if WINDOWS : <nl> + CLOSURE_COMPILER = [ path_from_root ( ' node_modules ' , ' . bin ' , ' google - closure - compiler . cmd ' ) ] <nl> + else : <nl> # Work around an issue that Closure compiler can take up a lot of memory and crash in an error <nl> - # " FATAL ERROR : Ineffective mark - compacts near heap limit Allocation failed - JavaScript heap out of memory " <nl> + # " FATAL ERROR : Ineffective mark - compacts near heap limit Allocation failed - JavaScript heap out of memory " <nl> CLOSURE_COMPILER = NODE_JS + [ ' - - max_old_space_size = 8192 ' , path_from_root ( ' node_modules ' , ' . bin ' , ' google - closure - compiler ' ) ] <nl> <nl> if JAVA is None : <nl>
Partial revert of ( )
emscripten-core/emscripten
ac4896450e9f164525b3023cbc8d150681e44f71
2020-09-10T16:53:17Z
mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> add_subdirectory ( cocos / audio ) <nl> # cocos2d library <nl> add_subdirectory ( cocos ) <nl> <nl> + # network library <nl> + add_subdirectory ( cocos / network ) <nl> + <nl> + # ui library <nl> + add_subdirectory ( cocos / ui ) <nl> + <nl> + # sqlite3 library <nl> + add_subdirectory ( cocos / storage ) <nl> + <nl> if ( BUILD_EXTENSIONS ) <nl> # extensions <nl> add_subdirectory ( extensions ) <nl> mmm a / cocos / CMakeLists . txt <nl> ppp b / cocos / CMakeLists . txt <nl> include ( physics / CMakeLists . txt ) <nl> include ( math / CMakeLists . txt ) <nl> include ( renderer / CMakeLists . txt ) <nl> include ( base / CMakeLists . txt ) <nl> - include ( ui / CMakeLists . txt ) <nl> include ( deprecated / CMakeLists . txt ) <nl> - include ( network / CMakeLists . txt ) <nl> - include ( storage / CMakeLists . txt ) <nl> <nl> add_library ( cocos2d STATIC <nl> $ { COCOS_SRC } <nl> add_library ( cocos2d STATIC <nl> $ { COCOS_RENDERER_SRC } <nl> $ { COCOS_MATH_SRC } <nl> $ { COCOS_PHYSICS_SRC } <nl> - $ { COCOS_UI_SRC } <nl> - $ { COCOS_NETWORK_SRC } <nl> - $ { COCOS_STORAGE_SRC } <nl> $ { COCOS_DEPRECATED_SRC } <nl> ) <nl> <nl> target_link_libraries ( cocos2d <nl> tinyxml2 <nl> unzip <nl> xxhash <nl> - $ { COCOS_STORAGE_LINK } <nl> - $ { COCOS_NETWORK_LINK } <nl> $ { COCOS_LINK } <nl> ) <nl> <nl> mmm a / cocos / network / CMakeLists . txt <nl> ppp b / cocos / network / CMakeLists . txt <nl> <nl> if ( WIN32 ) <nl> set ( PLATFORM_SRC <nl> - network / WebSocket . cpp <nl> + WebSocket . cpp <nl> ) <nl> <nl> set ( PLATFORM_LINK <nl> if ( WIN32 ) <nl> ) <nl> elseif ( NOT APPLE ) <nl> set ( PLATFORM_SRC <nl> - network / WebSocket . cpp <nl> + WebSocket . cpp <nl> ) <nl> <nl> set ( PLATFORM_LINK <nl> elseif ( NOT APPLE ) <nl> endif ( ) <nl> <nl> set ( COCOS_NETWORK_SRC <nl> - network / HttpClient . cpp <nl> - network / SocketIO . cpp <nl> + HttpClient . cpp <nl> + SocketIO . cpp <nl> $ { PLATFORM_SRC } <nl> ) <nl> <nl> + add_library ( network STATIC <nl> + $ { COCOS_NETWORK_SRC } <nl> + ) <nl> + <nl> IF ( WIN32 AND NOT MINGW ) <nl> set ( COCOS_NETWORK_LINK <nl> libcurl_imp <nl> ELSE ( ) <nl> $ { PLATFORM_LINK } <nl> ) <nl> ENDIF ( ) <nl> + <nl> + target_link_libraries ( network <nl> + $ { COCOS_NETWORK_LINK } <nl> + ) <nl> + <nl> + set_target_properties ( network <nl> + PROPERTIES <nl> + ARCHIVE_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } / lib " <nl> + LIBRARY_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } / lib " <nl> + ) <nl> mmm a / cocos / storage / CMakeLists . txt <nl> ppp b / cocos / storage / CMakeLists . txt <nl> <nl> <nl> set ( COCOS_STORAGE_SRC <nl> - storage / local - storage / LocalStorage . cpp <nl> + local - storage / LocalStorage . cpp <nl> ) <nl> <nl> - set ( COCOS_STORAGE_LINK <nl> - sqlite3 <nl> + add_library ( sqlite3 STATIC <nl> + $ { COCOS_STORAGE_SRC } <nl> + ) <nl> + <nl> + set_target_properties ( sqlite3 <nl> + PROPERTIES <nl> + ARCHIVE_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } / lib " <nl> + LIBRARY_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } / lib " <nl> ) <nl> <nl> mmm a / cocos / ui / CMakeLists . txt <nl> ppp b / cocos / ui / CMakeLists . txt <nl> <nl> set ( COCOS_UI_SRC <nl> - ui / CocosGUI . cpp <nl> - ui / UIButton . cpp <nl> - ui / UICheckBox . cpp <nl> - ui / UIHBox . cpp <nl> - ui / UIHelper . cpp <nl> - ui / UIImageView . cpp <nl> - ui / UILayout . cpp <nl> - ui / UILayoutParameter . cpp <nl> - ui / UILayoutManager . cpp <nl> - ui / UIListView . cpp <nl> - ui / UILoadingBar . cpp <nl> - ui / UIPageView . cpp <nl> - ui / UIRelativeBox . cpp <nl> - ui / UIRichText . cpp <nl> - ui / UIScrollView . cpp <nl> - ui / UISlider . cpp <nl> - ui / UITextAtlas . cpp <nl> - ui / UITextBMFont . cpp <nl> - ui / UIText . cpp <nl> - ui / UITextField . cpp <nl> - ui / UIVBox . cpp <nl> - ui / UIWidget . cpp <nl> - ui / UIDeprecated . cpp <nl> - ui / UIScale9Sprite . cpp <nl> + CocosGUI . cpp <nl> + UIButton . cpp <nl> + UICheckBox . cpp <nl> + UIHBox . cpp <nl> + UIHelper . cpp <nl> + UIImageView . cpp <nl> + UILayout . cpp <nl> + UILayoutParameter . cpp <nl> + UILayoutManager . cpp <nl> + UIListView . cpp <nl> + UILoadingBar . cpp <nl> + UIPageView . cpp <nl> + UIRelativeBox . cpp <nl> + UIRichText . cpp <nl> + UIScrollView . cpp <nl> + UISlider . cpp <nl> + UITextAtlas . cpp <nl> + UITextBMFont . cpp <nl> + UIText . cpp <nl> + UITextField . cpp <nl> + UIVBox . cpp <nl> + UIWidget . cpp <nl> + UIDeprecated . cpp <nl> + UIScale9Sprite . cpp <nl> + ) <nl> + <nl> + include_directories ( <nl> + ui <nl> + . . / . . / base <nl> + ) <nl> + <nl> + <nl> + add_library ( ui STATIC <nl> + $ { COCOS_UI_SRC } <nl> + ) <nl> + <nl> + target_link_libraries ( ui <nl> + cocos2d <nl> + ) <nl> + <nl> + set_target_properties ( ui <nl> + PROPERTIES <nl> + ARCHIVE_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } / lib " <nl> + LIBRARY_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } / lib " <nl> ) <nl> <nl> mmm a / templates / lua - template - default / frameworks / CMakeLists . txt <nl> ppp b / templates / lua - template - default / frameworks / CMakeLists . txt <nl> set ( FMOD_LIB " fmodex " ) <nl> endif ( ) <nl> <nl> target_link_libraries ( $ { APP_NAME } <nl> - luabinding <nl> - spine <nl> - cocostudio <nl> - cocosbuilder <nl> - extensions <nl> + luacocos2d <nl> + luacocosdenshion <nl> + luanetwork <nl> audio <nl> cocos2d <nl> xxtea <nl> mmm a / tests / cpp - tests / CMakeLists . txt <nl> ppp b / tests / cpp - tests / CMakeLists . txt <nl> target_link_libraries ( $ { APP_NAME } <nl> audio <nl> cocos2d <nl> box2d <nl> + ui <nl> + network <nl> + sqlite3 <nl> ) <nl> <nl> set ( APP_BIN_DIR " $ { CMAKE_BINARY_DIR } / bin / $ { APP_NAME } " ) <nl> mmm a / tests / lua - empty - test / project / CMakeLists . txt <nl> ppp b / tests / lua - empty - test / project / CMakeLists . txt <nl> set ( SAMPLE_SRC <nl> <nl> include_directories ( <nl> Classes <nl> - . . / . . / . . / cocos / scripting / lua / bindings <nl> + . . / . . / . . / cocos / scripting / lua - bindings <nl> . . / . . / . . / external / lua / lua <nl> . . / . . / . . / external / lua / tolua <nl> ) <nl> target_link_libraries ( $ { APP_NAME } <nl> luanetwork <nl> audio <nl> cocos2d <nl> + network <nl> ) <nl> <nl> set ( APP_BIN_DIR " $ { CMAKE_BINARY_DIR } / bin / $ { APP_NAME } " ) <nl> mmm a / tests / lua - tests / project / CMakeLists . txt <nl> ppp b / tests / lua - tests / project / CMakeLists . txt <nl> target_link_libraries ( $ { APP_NAME } <nl> spine <nl> cocosbuilder <nl> extensions <nl> + ui <nl> + network <nl> ) <nl> <nl> set ( APP_BIN_DIR " $ { CMAKE_BINARY_DIR } / bin / $ { APP_NAME } " ) <nl>
extract ui , network and storage from cocos2d module and adjust relate CMakeLists . txt
cocos2d/cocos2d-x
aa4f407851a2f14e4ae9a167b44668afdceebdd4
2014-08-07T05:53:13Z
mmm a / benchmark / single - source / DictTest2 . swift <nl> ppp b / benchmark / single - source / DictTest2 . swift <nl> public func run_Dictionary2 ( _ N : Int ) { <nl> CheckResults ( res = = ref_result , " Incorrect results in Dictionary2 : \ ( res ) ! = \ ( ref_result ) " ) <nl> } <nl> <nl> - class Box < T : Hashable > : Hashable { <nl> + class Box < T : Hashable > : Hashable where T : Equatable { <nl> var value : T <nl> <nl> init ( _ v : T ) { <nl> mmm a / benchmark / single - source / Histogram . swift <nl> ppp b / benchmark / single - source / Histogram . swift <nl> import TestsUtils <nl> <nl> typealias rrggbb_t = UInt32 <nl> <nl> - func output_sorted_sparse_rgb_histogram < S : Sequence where S . Iterator . Element = = rrggbb_t > ( _ samples : S , _ N : Int ) { <nl> + func output_sorted_sparse_rgb_histogram < S : Sequence > ( _ samples : S , _ N : Int ) <nl> + where S . Iterator . Element = = rrggbb_t { <nl> var histogram = Dictionary < rrggbb_t , Int > ( ) <nl> for _ in 1 . . . 50 * N { <nl> for sample in samples { / / This part is really awful , I agree <nl> mmm a / benchmark / single - source / PopFrontGeneric . swift <nl> ppp b / benchmark / single - source / PopFrontGeneric . swift <nl> extension Array : MyArrayBufferProtocol { <nl> } <nl> } <nl> <nl> - func myArrayReplace < B : MyArrayBufferProtocol , C : Collection <nl> - where C . Iterator . Element = = B . Element , B . Index = = Int <nl> - > ( <nl> - _ target : inout B , _ subRange : Range < Int > , _ newValues : C <nl> - ) { <nl> + func myArrayReplace < <nl> + B : MyArrayBufferProtocol , <nl> + C : Collection <nl> + > ( _ target : inout B , _ subRange : Range < Int > , _ newValues : C ) <nl> + where C . Iterator . Element = = B . Element , B . Index = = Int { <nl> target . myReplace ( subRange , with : newValues ) <nl> } <nl> <nl>
Merge pull request from bitjammer / update - benchmarks - where - clause
apple/swift
7be7cc5554f8c1075558e0ef18615758d2635e25
2016-07-29T21:32:14Z
mmm a / editor / plugins / script_text_editor . cpp <nl> ppp b / editor / plugins / script_text_editor . cpp <nl> void ScriptTextEditor : : register_editor ( ) { <nl> ED_SHORTCUT ( " script_text_editor / unfold_all_lines " , TTR ( " Unfold All Lines " ) , 0 ) ; <nl> # ifdef OSX_ENABLED <nl> ED_SHORTCUT ( " script_text_editor / clone_down " , TTR ( " Clone Down " ) , KEY_MASK_SHIFT | KEY_MASK_CMD | KEY_C ) ; <nl> + ED_SHORTCUT ( " script_text_editor / complete_symbol " , TTR ( " Complete Symbol " ) , KEY_MASK_CTRL | KEY_SPACE ) ; <nl> # else <nl> ED_SHORTCUT ( " script_text_editor / clone_down " , TTR ( " Clone Down " ) , KEY_MASK_CMD | KEY_B ) ; <nl> - # endif <nl> ED_SHORTCUT ( " script_text_editor / complete_symbol " , TTR ( " Complete Symbol " ) , KEY_MASK_CMD | KEY_SPACE ) ; <nl> + # endif <nl> ED_SHORTCUT ( " script_text_editor / trim_trailing_whitespace " , TTR ( " Trim Trailing Whitespace " ) , KEY_MASK_CMD | KEY_MASK_ALT | KEY_T ) ; <nl> ED_SHORTCUT ( " script_text_editor / convert_indent_to_spaces " , TTR ( " Convert Indent To Spaces " ) , KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_Y ) ; <nl> ED_SHORTCUT ( " script_text_editor / convert_indent_to_tabs " , TTR ( " Convert Indent To Tabs " ) , KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_X ) ; <nl>
Merge pull request from tko / macos - complete
godotengine/godot
ac38b7e97b3de082d87a65bed7b53b51e603fec0
2018-08-28T05:40:55Z
mmm a / hphp / runtime / base / emulate - zend . cpp <nl> ppp b / hphp / runtime / base / emulate - zend . cpp <nl> int emulate_zend ( int argc , char * * argv ) { <nl> exit ( EXIT_FAILURE ) ; <nl> } <nl> } <nl> - if ( strcmp ( argv [ cnt ] , " - d " ) = = 0 ) { <nl> + if ( strcmp ( argv [ cnt ] , " - d " ) = = 0 | | strcmp ( argv [ cnt ] , " - - define " ) = = 0 ) { <nl> ini_fd = get_tempfile_if_not_exists ( ini_fd , ini_path ) ; <nl> <nl> std : : string line = argv [ cnt + 1 ] ; <nl> mmm a / hphp / test / slow / emulate_zend / command_line_arguments . php <nl> ppp b / hphp / test / slow / emulate_zend / command_line_arguments . php <nl> <nl> $ cmd = PHP_BINARY . ' - - php - n < ' . SCRIPT_NAME ; <nl> var_dump ( $ cmd ) ; <nl> system ( $ cmd ) ; <nl> + <nl> + $ cmd = PHP_BINARY . ' - - php - - define date . timezone = America / New_York - r " var_dump ( ( string ) ( new DateTime ( ) ) - > format ( \ ' e \ ' ) ) ; " ' ; <nl> + var_dump ( $ cmd ) ; <nl> + system ( $ cmd ) ; <nl> + <nl> + $ cmd = PHP_BINARY . ' - - php - - define date . timezone = America / Los_Angeles - r " var_dump ( ( string ) ( new DateTime ( ) ) - > format ( \ ' e \ ' ) ) ; " ' ; <nl> + var_dump ( $ cmd ) ; <nl> + system ( $ cmd ) ; <nl> mmm a / hphp / test / slow / emulate_zend / command_line_arguments . php . expectf <nl> ppp b / hphp / test / slow / emulate_zend / command_line_arguments . php . expectf <nl> string ( % s ) " % s - - php - n - d foo = bar % s / command_line_arguments . inc " <nl> string ( 12 ) " Hello world ! " <nl> string ( % s ) " % s - - php - n < % s / command_line_arguments . inc " <nl> string ( 12 ) " Hello world ! " <nl> + string ( % s ) " % s - - php - - define date . timezone = America / New_York % s " <nl> + string ( 16 ) " America / New_York " <nl> + string ( % s ) " % s - - php - - define date . timezone = America / Los_Angeles % s " <nl> + string ( 19 ) " America / Los_Angeles " <nl>
fix add ' - - define ' CLI option for use with ' - - php '
facebook/hhvm
b1c4f18f32532e8af16babca9914939ef9064747
2015-10-08T22:30:32Z
mmm a / script / eslintrc - base . json <nl> ppp b / script / eslintrc - base . json <nl> <nl> " comma - dangle " : 0 , <nl> " linebreak - style " : 0 , <nl> " no - console " : 0 , <nl> - " no - undef " : 0 , <nl> + " no - undef " : 2 , <nl> " no - unused - vars " : 2 <nl> } , <nl> " env " : { <nl>
Enable no - undef eslint rule
electron/electron
b46d8ec91ba4218f34fc51ce91cd25db46f40b6a
2016-01-21T16:32:22Z
mmm a / xbmc / cores / AudioEngine / AEFactory . cpp <nl> ppp b / xbmc / cores / AudioEngine / AEFactory . cpp <nl> void CAEFactory : : UnregisterAudioCallback ( ) <nl> AE - > UnregisterAudioCallback ( ) ; <nl> } <nl> <nl> - bool CAEFactory : : IsSettingVisible ( const std : : string & condition , const std : : string & value , const std : : string & settingId ) <nl> + bool CAEFactory : : IsSettingVisible ( const std : : string & condition , const std : : string & value , const CSetting * setting ) <nl> { <nl> - if ( settingId . empty ( ) | | value . empty ( ) | | ! AE ) <nl> + if ( setting = = NULL | | value . empty ( ) | | ! AE ) <nl> return false ; <nl> <nl> return AE - > IsSettingVisible ( value ) ; <nl> mmm a / xbmc / cores / AudioEngine / AEFactory . h <nl> ppp b / xbmc / cores / AudioEngine / AEFactory . h <nl> class CAEFactory <nl> static void SettingOptionsAudioDevicesPassthroughFiller ( const CSetting * setting , std : : vector < std : : pair < std : : string , std : : string > > & list , std : : string & current ) ; <nl> static void SettingOptionsAudioQualityLevelsFiller ( const CSetting * setting , std : : vector < std : : pair < std : : string , int > > & list , int & current ) ; <nl> static void SettingOptionsAudioStreamsilenceFiller ( const CSetting * setting , std : : vector < std : : pair < std : : string , int > > & list , int & current ) ; <nl> - static bool IsSettingVisible ( const std : : string & condition , const std : : string & value , const std : : string & settingId ) ; <nl> + static bool IsSettingVisible ( const std : : string & condition , const std : : string & value , const CSetting * setting ) ; <nl> static void KeepConfiguration ( unsigned int millis ) ; <nl> static void DeviceChange ( ) ; <nl> <nl> mmm a / xbmc / cores / dvdplayer / DVDCodecs / Video / DVDVideoCodec . cpp <nl> ppp b / xbmc / cores / dvdplayer / DVDCodecs / Video / DVDVideoCodec . cpp <nl> <nl> # include " DVDVideoCodec . h " <nl> # include " windowing / WindowingFactory . h " <nl> # include " settings / Settings . h " <nl> + # include " settings / lib / Setting . h " <nl> <nl> - bool CDVDVideoCodec : : IsSettingVisible ( const std : : string & condition , const std : : string & value , const std : : string & settingId ) <nl> + bool CDVDVideoCodec : : IsSettingVisible ( const std : : string & condition , const std : : string & value , const CSetting * setting ) <nl> { <nl> - if ( settingId . empty ( ) | | value . empty ( ) ) <nl> + if ( setting = = NULL | | value . empty ( ) ) <nl> return false ; <nl> <nl> + const std : : string & settingId = setting - > GetId ( ) ; <nl> + <nl> / / check if we are running on nvidia hardware <nl> std : : string gpuvendor = g_Windowing . GetRenderVendor ( ) ; <nl> std : : transform ( gpuvendor . begin ( ) , gpuvendor . end ( ) , gpuvendor . begin ( ) , : : tolower ) ; <nl> bool CDVDVideoCodec : : IsCodecDisabled ( DVDCodecAvailableType * map , unsigned int si <nl> } <nl> } <nl> if ( index > - 1 ) <nl> - return ( ! CSettings : : Get ( ) . GetBool ( map [ index ] . setting ) | | ! CDVDVideoCodec : : IsSettingVisible ( " unused " , " unused " , map [ index ] . setting ) ) ; <nl> + return ( ! CSettings : : Get ( ) . GetBool ( map [ index ] . setting ) | | ! CDVDVideoCodec : : IsSettingVisible ( " unused " , " unused " , CSettings : : Get ( ) . GetSetting ( map [ index ] . setting ) ) ) ; <nl> <nl> return false ; / / don ' t disable what we don ' t have <nl> } <nl> mmm a / xbmc / cores / dvdplayer / DVDCodecs / Video / DVDVideoCodec . h <nl> ppp b / xbmc / cores / dvdplayer / DVDCodecs / Video / DVDVideoCodec . h <nl> extern " C " { <nl> # include " libavcodec / avcodec . h " <nl> } <nl> <nl> + class CSetting ; <nl> + <nl> struct DVDCodecAvailableType <nl> { <nl> AVCodecID codec ; <nl> class CDVDVideoCodec <nl> * Hide or Show Settings depending on the currently running hardware <nl> * <nl> * / <nl> - static bool IsSettingVisible ( const std : : string & condition , const std : : string & value , const std : : string & settingId ) ; <nl> + static bool IsSettingVisible ( const std : : string & condition , const std : : string & value , const CSetting * setting ) ; <nl> <nl> / * * <nl> * Interact with user settings so that user disabled codecs are disabled <nl> mmm a / xbmc / settings / SettingConditions . cpp <nl> ppp b / xbmc / settings / SettingConditions . cpp <nl> <nl> # include " Application . h " <nl> # include " GUIPassword . h " <nl> # include " Util . h " <nl> + # include " addons / AddonManager . h " <nl> + # include " addons / Skin . h " <nl> # if defined ( TARGET_ANDROID ) <nl> # include " android / activity / AndroidFeatures . h " <nl> # endif / / defined ( TARGET_ANDROID ) <nl> <nl> # include " utils / SystemInfo . h " <nl> # include " windowing / WindowingFactory . h " <nl> <nl> - bool CheckMasterLock ( const std : : string & condition , const std : : string & value , const std : : string & settingId ) <nl> + bool AddonHasSettings ( const std : : string & condition , const std : : string & value , const CSetting * setting ) <nl> + { <nl> + if ( setting = = NULL ) <nl> + return false ; <nl> + <nl> + const CSettingAddon * settingAddon = dynamic_cast < const CSettingAddon * > ( setting ) ; <nl> + if ( settingAddon = = NULL ) <nl> + return false ; <nl> + <nl> + ADDON : : AddonPtr addon ; <nl> + if ( ! ADDON : : CAddonMgr : : Get ( ) . GetAddon ( settingAddon - > GetValue ( ) , addon , settingAddon - > GetAddonType ( ) ) | | addon = = NULL ) <nl> + return false ; <nl> + <nl> + if ( addon - > Type ( ) = = ADDON : : ADDON_SKIN ) <nl> + return ( ( ADDON : : CSkinInfo * ) addon . get ( ) ) - > HasSkinFile ( " SkinSettings . xml " ) ; <nl> + <nl> + return addon - > HasSettings ( ) ; <nl> + } <nl> + <nl> + bool CheckMasterLock ( const std : : string & condition , const std : : string & value , const CSetting * setting ) <nl> { <nl> return g_passwordManager . IsMasterLockUnlocked ( StringUtils : : EqualsNoCase ( value , " true " ) ) ; <nl> } <nl> <nl> - bool CheckPVRParentalPin ( const std : : string & condition , const std : : string & value , const std : : string & settingId ) <nl> + bool CheckPVRParentalPin ( const std : : string & condition , const std : : string & value , const CSetting * setting ) <nl> { <nl> return PVR : : g_PVRManager . CheckParentalPIN ( g_localizeStrings . Get ( 19262 ) . c_str ( ) ) ; <nl> } <nl> <nl> - bool HasPeripherals ( const std : : string & condition , const std : : string & value , const std : : string & settingId ) <nl> + bool HasPeripherals ( const std : : string & condition , const std : : string & value , const CSetting * setting ) <nl> { <nl> return PERIPHERALS : : g_peripherals . GetNumberOfPeripherals ( ) > 0 ; <nl> } <nl> <nl> - bool IsFullscreen ( const std : : string & condition , const std : : string & value , const std : : string & settingId ) <nl> + bool IsFullscreen ( const std : : string & condition , const std : : string & value , const CSetting * setting ) <nl> { <nl> return g_Windowing . IsFullScreen ( ) ; <nl> } <nl> <nl> - bool IsMasterUser ( const std : : string & condition , const std : : string & value , const std : : string & settingId ) <nl> + bool IsMasterUser ( const std : : string & condition , const std : : string & value , const CSetting * setting ) <nl> { <nl> return g_passwordManager . bMasterUser ; <nl> } <nl> <nl> - bool IsUsingTTFSubtitles ( const std : : string & condition , const std : : string & value , const std : : string & settingId ) <nl> + bool IsUsingTTFSubtitles ( const std : : string & condition , const std : : string & value , const CSetting * setting ) <nl> { <nl> return CUtil : : IsUsingTTFSubtitles ( ) ; <nl> } <nl> <nl> - bool ProfileCanWriteDatabase ( const std : : string & condition , const std : : string & value , const std : : string & settingId ) <nl> + bool ProfileCanWriteDatabase ( const std : : string & condition , const std : : string & value , const CSetting * setting ) <nl> { <nl> return CProfilesManager : : Get ( ) . GetCurrentProfile ( ) . canWriteDatabases ( ) ; <nl> } <nl> <nl> - bool ProfileCanWriteSources ( const std : : string & condition , const std : : string & value , const std : : string & settingId ) <nl> + bool ProfileCanWriteSources ( const std : : string & condition , const std : : string & value , const CSetting * setting ) <nl> { <nl> return CProfilesManager : : Get ( ) . GetCurrentProfile ( ) . canWriteSources ( ) ; <nl> } <nl> <nl> - bool ProfileHasAddons ( const std : : string & condition , const std : : string & value , const std : : string & settingId ) <nl> + bool ProfileHasAddons ( const std : : string & condition , const std : : string & value , const CSetting * setting ) <nl> { <nl> return CProfilesManager : : Get ( ) . GetCurrentProfile ( ) . hasAddons ( ) ; <nl> } <nl> <nl> - bool ProfileHasDatabase ( const std : : string & condition , const std : : string & value , const std : : string & settingId ) <nl> + bool ProfileHasDatabase ( const std : : string & condition , const std : : string & value , const CSetting * setting ) <nl> { <nl> return CProfilesManager : : Get ( ) . GetCurrentProfile ( ) . hasDatabases ( ) ; <nl> } <nl> <nl> - bool ProfileHasSources ( const std : : string & condition , const std : : string & value , const std : : string & settingId ) <nl> + bool ProfileHasSources ( const std : : string & condition , const std : : string & value , const CSetting * setting ) <nl> { <nl> return CProfilesManager : : Get ( ) . GetCurrentProfile ( ) . hasSources ( ) ; <nl> } <nl> <nl> - bool ProfileHasAddonManagerLocked ( const std : : string & condition , const std : : string & value , const std : : string & settingId ) <nl> + bool ProfileHasAddonManagerLocked ( const std : : string & condition , const std : : string & value , const CSetting * setting ) <nl> { <nl> return CProfilesManager : : Get ( ) . GetCurrentProfile ( ) . addonmanagerLocked ( ) ; <nl> } <nl> <nl> - bool ProfileHasFilesLocked ( const std : : string & condition , const std : : string & value , const std : : string & settingId ) <nl> + bool ProfileHasFilesLocked ( const std : : string & condition , const std : : string & value , const CSetting * setting ) <nl> { <nl> return CProfilesManager : : Get ( ) . GetCurrentProfile ( ) . filesLocked ( ) ; <nl> } <nl> <nl> - bool ProfileHasMusicLocked ( const std : : string & condition , const std : : string & value , const std : : string & settingId ) <nl> + bool ProfileHasMusicLocked ( const std : : string & condition , const std : : string & value , const CSetting * setting ) <nl> { <nl> return CProfilesManager : : Get ( ) . GetCurrentProfile ( ) . musicLocked ( ) ; <nl> } <nl> <nl> - bool ProfileHasPicturesLocked ( const std : : string & condition , const std : : string & value , const std : : string & settingId ) <nl> + bool ProfileHasPicturesLocked ( const std : : string & condition , const std : : string & value , const CSetting * setting ) <nl> { <nl> return CProfilesManager : : Get ( ) . GetCurrentProfile ( ) . picturesLocked ( ) ; <nl> } <nl> <nl> - bool ProfileHasProgramsLocked ( const std : : string & condition , const std : : string & value , const std : : string & settingId ) <nl> + bool ProfileHasProgramsLocked ( const std : : string & condition , const std : : string & value , const CSetting * setting ) <nl> { <nl> return CProfilesManager : : Get ( ) . GetCurrentProfile ( ) . programsLocked ( ) ; <nl> } <nl> <nl> - bool ProfileHasSettingsLocked ( const std : : string & condition , const std : : string & value , const std : : string & settingId ) <nl> + bool ProfileHasSettingsLocked ( const std : : string & condition , const std : : string & value , const CSetting * setting ) <nl> { <nl> LOCK_LEVEL : : SETTINGS_LOCK slValue = LOCK_LEVEL : : ALL ; <nl> if ( StringUtils : : EqualsNoCase ( value , " none " ) ) <nl> bool ProfileHasSettingsLocked ( const std : : string & condition , const std : : string & v <nl> return slValue < = CProfilesManager : : Get ( ) . GetCurrentProfile ( ) . settingsLockLevel ( ) ; <nl> } <nl> <nl> - bool ProfileHasVideosLocked ( const std : : string & condition , const std : : string & value , const std : : string & settingId ) <nl> + bool ProfileHasVideosLocked ( const std : : string & condition , const std : : string & value , const CSetting * setting ) <nl> { <nl> return CProfilesManager : : Get ( ) . GetCurrentProfile ( ) . videoLocked ( ) ; <nl> } <nl> <nl> - bool ProfileLockMode ( const std : : string & condition , const std : : string & value , const std : : string & settingId ) <nl> + bool ProfileLockMode ( const std : : string & condition , const std : : string & value , const CSetting * setting ) <nl> { <nl> char * tmp = NULL ; <nl> LockType lock = ( LockType ) strtol ( value . c_str ( ) , & tmp , 0 ) ; <nl> void CSettingConditions : : Initialize ( ) <nl> m_simpleConditions . insert ( " has_ae_quality_levels " ) ; <nl> <nl> / / add complex conditions <nl> - m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " checkmasterlock " , CheckMasterLock ) ) ; <nl> - m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " checkpvrparentalpin " , CheckPVRParentalPin ) ) ; <nl> - m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " hasperipherals " , HasPeripherals ) ) ; <nl> - m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " isfullscreen " , IsFullscreen ) ) ; <nl> - m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " ismasteruser " , IsMasterUser ) ) ; <nl> - m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " isusingttfsubtitles " , IsUsingTTFSubtitles ) ) ; <nl> - m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " profilecanwritedatabase " , ProfileCanWriteDatabase ) ) ; <nl> - m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " profilecanwritesources " , ProfileCanWriteSources ) ) ; <nl> - m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " profilehasaddons " , ProfileHasAddons ) ) ; <nl> - m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " profilehasdatabase " , ProfileHasDatabase ) ) ; <nl> - m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " profilehassources " , ProfileHasSources ) ) ; <nl> - m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " profilehasaddonmanagerlocked " , ProfileHasAddonManagerLocked ) ) ; <nl> - m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " profilehasfileslocked " , ProfileHasFilesLocked ) ) ; <nl> - m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " profilehasmusiclocked " , ProfileHasMusicLocked ) ) ; <nl> - m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " profilehaspictureslocked " , ProfileHasPicturesLocked ) ) ; <nl> - m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " profilehasprogramslocked " , ProfileHasProgramsLocked ) ) ; <nl> - m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " profilehassettingslocked " , ProfileHasSettingsLocked ) ) ; <nl> - m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " profilehasvideoslocked " , ProfileHasVideosLocked ) ) ; <nl> - m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " profilelockmode " , ProfileLockMode ) ) ; <nl> - m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " aesettingvisible " , CAEFactory : : IsSettingVisible ) ) ; <nl> - m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " codecoptionvisible " , CDVDVideoCodec : : IsSettingVisible ) ) ; <nl> + m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " addonhassettings " , AddonHasSettings ) ) ; <nl> + m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " checkmasterlock " , CheckMasterLock ) ) ; <nl> + m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " checkpvrparentalpin " , CheckPVRParentalPin ) ) ; <nl> + m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " hasperipherals " , HasPeripherals ) ) ; <nl> + m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " isfullscreen " , IsFullscreen ) ) ; <nl> + m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " ismasteruser " , IsMasterUser ) ) ; <nl> + m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " isusingttfsubtitles " , IsUsingTTFSubtitles ) ) ; <nl> + m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " profilecanwritedatabase " , ProfileCanWriteDatabase ) ) ; <nl> + m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " profilecanwritesources " , ProfileCanWriteSources ) ) ; <nl> + m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " profilehasaddons " , ProfileHasAddons ) ) ; <nl> + m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " profilehasdatabase " , ProfileHasDatabase ) ) ; <nl> + m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " profilehassources " , ProfileHasSources ) ) ; <nl> + m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " profilehasaddonmanagerlocked " , ProfileHasAddonManagerLocked ) ) ; <nl> + m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " profilehasfileslocked " , ProfileHasFilesLocked ) ) ; <nl> + m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " profilehasmusiclocked " , ProfileHasMusicLocked ) ) ; <nl> + m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " profilehaspictureslocked " , ProfileHasPicturesLocked ) ) ; <nl> + m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " profilehasprogramslocked " , ProfileHasProgramsLocked ) ) ; <nl> + m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " profilehassettingslocked " , ProfileHasSettingsLocked ) ) ; <nl> + m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " profilehasvideoslocked " , ProfileHasVideosLocked ) ) ; <nl> + m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " profilelockmode " , ProfileLockMode ) ) ; <nl> + m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " aesettingvisible " , CAEFactory : : IsSettingVisible ) ) ; <nl> + m_complexConditions . insert ( std : : pair < std : : string , SettingConditionCheck > ( " codecoptionvisible " , CDVDVideoCodec : : IsSettingVisible ) ) ; <nl> } <nl> <nl> - bool CSettingConditions : : Check ( const std : : string & condition ) <nl> + bool CSettingConditions : : Check ( const std : : string & condition , const std : : string & value / * = " " * / , const CSetting * setting / * = NULL * / ) <nl> { <nl> - return m_simpleConditions . find ( condition ) ! = m_simpleConditions . end ( ) ; <nl> - } <nl> + if ( m_simpleConditions . find ( condition ) ! = m_simpleConditions . end ( ) ) <nl> + return true ; <nl> <nl> - bool CSettingConditions : : Check ( const std : : string & condition , const std : : string & value , const std : : string & settingId ) <nl> - { <nl> std : : map < std : : string , SettingConditionCheck > : : const_iterator itCondition = m_complexConditions . find ( condition ) ; <nl> if ( itCondition ! = m_complexConditions . end ( ) ) <nl> - return itCondition - > second ( condition , value , settingId ) ; <nl> + return itCondition - > second ( condition , value , setting ) ; <nl> <nl> return Check ( condition ) ; <nl> } <nl> mmm a / xbmc / settings / SettingConditions . h <nl> ppp b / xbmc / settings / SettingConditions . h <nl> class CSettingConditions <nl> static const std : : set < std : : string > & GetSimpleConditions ( ) { return m_simpleConditions ; } <nl> static const std : : map < std : : string , SettingConditionCheck > & GetComplexConditions ( ) { return m_complexConditions ; } <nl> <nl> - static bool Check ( const std : : string & condition ) ; <nl> - static bool Check ( const std : : string & condition , const std : : string & value , const std : : string & settingId ) ; <nl> + static bool Check ( const std : : string & condition , const std : : string & value = " " , const CSetting * setting = NULL ) ; <nl> <nl> private : <nl> static std : : set < std : : string > m_simpleConditions ; <nl> mmm a / xbmc / settings / Settings . cpp <nl> ppp b / xbmc / settings / Settings . cpp <nl> <nl> # include " Autorun . h " <nl> # include " LangInfo . h " <nl> # include " Util . h " <nl> - # include " addons / AddonManager . h " <nl> # include " addons / Skin . h " <nl> # include " cores / AudioEngine / AEFactory . h " <nl> # include " cores / dvdplayer / DVDCodecs / Video / DVDVideoCodec . h " <nl> <nl> <nl> using namespace XFILE ; <nl> <nl> - bool AddonHasSettings ( const std : : string & condition , const std : : string & value , const std : : string & settingId ) <nl> - { <nl> - if ( settingId . empty ( ) ) <nl> - return false ; <nl> - <nl> - CSettingAddon * setting = ( CSettingAddon * ) CSettings : : Get ( ) . GetSetting ( settingId ) ; <nl> - if ( setting = = NULL ) <nl> - return false ; <nl> - <nl> - ADDON : : AddonPtr addon ; <nl> - if ( ! ADDON : : CAddonMgr : : Get ( ) . GetAddon ( setting - > GetValue ( ) , addon , setting - > GetAddonType ( ) ) | | addon = = NULL ) <nl> - return false ; <nl> - <nl> - if ( addon - > Type ( ) = = ADDON : : ADDON_SKIN ) <nl> - return ( ( ADDON : : CSkinInfo * ) addon . get ( ) ) - > HasSkinFile ( " SkinSettings . xml " ) ; <nl> - <nl> - return addon - > HasSettings ( ) ; <nl> - } <nl> - <nl> CSettings : : CSettings ( ) <nl> : m_initialized ( false ) <nl> { <nl> void CSettings : : InitializeConditions ( ) <nl> m_settingsManager - > AddCondition ( * itCondition ) ; <nl> <nl> / / add more complex conditions <nl> - m_settingsManager - > AddCondition ( " addonhassettings " , AddonHasSettings ) ; <nl> - <nl> const std : : map < std : : string , SettingConditionCheck > & complexConditions = CSettingConditions : : GetComplexConditions ( ) ; <nl> for ( std : : map < std : : string , SettingConditionCheck > : : const_iterator itCondition = complexConditions . begin ( ) ; itCondition ! = complexConditions . end ( ) ; + + itCondition ) <nl> m_settingsManager - > AddCondition ( itCondition - > first , itCondition - > second ) ; <nl>
settings : adjust the implementations of SettingConditionCheck
xbmc/xbmc
a2a2c6fbf13878ca154c9395716e14601959eece
2014-05-07T16:33:00Z
mmm a / tools / jenkins / grpc_interop_node / Dockerfile <nl> ppp b / tools / jenkins / grpc_interop_node / Dockerfile <nl> RUN apt - get update & & apt - get install - y \ <nl> libc6 - dbg \ <nl> libc6 - dev \ <nl> libgtest - dev \ <nl> + libssl - dev \ <nl> libtool \ <nl> make \ <nl> strace \ <nl> mmm a / tools / jenkins / grpc_interop_node / build_interop . sh <nl> ppp b / tools / jenkins / grpc_interop_node / build_interop . sh <nl> make install - certs <nl> <nl> # build Node interop client & server <nl> npm install - g node - gyp <nl> - make install_c - C / var / local / git / grpc <nl> - ( cd src / node & & npm install & & node - gyp rebuild ) <nl> + ( npm install & & node - gyp rebuild ) <nl>
Fixed node interop build script and Dockerfile
grpc/grpc
c86909ce71b04a78a6cf7f662e1ce937d7f8ef3b
2015-10-09T18:25:42Z
mmm a / src / extensions / gc - extension . cc <nl> ppp b / src / extensions / gc - extension . cc <nl> struct GCOptions { <nl> ExecutionType execution ; <nl> } ; <nl> <nl> - bool IsProperty ( v8 : : Isolate * isolate , v8 : : Local < v8 : : Context > ctx , <nl> - v8 : : Local < v8 : : Object > object , const char * key , <nl> - const char * value ) { <nl> + Maybe < bool > IsProperty ( v8 : : Isolate * isolate , v8 : : Local < v8 : : Context > ctx , <nl> + v8 : : Local < v8 : : Object > object , const char * key , <nl> + const char * value ) { <nl> auto k = v8 : : String : : NewFromUtf8 ( isolate , key ) . ToLocalChecked ( ) ; <nl> / / Get will return undefined for non - existing keys which will make <nl> / / StrictEquals fail . <nl> auto maybe_property = object - > Get ( ctx , k ) ; <nl> - if ( maybe_property . IsEmpty ( ) ) return false ; <nl> - return maybe_property . ToLocalChecked ( ) - > StrictEquals ( <nl> - v8 : : String : : NewFromUtf8 ( isolate , value ) . ToLocalChecked ( ) ) ; <nl> + if ( maybe_property . IsEmpty ( ) ) return Nothing < bool > ( ) ; <nl> + return Just < bool > ( maybe_property . ToLocalChecked ( ) - > StrictEquals ( <nl> + v8 : : String : : NewFromUtf8 ( isolate , value ) . ToLocalChecked ( ) ) ) ; <nl> } <nl> <nl> - GCOptions Parse ( v8 : : Isolate * isolate , v8 : : Local < v8 : : Context > ctx , <nl> - const v8 : : FunctionCallbackInfo < v8 : : Value > & args ) { <nl> + Maybe < GCOptions > Parse ( v8 : : Isolate * isolate , v8 : : Local < v8 : : Context > ctx , <nl> + const v8 : : FunctionCallbackInfo < v8 : : Value > & args ) { <nl> / / Default values . <nl> auto options = <nl> GCOptions { v8 : : Isolate : : GarbageCollectionType : : kFullGarbageCollection , <nl> ExecutionType : : kSync } ; <nl> bool found_options_object = false ; <nl> <nl> - if ( args [ 0 ] - > IsObject ( ) & & ! args [ 0 ] - > IsProxy ( ) ) { <nl> + if ( args [ 0 ] - > IsObject ( ) ) { <nl> auto param = v8 : : Local < v8 : : Object > : : Cast ( args [ 0 ] ) ; <nl> - if ( IsProperty ( isolate , ctx , param , " type " , " minor " ) ) { <nl> + <nl> + auto maybe_type = IsProperty ( isolate , ctx , param , " type " , " minor " ) ; <nl> + if ( maybe_type . IsNothing ( ) ) return Nothing < GCOptions > ( ) ; <nl> + if ( maybe_type . ToChecked ( ) ) { <nl> found_options_object = true ; <nl> options . type = <nl> v8 : : Isolate : : GarbageCollectionType : : kMinorGarbageCollection ; <nl> } <nl> - if ( IsProperty ( isolate , ctx , param , " execution " , " async " ) ) { <nl> + auto maybe_execution = <nl> + IsProperty ( isolate , ctx , param , " execution " , " async " ) ; <nl> + if ( maybe_execution . IsNothing ( ) ) return Nothing < GCOptions > ( ) ; <nl> + if ( maybe_execution . ToChecked ( ) ) { <nl> found_options_object = true ; <nl> options . execution = ExecutionType : : kAsync ; <nl> } <nl> GCOptions Parse ( v8 : : Isolate * isolate , v8 : : Local < v8 : : Context > ctx , <nl> : v8 : : Isolate : : GarbageCollectionType : : kFullGarbageCollection ; <nl> } <nl> <nl> - return options ; <nl> + return Just < GCOptions > ( options ) ; <nl> } <nl> <nl> void InvokeGC ( v8 : : Isolate * isolate , v8 : : Isolate : : GarbageCollectionType type , <nl> void GCExtension : : GC ( const v8 : : FunctionCallbackInfo < v8 : : Value > & args ) { <nl> v8 : : HandleScope scope ( isolate ) ; <nl> auto ctx = isolate - > GetCurrentContext ( ) ; <nl> <nl> - auto options = Parse ( isolate , ctx , args ) ; <nl> + auto maybe_options = Parse ( isolate , ctx , args ) ; <nl> + if ( maybe_options . IsNothing ( ) ) return ; <nl> + GCOptions options = maybe_options . ToChecked ( ) ; <nl> switch ( options . execution ) { <nl> case ExecutionType : : kSync : <nl> InvokeGC ( isolate , options . type , <nl> new file mode 100644 <nl> index 00000000000 . . 2acaf73debf <nl> mmm / dev / null <nl> ppp b / test / mjsunit / regress / regress - 1002827 . js <nl> <nl> + / / Copyright 2019 the V8 project authors . All rights reserved . <nl> + / / Use of this source code is governed by a BSD - style license that can be <nl> + / / found in the LICENSE file . <nl> + <nl> + / / Flags : - - allow - natives - syntax - - expose - gc <nl> + <nl> + var PI = new Proxy ( this , { <nl> + get ( ) { <nl> + PI ( ) ; <nl> + } <nl> + } ) ; <nl> + <nl> + assertThrows ( ( ) = > new gc ( PI , { } ) , TypeError ) ; <nl> new file mode 100644 <nl> index 00000000000 . . 597b42057d8 <nl> mmm / dev / null <nl> ppp b / test / mjsunit / regress / regress - 1006640 . js <nl> <nl> + / / Copyright 2019 the V8 project authors . All rights reserved . <nl> + / / Use of this source code is governed by a BSD - style license that can be <nl> + / / found in the LICENSE file . <nl> + <nl> + / / Flags : - - expose - gc <nl> + <nl> + function main ( ) { <nl> + const v2 = [ 1337 , 1337 , 1337 , 1337 , 1337 ] ; <nl> + function v9 ( ) { <nl> + const v15 = { get : RegExp } ; <nl> + Object . defineProperty ( v2 , 501 , v15 ) ; <nl> + const v18 = RegExp ( ) ; <nl> + const v19 = 1337 instanceof v18 ; <nl> + } <nl> + const v30 = { defineProperty : Function , get : v9 , getPrototypeOf : Object } ; <nl> + const v32 = new Proxy ( ArrayBuffer , v30 ) ; <nl> + const v34 = gc ( v32 ) ; <nl> + } <nl> + <nl> + assertThrows ( ( ) = > main ( ) , TypeError ) ; <nl>
GCExtension : Properly support exceptions
v8/v8
38c901614e925e35358ec01c959ac2d16b94d94b
2019-10-02T12:14:02Z
mmm a / hphp / runtime / vm / jit / alias - analysis . cpp <nl> ppp b / hphp / runtime / vm / jit / alias - analysis . cpp <nl> <nl> # include < utility > <nl> # include < sstream > <nl> <nl> + # include " hphp / util / bitset - utils . h " <nl> # include " hphp / util / match . h " <nl> # include " hphp / runtime / base / perf - warning . h " <nl> # include " hphp / runtime / vm / jit / ir - unit . h " <nl> ALocBits AliasAnalysis : : may_alias ( AliasClass acls ) const { <nl> <nl> ret | = may_alias_part ( * this , acls , acls . prop ( ) , APropAny , all_props ) ; <nl> ret | = may_alias_part ( * this , acls , acls . elemI ( ) , AElemIAny , all_elemIs ) ; <nl> + ret | = may_alias_part ( * this , acls , acls . elemS ( ) , AElemSAny , all_elemSs ) ; <nl> ret | = may_alias_part ( * this , acls , acls . ref ( ) , ARefAny , all_ref ) ; <nl> ret | = may_alias_part ( * this , acls , acls . iterPos ( ) , AIterPosAny , all_iterPos ) ; <nl> ret | = may_alias_part ( * this , acls , acls . iterBase ( ) , AIterBaseAny , <nl> ALocBits AliasAnalysis : : expand ( AliasClass acls ) const { <nl> <nl> ret | = expand_part ( * this , acls , acls . prop ( ) , APropAny , all_props ) ; <nl> ret | = expand_part ( * this , acls , acls . elemI ( ) , AElemIAny , all_elemIs ) ; <nl> + ret | = expand_part ( * this , acls , acls . elemS ( ) , AElemSAny , all_elemSs ) ; <nl> ret | = expand_part ( * this , acls , acls . ref ( ) , ARefAny , all_ref ) ; <nl> ret | = expand_part ( * this , acls , acls . iterPos ( ) , AIterPosAny , all_iterPos ) ; <nl> ret | = expand_part ( * this , acls , acls . iterBase ( ) , AIterBaseAny , all_iterBase ) ; <nl> AliasAnalysis collect_aliases ( const IRUnit & unit , const BlockList & blocks ) { <nl> * / <nl> auto conflict_prop_offset = jit : : fast_map < uint32_t , ALocBits > { } ; <nl> auto conflict_array_index = jit : : fast_map < int64_t , ALocBits > { } ; <nl> + auto conflict_array_key = jit : : fast_map < const StringData * , ALocBits > { } ; <nl> + auto prop_array_map = jit : : fast_map < int64_t , AliasClass > { } ; <nl> <nl> visit_locations ( blocks , [ & ] ( AliasClass acls ) { <nl> if ( auto const prop = acls . is_prop ( ) ) { <nl> if ( auto const index = add_class ( ret , acls ) ) { <nl> conflict_prop_offset [ prop - > offset ] . set ( * index ) ; <nl> + prop_array_map . emplace ( * index , acls ) ; <nl> } <nl> return ; <nl> } <nl> AliasAnalysis collect_aliases ( const IRUnit & unit , const BlockList & blocks ) { <nl> if ( auto const elemI = acls . is_elemI ( ) ) { <nl> if ( auto const index = add_class ( ret , acls ) ) { <nl> conflict_array_index [ elemI - > idx ] . set ( * index ) ; <nl> + prop_array_map . emplace ( * index , acls ) ; <nl> + } <nl> + return ; <nl> + } <nl> + <nl> + if ( auto const elemS = acls . is_elemS ( ) ) { <nl> + if ( auto const index = add_class ( ret , acls ) ) { <nl> + conflict_array_key [ elemS - > key ] . set ( * index ) ; <nl> + prop_array_map . emplace ( * index , acls ) ; <nl> } <nl> return ; <nl> } <nl> AliasAnalysis collect_aliases ( const IRUnit & unit , const BlockList & blocks ) { <nl> FTRACE ( 1 , " max locations limit was reached \ n " ) ; <nl> } <nl> <nl> + auto const maybe_set_conflicts = <nl> + [ & ] ( ALocBits conflicts , ALocMeta & meta , const AliasClass & acls ) { <nl> + bitset_for_each_set ( <nl> + conflicts , <nl> + [ & ] ( size_t i ) { <nl> + auto const other_acls = folly : : get_ptr ( prop_array_map , i ) ; <nl> + assertx ( other_acls ) ; <nl> + if ( i ! = meta . index & & acls . maybe ( * other_acls ) ) { <nl> + meta . conflicts . set ( i ) ; <nl> + } <nl> + } <nl> + ) ; <nl> + } ; <nl> + <nl> auto make_conflict_set = [ & ] ( AliasClass acls , ALocMeta & meta ) { <nl> if ( auto const prop = acls . is_prop ( ) ) { <nl> - meta . conflicts = conflict_prop_offset [ prop - > offset ] ; <nl> - meta . conflicts . reset ( meta . index ) ; <nl> + maybe_set_conflicts ( conflict_prop_offset [ prop - > offset ] , meta , acls ) ; <nl> ret . all_props . set ( meta . index ) ; <nl> return ; <nl> } <nl> <nl> if ( auto const elemI = acls . is_elemI ( ) ) { <nl> - meta . conflicts = conflict_array_index [ elemI - > idx ] ; <nl> - meta . conflicts . reset ( meta . index ) ; <nl> + maybe_set_conflicts ( conflict_array_index [ elemI - > idx ] , meta , acls ) ; <nl> ret . all_elemIs . set ( meta . index ) ; <nl> return ; <nl> } <nl> <nl> + if ( auto const elemS = acls . is_elemS ( ) ) { <nl> + maybe_set_conflicts ( conflict_array_key [ elemS - > key ] , meta , acls ) ; <nl> + ret . all_elemSs . set ( meta . index ) ; <nl> + return ; <nl> + } <nl> + <nl> if ( auto const frame = acls . is_frame ( ) ) { <nl> ret . all_frame . set ( meta . index ) ; <nl> return ; <nl> std : : string show ( const AliasAnalysis & ainfo ) { <nl> " { : < 20 } : { } \ n " <nl> " { : < 20 } : { } \ n " <nl> " { : < 20 } : { } \ n " <nl> + " { : < 20 } : { } \ n " <nl> " { : < 20 } : { } \ n " , <nl> <nl> " all props " , show ( ainfo . all_props ) , <nl> " all elemIs " , show ( ainfo . all_elemIs ) , <nl> + " all elemSs " , show ( ainfo . all_elemSs ) , <nl> " all refs " , show ( ainfo . all_ref ) , <nl> " all iterPos " , show ( ainfo . all_iterPos ) , <nl> " all iterBase " , show ( ainfo . all_iterBase ) , <nl> mmm a / hphp / runtime / vm / jit / alias - analysis . h <nl> ppp b / hphp / runtime / vm / jit / alias - analysis . h <nl> struct AliasAnalysis { <nl> * / <nl> ALocBits all_props ; <nl> ALocBits all_elemIs ; <nl> + ALocBits all_elemSs ; <nl> ALocBits all_frame ; <nl> ALocBits all_stack ; <nl> ALocBits all_clsRefClsSlot ; <nl> mmm a / hphp / runtime / vm / jit / alias - class . cpp <nl> ppp b / hphp / runtime / vm / jit / alias - class . cpp <nl> bool AliasClass : : maybeData ( AliasClass o ) const { <nl> * We can ' t tell if two objects could be the same from here in general , but <nl> * we can rule out simple cases based on type . The props can ' t be the same <nl> * if they are at different offsets , though . <nl> - * <nl> - * For now we ' re ignoring the type information , and only using offset . <nl> - * TODO ( # 2939547 ) TODO ( # 2884927 ) <nl> * / <nl> if ( m_prop . offset ! = o . m_prop . offset ) return false ; <nl> + if ( ! m_prop . obj - > type ( ) . maybe ( o . m_prop . obj - > type ( ) ) ) return false ; <nl> return true ; <nl> <nl> / * <nl> bool AliasClass : : maybeData ( AliasClass o ) const { <nl> * / <nl> case STag : : ElemI : <nl> if ( m_elemI . idx ! = o . m_elemI . idx ) return false ; <nl> + if ( ! m_elemI . arr - > type ( ) . maybe ( o . m_elemI . arr - > type ( ) ) ) return false ; <nl> return true ; <nl> case STag : : ElemS : <nl> if ( m_elemS . key ! = o . m_elemS . key ) return false ; <nl> + if ( ! m_elemS . arr - > type ( ) . maybe ( o . m_elemS . arr - > type ( ) ) ) return false ; <nl> return true ; <nl> <nl> case STag : : Stack : <nl>
Improve may_alias analysis for AProp and AElem *
facebook/hhvm
2c2538a350952011e3ff624bfdde0aa5ff32f610
2019-05-06T17:59:43Z
mmm a / modules / videoio / src / cap_mjpeg_encoder . cpp <nl> ppp b / modules / videoio / src / cap_mjpeg_encoder . cpp <nl> class MotionJpegWriter : public IVideoWriter <nl> strm . putInt ( height ) ; <nl> strm . putShort ( 1 ) ; / / planes ( 1 means interleaved data ( after decompression ) ) <nl> <nl> - strm . putShort ( channels ) ; / / bits per pixel <nl> + strm . putShort ( 8 * channels ) ; / / bits per pixel <nl> strm . putInt ( fourCC ( ' M ' , ' J ' , ' P ' , ' G ' ) ) ; <nl> strm . putInt ( width * height * channels ) ; <nl> strm . putInt ( 0 ) ; <nl>
Change the value of bit / pixel from channels to 8 * channels because videos encoded
opencv/opencv
a41d877fe6c7229e27d331fcc514150fd836bd73
2017-02-21T17:15:40Z
mmm a / third_party / mlir / include / mlir / LLVMIR / LLVMOps . td <nl> ppp b / third_party / mlir / include / mlir / LLVMIR / LLVMOps . td <nl> def LLVM_AllocaOp : <nl> $ res = alloca ; <nl> } ] ; <nl> let builders = [ OpBuilder < <nl> - " Builder * b , OperationState * result , Type resultType , Value * arraySize , " <nl> - " unsigned alignment = 0 " , <nl> + " Builder * b , OperationState * result , Type resultType , Value * arraySize , " <nl> + " unsigned alignment " , <nl> [ { <nl> - if ( ! alignment ) <nl> + if ( alignment = = 0 ) <nl> return build ( b , result , resultType , arraySize , IntegerAttr ( ) ) ; <nl> - auto * ctx = resultType . getContext ( ) ; <nl> - auto align = IntegerAttr : : get ( IntegerType : : get ( 64 , ctx ) , alignment ) ; <nl> - build ( b , result , resultType , arraySize , align ) ; <nl> + build ( b , result , resultType , arraySize , b - > getI64IntegerAttr ( alignment ) ) ; <nl> } ] > ] ; <nl> let parser = [ { return parseAllocaOp ( parser , result ) ; } ] ; <nl> let printer = [ { printAllocaOp ( p , * this ) ; } ] ; <nl> def LLVM_GEPOp : LLVM_OneResultOp < " getelementptr " , [ NoSideEffect ] > , <nl> } <nl> def LLVM_LoadOp : LLVM_OneResultOp < " load " > , Arguments < ( ins LLVM_Type : $ addr ) > , <nl> LLVM_Builder < " $ res = builder . CreateLoad ( $ addr ) ; " > { <nl> + let builders = [ OpBuilder < <nl> + " Builder * b , OperationState * result , Value * addr " , <nl> + [ { <nl> + auto type = addr - > getType ( ) . cast < LLVM : : LLVMType > ( ) . getPointerElementTy ( ) ; <nl> + build ( b , result , type , addr ) ; <nl> + } ] > ] ; <nl> let parser = [ { return parseLoadOp ( parser , result ) ; } ] ; <nl> let printer = [ { printLoadOp ( p , * this ) ; } ] ; <nl> } <nl> def LLVM_InsertValueOp : LLVM_OneResultOp < " insertvalue " , [ NoSideEffect ] > , <nl> $ res = builder . CreateInsertValue ( $ container , $ value , <nl> extractPosition ( $ position ) ) ; <nl> } ] ; <nl> + let builders = [ OpBuilder < <nl> + " Builder * b , OperationState * result , Value * container , Value * value , " <nl> + " ArrayAttr position " , <nl> + [ { <nl> + build ( b , result , container - > getType ( ) , container , value , position ) ; <nl> + } ] > ] ; <nl> let parser = [ { return parseInsertValueOp ( parser , result ) ; } ] ; <nl> let printer = [ { printInsertValueOp ( p , * this ) ; } ] ; <nl> } <nl> mmm a / third_party / mlir / include / mlir / Linalg / IR / LinalgBase . td <nl> ppp b / third_party / mlir / include / mlir / Linalg / IR / LinalgBase . td <nl> include " mlir / IR / OpBase . td " <nl> <nl> def Linalg_Dialect : Dialect { <nl> let name = " linalg " ; <nl> + let description = [ { <nl> + The Linalg dialect groups together a set of types and operations that are <nl> + useful to implement a " linear algebra " - like abstraction where ops can lower <nl> + to scalar load / store and operations or to more general library calls . <nl> + <nl> + The Linalg dialect adopts a convention that is similar to BLAS when <nl> + offloading operations to fast library implementations : pass a non - owning <nl> + pointer to input and output data with additional metadata . This convention <nl> + is also found in libraries such as MKL , OpenBLAS , cuBLAS , cuDNN , etc . . and <nl> + more generally at interface points across language boundaries ( e . g . C + + / <nl> + Python ) . <nl> + <nl> + Generally , Linalg passes non - owning pointers to View data structures to <nl> + precompiled library calls linked externally . <nl> + } ] ; <nl> } <nl> <nl> / / Whether a type is a BufferType . <nl> mmm a / third_party / mlir / lib / Conversion / GPUToCUDA / ConvertLaunchFuncToCudaCalls . cpp <nl> ppp b / third_party / mlir / lib / Conversion / GPUToCUDA / ConvertLaunchFuncToCudaCalls . cpp <nl> class GpuLaunchFuncToCudaCallsPass <nl> Value * allocatePointer ( OpBuilder & builder , Location loc ) { <nl> auto one = builder . create < LLVM : : ConstantOp > ( loc , getInt32Type ( ) , <nl> builder . getI32IntegerAttr ( 1 ) ) ; <nl> - return builder . create < LLVM : : AllocaOp > ( loc , getPointerPointerType ( ) , one ) ; <nl> + return builder . create < LLVM : : AllocaOp > ( loc , getPointerPointerType ( ) , one , <nl> + / * alignment = * / 0 ) ; <nl> } <nl> <nl> void declareCudaFunctions ( Location loc ) ; <nl> GpuLaunchFuncToCudaCallsPass : : setupParamsArray ( gpu : : LaunchFuncOp launchOp , <nl> auto arraySize = builder . create < LLVM : : ConstantOp > ( <nl> loc , getInt32Type ( ) , <nl> builder . getI32IntegerAttr ( launchOp . getNumKernelOperands ( ) ) ) ; <nl> - auto array = <nl> - builder . create < LLVM : : AllocaOp > ( loc , getPointerPointerType ( ) , arraySize ) ; <nl> + auto array = builder . create < LLVM : : AllocaOp > ( loc , getPointerPointerType ( ) , <nl> + arraySize , / * alignment = * / 0 ) ; <nl> for ( int idx = 0 , e = launchOp . getNumKernelOperands ( ) ; idx < e ; + + idx ) { <nl> auto operand = launchOp . getKernelOperand ( idx ) ; <nl> auto llvmType = operand - > getType ( ) . cast < LLVM : : LLVMType > ( ) ; <nl> - auto memLocation = <nl> - builder . create < LLVM : : AllocaOp > ( loc , llvmType . getPointerTo ( ) , one ) ; <nl> + auto memLocation = builder . create < LLVM : : AllocaOp > ( <nl> + loc , llvmType . getPointerTo ( ) , one , / * alignment = * / 1 ) ; <nl> builder . create < LLVM : : StoreOp > ( loc , operand , memLocation ) ; <nl> auto casted = <nl> builder . create < LLVM : : BitcastOp > ( loc , getPointerType ( ) , memLocation ) ; <nl> Value * GpuLaunchFuncToCudaCallsPass : : generateKernelNameConstant ( <nl> auto kernelNameSize = builder . create < LLVM : : ConstantOp > ( <nl> loc , getInt32Type ( ) , <nl> builder . getI32IntegerAttr ( kernelFunction . getName ( ) . size ( ) + 1 ) ) ; <nl> - auto kernelName = <nl> - builder . create < LLVM : : AllocaOp > ( loc , getPointerType ( ) , kernelNameSize ) ; <nl> + auto kernelName = builder . create < LLVM : : AllocaOp > ( <nl> + loc , getPointerType ( ) , kernelNameSize , / * alignment = * / 1 ) ; <nl> for ( auto byte : llvm : : enumerate ( kernelFunction . getName ( ) ) ) { <nl> auto index = builder . create < LLVM : : ConstantOp > ( <nl> loc , getInt32Type ( ) , builder . getI32IntegerAttr ( byte . index ( ) ) ) ; <nl> mmm a / third_party / mlir / lib / Conversion / StandardToLLVM / ConvertStandardToLLVM . cpp <nl> ppp b / third_party / mlir / lib / Conversion / StandardToLLVM / ConvertStandardToLLVM . cpp <nl> struct LoadOpLowering : public LoadStoreOpLowering < LoadOp > { <nl> <nl> Value * dataPtr = getDataPtr ( op - > getLoc ( ) , type , transformed . memref ( ) , <nl> transformed . indices ( ) , rewriter , getModule ( ) ) ; <nl> - auto elementType = lowering . convertType ( type . getElementType ( ) ) ; <nl> - <nl> - rewriter . replaceOpWithNewOp < LLVM : : LoadOp > ( op , elementType , <nl> - ArrayRef < Value * > { dataPtr } ) ; <nl> + rewriter . replaceOpWithNewOp < LLVM : : LoadOp > ( op , dataPtr ) ; <nl> return matchSuccess ( ) ; <nl> } <nl> } ; <nl> mmm a / third_party / mlir / lib / Linalg / Transforms / LowerToLLVMDialect . cpp <nl> ppp b / third_party / mlir / lib / Linalg / Transforms / LowerToLLVMDialect . cpp <nl> static Type convertLinalgType ( Type t , LLVMTypeConverter & lowering ) { <nl> if ( t . isa < RangeType > ( ) ) <nl> return LLVMType : : getStructTy ( int64Ty , int64Ty , int64Ty ) ; <nl> <nl> - / / View descriptor contains the pointer to the data buffer , followed by a <nl> - / / 64 - bit integer containing the distance between the beginning of the buffer <nl> - / / and the first element to be accessed through the view , followed by two <nl> - / / arrays , each containing as many 64 - bit integers as the rank of the View . <nl> - / / The first array represents the size , in number of original elements , of the <nl> - / / view along the given dimension . When taking the view , the size is the <nl> - / / difference between the upper and the lower bound of the range . The second <nl> - / / array represents the " stride " ( in tensor abstraction sense ) , i . e . the <nl> - / / number of consecutive elements of the underlying buffer that separate two <nl> - / / consecutive elements addressable through the view along the given <nl> - / / dimension . When taking the view , the strides are constructed as products <nl> - / / of the original sizes along the trailing dimensions , multiplied by the view <nl> - / / step . For example , a view of a MxN memref with ranges { 0 : M : 1 } , { 0 : N : 1 } , <nl> - / / i . e . the view of a complete memref , will have strides N and 1 . A view with <nl> - / / ranges { 0 : M : 2 } , { 0 : N : 3 } will have strides 2 * N and 3 . <nl> + / / A linalg . view type converts to a * pointer to * a view descriptor . The view <nl> + / / descriptor contains the pointer to the data buffer , followed by a 64 - bit <nl> + / / integer containing the distance between the beginning of the buffer and the <nl> + / / first element to be accessed through the view , followed by two arrays , each <nl> + / / containing as many 64 - bit integers as the rank of the View . The first array <nl> + / / represents the size , in number of original elements , of the view along the <nl> + / / given dimension . When taking the view , the size is the difference between <nl> + / / the upper and the lower bound of the range . The second array represents the <nl> + / / " stride " ( in tensor abstraction sense ) , i . e . the number of consecutive <nl> + / / elements of the underlying buffer that separate two consecutive elements <nl> + / / addressable through the view along the given dimension . When taking the <nl> + / / view , the strides are constructed as products of the original sizes along <nl> + / / the trailing dimensions , multiplied by the view step . For example , a view <nl> + / / of a MxN memref with ranges { 0 : M : 1 } , { 0 : N : 1 } , i . e . the view of a complete <nl> + / / memref , will have strides N and 1 . A view with ranges { 0 : M : 2 } , { 0 : N : 3 } <nl> + / / will have strides 2 * N and 3 . <nl> / / <nl> / / template < typename Elem , size_t Rank > <nl> / / struct { <nl> static Type convertLinalgType ( Type t , LLVMTypeConverter & lowering ) { <nl> / / int64_t offset ; <nl> / / int64_t sizes [ Rank ] ; <nl> / / int64_t strides [ Rank ] ; <nl> - / / } ; <nl> + / / } * ; <nl> if ( auto viewType = t . dyn_cast < ViewType > ( ) ) { <nl> auto ptrTy = getPtrToElementType ( viewType , lowering ) ; <nl> auto arrayTy = LLVMType : : getArrayTy ( int64Ty , viewType . getRank ( ) ) ; <nl> - return LLVMType : : getStructTy ( ptrTy , int64Ty , arrayTy , arrayTy ) ; <nl> + return LLVMType : : getStructTy ( ptrTy , int64Ty , arrayTy , arrayTy ) <nl> + . getPointerTo ( ) ; <nl> } <nl> <nl> return Type ( ) ; <nl> } <nl> <nl> + static constexpr int kPtrPosInBuffer = 0 ; <nl> + static constexpr int kSizePosInBuffer = 1 ; <nl> + static constexpr int kPtrPosInView = 0 ; <nl> + static constexpr int kOffsetPosInView = 1 ; <nl> + static constexpr int kSizePosInView = 2 ; <nl> + static constexpr int kStridePosInView = 3 ; <nl> + <nl> / / Create an array attribute containing integer attributes with values provided <nl> / / in ` position ` . <nl> static ArrayAttr positionAttr ( Builder & builder , ArrayRef < int > position ) { <nl> class BufferAllocOpConversion : public LLVMOpLowering { <nl> llvm : : divideCeil ( vectorType . getElementTypeBitWidth ( ) , 8 ) ; <nl> else <nl> elementSize = llvm : : divideCeil ( elementType . getIntOrFloatBitWidth ( ) , 8 ) ; <nl> - auto bufferType = allocOp . getResult ( ) - > getType ( ) . cast < BufferType > ( ) ; <nl> + auto bufferType = allocOp . getBufferType ( ) ; <nl> auto elementPtrType = getPtrToElementType ( bufferType , lowering ) ; <nl> - auto bufferDescriptorType = <nl> - convertLinalgType ( allocOp . getResult ( ) - > getType ( ) , lowering ) ; <nl> + auto bufferDescriptorTy = convertLinalgType ( bufferType , lowering ) ; <nl> <nl> / / Emit IR for creating a new buffer descriptor with an underlying malloc . <nl> edsc : : ScopedContext context ( rewriter , op - > getLoc ( ) ) ; <nl> class BufferAllocOpConversion : public LLVMOpLowering { <nl> . getOperation ( ) <nl> - > getResult ( 0 ) ; <nl> allocated = bitcast ( elementPtrType , allocated ) ; <nl> - Value * desc = undef ( bufferDescriptorType ) ; <nl> - desc = insertvalue ( bufferDescriptorType , desc , allocated , <nl> - positionAttr ( rewriter , 0 ) ) ; <nl> - desc = insertvalue ( bufferDescriptorType , desc , size , <nl> - positionAttr ( rewriter , 1 ) ) ; <nl> + Value * desc = undef ( bufferDescriptorTy ) ; <nl> + desc = insertvalue ( bufferDescriptorTy , desc , allocated , <nl> + positionAttr ( rewriter , kPtrPosInBuffer ) ) ; <nl> + desc = insertvalue ( bufferDescriptorTy , desc , size , <nl> + positionAttr ( rewriter , kSizePosInBuffer ) ) ; <nl> rewriter . replaceOp ( op , desc ) ; <nl> return matchSuccess ( ) ; <nl> } <nl> class BufferDeallocOpConversion : public LLVMOpLowering { <nl> <nl> / / Get MLIR types for extracting element pointer . <nl> auto deallocOp = cast < BufferDeallocOp > ( op ) ; <nl> - auto elementPtrTy = getPtrToElementType ( <nl> - deallocOp . getOperand ( ) - > getType ( ) . cast < BufferType > ( ) , lowering ) ; <nl> + auto elementPtrTy = <nl> + getPtrToElementType ( deallocOp . getBufferType ( ) , lowering ) ; <nl> <nl> / / Emit MLIR for buffer_dealloc . <nl> + BufferDeallocOpOperandAdaptor adaptor ( operands ) ; <nl> edsc : : ScopedContext context ( rewriter , op - > getLoc ( ) ) ; <nl> - Value * casted = bitcast ( voidPtrTy , extractvalue ( elementPtrTy , operands [ 0 ] , <nl> - positionAttr ( rewriter , 0 ) ) ) ; <nl> + Value * casted = <nl> + bitcast ( voidPtrTy , extractvalue ( elementPtrTy , adaptor . buffer ( ) , <nl> + positionAttr ( rewriter , 0 ) ) ) ; <nl> llvm_call ( ArrayRef < Type > ( ) , rewriter . getSymbolRefAttr ( freeFunc ) , casted ) ; <nl> rewriter . replaceOp ( op , llvm : : None ) ; <nl> return matchSuccess ( ) ; <nl> class BufferSizeOpConversion : public LLVMOpLowering { <nl> ConversionPatternRewriter & rewriter ) const override { <nl> auto int64Ty = lowering . convertType ( rewriter . getIntegerType ( 64 ) ) ; <nl> edsc : : ScopedContext context ( rewriter , op - > getLoc ( ) ) ; <nl> + BufferSizeOpOperandAdaptor adaptor ( operands ) ; <nl> rewriter . replaceOp ( <nl> - op , { extractvalue ( int64Ty , operands [ 0 ] , positionAttr ( rewriter , 1 ) ) } ) ; <nl> + op , { extractvalue ( int64Ty , adaptor . buffer ( ) , <nl> + positionAttr ( rewriter , kSizePosInBuffer ) ) } ) ; <nl> return matchSuccess ( ) ; <nl> } <nl> } ; <nl> class DimOpConversion : public LLVMOpLowering { <nl> auto dimOp = cast < linalg : : DimOp > ( op ) ; <nl> auto indexTy = lowering . convertType ( rewriter . getIndexType ( ) ) ; <nl> edsc : : ScopedContext context ( rewriter , op - > getLoc ( ) ) ; <nl> - rewriter . replaceOp ( <nl> - op , <nl> - { extractvalue ( <nl> - indexTy , operands [ 0 ] , <nl> - positionAttr ( rewriter , { 2 , static_cast < int > ( dimOp . getIndex ( ) ) } ) ) } ) ; <nl> + auto pos = positionAttr ( <nl> + rewriter , { kSizePosInView , static_cast < int > ( dimOp . getIndex ( ) ) } ) ; <nl> + linalg : : DimOpOperandAdaptor adaptor ( operands ) ; <nl> + Value * viewDescriptor = llvm_load ( adaptor . view ( ) ) ; <nl> + rewriter . replaceOp ( op , { extractvalue ( indexTy , viewDescriptor , pos ) } ) ; <nl> return matchSuccess ( ) ; <nl> } <nl> } ; <nl> template < typename Op > class LoadStoreOpConversion : public LLVMOpLowering { <nl> / / current view indices . Use the base offset and strides stored in the view <nl> / / descriptor to emit IR iteratively computing the actual offset , followed by <nl> / / a getelementptr . This must be called under an edsc : : ScopedContext . <nl> - Value * obtainDataPtr ( Operation * op , Value * viewDescriptor , <nl> + Value * obtainDataPtr ( Operation * op , Value * viewDescriptorPtr , <nl> ArrayRef < Value * > indices , <nl> ConversionPatternRewriter & rewriter ) const { <nl> auto loadOp = cast < Op > ( op ) ; <nl> template < typename Op > class LoadStoreOpConversion : public LLVMOpLowering { <nl> <nl> / / Linearize subscripts as : <nl> / / base_offset + SUM_i index_i * stride_i . <nl> - Value * base = extractvalue ( elementTy , viewDescriptor , pos ( 0 ) ) ; <nl> - Value * offset = extractvalue ( int64Ty , viewDescriptor , pos ( 1 ) ) ; <nl> + Value * viewDescriptor = llvm_load ( viewDescriptorPtr ) ; <nl> + Value * base = extractvalue ( elementTy , viewDescriptor , pos ( kPtrPosInView ) ) ; <nl> + Value * offset = <nl> + extractvalue ( int64Ty , viewDescriptor , pos ( kOffsetPosInView ) ) ; <nl> for ( int i = 0 , e = loadOp . getRank ( ) ; i < e ; + + i ) { <nl> - Value * stride = extractvalue ( int64Ty , viewDescriptor , pos ( { 3 , i } ) ) ; <nl> + Value * stride = <nl> + extractvalue ( int64Ty , viewDescriptor , pos ( { kStridePosInView , i } ) ) ; <nl> Value * additionalOffset = mul ( indices [ i ] , stride ) ; <nl> offset = add ( offset , additionalOffset ) ; <nl> } <nl> class LoadOpConversion : public LoadStoreOpConversion < linalg : : LoadOp > { <nl> ConversionPatternRewriter & rewriter ) const override { <nl> edsc : : ScopedContext edscContext ( rewriter , op - > getLoc ( ) ) ; <nl> auto elementTy = lowering . convertType ( * op - > result_type_begin ( ) ) ; <nl> - Value * viewDescriptor = operands [ 0 ] ; <nl> - ArrayRef < Value * > indices = operands . drop_front ( ) ; <nl> - auto ptr = obtainDataPtr ( op , viewDescriptor , indices , rewriter ) ; <nl> + linalg : : LoadOpOperandAdaptor adaptor ( operands ) ; <nl> + auto ptr = obtainDataPtr ( op , adaptor . view ( ) , adaptor . indices ( ) , rewriter ) ; <nl> rewriter . replaceOp ( op , { llvm_load ( elementTy , ptr ) } ) ; <nl> return matchSuccess ( ) ; <nl> } <nl> class RangeOpConversion : public LLVMOpLowering { <nl> edsc : : ScopedContext context ( rewriter , op - > getLoc ( ) ) ; <nl> <nl> / / Fill in an aggregate value of the descriptor . <nl> + RangeOpOperandAdaptor adaptor ( operands ) ; <nl> Value * desc = undef ( rangeDescriptorTy ) ; <nl> - desc = insertvalue ( rangeDescriptorTy , desc , operands [ 0 ] , <nl> - positionAttr ( rewriter , 0 ) ) ; <nl> - desc = insertvalue ( rangeDescriptorTy , desc , operands [ 1 ] , <nl> - positionAttr ( rewriter , 1 ) ) ; <nl> - desc = insertvalue ( rangeDescriptorTy , desc , operands [ 2 ] , <nl> - positionAttr ( rewriter , 2 ) ) ; <nl> + desc = insertvalue ( desc , adaptor . min ( ) , positionAttr ( rewriter , 0 ) ) ; <nl> + desc = insertvalue ( desc , adaptor . max ( ) , positionAttr ( rewriter , 1 ) ) ; <nl> + desc = insertvalue ( desc , adaptor . step ( ) , positionAttr ( rewriter , 2 ) ) ; <nl> rewriter . replaceOp ( op , desc ) ; <nl> return matchSuccess ( ) ; <nl> } <nl> } ; <nl> <nl> + / / / Conversion pattern that transforms a linalg . slice op into : <nl> + / / / 1 . A function entry ` alloca ` operation to allocate a ViewDescriptor . <nl> + / / / 2 . A load of the ViewDescriptor from the pointer allocated in 1 . <nl> + / / / 3 . Updates to the ViewDescriptor to introduce the data ptr , offset , size <nl> + / / / and stride corresponding to the <nl> + / / / 4 . A store of the resulting ViewDescriptor to the alloca ' ed pointer . <nl> + / / / The linalg . slice op is replaced by the alloca ' ed pointer . <nl> class SliceOpConversion : public LLVMOpLowering { <nl> public : <nl> explicit SliceOpConversion ( MLIRContext * context , LLVMTypeConverter & lowering_ ) <nl> class SliceOpConversion : public LLVMOpLowering { <nl> ConversionPatternRewriter & rewriter ) const override { <nl> SliceOpOperandAdaptor adaptor ( operands ) ; <nl> auto sliceOp = cast < SliceOp > ( op ) ; <nl> - auto viewDescriptorTy = convertLinalgType ( sliceOp . getViewType ( ) , lowering ) ; <nl> + auto viewDescriptorPtrTy = <nl> + convertLinalgType ( sliceOp . getViewType ( ) , lowering ) ; <nl> auto viewType = sliceOp . getBaseViewType ( ) ; <nl> auto int64Ty = lowering . convertType ( rewriter . getIntegerType ( 64 ) ) ; <nl> <nl> class SliceOpConversion : public LLVMOpLowering { <nl> auto pos = [ & rewriter ] ( ArrayRef < int > values ) { <nl> return positionAttr ( rewriter , values ) ; <nl> } ; <nl> - / / Helper function to obtain the ptr of the given ` view ` . <nl> - auto getViewPtr = [ pos , this ] ( ViewType type , Value * view ) - > Value * { <nl> - auto elementPtrTy = getPtrToElementType ( type , lowering ) ; <nl> - return extractvalue ( elementPtrTy , view , pos ( 0 ) ) ; <nl> - } ; <nl> <nl> edsc : : ScopedContext context ( rewriter , op - > getLoc ( ) ) ; <nl> - / / Declare the view descriptor and insert data ptr . <nl> - Value * desc = undef ( viewDescriptorTy ) ; <nl> - desc = insertvalue ( viewDescriptorTy , desc , <nl> - getViewPtr ( viewType , adaptor . view ( ) ) , pos ( 0 ) ) ; <nl> + / / Declare the view descriptor and insert data ptr * at the entry block of <nl> + / / the function * , which is the preferred location for LLVM ' s analyses . <nl> + auto ip = rewriter . getInsertionPoint ( ) ; <nl> + auto ib = rewriter . getInsertionBlock ( ) ; <nl> + rewriter . setInsertionPointToStart ( <nl> + & op - > getParentOfType < FuncOp > ( ) . getBlocks ( ) . front ( ) ) ; <nl> + Value * one = <nl> + constant ( int64Ty , rewriter . getIntegerAttr ( rewriter . getIndexType ( ) , 1 ) ) ; <nl> + / / Alloca with proper alignment . <nl> + Value * allocatedDesc = <nl> + llvm_alloca ( viewDescriptorPtrTy , one , / * alignment = * / 8 ) ; <nl> + Value * desc = llvm_load ( allocatedDesc ) ; <nl> + rewriter . setInsertionPoint ( ib , ip ) ; <nl> + <nl> + Value * baseDesc = llvm_load ( adaptor . view ( ) ) ; <nl> + <nl> + auto ptrPos = pos ( kPtrPosInView ) ; <nl> + auto elementTy = getPtrToElementType ( sliceOp . getViewType ( ) , lowering ) ; <nl> + desc = insertvalue ( desc , extractvalue ( elementTy , baseDesc , ptrPos ) , ptrPos ) ; <nl> <nl> / / TODO ( ntv ) : extract sizes and emit asserts . <nl> SmallVector < Value * , 4 > strides ( viewType . getRank ( ) ) ; <nl> for ( int i = 0 , e = viewType . getRank ( ) ; i < e ; + + i ) { <nl> - strides [ i ] = extractvalue ( int64Ty , adaptor . view ( ) , pos ( { 3 , i } ) ) ; <nl> + strides [ i ] = extractvalue ( int64Ty , baseDesc , pos ( { kStridePosInView , i } ) ) ; <nl> } <nl> <nl> / / Compute and insert base offset . <nl> - Value * baseOffset = extractvalue ( int64Ty , adaptor . view ( ) , pos ( 1 ) ) ; <nl> + Value * baseOffset = extractvalue ( int64Ty , baseDesc , pos ( kOffsetPosInView ) ) ; <nl> for ( int i = 0 , e = viewType . getRank ( ) ; i < e ; + + i ) { <nl> Value * indexing = adaptor . indexings ( ) [ i ] ; <nl> Value * min = <nl> class SliceOpConversion : public LLVMOpLowering { <nl> Value * product = mul ( min , strides [ i ] ) ; <nl> baseOffset = add ( baseOffset , product ) ; <nl> } <nl> - desc = insertvalue ( viewDescriptorTy , desc , baseOffset , pos ( 1 ) ) ; <nl> + desc = insertvalue ( desc , baseOffset , pos ( kOffsetPosInView ) ) ; <nl> <nl> / / Compute and insert view sizes ( max - min along the range ) and strides . <nl> / / Skip the non - range operands as they will be projected away from the view . <nl> class SliceOpConversion : public LLVMOpLowering { <nl> Value * step = extractvalue ( int64Ty , rangeDescriptor , pos ( 2 ) ) ; <nl> Value * size = sub ( max , min ) ; <nl> Value * stride = mul ( strides [ i ] , step ) ; <nl> - desc = insertvalue ( viewDescriptorTy , desc , size , pos ( { 2 , numNewDims } ) ) ; <nl> - desc = <nl> - insertvalue ( viewDescriptorTy , desc , stride , pos ( { 3 , numNewDims } ) ) ; <nl> + desc = insertvalue ( desc , size , pos ( { kSizePosInView , numNewDims } ) ) ; <nl> + desc = insertvalue ( desc , stride , pos ( { kStridePosInView , numNewDims } ) ) ; <nl> + + numNewDims ; <nl> } <nl> } <nl> <nl> - rewriter . replaceOp ( op , desc ) ; <nl> + / / Store back in alloca ' ed region . <nl> + llvm_store ( desc , allocatedDesc ) ; <nl> + rewriter . replaceOp ( op , allocatedDesc ) ; <nl> return matchSuccess ( ) ; <nl> } <nl> } ; <nl> class StoreOpConversion : public LoadStoreOpConversion < linalg : : StoreOp > { <nl> matchAndRewrite ( Operation * op , ArrayRef < Value * > operands , <nl> ConversionPatternRewriter & rewriter ) const override { <nl> edsc : : ScopedContext edscContext ( rewriter , op - > getLoc ( ) ) ; <nl> - Value * data = operands [ 0 ] ; <nl> - Value * viewDescriptor = operands [ 1 ] ; <nl> - ArrayRef < Value * > indices = operands . drop_front ( 2 ) ; <nl> - Value * ptr = obtainDataPtr ( op , viewDescriptor , indices , rewriter ) ; <nl> - llvm_store ( data , ptr ) ; <nl> + linalg : : StoreOpOperandAdaptor adaptor ( operands ) ; <nl> + Value * ptr = obtainDataPtr ( op , adaptor . view ( ) , adaptor . indices ( ) , rewriter ) ; <nl> + llvm_store ( adaptor . value ( ) , ptr ) ; <nl> rewriter . replaceOp ( op , llvm : : None ) ; <nl> return matchSuccess ( ) ; <nl> } <nl> } ; <nl> <nl> + / / / Conversion pattern that transforms a linalg . view op into : <nl> + / / / 1 . A function entry ` alloca ` operation to allocate a ViewDescriptor . <nl> + / / / 2 . A load of the ViewDescriptor from the pointer allocated in 1 . <nl> + / / / 3 . Updates to the ViewDescriptor to introduce the data ptr , offset , size <nl> + / / / and stride . <nl> + / / / 4 . A store of the resulting ViewDescriptor to the alloca ' ed pointer . <nl> + / / / The linalg . view op is replaced by the alloca ' ed pointer . <nl> class ViewOpConversion : public LLVMOpLowering { <nl> public : <nl> explicit ViewOpConversion ( MLIRContext * context , LLVMTypeConverter & lowering_ ) <nl> class ViewOpConversion : public LLVMOpLowering { <nl> matchAndRewrite ( Operation * op , ArrayRef < Value * > operands , <nl> ConversionPatternRewriter & rewriter ) const override { <nl> auto viewOp = cast < ViewOp > ( op ) ; <nl> - auto viewDescriptorTy = convertLinalgType ( viewOp . getViewType ( ) , lowering ) ; <nl> + ViewOpOperandAdaptor adaptor ( operands ) ; <nl> + auto viewDescriptorPtrTy = <nl> + convertLinalgType ( viewOp . getViewType ( ) , lowering ) ; <nl> auto elementTy = getPtrToElementType ( viewOp . getViewType ( ) , lowering ) ; <nl> auto int64Ty = lowering . convertType ( rewriter . getIntegerType ( 64 ) ) ; <nl> <nl> class ViewOpConversion : public LLVMOpLowering { <nl> return positionAttr ( rewriter , values ) ; <nl> } ; <nl> <nl> - / / First operand to ` view ` is the buffer descriptor . <nl> - Value * bufferDescriptor = operands [ 0 ] ; <nl> + Value * bufferDescriptor = adaptor . buffer ( ) ; <nl> + auto bufferTy = getPtrToElementType ( <nl> + viewOp . buffer ( ) - > getType ( ) . cast < BufferType > ( ) , lowering ) ; <nl> <nl> / / Declare the descriptor of the view . <nl> edsc : : ScopedContext context ( rewriter , op - > getLoc ( ) ) ; <nl> - Value * desc = undef ( viewDescriptorTy ) ; <nl> + auto ip = rewriter . getInsertionPoint ( ) ; <nl> + auto ib = rewriter . getInsertionBlock ( ) ; <nl> + rewriter . setInsertionPointToStart ( <nl> + & op - > getParentOfType < FuncOp > ( ) . getBlocks ( ) . front ( ) ) ; <nl> + Value * one = <nl> + constant ( int64Ty , rewriter . getIntegerAttr ( rewriter . getIndexType ( ) , 1 ) ) ; <nl> + / / Alloca for proper alignment . <nl> + Value * allocatedDesc = <nl> + llvm_alloca ( viewDescriptorPtrTy , one , / * alignment = * / 8 ) ; <nl> + Value * desc = llvm_load ( allocatedDesc ) ; <nl> + rewriter . setInsertionPoint ( ib , ip ) ; <nl> <nl> / / Copy the buffer pointer from the old descriptor to the new one . <nl> - Value * buffer = extractvalue ( elementTy , bufferDescriptor , pos ( 0 ) ) ; <nl> - desc = insertvalue ( viewDescriptorTy , desc , buffer , pos ( 0 ) ) ; <nl> + Value * bufferAsViewElementType = <nl> + bitcast ( elementTy , <nl> + extractvalue ( bufferTy , bufferDescriptor , pos ( kPtrPosInBuffer ) ) ) ; <nl> + desc = insertvalue ( desc , bufferAsViewElementType , pos ( kPtrPosInView ) ) ; <nl> <nl> / / Zero base offset . <nl> auto indexTy = rewriter . getIndexType ( ) ; <nl> Value * baseOffset = constant ( int64Ty , IntegerAttr : : get ( indexTy , 0 ) ) ; <nl> - desc = insertvalue ( viewDescriptorTy , desc , baseOffset , pos ( 1 ) ) ; <nl> + desc = insertvalue ( desc , baseOffset , pos ( kOffsetPosInView ) ) ; <nl> <nl> / / Compute and insert view sizes ( max - min along the range ) . <nl> int numRanges = llvm : : size ( viewOp . ranges ( ) ) ; <nl> class ViewOpConversion : public LLVMOpLowering { <nl> Value * rangeDescriptor = operands [ 1 + i ] ; <nl> Value * step = extractvalue ( int64Ty , rangeDescriptor , pos ( 2 ) ) ; <nl> Value * stride = mul ( runningStride , step ) ; <nl> - desc = insertvalue ( viewDescriptorTy , desc , stride , pos ( { 3 , i } ) ) ; <nl> + desc = insertvalue ( desc , stride , pos ( { kStridePosInView , i } ) ) ; <nl> / / Update size . <nl> Value * min = extractvalue ( int64Ty , rangeDescriptor , pos ( 0 ) ) ; <nl> Value * max = extractvalue ( int64Ty , rangeDescriptor , pos ( 1 ) ) ; <nl> Value * size = sub ( max , min ) ; <nl> - desc = insertvalue ( viewDescriptorTy , desc , size , pos ( { 2 , i } ) ) ; <nl> + desc = insertvalue ( desc , size , pos ( { kSizePosInView , i } ) ) ; <nl> / / Update stride for the next dimension . <nl> if ( i > 0 ) <nl> runningStride = mul ( runningStride , max ) ; <nl> } <nl> <nl> - rewriter . replaceOp ( op , desc ) ; <nl> + / / Store back in alloca ' ed region . <nl> + llvm_store ( desc , allocatedDesc ) ; <nl> + rewriter . replaceOp ( op , allocatedDesc ) ; <nl> return matchSuccess ( ) ; <nl> } <nl> } ; <nl> getLLVMLibraryCallDeclaration ( Operation * op , LLVMTypeConverter & lowering , <nl> return libFn ; <nl> } <nl> <nl> - static void getLLVMLibraryCallDefinition ( FuncOp fn , <nl> - LLVMTypeConverter & lowering ) { <nl> - / / Generate the implementation function definition . <nl> - auto implFn = getLLVMLibraryCallImplDefinition ( fn ) ; <nl> - <nl> - / / Generate the function body . <nl> - OpBuilder builder ( fn . addEntryBlock ( ) ) ; <nl> - edsc : : ScopedContext scope ( builder , fn . getLoc ( ) ) ; <nl> - SmallVector < Value * , 4 > implFnArgs ; <nl> - <nl> - / / Create a constant 1 . <nl> - auto one = constant ( LLVMType : : getInt64Ty ( lowering . getDialect ( ) ) , <nl> - IntegerAttr : : get ( IndexType : : get ( fn . getContext ( ) ) , 1 ) ) ; <nl> - for ( auto arg : fn . getArguments ( ) ) { <nl> - / / Allocate a stack for storing the argument value . The stack is passed to <nl> - / / the implementation function . <nl> - auto alloca = <nl> - llvm_alloca ( arg - > getType ( ) . cast < LLVMType > ( ) . getPointerTo ( ) , one ) <nl> - . getValue ( ) ; <nl> - implFnArgs . push_back ( alloca ) ; <nl> - llvm_store ( arg , alloca ) ; <nl> - } <nl> - llvm_call ( ArrayRef < Type > ( ) , builder . getSymbolRefAttr ( implFn ) , implFnArgs ) ; <nl> - llvm_return { ArrayRef < Value * > ( ) } ; <nl> - } <nl> - <nl> namespace { <nl> / / The conversion class from Linalg to LLVMIR . <nl> class LinalgTypeConverter : public LLVMTypeConverter { <nl> class LinalgTypeConverter : public LLVMTypeConverter { <nl> return result ; <nl> return convertLinalgType ( t , * this ) ; <nl> } <nl> - <nl> - void addLibraryFnDeclaration ( FuncOp fn ) { libraryFnDeclarations . insert ( fn ) ; } <nl> - <nl> - ArrayRef < FuncOp > getLibraryFnDeclarations ( ) { <nl> - return libraryFnDeclarations . getArrayRef ( ) ; <nl> - } <nl> - <nl> - private : <nl> - / / / List of library functions declarations needed during dialect conversion <nl> - llvm : : SetVector < FuncOp > libraryFnDeclarations ; <nl> } ; <nl> } / / end anonymous namespace <nl> <nl> template < typename LinalgOp > class LinalgOpConversion : public LLVMOpLowering { <nl> auto f = getLLVMLibraryCallDeclaration < LinalgOp > ( op , lowering , rewriter ) ; <nl> if ( ! f ) <nl> return matchFailure ( ) ; <nl> - static_cast < LinalgTypeConverter & > ( lowering ) . addLibraryFnDeclaration ( f ) ; <nl> <nl> auto fAttr = rewriter . getSymbolRefAttr ( f ) ; <nl> auto named = rewriter . getNamedAttr ( " callee " , fAttr ) ; <nl> void LowerLinalgToLLVMPass : : runOnModule ( ) { <nl> if ( failed ( applyPartialConversion ( module , target , patterns , & converter ) ) ) { <nl> signalPassFailure ( ) ; <nl> } <nl> - <nl> - / / Emit the function body of any Library function that was declared . <nl> - for ( auto fn : converter . getLibraryFnDeclarations ( ) ) { <nl> - getLLVMLibraryCallDefinition ( fn , converter ) ; <nl> - } <nl> } <nl> <nl> std : : unique_ptr < ModulePassBase > mlir : : linalg : : createLowerLinalgToLLVMPass ( ) { <nl>
Refactor linalg lowering to LLVM
tensorflow/tensorflow
9141405dcd71cf7115b20a103e675471d3e3de39
2019-08-19T17:35:58Z
mmm a / tensorflow / python / ops / nn_ops . py <nl> ppp b / tensorflow / python / ops / nn_ops . py <nl> def conv2d_transpose_v2 ( <nl> input : A 4 - D ` Tensor ` of type ` float ` and shape ` [ batch , height , width , <nl> in_channels ] ` for ` NHWC ` data format or ` [ batch , in_channels , height , <nl> width ] ` for ` NCHW ` data format . <nl> - filters : A 4 - D ` Tensor ` with the same type as ` value ` and shape ` [ height , <nl> + filters : A 4 - D ` Tensor ` with the same type as ` input ` and shape ` [ height , <nl> width , output_channels , in_channels ] ` . ` filter ` ' s ` in_channels ` dimension <nl> - must match that of ` value ` . <nl> + must match that of ` input ` . <nl> output_shape : A 1 - D ` Tensor ` representing the output shape of the <nl> deconvolution op . <nl> strides : An int or list of ` ints ` that has length ` 1 ` , ` 2 ` or ` 4 ` . The <nl> def conv2d_transpose_v2 ( <nl> name : Optional name for the returned tensor . <nl> <nl> Returns : <nl> - A ` Tensor ` with the same type as ` value ` . <nl> + A ` Tensor ` with the same type as ` input ` . <nl> <nl> Raises : <nl> ValueError : If input / output depth does not match ` filter ` ' s shape , or if <nl>
Merge pull request from astropeak : fix - doc
tensorflow/tensorflow
2f67e7710637251d6d580e5c4f71d44ce825b4e0
2019-05-22T16:36:24Z
mmm a / bindings / python / cntk / ops / __init__ . py <nl> ppp b / bindings / python / cntk / ops / __init__ . py <nl> def convolution ( convolution_map , operand , strides = ( 1 , ) , sharing = [ True ] , <nl> auto_padding = [ True ] , lower_pad = ( 0 , ) , upper_pad = ( 0 , ) , transpose = False , <nl> max_temp_mem_size_in_samples = 0 , name = ' ' ) : <nl> ' ' ' <nl> - Computes the convolution of a weight matrix with an image or tensor . This operation is used in image - processing applications <nl> - and language processing . It supports any dimensions , stride , sharing or padding . <nl> + Computes the convolution of ` ` convolution_map ` ` ( typically a tensor of learnable parameters ) with <nl> + ` ` operand ` ` ( commonly an image or output of a previous convolution / pooling operation ) . <nl> + This operation is used in image and language processing applications . It supports arbitrary <nl> + dimensions , strides , sharing , and padding . <nl> <nl> - This function operates on input tensors of the form [ M1 x M2 x . . . x Mn x inChannels ] . This can be understood as a rank - n <nl> - object , where each entry consists of a inChannels - dimensional vector . For example , an RGB image would have dimensions <nl> - [ W x H x 3 ] , i . e . a [ W x H ] - sized structure , where each entry ( pixel ) consists of a 3 - tuple ( note , however , that the <nl> - memory - storage format is the concatenation of 3 planes of size [ W x H ] ) . <nl> + This function operates on input tensors with dimensions : math : ` [ C \ \ times M_1 \ \ times M_2 \ \ times \ \ ldots \ \ times M_n ] ` . This can be understood as a rank - n <nl> + object , where each entry consists of a : math : ` C ` - dimensional vector . For example , an RGB image would have dimensions <nl> + : math : ` [ 3 \ \ times W \ \ times H ] ` , i . e . a : math : ` [ W \ \ times H ] ` - sized structure , where each entry ( pixel ) consists of a 3 - tuple . <nl> <nl> - ` convolution ` convolves the input with n + 1 - dimensional filters , where the first n dimensions are the spatial extent of the <nl> - filter , and the last one must be equal to inChannels . There are outChannels filters . I . e . for each output position , a vector of <nl> - dimension outChannels is computed . Hence , the total number of filter parameters is ( M1 * M2 * . . . * Mn ) * inChannels * outChannels . <nl> + ` convolution ` convolves the input ` ` operand ` ` with a : math : ` n + 2 ` rank tensor of ( typically learnable ) filters called <nl> + ` ` convolution_map ` ` of shape : math : ` [ O \ \ times I \ \ times m_1 \ \ times m_2 \ \ times \ \ ldots \ \ times m_n ] ` ( typically : math : ` m_i \ \ ll M_i ` ) . <nl> + The first dimension , : math : ` O ` , is the nunber of convolution filters ( i . e . the number of <nl> + channels in the output ) . The second dimension , : math : ` I ` , must match the number of channels in the input . <nl> + The last n dimensions are the spatial extent of the filter . I . e . for each output position , a vector of <nl> + dimension : math : ` O ` is computed . Hence , the total number of filter parameters is : math : ` O \ \ times I \ \ times m_1 \ \ times m_2 \ \ times \ \ ldots \ \ times m_n ` <nl> <nl> <nl> Example : <nl> def convolution ( convolution_map , operand , strides = ( 1 , ) , sharing = [ True ] , <nl> [ 36 . , 38 . , 40 . , 42 . ] ] ] ] ] , dtype = float32 ) <nl> <nl> Args : <nl> - convolution_map : convolution filter weights , stored as a tensor of dimensions [ outChannels x M1 x M2 x . . . x Mn ] , <nl> - where [ M1 x M2 x . . . x Mn ] must be the kernel dimensions . <nl> - operand : convolution input . A tensor with dimensions [ M1 x M2 x . . . x Mn x inChannels ] . <nl> - strides ( optional ) : stride dimensions . A stride > 1 means that only pixel positions that are multiples of the stride value are computed . <nl> - For example , a stride of 2 will lead to a halving of the dimensions . The last stride dimension that lines up with the number <nl> - of input channels must be equal to the number of input channels . <nl> + convolution_map : convolution filter weights , stored as a tensor of dimensions : math : ` [ O \ \ times I \ \ times m_1 \ \ times m_2 \ \ times \ \ ldots \ \ times m_n ] ` , <nl> + where : math : ` [ m_1 \ \ times m_2 \ \ times \ \ ldots \ \ times m_n ] ` must be the kernel dimensions ( spatial extent of the filter ) . <nl> + operand : convolution input . A tensor with dimensions : math : ` [ I \ \ times M_1 \ \ times M_2 \ \ times \ \ ldots \ \ times M_n ] ` . <nl> + strides ( ` tuple ` , optional ) : stride dimensions . If strides [ i ] > 1 then only pixel positions that are multiples of strides [ i ] are computed . <nl> + For example , a stride of 2 will lead to a halving of that dimension . The first stride dimension that lines up with the number <nl> + of input channels can be set to any non - zero value . <nl> sharing ( bool ) : sharing flags for each input dimension <nl> auto_padding ( bool ) : flags for each input dimension whether it should be padded automatically ( that is , <nl> symmetrically ) or not padded at all . Padding means that the convolution kernel is applied to all pixel positions , where all <nl> def batch_normalization ( operand , scale , bias , running_mean , running_inv_std , spa <nl> spatial ( ` bool ` ) : flag that indicates whether to compute mean / var for each feature in a minibatch <nl> independently or , in case of convolutional layers , per future map <nl> normalization_time_constant ( ` float ` , default 5000 ) : time constant for computing running average of <nl> - mean and variance as a low - pass filtered version of the batch statistics . <nl> + mean and variance as a low - pass filtered version of the batch statistics . <nl> blend_time_constant ( ` float ` , default 0 ) : constant for smoothing batch estimates with the running <nl> statistics <nl> epsilon : conditioner constant added to the variance when computing the inverse standard deviation <nl> def random_sample ( weights , num_samples , allow_duplicates , name = ' ' ) : <nl> <nl> @ typemap <nl> def random_sample_inclusion_frequency ( <nl> - weights , <nl> - num_samples , <nl> - allow_duplicates , <nl> + weights , <nl> + num_samples , <nl> + allow_duplicates , <nl> name = ' ' ) : <nl> ' ' ' <nl> For weighted sampling with the specifed sample size ( ` num_samples ` ) <nl> this node computes the expected number of occurences of each class <nl> - in the the sampled set . In case of sampling without replacement <nl> + in the the sampled set . In case of sampling without replacement <nl> the result is only an estimate which might be quite rough in the <nl> case of small sample sizes . <nl> - Intended uses are e . g . sampled softmax , noise contrastive <nl> + Intended uses are e . g . sampled softmax , noise contrastive <nl> estimation etc . <nl> - This operation will be typically used together <nl> + This operation will be typically used together <nl> with : func : ` random_sample ` . <nl> <nl> Args : <nl> - weights : input vector of sampling weights which should be <nl> - non - negative numbers . <nl> + weights : input vector of sampling weights which should be <nl> + non - negative numbers . <nl> num_samples ( ` int ` ) : number of expected samples <nl> - allow_duplicates ( ` bool ` ) : If sampling is done <nl> + allow_duplicates ( ` bool ` ) : If sampling is done <nl> with replacement ( ` True ` ) or without ( ` False ` ) . <nl> <nl> Examples : <nl> > > > import numpy as np <nl> > > > from cntk import * <nl> - > > > # weight vector with 100 ' 1000 ' - values followed <nl> + > > > # weight vector with 100 ' 1000 ' - values followed <nl> > > > # by 100 ' 1 ' values <nl> > > > w1 = np . full ( ( 100 ) , 1000 , dtype = np . float ) <nl> > > > w2 = np . full ( ( 100 ) , 1 , dtype = np . float ) <nl> def random_sample_inclusion_frequency ( <nl> weights = sanitize_input ( weights ) <nl> <nl> return random_sample_inclusion_frequency ( <nl> - weights , <nl> - num_samples , <nl> - allow_duplicates , <nl> + weights , <nl> + num_samples , <nl> + allow_duplicates , <nl> name ) <nl> <nl> <nl>
convolution doc update
microsoft/CNTK
a96dccc4eccb46175f9c4154eff6389c45f85fa2
2016-11-06T21:09:05Z
mmm a / template / multi - platform - cpp / proj . ios / HelloCpp . xcodeproj / project . pbxproj . REMOVED . git - id <nl> ppp b / template / multi - platform - cpp / proj . ios / HelloCpp . xcodeproj / project . pbxproj . REMOVED . git - id <nl> @ @ - 1 + 1 @ @ <nl> - 4d7caebf5ec01e9050f96e5945fcc3c8ee9b3db3 <nl> \ No newline at end of file <nl> + 204c297795577c5443fbc61ae226489cd1b43a21 <nl> \ No newline at end of file <nl> mmm a / template / multi - platform - cpp / proj . mac / HelloCpp . xcodeproj / project . pbxproj . REMOVED . git - id <nl> ppp b / template / multi - platform - cpp / proj . mac / HelloCpp . xcodeproj / project . pbxproj . REMOVED . git - id <nl> @ @ - 1 + 1 @ @ <nl> - 1b7c61e11a503cf6c5b902591364c0394d67a545 <nl> \ No newline at end of file <nl> + 3d584f311c499d229a1c5a7d6b7e3dc0567e9b14 <nl> \ No newline at end of file <nl> mmm a / template / multi - platform - js / Classes / AppDelegate . cpp <nl> ppp b / template / multi - platform - js / Classes / AppDelegate . cpp <nl> <nl> # include " js_bindings_chipmunk_registration . h " <nl> # include " js_bindings_system_registration . h " <nl> # include " js_bindings_ccbreader . h " <nl> + # include " jsb_opengl_registration . h " <nl> <nl> USING_NS_CC ; <nl> using namespace CocosDenshion ; <nl> bool AppDelegate : : applicationDidFinishLaunching ( ) <nl> sc - > addRegisterCallback ( register_CCBuilderReader ) ; <nl> sc - > addRegisterCallback ( jsb_register_chipmunk ) ; <nl> sc - > addRegisterCallback ( jsb_register_system ) ; <nl> + sc - > addRegisterCallback ( JSB_register_opengl ) ; <nl> <nl> sc - > start ( ) ; <nl> <nl> mmm a / template / multi - platform - js / proj . ios / HelloJavascript . xcodeproj / project . pbxproj . REMOVED . git - id <nl> ppp b / template / multi - platform - js / proj . ios / HelloJavascript . xcodeproj / project . pbxproj . REMOVED . git - id <nl> @ @ - 1 + 1 @ @ <nl> - e446721f2ad0946c385a3aca082b35572cac729e <nl> \ No newline at end of file <nl> + 2d1e2d547cea7fcada3a110964e4c0a9960936e0 <nl> \ No newline at end of file <nl> mmm a / template / multi - platform - lua / proj . ios / HelloLua . xcodeproj / project . pbxproj . REMOVED . git - id <nl> ppp b / template / multi - platform - lua / proj . ios / HelloLua . xcodeproj / project . pbxproj . REMOVED . git - id <nl> @ @ - 1 + 1 @ @ <nl> - 395b13c3c4cefb526970a182ba7e661ef87f1222 <nl> \ No newline at end of file <nl> + 6f28a01cf8f17ee701637a57d7d025fb04fe4daf <nl> \ No newline at end of file <nl>
fixed : Updating multi - platform template project settings .
cocos2d/cocos2d-x
2c69ce8d80256e976458daca2f3bed5b3e9f6c80
2013-04-24T07:56:37Z
mmm a / test / fuzz / test_runner . py <nl> ppp b / test / fuzz / test_runner . py <nl> def main ( ) : <nl> os . path . join ( config [ " environment " ] [ " BUILDDIR " ] , ' src ' , ' test ' , ' fuzz ' , test_list_selection [ 0 ] ) , <nl> ' - help = 1 ' , <nl> ] , <nl> - timeout = 1 , <nl> + timeout = 10 , <nl> check = True , <nl> stderr = subprocess . PIPE , <nl> universal_newlines = True , <nl>
fuzz : Bump timeout in test_runner to accomodate for slow arm64 CPUs
bitcoin/bitcoin
fa2ec9f4518c1da3ab3592537c6cd204693a6069
2019-11-14T18:50:20Z
mmm a / src / clustering / administration / main / file_based_svs_by_namespace . cc <nl> ppp b / src / clustering / administration / main / file_based_svs_by_namespace . cc <nl> std : : string hash_shard_perfmon_name ( int hash_shard_number ) { <nl> return strprintf ( " shard_ % d " , hash_shard_number ) ; <nl> } <nl> <nl> - void do_construct_existing_store ( <nl> + void do_construct_store ( <nl> const std : : vector < threadnum_t > & threads , <nl> int thread_offset , <nl> store_args_t store_args , <nl> serializer_multiplexer_t * multiplexer , <nl> scoped_array_t < scoped_ptr_t < store_t > > * stores_out_stores , <nl> - store_view_t * * store_views ) { <nl> + store_view_t * * store_views , <nl> + bool create ) { <nl> <nl> / / TODO : Exceptions ? Can exceptions happen , and then this doesn ' t <nl> / / catch it , and the caller doesn ' t handle it . <nl> void do_construct_existing_store ( <nl> store_t * store = new store_t ( <nl> multiplexer - > proxies [ thread_offset ] , store_args . balancer , <nl> hash_shard_perfmon_name ( thread_offset ) , <nl> - false , store_args . serializers_perfmon_collection , <nl> + create , store_args . serializers_perfmon_collection , <nl> store_args . ctx , store_args . io_backender , store_args . base_path , <nl> std : : move ( index_report ) , store_args . ns_id ) ; <nl> ( * stores_out_stores ) [ thread_offset ] . init ( store ) ; <nl> store_views [ thread_offset ] = store ; <nl> } <nl> <nl> - void do_create_new_store ( <nl> + void do_construct_existing_store ( <nl> const std : : vector < threadnum_t > & threads , <nl> int thread_offset , <nl> store_args_t store_args , <nl> void do_create_new_store ( <nl> scoped_array_t < scoped_ptr_t < store_t > > * stores_out_stores , <nl> store_view_t * * store_views ) { <nl> <nl> - on_thread_t th ( threads [ thread_offset ] ) ; <nl> + do_construct_store ( threads , thread_offset , store_args , multiplexer , stores_out_stores , <nl> + store_views , false ) ; <nl> + } <nl> <nl> - / / Only pass this down to the first store <nl> - scoped_ptr_t < outdated_index_report_t > index_report ; <nl> - if ( thread_offset = = 0 ) { <nl> - index_report = store_args . outdated_index_tracker - > create_report ( store_args . ns_id ) ; <nl> - } <nl> + void do_create_new_store ( <nl> + const std : : vector < threadnum_t > & threads , <nl> + int thread_offset , <nl> + store_args_t store_args , <nl> + serializer_multiplexer_t * multiplexer , <nl> + scoped_array_t < scoped_ptr_t < store_t > > * stores_out_stores , <nl> + store_view_t * * store_views ) { <nl> <nl> - store_t * store = new store_t ( <nl> - multiplexer - > proxies [ thread_offset ] , store_args . balancer , <nl> - hash_shard_perfmon_name ( thread_offset ) , <nl> - true , store_args . serializers_perfmon_collection , <nl> - store_args . ctx , store_args . io_backender , store_args . base_path , <nl> - std : : move ( index_report ) , store_args . ns_id ) ; <nl> - ( * stores_out_stores ) [ thread_offset ] . init ( store ) ; <nl> - store_views [ thread_offset ] = store ; <nl> + do_construct_store ( threads , thread_offset , store_args , multiplexer , stores_out_stores , <nl> + store_views , true ) ; <nl> } <nl> <nl> void <nl>
Merge pull request from krishnanm86 / next
rethinkdb/rethinkdb
c2c92340d4d634222775cfb097a46f62e39edc62
2015-02-24T19:48:42Z
mmm a / test / core / iomgr / alarm_test . c <nl> ppp b / test / core / iomgr / alarm_test . c <nl> <nl> # include < ctype . h > <nl> # include < errno . h > <nl> # include < fcntl . h > <nl> - # include < netinet / in . h > <nl> # include < stdio . h > <nl> # include < stdlib . h > <nl> # include < string . h > <nl> - # include < sys / socket . h > <nl> - # include < sys / time . h > <nl> - # include < unistd . h > <nl> <nl> # include < grpc / support / alloc . h > <nl> # include < grpc / support / log . h > <nl>
Clean up alarm_test . c includes
grpc/grpc
87f84051958879f088449810d68a4e4f1eba09d6
2015-04-08T16:58:27Z
mmm a / aten / src / ATen / cpp_custom_type_hack . h <nl> ppp b / aten / src / ATen / cpp_custom_type_hack . h <nl> <nl> namespace at { <nl> namespace cpp_custom_type_hack { <nl> <nl> + template < typename T > <nl> + bool isa ( const Tensor & packed ) { <nl> + return ( packed . scalar_type ( ) = = kByte ) & & <nl> + ( packed . storage ( ) . data_ptr ( ) . get_deleter ( ) = = <nl> + caffe2 : : TypeMeta : : Make < T > ( ) . deleteFn ( ) ) ; <nl> + } <nl> + <nl> template < typename T > <nl> T & cast ( const Tensor & packed ) { <nl> TORCH_CHECK ( <nl>
Add a check method for custom type tensor ( )
pytorch/pytorch
c65305e9913629891ea9296c414b54259c1ddbb9
2020-01-06T19:15:33Z
mmm a / modules / planning / optimizer / st_graph / st_boundary_mapper . cc <nl> ppp b / modules / planning / optimizer / st_graph / st_boundary_mapper . cc <nl> Status StBoundaryMapper : : MapWithoutDecision ( <nl> AWARN < < " lower / upper points are reversed . " ; <nl> } <nl> <nl> - const double area = GetArea ( boundary_points ) ; <nl> - if ( Double : : Compare ( area , 0 . 0 ) > 0 ) { <nl> - * boundary = StGraphBoundary ( boundary_points ) ; <nl> - boundary - > SetId ( path_obstacle . Obstacle ( ) - > Id ( ) ) ; <nl> - } <nl> + * boundary = StGraphBoundary ( boundary_points ) ; <nl> + boundary - > SetId ( path_obstacle . Obstacle ( ) - > Id ( ) ) ; <nl> } <nl> return Status : : OK ( ) ; <nl> } <nl> Status StBoundaryMapper : : MapWithPredictionTrajectory ( <nl> DCHECK ( false ) < < " Obj decision should be either yield or overtake : " <nl> < < obj_decision . DebugString ( ) ; <nl> } <nl> - const double area = GetArea ( boundary_points ) ; <nl> - if ( Double : : Compare ( area , 0 . 0 ) > 0 ) { <nl> - * boundary = StGraphBoundary ( boundary_points ) ; <nl> - boundary - > SetBoundaryType ( b_type ) ; <nl> - boundary - > SetId ( path_obstacle . Obstacle ( ) - > Id ( ) ) ; <nl> - boundary - > SetCharacteristicLength ( characteristic_length ) ; <nl> - } <nl> + * boundary = StGraphBoundary ( boundary_points ) ; <nl> + boundary - > SetBoundaryType ( b_type ) ; <nl> + boundary - > SetId ( path_obstacle . Obstacle ( ) - > Id ( ) ) ; <nl> + boundary - > SetCharacteristicLength ( characteristic_length ) ; <nl> } <nl> return Status : : OK ( ) ; <nl> } <nl> Status StBoundaryMapper : : MapFollowDecision ( <nl> boundary_points . emplace_back ( s_max_upper , planning_time_ ) ; <nl> boundary_points . emplace_back ( s_min_upper , 0 . 0 ) ; <nl> <nl> - const double area = GetArea ( boundary_points ) ; <nl> - if ( Double : : Compare ( area , 0 . 0 ) < = 0 ) { <nl> - std : : string msg = " Do not need to map because area is zero . " ; <nl> - ADEBUG < < msg ; <nl> - return Status : : OK ( ) ; <nl> - } <nl> * boundary = StGraphBoundary ( boundary_points ) ; <nl> <nl> const double characteristic_length = <nl> Status StBoundaryMapper : : MapFollowDecision ( <nl> return Status : : OK ( ) ; <nl> } <nl> <nl> - double StBoundaryMapper : : GetArea ( <nl> - const std : : vector < STPoint > & boundary_points ) const { <nl> - if ( boundary_points . size ( ) < 3 ) { <nl> - return 0 . 0 ; <nl> - } <nl> - <nl> - double area = 0 . 0 ; <nl> - for ( uint32_t i = 2 ; i < boundary_points . size ( ) ; + + i ) { <nl> - const double ds1 = boundary_points [ i - 1 ] . s ( ) - boundary_points [ 0 ] . s ( ) ; <nl> - const double dt1 = boundary_points [ i - 1 ] . t ( ) - boundary_points [ 0 ] . t ( ) ; <nl> - <nl> - const double ds2 = boundary_points [ i ] . s ( ) - boundary_points [ 0 ] . s ( ) ; <nl> - const double dt2 = boundary_points [ i ] . t ( ) - boundary_points [ 0 ] . t ( ) ; <nl> - / / cross product <nl> - area + = ( ds1 * dt2 - ds2 * dt1 ) ; <nl> - } <nl> - return fabs ( area * 0 . 5 ) ; <nl> - } <nl> - <nl> bool StBoundaryMapper : : CheckOverlap ( const PathPoint & path_point , <nl> const Box2d & obs_box , <nl> const double buffer ) const { <nl> Status StBoundaryMapper : : GetSpeedLimits ( <nl> void StBoundaryMapper : : AppendBoundary ( <nl> const StGraphBoundary & boundary , <nl> std : : vector < StGraphBoundary > * st_graph_boundaries ) const { <nl> - if ( boundary . points ( ) . empty ( ) ) { <nl> + if ( Double : : Compare ( boundary . area ( ) , 0 . 0 ) < = 0 ) { <nl> return ; <nl> } <nl> st_graph_boundaries - > push_back ( std : : move ( boundary ) ) ; <nl> mmm a / modules / planning / optimizer / st_graph / st_boundary_mapper . h <nl> ppp b / modules / planning / optimizer / st_graph / st_boundary_mapper . h <nl> class StBoundaryMapper { <nl> const apollo : : common : : math : : Box2d & obs_box , <nl> const double buffer ) const ; <nl> <nl> - double GetArea ( const std : : vector < STPoint > & boundary_points ) const ; <nl> - <nl> bool GetOverlapBoundaryPoints ( <nl> const std : : vector < apollo : : common : : PathPoint > & path_points , <nl> const Obstacle & obstacle , std : : vector < STPoint > * upper_points , <nl>
Planning : removed GetArea ( ) function in StBoundaryMapper . Use area ( ) in polygon2d
ApolloAuto/apollo
d6cc3ca4555757e1fb7201ddf6b100e5150fd3b8
2017-08-16T23:58:40Z
new file mode 100644 <nl> index 0000000000000 . . 2dce134d5f34c <nl> mmm / dev / null <nl> ppp b / tensorflow / go / op / gradients . go <nl> <nl> + / * <nl> + Copyright 2016 The TensorFlow Authors . All Rights Reserved . <nl> + <nl> + Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + you may not use this file except in compliance with the License . <nl> + You may obtain a copy of the License at <nl> + <nl> + http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + <nl> + Unless required by applicable law or agreed to in writing , software <nl> + distributed under the License is distributed on an " AS IS " BASIS , <nl> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + See the License for the specific language governing permissions and <nl> + limitations under the License . <nl> + * / <nl> + <nl> + package op <nl> + <nl> + import tf " github . com / tensorflow / tensorflow / tensorflow / go " <nl> + <nl> + / / Gradients adds gradients computation ops to the graph according to scope . <nl> + / / <nl> + / / Arguments : <nl> + / / prefix : unique string prefix applied before the names of nodes added to the graph to <nl> + / / compute gradients . If null , will use " Gradients " . <nl> + / / y : output of the function to derive <nl> + / / x : inputs of the function for which partial derivatives are computed <nl> + / / dx : if not null , the partial derivatives of some loss function L w . r . t . y <nl> + / / <nl> + / / return the partial derivatives <nl> + func Gradients ( scope * Scope , prefix string , y [ ] tf . Output , x [ ] tf . Output , dx . . . tf . Output ) ( output [ ] tf . Output ) { <nl> + var err error <nl> + if prefix = = " " { <nl> + prefix = " Gradients " <nl> + } <nl> + if output , err = scope . graph . AddGradients ( scope . opName ( scope . uniqueName ( prefix ) ) , y , x , dx ) ; err ! = nil { <nl> + scope . UpdateErr ( " Gradients " , err ) <nl> + return <nl> + } <nl> + return output <nl> + } <nl> new file mode 100644 <nl> index 0000000000000 . . 7d03fada7453c <nl> mmm / dev / null <nl> ppp b / tensorflow / go / op / gradients_test . go <nl> <nl> + / * <nl> + Copyright 2016 The TensorFlow Authors . All Rights Reserved . <nl> + <nl> + Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + you may not use this file except in compliance with the License . <nl> + You may obtain a copy of the License at <nl> + <nl> + http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + <nl> + Unless required by applicable law or agreed to in writing , software <nl> + distributed under the License is distributed on an " AS IS " BASIS , <nl> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + See the License for the specific language governing permissions and <nl> + limitations under the License . <nl> + * / <nl> + <nl> + package op <nl> + <nl> + import ( <nl> + " strings " <nl> + " testing " <nl> + <nl> + tf " github . com / tensorflow / tensorflow / tensorflow / go " <nl> + ) <nl> + <nl> + func TestAddGradients ( t * testing . T ) { <nl> + var ( <nl> + s = NewScope ( ) <nl> + x1 = Placeholder ( s . SubScope ( " x1 " ) , tf . Float ) <nl> + x2 = Placeholder ( s . SubScope ( " x2 " ) , tf . Float ) <nl> + y0 = Square ( s . SubScope ( " y0 " ) , x1 ) <nl> + y1 = Square ( s . SubScope ( " y1 " ) , y0 ) <nl> + y2 = AddN ( s . SubScope ( " y2 " ) , [ ] tf . Output { y0 , x2 } ) <nl> + ) <nl> + <nl> + grads0 : = Gradients ( s , " " , [ ] tf . Output { y1 } , [ ] tf . Output { x1 } ) <nl> + if err : = s . Err ( ) ; err ! = nil { <nl> + t . Fatal ( err ) <nl> + } <nl> + if len ( grads0 ) ! = 1 { <nl> + t . Fatal ( len ( grads0 ) ) <nl> + } <nl> + if grads0 [ 0 ] . DataType ( ) ! = tf . Float { <nl> + t . Fatalf ( " Got DataType % v , wanted % v " , grads0 [ 0 ] . DataType ( ) , tf . Float ) <nl> + } <nl> + <nl> + grads1 : = Gradients ( s , " " , [ ] tf . Output { y2 } , [ ] tf . Output { x1 , x2 } ) <nl> + if err : = s . Err ( ) ; err ! = nil { <nl> + t . Fatal ( err ) <nl> + } <nl> + if len ( grads1 ) ! = 2 { <nl> + t . Fatal ( len ( grads1 ) ) <nl> + } <nl> + if grads1 [ 0 ] . DataType ( ) ! = tf . Float { <nl> + t . Fatalf ( " Got DataType % v , wanted % v " , grads1 [ 0 ] . DataType ( ) , tf . Float ) <nl> + } <nl> + if grads1 [ 1 ] . DataType ( ) ! = tf . Float { <nl> + t . Fatalf ( " Got DataType % v , wanted % v " , grads1 [ 1 ] . DataType ( ) , tf . Float ) <nl> + } <nl> + <nl> + graph , err : = s . Finalize ( ) <nl> + if err ! = nil { <nl> + t . Fatal ( err ) <nl> + } <nl> + sess , err : = tf . NewSession ( graph , nil ) <nl> + if err ! = nil { <nl> + t . Fatal ( err ) <nl> + } <nl> + <nl> + c1 , _ : = tf . NewTensor ( float32 ( 3 . 0 ) ) <nl> + c2 , _ : = tf . NewTensor ( float32 ( 3 . 0 ) ) <nl> + outputs , err : = sess . Run ( <nl> + map [ tf . Output ] * tf . Tensor { x1 : c1 , x2 : c2 } , <nl> + [ ] tf . Output { grads0 [ 0 ] , grads1 [ 0 ] , grads1 [ 1 ] } , <nl> + nil ) <nl> + if err ! = nil { <nl> + t . Fatal ( err ) <nl> + } <nl> + if len ( outputs ) ! = 3 { <nl> + t . Fatal ( len ( outputs ) ) <nl> + } <nl> + if outputs [ 0 ] . Value ( ) . ( float32 ) ! = 108 . 0 { <nl> + t . Fatalf ( " Got % v , wanted float 108 . 0 " , outputs [ 0 ] . Value ( ) ) <nl> + } <nl> + if outputs [ 1 ] . Value ( ) . ( float32 ) ! = 6 . 0 { <nl> + t . Fatalf ( " Got % v , wanted float 6 . 0 " , outputs [ 1 ] . Value ( ) ) <nl> + } <nl> + if outputs [ 2 ] . Value ( ) . ( float32 ) ! = 1 . 0 { <nl> + t . Fatalf ( " Got % v , wanted float 1 . 0 " , outputs [ 2 ] . Value ( ) ) <nl> + } <nl> + } <nl> + <nl> + func TestAddGradientsSums ( t * testing . T ) { <nl> + var ( <nl> + s = NewScope ( ) <nl> + x = Placeholder ( s . SubScope ( " x " ) , tf . Float ) <nl> + y0 = Square ( s . SubScope ( " y0 " ) , x ) <nl> + y1 = Square ( s . SubScope ( " y1 " ) , y0 ) <nl> + ) <nl> + <nl> + grad : = Gradients ( s , " " , [ ] tf . Output { y0 , y1 } , [ ] tf . Output { x } ) <nl> + if err : = s . Err ( ) ; err ! = nil { <nl> + t . Fatal ( err ) <nl> + } <nl> + if len ( grad ) ! = 1 { <nl> + t . Fatal ( len ( grad ) ) <nl> + } <nl> + if grad [ 0 ] . DataType ( ) ! = tf . Float { <nl> + t . Fatalf ( " Got DataType % v , wanted % v " , grad [ 0 ] . DataType ( ) , tf . Float ) <nl> + } <nl> + <nl> + graph , err : = s . Finalize ( ) <nl> + if err ! = nil { <nl> + t . Fatal ( err ) <nl> + } <nl> + sess , err : = tf . NewSession ( graph , nil ) <nl> + if err ! = nil { <nl> + t . Fatal ( err ) <nl> + } <nl> + <nl> + c , _ : = tf . NewTensor ( float32 ( 3 . 0 ) ) <nl> + outputs , err : = sess . Run ( <nl> + map [ tf . Output ] * tf . Tensor { x : c } , <nl> + [ ] tf . Output { grad [ 0 ] } , <nl> + nil ) <nl> + if err ! = nil { <nl> + t . Fatal ( err ) <nl> + } <nl> + if outputs [ 0 ] . Value ( ) . ( float32 ) ! = 114 . 0 { <nl> + t . Fatalf ( " Got % v , wanted float 114 . 0 " , outputs [ 0 ] . Value ( ) ) <nl> + } <nl> + } <nl> + <nl> + func TestAddGradientsWithInitialValues ( t * testing . T ) { <nl> + var ( <nl> + s = NewScope ( ) <nl> + x = Placeholder ( s . SubScope ( " x1 " ) , tf . Float ) <nl> + y0 = Square ( s . SubScope ( " y0 " ) , x ) <nl> + y1 = Square ( s . SubScope ( " y1 " ) , y0 ) <nl> + ) <nl> + <nl> + grads0 : = Gradients ( s , " " , [ ] tf . Output { y1 } , [ ] tf . Output { y0 } ) <nl> + if err : = s . Err ( ) ; err ! = nil { <nl> + t . Fatal ( err ) <nl> + } <nl> + if len ( grads0 ) ! = 1 { <nl> + t . Fatal ( len ( grads0 ) ) <nl> + } <nl> + if grads0 [ 0 ] . DataType ( ) ! = tf . Float { <nl> + t . Fatalf ( " Got DataType % v , wanted % v " , grads0 [ 0 ] . DataType ( ) , tf . Float ) <nl> + } <nl> + <nl> + grads1 : = Gradients ( s , " " , [ ] tf . Output { y0 } , [ ] tf . Output { x } , grads0 [ 0 ] ) <nl> + if err : = s . Err ( ) ; err ! = nil { <nl> + t . Fatal ( err ) <nl> + } <nl> + if len ( grads1 ) ! = 1 { <nl> + t . Fatal ( len ( grads1 ) ) <nl> + } <nl> + if grads1 [ 0 ] . DataType ( ) ! = tf . Float { <nl> + t . Fatalf ( " Got DataType % v , wanted % v " , grads1 [ 0 ] . DataType ( ) , tf . Float ) <nl> + } <nl> + <nl> + graph , err : = s . Finalize ( ) <nl> + if err ! = nil { <nl> + t . Fatal ( err ) <nl> + } <nl> + sess , err : = tf . NewSession ( graph , nil ) <nl> + if err ! = nil { <nl> + t . Fatal ( err ) <nl> + } <nl> + <nl> + c , _ : = tf . NewTensor ( float32 ( 3 . 0 ) ) <nl> + outputs , err : = sess . Run ( <nl> + map [ tf . Output ] * tf . Tensor { x : c } , <nl> + [ ] tf . Output { grads1 [ 0 ] } , <nl> + nil ) <nl> + if err ! = nil { <nl> + t . Fatal ( err ) <nl> + } <nl> + if outputs [ 0 ] . Value ( ) . ( float32 ) ! = 108 . 0 { <nl> + t . Fatalf ( " Got % v , wanted float 108 . 0 " , outputs [ 0 ] . Value ( ) ) <nl> + } <nl> + } <nl> + <nl> + func TestValidateGradientsNames ( t * testing . T ) { <nl> + var ( <nl> + s = NewScope ( ) <nl> + x = Placeholder ( s . SubScope ( " x " ) , tf . Float ) <nl> + y0 = Square ( s . SubScope ( " y0 " ) , x ) <nl> + ) <nl> + <nl> + grads0 : = Gradients ( s , " " , [ ] tf . Output { y0 } , [ ] tf . Output { x } ) <nl> + if err : = s . Err ( ) ; err ! = nil { <nl> + t . Fatal ( err ) <nl> + } <nl> + if ! strings . HasPrefix ( grads0 [ 0 ] . Op . Name ( ) , " Gradients / " ) { <nl> + t . Fatalf ( " Got name % v , wanted started with Gradients / " , grads0 [ 0 ] . Op . Name ( ) ) <nl> + } <nl> + <nl> + grads1 : = Gradients ( s , " " , [ ] tf . Output { y0 } , [ ] tf . Output { x } ) <nl> + if err : = s . Err ( ) ; err ! = nil { <nl> + t . Fatal ( err ) <nl> + } <nl> + if ! strings . HasPrefix ( grads1 [ 0 ] . Op . Name ( ) , " Gradients_1 / " ) { <nl> + t . Fatalf ( " Got name % v , wanted started with Gradients_1 / " , grads1 [ 0 ] . Op . Name ( ) ) <nl> + } <nl> + <nl> + grads2 : = Gradients ( s , " more_gradients " , [ ] tf . Output { y0 } , [ ] tf . Output { x } ) <nl> + if err : = s . Err ( ) ; err ! = nil { <nl> + t . Fatal ( err ) <nl> + } <nl> + if ! strings . HasPrefix ( grads2 [ 0 ] . Op . Name ( ) , " more_gradients / " ) { <nl> + t . Fatalf ( " Got name % v , wanted started with more_gradients / " , grads2 [ 0 ] . Op . Name ( ) ) <nl> + } <nl> + <nl> + sub : = s . SubScope ( " sub " ) <nl> + grads3 : = Gradients ( sub , " even_more_gradients " , [ ] tf . Output { y0 } , [ ] tf . Output { x } ) <nl> + if err : = s . Err ( ) ; err ! = nil { <nl> + t . Fatal ( err ) <nl> + } <nl> + if ! strings . HasPrefix ( grads3 [ 0 ] . Op . Name ( ) , " sub / even_more_gradients / " ) { <nl> + t . Fatalf ( " Got name % v , wanted started with sub / even_more_gradients / " , grads3 [ 0 ] . Op . Name ( ) ) <nl> + } <nl> + <nl> + grads4 : = Gradients ( sub , " even_more_gradients " , [ ] tf . Output { y0 } , [ ] tf . Output { x } ) <nl> + if err : = s . Err ( ) ; err ! = nil { <nl> + t . Fatal ( err ) <nl> + } <nl> + if ! strings . HasPrefix ( grads4 [ 0 ] . Op . Name ( ) , " sub / even_more_gradients_1 / " ) { <nl> + t . Fatalf ( " Got name % v , wanted started with sub / even_more_gradients_1 / " , grads4 [ 0 ] . Op . Name ( ) ) <nl> + } <nl> + } <nl>
Support addition of gradient operations in op package for golang
tensorflow/tensorflow
e40c032d62075621053262758c065f9bfb9faed9
2018-09-12T07:00:23Z
mmm a / Documentation / Books / AQL / book . json <nl> ppp b / Documentation / Books / AQL / book . json <nl> <nl> " author " : " ArangoDB GmbH " , <nl> " description " : " Official AQL manual for ArangoDB - the multi - model NoSQL database " , <nl> " language " : " en " , <nl> - " plugins " : [ " - search " , " - sharing " , " toggle - chapters " , " addcssjs " , " heading - anchors " , " add - header " , " piwik " ] , <nl> + " plugins " : [ " - search " , " - sharing " , " toggle - chapters " , " addcssjs " , " anchorjs " , " add - header " , " piwik " ] , <nl> " pdf " : { <nl> " fontSize " : 12 , <nl> " toc " : true , <nl> mmm a / Documentation / Books / HTTP / book . json <nl> ppp b / Documentation / Books / HTTP / book . json <nl> <nl> " author " : " ArangoDB GmbH " , <nl> " description " : " Official HTTP API manual for ArangoDB - the multi - model NoSQL database " , <nl> " language " : " en " , <nl> - " plugins " : [ " - search " , " - sharing " , " toggle - chapters " , " addcssjs " , " heading - anchors " , " add - header " , " piwik " ] , <nl> + " plugins " : [ " - search " , " - sharing " , " toggle - chapters " , " addcssjs " , " anchorjs " , " add - header " , " piwik " ] , <nl> " pdf " : { <nl> " fontSize " : 12 , <nl> " toc " : true , <nl> mmm a / Documentation / Books / Manual / Administration / Configuration / Communication . mdpp <nl> ppp b / Documentation / Books / Manual / Administration / Configuration / Communication . mdpp <nl> <nl> - ! CHAPTER Command - Line Options for Communication <nl> + ! CHAPTER Command Line Options for Communication <nl> <nl> ! SUBSECTION Scheduler threads <nl> <nl> exit . This option is useful only when used in conjunction with the option <nl> scheduler . backend . An integer is returned ( which is platform dependent ) which <nl> indicates available backends on your platform . See libev for further details and <nl> for the meaning of the integer returned . This describes the allowed integers for <nl> - * scheduler . backend * , see [ here ] ( # commandline - options - for - communication ) for details . <nl> + * scheduler . backend * , see [ here ] ( # command - line - options - for - communication ) for details . <nl> mmm a / Documentation / Books / Manual / GettingStarted / Installing / Linux . mdpp <nl> ppp b / Documentation / Books / Manual / GettingStarted / Installing / Linux . mdpp <nl> We provide packages for : <nl> * Centos <nl> * Debian <nl> * Fedora <nl> - * [ Linux - Mint ] ( # linuxmint ) <nl> + * [ Linux - Mint ] ( # linux - mint ) <nl> * Mandriva <nl> * OpenSUSE <nl> * RedHat RHEL <nl> page to use your favorite package manager for the major distributions . After <nl> setting up the ArangoDB repository you can easily install ArangoDB using yum , <nl> aptitude , urpmi or zypper . <nl> <nl> - ! SUBSECTION Linux - Mint <nl> + ! SUBSECTION Linux Mint <nl> <nl> Please use the corresponding Ubuntu or Debian packages . <nl> <nl> mmm a / Documentation / Books / Manual / book . json <nl> ppp b / Documentation / Books / Manual / book . json <nl> <nl> " author " : " ArangoDB GmbH " , <nl> " description " : " Official manual for ArangoDB - the multi - model NoSQL database " , <nl> " language " : " en " , <nl> - " plugins " : [ " - search " , " - sharing " , " toggle - chapters " , " addcssjs " , " heading - anchors " , " add - header " , " piwik " ] , <nl> + " plugins " : [ " - search " , " - sharing " , " toggle - chapters " , " addcssjs " , " anchorjs " , " add - header " , " piwik " ] , <nl> " pdf " : { <nl> " fontSize " : 12 , <nl> " toc " : true , <nl>
Replace gitbook plugin , fix two anchor links
arangodb/arangodb
c36e2c42adfa6b9241227d5a11bf72d2c6b4f8b9
2016-05-30T20:29:07Z
mmm a / ports / qt5modularscripts / qt_modular_library . cmake <nl> ppp b / ports / qt5modularscripts / qt_modular_library . cmake <nl> function ( qt_modular_library NAME HASH ) <nl> foreach ( DEBUG_MAKEFILE $ { DEBUG_MAKEFILES } ) <nl> file ( READ " $ { DEBUG_MAKEFILE } " _contents ) <nl> string ( REPLACE " zlib . lib " " zlibd . lib " _contents " $ { _contents } " ) <nl> - string ( REPLACE " vcpkg \ \ installed \ \ $ { TARGET_TRIPLET } \ \ lib " " vcpkg \ \ installed \ \ $ { TARGET_TRIPLET } \ \ debug \ \ lib " _contents " $ { _contents } " ) <nl> + string ( REPLACE " installed \ \ $ { TARGET_TRIPLET } \ \ lib " " installed \ \ $ { TARGET_TRIPLET } \ \ debug \ \ lib " _contents " $ { _contents } " ) <nl> string ( REPLACE " / LIBPATH : $ { NATIVE_INSTALLED_DIR } \ \ debug \ \ lib qtmaind . lib " " shell32 . lib / LIBPATH : $ { NATIVE_INSTALLED_DIR } \ \ debug \ \ lib \ \ manual - link qtmaind . lib / LIBPATH : $ { NATIVE_INSTALLED_DIR } \ \ debug \ \ lib " _contents " $ { _contents } " ) <nl> file ( WRITE " $ { DEBUG_MAKEFILE } " " $ { _contents } " ) <nl> endforeach ( ) <nl> similarity index 61 % <nl> rename from ports / qt5serial / CONTROL <nl> rename to ports / qt5serialport / CONTROL <nl> mmm a / ports / qt5serial / CONTROL <nl> ppp b / ports / qt5serialport / CONTROL <nl> <nl> - Source : qt5serial <nl> + Source : qt5serialport <nl> Version : 5 . 9 . 2 - 0 <nl> Description : Qt5 Serial Port - provides access to hardware and virtual serial ports <nl> Build - Depends : qt5modularscripts , qt5base <nl> \ No newline at end of file <nl> similarity index 100 % <nl> rename from ports / qt5serial / portfile . cmake <nl> rename to ports / qt5serialport / portfile . cmake <nl>
fix naming issues
microsoft/vcpkg
eb92719c5d41b3013050b269ba5ec85383789b17
2017-12-14T20:02:25Z
mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> if ( OS_LINUX AND NOT UNBUNDLED AND ( GLIBC_COMPATIBILITY OR USE_INTERNAL_UNWIND_L <nl> <nl> if ( USE_INTERNAL_UNWIND_LIBRARY_FOR_EXCEPTION_HANDLING ) <nl> # TODO : Allow to use non - static library as well . <nl> - set ( EXCEPTION_HANDLING_LIBRARY " lib / libunwind $ { $ { CMAKE_POSTFIX_VARIABLE } } . a " ) <nl> + set ( EXCEPTION_HANDLING_LIBRARY " $ { ClickHouse_BINARY_DIR } / contrib / libunwind - cmake / libunwind_static $ { $ { CMAKE_POSTFIX_VARIABLE } } . a " ) <nl> else ( ) <nl> set ( EXCEPTION_HANDLING_LIBRARY " - lgcc_eh " ) <nl> endif ( ) <nl> if ( GLIBC_COMPATIBILITY OR USE_INTERNAL_UNWIND_LIBRARY_FOR_EXCEPTION_HANDLING ) <nl> add_dependencies ( $ { target_name } glibc - compatibility ) <nl> endif ( ) <nl> if ( USE_INTERNAL_UNWIND_LIBRARY_FOR_EXCEPTION_HANDLING ) <nl> - add_dependencies ( $ { target_name } $ { UNWIND_LIBRARY } ) <nl> + add_dependencies ( $ { target_name } unwind_static ) <nl> endif ( ) <nl> endif ( ) <nl> endfunction ( ) <nl> mmm a / contrib / CMakeLists . txt <nl> ppp b / contrib / CMakeLists . txt <nl> endif ( ) <nl> <nl> set_property ( DIRECTORY PROPERTY EXCLUDE_FROM_ALL 1 ) <nl> <nl> + <nl> + if ( USE_INTERNAL_UNWIND_LIBRARY ) <nl> + add_subdirectory ( libunwind - cmake ) <nl> + endif ( ) <nl> + <nl> + if ( USE_LIBCXX AND USE_INTERNAL_LIBCXXABI_LIBRARY ) <nl> + add_subdirectory ( libcxxabi - cmake ) <nl> + endif ( ) <nl> + <nl> + if ( USE_LIBCXX AND USE_INTERNAL_LIBCXX_LIBRARY ) <nl> + add_subdirectory ( libcxx - cmake ) <nl> + endif ( ) <nl> + <nl> + <nl> if ( USE_INTERNAL_BOOST_LIBRARY ) <nl> add_subdirectory ( boost - cmake ) <nl> endif ( ) <nl> if ( USE_INTERNAL_BTRIE_LIBRARY ) <nl> add_subdirectory ( libbtrie ) <nl> endif ( ) <nl> <nl> - if ( USE_INTERNAL_UNWIND_LIBRARY ) <nl> - add_subdirectory ( libunwind ) <nl> - endif ( ) <nl> - <nl> if ( USE_INTERNAL_ZLIB_LIBRARY ) <nl> set ( ZLIB_ENABLE_TESTS 0 CACHE INTERNAL " " ) <nl> set ( SKIP_INSTALL_ALL 1 CACHE INTERNAL " " ) <nl> new file mode 100644 <nl> index 00000000000 . . 6e87f8438b1 <nl> mmm / dev / null <nl> ppp b / contrib / libunwind - cmake / CMakeLists . txt <nl> <nl> + set ( LIBUNWIND_SOURCE_DIR $ { ClickHouse_SOURCE_DIR } / contrib / libunwind ) <nl> + <nl> + set ( LIBUNWIND_CXX_SOURCES <nl> + $ { LIBUNWIND_SOURCE_DIR } / src / libunwind . cpp <nl> + $ { LIBUNWIND_SOURCE_DIR } / src / Unwind - EHABI . cpp <nl> + $ { LIBUNWIND_SOURCE_DIR } / src / Unwind - seh . cpp ) <nl> + if ( APPLE ) <nl> + set ( LIBUNWIND_CXX_SOURCES $ { LIBUNWIND_CXX_SOURCES } $ { LIBUNWIND_SOURCE_DIR } / src / Unwind_AppleExtras . cpp ) <nl> + endif ( ) <nl> + <nl> + set ( LIBUNWIND_C_SOURCES <nl> + $ { LIBUNWIND_SOURCE_DIR } / src / UnwindLevel1 . c <nl> + $ { LIBUNWIND_SOURCE_DIR } / src / UnwindLevel1 - gcc - ext . c <nl> + $ { LIBUNWIND_SOURCE_DIR } / src / Unwind - sjlj . c ) <nl> + set_source_files_properties ( $ { LIBUNWIND_C_SOURCES } PROPERTIES COMPILE_FLAGS " - std = c99 " ) <nl> + <nl> + set ( LIBUNWIND_ASM_SOURCES <nl> + $ { LIBUNWIND_SOURCE_DIR } / src / UnwindRegistersRestore . S <nl> + $ { LIBUNWIND_SOURCE_DIR } / src / UnwindRegistersSave . S ) <nl> + set_source_files_properties ( $ { LIBUNWIND_ASM_SOURCES } PROPERTIES LANGUAGE C ) <nl> + <nl> + set ( LIBUNWIND_SOURCES <nl> + $ { LIBUNWIND_CXX_SOURCES } <nl> + $ { LIBUNWIND_C_SOURCES } <nl> + $ { LIBUNWIND_ASM_SOURCES } ) <nl> + <nl> + add_library ( unwind_static $ { LIBUNWIND_SOURCES } ) <nl> + <nl> + target_include_directories ( unwind_static PUBLIC $ { LIBUNWIND_SOURCE_DIR } / include ) <nl> + target_compile_definitions ( unwind_static PRIVATE - D_LIBUNWIND_NO_HEAP = 1 ) <nl> + target_compile_options ( unwind_static PRIVATE - fno - rtti - fno - sanitize = all ) <nl> + <nl>
Clean CMakeLists for libunwind .
ClickHouse/ClickHouse
7f8eefedead275cc6c6dbf1c9bf5cbaf2a70a120
2019-07-09T11:46:01Z
mmm a / tensorflow / core / public / version . h <nl> ppp b / tensorflow / core / public / version . h <nl> limitations under the License . <nl> <nl> # define TF_GRAPH_DEF_VERSION_MIN_PRODUCER 0 <nl> # define TF_GRAPH_DEF_VERSION_MIN_CONSUMER 0 <nl> - # define TF_GRAPH_DEF_VERSION 411 / / Updated : 2020 / 5 / 24 <nl> + # define TF_GRAPH_DEF_VERSION 412 / / Updated : 2020 / 5 / 25 <nl> <nl> / / Checkpoint compatibility versions ( the versions field in SavedSliceMeta ) . <nl> / / <nl>
Update GraphDef version to 412 .
tensorflow/tensorflow
a814cfb7c0e1d2aac129634965fd8b45a8808760
2020-05-25T09:06:05Z
mmm a / validation - test / SILOptimizer / large_string_array . swift . gyb <nl> ppp b / validation - test / SILOptimizer / large_string_array . swift . gyb <nl> <nl> / / REQUIRES : long_test <nl> / / REQUIRES : CPU = arm64 | | CPU = x86_64 <nl> <nl> + / / REQUIRES : rdar66807959 <nl> + <nl> / / Check if the optimizer can optimize the whole array into a statically <nl> / / initialized global <nl> <nl>
Merge pull request from apple / shahmishal / disable - test - siloptimizer
apple/swift
142aa5f9996954c32a311932e6cbd7652414f008
2020-08-11T00:30:58Z
mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> endif ( ) <nl> <nl> include ( cmake / test_cpu . cmake ) <nl> <nl> - option ( ARCH_NATIVE " Enable - march = native compiler flag " OFF ) <nl> + option ( ARCH_NATIVE " Enable - march = native compiler flag " $ { ARCH_ARM } ) <nl> if ( ARCH_NATIVE ) <nl> set ( COMPILER_FLAGS " $ { COMPILER_FLAGS } - march = native " ) <nl> endif ( ) <nl> mmm a / cmake / find_llvm . cmake <nl> ppp b / cmake / find_llvm . cmake <nl> if ( ENABLE_EMBEDDED_COMPILER ) <nl> elseif ( CMAKE_CXX_COMPILER_ID STREQUAL " Clang " ) <nl> find_package ( LLVM $ { CMAKE_CXX_COMPILER_VERSION } CONFIG PATHS $ { LLVM_PATHS } ) <nl> else ( ) <nl> - find_package ( LLVM 6 CONFIG PATHS $ { LLVM_PATHS } ) <nl> + find_package ( LLVM 7 CONFIG PATHS $ { LLVM_PATHS } ) <nl> if ( NOT LLVM_FOUND ) <nl> - find_package ( LLVM 5 CONFIG PATHS $ { LLVM_PATHS } ) <nl> + find_package ( LLVM 6 CONFIG PATHS $ { LLVM_PATHS } ) <nl> endif ( ) <nl> if ( NOT LLVM_FOUND ) <nl> - find_package ( LLVM 7 CONFIG PATHS $ { LLVM_PATHS } ) <nl> + find_package ( LLVM 5 CONFIG PATHS $ { LLVM_PATHS } ) <nl> endif ( ) <nl> endif ( ) <nl> <nl> mmm a / contrib / CMakeLists . txt <nl> ppp b / contrib / CMakeLists . txt <nl> if ( USE_INTERNAL_POCO_LIBRARY ) <nl> endif ( ) <nl> endif ( ) <nl> <nl> + if ( USE_INTERNAL_GTEST_LIBRARY ) <nl> + # Google Test from sources <nl> + add_subdirectory ( $ { ClickHouse_SOURCE_DIR } / contrib / googletest / googletest $ { CMAKE_CURRENT_BINARY_DIR } / googletest ) <nl> + # avoid problems with < regexp . h > <nl> + target_compile_definitions ( gtest INTERFACE GTEST_HAS_POSIX_RE = 0 ) <nl> + target_include_directories ( gtest SYSTEM INTERFACE $ { ClickHouse_SOURCE_DIR } / contrib / googletest / include ) <nl> + endif ( ) <nl> + <nl> if ( USE_INTERNAL_LLVM_LIBRARY ) <nl> + file ( GENERATE OUTPUT $ { CMAKE_CURRENT_BINARY_DIR } / empty . cpp CONTENT " " ) <nl> + add_library ( LLVM0 $ { CMAKE_CURRENT_BINARY_DIR } / empty . cpp ) # silly cmake bug fix <nl> # ld : unknown option : - - color - diagnostics <nl> if ( APPLE ) <nl> set ( LINKER_SUPPORTS_COLOR_DIAGNOSTICS 0 CACHE INTERNAL " " ) <nl> endif ( ) <nl> set ( LLVM_ENABLE_EH 1 CACHE INTERNAL " " ) <nl> set ( LLVM_ENABLE_RTTI 1 CACHE INTERNAL " " ) <nl> + set ( LLVM_INCLUDE_TESTS 0 CACHE INTERNAL " " ) <nl> + set ( LLVM_INCLUDE_EXAMPLES 0 CACHE INTERNAL " " ) <nl> + set ( LLVM_INCLUDE_TOOLS 0 CACHE INTERNAL " " ) <nl> + set ( LLVM_INSTALL_TOOLCHAIN_ONLY 0 CACHE INTERNAL " " ) <nl> + set ( CLANG_BUILT_STANDALONE 0 CACHE INTERNAL " " ) <nl> + set ( LLDB_BUILT_STANDALONE 0 CACHE INTERNAL " " ) <nl> + set ( CLANG_ENABLE_STATIC_ANALYZER 0 CACHE INTERNAL " " ) <nl> + set ( CLANG_ENABLE_ARCMT 0 CACHE INTERNAL " " ) <nl> + set ( CLANG_BUILD_TOOLS 0 CACHE INTERNAL " " ) <nl> + set ( BENCHMARK_ENABLE_GTEST_TESTS 0 CACHE INTERNAL " " ) <nl> + set ( BENCHMARK_ENABLE_ASSEMBLY_TESTS 0 CACHE INTERNAL " " ) <nl> + set ( LLVM_TARGETS_TO_BUILD " X86 ; AArch64 " CACHE INTERNAL " " ) <nl> add_subdirectory ( llvm / llvm ) <nl> endif ( ) <nl> <nl> - if ( USE_INTERNAL_GTEST_LIBRARY ) <nl> - # Google Test from sources <nl> - add_subdirectory ( $ { ClickHouse_SOURCE_DIR } / contrib / googletest / googletest $ { CMAKE_CURRENT_BINARY_DIR } / googletest ) <nl> - # avoid problems with < regexp . h > <nl> - target_compile_definitions ( gtest INTERFACE GTEST_HAS_POSIX_RE = 0 ) <nl> - target_include_directories ( gtest SYSTEM INTERFACE $ { ClickHouse_SOURCE_DIR } / contrib / googletest / include ) <nl> - endif ( ) <nl> mmm a / dbms / programs / clang / Compiler - 5 . 0 . 0 / CMakeLists . txt <nl> ppp b / dbms / programs / clang / Compiler - 5 . 0 . 0 / CMakeLists . txt <nl> <nl> add_definitions ( - Wno - error - Wno - unused - parameter - Wno - non - virtual - dtor - U_LIBCPP_DEBUG ) <nl> <nl> + link_directories ( $ { LLVM_LIBRARY_DIRS } ) <nl> + <nl> add_library ( clickhouse - compiler - lib $ { LINK_MODE } <nl> driver . cpp <nl> cc1_main . cpp <nl> mmm a / dbms / programs / clang / Compiler - 6 . 0 . 0 / CMakeLists . txt <nl> ppp b / dbms / programs / clang / Compiler - 6 . 0 . 0 / CMakeLists . txt <nl> <nl> add_definitions ( - Wno - error - Wno - unused - parameter - Wno - non - virtual - dtor - U_LIBCPP_DEBUG ) <nl> <nl> + link_directories ( $ { LLVM_LIBRARY_DIRS } ) <nl> + <nl> add_library ( clickhouse - compiler - lib $ { LINK_MODE } <nl> driver . cpp <nl> cc1_main . cpp <nl> mmm a / dbms / programs / clang / Compiler - 6 . 0 . 0 / cc1as_main . cpp <nl> ppp b / dbms / programs / clang / Compiler - 6 . 0 . 0 / cc1as_main . cpp <nl> static bool ExecuteAssembler ( AssemblerInvocation & Opts , <nl> auto Pair = StringRef ( S ) . split ( ' = ' ) ; <nl> auto Sym = Pair . first ; <nl> auto Val = Pair . second ; <nl> - int64_t Value ; <nl> + int64_t Value = 0 ; <nl> / / We have already error checked this in the driver . <nl> Val . getAsInteger ( 0 , Value ) ; <nl> Ctx . setSymbolValue ( Parser - > getStreamer ( ) , Sym , Value ) ; <nl> mmm a / dbms / programs / clang / Compiler - 7 . 0 . 0 / CMakeLists . txt <nl> ppp b / dbms / programs / clang / Compiler - 7 . 0 . 0 / CMakeLists . txt <nl> <nl> add_definitions ( - Wno - error - Wno - unused - parameter - Wno - non - virtual - dtor - U_LIBCPP_DEBUG ) <nl> <nl> + link_directories ( $ { LLVM_LIBRARY_DIRS } ) <nl> + <nl> add_library ( clickhouse - compiler - lib $ { LINK_MODE } <nl> driver . cpp <nl> cc1_main . cpp <nl> + cc1gen_reproducer_main . cpp <nl> cc1as_main . cpp <nl> lld . cpp ) <nl> <nl> target_include_directories ( clickhouse - compiler - lib SYSTEM PRIVATE $ { LLVM_INCLUDE <nl> # This is extracted almost directly from CMakeFiles / . . . / link . txt in LLVM build directory . <nl> <nl> target_link_libraries ( clickhouse - compiler - lib PRIVATE <nl> - <nl> clangBasic clangCodeGen clangDriver <nl> clangFrontend <nl> clangFrontendTool <nl> mmm a / dbms / programs / clang / Compiler - 7 . 0 . 0 / cc1_main . cpp <nl> ppp b / dbms / programs / clang / Compiler - 7 . 0 . 0 / cc1_main . cpp <nl> <nl> # include " llvm / Option / Arg . h " <nl> # include " clang / CodeGen / ObjectFilePCHContainerOperations . h " <nl> # include " clang / Config / config . h " <nl> + # include " clang / Basic / Stack . h " <nl> # include " clang / Driver / DriverDiagnostic . h " <nl> # include " clang / Driver / Options . h " <nl> # include " clang / Frontend / CompilerInstance . h " <nl> void initializePollyPasses ( llvm : : PassRegistry & Registry ) ; <nl> # endif <nl> <nl> # ifdef CLANG_HAVE_RLIMITS <nl> - / / The amount of stack we think is " sufficient " . If less than this much is <nl> - / / available , we may be unable to reach our template instantiation depth <nl> - / / limit and other similar limits . <nl> - / / FIXME : Unify this with the stack we request when spawning a thread to build <nl> - / / a module . <nl> - static const int kSufficientStack = 8 < < 20 ; <nl> - <nl> # if defined ( __linux__ ) & & defined ( __PIE__ ) <nl> static size_t getCurrentStackAllocation ( ) { <nl> / / If we can ' t compute the current stack usage , allow for 512K of command <nl> static size_t getCurrentStackAllocation ( ) { <nl> # include < alloca . h > <nl> <nl> LLVM_ATTRIBUTE_NOINLINE <nl> - static void ensureStackAddressSpace ( int ExtraChunks = 0 ) { <nl> + static void ensureStackAddressSpace ( ) { <nl> / / Linux kernels prior to 4 . 1 will sometimes locate the heap of a PIE binary <nl> / / relatively close to the stack ( they are only guaranteed to be 128MiB <nl> / / apart ) . This results in crashes if we happen to heap - allocate more than <nl> static void ensureStackAddressSpace ( int ExtraChunks = 0 ) { <nl> / / To avoid these crashes , ensure that we have sufficient virtual memory <nl> / / pages allocated before we start running . <nl> size_t Curr = getCurrentStackAllocation ( ) ; <nl> - const int kTargetStack = kSufficientStack - 256 * 1024 ; <nl> + const int kTargetStack = DesiredStackSize - 256 * 1024 ; <nl> if ( Curr < kTargetStack ) { <nl> volatile char * volatile Alloc = <nl> static_cast < volatile char * > ( alloca ( kTargetStack - Curr ) ) ; <nl> static void ensureSufficientStack ( ) { <nl> <nl> / / Increase the soft stack limit to our desired level , if necessary and <nl> / / possible . <nl> - if ( rlim . rlim_cur ! = RLIM_INFINITY & & rlim . rlim_cur < kSufficientStack ) { <nl> + if ( rlim . rlim_cur ! = RLIM_INFINITY & & <nl> + rlim . rlim_cur < rlim_t ( DesiredStackSize ) ) { <nl> / / Try to allocate sufficient stack . <nl> - if ( rlim . rlim_max = = RLIM_INFINITY | | rlim . rlim_max > = kSufficientStack ) <nl> - rlim . rlim_cur = kSufficientStack ; <nl> + if ( rlim . rlim_max = = RLIM_INFINITY | | <nl> + rlim . rlim_max > = rlim_t ( DesiredStackSize ) ) <nl> + rlim . rlim_cur = DesiredStackSize ; <nl> else if ( rlim . rlim_cur = = rlim . rlim_max ) <nl> return ; <nl> else <nl> rlim . rlim_cur = rlim . rlim_max ; <nl> <nl> if ( setrlimit ( RLIMIT_STACK , & rlim ) ! = 0 | | <nl> - rlim . rlim_cur ! = kSufficientStack ) <nl> + rlim . rlim_cur ! = DesiredStackSize ) <nl> return ; <nl> } <nl> <nl> - / / We should now have a stack of size at least kSufficientStack . Ensure <nl> + / / We should now have a stack of size at least DesiredStackSize . Ensure <nl> / / that we can actually use that much , if necessary . <nl> ensureStackAddressSpace ( ) ; <nl> } <nl> mmm a / dbms / programs / clang / Compiler - 7 . 0 . 0 / cc1as_main . cpp <nl> ppp b / dbms / programs / clang / Compiler - 7 . 0 . 0 / cc1as_main . cpp <nl> <nl> # include " llvm / MC / MCContext . h " <nl> # include " llvm / MC / MCInstrInfo . h " <nl> # include " llvm / MC / MCObjectFileInfo . h " <nl> + # include " llvm / MC / MCObjectWriter . h " <nl> # include " llvm / MC / MCParser / MCAsmParser . h " <nl> # include " llvm / MC / MCParser / MCTargetAsmParser . h " <nl> # include " llvm / MC / MCRegisterInfo . h " <nl> using namespace clang : : driver : : options ; <nl> using namespace llvm ; <nl> using namespace llvm : : opt ; <nl> <nl> - <nl> namespace { <nl> <nl> - / / / \ brief Helper class for representing a single invocation of the assembler . <nl> + / / / Helper class for representing a single invocation of the assembler . <nl> struct AssemblerInvocation { <nl> / / / @ name Target Options <nl> / / / @ { <nl> struct AssemblerInvocation { <nl> std : : string DwarfDebugFlags ; <nl> std : : string DwarfDebugProducer ; <nl> std : : string DebugCompilationDir ; <nl> + std : : map < const std : : string , const std : : string > DebugPrefixMap ; <nl> llvm : : DebugCompressionType CompressDebugSections = <nl> llvm : : DebugCompressionType : : None ; <nl> std : : string MainFileName ; <nl> + std : : string SplitDwarfFile ; <nl> <nl> / / / @ } <nl> / / / @ name Frontend Options <nl> bool AssemblerInvocation : : CreateFromArgs ( AssemblerInvocation & Opts , <nl> Opts . DebugCompilationDir = Args . getLastArgValue ( OPT_fdebug_compilation_dir ) ; <nl> Opts . MainFileName = Args . getLastArgValue ( OPT_main_file_name ) ; <nl> <nl> + for ( const auto & Arg : Args . getAllArgValues ( OPT_fdebug_prefix_map_EQ ) ) <nl> + Opts . DebugPrefixMap . insert ( StringRef ( Arg ) . split ( ' = ' ) ) ; <nl> + <nl> / / Frontend Options <nl> if ( Args . hasArg ( OPT_INPUT ) ) { <nl> bool First = true ; <nl> bool AssemblerInvocation : : CreateFromArgs ( AssemblerInvocation & Opts , <nl> } <nl> Opts . LLVMArgs = Args . getAllArgValues ( OPT_mllvm ) ; <nl> Opts . OutputPath = Args . getLastArgValue ( OPT_o ) ; <nl> + Opts . SplitDwarfFile = Args . getLastArgValue ( OPT_split_dwarf_file ) ; <nl> if ( Arg * A = Args . getLastArg ( OPT_filetype ) ) { <nl> StringRef Name = A - > getValue ( ) ; <nl> unsigned OutputType = StringSwitch < unsigned > ( Name ) <nl> bool AssemblerInvocation : : CreateFromArgs ( AssemblerInvocation & Opts , <nl> } <nl> <nl> static std : : unique_ptr < raw_fd_ostream > <nl> - getOutputStream ( AssemblerInvocation & Opts , DiagnosticsEngine & Diags , <nl> - bool Binary ) { <nl> - if ( Opts . OutputPath . empty ( ) ) <nl> - Opts . OutputPath = " - " ; <nl> - <nl> + getOutputStream ( StringRef Path , DiagnosticsEngine & Diags , bool Binary ) { <nl> / / Make sure that the Out file gets unlinked from the disk if we get a <nl> / / SIGINT . <nl> - if ( Opts . OutputPath ! = " - " ) <nl> - sys : : RemoveFileOnSignal ( Opts . OutputPath ) ; <nl> + if ( Path ! = " - " ) <nl> + sys : : RemoveFileOnSignal ( Path ) ; <nl> <nl> std : : error_code EC ; <nl> auto Out = llvm : : make_unique < raw_fd_ostream > ( <nl> - Opts . OutputPath , EC , ( Binary ? sys : : fs : : F_None : sys : : fs : : F_Text ) ) ; <nl> + Path , EC , ( Binary ? sys : : fs : : F_None : sys : : fs : : F_Text ) ) ; <nl> if ( EC ) { <nl> - Diags . Report ( diag : : err_fe_unable_to_open_output ) < < Opts . OutputPath <nl> - < < EC . message ( ) ; <nl> + Diags . Report ( diag : : err_fe_unable_to_open_output ) < < Path < < EC . message ( ) ; <nl> return nullptr ; <nl> } <nl> <nl> static bool ExecuteAssembler ( AssemblerInvocation & Opts , <nl> MAI - > setRelaxELFRelocations ( Opts . RelaxELFRelocations ) ; <nl> <nl> bool IsBinary = Opts . OutputType = = AssemblerInvocation : : FT_Obj ; <nl> - std : : unique_ptr < raw_fd_ostream > FDOS = getOutputStream ( Opts , Diags , IsBinary ) ; <nl> + if ( Opts . OutputPath . empty ( ) ) <nl> + Opts . OutputPath = " - " ; <nl> + std : : unique_ptr < raw_fd_ostream > FDOS = <nl> + getOutputStream ( Opts . OutputPath , Diags , IsBinary ) ; <nl> if ( ! FDOS ) <nl> return true ; <nl> + std : : unique_ptr < raw_fd_ostream > DwoOS ; <nl> + if ( ! Opts . SplitDwarfFile . empty ( ) ) <nl> + DwoOS = getOutputStream ( Opts . SplitDwarfFile , Diags , IsBinary ) ; <nl> <nl> / / FIXME : This is not pretty . MCContext has a ptr to MCObjectFileInfo and <nl> / / MCObjectFileInfo needs a MCContext reference in order to initialize itself . <nl> static bool ExecuteAssembler ( AssemblerInvocation & Opts , <nl> Ctx . setDwarfDebugProducer ( StringRef ( Opts . DwarfDebugProducer ) ) ; <nl> if ( ! Opts . DebugCompilationDir . empty ( ) ) <nl> Ctx . setCompilationDir ( Opts . DebugCompilationDir ) ; <nl> + if ( ! Opts . DebugPrefixMap . empty ( ) ) <nl> + for ( const auto & KV : Opts . DebugPrefixMap ) <nl> + Ctx . addDebugPrefixMapEntry ( KV . first , KV . second ) ; <nl> if ( ! Opts . MainFileName . empty ( ) ) <nl> Ctx . setMainFileName ( StringRef ( Opts . MainFileName ) ) ; <nl> Ctx . setDwarfVersion ( Opts . DwarfVersion ) ; <nl> static bool ExecuteAssembler ( AssemblerInvocation & Opts , <nl> MCTargetOptions MCOptions ; <nl> std : : unique_ptr < MCAsmBackend > MAB ( <nl> TheTarget - > createMCAsmBackend ( * STI , * MRI , MCOptions ) ) ; <nl> + std : : unique_ptr < MCObjectWriter > OW = <nl> + DwoOS ? MAB - > createDwoObjectWriter ( * Out , * DwoOS ) <nl> + : MAB - > createObjectWriter ( * Out ) ; <nl> <nl> Triple T ( Opts . Triple ) ; <nl> Str . reset ( TheTarget - > createMCObjectStreamer ( <nl> - T , Ctx , std : : move ( MAB ) , * Out , std : : move ( CE ) , * STI , Opts . RelaxAll , <nl> - Opts . IncrementalLinkerCompatible , <nl> + T , Ctx , std : : move ( MAB ) , std : : move ( OW ) , std : : move ( CE ) , * STI , <nl> + Opts . RelaxAll , Opts . IncrementalLinkerCompatible , <nl> / * DWARFMustBeAtTheEnd * / true ) ) ; <nl> Str . get ( ) - > InitSections ( Opts . NoExecStack ) ; <nl> } <nl> static bool ExecuteAssembler ( AssemblerInvocation & Opts , <nl> auto Pair = StringRef ( S ) . split ( ' = ' ) ; <nl> auto Sym = Pair . first ; <nl> auto Val = Pair . second ; <nl> - int64_t Value ; <nl> + int64_t Value = 1 ; <nl> / / We have already error checked this in the driver . <nl> Val . getAsInteger ( 0 , Value ) ; <nl> Ctx . setSymbolValue ( Parser - > getStreamer ( ) , Sym , Value ) ; <nl> static bool ExecuteAssembler ( AssemblerInvocation & Opts , <nl> FDOS . reset ( ) ; <nl> <nl> / / Delete output file if there were errors . <nl> - if ( Failed & & Opts . OutputPath ! = " - " ) <nl> - sys : : fs : : remove ( Opts . OutputPath ) ; <nl> + if ( Failed ) { <nl> + if ( Opts . OutputPath ! = " - " ) <nl> + sys : : fs : : remove ( Opts . OutputPath ) ; <nl> + if ( ! Opts . SplitDwarfFile . empty ( ) & & Opts . SplitDwarfFile ! = " - " ) <nl> + sys : : fs : : remove ( Opts . SplitDwarfFile ) ; <nl> + } <nl> <nl> return Failed ; <nl> } <nl> <nl> static void LLVMErrorHandler ( void * UserData , const std : : string & Message , <nl> - bool / * GenCrashDiag * / ) { <nl> + bool GenCrashDiag ) { <nl> DiagnosticsEngine & Diags = * static_cast < DiagnosticsEngine * > ( UserData ) ; <nl> <nl> Diags . Report ( diag : : err_fe_error_backend ) < < Message ; <nl> static void LLVMErrorHandler ( void * UserData , const std : : string & Message , <nl> exit ( 1 ) ; <nl> } <nl> <nl> - int cc1as_main ( ArrayRef < const char * > Argv , const char * / * Argv0 * / , void * / * MainAddr * / ) { <nl> + int cc1as_main ( ArrayRef < const char * > Argv , const char * Argv0 , void * MainAddr ) { <nl> / / Initialize targets and assembly printers / parsers . <nl> InitializeAllTargetInfos ( ) ; <nl> InitializeAllTargetMCs ( ) ; <nl> new file mode 100644 <nl> index 00000000000 . . a4c034d8d35 <nl> mmm / dev / null <nl> ppp b / dbms / programs / clang / Compiler - 7 . 0 . 0 / cc1gen_reproducer_main . cpp <nl> <nl> + / / = = = - - cc1gen_reproducer_main . cpp - Clang reproducer generator mmmmmmmmm - = = = / / <nl> + / / <nl> + / / The LLVM Compiler Infrastructure <nl> + / / <nl> + / / This file is distributed under the University of Illinois Open Source <nl> + / / License . See LICENSE . TXT for details . <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + / / <nl> + / / This is the entry point to the clang - cc1gen - reproducer functionality , which <nl> + / / generates reproducers for invocations for clang - based tools . <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + <nl> + # include " clang / Basic / Diagnostic . h " <nl> + # include " clang / Basic / LLVM . h " <nl> + # include " clang / Basic / VirtualFileSystem . h " <nl> + # include " clang / Driver / Compilation . h " <nl> + # include " clang / Driver / Driver . h " <nl> + # include " llvm / ADT / ArrayRef . h " <nl> + # include " llvm / ADT / STLExtras . h " <nl> + # include " llvm / Support / FileSystem . h " <nl> + # include " llvm / Support / TargetSelect . h " <nl> + # include " llvm / Support / YAMLTraits . h " <nl> + # include " llvm / Support / raw_ostream . h " <nl> + <nl> + using namespace clang ; <nl> + <nl> + namespace { <nl> + <nl> + struct UnsavedFileHash { <nl> + std : : string Name ; <nl> + std : : string MD5 ; <nl> + } ; <nl> + <nl> + struct ClangInvocationInfo { <nl> + std : : string Toolchain ; <nl> + std : : string LibclangOperation ; <nl> + std : : string LibclangOptions ; <nl> + std : : vector < std : : string > Arguments ; <nl> + std : : vector < std : : string > InvocationArguments ; <nl> + std : : vector < UnsavedFileHash > UnsavedFileHashes ; <nl> + bool Dump = false ; <nl> + } ; <nl> + <nl> + } / / end anonymous namespace <nl> + <nl> + LLVM_YAML_IS_SEQUENCE_VECTOR ( UnsavedFileHash ) <nl> + <nl> + namespace llvm { <nl> + namespace yaml { <nl> + <nl> + template < > struct MappingTraits < UnsavedFileHash > { <nl> + static void mapping ( IO & IO , UnsavedFileHash & Info ) { <nl> + IO . mapRequired ( " name " , Info . Name ) ; <nl> + IO . mapRequired ( " md5 " , Info . MD5 ) ; <nl> + } <nl> + } ; <nl> + <nl> + template < > struct MappingTraits < ClangInvocationInfo > { <nl> + static void mapping ( IO & IO , ClangInvocationInfo & Info ) { <nl> + IO . mapRequired ( " toolchain " , Info . Toolchain ) ; <nl> + IO . mapOptional ( " libclang . operation " , Info . LibclangOperation ) ; <nl> + IO . mapOptional ( " libclang . opts " , Info . LibclangOptions ) ; <nl> + IO . mapRequired ( " args " , Info . Arguments ) ; <nl> + IO . mapOptional ( " invocation - args " , Info . InvocationArguments ) ; <nl> + IO . mapOptional ( " unsaved_file_hashes " , Info . UnsavedFileHashes ) ; <nl> + } <nl> + } ; <nl> + <nl> + } / / end namespace yaml <nl> + } / / end namespace llvm <nl> + <nl> + static std : : string generateReproducerMetaInfo ( const ClangInvocationInfo & Info ) { <nl> + std : : string Result ; <nl> + llvm : : raw_string_ostream OS ( Result ) ; <nl> + OS < < ' { ' ; <nl> + bool NeedComma = false ; <nl> + auto EmitKey = [ & ] ( StringRef Key ) { <nl> + if ( NeedComma ) <nl> + OS < < " , " ; <nl> + NeedComma = true ; <nl> + OS < < ' " ' < < Key < < " \ " : " ; <nl> + } ; <nl> + auto EmitStringKey = [ & ] ( StringRef Key , StringRef Value ) { <nl> + if ( Value . empty ( ) ) <nl> + return ; <nl> + EmitKey ( Key ) ; <nl> + OS < < ' " ' < < Value < < ' " ' ; <nl> + } ; <nl> + EmitStringKey ( " libclang . operation " , Info . LibclangOperation ) ; <nl> + EmitStringKey ( " libclang . opts " , Info . LibclangOptions ) ; <nl> + if ( ! Info . InvocationArguments . empty ( ) ) { <nl> + EmitKey ( " invocation - args " ) ; <nl> + OS < < ' [ ' ; <nl> + for ( const auto & Arg : llvm : : enumerate ( Info . InvocationArguments ) ) { <nl> + if ( Arg . index ( ) ) <nl> + OS < < ' , ' ; <nl> + OS < < ' " ' < < Arg . value ( ) < < ' " ' ; <nl> + } <nl> + OS < < ' ] ' ; <nl> + } <nl> + OS < < ' } ' ; <nl> + / / FIXME : Compare unsaved file hashes and report mismatch in the reproducer . <nl> + if ( Info . Dump ) <nl> + llvm : : outs ( ) < < " REPRODUCER METAINFO : " < < OS . str ( ) < < " \ n " ; <nl> + return std : : move ( OS . str ( ) ) ; <nl> + } <nl> + <nl> + / / / Generates a reproducer for a set of arguments from a specific invocation . <nl> + static llvm : : Optional < driver : : Driver : : CompilationDiagnosticReport > <nl> + generateReproducerForInvocationArguments ( ArrayRef < const char * > Argv , <nl> + const ClangInvocationInfo & Info ) { <nl> + using namespace driver ; <nl> + auto TargetAndMode = ToolChain : : getTargetAndModeFromProgramName ( Argv [ 0 ] ) ; <nl> + <nl> + IntrusiveRefCntPtr < DiagnosticOptions > DiagOpts = new DiagnosticOptions ; <nl> + <nl> + IntrusiveRefCntPtr < DiagnosticIDs > DiagID ( new DiagnosticIDs ( ) ) ; <nl> + DiagnosticsEngine Diags ( DiagID , & * DiagOpts , new IgnoringDiagConsumer ( ) ) ; <nl> + ProcessWarningOptions ( Diags , * DiagOpts , / * ReportDiags = * / false ) ; <nl> + Driver TheDriver ( Argv [ 0 ] , llvm : : sys : : getDefaultTargetTriple ( ) , Diags ) ; <nl> + TheDriver . setTargetAndMode ( TargetAndMode ) ; <nl> + <nl> + std : : unique_ptr < Compilation > C ( TheDriver . BuildCompilation ( Argv ) ) ; <nl> + if ( C & & ! C - > containsError ( ) ) { <nl> + for ( const auto & J : C - > getJobs ( ) ) { <nl> + if ( const Command * Cmd = dyn_cast < Command > ( & J ) ) { <nl> + Driver : : CompilationDiagnosticReport Report ; <nl> + TheDriver . generateCompilationDiagnostics ( <nl> + * C , * Cmd , generateReproducerMetaInfo ( Info ) , & Report ) ; <nl> + return Report ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + return None ; <nl> + } <nl> + <nl> + std : : string GetExecutablePath ( const char * Argv0 , bool CanonicalPrefixes ) ; <nl> + <nl> + static void printReproducerInformation ( <nl> + llvm : : raw_ostream & OS , const ClangInvocationInfo & Info , <nl> + const driver : : Driver : : CompilationDiagnosticReport & Report ) { <nl> + OS < < " REPRODUCER : \ n " ; <nl> + OS < < " { \ n " ; <nl> + OS < < R " ( " files " : [ ) " ; <nl> + for ( const auto & File : llvm : : enumerate ( Report . TemporaryFiles ) ) { <nl> + if ( File . index ( ) ) <nl> + OS < < ' , ' ; <nl> + OS < < ' " ' < < File . value ( ) < < ' " ' ; <nl> + } <nl> + OS < < " ] \ n } \ n " ; <nl> + } <nl> + <nl> + int cc1gen_reproducer_main ( ArrayRef < const char * > Argv , const char * Argv0 , <nl> + void * MainAddr ) { <nl> + if ( Argv . size ( ) < 1 ) { <nl> + llvm : : errs ( ) < < " error : missing invocation file \ n " ; <nl> + return 1 ; <nl> + } <nl> + / / Parse the invocation descriptor . <nl> + StringRef Input = Argv [ 0 ] ; <nl> + llvm : : ErrorOr < std : : unique_ptr < llvm : : MemoryBuffer > > Buffer = <nl> + llvm : : MemoryBuffer : : getFile ( Input ) ; <nl> + if ( ! Buffer ) { <nl> + llvm : : errs ( ) < < " error : failed to read " < < Input < < " : " <nl> + < < Buffer . getError ( ) . message ( ) < < " \ n " ; <nl> + return 1 ; <nl> + } <nl> + llvm : : yaml : : Input YAML ( Buffer . get ( ) - > getBuffer ( ) ) ; <nl> + ClangInvocationInfo InvocationInfo ; <nl> + YAML > > InvocationInfo ; <nl> + if ( Argv . size ( ) > 1 & & Argv [ 1 ] = = StringRef ( " - v " ) ) <nl> + InvocationInfo . Dump = true ; <nl> + <nl> + / / Create an invocation that will produce the reproducer . <nl> + std : : vector < const char * > DriverArgs ; <nl> + for ( const auto & Arg : InvocationInfo . Arguments ) <nl> + DriverArgs . push_back ( Arg . c_str ( ) ) ; <nl> + std : : string Path = GetExecutablePath ( Argv0 , / * CanonicalPrefixes = * / true ) ; <nl> + DriverArgs [ 0 ] = Path . c_str ( ) ; <nl> + llvm : : Optional < driver : : Driver : : CompilationDiagnosticReport > Report = <nl> + generateReproducerForInvocationArguments ( DriverArgs , InvocationInfo ) ; <nl> + <nl> + / / Emit the information about the reproduce files to stdout . <nl> + int Result = 1 ; <nl> + if ( Report ) { <nl> + printReproducerInformation ( llvm : : outs ( ) , InvocationInfo , * Report ) ; <nl> + Result = 0 ; <nl> + } <nl> + <nl> + / / Remove the input file . <nl> + llvm : : sys : : fs : : remove ( Input ) ; <nl> + return Result ; <nl> + } <nl> mmm a / dbms / programs / clang / Compiler - 7 . 0 . 0 / driver . cpp <nl> ppp b / dbms / programs / clang / Compiler - 7 . 0 . 0 / driver . cpp <nl> static int ExecuteCC1Tool ( ArrayRef < const char * > argv , StringRef Tool ) { <nl> return cc1_main ( argv . slice ( 2 ) , argv [ 0 ] , GetExecutablePathVP ) ; <nl> if ( Tool = = " as " ) <nl> return cc1as_main ( argv . slice ( 2 ) , argv [ 0 ] , GetExecutablePathVP ) ; <nl> + if ( Tool = = " gen - reproducer " ) <nl> + return cc1gen_reproducer_main ( argv . slice ( 2 ) , argv [ 0 ] , GetExecutablePathVP ) ; <nl> <nl> / / Reject unknown tools . <nl> llvm : : errs ( ) < < " error : unknown integrated tool ' " < < Tool < < " ' . " <nl> static int ExecuteCC1Tool ( ArrayRef < const char * > argv , StringRef Tool ) { <nl> return 1 ; <nl> } <nl> <nl> - int mainEntryClickHouseClang ( int argc_ , char * * argv_ ) { <nl> + int mainEntryClickHouseClang ( int argc_ , / * const * / char * * argv_ ) { <nl> llvm : : InitLLVM X ( argc_ , argv_ ) ; <nl> SmallVector < const char * , 256 > argv ( argv_ , argv_ + argc_ ) ; <nl> <nl> mmm a / dbms / programs / clang / Compiler - 7 . 0 . 0 / lld . cpp <nl> ppp b / dbms / programs / clang / Compiler - 7 . 0 . 0 / lld . cpp <nl> <nl> + / / = = = - tools / lld / lld . cpp - Linker Driver Dispatcher mmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> + / / <nl> + / / The LLVM Linker <nl> + / / <nl> + / / This file is distributed under the University of Illinois Open Source <nl> + / / License . See LICENSE . TXT for details . <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + / / <nl> + / / This file contains the main function of the lld executable . The main <nl> + / / function is a thin wrapper which dispatches to the platform specific <nl> + / / driver . <nl> + / / <nl> + / / lld is a single executable that contains four different linkers for ELF , <nl> + / / COFF , WebAssembly and Mach - O . The main function dispatches according to <nl> + / / argv [ 0 ] ( i . e . command name ) . The most common name for each target is shown <nl> + / / below : <nl> + / / <nl> + / / - ld . lld : ELF ( Unix ) <nl> + / / - ld64 : Mach - O ( macOS ) <nl> + / / - lld - link : COFF ( Windows ) <nl> + / / - ld - wasm : WebAssembly <nl> + / / <nl> + / / lld can be invoked as " lld " along with " - flavor " option . This is for <nl> + / / backward compatibility and not recommended . <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + <nl> # include " lld / Common / Driver . h " <nl> + # include " llvm / ADT / STLExtras . h " <nl> + # include " llvm / ADT / StringSwitch . h " <nl> + # include " llvm / ADT / Twine . h " <nl> # include " llvm / Support / InitLLVM . h " <nl> - # include < vector > <nl> + # include " llvm / Support / Path . h " <nl> + # include < cstdlib > <nl> + using namespace lld ; <nl> + using namespace llvm ; <nl> + using namespace llvm : : sys ; <nl> + <nl> + / * <nl> + <nl> + enum Flavor { <nl> + Invalid , <nl> + Gnu , / / - flavor gnu <nl> + WinLink , / / - flavor link <nl> + Darwin , / / - flavor darwin <nl> + Wasm , / / - flavor wasm <nl> + } ; <nl> + <nl> + LLVM_ATTRIBUTE_NORETURN static void die ( const Twine & S ) { <nl> + errs ( ) < < S < < " \ n " ; <nl> + exit ( 1 ) ; <nl> + } <nl> + <nl> + static Flavor getFlavor ( StringRef S ) { <nl> + return StringSwitch < Flavor > ( S ) <nl> + . CasesLower ( " ld " , " ld . lld " , " gnu " , Gnu ) <nl> + . CasesLower ( " wasm " , " ld - wasm " , Wasm ) <nl> + . CaseLower ( " link " , WinLink ) <nl> + . CasesLower ( " ld64 " , " ld64 . lld " , " darwin " , Darwin ) <nl> + . Default ( Invalid ) ; <nl> + } <nl> + <nl> + static bool isPETarget ( const std : : vector < const char * > & V ) { <nl> + for ( auto It = V . begin ( ) ; It + 1 ! = V . end ( ) ; + + It ) { <nl> + if ( StringRef ( * It ) ! = " - m " ) <nl> + continue ; <nl> + StringRef S = * ( It + 1 ) ; <nl> + return S = = " i386pe " | | S = = " i386pep " | | S = = " thumb2pe " | | S = = " arm64pe " ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + static Flavor parseProgname ( StringRef Progname ) { <nl> + # if __APPLE__ <nl> + / / Use Darwin driver for " ld " on Darwin . <nl> + if ( Progname = = " ld " ) <nl> + return Darwin ; <nl> + # endif <nl> + <nl> + # if LLVM_ON_UNIX <nl> + / / Use GNU driver for " ld " on other Unix - like system . <nl> + if ( Progname = = " ld " ) <nl> + return Gnu ; <nl> + # endif <nl> + <nl> + / / Progname may be something like " lld - gnu " . Parse it . <nl> + SmallVector < StringRef , 3 > V ; <nl> + Progname . split ( V , " - " ) ; <nl> + for ( StringRef S : V ) <nl> + if ( Flavor F = getFlavor ( S ) ) <nl> + return F ; <nl> + return Invalid ; <nl> + } <nl> + <nl> + static Flavor parseFlavor ( std : : vector < const char * > & V ) { <nl> + / / Parse - flavor option . <nl> + if ( V . size ( ) > 1 & & V [ 1 ] = = StringRef ( " - flavor " ) ) { <nl> + if ( V . size ( ) < = 2 ) <nl> + die ( " missing arg value for ' - flavor ' " ) ; <nl> + Flavor F = getFlavor ( V [ 2 ] ) ; <nl> + if ( F = = Invalid ) <nl> + die ( " Unknown flavor : " + StringRef ( V [ 2 ] ) ) ; <nl> + V . erase ( V . begin ( ) + 1 , V . begin ( ) + 3 ) ; <nl> + return F ; <nl> + } <nl> + <nl> + / / Deduct the flavor from argv [ 0 ] . <nl> + StringRef Arg0 = path : : filename ( V [ 0 ] ) ; <nl> + if ( Arg0 . endswith_lower ( " . exe " ) ) <nl> + Arg0 = Arg0 . drop_back ( 4 ) ; <nl> + return parseProgname ( Arg0 ) ; <nl> + } <nl> + * / <nl> + <nl> + / / If this function returns true , lld calls _exit ( ) so that it quickly <nl> + / / exits without invoking destructors of globally allocated objects . <nl> + / / <nl> + / / We don ' t want to do that if we are running tests though , because <nl> + / / doing that breaks leak sanitizer . So , lit sets this environment variable , <nl> + / / and we use it to detect whether we are running tests or not . <nl> + static bool canExitEarly ( ) { return StringRef ( getenv ( " LLD_IN_TEST " ) ) ! = " 1 " ; } <nl> + <nl> + / / / Universal linker main ( ) . This linker emulates the gnu , darwin , or <nl> + / / / windows linker based on the argv [ 0 ] or - flavor option . <nl> + int mainEntryClickHouseLLD ( int Argc , / * const * / char * * Argv ) { <nl> + InitLLVM X ( Argc , Argv ) ; <nl> <nl> - int mainEntryClickHouseLLD ( int argc , char * * argv ) <nl> - { <nl> - llvm : : InitLLVM X ( argc , argv ) ; <nl> - std : : vector < const char * > args ( argv , argv + argc ) ; <nl> - return ! lld : : elf : : link ( args , false ) ; <nl> + std : : vector < const char * > Args ( Argv , Argv + Argc ) ; <nl> + / * <nl> + switch ( parseFlavor ( Args ) ) { <nl> + case Gnu : <nl> + if ( isPETarget ( Args ) ) <nl> + return ! mingw : : link ( Args ) ; <nl> + * / <nl> + return ! elf : : link ( Args , canExitEarly ( ) ) ; <nl> + / * <nl> + case WinLink : <nl> + return ! coff : : link ( Args , canExitEarly ( ) ) ; <nl> + case Darwin : <nl> + return ! mach_o : : link ( Args , canExitEarly ( ) ) ; <nl> + case Wasm : <nl> + return ! wasm : : link ( Args , canExitEarly ( ) ) ; <nl> + default : <nl> + die ( " lld is a generic driver . \ n " <nl> + " Invoke ld . lld ( Unix ) , ld64 . lld ( macOS ) , lld - link ( Windows ) , wasm - lld " <nl> + " ( WebAssembly ) instead " ) ; <nl> + } <nl> + * / <nl> } <nl> deleted file mode 120000 <nl> index eeeb5bbc2c0 . . 00000000000 <nl> mmm a / dbms / programs / clang / Compiler - 7 . 0 . 0bundled <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - Compiler - 7 . 0 . 0 <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 00000000000 . . d0ccc8d672c <nl> mmm / dev / null <nl> ppp b / dbms / programs / clang / Compiler - 7 . 0 . 0bundled / CMakeLists . txt <nl> <nl> + add_definitions ( - Wno - error - Wno - unused - parameter - Wno - non - virtual - dtor - U_LIBCPP_DEBUG ) <nl> + <nl> + link_directories ( $ { LLVM_LIBRARY_DIRS } ) <nl> + <nl> + add_library ( clickhouse - compiler - lib $ { LINK_MODE } <nl> + driver . cpp <nl> + cc1_main . cpp <nl> + cc1as_main . cpp <nl> + lld . cpp ) <nl> + <nl> + target_compile_options ( clickhouse - compiler - lib PRIVATE - fno - rtti - fno - exceptions - g0 ) <nl> + <nl> + string ( REPLACE " $ { INCLUDE_DEBUG_HELPERS } " " " CMAKE_CXX_FLAGS $ { CMAKE_CXX_FLAGS } ) # cant compile with - fno - rtti <nl> + <nl> + llvm_libs_all ( REQUIRED_LLVM_LIBRARIES ) <nl> + <nl> + message ( STATUS " Using LLVM $ { LLVM_VERSION } : $ { LLVM_INCLUDE_DIRS } : $ { REQUIRED_LLVM_LIBRARIES } " ) <nl> + <nl> + target_include_directories ( clickhouse - compiler - lib SYSTEM PRIVATE $ { LLVM_INCLUDE_DIRS } ) <nl> + <nl> + # This is extracted almost directly from CMakeFiles / . . . / link . txt in LLVM build directory . <nl> + <nl> + target_link_libraries ( clickhouse - compiler - lib PRIVATE <nl> + <nl> + clangBasic clangCodeGen clangDriver <nl> + clangFrontend <nl> + clangFrontendTool <nl> + clangRewriteFrontend clangARCMigrate clangStaticAnalyzerFrontend <nl> + clangParse clangSerialization clangSema clangEdit clangStaticAnalyzerCheckers <nl> + clangASTMatchers clangStaticAnalyzerCore clangAnalysis clangAST clangRewrite clangLex clangBasic <nl> + clangCrossTU clangIndex <nl> + <nl> + lldCOFF <nl> + lldDriver <nl> + lldELF <nl> + lldMinGW <nl> + lldMachO <nl> + lldReaderWriter <nl> + lldYAML <nl> + lldCommon <nl> + lldCore <nl> + <nl> + $ { REQUIRED_LLVM_LIBRARIES } <nl> + <nl> + PUBLIC $ { ZLIB_LIBRARIES } $ { EXECINFO_LIBRARY } Threads : : Threads <nl> + $ { MALLOC_LIBRARIES } <nl> + $ { GLIBC_COMPATIBILITY_LIBRARIES } <nl> + $ { MEMCPY_LIBRARIES } <nl> + ) <nl> new file mode 100644 <nl> index 00000000000 . . 3686475dd42 <nl> mmm / dev / null <nl> ppp b / dbms / programs / clang / Compiler - 7 . 0 . 0bundled / cc1_main . cpp <nl> <nl> + / / = = = - - cc1_main . cpp - Clang CC1 Compiler Frontend mmmmmmmmmmmmmmmmmmmmmmmm = = = / / <nl> + / / <nl> + / / The LLVM Compiler Infrastructure <nl> + / / <nl> + / / This file is distributed under the University of Illinois Open Source <nl> + / / License . See LICENSE . TXT for details . <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + / / <nl> + / / This is the entry point to the clang - cc1 functionality , which implements the <nl> + / / core compiler functionality along with a number of additional tools for <nl> + / / demonstration and testing purposes . <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + <nl> + # include " llvm / Option / Arg . h " <nl> + # include " clang / CodeGen / ObjectFilePCHContainerOperations . h " <nl> + # include " clang / Config / config . h " <nl> + # include " clang / Driver / DriverDiagnostic . h " <nl> + # include " clang / Driver / Options . h " <nl> + # include " clang / Frontend / CompilerInstance . h " <nl> + # include " clang / Frontend / CompilerInvocation . h " <nl> + # include " clang / Frontend / FrontendDiagnostic . h " <nl> + # include " clang / Frontend / TextDiagnosticBuffer . h " <nl> + # include " clang / Frontend / TextDiagnosticPrinter . h " <nl> + # include " clang / Frontend / Utils . h " <nl> + # include " clang / FrontendTool / Utils . h " <nl> + # include " llvm / ADT / Statistic . h " <nl> + # include " llvm / Config / llvm - config . h " <nl> + # include " llvm / LinkAllPasses . h " <nl> + # include " llvm / Option / ArgList . h " <nl> + # include " llvm / Option / OptTable . h " <nl> + # include " llvm / Support / Compiler . h " <nl> + # include " llvm / Support / ErrorHandling . h " <nl> + # include " llvm / Support / ManagedStatic . h " <nl> + # include " llvm / Support / Signals . h " <nl> + # include " llvm / Support / TargetSelect . h " <nl> + # include " llvm / Support / Timer . h " <nl> + # include " llvm / Support / raw_ostream . h " <nl> + # include < cstdio > <nl> + <nl> + # ifdef CLANG_HAVE_RLIMITS <nl> + # include < sys / resource . h > <nl> + # endif <nl> + <nl> + / / have no . a version in packages <nl> + # undef LINK_POLLY_INTO_TOOLS <nl> + <nl> + using namespace clang ; <nl> + using namespace llvm : : opt ; <nl> + <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + / / Main driver <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + <nl> + static void LLVMErrorHandler ( void * UserData , const std : : string & Message , <nl> + bool GenCrashDiag ) { <nl> + DiagnosticsEngine & Diags = * static_cast < DiagnosticsEngine * > ( UserData ) ; <nl> + <nl> + Diags . Report ( diag : : err_fe_error_backend ) < < Message ; <nl> + <nl> + / / Run the interrupt handlers to make sure any special cleanups get done , in <nl> + / / particular that we remove files registered with RemoveFileOnSignal . <nl> + llvm : : sys : : RunInterruptHandlers ( ) ; <nl> + <nl> + / / We cannot recover from llvm errors . When reporting a fatal error , exit <nl> + / / with status 70 to generate crash diagnostics . For BSD systems this is <nl> + / / defined as an internal software error . Otherwise , exit with status 1 . <nl> + exit ( GenCrashDiag ? 70 : 1 ) ; <nl> + } <nl> + <nl> + # ifdef LINK_POLLY_INTO_TOOLS <nl> + namespace polly { <nl> + void initializePollyPasses ( llvm : : PassRegistry & Registry ) ; <nl> + } <nl> + # endif <nl> + <nl> + # ifdef CLANG_HAVE_RLIMITS <nl> + / / The amount of stack we think is " sufficient " . If less than this much is <nl> + / / available , we may be unable to reach our template instantiation depth <nl> + / / limit and other similar limits . <nl> + / / FIXME : Unify this with the stack we request when spawning a thread to build <nl> + / / a module . <nl> + static const int kSufficientStack = 8 < < 20 ; <nl> + <nl> + # if defined ( __linux__ ) & & defined ( __PIE__ ) <nl> + static size_t getCurrentStackAllocation ( ) { <nl> + / / If we can ' t compute the current stack usage , allow for 512K of command <nl> + / / line arguments and environment . <nl> + size_t Usage = 512 * 1024 ; <nl> + if ( FILE * StatFile = fopen ( " / proc / self / stat " , " r " ) ) { <nl> + / / We assume that the stack extends from its current address to the end of <nl> + / / the environment space . In reality , there is another string literal ( the <nl> + / / program name ) after the environment , but this is close enough ( we only <nl> + / / need to be within 100K or so ) . <nl> + unsigned long StackPtr , EnvEnd ; <nl> + / / Disable silly GCC - Wformat warning that complains about length <nl> + / / modifiers on ignored format specifiers . We want to retain these <nl> + / / for documentation purposes even though they have no effect . <nl> + # if defined ( __GNUC__ ) & & ! defined ( __clang__ ) <nl> + # pragma GCC diagnostic push <nl> + # pragma GCC diagnostic ignored " - Wformat " <nl> + # endif <nl> + if ( fscanf ( StatFile , <nl> + " % * d % * s % * c % * d % * d % * d % * d % * d % * u % * lu % * lu % * lu % * lu % * lu " <nl> + " % * lu % * ld % * ld % * ld % * ld % * ld % * ld % * llu % * lu % * ld % * lu % * lu " <nl> + " % * lu % * lu % lu % * lu % * lu % * lu % * lu % * lu % * llu % * lu % * lu % * d % * d " <nl> + " % * u % * u % * llu % * lu % * ld % * lu % * lu % * lu % * lu % * lu % * lu % lu % * d " , <nl> + & StackPtr , & EnvEnd ) = = 2 ) { <nl> + # if defined ( __GNUC__ ) & & ! defined ( __clang__ ) <nl> + # pragma GCC diagnostic pop <nl> + # endif <nl> + Usage = StackPtr < EnvEnd ? EnvEnd - StackPtr : StackPtr - EnvEnd ; <nl> + } <nl> + fclose ( StatFile ) ; <nl> + } <nl> + return Usage ; <nl> + } <nl> + <nl> + # include < alloca . h > <nl> + <nl> + LLVM_ATTRIBUTE_NOINLINE <nl> + static void ensureStackAddressSpace ( int ExtraChunks = 0 ) { <nl> + / / Linux kernels prior to 4 . 1 will sometimes locate the heap of a PIE binary <nl> + / / relatively close to the stack ( they are only guaranteed to be 128MiB <nl> + / / apart ) . This results in crashes if we happen to heap - allocate more than <nl> + / / 128MiB before we reach our stack high - water mark . <nl> + / / <nl> + / / To avoid these crashes , ensure that we have sufficient virtual memory <nl> + / / pages allocated before we start running . <nl> + size_t Curr = getCurrentStackAllocation ( ) ; <nl> + const int kTargetStack = kSufficientStack - 256 * 1024 ; <nl> + if ( Curr < kTargetStack ) { <nl> + volatile char * volatile Alloc = <nl> + static_cast < volatile char * > ( alloca ( kTargetStack - Curr ) ) ; <nl> + Alloc [ 0 ] = 0 ; <nl> + Alloc [ kTargetStack - Curr - 1 ] = 0 ; <nl> + } <nl> + } <nl> + # else <nl> + static void ensureStackAddressSpace ( ) { } <nl> + # endif <nl> + <nl> + / / / Attempt to ensure that we have at least 8MiB of usable stack space . <nl> + static void ensureSufficientStack ( ) { <nl> + struct rlimit rlim ; <nl> + if ( getrlimit ( RLIMIT_STACK , & rlim ) ! = 0 ) <nl> + return ; <nl> + <nl> + / / Increase the soft stack limit to our desired level , if necessary and <nl> + / / possible . <nl> + if ( rlim . rlim_cur ! = RLIM_INFINITY & & rlim . rlim_cur < kSufficientStack ) { <nl> + / / Try to allocate sufficient stack . <nl> + if ( rlim . rlim_max = = RLIM_INFINITY | | rlim . rlim_max > = kSufficientStack ) <nl> + rlim . rlim_cur = kSufficientStack ; <nl> + else if ( rlim . rlim_cur = = rlim . rlim_max ) <nl> + return ; <nl> + else <nl> + rlim . rlim_cur = rlim . rlim_max ; <nl> + <nl> + if ( setrlimit ( RLIMIT_STACK , & rlim ) ! = 0 | | <nl> + rlim . rlim_cur ! = kSufficientStack ) <nl> + return ; <nl> + } <nl> + <nl> + / / We should now have a stack of size at least kSufficientStack . Ensure <nl> + / / that we can actually use that much , if necessary . <nl> + ensureStackAddressSpace ( ) ; <nl> + } <nl> + # else <nl> + static void ensureSufficientStack ( ) { } <nl> + # endif <nl> + <nl> + int cc1_main ( ArrayRef < const char * > Argv , const char * Argv0 , void * MainAddr ) { <nl> + ensureSufficientStack ( ) ; <nl> + <nl> + std : : unique_ptr < CompilerInstance > Clang ( new CompilerInstance ( ) ) ; <nl> + IntrusiveRefCntPtr < DiagnosticIDs > DiagID ( new DiagnosticIDs ( ) ) ; <nl> + <nl> + / / Register the support for object - file - wrapped Clang modules . <nl> + auto PCHOps = Clang - > getPCHContainerOperations ( ) ; <nl> + PCHOps - > registerWriter ( llvm : : make_unique < ObjectFilePCHContainerWriter > ( ) ) ; <nl> + PCHOps - > registerReader ( llvm : : make_unique < ObjectFilePCHContainerReader > ( ) ) ; <nl> + <nl> + / / Initialize targets first , so that - - version shows registered targets . <nl> + llvm : : InitializeAllTargets ( ) ; <nl> + llvm : : InitializeAllTargetMCs ( ) ; <nl> + llvm : : InitializeAllAsmPrinters ( ) ; <nl> + llvm : : InitializeAllAsmParsers ( ) ; <nl> + <nl> + # ifdef LINK_POLLY_INTO_TOOLS <nl> + llvm : : PassRegistry & Registry = * llvm : : PassRegistry : : getPassRegistry ( ) ; <nl> + polly : : initializePollyPasses ( Registry ) ; <nl> + # endif <nl> + <nl> + / / Buffer diagnostics from argument parsing so that we can output them using a <nl> + / / well formed diagnostic object . <nl> + IntrusiveRefCntPtr < DiagnosticOptions > DiagOpts = new DiagnosticOptions ( ) ; <nl> + TextDiagnosticBuffer * DiagsBuffer = new TextDiagnosticBuffer ; <nl> + DiagnosticsEngine Diags ( DiagID , & * DiagOpts , DiagsBuffer ) ; <nl> + bool Success = CompilerInvocation : : CreateFromArgs ( <nl> + Clang - > getInvocation ( ) , Argv . begin ( ) , Argv . end ( ) , Diags ) ; <nl> + <nl> + / / Infer the builtin include path if unspecified . <nl> + if ( Clang - > getHeaderSearchOpts ( ) . UseBuiltinIncludes & & <nl> + Clang - > getHeaderSearchOpts ( ) . ResourceDir . empty ( ) ) <nl> + Clang - > getHeaderSearchOpts ( ) . ResourceDir = <nl> + CompilerInvocation : : GetResourcesPath ( Argv0 , MainAddr ) ; <nl> + <nl> + / / Create the actual diagnostics engine . <nl> + Clang - > createDiagnostics ( ) ; <nl> + if ( ! Clang - > hasDiagnostics ( ) ) <nl> + return 1 ; <nl> + <nl> + / / Set an error handler , so that any LLVM backend diagnostics go through our <nl> + / / error handler . <nl> + llvm : : install_fatal_error_handler ( LLVMErrorHandler , <nl> + static_cast < void * > ( & Clang - > getDiagnostics ( ) ) ) ; <nl> + <nl> + DiagsBuffer - > FlushDiagnostics ( Clang - > getDiagnostics ( ) ) ; <nl> + if ( ! Success ) <nl> + return 1 ; <nl> + <nl> + / / Execute the frontend actions . <nl> + Success = ExecuteCompilerInvocation ( Clang . get ( ) ) ; <nl> + <nl> + / / If any timers were active but haven ' t been destroyed yet , print their <nl> + / / results now . This happens in - disable - free mode . <nl> + llvm : : TimerGroup : : printAll ( llvm : : errs ( ) ) ; <nl> + <nl> + / / Our error handler depends on the Diagnostics object , which we ' re <nl> + / / potentially about to delete . Uninstall the handler now so that any <nl> + / / later errors use the default handling behavior instead . <nl> + llvm : : remove_fatal_error_handler ( ) ; <nl> + <nl> + / / When running with - disable - free , don ' t do any destruction or shutdown . <nl> + if ( Clang - > getFrontendOpts ( ) . DisableFree ) { <nl> + BuryPointer ( std : : move ( Clang ) ) ; <nl> + return ! Success ; <nl> + } <nl> + <nl> + return ! Success ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . ce23422077f <nl> mmm / dev / null <nl> ppp b / dbms / programs / clang / Compiler - 7 . 0 . 0bundled / cc1as_main . cpp <nl> <nl> + / / = = = - - cc1as_main . cpp - Clang Assembler mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = = = / / <nl> + / / <nl> + / / The LLVM Compiler Infrastructure <nl> + / / <nl> + / / This file is distributed under the University of Illinois Open Source <nl> + / / License . See LICENSE . TXT for details . <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + / / <nl> + / / This is the entry point to the clang - cc1as functionality , which implements <nl> + / / the direct interface to the LLVM MC based assembler . <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + <nl> + # include " clang / Basic / Diagnostic . h " <nl> + # include " clang / Basic / DiagnosticOptions . h " <nl> + # include " clang / Driver / DriverDiagnostic . h " <nl> + # include " clang / Driver / Options . h " <nl> + # include " clang / Frontend / FrontendDiagnostic . h " <nl> + # include " clang / Frontend / TextDiagnosticPrinter . h " <nl> + # include " clang / Frontend / Utils . h " <nl> + # include " llvm / ADT / STLExtras . h " <nl> + # include " llvm / ADT / StringSwitch . h " <nl> + # include " llvm / ADT / Triple . h " <nl> + # include " llvm / IR / DataLayout . h " <nl> + # include " llvm / MC / MCAsmBackend . h " <nl> + # include " llvm / MC / MCAsmInfo . h " <nl> + # include " llvm / MC / MCCodeEmitter . h " <nl> + # include " llvm / MC / MCContext . h " <nl> + # include " llvm / MC / MCInstrInfo . h " <nl> + # include " llvm / MC / MCObjectFileInfo . h " <nl> + # include " llvm / MC / MCParser / MCAsmParser . h " <nl> + # include " llvm / MC / MCParser / MCTargetAsmParser . h " <nl> + # include " llvm / MC / MCRegisterInfo . h " <nl> + # include " llvm / MC / MCStreamer . h " <nl> + # include " llvm / MC / MCSubtargetInfo . h " <nl> + # include " llvm / MC / MCTargetOptions . h " <nl> + # include " llvm / Option / Arg . h " <nl> + # include " llvm / Option / ArgList . h " <nl> + # include " llvm / Option / OptTable . h " <nl> + # include " llvm / Support / CommandLine . h " <nl> + # include " llvm / Support / ErrorHandling . h " <nl> + # include " llvm / Support / FileSystem . h " <nl> + # include " llvm / Support / FormattedStream . h " <nl> + # include " llvm / Support / Host . h " <nl> + # include " llvm / Support / MemoryBuffer . h " <nl> + # include " llvm / Support / Path . h " <nl> + # include " llvm / Support / Signals . h " <nl> + # include " llvm / Support / SourceMgr . h " <nl> + # include " llvm / Support / TargetRegistry . h " <nl> + # include " llvm / Support / TargetSelect . h " <nl> + # include " llvm / Support / Timer . h " <nl> + # include " llvm / Support / raw_ostream . h " <nl> + # include < memory > <nl> + # include < system_error > <nl> + using namespace clang ; <nl> + using namespace clang : : driver ; <nl> + using namespace clang : : driver : : options ; <nl> + using namespace llvm ; <nl> + using namespace llvm : : opt ; <nl> + <nl> + <nl> + namespace { <nl> + <nl> + / / / \ brief Helper class for representing a single invocation of the assembler . <nl> + struct AssemblerInvocation { <nl> + / / / @ name Target Options <nl> + / / / @ { <nl> + <nl> + / / / The name of the target triple to assemble for . <nl> + std : : string Triple ; <nl> + <nl> + / / / If given , the name of the target CPU to determine which instructions <nl> + / / / are legal . <nl> + std : : string CPU ; <nl> + <nl> + / / / The list of target specific features to enable or disable - - this should <nl> + / / / be a list of strings starting with ' + ' or ' - ' . <nl> + std : : vector < std : : string > Features ; <nl> + <nl> + / / / The list of symbol definitions . <nl> + std : : vector < std : : string > SymbolDefs ; <nl> + <nl> + / / / @ } <nl> + / / / @ name Language Options <nl> + / / / @ { <nl> + <nl> + std : : vector < std : : string > IncludePaths ; <nl> + unsigned NoInitialTextSection : 1 ; <nl> + unsigned SaveTemporaryLabels : 1 ; <nl> + unsigned GenDwarfForAssembly : 1 ; <nl> + unsigned RelaxELFRelocations : 1 ; <nl> + unsigned DwarfVersion ; <nl> + std : : string DwarfDebugFlags ; <nl> + std : : string DwarfDebugProducer ; <nl> + std : : string DebugCompilationDir ; <nl> + llvm : : DebugCompressionType CompressDebugSections = <nl> + llvm : : DebugCompressionType : : None ; <nl> + std : : string MainFileName ; <nl> + <nl> + / / / @ } <nl> + / / / @ name Frontend Options <nl> + / / / @ { <nl> + <nl> + std : : string InputFile ; <nl> + std : : vector < std : : string > LLVMArgs ; <nl> + std : : string OutputPath ; <nl> + enum FileType { <nl> + FT_Asm , / / / < Assembly ( . s ) output , transliterate mode . <nl> + FT_Null , / / / < No output , for timing purposes . <nl> + FT_Obj / / / < Object file output . <nl> + } ; <nl> + FileType OutputType ; <nl> + unsigned ShowHelp : 1 ; <nl> + unsigned ShowVersion : 1 ; <nl> + <nl> + / / / @ } <nl> + / / / @ name Transliterate Options <nl> + / / / @ { <nl> + <nl> + unsigned OutputAsmVariant ; <nl> + unsigned ShowEncoding : 1 ; <nl> + unsigned ShowInst : 1 ; <nl> + <nl> + / / / @ } <nl> + / / / @ name Assembler Options <nl> + / / / @ { <nl> + <nl> + unsigned RelaxAll : 1 ; <nl> + unsigned NoExecStack : 1 ; <nl> + unsigned FatalWarnings : 1 ; <nl> + unsigned IncrementalLinkerCompatible : 1 ; <nl> + <nl> + / / / The name of the relocation model to use . <nl> + std : : string RelocationModel ; <nl> + <nl> + / / / @ } <nl> + <nl> + public : <nl> + AssemblerInvocation ( ) { <nl> + Triple = " " ; <nl> + NoInitialTextSection = 0 ; <nl> + InputFile = " - " ; <nl> + OutputPath = " - " ; <nl> + OutputType = FT_Asm ; <nl> + OutputAsmVariant = 0 ; <nl> + ShowInst = 0 ; <nl> + ShowEncoding = 0 ; <nl> + RelaxAll = 0 ; <nl> + NoExecStack = 0 ; <nl> + FatalWarnings = 0 ; <nl> + IncrementalLinkerCompatible = 0 ; <nl> + DwarfVersion = 0 ; <nl> + } <nl> + <nl> + static bool CreateFromArgs ( AssemblerInvocation & Res , <nl> + ArrayRef < const char * > Argv , <nl> + DiagnosticsEngine & Diags ) ; <nl> + } ; <nl> + <nl> + } <nl> + <nl> + bool AssemblerInvocation : : CreateFromArgs ( AssemblerInvocation & Opts , <nl> + ArrayRef < const char * > Argv , <nl> + DiagnosticsEngine & Diags ) { <nl> + bool Success = true ; <nl> + <nl> + / / Parse the arguments . <nl> + std : : unique_ptr < OptTable > OptTbl ( createDriverOptTable ( ) ) ; <nl> + <nl> + const unsigned IncludedFlagsBitmask = options : : CC1AsOption ; <nl> + unsigned MissingArgIndex , MissingArgCount ; <nl> + InputArgList Args = OptTbl - > ParseArgs ( Argv , MissingArgIndex , MissingArgCount , <nl> + IncludedFlagsBitmask ) ; <nl> + <nl> + / / Check for missing argument error . <nl> + if ( MissingArgCount ) { <nl> + Diags . Report ( diag : : err_drv_missing_argument ) <nl> + < < Args . getArgString ( MissingArgIndex ) < < MissingArgCount ; <nl> + Success = false ; <nl> + } <nl> + <nl> + / / Issue errors on unknown arguments . <nl> + for ( const Arg * A : Args . filtered ( OPT_UNKNOWN ) ) { <nl> + auto ArgString = A - > getAsString ( Args ) ; <nl> + std : : string Nearest ; <nl> + if ( OptTbl - > findNearest ( ArgString , Nearest , IncludedFlagsBitmask ) > 1 ) <nl> + Diags . Report ( diag : : err_drv_unknown_argument ) < < ArgString ; <nl> + else <nl> + Diags . Report ( diag : : err_drv_unknown_argument_with_suggestion ) <nl> + < < ArgString < < Nearest ; <nl> + Success = false ; <nl> + } <nl> + <nl> + / / Construct the invocation . <nl> + <nl> + / / Target Options <nl> + Opts . Triple = llvm : : Triple : : normalize ( Args . getLastArgValue ( OPT_triple ) ) ; <nl> + Opts . CPU = Args . getLastArgValue ( OPT_target_cpu ) ; <nl> + Opts . Features = Args . getAllArgValues ( OPT_target_feature ) ; <nl> + <nl> + / / Use the default target triple if unspecified . <nl> + if ( Opts . Triple . empty ( ) ) <nl> + Opts . Triple = llvm : : sys : : getDefaultTargetTriple ( ) ; <nl> + <nl> + / / Language Options <nl> + Opts . IncludePaths = Args . getAllArgValues ( OPT_I ) ; <nl> + Opts . NoInitialTextSection = Args . hasArg ( OPT_n ) ; <nl> + Opts . SaveTemporaryLabels = Args . hasArg ( OPT_msave_temp_labels ) ; <nl> + / / Any DebugInfoKind implies GenDwarfForAssembly . <nl> + Opts . GenDwarfForAssembly = Args . hasArg ( OPT_debug_info_kind_EQ ) ; <nl> + <nl> + if ( const Arg * A = Args . getLastArg ( OPT_compress_debug_sections , <nl> + OPT_compress_debug_sections_EQ ) ) { <nl> + if ( A - > getOption ( ) . getID ( ) = = OPT_compress_debug_sections ) { <nl> + / / TODO : be more clever about the compression type auto - detection <nl> + Opts . CompressDebugSections = llvm : : DebugCompressionType : : GNU ; <nl> + } else { <nl> + Opts . CompressDebugSections = <nl> + llvm : : StringSwitch < llvm : : DebugCompressionType > ( A - > getValue ( ) ) <nl> + . Case ( " none " , llvm : : DebugCompressionType : : None ) <nl> + . Case ( " zlib " , llvm : : DebugCompressionType : : Z ) <nl> + . Case ( " zlib - gnu " , llvm : : DebugCompressionType : : GNU ) <nl> + . Default ( llvm : : DebugCompressionType : : None ) ; <nl> + } <nl> + } <nl> + <nl> + Opts . RelaxELFRelocations = Args . hasArg ( OPT_mrelax_relocations ) ; <nl> + Opts . DwarfVersion = getLastArgIntValue ( Args , OPT_dwarf_version_EQ , 2 , Diags ) ; <nl> + Opts . DwarfDebugFlags = Args . getLastArgValue ( OPT_dwarf_debug_flags ) ; <nl> + Opts . DwarfDebugProducer = Args . getLastArgValue ( OPT_dwarf_debug_producer ) ; <nl> + Opts . DebugCompilationDir = Args . getLastArgValue ( OPT_fdebug_compilation_dir ) ; <nl> + Opts . MainFileName = Args . getLastArgValue ( OPT_main_file_name ) ; <nl> + <nl> + / / Frontend Options <nl> + if ( Args . hasArg ( OPT_INPUT ) ) { <nl> + bool First = true ; <nl> + for ( const Arg * A : Args . filtered ( OPT_INPUT ) ) { <nl> + if ( First ) { <nl> + Opts . InputFile = A - > getValue ( ) ; <nl> + First = false ; <nl> + } else { <nl> + Diags . Report ( diag : : err_drv_unknown_argument ) < < A - > getAsString ( Args ) ; <nl> + Success = false ; <nl> + } <nl> + } <nl> + } <nl> + Opts . LLVMArgs = Args . getAllArgValues ( OPT_mllvm ) ; <nl> + Opts . OutputPath = Args . getLastArgValue ( OPT_o ) ; <nl> + if ( Arg * A = Args . getLastArg ( OPT_filetype ) ) { <nl> + StringRef Name = A - > getValue ( ) ; <nl> + unsigned OutputType = StringSwitch < unsigned > ( Name ) <nl> + . Case ( " asm " , FT_Asm ) <nl> + . Case ( " null " , FT_Null ) <nl> + . Case ( " obj " , FT_Obj ) <nl> + . Default ( ~ 0U ) ; <nl> + if ( OutputType = = ~ 0U ) { <nl> + Diags . Report ( diag : : err_drv_invalid_value ) < < A - > getAsString ( Args ) < < Name ; <nl> + Success = false ; <nl> + } else <nl> + Opts . OutputType = FileType ( OutputType ) ; <nl> + } <nl> + Opts . ShowHelp = Args . hasArg ( OPT_help ) ; <nl> + Opts . ShowVersion = Args . hasArg ( OPT_version ) ; <nl> + <nl> + / / Transliterate Options <nl> + Opts . OutputAsmVariant = <nl> + getLastArgIntValue ( Args , OPT_output_asm_variant , 0 , Diags ) ; <nl> + Opts . ShowEncoding = Args . hasArg ( OPT_show_encoding ) ; <nl> + Opts . ShowInst = Args . hasArg ( OPT_show_inst ) ; <nl> + <nl> + / / Assemble Options <nl> + Opts . RelaxAll = Args . hasArg ( OPT_mrelax_all ) ; <nl> + Opts . NoExecStack = Args . hasArg ( OPT_mno_exec_stack ) ; <nl> + Opts . FatalWarnings = Args . hasArg ( OPT_massembler_fatal_warnings ) ; <nl> + Opts . RelocationModel = Args . getLastArgValue ( OPT_mrelocation_model , " pic " ) ; <nl> + Opts . IncrementalLinkerCompatible = <nl> + Args . hasArg ( OPT_mincremental_linker_compatible ) ; <nl> + Opts . SymbolDefs = Args . getAllArgValues ( OPT_defsym ) ; <nl> + <nl> + return Success ; <nl> + } <nl> + <nl> + static std : : unique_ptr < raw_fd_ostream > <nl> + getOutputStream ( AssemblerInvocation & Opts , DiagnosticsEngine & Diags , <nl> + bool Binary ) { <nl> + if ( Opts . OutputPath . empty ( ) ) <nl> + Opts . OutputPath = " - " ; <nl> + <nl> + / / Make sure that the Out file gets unlinked from the disk if we get a <nl> + / / SIGINT . <nl> + if ( Opts . OutputPath ! = " - " ) <nl> + sys : : RemoveFileOnSignal ( Opts . OutputPath ) ; <nl> + <nl> + std : : error_code EC ; <nl> + auto Out = llvm : : make_unique < raw_fd_ostream > ( <nl> + Opts . OutputPath , EC , ( Binary ? sys : : fs : : F_None : sys : : fs : : F_Text ) ) ; <nl> + if ( EC ) { <nl> + Diags . Report ( diag : : err_fe_unable_to_open_output ) < < Opts . OutputPath <nl> + < < EC . message ( ) ; <nl> + return nullptr ; <nl> + } <nl> + <nl> + return Out ; <nl> + } <nl> + <nl> + static bool ExecuteAssembler ( AssemblerInvocation & Opts , <nl> + DiagnosticsEngine & Diags ) { <nl> + / / Get the target specific parser . <nl> + std : : string Error ; <nl> + const Target * TheTarget = TargetRegistry : : lookupTarget ( Opts . Triple , Error ) ; <nl> + if ( ! TheTarget ) <nl> + return Diags . Report ( diag : : err_target_unknown_triple ) < < Opts . Triple ; <nl> + <nl> + ErrorOr < std : : unique_ptr < MemoryBuffer > > Buffer = <nl> + MemoryBuffer : : getFileOrSTDIN ( Opts . InputFile ) ; <nl> + <nl> + if ( std : : error_code EC = Buffer . getError ( ) ) { <nl> + Error = EC . message ( ) ; <nl> + return Diags . Report ( diag : : err_fe_error_reading ) < < Opts . InputFile ; <nl> + } <nl> + <nl> + SourceMgr SrcMgr ; <nl> + <nl> + / / Tell SrcMgr about this buffer , which is what the parser will pick up . <nl> + SrcMgr . AddNewSourceBuffer ( std : : move ( * Buffer ) , SMLoc ( ) ) ; <nl> + <nl> + / / Record the location of the include directories so that the lexer can find <nl> + / / it later . <nl> + SrcMgr . setIncludeDirs ( Opts . IncludePaths ) ; <nl> + <nl> + std : : unique_ptr < MCRegisterInfo > MRI ( TheTarget - > createMCRegInfo ( Opts . Triple ) ) ; <nl> + assert ( MRI & & " Unable to create target register info ! " ) ; <nl> + <nl> + std : : unique_ptr < MCAsmInfo > MAI ( TheTarget - > createMCAsmInfo ( * MRI , Opts . Triple ) ) ; <nl> + assert ( MAI & & " Unable to create target asm info ! " ) ; <nl> + <nl> + / / Ensure MCAsmInfo initialization occurs before any use , otherwise sections <nl> + / / may be created with a combination of default and explicit settings . <nl> + MAI - > setCompressDebugSections ( Opts . CompressDebugSections ) ; <nl> + <nl> + MAI - > setRelaxELFRelocations ( Opts . RelaxELFRelocations ) ; <nl> + <nl> + bool IsBinary = Opts . OutputType = = AssemblerInvocation : : FT_Obj ; <nl> + std : : unique_ptr < raw_fd_ostream > FDOS = getOutputStream ( Opts , Diags , IsBinary ) ; <nl> + if ( ! FDOS ) <nl> + return true ; <nl> + <nl> + / / FIXME : This is not pretty . MCContext has a ptr to MCObjectFileInfo and <nl> + / / MCObjectFileInfo needs a MCContext reference in order to initialize itself . <nl> + std : : unique_ptr < MCObjectFileInfo > MOFI ( new MCObjectFileInfo ( ) ) ; <nl> + <nl> + MCContext Ctx ( MAI . get ( ) , MRI . get ( ) , MOFI . get ( ) , & SrcMgr ) ; <nl> + <nl> + bool PIC = false ; <nl> + if ( Opts . RelocationModel = = " static " ) { <nl> + PIC = false ; <nl> + } else if ( Opts . RelocationModel = = " pic " ) { <nl> + PIC = true ; <nl> + } else { <nl> + assert ( Opts . RelocationModel = = " dynamic - no - pic " & & <nl> + " Invalid PIC model ! " ) ; <nl> + PIC = false ; <nl> + } <nl> + <nl> + MOFI - > InitMCObjectFileInfo ( Triple ( Opts . Triple ) , PIC , Ctx ) ; <nl> + if ( Opts . SaveTemporaryLabels ) <nl> + Ctx . setAllowTemporaryLabels ( false ) ; <nl> + if ( Opts . GenDwarfForAssembly ) <nl> + Ctx . setGenDwarfForAssembly ( true ) ; <nl> + if ( ! Opts . DwarfDebugFlags . empty ( ) ) <nl> + Ctx . setDwarfDebugFlags ( StringRef ( Opts . DwarfDebugFlags ) ) ; <nl> + if ( ! Opts . DwarfDebugProducer . empty ( ) ) <nl> + Ctx . setDwarfDebugProducer ( StringRef ( Opts . DwarfDebugProducer ) ) ; <nl> + if ( ! Opts . DebugCompilationDir . empty ( ) ) <nl> + Ctx . setCompilationDir ( Opts . DebugCompilationDir ) ; <nl> + if ( ! Opts . MainFileName . empty ( ) ) <nl> + Ctx . setMainFileName ( StringRef ( Opts . MainFileName ) ) ; <nl> + Ctx . setDwarfVersion ( Opts . DwarfVersion ) ; <nl> + <nl> + / / Build up the feature string from the target feature list . <nl> + std : : string FS ; <nl> + if ( ! Opts . Features . empty ( ) ) { <nl> + FS = Opts . Features [ 0 ] ; <nl> + for ( unsigned i = 1 , e = Opts . Features . size ( ) ; i ! = e ; + + i ) <nl> + FS + = " , " + Opts . Features [ i ] ; <nl> + } <nl> + <nl> + std : : unique_ptr < MCStreamer > Str ; <nl> + <nl> + std : : unique_ptr < MCInstrInfo > MCII ( TheTarget - > createMCInstrInfo ( ) ) ; <nl> + std : : unique_ptr < MCSubtargetInfo > STI ( <nl> + TheTarget - > createMCSubtargetInfo ( Opts . Triple , Opts . CPU , FS ) ) ; <nl> + <nl> + raw_pwrite_stream * Out = FDOS . get ( ) ; <nl> + std : : unique_ptr < buffer_ostream > BOS ; <nl> + <nl> + / / FIXME : There is a bit of code duplication with addPassesToEmitFile . <nl> + if ( Opts . OutputType = = AssemblerInvocation : : FT_Asm ) { <nl> + MCInstPrinter * IP = TheTarget - > createMCInstPrinter ( <nl> + llvm : : Triple ( Opts . Triple ) , Opts . OutputAsmVariant , * MAI , * MCII , * MRI ) ; <nl> + <nl> + std : : unique_ptr < MCCodeEmitter > CE ; <nl> + if ( Opts . ShowEncoding ) <nl> + CE . reset ( TheTarget - > createMCCodeEmitter ( * MCII , * MRI , Ctx ) ) ; <nl> + MCTargetOptions MCOptions ; <nl> + std : : unique_ptr < MCAsmBackend > MAB ( <nl> + TheTarget - > createMCAsmBackend ( * STI , * MRI , MCOptions ) ) ; <nl> + <nl> + auto FOut = llvm : : make_unique < formatted_raw_ostream > ( * Out ) ; <nl> + Str . reset ( TheTarget - > createAsmStreamer ( <nl> + Ctx , std : : move ( FOut ) , / * asmverbose * / true , <nl> + / * useDwarfDirectory * / true , IP , std : : move ( CE ) , std : : move ( MAB ) , <nl> + Opts . ShowInst ) ) ; <nl> + } else if ( Opts . OutputType = = AssemblerInvocation : : FT_Null ) { <nl> + Str . reset ( createNullStreamer ( Ctx ) ) ; <nl> + } else { <nl> + assert ( Opts . OutputType = = AssemblerInvocation : : FT_Obj & & <nl> + " Invalid file type ! " ) ; <nl> + if ( ! FDOS - > supportsSeeking ( ) ) { <nl> + BOS = make_unique < buffer_ostream > ( * FDOS ) ; <nl> + Out = BOS . get ( ) ; <nl> + } <nl> + <nl> + std : : unique_ptr < MCCodeEmitter > CE ( <nl> + TheTarget - > createMCCodeEmitter ( * MCII , * MRI , Ctx ) ) ; <nl> + MCTargetOptions MCOptions ; <nl> + std : : unique_ptr < MCAsmBackend > MAB ( <nl> + TheTarget - > createMCAsmBackend ( * STI , * MRI , MCOptions ) ) ; <nl> + <nl> + Triple T ( Opts . Triple ) ; <nl> + Str . reset ( TheTarget - > createMCObjectStreamer ( <nl> + T , Ctx , std : : move ( MAB ) , * Out , std : : move ( CE ) , * STI , Opts . RelaxAll , <nl> + Opts . IncrementalLinkerCompatible , <nl> + / * DWARFMustBeAtTheEnd * / true ) ) ; <nl> + Str . get ( ) - > InitSections ( Opts . NoExecStack ) ; <nl> + } <nl> + <nl> + / / Assembly to object compilation should leverage assembly info . <nl> + Str - > setUseAssemblerInfoForParsing ( true ) ; <nl> + <nl> + bool Failed = false ; <nl> + <nl> + std : : unique_ptr < MCAsmParser > Parser ( <nl> + createMCAsmParser ( SrcMgr , Ctx , * Str . get ( ) , * MAI ) ) ; <nl> + <nl> + / / FIXME : init MCTargetOptions from sanitizer flags here . <nl> + MCTargetOptions Options ; <nl> + std : : unique_ptr < MCTargetAsmParser > TAP ( <nl> + TheTarget - > createMCAsmParser ( * STI , * Parser , * MCII , Options ) ) ; <nl> + if ( ! TAP ) <nl> + Failed = Diags . Report ( diag : : err_target_unknown_triple ) < < Opts . Triple ; <nl> + <nl> + / / Set values for symbols , if any . <nl> + for ( auto & S : Opts . SymbolDefs ) { <nl> + auto Pair = StringRef ( S ) . split ( ' = ' ) ; <nl> + auto Sym = Pair . first ; <nl> + auto Val = Pair . second ; <nl> + int64_t Value ; <nl> + / / We have already error checked this in the driver . <nl> + Val . getAsInteger ( 0 , Value ) ; <nl> + Ctx . setSymbolValue ( Parser - > getStreamer ( ) , Sym , Value ) ; <nl> + } <nl> + <nl> + if ( ! Failed ) { <nl> + Parser - > setTargetParser ( * TAP . get ( ) ) ; <nl> + Failed = Parser - > Run ( Opts . NoInitialTextSection ) ; <nl> + } <nl> + <nl> + / / Close Streamer first . <nl> + / / It might have a reference to the output stream . <nl> + Str . reset ( ) ; <nl> + / / Close the output stream early . <nl> + BOS . reset ( ) ; <nl> + FDOS . reset ( ) ; <nl> + <nl> + / / Delete output file if there were errors . <nl> + if ( Failed & & Opts . OutputPath ! = " - " ) <nl> + sys : : fs : : remove ( Opts . OutputPath ) ; <nl> + <nl> + return Failed ; <nl> + } <nl> + <nl> + static void LLVMErrorHandler ( void * UserData , const std : : string & Message , <nl> + bool / * GenCrashDiag * / ) { <nl> + DiagnosticsEngine & Diags = * static_cast < DiagnosticsEngine * > ( UserData ) ; <nl> + <nl> + Diags . Report ( diag : : err_fe_error_backend ) < < Message ; <nl> + <nl> + / / We cannot recover from llvm errors . <nl> + exit ( 1 ) ; <nl> + } <nl> + <nl> + int cc1as_main ( ArrayRef < const char * > Argv , const char * / * Argv0 * / , void * / * MainAddr * / ) { <nl> + / / Initialize targets and assembly printers / parsers . <nl> + InitializeAllTargetInfos ( ) ; <nl> + InitializeAllTargetMCs ( ) ; <nl> + InitializeAllAsmParsers ( ) ; <nl> + <nl> + / / Construct our diagnostic client . <nl> + IntrusiveRefCntPtr < DiagnosticOptions > DiagOpts = new DiagnosticOptions ( ) ; <nl> + TextDiagnosticPrinter * DiagClient <nl> + = new TextDiagnosticPrinter ( errs ( ) , & * DiagOpts ) ; <nl> + DiagClient - > setPrefix ( " clang - cc1as " ) ; <nl> + IntrusiveRefCntPtr < DiagnosticIDs > DiagID ( new DiagnosticIDs ( ) ) ; <nl> + DiagnosticsEngine Diags ( DiagID , & * DiagOpts , DiagClient ) ; <nl> + <nl> + / / Set an error handler , so that any LLVM backend diagnostics go through our <nl> + / / error handler . <nl> + ScopedFatalErrorHandler FatalErrorHandler <nl> + ( LLVMErrorHandler , static_cast < void * > ( & Diags ) ) ; <nl> + <nl> + / / Parse the arguments . <nl> + AssemblerInvocation Asm ; <nl> + if ( ! AssemblerInvocation : : CreateFromArgs ( Asm , Argv , Diags ) ) <nl> + return 1 ; <nl> + <nl> + if ( Asm . ShowHelp ) { <nl> + std : : unique_ptr < OptTable > Opts ( driver : : createDriverOptTable ( ) ) ; <nl> + Opts - > PrintHelp ( llvm : : outs ( ) , " clang - cc1as " , " Clang Integrated Assembler " , <nl> + / * Include = * / driver : : options : : CC1AsOption , / * Exclude = * / 0 , <nl> + / * ShowAllAliases = * / false ) ; <nl> + return 0 ; <nl> + } <nl> + <nl> + / / Honor - version . <nl> + / / <nl> + / / FIXME : Use a better - version message ? <nl> + if ( Asm . ShowVersion ) { <nl> + llvm : : cl : : PrintVersionMessage ( ) ; <nl> + return 0 ; <nl> + } <nl> + <nl> + / / Honor - mllvm . <nl> + / / <nl> + / / FIXME : Remove this , one day . <nl> + if ( ! Asm . LLVMArgs . empty ( ) ) { <nl> + unsigned NumArgs = Asm . LLVMArgs . size ( ) ; <nl> + auto Args = llvm : : make_unique < const char * [ ] > ( NumArgs + 2 ) ; <nl> + Args [ 0 ] = " clang ( LLVM option parsing ) " ; <nl> + for ( unsigned i = 0 ; i ! = NumArgs ; + + i ) <nl> + Args [ i + 1 ] = Asm . LLVMArgs [ i ] . c_str ( ) ; <nl> + Args [ NumArgs + 1 ] = nullptr ; <nl> + llvm : : cl : : ParseCommandLineOptions ( NumArgs + 1 , Args . get ( ) ) ; <nl> + } <nl> + <nl> + / / Execute the invocation , unless there were parsing errors . <nl> + bool Failed = Diags . hasErrorOccurred ( ) | | ExecuteAssembler ( Asm , Diags ) ; <nl> + <nl> + / / If any timers were active but haven ' t been destroyed yet , print their <nl> + / / results now . <nl> + TimerGroup : : printAll ( errs ( ) ) ; <nl> + <nl> + return ! ! Failed ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 9a061b9d137 <nl> mmm / dev / null <nl> ppp b / dbms / programs / clang / Compiler - 7 . 0 . 0bundled / driver . cpp <nl> <nl> + / / = = = - - driver . cpp - Clang GCC - Compatible Driver mmmmmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> + / / <nl> + / / The LLVM Compiler Infrastructure <nl> + / / <nl> + / / This file is distributed under the University of Illinois Open Source <nl> + / / License . See LICENSE . TXT for details . <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + / / <nl> + / / This is the entry point to the clang driver ; it is a thin wrapper <nl> + / / for functionality in the Driver clang library . <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + <nl> + # include " clang / Driver / Driver . h " <nl> + # include " clang / Basic / DiagnosticOptions . h " <nl> + # include " clang / Driver / Compilation . h " <nl> + # include " clang / Driver / DriverDiagnostic . h " <nl> + # include " clang / Driver / Options . h " <nl> + # include " clang / Driver / ToolChain . h " <nl> + # include " clang / Frontend / ChainedDiagnosticConsumer . h " <nl> + # include " clang / Frontend / CompilerInvocation . h " <nl> + # include " clang / Frontend / SerializedDiagnosticPrinter . h " <nl> + # include " clang / Frontend / TextDiagnosticPrinter . h " <nl> + # include " clang / Frontend / Utils . h " <nl> + # include " llvm / ADT / ArrayRef . h " <nl> + # include " llvm / ADT / SmallString . h " <nl> + # include " llvm / ADT / SmallVector . h " <nl> + # include " llvm / Option / ArgList . h " <nl> + # include " llvm / Option / OptTable . h " <nl> + # include " llvm / Option / Option . h " <nl> + # include " llvm / Support / CommandLine . h " <nl> + # include " llvm / Support / ErrorHandling . h " <nl> + # include " llvm / Support / FileSystem . h " <nl> + # include " llvm / Support / Host . h " <nl> + # include " llvm / Support / InitLLVM . h " <nl> + # include " llvm / Support / Path . h " <nl> + # include " llvm / Support / Process . h " <nl> + # include " llvm / Support / Program . h " <nl> + # include " llvm / Support / Regex . h " <nl> + # include " llvm / Support / Signals . h " <nl> + # include " llvm / Support / StringSaver . h " <nl> + # include " llvm / Support / TargetSelect . h " <nl> + # include " llvm / Support / Timer . h " <nl> + # include " llvm / Support / raw_ostream . h " <nl> + # include < memory > <nl> + # include < set > <nl> + # include < system_error > <nl> + using namespace clang ; <nl> + using namespace clang : : driver ; <nl> + using namespace llvm : : opt ; <nl> + <nl> + std : : string GetExecutablePath ( const char * Argv0 , bool CanonicalPrefixes ) { <nl> + if ( ! CanonicalPrefixes ) { <nl> + SmallString < 128 > ExecutablePath ( Argv0 ) ; <nl> + / / Do a PATH lookup if Argv0 isn ' t a valid path . <nl> + if ( ! llvm : : sys : : fs : : exists ( ExecutablePath ) ) <nl> + if ( llvm : : ErrorOr < std : : string > P = <nl> + llvm : : sys : : findProgramByName ( ExecutablePath ) ) <nl> + ExecutablePath = * P ; <nl> + return ExecutablePath . str ( ) ; <nl> + } <nl> + <nl> + / / This just needs to be some symbol in the binary ; C + + doesn ' t <nl> + / / allow taking the address of : : main however . <nl> + void * P = ( void * ) ( intptr_t ) GetExecutablePath ; <nl> + return llvm : : sys : : fs : : getMainExecutable ( Argv0 , P ) ; <nl> + } <nl> + <nl> + static const char * GetStableCStr ( std : : set < std : : string > & SavedStrings , <nl> + StringRef S ) { <nl> + return SavedStrings . insert ( S ) . first - > c_str ( ) ; <nl> + } <nl> + <nl> + / / / ApplyQAOverride - Apply a list of edits to the input argument lists . <nl> + / / / <nl> + / / / The input string is a space separate list of edits to perform , <nl> + / / / they are applied in order to the input argument lists . Edits <nl> + / / / should be one of the following forms : <nl> + / / / <nl> + / / / ' # ' : Silence information about the changes to the command line arguments . <nl> + / / / <nl> + / / / ' ^ ' : Add FOO as a new argument at the beginning of the command line . <nl> + / / / <nl> + / / / ' + ' : Add FOO as a new argument at the end of the command line . <nl> + / / / <nl> + / / / ' s / XXX / YYY / ' : Substitute the regular expression XXX with YYY in the command <nl> + / / / line . <nl> + / / / <nl> + / / / ' xOPTION ' : Removes all instances of the literal argument OPTION . <nl> + / / / <nl> + / / / ' XOPTION ' : Removes all instances of the literal argument OPTION , <nl> + / / / and the following argument . <nl> + / / / <nl> + / / / ' Ox ' : Removes all flags matching ' O ' or ' O [ sz0 - 9 ] ' and adds ' Ox ' <nl> + / / / at the end of the command line . <nl> + / / / <nl> + / / / \ param OS - The stream to write edit information to . <nl> + / / / \ param Args - The vector of command line arguments . <nl> + / / / \ param Edit - The override command to perform . <nl> + / / / \ param SavedStrings - Set to use for storing string representations . <nl> + static void ApplyOneQAOverride ( raw_ostream & OS , <nl> + SmallVectorImpl < const char * > & Args , <nl> + StringRef Edit , <nl> + std : : set < std : : string > & SavedStrings ) { <nl> + / / This does not need to be efficient . <nl> + <nl> + if ( Edit [ 0 ] = = ' ^ ' ) { <nl> + const char * Str = <nl> + GetStableCStr ( SavedStrings , Edit . substr ( 1 ) ) ; <nl> + OS < < " # # # Adding argument " < < Str < < " at beginning \ n " ; <nl> + Args . insert ( Args . begin ( ) + 1 , Str ) ; <nl> + } else if ( Edit [ 0 ] = = ' + ' ) { <nl> + const char * Str = <nl> + GetStableCStr ( SavedStrings , Edit . substr ( 1 ) ) ; <nl> + OS < < " # # # Adding argument " < < Str < < " at end \ n " ; <nl> + Args . push_back ( Str ) ; <nl> + } else if ( Edit [ 0 ] = = ' s ' & & Edit [ 1 ] = = ' / ' & & Edit . endswith ( " / " ) & & <nl> + Edit . slice ( 2 , Edit . size ( ) - 1 ) . find ( ' / ' ) ! = StringRef : : npos ) { <nl> + StringRef MatchPattern = Edit . substr ( 2 ) . split ( ' / ' ) . first ; <nl> + StringRef ReplPattern = Edit . substr ( 2 ) . split ( ' / ' ) . second ; <nl> + ReplPattern = ReplPattern . slice ( 0 , ReplPattern . size ( ) - 1 ) ; <nl> + <nl> + for ( unsigned i = 1 , e = Args . size ( ) ; i ! = e ; + + i ) { <nl> + / / Ignore end - of - line response file markers <nl> + if ( Args [ i ] = = nullptr ) <nl> + continue ; <nl> + std : : string Repl = llvm : : Regex ( MatchPattern ) . sub ( ReplPattern , Args [ i ] ) ; <nl> + <nl> + if ( Repl ! = Args [ i ] ) { <nl> + OS < < " # # # Replacing ' " < < Args [ i ] < < " ' with ' " < < Repl < < " ' \ n " ; <nl> + Args [ i ] = GetStableCStr ( SavedStrings , Repl ) ; <nl> + } <nl> + } <nl> + } else if ( Edit [ 0 ] = = ' x ' | | Edit [ 0 ] = = ' X ' ) { <nl> + auto Option = Edit . substr ( 1 ) ; <nl> + for ( unsigned i = 1 ; i < Args . size ( ) ; ) { <nl> + if ( Option = = Args [ i ] ) { <nl> + OS < < " # # # Deleting argument " < < Args [ i ] < < ' \ n ' ; <nl> + Args . erase ( Args . begin ( ) + i ) ; <nl> + if ( Edit [ 0 ] = = ' X ' ) { <nl> + if ( i < Args . size ( ) ) { <nl> + OS < < " # # # Deleting argument " < < Args [ i ] < < ' \ n ' ; <nl> + Args . erase ( Args . begin ( ) + i ) ; <nl> + } else <nl> + OS < < " # # # Invalid X edit , end of command line ! \ n " ; <nl> + } <nl> + } else <nl> + + + i ; <nl> + } <nl> + } else if ( Edit [ 0 ] = = ' O ' ) { <nl> + for ( unsigned i = 1 ; i < Args . size ( ) ; ) { <nl> + const char * A = Args [ i ] ; <nl> + / / Ignore end - of - line response file markers <nl> + if ( A = = nullptr ) <nl> + continue ; <nl> + if ( A [ 0 ] = = ' - ' & & A [ 1 ] = = ' O ' & & <nl> + ( A [ 2 ] = = ' \ 0 ' | | <nl> + ( A [ 3 ] = = ' \ 0 ' & & ( A [ 2 ] = = ' s ' | | A [ 2 ] = = ' z ' | | <nl> + ( ' 0 ' < = A [ 2 ] & & A [ 2 ] < = ' 9 ' ) ) ) ) ) { <nl> + OS < < " # # # Deleting argument " < < Args [ i ] < < ' \ n ' ; <nl> + Args . erase ( Args . begin ( ) + i ) ; <nl> + } else <nl> + + + i ; <nl> + } <nl> + OS < < " # # # Adding argument " < < Edit < < " at end \ n " ; <nl> + Args . push_back ( GetStableCStr ( SavedStrings , ' - ' + Edit . str ( ) ) ) ; <nl> + } else { <nl> + OS < < " # # # Unrecognized edit : " < < Edit < < " \ n " ; <nl> + } <nl> + } <nl> + <nl> + / / / ApplyQAOverride - Apply a comma separate list of edits to the <nl> + / / / input argument lists . See ApplyOneQAOverride . <nl> + static void ApplyQAOverride ( SmallVectorImpl < const char * > & Args , <nl> + const char * OverrideStr , <nl> + std : : set < std : : string > & SavedStrings ) { <nl> + raw_ostream * OS = & llvm : : errs ( ) ; <nl> + <nl> + if ( OverrideStr [ 0 ] = = ' # ' ) { <nl> + + + OverrideStr ; <nl> + OS = & llvm : : nulls ( ) ; <nl> + } <nl> + <nl> + * OS < < " # # # CCC_OVERRIDE_OPTIONS : " < < OverrideStr < < " \ n " ; <nl> + <nl> + / / This does not need to be efficient . <nl> + <nl> + const char * S = OverrideStr ; <nl> + while ( * S ) { <nl> + const char * End = : : strchr ( S , ' ' ) ; <nl> + if ( ! End ) <nl> + End = S + strlen ( S ) ; <nl> + if ( End ! = S ) <nl> + ApplyOneQAOverride ( * OS , Args , std : : string ( S , End ) , SavedStrings ) ; <nl> + S = End ; <nl> + if ( * S ! = ' \ 0 ' ) <nl> + + + S ; <nl> + } <nl> + } <nl> + <nl> + extern int cc1_main ( ArrayRef < const char * > Argv , const char * Argv0 , <nl> + void * MainAddr ) ; <nl> + extern int cc1as_main ( ArrayRef < const char * > Argv , const char * Argv0 , <nl> + void * MainAddr ) ; <nl> + extern int cc1gen_reproducer_main ( ArrayRef < const char * > Argv , <nl> + const char * Argv0 , void * MainAddr ) ; <nl> + <nl> + static void insertTargetAndModeArgs ( const ParsedClangName & NameParts , <nl> + SmallVectorImpl < const char * > & ArgVector , <nl> + std : : set < std : : string > & SavedStrings ) { <nl> + / / Put target and mode arguments at the start of argument list so that <nl> + / / arguments specified in command line could override them . Avoid putting <nl> + / / them at index 0 , as an option like ' - cc1 ' must remain the first . <nl> + int InsertionPoint = 0 ; <nl> + if ( ArgVector . size ( ) > 0 ) <nl> + + + InsertionPoint ; <nl> + <nl> + if ( NameParts . DriverMode ) { <nl> + / / Add the mode flag to the arguments . <nl> + ArgVector . insert ( ArgVector . begin ( ) + InsertionPoint , <nl> + GetStableCStr ( SavedStrings , NameParts . DriverMode ) ) ; <nl> + } <nl> + <nl> + if ( NameParts . TargetIsValid ) { <nl> + const char * arr [ ] = { " - target " , GetStableCStr ( SavedStrings , <nl> + NameParts . TargetPrefix ) } ; <nl> + ArgVector . insert ( ArgVector . begin ( ) + InsertionPoint , <nl> + std : : begin ( arr ) , std : : end ( arr ) ) ; <nl> + } <nl> + } <nl> + <nl> + static void getCLEnvVarOptions ( std : : string & EnvValue , llvm : : StringSaver & Saver , <nl> + SmallVectorImpl < const char * > & Opts ) { <nl> + llvm : : cl : : TokenizeWindowsCommandLine ( EnvValue , Saver , Opts ) ; <nl> + / / The first instance of ' # ' should be replaced with ' = ' in each option . <nl> + for ( const char * Opt : Opts ) <nl> + if ( char * NumberSignPtr = const_cast < char * > ( : : strchr ( Opt , ' # ' ) ) ) <nl> + * NumberSignPtr = ' = ' ; <nl> + } <nl> + <nl> + static void SetBackdoorDriverOutputsFromEnvVars ( Driver & TheDriver ) { <nl> + / / Handle CC_PRINT_OPTIONS and CC_PRINT_OPTIONS_FILE . <nl> + TheDriver . CCPrintOptions = ! ! : : getenv ( " CC_PRINT_OPTIONS " ) ; <nl> + if ( TheDriver . CCPrintOptions ) <nl> + TheDriver . CCPrintOptionsFilename = : : getenv ( " CC_PRINT_OPTIONS_FILE " ) ; <nl> + <nl> + / / Handle CC_PRINT_HEADERS and CC_PRINT_HEADERS_FILE . <nl> + TheDriver . CCPrintHeaders = ! ! : : getenv ( " CC_PRINT_HEADERS " ) ; <nl> + if ( TheDriver . CCPrintHeaders ) <nl> + TheDriver . CCPrintHeadersFilename = : : getenv ( " CC_PRINT_HEADERS_FILE " ) ; <nl> + <nl> + / / Handle CC_LOG_DIAGNOSTICS and CC_LOG_DIAGNOSTICS_FILE . <nl> + TheDriver . CCLogDiagnostics = ! ! : : getenv ( " CC_LOG_DIAGNOSTICS " ) ; <nl> + if ( TheDriver . CCLogDiagnostics ) <nl> + TheDriver . CCLogDiagnosticsFilename = : : getenv ( " CC_LOG_DIAGNOSTICS_FILE " ) ; <nl> + } <nl> + <nl> + static void FixupDiagPrefixExeName ( TextDiagnosticPrinter * DiagClient , <nl> + const std : : string & Path ) { <nl> + / / If the clang binary happens to be named cl . exe for compatibility reasons , <nl> + / / use clang - cl . exe as the prefix to avoid confusion between clang and MSVC . <nl> + StringRef ExeBasename ( llvm : : sys : : path : : filename ( Path ) ) ; <nl> + if ( ExeBasename . equals_lower ( " cl . exe " ) ) <nl> + ExeBasename = " clang - cl . exe " ; <nl> + DiagClient - > setPrefix ( ExeBasename ) ; <nl> + } <nl> + <nl> + / / This lets us create the DiagnosticsEngine with a properly - filled - out <nl> + / / DiagnosticOptions instance . <nl> + static DiagnosticOptions * <nl> + CreateAndPopulateDiagOpts ( ArrayRef < const char * > argv ) { <nl> + auto * DiagOpts = new DiagnosticOptions ; <nl> + std : : unique_ptr < OptTable > Opts ( createDriverOptTable ( ) ) ; <nl> + unsigned MissingArgIndex , MissingArgCount ; <nl> + InputArgList Args = <nl> + Opts - > ParseArgs ( argv . slice ( 1 ) , MissingArgIndex , MissingArgCount ) ; <nl> + / / We ignore MissingArgCount and the return value of ParseDiagnosticArgs . <nl> + / / Any errors that would be diagnosed here will also be diagnosed later , <nl> + / / when the DiagnosticsEngine actually exists . <nl> + ( void ) ParseDiagnosticArgs ( * DiagOpts , Args ) ; <nl> + return DiagOpts ; <nl> + } <nl> + <nl> + static void SetInstallDir ( SmallVectorImpl < const char * > & argv , <nl> + Driver & TheDriver , bool CanonicalPrefixes ) { <nl> + / / Attempt to find the original path used to invoke the driver , to determine <nl> + / / the installed path . We do this manually , because we want to support that <nl> + / / path being a symlink . <nl> + SmallString < 128 > InstalledPath ( argv [ 0 ] ) ; <nl> + <nl> + / / Do a PATH lookup , if there are no directory components . <nl> + if ( llvm : : sys : : path : : filename ( InstalledPath ) = = InstalledPath ) <nl> + if ( llvm : : ErrorOr < std : : string > Tmp = llvm : : sys : : findProgramByName ( <nl> + llvm : : sys : : path : : filename ( InstalledPath . str ( ) ) ) ) <nl> + InstalledPath = * Tmp ; <nl> + <nl> + / / FIXME : We don ' t actually canonicalize this , we just make it absolute . <nl> + if ( CanonicalPrefixes ) <nl> + llvm : : sys : : fs : : make_absolute ( InstalledPath ) ; <nl> + <nl> + StringRef InstalledPathParent ( llvm : : sys : : path : : parent_path ( InstalledPath ) ) ; <nl> + if ( llvm : : sys : : fs : : exists ( InstalledPathParent ) ) <nl> + TheDriver . setInstalledDir ( InstalledPathParent ) ; <nl> + } <nl> + <nl> + static int ExecuteCC1Tool ( ArrayRef < const char * > argv , StringRef Tool ) { <nl> + void * GetExecutablePathVP = ( void * ) ( intptr_t ) GetExecutablePath ; <nl> + if ( Tool = = " " ) <nl> + return cc1_main ( argv . slice ( 2 ) , argv [ 0 ] , GetExecutablePathVP ) ; <nl> + if ( Tool = = " as " ) <nl> + return cc1as_main ( argv . slice ( 2 ) , argv [ 0 ] , GetExecutablePathVP ) ; <nl> + <nl> + / / Reject unknown tools . <nl> + llvm : : errs ( ) < < " error : unknown integrated tool ' " < < Tool < < " ' . " <nl> + < < " Valid tools include ' - cc1 ' and ' - cc1as ' . \ n " ; <nl> + return 1 ; <nl> + } <nl> + <nl> + int mainEntryClickHouseClang ( int argc_ , char * * argv_ ) { <nl> + llvm : : InitLLVM X ( argc_ , argv_ ) ; <nl> + SmallVector < const char * , 256 > argv ( argv_ , argv_ + argc_ ) ; <nl> + <nl> + if ( llvm : : sys : : Process : : FixupStandardFileDescriptors ( ) ) <nl> + return 1 ; <nl> + <nl> + llvm : : InitializeAllTargets ( ) ; <nl> + auto TargetAndMode = ToolChain : : getTargetAndModeFromProgramName ( argv [ 0 ] ) ; <nl> + <nl> + llvm : : BumpPtrAllocator A ; <nl> + llvm : : StringSaver Saver ( A ) ; <nl> + <nl> + / / Parse response files using the GNU syntax , unless we ' re in CL mode . There <nl> + / / are two ways to put clang in CL compatibility mode : argv [ 0 ] is either <nl> + / / clang - cl or cl , or - - driver - mode = cl is on the command line . The normal <nl> + / / command line parsing can ' t happen until after response file parsing , so we <nl> + / / have to manually search for a - - driver - mode = cl argument the hard way . <nl> + / / Finally , our - cc1 tools don ' t care which tokenization mode we use because <nl> + / / response files written by clang will tokenize the same way in either mode . <nl> + bool ClangCLMode = false ; <nl> + if ( StringRef ( TargetAndMode . DriverMode ) . equals ( " - - driver - mode = cl " ) | | <nl> + std : : find_if ( argv . begin ( ) , argv . end ( ) , [ ] ( const char * F ) { <nl> + return F & & strcmp ( F , " - - driver - mode = cl " ) = = 0 ; <nl> + } ) ! = argv . end ( ) ) { <nl> + ClangCLMode = true ; <nl> + } <nl> + enum { Default , POSIX , Windows } RSPQuoting = Default ; <nl> + for ( const char * F : argv ) { <nl> + if ( strcmp ( F , " - - rsp - quoting = posix " ) = = 0 ) <nl> + RSPQuoting = POSIX ; <nl> + else if ( strcmp ( F , " - - rsp - quoting = windows " ) = = 0 ) <nl> + RSPQuoting = Windows ; <nl> + } <nl> + <nl> + / / Determines whether we want nullptr markers in argv to indicate response <nl> + / / files end - of - lines . We only use this for the / LINK driver argument with <nl> + / / clang - cl . exe on Windows . <nl> + bool MarkEOLs = ClangCLMode ; <nl> + <nl> + llvm : : cl : : TokenizerCallback Tokenizer ; <nl> + if ( RSPQuoting = = Windows | | ( RSPQuoting = = Default & & ClangCLMode ) ) <nl> + Tokenizer = & llvm : : cl : : TokenizeWindowsCommandLine ; <nl> + else <nl> + Tokenizer = & llvm : : cl : : TokenizeGNUCommandLine ; <nl> + <nl> + if ( MarkEOLs & & argv . size ( ) > 1 & & StringRef ( argv [ 1 ] ) . startswith ( " - cc1 " ) ) <nl> + MarkEOLs = false ; <nl> + llvm : : cl : : ExpandResponseFiles ( Saver , Tokenizer , argv , MarkEOLs ) ; <nl> + <nl> + / / Handle - cc1 integrated tools , even if - cc1 was expanded from a response <nl> + / / file . <nl> + auto FirstArg = std : : find_if ( argv . begin ( ) + 1 , argv . end ( ) , <nl> + [ ] ( const char * A ) { return A ! = nullptr ; } ) ; <nl> + if ( FirstArg ! = argv . end ( ) & & StringRef ( * FirstArg ) . startswith ( " - cc1 " ) ) { <nl> + / / If - cc1 came from a response file , remove the EOL sentinels . <nl> + if ( MarkEOLs ) { <nl> + auto newEnd = std : : remove ( argv . begin ( ) , argv . end ( ) , nullptr ) ; <nl> + argv . resize ( newEnd - argv . begin ( ) ) ; <nl> + } <nl> + return ExecuteCC1Tool ( argv , argv [ 1 ] + 4 ) ; <nl> + } <nl> + <nl> + bool CanonicalPrefixes = true ; <nl> + for ( int i = 1 , size = argv . size ( ) ; i < size ; + + i ) { <nl> + / / Skip end - of - line response file markers <nl> + if ( argv [ i ] = = nullptr ) <nl> + continue ; <nl> + if ( StringRef ( argv [ i ] ) = = " - no - canonical - prefixes " ) { <nl> + CanonicalPrefixes = false ; <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + / / Handle CL and _CL_ which permits additional command line options to be <nl> + / / prepended or appended . <nl> + if ( ClangCLMode ) { <nl> + / / Arguments in " CL " are prepended . <nl> + llvm : : Optional < std : : string > OptCL = llvm : : sys : : Process : : GetEnv ( " CL " ) ; <nl> + if ( OptCL . hasValue ( ) ) { <nl> + SmallVector < const char * , 8 > PrependedOpts ; <nl> + getCLEnvVarOptions ( OptCL . getValue ( ) , Saver , PrependedOpts ) ; <nl> + <nl> + / / Insert right after the program name to prepend to the argument list . <nl> + argv . insert ( argv . begin ( ) + 1 , PrependedOpts . begin ( ) , PrependedOpts . end ( ) ) ; <nl> + } <nl> + / / Arguments in " _CL_ " are appended . <nl> + llvm : : Optional < std : : string > Opt_CL_ = llvm : : sys : : Process : : GetEnv ( " _CL_ " ) ; <nl> + if ( Opt_CL_ . hasValue ( ) ) { <nl> + SmallVector < const char * , 8 > AppendedOpts ; <nl> + getCLEnvVarOptions ( Opt_CL_ . getValue ( ) , Saver , AppendedOpts ) ; <nl> + <nl> + / / Insert at the end of the argument list to append . <nl> + argv . append ( AppendedOpts . begin ( ) , AppendedOpts . end ( ) ) ; <nl> + } <nl> + } <nl> + <nl> + std : : set < std : : string > SavedStrings ; <nl> + / / Handle CCC_OVERRIDE_OPTIONS , used for editing a command line behind the <nl> + / / scenes . <nl> + if ( const char * OverrideStr = : : getenv ( " CCC_OVERRIDE_OPTIONS " ) ) { <nl> + / / FIXME : Driver shouldn ' t take extra initial argument . <nl> + ApplyQAOverride ( argv , OverrideStr , SavedStrings ) ; <nl> + } <nl> + <nl> + std : : string Path = GetExecutablePath ( argv [ 0 ] , CanonicalPrefixes ) ; <nl> + <nl> + IntrusiveRefCntPtr < DiagnosticOptions > DiagOpts = <nl> + CreateAndPopulateDiagOpts ( argv ) ; <nl> + <nl> + TextDiagnosticPrinter * DiagClient <nl> + = new TextDiagnosticPrinter ( llvm : : errs ( ) , & * DiagOpts ) ; <nl> + FixupDiagPrefixExeName ( DiagClient , Path ) ; <nl> + <nl> + IntrusiveRefCntPtr < DiagnosticIDs > DiagID ( new DiagnosticIDs ( ) ) ; <nl> + <nl> + DiagnosticsEngine Diags ( DiagID , & * DiagOpts , DiagClient ) ; <nl> + <nl> + if ( ! DiagOpts - > DiagnosticSerializationFile . empty ( ) ) { <nl> + auto SerializedConsumer = <nl> + clang : : serialized_diags : : create ( DiagOpts - > DiagnosticSerializationFile , <nl> + & * DiagOpts , / * MergeChildRecords = * / true ) ; <nl> + Diags . setClient ( new ChainedDiagnosticConsumer ( <nl> + Diags . takeClient ( ) , std : : move ( SerializedConsumer ) ) ) ; <nl> + } <nl> + <nl> + ProcessWarningOptions ( Diags , * DiagOpts , / * ReportDiags = * / false ) ; <nl> + <nl> + Driver TheDriver ( Path , llvm : : sys : : getDefaultTargetTriple ( ) , Diags ) ; <nl> + SetInstallDir ( argv , TheDriver , CanonicalPrefixes ) ; <nl> + TheDriver . setTargetAndMode ( TargetAndMode ) ; <nl> + <nl> + insertTargetAndModeArgs ( TargetAndMode , argv , SavedStrings ) ; <nl> + <nl> + SetBackdoorDriverOutputsFromEnvVars ( TheDriver ) ; <nl> + <nl> + std : : unique_ptr < Compilation > C ( TheDriver . BuildCompilation ( argv ) ) ; <nl> + int Res = 1 ; <nl> + if ( C & & ! C - > containsError ( ) ) { <nl> + SmallVector < std : : pair < int , const Command * > , 4 > FailingCommands ; <nl> + Res = TheDriver . ExecuteCompilation ( * C , FailingCommands ) ; <nl> + <nl> + / / Force a crash to test the diagnostics . <nl> + if ( TheDriver . GenReproducer ) { <nl> + Diags . Report ( diag : : err_drv_force_crash ) <nl> + < < ! : : getenv ( " FORCE_CLANG_DIAGNOSTICS_CRASH " ) ; <nl> + <nl> + / / Pretend that every command failed . <nl> + FailingCommands . clear ( ) ; <nl> + for ( const auto & J : C - > getJobs ( ) ) <nl> + if ( const Command * C = dyn_cast < Command > ( & J ) ) <nl> + FailingCommands . push_back ( std : : make_pair ( - 1 , C ) ) ; <nl> + } <nl> + <nl> + for ( const auto & P : FailingCommands ) { <nl> + int CommandRes = P . first ; <nl> + const Command * FailingCommand = P . second ; <nl> + if ( ! Res ) <nl> + Res = CommandRes ; <nl> + <nl> + / / If result status is < 0 , then the driver command signalled an error . <nl> + / / If result status is 70 , then the driver command reported a fatal error . <nl> + / / On Windows , abort will return an exit code of 3 . In these cases , <nl> + / / generate additional diagnostic information if possible . <nl> + bool DiagnoseCrash = CommandRes < 0 | | CommandRes = = 70 ; <nl> + # ifdef _WIN32 <nl> + DiagnoseCrash | = CommandRes = = 3 ; <nl> + # endif <nl> + if ( DiagnoseCrash ) { <nl> + TheDriver . generateCompilationDiagnostics ( * C , * FailingCommand ) ; <nl> + break ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + Diags . getClient ( ) - > finish ( ) ; <nl> + <nl> + / / If any timers were active but haven ' t been destroyed yet , print their <nl> + / / results now . This happens in - disable - free mode . <nl> + llvm : : TimerGroup : : printAll ( llvm : : errs ( ) ) ; <nl> + <nl> + # ifdef _WIN32 <nl> + / / Exit status should not be negative on Win32 , unless abnormal termination . <nl> + / / Once abnormal termiation was caught , negative status should not be <nl> + / / propagated . <nl> + if ( Res < 0 ) <nl> + Res = 1 ; <nl> + # endif <nl> + <nl> + / / If we have multiple failing commands , we return the result of the first <nl> + / / failing command . <nl> + return Res ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 203e50d42a9 <nl> mmm / dev / null <nl> ppp b / dbms / programs / clang / Compiler - 7 . 0 . 0bundled / lld . cpp <nl> <nl> + # include " lld / Common / Driver . h " <nl> + # include " llvm / Support / InitLLVM . h " <nl> + # include < vector > <nl> + <nl> + int mainEntryClickHouseLLD ( int argc , char * * argv ) <nl> + { <nl> + llvm : : InitLLVM X ( argc , argv ) ; <nl> + std : : vector < const char * > args ( argv , argv + argc ) ; <nl> + return ! lld : : elf : : link ( args , false ) ; <nl> + } <nl> mmm a / dbms / programs / server / CMakeLists . txt <nl> ppp b / dbms / programs / server / CMakeLists . txt <nl> if ( CLICKHOUSE_SPLIT_BINARY ) <nl> install ( TARGETS clickhouse - server $ { CLICKHOUSE_ALL_TARGETS } RUNTIME DESTINATION $ { CMAKE_INSTALL_BINDIR } COMPONENT clickhouse ) <nl> endif ( ) <nl> <nl> - if ( OS_LINUX ) <nl> - set ( GLIBC_MAX_REQUIRED 2 . 4 ) <nl> + if ( OS_LINUX AND MAKE_STATIC_LIBRARIES ) <nl> + set ( GLIBC_MAX_REQUIRED 2 . 4 CACHE INTERNAL " " ) <nl> add_test ( NAME GLIBC_required_version COMMAND bash - c " readelf - s $ { CMAKE_CURRENT_BINARY_DIR } / . . / clickhouse - server | grep ' @ GLIBC ' | grep - oP ' GLIBC_ [ \ \ d \ \ . ] + ' | sort | uniq | sort - r | perl - lnE ' exit 1 if $ _ gt q { GLIBC_ $ { GLIBC_MAX_REQUIRED } } ' " ) <nl> endif ( ) <nl> <nl> mmm a / dbms / src / Columns / ColumnVector . cpp <nl> ppp b / dbms / src / Columns / ColumnVector . cpp <nl> <nl> + # include " ColumnVector . h " <nl> + <nl> # include < cstring > <nl> # include < cmath > <nl> - <nl> # include < common / unaligned . h > <nl> # include < Common / Exception . h > <nl> # include < Common / Arena . h > <nl> # include < Common / SipHash . h > <nl> # include < Common / NaNUtils . h > <nl> - <nl> # include < IO / WriteBuffer . h > <nl> # include < IO / WriteHelpers . h > <nl> - <nl> - # include < Columns / ColumnVector . h > <nl> - <nl> + # include < Columns / ColumnsCommon . h > <nl> # include < DataStreams / ColumnGathererStream . h > <nl> - <nl> # include < ext / bit_cast . h > <nl> <nl> # if __SSE2__ <nl> mmm a / dbms / src / Interpreters / ExpressionJIT . cpp <nl> ppp b / dbms / src / Interpreters / ExpressionJIT . cpp <nl> static llvm : : TargetMachine * getNativeMachine ( ) <nl> # if LLVM_VERSION_MAJOR > = 7 <nl> auto wrapJITSymbolResolver ( llvm : : JITSymbolResolver & jsr ) <nl> { <nl> + # if USE_INTERNAL_LLVM_LIBRARY & & LLVM_VERSION_PATCH = = 0 <nl> + / / REMOVE AFTER contrib / llvm upgrade <nl> auto flags = [ & ] ( llvm : : orc : : SymbolFlagsMap & flags , const llvm : : orc : : SymbolNameSet & symbols ) <nl> { <nl> llvm : : orc : : SymbolNameSet missing ; <nl> auto wrapJITSymbolResolver ( llvm : : JITSymbolResolver & jsr ) <nl> } <nl> return missing ; <nl> } ; <nl> + # else <nl> + / / Actually this should work for 7 . 0 . 0 but now we have OLDER 7 . 0 . 0svn in contrib <nl> + auto flags = [ & ] ( const llvm : : orc : : SymbolNameSet & symbols ) <nl> + { <nl> + llvm : : orc : : SymbolFlagsMap flags ; <nl> + for ( const auto & symbol : symbols ) <nl> + { <nl> + auto resolved = jsr . lookupFlags ( { * symbol } ) ; <nl> + if ( resolved & & resolved - > size ( ) ) <nl> + flags . emplace ( symbol , resolved - > begin ( ) - > second ) ; <nl> + } <nl> + return flags ; <nl> + } ; <nl> + # endif <nl> + <nl> auto symbols = [ & ] ( std : : shared_ptr < llvm : : orc : : AsynchronousSymbolQuery > query , llvm : : orc : : SymbolNameSet symbols ) <nl> { <nl> llvm : : orc : : SymbolNameSet missing ; <nl> mmm a / dbms / src / Storages / MergeTree / MergeTreeRangeReader . cpp <nl> ppp b / dbms / src / Storages / MergeTree / MergeTreeRangeReader . cpp <nl> <nl> # include < Columns / ColumnsCommon . h > <nl> # include < Columns / ColumnNothing . h > <nl> # include < ext / range . h > <nl> + # include < DataTypes / DataTypeNothing . h > <nl> <nl> # if __SSE2__ <nl> # include < emmintrin . h > <nl> - # include < DataTypes / DataTypeNothing . h > <nl> # endif <nl> <nl> namespace DB <nl>
Build fixes ( clang 7 . 0 . 0 + ) ( )
ClickHouse/ClickHouse
160ffb22839692343c2d4ab67c07dd89620ba866
2018-11-16T12:22:51Z
mmm a / src / caffe / net . cpp <nl> ppp b / src / caffe / net . cpp <nl> <nl> / / Copyright Yangqing Jia 2013 <nl> <nl> - # include < fstream > <nl> # include < map > <nl> # include < set > <nl> # include < string > <nl> mmm a / src / caffe / test / test_split_layer . cpp <nl> ppp b / src / caffe / test / test_split_layer . cpp <nl> class SplitLayerInsertionTest : public : : testing : : Test { <nl> output_param_string , & expected_output_param ) ) ; <nl> NetParameter actual_output_param ; <nl> insert_splits ( input_param , & actual_output_param ) ; <nl> - CHECK_EQ ( expected_output_param . DebugString ( ) , <nl> - actual_output_param . DebugString ( ) ) ; <nl> EXPECT_EQ ( expected_output_param . DebugString ( ) , <nl> actual_output_param . DebugString ( ) ) ; <nl> } <nl> mmm a / src / caffe / util / insert_splits . cpp <nl> ppp b / src / caffe / util / insert_splits . cpp <nl> void insert_splits ( const NetParameter & param , NetParameter * param_split ) { <nl> blob_name_to_bottom_split_idx [ blob_name ] = 0 ; <nl> } <nl> } <nl> + / / Create split layer for any input blobs user by other layers as bottom <nl> + / / blobs more than once . <nl> for ( int i = 0 ; i < param . input_size ( ) ; + + i ) { <nl> const string & blob_name = param . input ( i ) ; <nl> const int split_count = blob_name_to_bottom_count [ blob_name ] ; <nl> void insert_splits ( const NetParameter & param , NetParameter * param_split ) { <nl> layer_connection - > set_bottom ( j , split_blob_name ) ; <nl> } <nl> } <nl> - / / Create split blob for any top blobs used by other layers as bottom <nl> + / / Create split layer for any top blobs used by other layers as bottom <nl> / / blobs more than once . <nl> for ( int j = 0 ; j < layer_connection - > top_size ( ) ; + + j ) { <nl> const string & blob_name = layer_connection - > top ( j ) ; <nl>
some cleanup
BVLC/caffe
add03b8b23ca337d68f9dd87cf28cdcb1c2da7bb
2014-02-15T23:05:23Z
mmm a / dbms / src / Core / SettingsCollection . cpp <nl> ppp b / dbms / src / Core / SettingsCollection . cpp <nl> void SettingNumber < Type > : : set ( const Field & x ) <nl> template < typename Type > <nl> void SettingNumber < Type > : : set ( const String & x ) <nl> { <nl> - set ( parseWithSuffix < Type > ( x ) ) ; <nl> + set ( parseWithSizeSuffix < Type > ( x ) ) ; <nl> } <nl> <nl> template < > <nl> mmm a / dbms / src / IO / ReadHelpers . h <nl> ppp b / dbms / src / IO / ReadHelpers . h <nl> inline T parse ( const char * data , size_t size ) <nl> <nl> template < typename T > <nl> inline std : : enable_if_t < ! is_integral_v < T > , void > <nl> - readTextWithSuffix ( T & x , ReadBuffer & buf ) { readText ( x , buf ) ; } <nl> + readTextWithSizeSuffix ( T & x , ReadBuffer & buf ) { readText ( x , buf ) ; } <nl> <nl> template < typename T > <nl> inline std : : enable_if_t < is_integral_v < T > , void > <nl> - readTextWithSuffix ( T & x , ReadBuffer & buf ) <nl> + readTextWithSizeSuffix ( T & x , ReadBuffer & buf ) <nl> { <nl> readIntText ( x , buf ) ; <nl> if ( buf . eof ( ) ) <nl> return ; <nl> <nl> - auto F = [ & buf , & x ] ( long long base , int power_of_two ) mutable <nl> + / / / Updates x depending on the suffix <nl> + auto finish = [ & buf , & x ] ( UInt64 base , int power_of_two ) mutable <nl> { <nl> + + buf . position ( ) ; <nl> if ( buf . eof ( ) ) <nl> { <nl> - x * = base ; <nl> + x * = base ; / / / For decimal suffixes , such as k , M , G etc . <nl> } <nl> else if ( * buf . position ( ) = = ' i ' ) <nl> { <nl> - x = ( x < < power_of_two ) ; <nl> + x = ( x < < power_of_two ) ; / / / For binary suffixes , such as ki , Mi , Gi , etc . <nl> + + buf . position ( ) ; <nl> } <nl> return ; <nl> readTextWithSuffix ( T & x , ReadBuffer & buf ) <nl> { <nl> case ' k ' : [ [ fallthrough ] ] ; <nl> case ' K ' : <nl> - F ( 1000 , 10 ) ; <nl> + finish ( 1000 , 10 ) ; <nl> break ; <nl> case ' M ' : <nl> - F ( 1000000 , 20 ) ; <nl> + finish ( 1000000 , 20 ) ; <nl> break ; <nl> case ' G ' : <nl> - F ( 1000000000 , 30 ) ; <nl> + finish ( 1000000000 , 30 ) ; <nl> break ; <nl> case ' T ' : <nl> - F ( 1000000000000ULL , 40 ) ; <nl> + finish ( 1000000000000ULL , 40 ) ; <nl> break ; <nl> default : <nl> return ; <nl> readTextWithSuffix ( T & x , ReadBuffer & buf ) <nl> return ; <nl> } <nl> <nl> - / / / Read something from text format , but expect complete parse of given text <nl> - / / / For example : 723145 - - ok , 213MB - - not ok <nl> - / / / Integral values parsing with suffix ( k , ki , M , Mi , G , Gi , T , Ti ) <nl> - / / / For example : 133M = 133000000 <nl> + / / / Read something from text format and trying to parse the suffix . <nl> + / / / If the suffix is not valid gives an error <nl> + / / / For example : 723145 - - ok , 213MB - - not ok , but 213Mi - - ok <nl> template < typename T > <nl> - inline T parseWithSuffix ( const char * data , size_t size ) <nl> + inline T parseWithSizeSuffix ( const char * data , size_t size ) <nl> { <nl> T res ; <nl> ReadBufferFromMemory buf ( data , size ) ; <nl> inline T parseWithSuffix ( const char * data , size_t size ) <nl> } <nl> <nl> template < typename T > <nl> - inline T parseWithSuffix ( const String & s ) <nl> + inline T parseWithSizeSuffix ( const String & s ) <nl> { <nl> - return parseWithSuffix < T > ( s . data ( ) , s . size ( ) ) ; <nl> + return parseWithSizeSuffix < T > ( s . data ( ) , s . size ( ) ) ; <nl> } <nl> <nl> template < typename T > <nl> - inline T parseWithSuffix ( const char * data ) <nl> + inline T parseWithSizeSuffix ( const char * data ) <nl> { <nl> - return parseWithSuffix < T > ( data , strlen ( data ) ) ; <nl> + return parseWithSizeSuffix < T > ( data , strlen ( data ) ) ; <nl> } <nl> <nl> template < typename T > <nl>
Comments fixed
ClickHouse/ClickHouse
4480ed5b145b310a9dcdbc6e4078085e178fc994
2020-01-24T10:54:24Z
mmm a / ports / qt - advanced - docking - system / portfile . cmake <nl> ppp b / ports / qt - advanced - docking - system / portfile . cmake <nl> vcpkg_from_github ( <nl> vcpkg_configure_cmake ( <nl> SOURCE_PATH $ { SOURCE_PATH } <nl> PREFER_NINJA <nl> + OPTIONS - DBUILD_EXAMPLES = OFF <nl> ) <nl> <nl> vcpkg_install_cmake ( ) <nl>
disabled examples
microsoft/vcpkg
531009c7992ff6a632704a8c833e328415f7ea04
2019-08-21T12:50:17Z
mmm a / include / gtest / internal / gtest - port . h <nl> ppp b / include / gtest / internal / gtest - port . h <nl> <nl> # define GTEST_API_ <nl> # endif <nl> <nl> + # if defined ( __GNUC__ ) <nl> + / / Ask the compiler to never inline a given function . <nl> + # define GTEST_NO_INLINE_ __attribute__ ( ( noinline ) ) <nl> + # else <nl> + # define GTEST_NO_INLINE_ <nl> + # endif / / __GNUC__ <nl> + <nl> namespace testing { <nl> <nl> class Message ; <nl> mmm a / src / gtest - death - test . cc <nl> ppp b / src / gtest - death - test . cc <nl> static int ExecDeathTestChildMain ( void * child_arg ) { <nl> / / This could be accomplished more elegantly by a single recursive <nl> / / function , but we want to guard against the unlikely possibility of <nl> / / a smart compiler optimizing the recursion away . <nl> + / / <nl> + / / GTEST_NO_INLINE_ is required to prevent GCC 4 . 6 from inlining <nl> + / / StackLowerThanAddress into StackGrowsDown , which then doesn ' t give <nl> + / / correct answer . <nl> + bool StackLowerThanAddress ( const void * ptr ) GTEST_NO_INLINE_ ; <nl> bool StackLowerThanAddress ( const void * ptr ) { <nl> int dummy ; <nl> return & dummy < ptr ; <nl>
fixes a problem caused by gcc 4 . 6 optimization ( by Paul Pluzhnikov )
google/googletest
c006f8c12bc74131692a2df8fd64dcedeafe6c77
2011-04-14T19:36:05Z
mmm a / src / validation . cpp <nl> ppp b / src / validation . cpp <nl> static void UpdateTip ( CTxMemPool & mempool , const CBlockIndex * pindexNew , const C <nl> } <nl> <nl> bilingual_str warning_messages ; <nl> - int num_unexpected_version = 0 ; <nl> - if ( ! : : ChainstateActive ( ) . IsInitialBlockDownload ( ) ) <nl> - { <nl> + if ( ! : : ChainstateActive ( ) . IsInitialBlockDownload ( ) ) { <nl> const CBlockIndex * pindex = pindexNew ; <nl> for ( int bit = 0 ; bit < VERSIONBITS_NUM_BITS ; bit + + ) { <nl> WarningBitsConditionChecker checker ( bit ) ; <nl> static void UpdateTip ( CTxMemPool & mempool , const CBlockIndex * pindexNew , const C <nl> } <nl> } <nl> } <nl> - / / Check the version of the last 100 blocks to see if we need to upgrade : <nl> - for ( int i = 0 ; i < 100 & & pindex ! = nullptr ; i + + ) <nl> - { <nl> - int32_t nExpectedVersion = ComputeBlockVersion ( pindex - > pprev , chainParams . GetConsensus ( ) ) ; <nl> - if ( pindex - > nVersion > VERSIONBITS_LAST_OLD_BLOCK_VERSION & & ( pindex - > nVersion & ~ nExpectedVersion ) ! = 0 ) <nl> - + + num_unexpected_version ; <nl> - pindex = pindex - > pprev ; <nl> - } <nl> } <nl> LogPrintf ( " % s : new best = % s height = % d version = 0x % 08x log2_work = % f tx = % lu date = ' % s ' progress = % f cache = % . 1fMiB ( % utxo ) % s \ n " , __func__ , <nl> pindexNew - > GetBlockHash ( ) . ToString ( ) , pindexNew - > nHeight , pindexNew - > nVersion , <nl> static void UpdateTip ( CTxMemPool & mempool , const CBlockIndex * pindexNew , const C <nl> FormatISO8601DateTime ( pindexNew - > GetBlockTime ( ) ) , <nl> GuessVerificationProgress ( chainParams . TxData ( ) , pindexNew ) , : : ChainstateActive ( ) . CoinsTip ( ) . DynamicMemoryUsage ( ) * ( 1 . 0 / ( 1 < < 20 ) ) , : : ChainstateActive ( ) . CoinsTip ( ) . GetCacheSize ( ) , <nl> ! warning_messages . empty ( ) ? strprintf ( " warning = ' % s ' " , warning_messages . original ) : " " ) ; <nl> - <nl> - if ( num_unexpected_version > 0 ) { <nl> - LogPrint ( BCLog : : VALIDATION , " % d of last 100 blocks have unexpected version \ n " , num_unexpected_version ) ; <nl> - } <nl> } <nl> <nl> / * * Disconnect m_chain ' s tip . <nl>
Merge : Remove confusing and useless " unexpected version " warning
bitcoin/bitcoin
848d66519c392093dbc1bbd5689f84be5ecd9bc8
2020-11-19T15:39:31Z
mmm a / tensorflow / compiler / mlir / tensorflow / ir / tf_generated_ops . td <nl> ppp b / tensorflow / compiler / mlir / tensorflow / ir / tf_generated_ops . td <nl> tf . range ( start , limit , delta ) = = > [ 3 , 6 , 9 , 12 , 15 ] <nl> ] ; <nl> } <nl> <nl> + def TF_RangeDatasetOp : TF_Op < " RangeDataset " , [ ] > { <nl> + let summary = [ { <nl> + Creates a dataset with a range of values . Corresponds to python ' s xrange . <nl> + } ] ; <nl> + <nl> + let description = [ { <nl> + } ] ; <nl> + <nl> + let arguments = ( ins <nl> + I64Tensor : $ start , <nl> + I64Tensor : $ stop , <nl> + I64Tensor : $ step , <nl> + <nl> + Confined < TypeArrayAttr , [ ArrayMinCount < 1 > ] > : $ output_types , <nl> + Confined < TF_ShapeAttrArray , [ ArrayMinCount < 1 > ] > : $ output_shapes <nl> + ) ; <nl> + <nl> + let results = ( outs <nl> + TF_VariantTensor : $ handle <nl> + ) ; <nl> + } <nl> + <nl> def TF_RankOp : TF_Op < " Rank " , [ NoSideEffect ] > { <nl> let summary = " Returns the rank of a tensor . " ; <nl> <nl>
Update visibility of build target .
tensorflow/tensorflow
895ed30e83b57c8c7702839f3a4c2697a4b4e52a
2020-08-04T20:53:21Z
mmm a / cmake / modules / AddSwift . cmake <nl> ppp b / cmake / modules / AddSwift . cmake <nl> endfunction ( ) <nl> # [ SHARED ] <nl> # [ STATIC ] <nl> # [ DEPENDS dep1 . . . ] <nl> - # [ LINK_LIBRARIES dep1 . . . ] <nl> + # [ LINK_LIBS lib1 . . . ] <nl> # [ INTERFACE_LINK_LIBRARIES dep1 . . . ] <nl> # [ SWIFT_MODULE_DEPENDS dep1 . . . ] <nl> # [ LLVM_COMPONENT_DEPENDS comp1 . . . ] <nl> endfunction ( ) <nl> # DEPENDS <nl> # Targets that this library depends on . <nl> # <nl> - # LINK_LIBRARIES <nl> + # LINK_LIBS <nl> # Libraries this library depends on . <nl> # <nl> # LLVM_COMPONENT_DEPENDS <nl> function ( add_swift_host_library name ) <nl> DEPENDS <nl> INTERFACE_LINK_LIBRARIES <nl> LINK_FLAGS <nl> - LINK_LIBRARIES <nl> + LINK_LIBS <nl> LLVM_COMPONENT_DEPENDS ) <nl> <nl> cmake_parse_arguments ( ASHL <nl> function ( add_swift_host_library name ) <nl> SDK $ { SWIFT_HOST_VARIANT_SDK } <nl> ARCHITECTURE $ { SWIFT_HOST_VARIANT_ARCH } <nl> DEPENDS $ { ASHL_DEPENDS } <nl> - LINK_LIBRARIES $ { ASHL_LINK_LIBRARIES } <nl> + LINK_LIBRARIES $ { ASHL_LINK_LIBS } <nl> LLVM_COMPONENT_DEPENDS $ { ASHL_LLVM_COMPONENT_DEPENDS } <nl> LINK_FLAGS $ { ASHL_LINK_FLAGS } <nl> INTERFACE_LINK_LIBRARIES $ { ASHL_INTERFACE_LINK_LIBRARIES } <nl> mmm a / lib / AST / CMakeLists . txt <nl> ppp b / lib / AST / CMakeLists . txt <nl> add_swift_host_library ( swiftAST STATIC <nl> TypeWalker . cpp <nl> USRGeneration . cpp <nl> <nl> - LINK_LIBRARIES <nl> + LINK_LIBS <nl> swiftMarkup <nl> swiftBasic <nl> swiftSyntax <nl> mmm a / lib / ASTSectionImporter / CMakeLists . txt <nl> ppp b / lib / ASTSectionImporter / CMakeLists . txt <nl> <nl> add_swift_host_library ( swiftASTSectionImporter STATIC <nl> ASTSectionImporter . cpp <nl> - LINK_LIBRARIES swiftBasic <nl> + LINK_LIBS swiftBasic <nl> LLVM_COMPONENT_DEPENDS core ) <nl> <nl> mmm a / lib / Basic / CMakeLists . txt <nl> ppp b / lib / Basic / CMakeLists . txt <nl> add_swift_host_library ( swiftBasic STATIC <nl> <nl> UnicodeExtendedGraphemeClusters . cpp . gyb <nl> <nl> - LINK_LIBRARIES <nl> + LINK_LIBS <nl> swiftDemangling <nl> $ { UUID_LIBRARIES } <nl> LLVM_COMPONENT_DEPENDS support ) <nl> mmm a / lib / ClangImporter / CMakeLists . txt <nl> ppp b / lib / ClangImporter / CMakeLists . txt <nl> add_swift_host_library ( swiftClangImporter STATIC <nl> ImportName . cpp <nl> ImportType . cpp <nl> SwiftLookupTable . cpp <nl> - LINK_LIBRARIES <nl> + LINK_LIBS <nl> swiftAST <nl> swiftParse <nl> ) <nl> mmm a / lib / Driver / CMakeLists . txt <nl> ppp b / lib / Driver / CMakeLists . txt <nl> set ( swiftDriver_targetDefines ) <nl> add_swift_host_library ( swiftDriver STATIC <nl> $ { swiftDriver_sources } <nl> DEPENDS SwiftOptions <nl> - LINK_LIBRARIES swiftAST swiftBasic swiftOption ) <nl> + LINK_LIBS <nl> + swiftAST swiftBasic swiftOption ) <nl> <nl> # Generate the static - stdlib - args . lnk file used by - static - stdlib option <nl> # for ' GenericUnix ' ( eg linux ) <nl> mmm a / lib / Frontend / CMakeLists . txt <nl> ppp b / lib / Frontend / CMakeLists . txt <nl> add_swift_host_library ( swiftFrontend STATIC <nl> SerializedDiagnosticConsumer . cpp <nl> DEPENDS <nl> SwiftOptions <nl> - LINK_LIBRARIES <nl> + LINK_LIBS <nl> swiftSIL <nl> swiftMigrator <nl> swiftOption <nl> mmm a / lib / FrontendTool / CMakeLists . txt <nl> ppp b / lib / FrontendTool / CMakeLists . txt <nl> add_swift_host_library ( swiftFrontendTool STATIC <nl> TBD . cpp <nl> DEPENDS <nl> swift - syntax - generated - headers SwiftOptions <nl> - LINK_LIBRARIES <nl> + LINK_LIBS <nl> swiftIndex <nl> swiftIDE <nl> swiftTBDGen swiftIRGen swiftSIL swiftSILGen swiftSILOptimizer <nl> mmm a / lib / IDE / CMakeLists . txt <nl> ppp b / lib / IDE / CMakeLists . txt <nl> add_swift_host_library ( swiftIDE STATIC <nl> IDETypeChecking . cpp <nl> APIDigesterData . cpp <nl> SourceEntityWalker . cpp <nl> - LINK_LIBRARIES <nl> + LINK_LIBS <nl> swiftFrontend <nl> swiftClangImporter <nl> swiftParse <nl> mmm a / lib / IRGen / CMakeLists . txt <nl> ppp b / lib / IRGen / CMakeLists . txt <nl> add_swift_host_library ( swiftIRGen STATIC <nl> SwiftTargetInfo . cpp <nl> TypeLayoutDumper . cpp <nl> TypeLayoutVerifier . cpp <nl> - LINK_LIBRARIES <nl> + LINK_LIBS <nl> swiftAST <nl> swiftLLVMPasses <nl> swiftSIL <nl> mmm a / lib / Immediate / CMakeLists . txt <nl> ppp b / lib / Immediate / CMakeLists . txt <nl> <nl> add_swift_host_library ( swiftImmediate STATIC <nl> Immediate . cpp <nl> REPL . cpp <nl> - LINK_LIBRARIES <nl> + LINK_LIBS <nl> swiftIDE <nl> swiftFrontend <nl> swiftSILGen <nl> mmm a / lib / Index / CMakeLists . txt <nl> ppp b / lib / Index / CMakeLists . txt <nl> add_swift_host_library ( swiftIndex STATIC <nl> IndexDataConsumer . cpp <nl> IndexRecord . cpp <nl> IndexSymbol . cpp <nl> - LINK_LIBRARIES <nl> + LINK_LIBS <nl> swiftAST ) <nl> mmm a / lib / Markup / CMakeLists . txt <nl> ppp b / lib / Markup / CMakeLists . txt <nl> add_swift_host_library ( swiftMarkup STATIC <nl> AST . cpp <nl> LineList . cpp <nl> Markup . cpp <nl> - <nl> - LINK_LIBRARIES <nl> + LINK_LIBS <nl> libcmark_static ) <nl> target_compile_definitions ( swiftMarkup <nl> PRIVATE <nl> mmm a / lib / Migrator / CMakeLists . txt <nl> ppp b / lib / Migrator / CMakeLists . txt <nl> add_swift_host_library ( swiftMigrator STATIC <nl> Migrator . cpp <nl> MigrationState . cpp <nl> RewriteBufferEditsReceiver . cpp <nl> - LINK_LIBRARIES swiftSyntax swiftIDE ) <nl> + LINK_LIBS <nl> + swiftSyntax swiftIDE ) <nl> <nl> add_dependencies ( swiftMigrator <nl> " symlink_migrator_data " ) <nl> mmm a / lib / Option / CMakeLists . txt <nl> ppp b / lib / Option / CMakeLists . txt <nl> add_swift_host_library ( swiftOption STATIC <nl> Options . cpp <nl> SanitizerOptions . cpp <nl> DEPENDS SwiftOptions <nl> - LINK_LIBRARIES swiftBasic ) <nl> + LINK_LIBS <nl> + swiftBasic ) <nl> <nl> mmm a / lib / Parse / CMakeLists . txt <nl> ppp b / lib / Parse / CMakeLists . txt <nl> add_swift_host_library ( swiftParse STATIC <nl> Scope . cpp <nl> SyntaxParsingCache . cpp <nl> SyntaxParsingContext . cpp <nl> - LINK_LIBRARIES <nl> + LINK_LIBS <nl> swiftAST <nl> swiftSyntax <nl> ) <nl> mmm a / lib / ParseSIL / CMakeLists . txt <nl> ppp b / lib / ParseSIL / CMakeLists . txt <nl> <nl> add_swift_host_library ( swiftParseSIL STATIC <nl> ParseSIL . cpp <nl> - LINK_LIBRARIES <nl> + LINK_LIBS <nl> swiftParse <nl> swiftSema <nl> swiftSIL <nl> mmm a / lib / PrintAsObjC / CMakeLists . txt <nl> ppp b / lib / PrintAsObjC / CMakeLists . txt <nl> <nl> add_swift_host_library ( swiftPrintAsObjC STATIC <nl> PrintAsObjC . cpp <nl> - LINK_LIBRARIES <nl> + LINK_LIBS <nl> swiftIDE <nl> swiftFrontend <nl> swiftClangImporter <nl> mmm a / lib / RemoteAST / CMakeLists . txt <nl> ppp b / lib / RemoteAST / CMakeLists . txt <nl> add_swift_host_library ( swiftRemoteAST STATIC <nl> RemoteAST . cpp <nl> InProcessMemoryReader . cpp <nl> $ { REMOTE_LIB_HEADERS } <nl> - LINK_LIBRARIES <nl> + LINK_LIBS <nl> swiftSema swiftIRGen ) <nl> mmm a / lib / SIL / CMakeLists . txt <nl> ppp b / lib / SIL / CMakeLists . txt <nl> add_swift_host_library ( swiftSIL STATIC <nl> SILWitnessTable . cpp <nl> TypeLowering . cpp <nl> ValueOwnership . cpp <nl> - LINK_LIBRARIES <nl> + LINK_LIBS <nl> swiftSerialization <nl> swiftSema <nl> ) <nl> mmm a / lib / SILGen / CMakeLists . txt <nl> ppp b / lib / SILGen / CMakeLists . txt <nl> add_swift_host_library ( swiftSILGen STATIC <nl> SILGenStmt . cpp <nl> SILGenThunk . cpp <nl> SILGenType . cpp <nl> - LINK_LIBRARIES <nl> + LINK_LIBS <nl> swiftSIL <nl> ) <nl> mmm a / lib / SILOptimizer / CMakeLists . txt <nl> ppp b / lib / SILOptimizer / CMakeLists . txt <nl> add_subdirectory ( Utils ) <nl> <nl> add_swift_host_library ( swiftSILOptimizer STATIC <nl> $ { SILOPTIMIZER_SOURCES } <nl> - LINK_LIBRARIES swiftSIL ) <nl> + LINK_LIBS <nl> + swiftSIL ) <nl> mmm a / lib / Sema / CMakeLists . txt <nl> ppp b / lib / Sema / CMakeLists . txt <nl> add_swift_host_library ( swiftSema STATIC <nl> TypeCheckSwitchStmt . cpp <nl> TypeCheckType . cpp <nl> TypeChecker . cpp <nl> - LINK_LIBRARIES <nl> + LINK_LIBS <nl> swiftParse <nl> swiftAST <nl> swiftSerialization <nl> mmm a / lib / Serialization / CMakeLists . txt <nl> ppp b / lib / Serialization / CMakeLists . txt <nl> add_swift_host_library ( swiftSerialization STATIC <nl> SerializedSILLoader . cpp <nl> SerializeDoc . cpp <nl> SerializeSIL . cpp <nl> - LINK_LIBRARIES <nl> + LINK_LIBS <nl> swiftClangImporter ) <nl> <nl> mmm a / lib / SwiftDemangle / CMakeLists . txt <nl> ppp b / lib / SwiftDemangle / CMakeLists . txt <nl> add_swift_host_library ( swiftDemangle <nl> SHARED <nl> SwiftDemangle . cpp <nl> MangleHack . cpp <nl> - LINK_LIBRARIES <nl> + LINK_LIBS <nl> swiftDemangling ) <nl> target_compile_definitions ( swiftDemangle <nl> PRIVATE <nl> mmm a / lib / TBDGen / CMakeLists . txt <nl> ppp b / lib / TBDGen / CMakeLists . txt <nl> add_subdirectory ( tapi ) <nl> add_swift_host_library ( swiftTBDGen STATIC <nl> $ { TAPI_SOURCES } <nl> TBDGen . cpp <nl> - LINK_LIBRARIES <nl> + LINK_LIBS <nl> swiftAST <nl> swiftSIL <nl> ) <nl>
add_swift_host_library : rename LINK_LIBRARIES to LINK_LIBS
apple/swift
39dde93c887fef1c907c240db554198fc8a1b163
2018-10-31T19:46:31Z
mmm a / tensorflow / python / ops / image_ops_impl . py <nl> ppp b / tensorflow / python / ops / image_ops_impl . py <nl> def extract_glimpse ( <nl> <nl> Usage Example : <nl> ` ` ` python <nl> - BATCH_SIZE = 2 <nl> - IMAGE_HEIGHT = 256 <nl> - IMAGE_WIDTH = 256 <nl> - CHANNELS = 3 <nl> - GLIMPSE_SIZE = ( 24 , 24 ) <nl> - image = tf . random . normal ( shape = ( BATCH_SIZE , IMAGE_HEIGHT , <nl> - IMAGE_WIDTH , CHANNELS ) ) <nl> - offsets = tf . random . uniform ( shape = ( BATCH_SIZE , 2 ) ) <nl> + BATCH_SIZE = 1 <nl> + IMAGE_HEIGHT = 5 <nl> + IMAGE_WIDTH = 5 <nl> + CHANNELS = 1 <nl> + GLIMPSE_SIZE = ( 3 , 3 ) <nl> + image = tf . random . uniform ( shape = ( BATCH_SIZE , IMAGE_HEIGHT , <nl> + IMAGE_WIDTH , CHANNELS ) ) <nl> output = tf . image . extract_glimpse ( image , size = GLIMPSE_SIZE , <nl> - offsets = offsets ) <nl> - print ( output . shape ) <nl> + offsets = [ [ 1 , 1 ] ] , centered = False , normalized = False ) <nl> + print ( image ) <nl> + < tf . Tensor : id = 172 , shape = ( 3 , 3 ) , dtype = float32 , numpy = <nl> + array ( [ [ 0 . 98461604 , 0 . 14595735 , 0 . 3296578 ] , <nl> + [ 0 . 247967 , 0 . 17635965 , 0 . 3487332 ] , <nl> + [ 0 . 33684814 , 0 . 971017 , 0 . 41953743 ] ] , dtype = float32 ) > <nl> + print ( output ) <nl> + tf . Tensor ( <nl> + [ [ 0 . 98461604 0 . 14595735 ] <nl> + [ 0 . 247967 0 . 17635965 ] ] , shape = ( 2 , 2 ) , dtype = float32 ) <nl> ` ` ` <nl> " " " <nl> return gen_image_ops . extract_glimpse ( <nl> def extract_glimpse_v2 ( <nl> A ` Tensor ` of type ` float32 ` . <nl> <nl> Usage Example : <nl> - ` ` ` python <nl> - BATCH_SIZE = 2 <nl> - IMAGE_HEIGHT = 256 <nl> - IMAGE_WIDTH = 256 <nl> - CHANNELS = 3 <nl> - GLIMPSE_SIZE = ( 24 , 24 ) <nl> - image = tf . random . normal ( shape = ( BATCH_SIZE , IMAGE_HEIGHT , <nl> - IMAGE_WIDTH , CHANNELS ) ) <nl> - offsets = tf . random . uniform ( shape = ( BATCH_SIZE , 2 ) ) <nl> + ` ` ` python <nl> + BATCH_SIZE = 1 <nl> + IMAGE_HEIGHT = 5 <nl> + IMAGE_WIDTH = 5 <nl> + CHANNELS = 1 <nl> + GLIMPSE_SIZE = ( 3 , 3 ) <nl> + image = tf . random . uniform ( shape = ( BATCH_SIZE , IMAGE_HEIGHT , <nl> + IMAGE_WIDTH , CHANNELS ) ) <nl> output = tf . image . extract_glimpse ( image , size = GLIMPSE_SIZE , <nl> - offsets = offsets ) <nl> - print ( output . shape ) <nl> + offsets = [ [ 1 , 1 ] ] , centered = False , normalized = False ) <nl> + print ( image ) <nl> + < tf . Tensor : id = 172 , shape = ( 3 , 3 ) , dtype = float32 , numpy = <nl> + array ( [ [ 0 . 98461604 , 0 . 14595735 , 0 . 3296578 ] , <nl> + [ 0 . 247967 , 0 . 17635965 , 0 . 3487332 ] , <nl> + [ 0 . 33684814 , 0 . 971017 , 0 . 41953743 ] ] , dtype = float32 ) > <nl> + print ( output ) <nl> + tf . Tensor ( <nl> + [ [ 0 . 98461604 0 . 14595735 ] <nl> + [ 0 . 247967 0 . 17635965 ] ] , shape = ( 2 , 2 ) , dtype = float32 ) <nl> ` ` ` <nl> - <nl> " " " <nl> return gen_image_ops . extract_glimpse ( <nl> input = input , <nl>
Usable example added in extract_glimpses
tensorflow/tensorflow
d3f5e4608e6b37e9493951c37624d01cef4037f9
2019-06-25T20:57:57Z
mmm a / modules / planning / conf / traffic_rule_config . pb . txt <nl> ppp b / modules / planning / conf / traffic_rule_config . pb . txt <nl> config : { <nl> pull_over { <nl> stop_distance : 0 . 5 <nl> buffer_to_boundary : 0 . 5 <nl> - plan_distance : 25 . 0 <nl> - operation_length : 20 . 0 <nl> + plan_distance : 30 . 0 <nl> + operation_length : 25 . 0 <nl> max_check_distance : 60 . 0 <nl> max_failure_count : 10 <nl> } <nl> mmm a / modules / planning / integration_tests / garage_test . cc <nl> ppp b / modules / planning / integration_tests / garage_test . cc <nl> TEST_F ( GarageTest , stop_obstacle ) { <nl> FLAGS_test_localization_file = " stop_obstacle_localization . pb . txt " ; <nl> FLAGS_test_chassis_file = " stop_obstacle_chassis . pb . txt " ; <nl> PlanningTestBase : : SetUp ( ) ; <nl> + <nl> + / / set config <nl> + auto * destination_config = PlanningTestBase : : GetDestinationConfig ( ) ; <nl> + destination_config - > mutable_destination ( ) - > set_enable_pull_over ( false ) ; <nl> + <nl> RUN_GOLDEN_TEST ( 0 ) ; <nl> } <nl> <nl> TEST_F ( GarageTest , follow ) { <nl> FLAGS_test_localization_file = " follow_localization . pb . txt " ; <nl> FLAGS_test_chassis_file = " follow_chassis . pb . txt " ; <nl> PlanningTestBase : : SetUp ( ) ; <nl> + <nl> + / / set config <nl> + auto * destination_config = PlanningTestBase : : GetDestinationConfig ( ) ; <nl> + destination_config - > mutable_destination ( ) - > set_enable_pull_over ( false ) ; <nl> + <nl> RUN_GOLDEN_TEST ( 0 ) ; <nl> } <nl> <nl> TEST_F ( GarageTest , follow ) { <nl> * test destination stop <nl> * / <nl> TEST_F ( GarageTest , dest_stop_01 ) { <nl> + ENABLE_RULE ( TrafficRuleConfig : : PULL_OVER , false ) ; <nl> ENABLE_RULE ( TrafficRuleConfig : : STOP_SIGN , false ) ; <nl> <nl> FLAGS_test_prediction_file = " stop_dest_prediction . pb . txt " ; <nl> TEST_F ( GarageTest , stop_over_line ) { <nl> FLAGS_test_localization_file = seq_num + " _localization . pb . txt " ; <nl> FLAGS_test_chassis_file = seq_num + " _chassis . pb . txt " ; <nl> PlanningTestBase : : SetUp ( ) ; <nl> + <nl> + / / set config <nl> + auto * destination_config = PlanningTestBase : : GetDestinationConfig ( ) ; <nl> + destination_config - > mutable_destination ( ) - > set_enable_pull_over ( false ) ; <nl> + <nl> RUN_GOLDEN_TEST ( 0 ) ; <nl> } <nl> <nl> mmm a / modules / planning / integration_tests / sunnyvale_big_loop_test . cc <nl> ppp b / modules / planning / integration_tests / sunnyvale_big_loop_test . cc <nl> TEST_F ( SunnyvaleBigLoopTest , destination_pull_over_01 ) { <nl> destination_config - > mutable_destination ( ) - > set_enable_pull_over ( true ) ; <nl> <nl> auto * pull_over_config = PlanningTestBase : : GetPullOverConfig ( ) ; <nl> - pull_over_config - > mutable_pull_over ( ) - > set_plan_distance ( 20 . 0 ) ; <nl> - pull_over_config - > mutable_pull_over ( ) - > set_operation_length ( 15 . 0 ) ; <nl> + pull_over_config - > mutable_pull_over ( ) - > set_plan_distance ( 35 . 0 ) ; <nl> + pull_over_config - > mutable_pull_over ( ) - > set_operation_length ( 10 . 0 ) ; <nl> <nl> RUN_GOLDEN_TEST_DECISION ( 0 ) ; <nl> <nl> TEST_F ( SunnyvaleBigLoopTest , destination_pull_over_01 ) { <nl> EXPECT_DOUBLE_EQ ( status_set_time_0 , status_set_time_1 ) ; <nl> } <nl> <nl> + / * <nl> + * destination : stop inlane while pull over fails <nl> + * bag : 2018 - 05 - 16 - 10 - 00 - 32 / 2018 - 05 - 16 - 10 - 00 - 32_10 . bag <nl> + * decision : STOP <nl> + * / <nl> + TEST_F ( SunnyvaleBigLoopTest , destination_pull_over_02 ) { <nl> + ENABLE_RULE ( TrafficRuleConfig : : CROSSWALK , false ) ; <nl> + ENABLE_RULE ( TrafficRuleConfig : : DESTINATION , true ) ; <nl> + ENABLE_RULE ( TrafficRuleConfig : : KEEP_CLEAR , false ) ; <nl> + ENABLE_RULE ( TrafficRuleConfig : : PULL_OVER , true ) ; <nl> + ENABLE_RULE ( TrafficRuleConfig : : SIGNAL_LIGHT , false ) ; <nl> + ENABLE_RULE ( TrafficRuleConfig : : STOP_SIGN , false ) ; <nl> + <nl> + std : : string seq_num = " 601 " ; <nl> + FLAGS_test_routing_response_file = seq_num + " _routing . pb . txt " ; <nl> + FLAGS_test_localization_file = seq_num + " _localization . pb . txt " ; <nl> + FLAGS_test_chassis_file = seq_num + " _chassis . pb . txt " ; <nl> + FLAGS_test_prediction_file = seq_num + " _prediction . pb . txt " ; <nl> + PlanningTestBase : : SetUp ( ) ; <nl> + <nl> + / / set config <nl> + auto * destination_config = PlanningTestBase : : GetDestinationConfig ( ) ; <nl> + destination_config - > mutable_destination ( ) - > set_enable_pull_over ( true ) ; <nl> + <nl> + auto * pull_over_config = PlanningTestBase : : GetPullOverConfig ( ) ; <nl> + pull_over_config - > mutable_pull_over ( ) - > set_plan_distance ( 35 . 0 ) ; <nl> + pull_over_config - > mutable_pull_over ( ) - > set_operation_length ( 10 . 0 ) ; <nl> + <nl> + / / step 1 : pull over <nl> + RUN_GOLDEN_TEST_DECISION ( 0 ) ; <nl> + <nl> + / / check PlanningStatus value : PULL OVER <nl> + auto * planning_state = GetPlanningStatus ( ) - > mutable_planning_state ( ) ; <nl> + EXPECT_TRUE ( planning_state - > has_pull_over ( ) & & <nl> + planning_state - > pull_over ( ) . in_pull_over ( ) ) ; <nl> + EXPECT_EQ ( PullOverStatus : : DESTINATION , planning_state - > pull_over ( ) . reason ( ) ) ; <nl> + <nl> + / / step 2 : pull over failed , stop inlane <nl> + <nl> + / / set config <nl> + pull_over_config - > mutable_pull_over ( ) - > set_plan_distance ( 10 . 0 ) ; <nl> + pull_over_config - > mutable_pull_over ( ) - > set_max_check_distance ( 30 . 0 ) ; <nl> + <nl> + / / check PULL OVER decision <nl> + RUN_GOLDEN_TEST_DECISION ( 1 ) ; <nl> + <nl> + / / check PlanningStatus value : PULL OVER cleared <nl> + EXPECT_FALSE ( planning_state - > has_pull_over ( ) ) ; <nl> + } <nl> + <nl> / * <nl> / / TODO ( all ) : this test need rewrite <nl> TEST_F ( SunnyvaleBigLoopTest , bypass_parked_bus ) { <nl> mmm a / modules / planning / proto / traffic_rule_config . proto <nl> ppp b / modules / planning / proto / traffic_rule_config . proto <nl> message PullOverConfig { <nl> / / l - distance buffer to road / lane boundary <nl> optional double buffer_to_boundary = 2 [ default = 0 . 5 ] ; <nl> / / distance to stop point to start planning pull over <nl> - optional double plan_distance = 3 [ default = 25 . 0 ] ; <nl> + optional double plan_distance = 3 [ default = 30 . 0 ] ; <nl> / / s_distance to beteeen start and stop points <nl> - optional double operation_length = 4 [ default = 20 . 0 ] ; / / meter <nl> + optional double operation_length = 4 [ default = 25 . 0 ] ; / / meter <nl> / / max s_distance to check ahead while planning pull over <nl> optional double max_check_distance = 5 [ default = 60 . 0 ] ; / / meter <nl> / / max failure count before changing to stop in - lane <nl> mmm a / modules / planning / tasks / traffic_decider / destination . cc <nl> ppp b / modules / planning / tasks / traffic_decider / destination . cc <nl> bool Destination : : CheckPullOver ( <nl> ADEBUG < < " adc_front_edge_s [ " < < adc_front_edge_s <nl> < < " ] distance_to_dest [ " < < distance_to_dest <nl> < < " ] dest_lane [ " < < lane_id < < " ] dest_lane_s [ " < < dest_lane_s < < " ] " ; <nl> + <nl> if ( distance_to_dest > config_ . pull_over ( ) . plan_distance ( ) ) { <nl> + / / to far , not sending pull - over yet <nl> return false ; <nl> } <nl> <nl> + <nl> return true ; <nl> } <nl> <nl> mmm a / modules / planning / tasks / traffic_decider / pull_over . cc <nl> ppp b / modules / planning / tasks / traffic_decider / pull_over . cc <nl> Status PullOver : : ApplyRule ( Frame * const frame , <nl> } <nl> <nl> common : : PointENU stop_point ; <nl> - if ( GetPullOverStop ( & stop_point ) ! = 0 & & <nl> - failure_count_ > = config_ . pull_over ( ) . max_failure_count ( ) ) { <nl> + if ( GetPullOverStop ( & stop_point ) ! = 0 ) { <nl> + / / & & failure_count_ > = config_ . pull_over ( ) . max_failure_count ( ) ) { <nl> BuildInLaneStop ( stop_point ) ; <nl> ADEBUG < < " Could not find a safe pull over point . STOP in - lane " ; <nl> } else { <nl> bool PullOver : : IsPullOver ( ) const { <nl> planning_state - > pull_over ( ) . in_pull_over ( ) ) ; <nl> } <nl> <nl> - bool PullOver : : IsValidStop ( const common : : PointENU & stop_point ) const { <nl> + PullOver : : ValidateStopPointCode PullOver : : IsValidStop ( <nl> + const common : : PointENU & stop_point ) const { <nl> const auto & reference_line = reference_line_info_ - > reference_line ( ) ; <nl> <nl> common : : SLPoint stop_point_sl ; <nl> bool PullOver : : IsValidStop ( const common : : PointENU & stop_point ) const { <nl> return IsValidStop ( stop_point_sl ) ; <nl> } <nl> <nl> - bool PullOver : : IsValidStop ( const common : : SLPoint & stop_point_sl ) const { <nl> + PullOver : : ValidateStopPointCode PullOver : : IsValidStop ( <nl> + const common : : SLPoint & stop_point_sl ) const { <nl> const auto & reference_line = reference_line_info_ - > reference_line ( ) ; <nl> if ( stop_point_sl . s ( ) < 0 | | stop_point_sl . s ( ) > reference_line . Length ( ) ) { <nl> - return false ; <nl> + return OUT_OF_REFERENCE_LINE ; <nl> + } <nl> + <nl> + / / note : this check has to be done first <nl> + auto pull_over = GetPlanningStatus ( ) - > planning_state ( ) . pull_over ( ) ; <nl> + if ( pull_over . has_inlane_dest_point ( ) ) { <nl> + common : : SLPoint dest_point_sl ; <nl> + reference_line . XYToSL ( { pull_over . inlane_dest_point ( ) . x ( ) , <nl> + pull_over . inlane_dest_point ( ) . y ( ) } , & dest_point_sl ) ; <nl> + if ( stop_point_sl . s ( ) - dest_point_sl . s ( ) > <nl> + config_ . pull_over ( ) . max_check_distance ( ) ) { <nl> + return PASS_DEST_POINT_TOO_FAR ; <nl> + } <nl> } <nl> <nl> const double adc_front_edge_s = reference_line_info_ - > AdcSlBoundary ( ) . end_s ( ) ; <nl> + if ( stop_point_sl . s ( ) < = adc_front_edge_s ) { <nl> + return BEHIND_ADC ; <nl> + } <nl> + <nl> if ( stop_point_sl . s ( ) - adc_front_edge_s < <nl> config_ . pull_over ( ) . operation_length ( ) ) { <nl> - return false ; <nl> + return PLAN_DISTANCE_NOT_ENOUGH ; <nl> } <nl> <nl> / / parking spot boundary <nl> bool PullOver : : IsValidStop ( const common : : SLPoint & stop_point_sl ) const { <nl> ADEBUG < < " obstacle_id [ " < < obstacle_id < < " ] type [ " < < obstacle_type_name <nl> < < " ] overlap with parking spot : " < < obstacle_sl . DebugString ( ) ; <nl> <nl> - return false ; <nl> + return PARKING_SPOT_NOT_AVAIL ; <nl> } <nl> } <nl> <nl> - return true ; <nl> + return OK ; <nl> } <nl> <nl> / * * <nl> int PullOver : : GetPullOverStop ( common : : PointENU * stop_point ) { <nl> if ( pull_over_status . has_start_point ( ) & & pull_over_status . has_stop_point ( ) ) { <nl> stop_point - > set_x ( pull_over_status . stop_point ( ) . x ( ) ) ; <nl> stop_point - > set_y ( pull_over_status . stop_point ( ) . y ( ) ) ; <nl> - if ( IsValidStop ( * stop_point ) ) { <nl> - stop_point - > set_x ( pull_over_status . stop_point ( ) . x ( ) ) ; <nl> - stop_point - > set_y ( pull_over_status . stop_point ( ) . y ( ) ) ; <nl> <nl> + ValidateStopPointCode ret = IsValidStop ( * stop_point ) ; <nl> + if ( ret = = OK ) { <nl> failure_count_ = 0 ; <nl> return 0 ; <nl> + } else if ( ret = = PASS_DEST_POINT_TOO_FAR ) { <nl> + / / fail with no re - try <nl> + failure_count_ + + ; <nl> + return - 1 ; <nl> } <nl> } <nl> <nl> - / / calculate new stop point if don ' t have a pull over stop <nl> + / / calculate new stop point <nl> if ( FindPullOverStop ( stop_point ) = = 0 ) { <nl> failure_count_ = 0 ; <nl> return 0 ; <nl> bool PullOver : : OnOverlap ( const double s ) { <nl> reference_line . map_path ( ) . crosswalk_overlaps ( ) ; <nl> for ( const auto & crosswalk_overlap : crosswalk_overlaps ) { <nl> if ( s > = crosswalk_overlap . start_s & & s < = crosswalk_overlap . end_s ) { <nl> + ADEBUG < < " s [ " < < s < < " ] on crosswalk_overlap [ " <nl> + < < crosswalk_overlap . object_id < < " ] " ; <nl> return true ; <nl> } <nl> } <nl> bool PullOver : : OnOverlap ( const double s ) { <nl> reference_line . map_path ( ) . junction_overlaps ( ) ; <nl> for ( const auto & junction_overlap : junction_overlaps ) { <nl> if ( s > = junction_overlap . start_s & & s < = junction_overlap . end_s ) { <nl> + ADEBUG < < " s [ " < < s < < " ] on junction_overlap [ " <nl> + < < junction_overlap . object_id < < " ] " ; <nl> return true ; <nl> } <nl> } <nl> bool PullOver : : OnOverlap ( const double s ) { <nl> reference_line . map_path ( ) . clear_area_overlaps ( ) ; <nl> for ( const auto & clear_area_overlap : clear_area_overlaps ) { <nl> if ( s > = clear_area_overlap . start_s & & s < = clear_area_overlap . end_s ) { <nl> + ADEBUG < < " s [ " < < s < < " ] on clear_area_overlap [ " <nl> + < < clear_area_overlap . object_id < < " ] " ; <nl> return true ; <nl> } <nl> } <nl> bool PullOver : : OnOverlap ( const double s ) { <nl> reference_line . map_path ( ) . speed_bump_overlaps ( ) ; <nl> for ( const auto & speed_bump_overlap : speed_bump_overlaps ) { <nl> if ( s > = speed_bump_overlap . start_s & & s < = speed_bump_overlap . end_s ) { <nl> + ADEBUG < < " s [ " < < s < < " ] on speed_bump_overlap [ " <nl> + < < speed_bump_overlap . object_id < < " ] " ; <nl> return true ; <nl> } <nl> } <nl> int PullOver : : FindPullOverStop ( const double stop_point_s , <nl> stop_point_sl . set_l ( - ( road_right_width - adc_width / 2 - <nl> config_ . pull_over ( ) . buffer_to_boundary ( ) ) ) ; <nl> <nl> - if ( IsValidStop ( stop_point_sl ) ) { <nl> + if ( IsValidStop ( stop_point_sl ) = = OK ) { <nl> common : : math : : Vec2d point ; <nl> reference_line . SLToXY ( stop_point_sl , & point ) ; <nl> stop_point - > set_x ( point . x ( ) ) ; <nl> int PullOver : : FindPullOverStop ( common : : PointENU * stop_point ) { <nl> double check_s = adc_front_edge_s ; <nl> <nl> constexpr double kDistanceUnit = 5 . 0 ; <nl> - while ( total_check_length < config_ . pull_over ( ) . max_check_distance ( ) ) { <nl> + while ( check_s < reference_line . Length ( ) & & <nl> + total_check_length < config_ . pull_over ( ) . max_check_distance ( ) ) { <nl> check_s + = kDistanceUnit ; <nl> total_check_length + = kDistanceUnit ; <nl> <nl> int PullOver : : FindPullOverStop ( common : : PointENU * stop_point ) { <nl> } <nl> <nl> std : : string lane_id = lane - > lane ( ) . id ( ) . id ( ) ; <nl> - ADEBUG < < " check_s [ " < < check_s < < " ] lane [ " < < lane_id < < " ] " ; <nl> + ADEBUG < < " check_s [ " < < check_s < < " ] lane [ " < < lane_id <nl> + < < " ] reference_line . Length [ " < < reference_line . Length ( ) < < " ] " ; <nl> <nl> / / check turn type : NO_TURN / LEFT_TURN / RIGHT_TURN / U_TURN <nl> const auto & turn = lane - > lane ( ) . turn ( ) ; <nl> int PullOver : : FindPullOverStop ( common : : PointENU * stop_point ) { <nl> <nl> / / check if on overlaps <nl> if ( OnOverlap ( check_s ) ) { <nl> + ADEBUG < < " lane [ " < < lane_id < < " ] on overlap . can ' t pull over " ; <nl> check_length = 0 . 0 ; <nl> continue ; <nl> } <nl> <nl> / / all the lane checks have passed <nl> check_length + = kDistanceUnit ; <nl> + ADEBUG < < " check_length : " < < check_length < < " ; plan_distance : " < < <nl> + config_ . pull_over ( ) . plan_distance ( ) ; <nl> if ( check_length > = config_ . pull_over ( ) . plan_distance ( ) ) { <nl> common : : PointENU point ; <nl> / / check corresponding parking_spot <nl> int PullOver : : FindPullOverStop ( common : : PointENU * stop_point ) { <nl> <nl> stop_point - > set_x ( point . x ( ) ) ; <nl> stop_point - > set_y ( point . y ( ) ) ; <nl> - ADEBUG < < " stop point : lane [ " < < lane - > id ( ) . id ( ) < < " ] " <nl> - < < stop_point - > x ( ) < < " , " < < stop_point - > y ( ) < < " ) " ; <nl> + ADEBUG < < " stop point : lane [ " < < lane - > id ( ) . id ( ) <nl> + < < " ] ( " < < stop_point - > x ( ) < < " , " < < stop_point - > y ( ) < < " ) " ; <nl> + <nl> return 0 ; <nl> } <nl> } <nl> int PullOver : : BuildPullOverStop ( const common : : PointENU & stop_point ) { <nl> double stop_point_heading = <nl> reference_line . GetReferencePoint ( stop_point_sl . s ( ) ) . heading ( ) ; <nl> <nl> - BuildStopDecision ( stop_line_s , stop_point , stop_point_heading ) ; <nl> + BuildStopDecision ( " " , stop_line_s , stop_point , stop_point_heading ) ; <nl> <nl> / / record in PlanningStatus <nl> auto * pull_over_status = <nl> int PullOver : : BuildPullOverStop ( const common : : PointENU & stop_point ) { <nl> int PullOver : : BuildInLaneStop ( const common : : PointENU & pull_over_stop_point ) { <nl> const auto & reference_line = reference_line_info_ - > reference_line ( ) ; <nl> <nl> + const double adc_front_edge_s = <nl> + reference_line_info_ - > AdcSlBoundary ( ) . end_s ( ) ; <nl> + <nl> common : : SLPoint stop_point_sl ; <nl> - common : : PointENU stop_point ; <nl> + bool inlane_stop_point_set = false ; <nl> + <nl> + / / use inlane_dest_point if already set <nl> auto pull_over = GetPlanningStatus ( ) - > planning_state ( ) . pull_over ( ) ; <nl> if ( pull_over . has_inlane_dest_point ( ) ) { <nl> - / / in - lane stop point already set <nl> - stop_point . set_x ( pull_over . inlane_dest_point ( ) . x ( ) ) ; <nl> - stop_point . set_x ( pull_over . inlane_dest_point ( ) . y ( ) ) ; <nl> - reference_line . XYToSL ( stop_point , & stop_point_sl ) ; <nl> - } else { <nl> - / / in - lane stop point already NOT set , <nl> - / / use a point corresponding to pull_over_stop_point <nl> - reference_line . XYToSL ( pull_over_stop_point , & stop_point_sl ) ; <nl> - auto inlane_point = reference_line . GetReferencePoint ( stop_point_sl . s ( ) ) ; <nl> - stop_point . set_x ( inlane_point . x ( ) ) ; <nl> - stop_point . set_y ( inlane_point . y ( ) ) ; <nl> + reference_line . XYToSL ( { pull_over . inlane_dest_point ( ) . x ( ) , <nl> + pull_over . inlane_dest_point ( ) . y ( ) } , <nl> + & stop_point_sl ) ; <nl> + ADEBUG < < " BuildInLaneStop using inlane_dest_point : s [ " <nl> + < < stop_point_sl . s ( ) < < " ] dist [ " <nl> + < < stop_point_sl . s ( ) - adc_front_edge_s <nl> + < < " ] POINT : " < < pull_over . inlane_dest_point ( ) . DebugString ( ) ; <nl> + if ( stop_point_sl . s ( ) - adc_front_edge_s > <nl> + config_ . pull_over ( ) . plan_distance ( ) ) { <nl> + inlane_stop_point_set = true ; <nl> + } <nl> + } <nl> + <nl> + / / use a point corresponding to pull_over_stop_point <nl> + if ( ! inlane_stop_point_set ) { <nl> + if ( pull_over_stop_point . has_x ( ) & & pull_over_stop_point . has_y ( ) ) { <nl> + reference_line . XYToSL ( { pull_over_stop_point . x ( ) , <nl> + pull_over_stop_point . y ( ) } , <nl> + & stop_point_sl ) ; <nl> + ADEBUG < < " BuildInLaneStop using pull_over_stop_point : s [ " <nl> + < < stop_point_sl . s ( ) < < " ] dist [ " <nl> + < < stop_point_sl . s ( ) - adc_front_edge_s <nl> + < < " ] POINT : " < < pull_over_stop_point . DebugString ( ) ; <nl> + if ( stop_point_sl . s ( ) - adc_front_edge_s > <nl> + config_ . pull_over ( ) . plan_distance ( ) ) { <nl> + inlane_stop_point_set = true ; <nl> + } <nl> + } <nl> } <nl> <nl> + if ( ! inlane_stop_point_set ) { <nl> + stop_point_sl . set_s ( <nl> + adc_front_edge_s + config_ . pull_over ( ) . plan_distance ( ) ) ; <nl> + ADEBUG < < " BuildInLaneStop : adc : s [ " < < stop_point_sl . s ( ) <nl> + < < " ] l [ 0 . 0 ] adc_front_edge_s [ " < < adc_front_edge_s ; <nl> + } <nl> + <nl> + common : : PointENU stop_point ; <nl> + auto inlane_point = reference_line . GetReferencePoint ( stop_point_sl . s ( ) ) ; <nl> + stop_point . set_x ( inlane_point . x ( ) ) ; <nl> + stop_point . set_y ( inlane_point . y ( ) ) ; <nl> + <nl> double stop_line_s = stop_point_sl . s ( ) + config_ . pull_over ( ) . stop_distance ( ) ; <nl> double stop_point_heading = <nl> reference_line . GetReferencePoint ( stop_point_sl . s ( ) ) . heading ( ) ; <nl> <nl> - BuildStopDecision ( stop_line_s , stop_point , stop_point_heading ) ; <nl> + BuildStopDecision ( INLANE_STOP_VO_ID_PREFIX , <nl> + stop_line_s , stop_point , stop_point_heading ) ; <nl> <nl> / / record in PlanningStatus <nl> auto * planning_state = GetPlanningStatus ( ) - > mutable_planning_state ( ) ; <nl> planning_state - > clear_pull_over ( ) ; <nl> <nl> - ADEBUG < < " planning_state : " < < planning_state - > DebugString ( ) ; <nl> - <nl> return 0 ; <nl> } <nl> <nl> - int PullOver : : BuildStopDecision ( const double stop_line_s , <nl> + int PullOver : : BuildStopDecision ( const std : : string & vistual_obstacle_id_postfix , <nl> + const double stop_line_s , <nl> const common : : PointENU & stop_point , <nl> const double stop_point_heading ) { <nl> const auto & reference_line = reference_line_info_ - > reference_line ( ) ; <nl> int PullOver : : BuildStopDecision ( const double stop_line_s , <nl> } <nl> <nl> / / create virtual stop wall <nl> - auto pull_over_reason = <nl> - GetPlanningStatus ( ) - > planning_state ( ) . pull_over ( ) . reason ( ) ; <nl> - std : : string virtual_obstacle_id = <nl> - PULL_OVER_VO_ID_PREFIX + PullOverStatus_Reason_Name ( pull_over_reason ) ; <nl> + auto pull_over_reason = GetPlanningStatus ( ) - > <nl> + planning_state ( ) . pull_over ( ) . reason ( ) ; <nl> + std : : string virtual_obstacle_id = PULL_OVER_VO_ID_PREFIX + <nl> + PullOverStatus_Reason_Name ( pull_over_reason ) + <nl> + vistual_obstacle_id_postfix ; <nl> + <nl> auto * obstacle = frame_ - > CreateStopObstacle ( reference_line_info_ , <nl> virtual_obstacle_id , stop_line_s ) ; <nl> if ( ! obstacle ) { <nl> mmm a / modules / planning / tasks / traffic_decider / pull_over . h <nl> ppp b / modules / planning / tasks / traffic_decider / pull_over . h <nl> class PullOver : public TrafficRule { <nl> ReferenceLineInfo * const reference_line_info ) ; <nl> <nl> private : <nl> + enum ValidateStopPointCode { <nl> + OK = 0 , <nl> + OUT_OF_REFERENCE_LINE = 1 , <nl> + PASS_DEST_POINT_TOO_FAR = 2 , <nl> + BEHIND_ADC = 3 , <nl> + PLAN_DISTANCE_NOT_ENOUGH = 4 , <nl> + PARKING_SPOT_NOT_AVAIL = 5 , <nl> + } ; <nl> + <nl> / * * <nl> * Check if the planning status is in pull over mode <nl> * / <nl> class PullOver : public TrafficRule { <nl> * The stop point could be invalid if it is occupied by other obstacles ; <nl> * The stop point could be invalid if the vehicle has passed this point <nl> * / <nl> - bool IsValidStop ( const common : : PointENU & stop_point ) const ; <nl> - bool IsValidStop ( const common : : SLPoint & stop_point_sl ) const ; <nl> + ValidateStopPointCode IsValidStop ( const common : : PointENU & stop_point ) const ; <nl> + ValidateStopPointCode IsValidStop ( const common : : SLPoint & stop_point_sl ) const ; <nl> <nl> int BuildPullOverStop ( const common : : PointENU & stop_point ) ; <nl> int BuildInLaneStop ( const common : : PointENU & pull_over_stop_point ) ; <nl> - int BuildStopDecision ( const double stop_line_s , <nl> + int BuildStopDecision ( const std : : string & vistual_obstacle_id_postfix , <nl> + const double stop_line_s , <nl> const common : : PointENU & stop_point , <nl> const double stop_point_heading ) ; <nl> <nl> private : <nl> static constexpr char const * const PULL_OVER_VO_ID_PREFIX = " PO_ " ; <nl> + static constexpr char const * const INLANE_STOP_VO_ID_PREFIX = " _INLANE " ; <nl> static constexpr double PARKING_SPOT_LONGITUDINAL_BUFFER = 1 . 0 ; <nl> static uint32_t failure_count_ ; <nl> Frame * frame_ = nullptr ; <nl> mmm a / modules / planning / testdata / sunnyvale_big_loop_test / 601_chassis . pb . txt <nl> ppp b / modules / planning / testdata / sunnyvale_big_loop_test / 601_chassis . pb . txt <nl> <nl> engine_started : true <nl> engine_rpm : 0 <nl> - speed_mps : 11 . 025 <nl> + speed_mps : 10 . 897223 <nl> odometer_m : 0 <nl> fuel_range_m : 0 <nl> - throttle_percentage : 21 . 693752 <nl> + throttle_percentage : 22 . 560463 <nl> brake_percentage : 13 . 891813 <nl> - steering_percentage : 0 . 17021276 <nl> - steering_torque_nm : - 0 . 1875 <nl> + steering_percentage : - 0 . 19148937 <nl> + steering_torque_nm : - 0 . 0625 <nl> parking_brake : false <nl> driving_mode : COMPLETE_AUTO_DRIVE <nl> error_code : NO_ERROR <nl> gear_location : GEAR_DRIVE <nl> header { <nl> - timestamp_sec : 1526490049 . 1234806 <nl> + timestamp_sec : 1526490046 . 8840959 <nl> module_name : " chassis " <nl> - sequence_num : 136344 <nl> + sequence_num : 136120 <nl> } <nl> signal { <nl> turn_signal : TURN_NONE <nl> horn : false <nl> } <nl> chassis_gps { <nl> - latitude : 37 . 413602666666662 <nl> - longitude : - 122 . 01550933333333 <nl> + latitude : 37 . 413551999999996 <nl> + longitude : - 122 . 01526399999999 <nl> gps_valid : true <nl> year : 18 <nl> month : 5 <nl> day : 16 <nl> hours : 17 <nl> minutes : 0 <nl> - seconds : 48 <nl> + seconds : 46 <nl> compass_direction : 270 <nl> pdop : 1 <nl> is_gps_fault : false <nl> is_inferred : false <nl> altitude : - 42 . 5 <nl> - heading : 285 . 06 <nl> + heading : 284 . 67 <nl> hdop : 0 . 60000000000000009 <nl> vdop : 0 . 8 <nl> quality : FIX_3D <nl> - num_satellites : 19 <nl> + num_satellites : 18 <nl> gps_speed : 10 . 72896 <nl> } <nl> engage_advice { <nl> engage_advice { <nl> wheel_speed { <nl> is_wheel_spd_rr_valid : true <nl> wheel_direction_rr : FORWARD <nl> - wheel_spd_rr : 33 . 480000000000004 <nl> + wheel_spd_rr : 33 . 08 <nl> is_wheel_spd_rl_valid : true <nl> wheel_direction_rl : FORWARD <nl> - wheel_spd_rl : 33 . 44 <nl> + wheel_spd_rl : 33 . 160000000000004 <nl> is_wheel_spd_fr_valid : true <nl> wheel_direction_fr : FORWARD <nl> - wheel_spd_fr : 33 . 6 <nl> + wheel_spd_fr : 33 . 08 <nl> is_wheel_spd_fl_valid : true <nl> wheel_direction_fl : FORWARD <nl> - wheel_spd_fl : 33 . 68 <nl> + wheel_spd_fl : 33 . 160000000000004 <nl> } <nl> mmm a / modules / planning / testdata / sunnyvale_big_loop_test / 601_localization . pb . txt <nl> ppp b / modules / planning / testdata / sunnyvale_big_loop_test / 601_localization . pb . txt <nl> <nl> header { <nl> - timestamp_sec : 1526490049 . 1217933 <nl> + timestamp_sec : 1526490046 . 8718288 <nl> } <nl> pose { <nl> position { <nl> - x : 587116 . 45077844139 <nl> - y : 4141208 . 030775636 <nl> - z : - 31 . 409226659613388 <nl> + x : 587140 . 65734150843 <nl> + y : 4141201 . 915165436 <nl> + z : - 31 . 318700067025549 <nl> } <nl> orientation { <nl> - qx : - 0 . 021344492720504312 <nl> - qy : - 0 . 0072705434623588769 <nl> - qz : 0 . 60886843345011243 <nl> - qw : 0 . 79295068104912581 <nl> + qx : - 0 . 020444464985259789 <nl> + qy : - 0 . 0036190826896800141 <nl> + qz : 0 . 61092647220698171 <nl> + qw : 0 . 79141504386047912 <nl> } <nl> linear_velocity { <nl> - x : - 10 . 807778304227414 <nl> - y : 2 . 8786463286230379 <nl> - z : - 0 . 063362368709097269 <nl> + x : - 10 . 675175271276069 <nl> + y : 2 . 8451361938147248 <nl> + z : - 0 . 0066376198184972205 <nl> } <nl> linear_acceleration { <nl> - x : - 0 . 56085266453475824 <nl> - y : 0 . 15271794615567874 <nl> - z : 0 . 13219157269614001 <nl> + x : - 0 . 40113963537226927 <nl> + y : - 0 . 66988255300457467 <nl> + z : 1 . 3381704436066126 <nl> } <nl> angular_velocity { <nl> - x : 0 . 018812664599176424 <nl> - y : 0 . 033466083639781284 <nl> - z : - 0 . 0037882812997750105 <nl> + x : - 0 . 017847179486428291 <nl> + y : - 0 . 0043972424523252684 <nl> + z : - 0 . 0034499877804099071 <nl> } <nl> - heading : 2 . 8807626876900496 <nl> + heading : 2 . 8859441843256324 <nl> linear_acceleration_vrf { <nl> - x : - 0 . 14107674360275269 <nl> - y : 0 . 15659257769584656 <nl> - z : 9 . 9469535052776337 <nl> + x : - 0 . 9639933705329895 <nl> + y : - 0 . 1911260187625885 <nl> + z : 11 . 122170835733414 <nl> } <nl> angular_velocity_vrf { <nl> - x : 0 . 037242383294751644 <nl> - y : - 0 . 0093755493864073735 <nl> - z : - 0 . 0036537841947776582 <nl> + x : - 0 . 008710799411188375 <nl> + y : 0 . 016271160044841058 <nl> + z : - 0 . 0030218035845342452 <nl> } <nl> euler_angles { <nl> - x : - 0 . 042716858832551712 <nl> - y : 0 . 014475320726718756 <nl> - z : 1 . 3099663608951526 <nl> + x : - 0 . 0367904000915639 <nl> + y : 0 . 019265964882085596 <nl> + z : 1 . 315147857530736 <nl> } <nl> } <nl> uncertainty { <nl> position_std_dev { <nl> - x : 0 . 014616180544506587 <nl> - y : 0 . 021114172980533384 <nl> - z : 0 . 01223059326755371 <nl> + x : 0 . 016120661918877979 <nl> + y : 0 . 016399290523028326 <nl> + z : 0 . 01202368487727417 <nl> } <nl> orientation_std_dev { <nl> - x : 0 . 0628971784153256 <nl> - y : 0 . 05963223915271551 <nl> - z : 0 . 05032112950535568 <nl> + x : 0 . 063633955401171727 <nl> + y : 0 . 060494884926891937 <nl> + z : 0 . 049763558677293221 <nl> } <nl> linear_velocity_std_dev { <nl> - x : 0 . 014704865835481024 <nl> - y : 0 . 01733108197060975 <nl> - z : 0 . 0059390964102889873 <nl> + x : 0 . 015732244797480893 <nl> + y : 0 . 017610802129075891 <nl> + z : 0 . 0058910211561128255 <nl> } <nl> } <nl> - measurement_time : 1526490049 . 095139 <nl> + measurement_time : 1526490046 . 8451281 <nl> mmm a / modules / planning / testdata / sunnyvale_big_loop_test / 601_prediction . pb . txt <nl> ppp b / modules / planning / testdata / sunnyvale_big_loop_test / 601_prediction . pb . txt <nl> <nl> header { <nl> - timestamp_sec : 1526490049 . 1214654 <nl> + timestamp_sec : 1526490046 . 8165913 <nl> module_name : " prediction " <nl> - sequence_num : 13402 <nl> - } <nl> - prediction_obstacle { <nl> - perception_obstacle { <nl> - id : 23356 <nl> - position { <nl> - x : 587113 . 68156633922 <nl> - y : 4141208 . 7606054628 <nl> - z : - 31 . 086343342572469 <nl> - } <nl> - theta : 2 . 8914395694880479 <nl> - velocity { <nl> - x : 0 <nl> - y : 0 <nl> - z : 0 <nl> - } <nl> - length : 0 . 0673581138253212 <nl> - width : 0 . 16771174967288971 <nl> - height : 0 . 031169414520263672 <nl> - polygon_point { <nl> - x : 587113 . 71157760418 <nl> - y : 4141208 . 7417112114 <nl> - z : - 31 . 084230970406594 <nl> - } <nl> - polygon_point { <nl> - x : 587113 . 70847213571 <nl> - y : 4141208 . 7342735059 <nl> - z : - 31 . 084031179790642 <nl> - } <nl> - polygon_point { <nl> - x : 587113 . 65140635089 <nl> - y : 4141208 . 6904069497 <nl> - z : - 31 . 082708801688288 <nl> - } <nl> - polygon_point { <nl> - x : 587113 . 6378496089 <nl> - y : 4141208 . 685240231 <nl> - z : - 31 . 082527640257307 <nl> - } <nl> - polygon_point { <nl> - x : 587113 . 66567570239 <nl> - y : 4141208 . 8344609523 <nl> - z : - 31 . 086407825717075 <nl> - } <nl> - polygon_point { <nl> - x : 587113 . 67249890207 <nl> - y : 4141208 . 8494320572 <nl> - z : - 31 . 086812104817085 <nl> - } <nl> - polygon_point { <nl> - x : 587113 . 71295406355 <nl> - y : 4141208 . 7496049372 <nl> - z : - 31 . 084435875792117 <nl> - } <nl> - tracking_time : 0 . 10005712509155273 <nl> - type : UNKNOWN <nl> - timestamp : 1526490049 . 0176256 <nl> - confidence : 0 . 12561498582363129 <nl> - confidence_type : CONFIDENCE_CNN <nl> - } <nl> - timestamp : 1526490049 . 0176256 <nl> - predicted_period : 5 <nl> + sequence_num : 13379 <nl> } <nl> perception_error_code : OK <nl> - start_timestamp : 1526490049 . 1209192 <nl> - end_timestamp : 1526490049 . 1214647 <nl> + start_timestamp : 1526490046 . 8162825 <nl> + end_timestamp : 1526490046 . 8165908 <nl> mmm a / modules / planning / testdata / sunnyvale_big_loop_test / 601_routing . pb . txt <nl> ppp b / modules / planning / testdata / sunnyvale_big_loop_test / 601_routing . pb . txt <nl> <nl> header { <nl> - timestamp_sec : 1527801499 . 9811609 <nl> + timestamp_sec : 1528332691 . 6119256 <nl> module_name : " routing " <nl> - sequence_num : 5 <nl> + sequence_num : 2 <nl> } <nl> road { <nl> id : " 2716 " <nl> passage { <nl> segment { <nl> id : " 2716_1_ - 1 " <nl> - start_s : 1 . 4634490889935299 <nl> + start_s : 8 . 088348859428967 <nl> end_s : 22 . 4733 <nl> } <nl> can_exit : true <nl> road { <nl> segment { <nl> id : " 2690_1_ - 1 " <nl> start_s : 0 <nl> - end_s : 18 . 256449451669663 <nl> + end_s : 3 . 5088891146299894 <nl> } <nl> can_exit : true <nl> change_lane_type : FORWARD <nl> } <nl> } <nl> measurement { <nl> - distance : 204 . 14088036267611 <nl> + distance : 182 . 76842025520102 <nl> } <nl> routing_request { <nl> header { <nl> - timestamp_sec : 1527801499 . 9797726 <nl> + timestamp_sec : 1528332691 . 6105404 <nl> module_name : " dreamview " <nl> - sequence_num : 5 <nl> + sequence_num : 1 <nl> } <nl> waypoint { <nl> id : " 2716_1_ - 1 " <nl> - s : 1 . 4634490889935299 <nl> + s : 8 . 088348859428967 <nl> pose { <nl> - x : 587292 . 46682460688 <nl> - y : 4141163 . 5717007895 <nl> + x : 587286 . 02204968582 <nl> + y : 4141165 . 1134451679 <nl> } <nl> } <nl> waypoint { <nl> id : " 2690_1_ - 1 " <nl> - s : 18 . 256449451669663 <nl> + s : 3 . 5088891146299894 <nl> pose { <nl> - x : 587094 . 507407796 <nl> - y : 4141213 . 4539266722 <nl> + x : 587108 . 84545707039 <nl> + y : 4141210 . 0079495981 <nl> } <nl> } <nl> } <nl> mmm a / modules / planning / testdata / sunnyvale_big_loop_test / result_destination_pull_over_01_0 . pb . txt <nl> ppp b / modules / planning / testdata / sunnyvale_big_loop_test / result_destination_pull_over_01_0 . pb . txt <nl> decision { <nl> reason_code : STOP_REASON_PULL_OVER <nl> reason : " stop by PO_DESTINATION " <nl> stop_point { <nl> - x : 587093 . 66896728741 <nl> - y : 4141215 . 4967407207 <nl> + x : 587079 . 10948603891 <nl> + y : 4141219 . 2106658942 <nl> } <nl> - stop_heading : 2 . 8993230046048497 <nl> + stop_heading : 2 . 8985984162210214 <nl> change_lane_type : FORWARD <nl> } <nl> } <nl> decision { <nl> reason_code : STOP_REASON_PULL_OVER <nl> distance_s : - 0 . 5 <nl> stop_point { <nl> - x : 587093 . 66896728741 <nl> - y : 4141215 . 4967407207 <nl> + x : 587079 . 10948603891 <nl> + y : 4141219 . 2106658942 <nl> z : 0 <nl> } <nl> - stop_heading : 2 . 8993230046048497 <nl> + stop_heading : 2 . 8985984162210214 <nl> } <nl> } <nl> } <nl> decision { <nl> } <nl> } <nl> routing_header { <nl> - timestamp_sec : 1527801499 . 9811609 <nl> + timestamp_sec : 1528332691 . 6119256 <nl> module_name : " routing " <nl> - sequence_num : 5 <nl> + sequence_num : 2 <nl> } <nl> - right_of_way_status : PROTECTED <nl> + right_of_way_status : UNPROTECTED <nl> lane_id { <nl> id : " 2693_1_ - 1 " <nl> } <nl> lane_id { <nl> lane_id { <nl> id : " 732_1_ - 1 " <nl> } <nl> - lane_id { <nl> - id : " 141_1_ - 1 " <nl> - } <nl> - lane_id { <nl> - id : " 11105a_1_ - 1 " <nl> - } <nl> engage_advice { <nl> advice : KEEP_ENGAGED <nl> } <nl> mmm a / modules / planning / testdata / sunnyvale_big_loop_test / result_destination_pull_over_01_1 . pb . txt <nl> ppp b / modules / planning / testdata / sunnyvale_big_loop_test / result_destination_pull_over_01_1 . pb . txt <nl> decision { <nl> reason_code : STOP_REASON_PULL_OVER <nl> reason : " stop by PO_DESTINATION " <nl> stop_point { <nl> - x : 587093 . 66896728741 <nl> - y : 4141215 . 4967407207 <nl> + x : 587079 . 10948603891 <nl> + y : 4141219 . 2106658942 <nl> } <nl> - stop_heading : 2 . 8993230046048497 <nl> + stop_heading : 2 . 8985984162210214 <nl> change_lane_type : FORWARD <nl> } <nl> } <nl> decision { <nl> reason_code : STOP_REASON_PULL_OVER <nl> distance_s : - 0 . 5 <nl> stop_point { <nl> - x : 587093 . 66896728741 <nl> - y : 4141215 . 4967407207 <nl> + x : 587079 . 10948603891 <nl> + y : 4141219 . 2106658942 <nl> z : 0 <nl> } <nl> - stop_heading : 2 . 8993230046048497 <nl> + stop_heading : 2 . 8985984162210214 <nl> } <nl> } <nl> } <nl> decision { <nl> } <nl> } <nl> routing_header { <nl> - timestamp_sec : 1527801499 . 9811609 <nl> + timestamp_sec : 1528332691 . 6119256 <nl> module_name : " routing " <nl> - sequence_num : 5 <nl> + sequence_num : 2 <nl> } <nl> right_of_way_status : UNPROTECTED <nl> lane_id { <nl> lane_id { <nl> lane_id { <nl> id : " 732_1_ - 1 " <nl> } <nl> - lane_id { <nl> - id : " 141_1_ - 1 " <nl> - } <nl> - lane_id { <nl> - id : " 11105a_1_ - 1 " <nl> - } <nl> engage_advice { <nl> advice : KEEP_ENGAGED <nl> } <nl> new file mode 100644 <nl> index 00000000000 . . 8140d229f8e <nl> mmm / dev / null <nl> ppp b / modules / planning / testdata / sunnyvale_big_loop_test / result_destination_pull_over_02_0 . pb . txt <nl> <nl> + header { <nl> + module_name : " planning " <nl> + } <nl> + is_replan : true <nl> + gear : GEAR_DRIVE <nl> + decision { <nl> + main_decision { <nl> + stop { <nl> + reason_code : STOP_REASON_PULL_OVER <nl> + reason : " stop by PO_DESTINATION " <nl> + stop_point { <nl> + x : 587079 . 10948603891 <nl> + y : 4141219 . 2106658942 <nl> + } <nl> + stop_heading : 2 . 8985984162210214 <nl> + change_lane_type : FORWARD <nl> + } <nl> + } <nl> + object_decision { <nl> + decision { <nl> + id : " PO_DESTINATION " <nl> + perception_id : - 1274803422 <nl> + object_decision { <nl> + stop { <nl> + reason_code : STOP_REASON_PULL_OVER <nl> + distance_s : - 0 . 5 <nl> + stop_point { <nl> + x : 587079 . 10948603891 <nl> + y : 4141219 . 2106658942 <nl> + z : 0 <nl> + } <nl> + stop_heading : 2 . 8985984162210214 <nl> + } <nl> + } <nl> + } <nl> + } <nl> + vehicle_signal { <nl> + turn_signal : TURN_NONE <nl> + } <nl> + } <nl> + routing_header { <nl> + timestamp_sec : 1528332691 . 6119256 <nl> + module_name : " routing " <nl> + sequence_num : 2 <nl> + } <nl> + right_of_way_status : UNPROTECTED <nl> + lane_id { <nl> + id : " 2693_1_ - 1 " <nl> + } <nl> + lane_id { <nl> + id : " 2691_1_ - 1 " <nl> + } <nl> + lane_id { <nl> + id : " 2690_1_ - 1 " <nl> + } <nl> + lane_id { <nl> + id : " 2688_1_ - 1 " <nl> + } <nl> + lane_id { <nl> + id : " 2687_1_ - 1 " <nl> + } <nl> + lane_id { <nl> + id : " 732_1_ - 1 " <nl> + } <nl> + engage_advice { <nl> + advice : KEEP_ENGAGED <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 5e024f7ae88 <nl> mmm / dev / null <nl> ppp b / modules / planning / testdata / sunnyvale_big_loop_test / result_destination_pull_over_02_1 . pb . txt <nl> <nl> + header { <nl> + module_name : " planning " <nl> + } <nl> + is_replan : false <nl> + gear : GEAR_DRIVE <nl> + decision { <nl> + main_decision { <nl> + stop { <nl> + reason_code : STOP_REASON_PULL_OVER <nl> + reason : " stop by PO_DESTINATION_INLANE " <nl> + stop_point { <nl> + x : 587109 . 97119684669 <nl> + y : 4141209 . 5546708424 <nl> + } <nl> + stop_heading : 2 . 8977181954722679 <nl> + change_lane_type : FORWARD <nl> + } <nl> + } <nl> + object_decision { <nl> + decision { <nl> + id : " PO_DESTINATION_INLANE " <nl> + perception_id : - 2054579289 <nl> + object_decision { <nl> + stop { <nl> + reason_code : STOP_REASON_PULL_OVER <nl> + distance_s : - 0 . 5 <nl> + stop_point { <nl> + x : 587109 . 97119684669 <nl> + y : 4141209 . 5546708424 <nl> + z : 0 <nl> + } <nl> + stop_heading : 2 . 8977181954722679 <nl> + } <nl> + } <nl> + } <nl> + } <nl> + vehicle_signal { <nl> + turn_signal : TURN_NONE <nl> + } <nl> + } <nl> + routing_header { <nl> + timestamp_sec : 1528332691 . 6119256 <nl> + module_name : " routing " <nl> + sequence_num : 2 <nl> + } <nl> + right_of_way_status : UNPROTECTED <nl> + lane_id { <nl> + id : " 2693_1_ - 1 " <nl> + } <nl> + lane_id { <nl> + id : " 2691_1_ - 1 " <nl> + } <nl> + lane_id { <nl> + id : " 2690_1_ - 1 " <nl> + } <nl> + lane_id { <nl> + id : " 2688_1_ - 1 " <nl> + } <nl> + lane_id { <nl> + id : " 2687_1_ - 1 " <nl> + } <nl> + lane_id { <nl> + id : " 732_1_ - 1 " <nl> + } <nl> + engage_advice { <nl> + advice : KEEP_ENGAGED <nl> + } <nl>
planning : more on pull - over inlane stop ( when pull - over fails ) and tests
ApolloAuto/apollo
9d7e9d48627ddceb9b033787855d33c5a9937001
2018-06-07T16:05:31Z
mmm a / tensorflow / compiler / tests / sort_ops_test . py <nl> ppp b / tensorflow / compiler / tests / sort_ops_test . py <nl> def topk ( v , k = k ) : <nl> <nl> def testTopKZeros ( self ) : <nl> " " " Tests that positive and negative zeros sort correctly . " " " <nl> - # Only bfloat16 is implemented . <nl> - bfloat16 = dtypes . bfloat16 . as_numpy_dtype <nl> - if bfloat16 not in self . numeric_types : <nl> - return <nl> - <nl> - with self . session ( ) as sess : <nl> - p = array_ops . placeholder ( dtypes . bfloat16 ) <nl> - with self . test_scope ( ) : <nl> - topk = nn_ops . top_k ( p , k = 4 ) <nl> - results = sess . run ( <nl> - topk , <nl> - { p : np . array ( [ 0 . , - 0 . , 0 . , 3 . , - 0 . , - 4 . , 0 . , - 0 . ] , dtype = bfloat16 ) } ) <nl> - self . assertAllEqual ( <nl> - np . array ( [ 3 . , 0 . , 0 . , 0 . ] , dtype = bfloat16 ) , results [ 0 ] ) <nl> - self . assertEqual ( list ( [ 3 , 0 , 2 , 6 ] ) , list ( results [ 1 ] ) ) <nl> + supported_types = set ( [ dtypes . bfloat16 . as_numpy_dtype , np . float32 ] ) <nl> + for dtype in supported_types . intersection ( self . numeric_types ) : <nl> + with self . session ( ) as sess : <nl> + p = array_ops . placeholder ( dtype ) <nl> + with self . test_scope ( ) : <nl> + topk = nn_ops . top_k ( p , k = 4 ) <nl> + results = sess . run ( <nl> + topk , <nl> + { p : np . array ( [ 0 . , - 0 . , 0 . , 3 . , - 0 . , - 4 . , 0 . , - 0 . ] , dtype = dtype ) } ) <nl> + self . assertAllEqual ( np . array ( [ 3 . , 0 . , 0 . , 0 . ] , dtype = dtype ) , results [ 0 ] ) <nl> + self . assertEqual ( list ( [ 3 , 0 , 2 , 6 ] ) , list ( results [ 1 ] ) ) <nl> <nl> def testTopKInfinities ( self ) : <nl> " " " Tests that positive and negative infinity sort correctly . " " " <nl> - # Only bfloat16 is implemented . <nl> - bfloat16 = dtypes . bfloat16 . as_numpy_dtype <nl> - if bfloat16 not in self . numeric_types : <nl> - return <nl> - <nl> - with self . session ( ) as sess : <nl> - p = array_ops . placeholder ( dtypes . bfloat16 ) <nl> - with self . test_scope ( ) : <nl> - topk = nn_ops . top_k ( p , k = 6 ) <nl> - results = sess . run ( topk , { <nl> - p : np . array ( <nl> - [ 1 , 2 , float ( " inf " ) , - float ( " inf " ) , - 1 , - 2 ] , dtype = bfloat16 ) <nl> - } ) <nl> - self . assertAllEqual ( <nl> - np . array ( <nl> - [ float ( " inf " ) , 2 . 0 , 1 . 0 , - 1 . 0 , - 2 . 0 , - float ( " inf " ) ] , <nl> - dtype = bfloat16 ) , results [ 0 ] ) <nl> - self . assertEqual ( list ( [ 2 , 1 , 0 , 4 , 5 , 3 ] ) , list ( results [ 1 ] ) ) <nl> + supported_types = set ( [ dtypes . bfloat16 . as_numpy_dtype , np . float32 ] ) <nl> + for dtype in supported_types . intersection ( self . numeric_types ) : <nl> + with self . session ( ) as sess : <nl> + p = array_ops . placeholder ( dtype ) <nl> + with self . test_scope ( ) : <nl> + topk = nn_ops . top_k ( p , k = 6 ) <nl> + results = sess . run ( topk , { <nl> + p : <nl> + np . array ( [ 1 , 2 , float ( " inf " ) , - float ( " inf " ) , - 1 , - 2 ] , <nl> + dtype = dtype ) <nl> + } ) <nl> + self . assertAllEqual ( <nl> + np . array ( [ float ( " inf " ) , 2 . 0 , 1 . 0 , - 1 . 0 , - 2 . 0 , - float ( " inf " ) ] , <nl> + dtype = dtype ) , results [ 0 ] ) <nl> + self . assertEqual ( list ( [ 2 , 1 , 0 , 4 , 5 , 3 ] ) , list ( results [ 1 ] ) ) <nl> <nl> def testInTopK ( self ) : <nl> supported_types = set ( [ np . int32 , np . int64 ] ) <nl> mmm a / tensorflow / compiler / xla / service / cpu / BUILD <nl> ppp b / tensorflow / compiler / xla / service / cpu / BUILD <nl> filegroup ( <nl> " runtime_single_threaded_conv2d . cc " , <nl> " runtime_single_threaded_fft . cc " , <nl> " runtime_single_threaded_matmul . cc " , <nl> + " runtime_topk . cc " , <nl> ] , <nl> visibility = [ " : friends " ] , <nl> ) <nl> filegroup ( <nl> " runtime_single_threaded_conv2d . h " , <nl> " runtime_single_threaded_fft . h " , <nl> " runtime_single_threaded_matmul . h " , <nl> + " runtime_topk . h " , <nl> ] , <nl> visibility = [ " : friends " ] , <nl> ) <nl> cc_library ( <nl> " / / tensorflow / compiler / xla / service : copy_insertion " , <nl> " / / tensorflow / compiler / xla / service : hlo_casting_utils " , <nl> " / / tensorflow / compiler / xla / service : dump " , <nl> + " / / tensorflow / compiler / xla / service : topk_rewriter " , <nl> " / / tensorflow / compiler / xla / service : map_inliner " , <nl> " / / tensorflow / compiler / xla / service : rng_bit_generator_expander " , <nl> " / / tensorflow / compiler / xla / service : tree_reduction_rewriter " , <nl> cc_library ( <nl> " : runtime_fft " , <nl> " : runtime_fork_join " , <nl> " : runtime_key_value_sort " , <nl> + " : runtime_topk " , <nl> " : runtime_matmul " , <nl> " : runtime_matmul_mkl " , <nl> " : runtime_single_threaded_conv2d " , <nl> cc_library ( <nl> ] , <nl> ) <nl> <nl> + cc_library ( <nl> + name = " runtime_topk " , <nl> + srcs = [ " runtime_topk . cc " ] , <nl> + hdrs = [ " runtime_topk . h " ] , <nl> + copts = runtime_copts ( ) , <nl> + visibility = [ " / / visibility : public " ] , <nl> + deps = [ <nl> + " / / tensorflow / core / platform : dynamic_annotations " , <nl> + " / / tensorflow / core / platform : macros " , <nl> + " / / tensorflow / core / platform : types " , <nl> + ] , <nl> + ) <nl> + <nl> cc_library ( <nl> name = " runtime_fork_join " , <nl> srcs = [ " runtime_fork_join . cc " ] , <nl> mmm a / tensorflow / compiler / xla / service / cpu / cpu_compiler . cc <nl> ppp b / tensorflow / compiler / xla / service / cpu / cpu_compiler . cc <nl> limitations under the License . <nl> # include " tensorflow / compiler / xla / service / slice_sinker . h " <nl> # include " tensorflow / compiler / xla / service / slow_operation_alarm . h " <nl> # include " tensorflow / compiler / xla / service / sort_simplifier . h " <nl> + # include " tensorflow / compiler / xla / service / topk_rewriter . h " <nl> # include " tensorflow / compiler / xla / service / transpose_folding . h " <nl> # include " tensorflow / compiler / xla / service / tree_reduction_rewriter . h " <nl> # include " tensorflow / compiler / xla / service / triangular_solve_expander . h " <nl> Status CpuCompiler : : RunHloPassesThroughLayoutAssn ( <nl> pass . AddPass < HloConstantFolding > ( ) ; <nl> pass . AddPass < ConditionalSimplifier > ( ) ; <nl> } <nl> + pipeline . AddPass < TopkRewriter > ( [ ] ( const HloSortInstruction * sort , int64 ) { <nl> + return sort - > operand ( 0 ) - > shape ( ) . element_type ( ) = = F32 ; <nl> + } ) ; <nl> pipeline . AddPass < IndexedArrayAnalysisPrinterPass > ( ) ; <nl> pipeline . AddPass < TransposeFolding > ( <nl> [ & ] ( const HloInstruction & dot , <nl> mmm a / tensorflow / compiler / xla / service / cpu / cpu_runtime . cc <nl> ppp b / tensorflow / compiler / xla / service / cpu / cpu_runtime . cc <nl> extern const char * const kParallelForkJoinSymbolName = <nl> " __xla_cpu_runtime_ParallelForkJoin " ; <nl> extern const char * const kKeyValueSortSymbolName = <nl> " __xla_cpu_runtime_KeyValueSort " ; <nl> + extern const char * const kTopKF32SymbolName = " __xla_cpu_runtime_TopKF32 " ; <nl> extern const char * const kTracingStartSymbolName = <nl> " __xla_cpu_runtime_TracingStart " ; <nl> extern const char * const kTracingEndSymbolName = " __xla_cpu_runtime_TracingEnd " ; <nl> mmm a / tensorflow / compiler / xla / service / cpu / cpu_runtime . h <nl> ppp b / tensorflow / compiler / xla / service / cpu / cpu_runtime . h <nl> extern const char * const kAcquireOutfeedBufferForPopulationSymbolName ; <nl> extern const char * const kReleaseOutfeedBufferAfterPopulationSymbolName ; <nl> extern const char * const kParallelForkJoinSymbolName ; <nl> extern const char * const kKeyValueSortSymbolName ; <nl> + extern const char * const kTopKF32SymbolName ; <nl> extern const char * const kAllReduceSymbolName ; <nl> extern const char * const kCollectivePermuteSymbolName ; <nl> extern const char * const kReplicaIdSymbolName ; <nl> mmm a / tensorflow / compiler / xla / service / cpu / ir_emitter . cc <nl> ppp b / tensorflow / compiler / xla / service / cpu / ir_emitter . cc <nl> Status IrEmitter : : HandlePadToStatic ( HloInstruction * hlo ) { <nl> return Status : : OK ( ) ; <nl> } <nl> <nl> + Status IrEmitter : : HandleTopK ( HloInstruction * hlo ) { <nl> + TF_RETURN_IF_ERROR ( EmitTargetAddressForOp ( hlo ) ) ; <nl> + const HloInstruction * input = hlo - > operand ( 0 ) ; <nl> + int64 k = hlo - > shape ( ) . tuple_shapes ( 0 ) . dimensions ( 1 ) ; <nl> + TF_RET_CHECK ( input - > shape ( ) . element_type ( ) = = F32 ) ; <nl> + TF_RET_CHECK ( LayoutUtil : : IsMonotonicWithDim0Major ( <nl> + hlo - > shape ( ) . tuple_shapes ( 0 ) . layout ( ) ) ) ; <nl> + TF_RET_CHECK ( LayoutUtil : : IsMonotonicWithDim0Major ( <nl> + hlo - > shape ( ) . tuple_shapes ( 1 ) . layout ( ) ) ) ; <nl> + TF_RET_CHECK ( <nl> + LayoutUtil : : IsMonotonicWithDim0Major ( hlo - > operand ( 0 ) - > shape ( ) . layout ( ) ) ) ; <nl> + <nl> + TF_ASSIGN_OR_RETURN ( const BufferAllocation : : Slice values_slice , <nl> + assignment_ . GetUniqueSlice ( hlo - > operand ( 0 ) , { } ) ) ; <nl> + TF_ASSIGN_OR_RETURN ( const BufferAllocation : : Slice out_values_slice , <nl> + assignment_ . GetUniqueSlice ( hlo , { 0 } ) ) ; <nl> + TF_ASSIGN_OR_RETURN ( const BufferAllocation : : Slice out_indices_slice , <nl> + assignment_ . GetUniqueSlice ( hlo , { 1 } ) ) ; <nl> + llvm : : Value * values_ptr = <nl> + EmitBufferPointer ( values_slice , hlo - > operand ( 0 ) - > shape ( ) ) ; <nl> + llvm : : Value * out_values_ptr = <nl> + EmitBufferPointer ( out_values_slice , hlo - > shape ( ) . tuple_shapes ( 0 ) ) ; <nl> + llvm : : Value * out_indices_ptr = <nl> + EmitBufferPointer ( out_indices_slice , hlo - > shape ( ) . tuple_shapes ( 1 ) ) ; <nl> + EmitCallToFunc ( runtime : : kTopKF32SymbolName , <nl> + { b_ . getInt64 ( input - > shape ( ) . dimensions ( 0 ) ) , <nl> + b_ . getInt64 ( input - > shape ( ) . dimensions ( 1 ) ) , b_ . getInt64 ( k ) , <nl> + values_ptr , out_values_ptr , out_indices_ptr } , <nl> + b_ . getVoidTy ( ) ) ; <nl> + <nl> + llvm_ir : : EmitTuple ( GetIrArrayFor ( hlo ) , { out_values_ptr , out_indices_ptr } , <nl> + & b_ ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> Status IrEmitter : : HandleCustomCall ( HloInstruction * custom_call ) { <nl> if ( custom_call - > custom_call_target ( ) = = " PadToStatic " ) { <nl> return HandlePadToStatic ( custom_call ) ; <nl> Status IrEmitter : : HandleCustomCall ( HloInstruction * custom_call ) { <nl> if ( custom_call - > custom_call_target ( ) = = " SliceToDynamic " ) { <nl> return HandleSliceToDynamic ( custom_call ) ; <nl> } <nl> + if ( custom_call - > custom_call_target ( ) = = " TopK " ) { <nl> + return HandleTopK ( custom_call ) ; <nl> + } <nl> absl : : Span < HloInstruction * const > operands ( custom_call - > operands ( ) ) ; <nl> llvm : : Type * i8_ptr_type = b_ . getInt8PtrTy ( ) ; <nl> llvm : : AllocaInst * operands_alloca = <nl> mmm a / tensorflow / compiler / xla / service / cpu / ir_emitter . h <nl> ppp b / tensorflow / compiler / xla / service / cpu / ir_emitter . h <nl> class IrEmitter : public DfsHloVisitorWithDefault , <nl> private : <nl> Status HandleSliceToDynamic ( HloInstruction * hlo ) ; <nl> Status HandlePadToStatic ( HloInstruction * hlo ) ; <nl> + Status HandleTopK ( HloInstruction * hlo ) ; <nl> Status HandleAllReduceSingleReplica ( HloInstruction * crs ) ; <nl> Status HandleAllReduceMultipleReplica ( HloInstruction * crs ) ; <nl> <nl> new file mode 100644 <nl> index 0000000000000 . . 5174a3329fb23 <nl> mmm / dev / null <nl> ppp b / tensorflow / compiler / xla / service / cpu / runtime_topk . cc <nl> <nl> + / * Copyright 2020 The TensorFlow Authors . All Rights Reserved . <nl> + <nl> + Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + you may not use this file except in compliance with the License . <nl> + You may obtain a copy of the License at <nl> + <nl> + http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + <nl> + Unless required by applicable law or agreed to in writing , software <nl> + distributed under the License is distributed on an " AS IS " BASIS , <nl> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + See the License for the specific language governing permissions and <nl> + limitations under the License . <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + <nl> + # include " tensorflow / compiler / xla / service / cpu / runtime_topk . h " <nl> + <nl> + # include < algorithm > <nl> + # include < memory > <nl> + # include < numeric > <nl> + # include < vector > <nl> + <nl> + # include " tensorflow / core / platform / dynamic_annotations . h " <nl> + # include " tensorflow / core / platform / macros . h " <nl> + <nl> + template < typename T > <nl> + static void TopK ( tensorflow : : int64 batch_size , tensorflow : : int64 input_size , <nl> + tensorflow : : int64 k , const T * values , T * out_values , <nl> + tensorflow : : int32 * out_indices ) { <nl> + / / ' values ' is managed by the JIT code , so msan can ' t tell they are <nl> + / / initialized . <nl> + TF_ANNOTATE_MEMORY_IS_INITIALIZED ( values , <nl> + input_size * batch_size * sizeof ( T ) ) ; <nl> + <nl> + std : : vector < tensorflow : : int32 > temp_indices ( input_size ) ; <nl> + for ( tensorflow : : int64 batch = 0 ; batch ! = batch_size ; + + batch ) { <nl> + std : : iota ( temp_indices . begin ( ) , temp_indices . end ( ) , 0 ) ; <nl> + <nl> + const T * values_batch = values + batch * input_size ; <nl> + <nl> + auto convert_to_int = [ ] ( T value ) { <nl> + tensorflow : : uint32 x ; <nl> + std : : memcpy ( & x , & value , sizeof ( x ) ) ; <nl> + return static_cast < tensorflow : : int32 > ( x ) < 0 <nl> + ? std : : numeric_limits < tensorflow : : int32 > : : max ( ) - x <nl> + : x ; <nl> + } ; <nl> + <nl> + auto kth_element = temp_indices . begin ( ) + k ; <nl> + std : : partial_sort ( temp_indices . begin ( ) , kth_element , temp_indices . end ( ) , <nl> + [ & ] ( size_t i1 , size_t i2 ) { <nl> + / / Do the comparison in integers to enforce a total <nl> + / / order of - NaN < - Inf < - 0 < + 0 < + Inf < + NaN . <nl> + tensorflow : : int32 v1 = convert_to_int ( values_batch [ i1 ] ) ; <nl> + tensorflow : : int32 v2 = convert_to_int ( values_batch [ i2 ] ) ; <nl> + if ( v1 = = v2 ) { <nl> + return i1 < i2 ; / / Stabilize sorting . <nl> + } <nl> + return v1 > v2 ; <nl> + } ) ; <nl> + <nl> + T * out_values_batch = out_values + batch * k ; <nl> + tensorflow : : int32 * out_indices_batch = out_indices + batch * k ; <nl> + std : : copy ( temp_indices . begin ( ) , kth_element , out_indices_batch ) ; <nl> + for ( tensorflow : : int64 i = 0 ; i < k ; i + + ) { <nl> + out_values_batch [ i ] = values_batch [ temp_indices [ i ] ] ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + TF_ATTRIBUTE_NO_SANITIZE_MEMORY void __xla_cpu_runtime_TopKF32 ( <nl> + tensorflow : : int64 batch_size , tensorflow : : int64 input_size , <nl> + tensorflow : : int64 k , const float * values , float * out_values , <nl> + tensorflow : : int32 * out_indices ) { <nl> + TopK ( batch_size , input_size , k , values , out_values , out_indices ) ; <nl> + } <nl> new file mode 100644 <nl> index 0000000000000 . . de69c0603e3e2 <nl> mmm / dev / null <nl> ppp b / tensorflow / compiler / xla / service / cpu / runtime_topk . h <nl> <nl> + / * Copyright 2020 The TensorFlow Authors . All Rights Reserved . <nl> + <nl> + Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + you may not use this file except in compliance with the License . <nl> + You may obtain a copy of the License at <nl> + <nl> + http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + <nl> + Unless required by applicable law or agreed to in writing , software <nl> + distributed under the License is distributed on an " AS IS " BASIS , <nl> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + See the License for the specific language governing permissions and <nl> + limitations under the License . <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + <nl> + # ifndef TENSORFLOW_COMPILER_XLA_SERVICE_CPU_RUNTIME_TOPK_H <nl> + # define TENSORFLOW_COMPILER_XLA_SERVICE_CPU_RUNTIME_TOPK_H <nl> + <nl> + # include " tensorflow / core / platform / types . h " <nl> + <nl> + extern " C " { <nl> + <nl> + / / Calculates ` batch_size ` topk operations with ` input_size ` inputs each . The <nl> + / / outputs are written to ` out_values ` and ` out_indices ` . <nl> + extern void __xla_cpu_runtime_TopKF32 ( tensorflow : : int64 batch_size , <nl> + tensorflow : : int64 input_size , <nl> + tensorflow : : int64 k , const float * values , <nl> + float * out_values , <nl> + tensorflow : : int32 * out_indices ) ; <nl> + } <nl> + <nl> + # endif / / TENSORFLOW_COMPILER_XLA_SERVICE_CPU_RUNTIME_TOPK_H <nl> mmm a / tensorflow / compiler / xla / service / cpu / simple_orc_jit . cc <nl> ppp b / tensorflow / compiler / xla / service / cpu / simple_orc_jit . cc <nl> limitations under the License . <nl> # include " tensorflow / compiler / xla / service / cpu / runtime_single_threaded_conv2d . h " <nl> # include " tensorflow / compiler / xla / service / cpu / runtime_single_threaded_fft . h " <nl> # include " tensorflow / compiler / xla / service / cpu / runtime_single_threaded_matmul . h " <nl> + # include " tensorflow / compiler / xla / service / cpu / runtime_topk . h " <nl> # include " tensorflow / compiler / xla / service / cpu / windows_compatibility . h " <nl> # include " tensorflow / compiler / xla / service / custom_call_target_registry . h " <nl> # include " tensorflow / compiler / xla / types . h " <nl> bool RegisterKnownJITSymbols ( ) { <nl> REGISTER_CPU_RUNTIME_SYMBOL ( ReleaseInfeedBufferAfterDequeue ) ; <nl> REGISTER_CPU_RUNTIME_SYMBOL ( ReleaseOutfeedBufferAfterPopulation ) ; <nl> REGISTER_CPU_RUNTIME_SYMBOL ( KeyValueSort ) ; <nl> + REGISTER_CPU_RUNTIME_SYMBOL ( TopKF32 ) ; <nl> REGISTER_CPU_RUNTIME_SYMBOL ( TracingStart ) ; <nl> REGISTER_CPU_RUNTIME_SYMBOL ( TracingEnd ) ; <nl> <nl> mmm a / tensorflow / compiler / xla / service / cpu / tests / BUILD <nl> ppp b / tensorflow / compiler / xla / service / cpu / tests / BUILD <nl> tf_cc_test ( <nl> ] , <nl> ) <nl> <nl> + tf_cc_test ( <nl> + name = " cpu_topk_test " , <nl> + srcs = [ " cpu_topk_test . cc " ] , <nl> + deps = [ <nl> + " : cpu_codegen_test " , <nl> + " / / tensorflow / compiler / xla / client : xla_builder " , <nl> + " / / tensorflow / compiler / xla / client / lib : sorting " , <nl> + " / / tensorflow / compiler / xla / service : hlo " , <nl> + " / / tensorflow / compiler / xla / service / cpu : cpu_compiler " , <nl> + " / / tensorflow / compiler / xla / service / cpu : test_header_helper " , <nl> + " / / tensorflow / core : lib " , <nl> + " / / tensorflow / core : test " , <nl> + " / / tensorflow / core : test_main " , <nl> + ] , <nl> + ) <nl> + <nl> tf_cc_test ( <nl> name = " cpu_vectorization_test " , <nl> srcs = [ " cpu_vectorization_test . cc " ] , <nl> new file mode 100644 <nl> index 0000000000000 . . a4c74cfb8a24e <nl> mmm / dev / null <nl> ppp b / tensorflow / compiler / xla / service / cpu / tests / cpu_topk_test . cc <nl> <nl> + / * Copyright 2020 The TensorFlow Authors . All Rights Reserved . <nl> + <nl> + Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + you may not use this file except in compliance with the License . <nl> + You may obtain a copy of the License at <nl> + <nl> + http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + <nl> + Unless required by applicable law or agreed to in writing , software <nl> + distributed under the License is distributed on an " AS IS " BASIS , <nl> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + See the License for the specific language governing permissions and <nl> + limitations under the License . <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + <nl> + # include < memory > <nl> + <nl> + # include " tensorflow / compiler / xla / client / lib / sorting . h " <nl> + # include " tensorflow / compiler / xla / client / xla_builder . h " <nl> + # include " tensorflow / compiler / xla / service / cpu / cpu_compiler . h " <nl> + # include " tensorflow / compiler / xla / service / cpu / test_target_triple_helper . h " <nl> + # include " tensorflow / compiler / xla / service / cpu / tests / cpu_codegen_test . h " <nl> + <nl> + namespace xla { <nl> + namespace cpu { <nl> + namespace { <nl> + <nl> + using CpuTopKTest = CpuCodegenTest ; <nl> + <nl> + TEST_F ( CpuTopKTest , CallRuntime ) { <nl> + XlaBuilder builder ( TestName ( ) ) ; <nl> + XlaOp input = <nl> + Parameter ( & builder , 0 , ShapeUtil : : MakeShape ( F32 , { 5 , 100 } ) , " input " ) ; <nl> + TopK ( input , 10 ) ; <nl> + TF_ASSERT_OK_AND_ASSIGN ( XlaComputation xla_computation , builder . Build ( ) ) ; <nl> + <nl> + TF_ASSERT_OK_AND_ASSIGN ( ProgramShape program_shape , <nl> + xla_computation . GetProgramShape ( ) ) ; <nl> + HloModuleConfig config ( program_shape ) ; <nl> + TF_ASSERT_OK_AND_ASSIGN ( <nl> + auto module , HloModule : : CreateFromProto ( xla_computation . proto ( ) , config ) ) ; <nl> + <nl> + constexpr char filecheck_pattern [ ] = R " ( <nl> + CHECK : call void @ __xla_cpu_runtime_TopKF32 ( i64 5 , i64 100 , i64 10 , <nl> + ) " ; <nl> + <nl> + CpuAotCompilationOptions options { <nl> + / * triple = * / kTargetTripleForHost , / * cpu_name = * / kTargetCpuForHost , <nl> + / * features = * / " " , <nl> + / * entry_point_name = * / " entry " , <nl> + / * relocation_model = * / CpuAotCompilationOptions : : RelocationModel : : Static } ; <nl> + <nl> + CompileAheadOfTimeAndVerifyIr ( std : : move ( module ) , options , filecheck_pattern , <nl> + / * match_optimized_ir = * / true ) ; <nl> + } <nl> + <nl> + } / / namespace <nl> + } / / namespace cpu <nl> + } / / namespace xla <nl>
[ XLA : CPU ] Add a runtime function for F32 TopK and use TopkRewriter to target it
tensorflow/tensorflow
926642ea7a1a8095cddf3b063c5d19d4478eaeda
2020-08-05T09:20:45Z
mmm a / modules / flann / include / opencv2 / flann / flann . hpp <nl> ppp b / modules / flann / include / opencv2 / flann / flann . hpp <nl> class GenericIndex <nl> <nl> <nl> # define FLANN_DISTANCE_CHECK \ <nl> - if ( : : cvflann : : flann_distance_type ( ) ! = FLANN_DIST_L2 ) { \ <nl> + if ( : : cvflann : : flann_distance_type ( ) ! = cvflann : : FLANN_DIST_L2 ) { \ <nl> printf ( " [ WARNING ] You are using cv : : flann : : Index ( or cv : : flann : : GenericIndex ) and have also changed " \ <nl> " the distance using cvflann : : set_distance_type . This is no longer working as expected " \ <nl> " ( cv : : flann : : Index always uses L2 ) . You should create the index templated on the distance , " \ <nl> Index_ < T > : : Index_ ( const Mat & dataset , const IndexParams & params ) <nl> CV_Assert ( dataset . isContinuous ( ) ) ; <nl> : : cvflann : : Matrix < ElementType > m_dataset ( ( ElementType * ) dataset . ptr < ElementType > ( 0 ) , dataset . rows , dataset . cols ) ; <nl> <nl> - if ( : : cvflann : : flann_distance_type ( ) = = FLANN_DIST_L2 ) { <nl> + if ( : : cvflann : : flann_distance_type ( ) = = cvflann : : FLANN_DIST_L2 ) { <nl> nnIndex_L1 = NULL ; <nl> nnIndex_L2 = new : : cvflann : : Index < L2 < ElementType > > ( m_dataset , params ) ; <nl> } <nl> - else if ( : : cvflann : : flann_distance_type ( ) = = FLANN_DIST_L1 ) { <nl> + else if ( : : cvflann : : flann_distance_type ( ) = = cvflann : : FLANN_DIST_L1 ) { <nl> nnIndex_L1 = new : : cvflann : : Index < L1 < ElementType > > ( m_dataset , params ) ; <nl> nnIndex_L2 = NULL ; <nl> } <nl> FLANN_DEPRECATED int hierarchicalClustering ( const Mat & features , Mat & centers , c <nl> printf ( " [ WARNING ] cv : : flann : : hierarchicalClustering < ELEM_TYPE , DIST_TYPE > is deprecated , use " <nl> " cv : : flann : : hierarchicalClustering < Distance > instead \ n " ) ; <nl> <nl> - if ( : : cvflann : : flann_distance_type ( ) = = FLANN_DIST_L2 ) { <nl> + if ( : : cvflann : : flann_distance_type ( ) = = cvflann : : FLANN_DIST_L2 ) { <nl> return hierarchicalClustering < L2 < ELEM_TYPE > > ( features , centers , params ) ; <nl> } <nl> - else if ( : : cvflann : : flann_distance_type ( ) = = FLANN_DIST_L1 ) { <nl> + else if ( : : cvflann : : flann_distance_type ( ) = = cvflann : : FLANN_DIST_L1 ) { <nl> return hierarchicalClustering < L1 < ELEM_TYPE > > ( features , centers , params ) ; <nl> } <nl> else { <nl>
Fixes
opencv/opencv
d8ebf224445d10fb6b49d58006d9ea1253d809b3
2011-07-18T22:01:42Z
mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> <nl> <nl> cmake_minimum_required ( VERSION 3 . 5 . 1 ) <nl> <nl> - set ( PACKAGE_NAME " grpc " ) <nl> - set ( PACKAGE_VERSION " 1 . 25 . 0 - dev " ) <nl> - set ( gRPC_CORE_VERSION " 8 . 0 . 0 " ) <nl> - set ( PACKAGE_STRING " $ { PACKAGE_NAME } $ { PACKAGE_VERSION } " ) <nl> - set ( PACKAGE_TARNAME " $ { PACKAGE_NAME } - $ { PACKAGE_VERSION } " ) <nl> - set ( PACKAGE_BUGREPORT " https : / / github . com / grpc / grpc / issues / " ) <nl> + set ( PACKAGE_NAME " grpc " ) <nl> + set ( PACKAGE_VERSION " 1 . 25 . 0 - dev " ) <nl> + set ( gRPC_CORE_VERSION " 8 . 0 . 0 " ) <nl> + set ( gRPC_CORE_SOVERSION " 8 " ) <nl> + set ( gRPC_CPP_VERSION " 1 . 25 . 0 - dev " ) <nl> + set ( gRPC_CPP_SOVERSION " 1 " ) <nl> + set ( gRPC_CSHARP_VERSION " 2 . 25 . 0 - dev " ) <nl> + set ( gRPC_CSHARP_SOVERSION " 2 " ) <nl> + set ( PACKAGE_STRING " $ { PACKAGE_NAME } $ { PACKAGE_VERSION } " ) <nl> + set ( PACKAGE_TARNAME " $ { PACKAGE_NAME } - $ { PACKAGE_VERSION } " ) <nl> + set ( PACKAGE_BUGREPORT " https : / / github . com / grpc / grpc / issues / " ) <nl> project ( $ { PACKAGE_NAME } LANGUAGES C CXX ) <nl> <nl> set ( gRPC_INSTALL_BINDIR " bin " CACHE STRING " Installation directory for executables " ) <nl> add_library ( address_sorting <nl> third_party / address_sorting / address_sorting_windows . c <nl> ) <nl> <nl> + set_target_properties ( address_sorting PROPERTIES <nl> + VERSION $ { gRPC_CORE_VERSION } <nl> + SOVERSION $ { gRPC_CORE_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( address_sorting PROPERTIES COMPILE_PDB_NAME " address_sorting " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( alts_test_util <nl> test / core / tsi / alts / handshaker / alts_handshaker_service_api_test_lib . cc <nl> ) <nl> <nl> + set_target_properties ( alts_test_util PROPERTIES <nl> + VERSION $ { gRPC_CORE_VERSION } <nl> + SOVERSION $ { gRPC_CORE_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( alts_test_util PROPERTIES COMPILE_PDB_NAME " alts_test_util " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( gpr <nl> src / core / lib / profiling / stap_timers . cc <nl> ) <nl> <nl> + set_target_properties ( gpr PROPERTIES <nl> + VERSION $ { gRPC_CORE_VERSION } <nl> + SOVERSION $ { gRPC_CORE_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( gpr PROPERTIES COMPILE_PDB_NAME " gpr " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( grpc <nl> src / core / plugin_registry / grpc_plugin_registry . cc <nl> ) <nl> <nl> + set_target_properties ( grpc PROPERTIES <nl> + VERSION $ { gRPC_CORE_VERSION } <nl> + SOVERSION $ { gRPC_CORE_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( grpc PROPERTIES COMPILE_PDB_NAME " grpc " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( grpc_cronet <nl> src / core / tsi / transport_security_grpc . cc <nl> ) <nl> <nl> + set_target_properties ( grpc_cronet PROPERTIES <nl> + VERSION $ { gRPC_CORE_VERSION } <nl> + SOVERSION $ { gRPC_CORE_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( grpc_cronet PROPERTIES COMPILE_PDB_NAME " grpc_cronet " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( grpc_test_util <nl> src / core / ext / filters / http / server / http_server_filter . cc <nl> ) <nl> <nl> + set_target_properties ( grpc_test_util PROPERTIES <nl> + VERSION $ { gRPC_CORE_VERSION } <nl> + SOVERSION $ { gRPC_CORE_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( grpc_test_util PROPERTIES COMPILE_PDB_NAME " grpc_test_util " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( grpc_test_util_unsecure <nl> src / core / ext / filters / http / server / http_server_filter . cc <nl> ) <nl> <nl> + set_target_properties ( grpc_test_util_unsecure PROPERTIES <nl> + VERSION $ { gRPC_CORE_VERSION } <nl> + SOVERSION $ { gRPC_CORE_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( grpc_test_util_unsecure PROPERTIES COMPILE_PDB_NAME " grpc_test_util_unsecure " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( grpc_unsecure <nl> src / core / plugin_registry / grpc_unsecure_plugin_registry . cc <nl> ) <nl> <nl> + set_target_properties ( grpc_unsecure PROPERTIES <nl> + VERSION $ { gRPC_CORE_VERSION } <nl> + SOVERSION $ { gRPC_CORE_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( grpc_unsecure PROPERTIES COMPILE_PDB_NAME " grpc_unsecure " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( reconnect_server <nl> test / core / util / reconnect_server . cc <nl> ) <nl> <nl> + set_target_properties ( reconnect_server PROPERTIES <nl> + VERSION $ { gRPC_CORE_VERSION } <nl> + SOVERSION $ { gRPC_CORE_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( reconnect_server PROPERTIES COMPILE_PDB_NAME " reconnect_server " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( test_tcp_server <nl> test / core / util / test_tcp_server . cc <nl> ) <nl> <nl> + set_target_properties ( test_tcp_server PROPERTIES <nl> + VERSION $ { gRPC_CORE_VERSION } <nl> + SOVERSION $ { gRPC_CORE_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( test_tcp_server PROPERTIES COMPILE_PDB_NAME " test_tcp_server " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( bm_callback_test_service_impl <nl> test / cpp / microbenchmarks / callback_test_service . cc <nl> ) <nl> <nl> + set_target_properties ( bm_callback_test_service_impl PROPERTIES <nl> + VERSION $ { gRPC_CPP_VERSION } <nl> + SOVERSION $ { gRPC_CPP_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( bm_callback_test_service_impl PROPERTIES COMPILE_PDB_NAME " bm_callback_test_service_impl " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( dns_test_util <nl> test / cpp / naming / dns_test_util . cc <nl> ) <nl> <nl> + set_target_properties ( dns_test_util PROPERTIES <nl> + VERSION $ { gRPC_CPP_VERSION } <nl> + SOVERSION $ { gRPC_CPP_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( dns_test_util PROPERTIES COMPILE_PDB_NAME " dns_test_util " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( grpc + + <nl> src / cpp / codegen / codegen_init . cc <nl> ) <nl> <nl> + set_target_properties ( grpc + + PROPERTIES <nl> + VERSION $ { gRPC_CPP_VERSION } <nl> + SOVERSION $ { gRPC_CPP_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( grpc + + PROPERTIES COMPILE_PDB_NAME " grpc + + " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( grpc + + _core_stats <nl> src / cpp / util / core_stats . cc <nl> ) <nl> <nl> + set_target_properties ( grpc + + _core_stats PROPERTIES <nl> + VERSION $ { gRPC_CPP_VERSION } <nl> + SOVERSION $ { gRPC_CPP_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( grpc + + _core_stats PROPERTIES COMPILE_PDB_NAME " grpc + + _core_stats " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( grpc + + _error_details <nl> src / cpp / util / error_details . cc <nl> ) <nl> <nl> + set_target_properties ( grpc + + _error_details PROPERTIES <nl> + VERSION $ { gRPC_CPP_VERSION } <nl> + SOVERSION $ { gRPC_CPP_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( grpc + + _error_details PROPERTIES COMPILE_PDB_NAME " grpc + + _error_details " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( grpc + + _proto_reflection_desc_db <nl> $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / reflection / v1alpha / reflection . grpc . pb . h <nl> ) <nl> <nl> + set_target_properties ( grpc + + _proto_reflection_desc_db PROPERTIES <nl> + VERSION $ { gRPC_CPP_VERSION } <nl> + SOVERSION $ { gRPC_CPP_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( grpc + + _proto_reflection_desc_db PROPERTIES COMPILE_PDB_NAME " grpc + + _proto_reflection_desc_db " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( grpc + + _reflection <nl> $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / reflection / v1alpha / reflection . grpc . pb . h <nl> ) <nl> <nl> + set_target_properties ( grpc + + _reflection PROPERTIES <nl> + VERSION $ { gRPC_CPP_VERSION } <nl> + SOVERSION $ { gRPC_CPP_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( grpc + + _reflection PROPERTIES COMPILE_PDB_NAME " grpc + + _reflection " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( grpc + + _test_config <nl> test / cpp / util / test_config_cc . cc <nl> ) <nl> <nl> + set_target_properties ( grpc + + _test_config PROPERTIES <nl> + VERSION $ { gRPC_CPP_VERSION } <nl> + SOVERSION $ { gRPC_CPP_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( grpc + + _test_config PROPERTIES COMPILE_PDB_NAME " grpc + + _test_config " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( grpc + + _test_util <nl> src / cpp / codegen / codegen_init . cc <nl> ) <nl> <nl> + set_target_properties ( grpc + + _test_util PROPERTIES <nl> + VERSION $ { gRPC_CPP_VERSION } <nl> + SOVERSION $ { gRPC_CPP_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( grpc + + _test_util PROPERTIES COMPILE_PDB_NAME " grpc + + _test_util " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( grpc + + _test_util_unsecure <nl> src / cpp / codegen / codegen_init . cc <nl> ) <nl> <nl> + set_target_properties ( grpc + + _test_util_unsecure PROPERTIES <nl> + VERSION $ { gRPC_CPP_VERSION } <nl> + SOVERSION $ { gRPC_CPP_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( grpc + + _test_util_unsecure PROPERTIES COMPILE_PDB_NAME " grpc + + _test_util_unsecure " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( grpc + + _unsecure <nl> src / cpp / codegen / codegen_init . cc <nl> ) <nl> <nl> + set_target_properties ( grpc + + _unsecure PROPERTIES <nl> + VERSION $ { gRPC_CPP_VERSION } <nl> + SOVERSION $ { gRPC_CPP_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( grpc + + _unsecure PROPERTIES COMPILE_PDB_NAME " grpc + + _unsecure " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( grpc_benchmark <nl> test / cpp / microbenchmarks / helpers . cc <nl> ) <nl> <nl> + set_target_properties ( grpc_benchmark PROPERTIES <nl> + VERSION $ { gRPC_CPP_VERSION } <nl> + SOVERSION $ { gRPC_CPP_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( grpc_benchmark PROPERTIES COMPILE_PDB_NAME " grpc_benchmark " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( grpc_cli_libs <nl> $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / reflection / v1alpha / reflection . grpc . pb . h <nl> ) <nl> <nl> + set_target_properties ( grpc_cli_libs PROPERTIES <nl> + VERSION $ { gRPC_CPP_VERSION } <nl> + SOVERSION $ { gRPC_CPP_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( grpc_cli_libs PROPERTIES COMPILE_PDB_NAME " grpc_cli_libs " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( grpc_plugin_support <nl> src / compiler / ruby_generator . cc <nl> ) <nl> <nl> + set_target_properties ( grpc_plugin_support PROPERTIES <nl> + VERSION $ { gRPC_CPP_VERSION } <nl> + SOVERSION $ { gRPC_CPP_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( grpc_plugin_support PROPERTIES COMPILE_PDB_NAME " grpc_plugin_support " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( grpcpp_channelz <nl> $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / channelz / channelz . grpc . pb . h <nl> ) <nl> <nl> + set_target_properties ( grpcpp_channelz PROPERTIES <nl> + VERSION $ { gRPC_CPP_VERSION } <nl> + SOVERSION $ { gRPC_CPP_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( grpcpp_channelz PROPERTIES COMPILE_PDB_NAME " grpcpp_channelz " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( http2_client_main <nl> test / cpp / interop / http2_client . cc <nl> ) <nl> <nl> + set_target_properties ( http2_client_main PROPERTIES <nl> + VERSION $ { gRPC_CPP_VERSION } <nl> + SOVERSION $ { gRPC_CPP_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( http2_client_main PROPERTIES COMPILE_PDB_NAME " http2_client_main " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( interop_client_helper <nl> test / cpp / interop / client_helper . cc <nl> ) <nl> <nl> + set_target_properties ( interop_client_helper PROPERTIES <nl> + VERSION $ { gRPC_CPP_VERSION } <nl> + SOVERSION $ { gRPC_CPP_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( interop_client_helper PROPERTIES COMPILE_PDB_NAME " interop_client_helper " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( interop_client_main <nl> test / cpp / interop / interop_client . cc <nl> ) <nl> <nl> + set_target_properties ( interop_client_main PROPERTIES <nl> + VERSION $ { gRPC_CPP_VERSION } <nl> + SOVERSION $ { gRPC_CPP_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( interop_client_main PROPERTIES COMPILE_PDB_NAME " interop_client_main " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( interop_server_helper <nl> test / cpp / interop / server_helper . cc <nl> ) <nl> <nl> + set_target_properties ( interop_server_helper PROPERTIES <nl> + VERSION $ { gRPC_CPP_VERSION } <nl> + SOVERSION $ { gRPC_CPP_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( interop_server_helper PROPERTIES COMPILE_PDB_NAME " interop_server_helper " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( interop_server_lib <nl> test / cpp / interop / interop_server . cc <nl> ) <nl> <nl> + set_target_properties ( interop_server_lib PROPERTIES <nl> + VERSION $ { gRPC_CPP_VERSION } <nl> + SOVERSION $ { gRPC_CPP_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( interop_server_lib PROPERTIES COMPILE_PDB_NAME " interop_server_lib " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( interop_server_main <nl> test / cpp / interop / interop_server_bootstrap . cc <nl> ) <nl> <nl> + set_target_properties ( interop_server_main PROPERTIES <nl> + VERSION $ { gRPC_CPP_VERSION } <nl> + SOVERSION $ { gRPC_CPP_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( interop_server_main PROPERTIES COMPILE_PDB_NAME " interop_server_main " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( qps <nl> test / cpp / qps / usage_timer . cc <nl> ) <nl> <nl> + set_target_properties ( qps PROPERTIES <nl> + VERSION $ { gRPC_CPP_VERSION } <nl> + SOVERSION $ { gRPC_CPP_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( qps PROPERTIES COMPILE_PDB_NAME " qps " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( grpc_csharp_ext SHARED <nl> src / csharp / ext / grpc_csharp_ext . c <nl> ) <nl> <nl> + set_target_properties ( grpc_csharp_ext PROPERTIES <nl> + VERSION $ { gRPC_CSHARP_VERSION } <nl> + SOVERSION $ { gRPC_CSHARP_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( grpc_csharp_ext PROPERTIES COMPILE_PDB_NAME " grpc_csharp_ext " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( bad_client_test <nl> test / core / bad_client / bad_client . cc <nl> ) <nl> <nl> + set_target_properties ( bad_client_test PROPERTIES <nl> + VERSION $ { gRPC_CPP_VERSION } <nl> + SOVERSION $ { gRPC_CPP_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( bad_client_test PROPERTIES COMPILE_PDB_NAME " bad_client_test " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( bad_ssl_test_server <nl> test / core / bad_ssl / server_common . cc <nl> ) <nl> <nl> + set_target_properties ( bad_ssl_test_server PROPERTIES <nl> + VERSION $ { gRPC_CORE_VERSION } <nl> + SOVERSION $ { gRPC_CORE_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( bad_ssl_test_server PROPERTIES COMPILE_PDB_NAME " bad_ssl_test_server " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( end2end_tests <nl> test / core / end2end / tests / write_buffering_at_end . cc <nl> ) <nl> <nl> + set_target_properties ( end2end_tests PROPERTIES <nl> + VERSION $ { gRPC_CORE_VERSION } <nl> + SOVERSION $ { gRPC_CORE_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( end2end_tests PROPERTIES COMPILE_PDB_NAME " end2end_tests " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> add_library ( end2end_nosec_tests <nl> test / core / end2end / tests / write_buffering_at_end . cc <nl> ) <nl> <nl> + set_target_properties ( end2end_nosec_tests PROPERTIES <nl> + VERSION $ { gRPC_CORE_VERSION } <nl> + SOVERSION $ { gRPC_CORE_SOVERSION } <nl> + ) <nl> + <nl> if ( WIN32 AND MSVC ) <nl> set_target_properties ( end2end_nosec_tests PROPERTIES COMPILE_PDB_NAME " end2end_nosec_tests " <nl> COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl>
Regenerate CMakeLists . txt
grpc/grpc
c3f4d36687e8fd5b8d70612314aa68f636735f5d
2019-10-24T14:22:39Z
mmm a / src / v8natives . js <nl> ppp b / src / v8natives . js <nl> function ObjectDefineProperties ( obj , properties ) { <nl> throw MakeTypeError ( " obj_ctor_property_non_object " , [ " defineProperties " ] ) ; <nl> var props = ToObject ( properties ) ; <nl> var names = GetOwnEnumerablePropertyNames ( props ) ; <nl> + var descriptors = new InternalArray ( ) ; <nl> for ( var i = 0 ; i < names . length ; i + + ) { <nl> - var name = names [ i ] ; <nl> - var desc = ToPropertyDescriptor ( props [ name ] ) ; <nl> - DefineOwnProperty ( obj , name , desc , true ) ; <nl> + descriptors . push ( ToPropertyDescriptor ( props [ names [ i ] ] ) ) ; <nl> + } <nl> + for ( var i = 0 ; i < names . length ; i + + ) { <nl> + DefineOwnProperty ( obj , names [ i ] , descriptors [ i ] , true ) ; <nl> } <nl> return obj ; <nl> } <nl> mmm a / test / mjsunit / object - define - properties . js <nl> ppp b / test / mjsunit / object - define - properties . js <nl> var x = Object . defineProperties ( obj , desc ) ; <nl> <nl> assertEquals ( x . foo , 10 ) ; <nl> assertEquals ( x . bar , 42 ) ; <nl> + <nl> + <nl> + / / Make sure that all property descriptors are calculated before any <nl> + / / modifications are done . <nl> + <nl> + var object = { } ; <nl> + <nl> + assertThrows ( function ( ) { <nl> + Object . defineProperties ( object , { <nl> + foo : { value : 1 } , <nl> + bar : { value : 2 , get : function ( ) { return 3 ; } } <nl> + } ) ; <nl> + } , TypeError ) ; <nl> + <nl> + assertEquals ( undefined , object . foo ) ; <nl> + assertEquals ( undefined , object . bar ) ; <nl>
Fixed evaluation order issue in defineProperties .
v8/v8
d0fe04447e8dfd9ae8df6d586e23d2a391a7d6a4
2011-10-19T09:52:08Z
mmm a / modules / imgproc / src / opencl / canny . cl <nl> ppp b / modules / imgproc / src / opencl / canny . cl <nl> __kernel void stage1_with_sobel ( __global const uchar * src , int src_step , int src <nl> int value = 1 ; <nl> if ( mag0 > low_thr ) <nl> { <nl> - int a = ( y / ( float ) x ) * TG22 ; <nl> - int b = ( y / ( float ) x ) * TG67 ; <nl> + float x_ = abs ( x ) ; <nl> + float y_ = abs ( y ) ; <nl> <nl> - a = min ( ( int ) abs ( a ) , 1 ) + 1 ; <nl> - b = min ( ( int ) abs ( b ) , 1 ) ; <nl> + int a = ( y_ * TG22 > = x_ ) ? 2 : 1 ; <nl> + int b = ( y_ * TG67 > = x_ ) ? 1 : 0 ; <nl> <nl> / / a = { 1 , 2 } <nl> / / b = { 0 , 1 } <nl> __kernel void stage1_without_sobel ( __global const uchar * dxptr , int dx_step , int <nl> int value = 1 ; <nl> if ( mag0 > low_thr ) <nl> { <nl> - int a = ( y / ( float ) x ) * TG22 ; <nl> - int b = ( y / ( float ) x ) * TG67 ; <nl> + float x_ = abs ( x ) ; <nl> + float y_ = abs ( y ) ; <nl> <nl> - a = min ( ( int ) abs ( a ) , 1 ) + 1 ; <nl> - b = min ( ( int ) abs ( b ) , 1 ) ; <nl> + int a = ( y_ * TG22 > = x_ ) ? 2 : 1 ; <nl> + int b = ( y_ * TG67 > = x_ ) ? 1 : 0 ; <nl> <nl> int dir3 = ( a * b ) & ( ( ( x ^ y ) & 0x80000000 ) > > 31 ) ; <nl> int dir = a * b + 2 * dir3 ; <nl>
Merge pull request from alalek : ocl_fix_canny_ub_9496
opencv/opencv
d743a4c9690165b64ae092eb12566283700ce55c
2017-08-30T13:37:44Z
new file mode 100644 <nl> index 0000000000000 . . ca1255b16b157 <nl> mmm / dev / null <nl> ppp b / tensorflow / contrib / tpu / tpu_estimator . md <nl> <nl> + # Using the Estimator API with TPUs <nl> + <nl> + <nl> + This document describes how to train a TensorFlow model on TPUs using the <nl> + Estimator API . If you are interested in the hardware itself , check out the <nl> + [ Cloud TPU documentation ] ( https : / / cloud . google . com / tpu / docs ) . <nl> + <nl> + The TPU Estimator simplifies running models on a Cloud TPU by automatically <nl> + handling numerous low - level hardware - specific details <nl> + <nl> + [ TOC ] <nl> + <nl> + # # Introduction to Estimator <nl> + <nl> + [ TensorFlow <nl> + tutorials ] ( https : / / www . tensorflow . org / extend / estimators ) cover the Estimator <nl> + API . At a high - level , the Estimator API provides : <nl> + <nl> + * ` Estimator . train ( ) ` - train a model on a given input for a fixed number of <nl> + steps . <nl> + * ` Estimator . evaluate ( ) ` - evaluate the model on a test set . <nl> + * ` Estimator . predict ( ) ` - run inference using the trained model . <nl> + * ` Estimator . export_savedmodel ( ) ` - export your model for serving . <nl> + <nl> + In addition , ` Estimator ` includes default behavior common to training jobs , <nl> + such as saving and restoring checkpoints , creating summaries for TensorBoard , <nl> + etc . <nl> + <nl> + ` Estimator ` requires you to write a ` model_fn ` and an ` input_fn ` , which <nl> + correspond to the model and input portions of your TensorFlow graph . <nl> + <nl> + The following code demonstrates using ` TPUEstimator ` with MNIST example to <nl> + handle training : <nl> + <nl> + def model_fn ( features , labels , mode , params ) : <nl> + " " " A simple CNN . " " " <nl> + del params # unused <nl> + <nl> + input_layer = tf . reshape ( features , [ - 1 , 28 , 28 , 1 ] ) <nl> + conv1 = tf . layers . conv2d ( <nl> + inputs = input_layer , filters = 32 , kernel_size = [ 5 , 5 ] , padding = " same " , <nl> + activation = tf . nn . relu ) <nl> + pool1 = tf . layers . max_pooling2d ( inputs = conv1 , pool_size = [ 2 , 2 ] , strides = 2 ) <nl> + conv2 = tf . layers . conv2d ( <nl> + inputs = pool1 , filters = 64 , kernel_size = [ 5 , 5 ] , <nl> + padding = " same " , activation = tf . nn . relu ) <nl> + pool2 = tf . layers . max_pooling2d ( inputs = conv2 , pool_size = [ 2 , 2 ] , strides = 2 ) <nl> + pool2_flat = tf . reshape ( pool2 , [ - 1 , 7 * 7 * 64 ] ) <nl> + dense = tf . layers . dense ( inputs = pool2_flat , units = 128 , activation = tf . nn . relu ) <nl> + dropout = tf . layers . dropout ( <nl> + inputs = dense , rate = 0 . 4 , training = mode = = tf . estimator . ModeKeys . TRAIN ) <nl> + logits = tf . layers . dense ( inputs = dropout , units = 10 ) <nl> + onehot_labels = tf . one_hot ( indices = tf . cast ( labels , tf . int32 ) , depth = 10 ) <nl> + <nl> + loss = tf . losses . softmax_cross_entropy ( <nl> + onehot_labels = onehot_labels , logits = logits ) <nl> + <nl> + learning_rate = tf . train . exponential_decay ( <nl> + FLAGS . learning_rate , tf . train . get_global_step ( ) , 100000 , 0 . 96 ) <nl> + <nl> + optimizer = tpu_optimizer . CrossShardOptimizer ( <nl> + tf . train . GradientDescentOptimizer ( learning_rate = learning_rate ) ) <nl> + <nl> + train_op = optimizer . minimize ( loss , global_step = tf . train . get_global_step ( ) ) <nl> + return tpu_estimator . TPUEstimatorSpec ( mode = mode , loss = loss , train_op = train_op ) <nl> + <nl> + <nl> + def get_input_fn ( filename ) : <nl> + " " " Returns an ` input_fn ` for train and eval . " " " <nl> + <nl> + def input_fn ( params ) : <nl> + " " " An input_fn to parse 28x28 images from filename using tf . data . " " " <nl> + batch_size = params [ " batch_size " ] <nl> + <nl> + def parser ( serialized_example ) : <nl> + " " " Parses a single tf . Example into image and label tensors . " " " <nl> + features = tf . parse_single_example ( <nl> + serialized_example , <nl> + features = { <nl> + " image_raw " : tf . FixedLenFeature ( [ ] , tf . string ) , <nl> + " label " : tf . FixedLenFeature ( [ ] , tf . int64 ) , <nl> + } ) <nl> + image = tf . decode_raw ( features [ " image_raw " ] , tf . uint8 ) <nl> + image . set_shape ( [ 28 * 28 ] ) <nl> + # Normalize the values of the image from the range [ 0 , 255 ] to [ - 0 . 5 , 0 . 5 ] <nl> + image = tf . cast ( image , tf . float32 ) * ( 1 . / 255 ) - 0 . 5 <nl> + label = tf . cast ( features [ " label " ] , tf . int32 ) <nl> + return image , label <nl> + <nl> + dataset = tf . contrib . data . TFRecordDataset ( <nl> + filename , buffer_size = FLAGS . dataset_reader_buffer_size ) <nl> + dataset = dataset . map ( parser ) . cache ( ) . repeat ( ) . batch ( batch_size ) <nl> + images , labels = dataset . make_one_shot_iterator ( ) . get_next ( ) <nl> + # set_shape to give inputs statically known shapes . <nl> + images . set_shape ( [ batch_size , 28 * 28 ] ) <nl> + labels . set_shape ( [ batch_size ] ) <nl> + return images , labels <nl> + return input_fn <nl> + <nl> + <nl> + def main ( unused_argv ) : <nl> + <nl> + tf . logging . set_verbosity ( tf . logging . INFO ) <nl> + <nl> + run_config = tpu_config . RunConfig ( <nl> + master = FLAGS . master , <nl> + model_dir = FLAGS . model_dir , <nl> + session_config = tf . ConfigProto ( <nl> + allow_soft_placement = True , log_device_placement = True ) , <nl> + tpu_config = tpu_config . TPUConfig ( FLAGS . iterations , FLAGS . num_shards ) , ) <nl> + <nl> + estimator = tpu_estimator . TPUEstimator ( <nl> + model_fn = model_fn , <nl> + use_tpu = FLAGS . use_tpu , <nl> + train_batch_size = FLAGS . batch_size , <nl> + eval_batch_size = FLAGS . batch_size , <nl> + config = run_config ) <nl> + <nl> + estimator . train ( input_fn = get_input_fn ( FLAGS . train_file ) , <nl> + max_steps = FLAGS . train_steps ) <nl> + <nl> + <nl> + Although this code is quite simple by appearance , there are some new <nl> + concepts to learn for using ` TPU ` s . The next section will cover the most <nl> + important details . <nl> + <nl> + # # New Concepts Related to TPU / TPUEstimator <nl> + <nl> + TF programs run with ` TPU Estimator ` use an [ in - graph <nl> + replication ] ( https : / / www . tensorflow . org / deploy / distributed ) approach . <nl> + <nl> + In - graph replication ( also known as single - session replication ) differs from <nl> + the between - graph replication ( also known as multi - session replication ) <nl> + training typically used in distributed TensorFlow . The major <nl> + differences include : <nl> + <nl> + 1 . The TensorFlow Session master is not local anymore . The user python program <nl> + creates one single graph that is replicated across all the cores in the Cloud <nl> + TPU . The typical configuration today sets the TensorFlow session master to be <nl> + the first worker . <nl> + <nl> + 1 . The input pipeline is placed on remote hosts ( instead of local ) to ensure the <nl> + training examples can be fed as fast as possible to TPU system . All queue - based <nl> + input pipelines do not work effectively . Dataset ( tf . data ) is <nl> + required . <nl> + <nl> + 1 . Workers in the TPU system operate in synchronous fashion , and each perform <nl> + the same step at the same time . <nl> + <nl> + Regarding programming model , _ " The programmer picks a ( large ) batch size B and <nl> + writes the program ( and sets hyperparameters ) based on that batch size . The <nl> + system distributes the computation across the available devices . " <nl> + <nl> + To align these , ` TPUEstimator ` wraps the computation ( the ` model_fn ` ) and <nl> + distributes it to all available TPU chips . <nl> + <nl> + To summarize : <nl> + <nl> + - The ` input_fn ` models the input pipeline running on remote host CPU . Use <nl> + ` tf . data ` to program the input Ops . ` input_fn ` is expected to be invoked <nl> + multiple times when using TPU pods . Each handles one device ' s input of the <nl> + global batch . The shard batch size should be retrieved from <nl> + ` params [ ' batch_size ' ] ` . We plan to provide better abstraction about the <nl> + sharding mechanism for ` tf . data ` to remove the ` params [ ' batch_size ' ] ` . <nl> + <nl> + - The ` model_fn ` models the computation which will be replicated and distributed <nl> + to all TPU chips . It should only contains ops that are supported by TPUs . <nl> + <nl> + # # Convert from Vanilla Estimator to TPUEstimator <nl> + <nl> + It is always recommended to port a small , simple model first to make sure that <nl> + you are familiar with the basic concepts of ` TPUEstimator ` and test end - to - end <nl> + behavior . Once your simple model runs , gradually add more functionality . <nl> + In addition , there are several sample models , available at <nl> + [ github . com / tensorflow / tpu - demos ] ( https : / / github . com / tensorflow / tpu - demos ) . <nl> + <nl> + To convert your code from the vanilla ` Estimator ` class to use TPUs , change the <nl> + following ( note some of the details may change over time ) : <nl> + <nl> + - Switch from ` tf . estimator . RunConfig ` to ` tf . contrib . tpu . RunConfig ` . <nl> + - Set the ` TPUConfig ` ( part of the ` tf . contrib . tpu . RunConfig ` ) to specify the <nl> + ` iterations_per_loop ` , number of iterations to run on the TPU device for one <nl> + ` session . run ` call ( per training loop ) , and ` num_shards ` , the number of shards <nl> + ( typically the number of TPU cores you ’ re running on ) . TPUs run a number of <nl> + iterations of the training loop before returning to host . Until all iterations <nl> + on the TPU device are run , no checkpoints or summaries will be saved . In the <nl> + future , we ’ ll choose a reasonable default . <nl> + - In ` model_fn ` , use ` tf . contrib . tpu . CrossShardOptimizer ` to wrap your <nl> + optimizer . Example : <nl> + <nl> + optimizer = tpu_optimizer . CrossShardOptimizer ( <nl> + tf . train . GradientDescentOptimizer ( learning_rate = learning_rate ) ) <nl> + <nl> + - Switch from ` tf . estimator . Estimator ` to ` tf . contrib . tpu . TPUEstimator ` . <nl> + <nl> + The default ` RunConfig ` will save summaries for TensorBoard every 100 steps and <nl> + write checkpoints every 10 minutes . <nl> + <nl> + <nl> + # # FAQ <nl> + <nl> + # # # Why ` tf . data ` is Required for the Input Pipeline <nl> + <nl> + There are two reasons : <nl> + <nl> + 1 . The user code runs on the client , while the TPU computation is executed on <nl> + the ` worker ` . Input pipeline ops must be placed on the remote worker for <nl> + good performance . Only ` tf . data ` ( Dataset ) supports this . <nl> + <nl> + 1 . In order to amortize the TPU launch cost , the model train step is wrapped in <nl> + a ` tf . while_loop ` , such that one ` Session . run ` actually runs many iterations <nl> + for one train loop . To remove network back and forth , the input pipeline <nl> + in the future will be wrapped in a ` tf . while_loop ` and be placed on the <nl> + corresponding ` worker ` . Withou this , unnecessary network latency becomes <nl> + the performance bottleneck for models with short training - step times , or in <nl> + environments where network latency is higher . Only ` tf . data ` can be wrapped <nl> + by a ` tf . while_loop ` . <nl> + <nl> + <nl> + # # # How to add other CPU Ops into Graph <nl> + As ` model_fn ` only allows TPU Ops for computation , the easier workaround to add <nl> + CPU Ops into Graph is : <nl> + <nl> + 1 . Create a [ SessionRunHook ] ( https : / / www . tensorflow . org / api_docs / python / tf / train / SessionRunHook ) . <nl> + 1 . Modify the graph in the ` def begin ( self ) ` , <nl> + 1 . Pass the hook to ` TPUEstimator . train ` . <nl> + <nl> + # # # Running On GCP Cloud TPUs <nl> + To run your models on GCP Cloud TPUs refer to the [ Cloud Documentation ] ( https : / / cloud . google . com / tpu / docs / tutorials / mnist ) . <nl> + Refer to this link for all [ Cloud TPU documentation ] ( https : / / cloud . google . com / tpu / docs ) . <nl> + <nl> + <nl> + # # # Profiling <nl> + You can profile the ` worker ` by using instructions as spcified in the [ Cloud TPU Tools ] ( https : / / cloud . google . com / tpu / docs / cloud - tpu - tools ) . <nl> + <nl> + <nl> + # # # Is ` int64 ` supported ? <nl> + ` int64 ` is not supported by TPU . Cast to int32 if applicable . The only exception <nl> + is global step , which relies on ` assign_add ` . ` int64 ` support for global step <nl> + is added to ensure checkpoint compatibility between ` TPUEstimator ` and non - TPU <nl> + ` Estimator ` . <nl>
Publish TPU Estimators Docs on github
tensorflow/tensorflow
f33f0996924a00631f7b344c6a289df3510a3db1
2018-01-19T22:13:00Z
mmm a / docs / DebuggingTheCompiler . rst <nl> ppp b / docs / DebuggingTheCompiler . rst <nl> debugging press < CTRL > - C on the LLDB prompt . <nl> Note that this only works in Xcode if the PATH variable in the scheme ' s <nl> environment setting contains the path to the dot tool . <nl> <nl> + Debugging and Profiling on SIL level <nl> + ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` <nl> + <nl> + The compiler provides a way to debug and profile on SIL level . To enable SIL <nl> + debugging add the front - end option - gsil together with - g . Example : : <nl> + <nl> + swiftc - g - Xfrontend - gsil - O test . swift - o a . out <nl> + <nl> + This writes the SIL after optimizations into a file and generates debug info <nl> + for it . In the debugger and profiler you can then see the SIL code instead of <nl> + the swift source code . <nl> + For details see the SILDebugInfoGenerator pass . <nl> + <nl> Other Utilities <nl> ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` <nl> <nl> mmm a / include / swift / AST / SILOptions . h <nl> ppp b / include / swift / AST / SILOptions . h <nl> <nl> # ifndef SWIFT_AST_SILOPTIONS_H <nl> # define SWIFT_AST_SILOPTIONS_H <nl> <nl> + # include " llvm / ADT / StringRef . h " <nl> # include < string > <nl> # include < climits > <nl> <nl> class SILOptions { <nl> bool EmitProfileCoverageMapping = false ; <nl> <nl> / / / Should we use a pass pipeline passed in via a json file ? Null by default . <nl> - StringRef ExternalPassPipelineFilename ; <nl> + llvm : : StringRef ExternalPassPipelineFilename ; <nl> <nl> / / / Emit captures and function contexts using + 0 caller - guaranteed ARC <nl> / / / conventions . <nl> bool EnableGuaranteedClosureContexts = false ; <nl> + <nl> + / / / The name of the SIL outputfile if compiled with SIL debugging ( - gsil ) . <nl> + std : : string SILOutputFileNameForDebugging ; <nl> } ; <nl> <nl> } / / end namespace swift <nl> mmm a / include / swift / Option / FrontendOptions . td <nl> ppp b / include / swift / Option / FrontendOptions . td <nl> def print_inst_counts : Flag < [ " - " ] , " print - inst - counts " > , <nl> HelpText < " Before IRGen , count all the various SIL instructions . Must be used " <nl> " in conjunction with - print - stats . " > ; <nl> <nl> + def debug_on_sil : Flag < [ " - " ] , " gsil " > , <nl> + HelpText < " Write the SIL into a file and generate debug - info to debug on SIL " <nl> + " level . " > ; <nl> + <nl> def print_llvm_inline_tree : Flag < [ " - " ] , " print - llvm - inline - tree " > , <nl> HelpText < " Print the LLVM inline tree . " > ; <nl> <nl> mmm a / include / swift / SIL / SILCoverageMap . h <nl> ppp b / include / swift / SIL / SILCoverageMap . h <nl> <nl> # include " swift / Basic / SourceLoc . h " <nl> # include " swift / SIL / SILAllocated . h " <nl> # include " swift / SIL / SILFunction . h " <nl> + # include " swift / SIL / SILPrintContext . h " <nl> # include " llvm / ADT / ilist_node . h " <nl> # include " llvm / ADT / ilist . h " <nl> # include " llvm / ProfileData / CoverageMapping . h " <nl> class SILCoverageMap : public llvm : : ilist_node < SILCoverageMap > , <nl> void printCounter ( llvm : : raw_ostream & OS , llvm : : coverage : : Counter C ) const ; <nl> <nl> / / / Print the coverage map . <nl> - void print ( llvm : : raw_ostream & OS , bool ShouldSort = false , <nl> - bool Verbose = false ) const ; <nl> + void print ( llvm : : raw_ostream & OS , bool Verbose = false , <nl> + bool ShouldSort = false ) const { <nl> + SILPrintContext Ctx ( OS , Verbose , ShouldSort ) ; <nl> + print ( Ctx ) ; <nl> + } <nl> + <nl> + void print ( SILPrintContext & PrintCtx ) const ; <nl> + <nl> void dump ( ) const ; <nl> } ; <nl> <nl> mmm a / include / swift / SIL / SILFunction . h <nl> ppp b / include / swift / SIL / SILFunction . h <nl> <nl> # include " swift / SIL / SILBasicBlock . h " <nl> # include " swift / SIL / SILDebugScope . h " <nl> # include " swift / SIL / SILLinkage . h " <nl> + # include " swift / SIL / SILPrintContext . h " <nl> # include " llvm / ADT / StringMap . h " <nl> <nl> / / / The symbol name used for the program entry point function . <nl> class SILFunction <nl> / / / cannot be opened . <nl> void dump ( const char * FileName ) const ; <nl> <nl> - / / Helper for SILFunction : : print ( ) . <nl> - struct ScopeSlotTracker { <nl> - llvm : : DenseMap < const SILDebugScope * , unsigned > ScopeToIDMap ; <nl> - unsigned ScopeIndex = 0 ; <nl> - } ; <nl> - <nl> - / / / Pretty - print the SILFunction with the designated stream as a ' sil ' <nl> - / / / definition . <nl> + / / / Pretty - print the SILFunction to the tream \ p OS . <nl> / / / <nl> - / / / \ param Verbose In verbose mode , print the SIL locations . <nl> - void print ( raw_ostream & OS , bool Verbose = false , <nl> - bool SortedSIL = false ) const { <nl> - SILFunction : : ScopeSlotTracker Tracker ; <nl> - print ( OS , Tracker , Verbose , SortedSIL ) ; <nl> + / / / \ param Verbose Dump SIL location information in verbose mode . <nl> + void print ( raw_ostream & OS , bool Verbose = false ) const { <nl> + SILPrintContext PrintCtx ( OS , Verbose ) ; <nl> + print ( PrintCtx ) ; <nl> } <nl> <nl> - / / / Version of print that accepts a ScopeSlotTracker . <nl> - void print ( raw_ostream & OS , ScopeSlotTracker & ScopeTracker , bool Verbose , <nl> - bool SortedSIL ) const ; <nl> + / / / Pretty - print the SILFunction with the context \ p PrintCtx . <nl> + void print ( SILPrintContext & PrintCtx ) const ; <nl> <nl> / / / Pretty - print the SILFunction ' s name using SIL syntax , <nl> / / / ' @ function_mangled_name ' . <nl> mmm a / include / swift / SIL / SILInstruction . h <nl> ppp b / include / swift / SIL / SILInstruction . h <nl> class SILInstruction : public ValueBase , public llvm : : ilist_node < SILInstruction > { <nl> const SILDebugScope * getDebugScope ( ) const ; <nl> SILDebugLocation getDebugLocation ( ) const { return Location ; } <nl> <nl> + / / / Sets the debug location . <nl> + / / / Note : Usually it should not be needed to use this function as the location <nl> + / / / is already set in when creating an instruction . <nl> + void setDebugLocation ( SILDebugLocation Loc ) { Location = Loc ; } <nl> + <nl> / / / removeFromParent - This method unlinks ' self ' from the containing basic <nl> / / / block , but does not delete it . <nl> / / / <nl> mmm a / include / swift / SIL / SILLocation . h <nl> ppp b / include / swift / SIL / SILLocation . h <nl> class SILLocation { <nl> DebugInfoKind = 1 < < 3 | 1 < < 4 <nl> } ; <nl> <nl> - typedef struct { <nl> - unsigned Line = 0 , Column = 0 ; <nl> - const char * Filename = nullptr ; <nl> - } DebugLoc ; <nl> + struct DebugLoc { <nl> + unsigned Line ; <nl> + unsigned Column ; <nl> + const char * Filename ; <nl> + <nl> + DebugLoc ( unsigned Line = 0 , unsigned Column = 0 , <nl> + const char * Filename = nullptr ) : Line ( Line ) , Column ( Column ) , <nl> + Filename ( Filename ) { } <nl> + } ; <nl> <nl> protected : <nl> union UnderlyingLocation { <nl> mmm a / include / swift / SIL / SILModule . h <nl> ppp b / include / swift / SIL / SILModule . h <nl> <nl> # include " swift / SIL / SILVTable . h " <nl> # include " swift / SIL / SILWitnessTable . h " <nl> # include " swift / SIL / TypeLowering . h " <nl> + # include " swift / SIL / SILPrintContext . h " <nl> # include " llvm / ADT / ArrayRef . h " <nl> # include " llvm / ADT / Optional . h " <nl> # include " llvm / ADT / PointerIntPair . h " <nl> class SILModule { <nl> / / / \ param PrintASTDecls If set to true print AST decls . <nl> void print ( raw_ostream & OS , bool Verbose = false , <nl> ModuleDecl * M = nullptr , bool ShouldSort = false , <nl> + bool PrintASTDecls = true ) const { <nl> + SILPrintContext PrintCtx ( OS , Verbose , ShouldSort ) ; <nl> + print ( PrintCtx , M , PrintASTDecls ) ; <nl> + } <nl> + <nl> + / / / Pretty - print the module with the context \ p PrintCtx . <nl> + / / / <nl> + / / / \ param M If present , the types and declarations from this module will be <nl> + / / / printed . The module would usually contain the types and Decls that <nl> + / / / the SIL module depends on . <nl> + / / / \ param PrintASTDecls If set to true print AST decls . <nl> + void print ( SILPrintContext & PrintCtx , ModuleDecl * M = nullptr , <nl> bool PrintASTDecls = true ) const ; <nl> <nl> / / / Allocate memory using the module ' s internal allocator . <nl> new file mode 100644 <nl> index 000000000000 . . 3525c379388b <nl> mmm / dev / null <nl> ppp b / include / swift / SIL / SILPrintContext . h <nl> <nl> + / / = = = mmm - SILPrintContext - Context for SIL print functions mmm - - * - C + + - * - = = = / / <nl> + / / <nl> + / / This source file is part of the Swift . org open source project <nl> + / / <nl> + / / Copyright ( c ) 2014 - 2016 Apple Inc . and the Swift project authors <nl> + / / Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + / / <nl> + / / See http : / / swift . org / LICENSE . txt for license information <nl> + / / See http : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + <nl> + # ifndef SWIFT_SIL_PRINTCONTEXT_H <nl> + # define SWIFT_SIL_PRINTCONTEXT_H <nl> + <nl> + # include " llvm / ADT / DenseMap . h " <nl> + # include " llvm / Support / raw_ostream . h " <nl> + <nl> + namespace swift { <nl> + <nl> + class SILDebugScope ; <nl> + class SILInstruction ; <nl> + class SILFunction ; <nl> + <nl> + / / / Used as context for the SIL print functions . <nl> + class SILPrintContext { <nl> + protected : <nl> + llvm : : raw_ostream & OutStream ; <nl> + <nl> + llvm : : DenseMap < const SILDebugScope * , unsigned > ScopeToIDMap ; <nl> + <nl> + / / / Dump more information in the SIL output . <nl> + bool Verbose ; <nl> + <nl> + / / / Sort all kind of tables to ease diffing . <nl> + bool SortedSIL ; <nl> + <nl> + public : <nl> + SILPrintContext ( llvm : : raw_ostream & OS , bool Verbose = false , <nl> + bool SortedSIL = false ) : <nl> + OutStream ( OS ) , Verbose ( Verbose ) , SortedSIL ( SortedSIL ) { } <nl> + <nl> + virtual ~ SILPrintContext ( ) ; <nl> + <nl> + / / / Returns the output stream for printing . <nl> + llvm : : raw_ostream & OS ( ) const { return OutStream ; } <nl> + <nl> + / / / Returns true if the SIL output should be sorted . <nl> + bool sortSIL ( ) const { return SortedSIL ; } <nl> + <nl> + / / / Returns true if verbose SIL should be printed . <nl> + bool printVerbose ( ) const { return Verbose ; } <nl> + <nl> + / / / Returns true if the \ p Scope has and ID assigned . <nl> + bool hasScopeID ( const SILDebugScope * Scope ) const { <nl> + return ScopeToIDMap . count ( Scope ) ! = 0 ; <nl> + } <nl> + <nl> + / / / Returns the ID of \ p Scope . <nl> + unsigned getScopeID ( const SILDebugScope * Scope ) const { <nl> + return ScopeToIDMap . lookup ( Scope ) ; <nl> + } <nl> + <nl> + / / / Assigns the next available ID to \ p Scope . <nl> + unsigned assignScopeID ( const SILDebugScope * Scope ) { <nl> + assert ( ! hasScopeID ( Scope ) ) ; <nl> + unsigned ID = ScopeToIDMap . size ( ) + 1 ; <nl> + ScopeToIDMap . insert ( { Scope , ID } ) ; <nl> + return ID ; <nl> + } <nl> + <nl> + / / / Callback which is invoked by the SILPrinter before the instruction \ p I <nl> + / / / is written . <nl> + virtual void printInstructionCallBack ( const SILInstruction * I ) ; <nl> + } ; <nl> + <nl> + } / / end namespace swift <nl> + <nl> + # endif / * SWIFT_SIL_PRINTCONTEXT_H * / <nl> mmm a / include / swift / SILOptimizer / PassManager / Passes . def <nl> ppp b / include / swift / SILOptimizer / PassManager / Passes . def <nl> PASS ( SILCleanup , " cleanup " , <nl> " Cleanup SIL in preparation for IRGen " ) <nl> PASS ( SILCombine , " sil - combine " , <nl> " Perform small peepholes and combine operations " ) <nl> + PASS ( SILDebugInfoGenerator , " sil - debuginfo - gen " , <nl> + " Write a SIL file for debugging " ) <nl> PASS ( SILLinker , " linker " , <nl> " Link in all of the serialized SIL referenced in the module " ) <nl> PASS ( SROA , " sroa " , <nl> mmm a / lib / Frontend / CompilerInvocation . cpp <nl> ppp b / lib / Frontend / CompilerInvocation . cpp <nl> static bool ParseSILArgs ( SILOptions & Opts , ArgList & Args , <nl> Opts . EnableGuaranteedClosureContexts | = <nl> Args . hasArg ( OPT_enable_guaranteed_closure_contexts ) ; <nl> <nl> + if ( Args . hasArg ( OPT_debug_on_sil ) ) { <nl> + / / Derive the name of the SIL file for debugging from <nl> + / / the regular outputfile . <nl> + StringRef BaseName = FEOpts . getSingleOutputFilename ( ) ; <nl> + / / If there are no or multiple outputfiles , derive the name <nl> + / / from the module name . <nl> + if ( BaseName . empty ( ) ) <nl> + BaseName = FEOpts . ModuleName ; <nl> + Opts . SILOutputFileNameForDebugging = BaseName . str ( ) ; <nl> + } <nl> return false ; <nl> } <nl> <nl> void CompilerInvocation : : buildDWARFDebugFlags ( std : : string & Output , <nl> static bool ParseIRGenArgs ( IRGenOptions & Opts , ArgList & Args , <nl> DiagnosticEngine & Diags , <nl> const FrontendOptions & FrontendOpts , <nl> + const SILOptions & SILOpts , <nl> StringRef SDKPath , <nl> StringRef ResourceDir , <nl> const llvm : : Triple & Triple ) { <nl> using namespace options ; <nl> <nl> - if ( const Arg * A = Args . getLastArg ( OPT_g_Group ) ) { <nl> + if ( ! SILOpts . SILOutputFileNameForDebugging . empty ( ) ) { <nl> + Opts . DebugInfoKind = IRGenDebugInfoKind : : LineTables ; <nl> + } else if ( const Arg * A = Args . getLastArg ( OPT_g_Group ) ) { <nl> if ( A - > getOption ( ) . matches ( OPT_g ) ) <nl> Opts . DebugInfoKind = IRGenDebugInfoKind : : Normal ; <nl> else if ( A - > getOption ( ) . matches ( options : : OPT_gline_tables_only ) ) <nl> static bool ParseIRGenArgs ( IRGenOptions & Opts , ArgList & Args , <nl> <nl> / / TODO : investigate whether these should be removed , in favor of definitions <nl> / / in other classes . <nl> - if ( FrontendOpts . PrimaryInput & & FrontendOpts . PrimaryInput - > isFilename ( ) ) { <nl> + if ( ! SILOpts . SILOutputFileNameForDebugging . empty ( ) ) { <nl> + Opts . MainInputFilename = SILOpts . SILOutputFileNameForDebugging ; <nl> + } else if ( FrontendOpts . PrimaryInput & & FrontendOpts . PrimaryInput - > isFilename ( ) ) { <nl> unsigned Index = FrontendOpts . PrimaryInput - > Index ; <nl> Opts . MainInputFilename = FrontendOpts . InputFilenames [ Index ] ; <nl> } else if ( FrontendOpts . InputFilenames . size ( ) = = 1 ) { <nl> bool CompilerInvocation : : parseArgs ( ArrayRef < const char * > Args , <nl> return true ; <nl> } <nl> <nl> - if ( ParseIRGenArgs ( IRGenOpts , ParsedArgs , Diags , FrontendOpts , <nl> + if ( ParseIRGenArgs ( IRGenOpts , ParsedArgs , Diags , FrontendOpts , SILOpts , <nl> getSDKPath ( ) , SearchPathOpts . RuntimeResourcePath , <nl> LangOpts . Target ) ) { <nl> return true ; <nl> mmm a / lib / IRGen / IRGen . cpp <nl> ppp b / lib / IRGen / IRGen . cpp <nl> void swift : : performLLVMOptimizations ( IRGenOptions & Opts , llvm : : Module * Module , <nl> class MD5Stream : public llvm : : raw_ostream { <nl> private : <nl> <nl> - uint64_t Pos ; <nl> + uint64_t Pos = 0 ; <nl> llvm : : MD5 Hash ; <nl> <nl> void write_impl ( const char * Ptr , size_t Size ) override { <nl> mmm a / lib / IRGen / IRGenDebugInfo . cpp <nl> ppp b / lib / IRGen / IRGenDebugInfo . cpp <nl> static SILLocation : : DebugLoc getDebugLocation ( Optional < SILLocation > OptLoc , <nl> } <nl> <nl> <nl> - / / / Extract the start location from a SILLocation . <nl> - / / / <nl> - / / / This returns a FullLocation , which contains the location that <nl> - / / / should be used for the linetable and the " true " AST location ( used <nl> - / / / for , e . g . , variable declarations ) . <nl> - static FullLocation getFullLocation ( Optional < SILLocation > OptLoc , <nl> - SourceManager & SM ) { <nl> - if ( ! OptLoc ) <nl> - return { } ; <nl> - <nl> - SILLocation Loc = OptLoc . getValue ( ) ; <nl> - return { Loc . decodeDebugLoc ( SM ) , <nl> - SILLocation : : decode ( Loc . getSourceLoc ( ) , SM ) } ; <nl> - } <nl> - <nl> / / / Determine whether this debug scope belongs to an explicit closure . <nl> static bool isExplicitClosure ( const SILDebugScope * DS ) { <nl> if ( DS ) { <nl> llvm : : DISubprogram * IRGenDebugInfo : : emitFunction ( <nl> unsigned ScopeLine = 0 ; / / / The source line used for the function prologue . <nl> / / Bare functions and thunks should not have any line numbers . This <nl> / / is especially important for shared functions like reabstraction <nl> - / / thunk helpers , where getFullLocation ( ) returns an arbitrary location <nl> - / / of whichever use was emitted first . <nl> + / / thunk helpers , where DS - > Loc is an arbitrary location of whichever use <nl> + / / was emitted first . <nl> if ( DS & & ( ! SILFn | | ( ! SILFn - > isBare ( ) & & ! SILFn - > isThunk ( ) ) ) ) { <nl> - auto FL = getFullLocation ( DS - > Loc , SM ) ; <nl> - L = FL . Loc ; <nl> - ScopeLine = FL . LocForLinetable . Line ; <nl> + L = DS - > Loc . decodeDebugLoc ( SM ) ; <nl> + ScopeLine = L . Line ; <nl> + if ( ! DS - > Loc . isDebugInfoLoc ( ) ) <nl> + L = SILLocation : : decode ( DS - > Loc . getSourceLoc ( ) , SM ) ; <nl> } <nl> <nl> auto Line = L . Line ; <nl> mmm a / lib / IRGen / IRGenDebugInfo . h <nl> ppp b / lib / IRGen / IRGenDebugInfo . h <nl> namespace irgen { <nl> <nl> class IRGenFunction ; <nl> <nl> - typedef struct { SILLocation : : DebugLoc LocForLinetable , Loc ; } FullLocation ; <nl> - <nl> typedef llvm : : DenseMap < const llvm : : MDString * , llvm : : TrackingMDNodeRef > <nl> TrackingDIRefMap ; <nl> <nl> mmm a / lib / SIL / SILLocation . cpp <nl> ppp b / lib / SIL / SILLocation . cpp <nl> SourceLoc SILLocation : : getSourceLoc ( ) const { <nl> if ( isSILFile ( ) ) <nl> return Loc . SILFileLoc ; <nl> <nl> + / / Don ' t crash if the location is a DebugLoc . <nl> + / / TODO : this is a workaround until rdar : / / problem / 25225083 is implemented . <nl> + if ( isDebugInfoLoc ( ) ) <nl> + return SourceLoc ( ) ; <nl> + <nl> return getSourceLoc ( Loc . ASTNode . Primary ) ; <nl> } <nl> <nl> mmm a / lib / SIL / SILPrinter . cpp <nl> ppp b / lib / SIL / SILPrinter . cpp <nl> <nl> # include " swift / Strings . h " <nl> # include " swift / Basic / DemangleWrappers . h " <nl> # include " swift / Basic / QuotedString . h " <nl> + # include " swift / SIL / SILPrintContext . h " <nl> # include " swift / SIL / CFG . h " <nl> # include " swift / SIL / SILFunction . h " <nl> # include " swift / SIL / SILCoverageMap . h " <nl> namespace { <nl> / / / SILPrinter class - This holds the internal implementation details of <nl> / / / printing SIL structures . <nl> class SILPrinter : public SILVisitor < SILPrinter > { <nl> + SILPrintContext & Ctx ; <nl> struct { <nl> llvm : : formatted_raw_ostream OS ; <nl> PrintOptions ASTOptions ; <nl> } PrintState ; <nl> SILValue subjectValue ; <nl> - bool Verbose ; <nl> - bool SortedSIL ; <nl> unsigned LastBufferID ; <nl> <nl> llvm : : DenseMap < const SILBasicBlock * , unsigned > BlocksToIDMap ; <nl> llvm : : DenseMap < const ValueBase * , unsigned > ValueToIDMap ; <nl> - SILFunction : : ScopeSlotTracker * ScopeSlots ; <nl> - std : : unique_ptr < SILFunction : : ScopeSlotTracker > ManagedScopeSlotTracker ; <nl> <nl> / / Printers for the underlying stream . <nl> # define SIMPLE_PRINTER ( TYPE ) \ <nl> class SILPrinter : public SILVisitor < SILPrinter > { <nl> <nl> public : <nl> SILPrinter ( <nl> - raw_ostream & OS , <nl> - bool V = false , bool SortedSIL = false , <nl> - llvm : : DenseMap < CanType , Identifier > * AlternativeTypeNames = nullptr , <nl> - SILFunction : : ScopeSlotTracker * ScopeTracker = nullptr ) <nl> - : PrintState { { OS } , PrintOptions : : printSIL ( ) } , Verbose ( V ) , <nl> - SortedSIL ( SortedSIL ) , LastBufferID ( 0 ) { <nl> + SILPrintContext & PrintCtx , <nl> + llvm : : DenseMap < CanType , Identifier > * AlternativeTypeNames = nullptr ) <nl> + : Ctx ( PrintCtx ) , <nl> + PrintState { { PrintCtx . OS ( ) } , PrintOptions : : printSIL ( ) } , <nl> + LastBufferID ( 0 ) { <nl> PrintState . ASTOptions . AlternativeTypeNames = AlternativeTypeNames ; <nl> - if ( ScopeTracker ) <nl> - ScopeSlots = ScopeTracker ; <nl> - else { <nl> - ManagedScopeSlotTracker = <nl> - llvm : : make_unique < SILFunction : : ScopeSlotTracker > ( ) ; <nl> - ScopeSlots = ManagedScopeSlotTracker . get ( ) ; <nl> - } <nl> } <nl> <nl> ID getID ( const SILBasicBlock * B ) ; <nl> class SILPrinter : public SILVisitor < SILPrinter > { <nl> / / Big entrypoints . <nl> void print ( const SILFunction * F ) { <nl> / / If we are asked to emit sorted SIL , print out our BBs in RPOT order . <nl> - if ( SortedSIL ) { <nl> + if ( Ctx . sortSIL ( ) ) { <nl> std : : vector < SILBasicBlock * > RPOT ; <nl> auto * UnsafeF = const_cast < SILFunction * > ( F ) ; <nl> std : : copy ( po_begin ( UnsafeF ) , po_end ( UnsafeF ) , <nl> class SILPrinter : public SILVisitor < SILPrinter > { <nl> } <nl> * this < < ' \ n ' ; <nl> <nl> - for ( const SILInstruction & I : * BB ) <nl> + for ( const SILInstruction & I : * BB ) { <nl> + Ctx . printInstructionCallBack ( & I ) ; <nl> print ( & I ) ; <nl> + } <nl> } <nl> <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> class SILPrinter : public SILVisitor < SILPrinter > { <nl> if ( ! DS ) <nl> return ; <nl> <nl> - if ( ! ScopeSlots - > ScopeToIDMap . count ( DS ) ) { <nl> + if ( ! Ctx . hasScopeID ( DS ) ) { <nl> printDebugScope ( DS - > Parent . dyn_cast < const SILDebugScope * > ( ) , SM ) ; <nl> printDebugScope ( DS - > InlinedCallSite , SM ) ; <nl> - unsigned ID = + + ( ScopeSlots - > ScopeIndex ) ; <nl> - ScopeSlots - > ScopeToIDMap . insert ( { DS , ID } ) ; <nl> + unsigned ID = Ctx . assignScopeID ( DS ) ; <nl> * this < < " sil_scope " < < ID < < " { " ; <nl> printDebugLocRef ( DS - > Loc , SM , false ) ; <nl> * this < < " parent " ; <nl> class SILPrinter : public SILVisitor < SILPrinter > { <nl> * this < < " @ " < < F - > getName ( ) < < " : $ " < < F - > getLoweredFunctionType ( ) ; <nl> else { <nl> auto * PS = DS - > Parent . get < const SILDebugScope * > ( ) ; <nl> - * this < < ScopeSlots - > ScopeToIDMap [ PS ] ; <nl> + * this < < Ctx . getScopeID ( PS ) ; <nl> } <nl> if ( auto * CS = DS - > InlinedCallSite ) <nl> - * this < < " inlined_at " < < ScopeSlots - > ScopeToIDMap [ CS ] ; <nl> + * this < < " inlined_at " < < Ctx . getScopeID ( CS ) ; <nl> * this < < " } \ n " ; <nl> } <nl> } <nl> class SILPrinter : public SILVisitor < SILPrinter > { <nl> if ( DS ) { <nl> if ( PrintComma ) <nl> * this < < " , " ; <nl> - * this < < " scope " < < ScopeSlots - > ScopeToIDMap [ DS ] ; <nl> + * this < < " scope " < < Ctx . getScopeID ( DS ) ; <nl> } <nl> } <nl> <nl> class SILPrinter : public SILVisitor < SILPrinter > { <nl> bool printedSlashes = printUsersOfSILValue ( V ) ; <nl> <nl> / / Print SIL location . <nl> - if ( Verbose ) { <nl> + if ( Ctx . printVerbose ( ) ) { <nl> if ( auto * I = dyn_cast < SILInstruction > ( V ) ) { <nl> printSILLocation ( I - > getLoc ( ) , I - > getModule ( ) , I - > getDebugScope ( ) , <nl> printedSlashes ) ; <nl> ID SILPrinter : : getID ( SILValue V ) { <nl> } <nl> <nl> void SILBasicBlock : : printAsOperand ( raw_ostream & OS , bool PrintType ) { <nl> - OS < < SILPrinter ( OS ) . getID ( this ) ; <nl> + SILPrintContext Ctx ( OS ) ; <nl> + OS < < SILPrinter ( Ctx ) . getID ( this ) ; <nl> } <nl> <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> void ValueBase : : dump ( ) const { <nl> } <nl> <nl> void ValueBase : : print ( raw_ostream & OS ) const { <nl> - SILPrinter ( OS ) . print ( this ) ; <nl> + SILPrintContext Ctx ( OS ) ; <nl> + SILPrinter ( Ctx ) . print ( this ) ; <nl> } <nl> <nl> / / / Pretty - print the SILBasicBlock to errs . <nl> void SILBasicBlock : : dump ( ) const { <nl> <nl> / / / Pretty - print the SILBasicBlock to the designated stream . <nl> void SILBasicBlock : : print ( raw_ostream & OS ) const { <nl> - SILPrinter ( OS ) . print ( this ) ; <nl> + SILPrintContext Ctx ( OS ) ; <nl> + SILPrinter ( Ctx ) . print ( this ) ; <nl> } <nl> <nl> / / / Pretty - print the SILFunction to errs . <nl> void SILFunction : : dump ( bool Verbose ) const { <nl> - print ( llvm : : errs ( ) , Verbose ) ; <nl> + SILPrintContext Ctx ( llvm : : errs ( ) , Verbose ) ; <nl> + print ( Ctx ) ; <nl> } <nl> <nl> / / This is out of line so the debugger can find it . <nl> void SILFunction : : dump ( ) const { <nl> void SILFunction : : dump ( const char * FileName ) const { <nl> std : : error_code EC ; <nl> llvm : : raw_fd_ostream os ( FileName , EC , llvm : : sys : : fs : : OpenFlags : : F_None ) ; <nl> - print ( os , false ) ; <nl> + print ( os ) ; <nl> } <nl> <nl> static StringRef getLinkageString ( SILLinkage linkage ) { <nl> static void printLinkage ( llvm : : raw_ostream & OS , SILLinkage linkage , <nl> } <nl> <nl> / / / Pretty - print the SILFunction to the designated stream . <nl> - void SILFunction : : print ( llvm : : raw_ostream & OS , <nl> - SILFunction : : ScopeSlotTracker & MDT , bool Verbose , <nl> - bool SortedSIL ) const { <nl> + void SILFunction : : print ( SILPrintContext & PrintCtx ) const { <nl> auto & SM = getModule ( ) . getASTContext ( ) . SourceMgr ; <nl> + llvm : : raw_ostream & OS = PrintCtx . OS ( ) ; <nl> for ( auto & BB : * this ) <nl> for ( auto & I : BB ) { <nl> - SILPrinter P ( OS , Verbose , SortedSIL , nullptr , & MDT ) ; <nl> + SILPrinter P ( PrintCtx ) ; <nl> P . printDebugScope ( I . getDebugScope ( ) , SM ) ; <nl> } <nl> OS < < " \ n " ; <nl> - <nl> + <nl> OS < < " / / " < < demangleSymbol ( getName ( ) ) < < ' \ n ' ; <nl> OS < < " sil " ; <nl> printLinkage ( OS , getLinkage ( ) , isDefinition ( ) ) ; <nl> void SILFunction : : print ( llvm : : raw_ostream & OS , <nl> if ( ! isExternalDeclaration ( ) ) { <nl> OS < < " { \ n " ; <nl> <nl> - SILPrinter ( OS , Verbose , SortedSIL , ( Aliases . empty ( ) ? nullptr : & Aliases ) , <nl> - & MDT ) <nl> + SILPrinter ( PrintCtx , ( Aliases . empty ( ) ? nullptr : & Aliases ) ) <nl> . print ( this ) ; <nl> OS < < " } " ; <nl> } <nl> void SILGlobalVariable : : printName ( raw_ostream & OS ) const { <nl> <nl> / / / Pretty - print the SILModule to errs . <nl> void SILModule : : dump ( bool Verbose ) const { <nl> - print ( llvm : : errs ( ) , Verbose ) ; <nl> + SILPrintContext Ctx ( llvm : : errs ( ) , Verbose ) ; <nl> + print ( Ctx ) ; <nl> } <nl> <nl> void SILModule : : dump ( const char * FileName , bool Verbose , <nl> bool PrintASTDecls ) const { <nl> std : : error_code EC ; <nl> llvm : : raw_fd_ostream os ( FileName , EC , llvm : : sys : : fs : : OpenFlags : : F_None ) ; <nl> - print ( os , Verbose , getSwiftModule ( ) , false , PrintASTDecls ) ; <nl> + SILPrintContext Ctx ( os , Verbose ) ; <nl> + print ( Ctx , getSwiftModule ( ) , PrintASTDecls ) ; <nl> } <nl> <nl> - static void printSILGlobals ( llvm : : raw_ostream & OS , bool Verbose , <nl> - bool ShouldSort , <nl> + static void printSILGlobals ( SILPrintContext & Ctx , <nl> const SILModule : : GlobalListType & Globals ) { <nl> - if ( ! ShouldSort ) { <nl> + if ( ! Ctx . sortSIL ( ) ) { <nl> for ( const SILGlobalVariable & g : Globals ) <nl> - g . print ( OS , Verbose ) ; <nl> + g . print ( Ctx . OS ( ) , Ctx . printVerbose ( ) ) ; <nl> return ; <nl> } <nl> <nl> static void printSILGlobals ( llvm : : raw_ostream & OS , bool Verbose , <nl> } <nl> ) ; <nl> for ( const SILGlobalVariable * g : globals ) <nl> - g - > print ( OS , Verbose ) ; <nl> + g - > print ( Ctx . OS ( ) , Ctx . printVerbose ( ) ) ; <nl> } <nl> <nl> - static void printSILFunctions ( llvm : : raw_ostream & OS , <nl> - bool Verbose , bool ShouldSort , <nl> + static void printSILFunctions ( SILPrintContext & Ctx , <nl> const SILModule : : FunctionListType & Functions ) { <nl> - SILFunction : : ScopeSlotTracker Tracker ; <nl> - if ( ! ShouldSort ) { <nl> + if ( ! Ctx . sortSIL ( ) ) { <nl> for ( const SILFunction & f : Functions ) <nl> - f . print ( OS , Tracker , Verbose , false ) ; <nl> + f . print ( Ctx ) ; <nl> return ; <nl> } <nl> <nl> static void printSILFunctions ( llvm : : raw_ostream & OS , <nl> } <nl> ) ; <nl> for ( const SILFunction * f : functions ) <nl> - f - > print ( OS , Tracker , Verbose , true ) ; <nl> + f - > print ( Ctx ) ; <nl> } <nl> <nl> - static void printSILVTables ( llvm : : raw_ostream & OS , bool Verbose , <nl> - bool ShouldSort , <nl> + static void printSILVTables ( SILPrintContext & Ctx , <nl> const SILModule : : VTableListType & VTables ) { <nl> - if ( ! ShouldSort ) { <nl> + if ( ! Ctx . sortSIL ( ) ) { <nl> for ( const SILVTable & vt : VTables ) <nl> - vt . print ( OS , Verbose ) ; <nl> + vt . print ( Ctx . OS ( ) , Ctx . printVerbose ( ) ) ; <nl> return ; <nl> } <nl> <nl> static void printSILVTables ( llvm : : raw_ostream & OS , bool Verbose , <nl> } <nl> ) ; <nl> for ( const SILVTable * vt : vtables ) <nl> - vt - > print ( OS , Verbose ) ; <nl> + vt - > print ( Ctx . OS ( ) , Ctx . printVerbose ( ) ) ; <nl> } <nl> <nl> static void <nl> - printSILWitnessTables ( llvm : : raw_ostream & OS , bool Verbose , <nl> - bool ShouldSort , <nl> + printSILWitnessTables ( SILPrintContext & Ctx , <nl> const SILModule : : WitnessTableListType & WTables ) { <nl> - if ( ! ShouldSort ) { <nl> + if ( ! Ctx . sortSIL ( ) ) { <nl> for ( const SILWitnessTable & wt : WTables ) <nl> - wt . print ( OS , Verbose ) ; <nl> + wt . print ( Ctx . OS ( ) , Ctx . printVerbose ( ) ) ; <nl> return ; <nl> } <nl> <nl> printSILWitnessTables ( llvm : : raw_ostream & OS , bool Verbose , <nl> } <nl> ) ; <nl> for ( const SILWitnessTable * wt : witnesstables ) <nl> - wt - > print ( OS , Verbose ) ; <nl> + wt - > print ( Ctx . OS ( ) , Ctx . printVerbose ( ) ) ; <nl> } <nl> <nl> static void <nl> - printSILDefaultWitnessTables ( llvm : : raw_ostream & OS , bool Verbose , <nl> - bool ShouldSort , <nl> + printSILDefaultWitnessTables ( SILPrintContext & Ctx , <nl> const SILModule : : DefaultWitnessTableListType & WTables ) { <nl> - if ( ! ShouldSort ) { <nl> + if ( ! Ctx . sortSIL ( ) ) { <nl> for ( const SILDefaultWitnessTable & wt : WTables ) <nl> - wt . print ( OS , Verbose ) ; <nl> + wt . print ( Ctx . OS ( ) , Ctx . printVerbose ( ) ) ; <nl> return ; <nl> } <nl> <nl> printSILDefaultWitnessTables ( llvm : : raw_ostream & OS , bool Verbose , <nl> } <nl> ) ; <nl> for ( const SILDefaultWitnessTable * wt : witnesstables ) <nl> - wt - > print ( OS , Verbose ) ; <nl> + wt - > print ( Ctx . OS ( ) , Ctx . printVerbose ( ) ) ; <nl> } <nl> <nl> static void <nl> - printSILCoverageMaps ( llvm : : raw_ostream & OS , bool Verbose , bool ShouldSort , <nl> + printSILCoverageMaps ( SILPrintContext & Ctx , <nl> const SILModule : : CoverageMapListType & CoverageMaps ) { <nl> - if ( ! ShouldSort ) { <nl> + if ( ! Ctx . sortSIL ( ) ) { <nl> for ( const SILCoverageMap & M : CoverageMaps ) <nl> - M . print ( OS , ShouldSort , Verbose ) ; <nl> + M . print ( Ctx ) ; <nl> return ; <nl> } <nl> <nl> printSILCoverageMaps ( llvm : : raw_ostream & OS , bool Verbose , bool ShouldSort , <nl> return LHS - > getName ( ) . compare ( RHS - > getName ( ) ) = = - 1 ; <nl> } ) ; <nl> for ( const SILCoverageMap * M : Maps ) <nl> - M - > print ( OS , ShouldSort , Verbose ) ; <nl> + M - > print ( Ctx ) ; <nl> } <nl> <nl> / / / Pretty - print the SILModule to the designated stream . <nl> - void SILModule : : print ( llvm : : raw_ostream & OS , bool Verbose , <nl> - Module * M , bool ShouldSort , bool PrintASTDecls ) const { <nl> + void SILModule : : print ( SILPrintContext & PrintCtx , Module * M , <nl> + bool PrintASTDecls ) const { <nl> + llvm : : raw_ostream & OS = PrintCtx . OS ( ) ; <nl> OS < < " sil_stage " ; <nl> switch ( Stage ) { <nl> case SILStage : : Raw : <nl> void SILModule : : print ( llvm : : raw_ostream & OS , bool Verbose , <nl> } <nl> } <nl> <nl> - printSILGlobals ( OS , Verbose , ShouldSort , getSILGlobalList ( ) ) ; <nl> - printSILFunctions ( OS , Verbose , ShouldSort , getFunctionList ( ) ) ; <nl> - printSILVTables ( OS , Verbose , ShouldSort , getVTableList ( ) ) ; <nl> - printSILWitnessTables ( OS , Verbose , ShouldSort , getWitnessTableList ( ) ) ; <nl> - printSILDefaultWitnessTables ( OS , Verbose , ShouldSort , getDefaultWitnessTableList ( ) ) ; <nl> - printSILCoverageMaps ( OS , Verbose , ShouldSort , getCoverageMapList ( ) ) ; <nl> + printSILGlobals ( PrintCtx , getSILGlobalList ( ) ) ; <nl> + printSILFunctions ( PrintCtx , getFunctionList ( ) ) ; <nl> + printSILVTables ( PrintCtx , getVTableList ( ) ) ; <nl> + printSILWitnessTables ( PrintCtx , getWitnessTableList ( ) ) ; <nl> + printSILDefaultWitnessTables ( PrintCtx , getDefaultWitnessTableList ( ) ) ; <nl> + printSILCoverageMaps ( PrintCtx , getCoverageMapList ( ) ) ; <nl> <nl> OS < < " \ n \ n " ; <nl> } <nl> void ValueBase : : dumpInContext ( ) const { <nl> printInContext ( llvm : : errs ( ) ) ; <nl> } <nl> void ValueBase : : printInContext ( llvm : : raw_ostream & OS ) const { <nl> - SILPrinter ( OS ) . printInContext ( this ) ; <nl> + SILPrintContext Ctx ( OS ) ; <nl> + SILPrinter ( Ctx ) . printInContext ( this ) ; <nl> } <nl> <nl> void SILVTable : : print ( llvm : : raw_ostream & OS , bool Verbose ) const { <nl> void SILDefaultWitnessTable : : dump ( ) const { <nl> print ( llvm : : errs ( ) ) ; <nl> } <nl> <nl> - void SILCoverageMap : : print ( llvm : : raw_ostream & OS , bool ShouldSort , <nl> - bool Verbose ) const { <nl> + void SILCoverageMap : : print ( SILPrintContext & PrintCtx ) const { <nl> + llvm : : raw_ostream & OS = PrintCtx . OS ( ) ; <nl> OS < < " sil_coverage_map " < < QuotedString ( getFile ( ) ) < < " " < < getName ( ) <nl> < < " " < < getHash ( ) < < " { \ t / / " < < demangleSymbol ( getName ( ) ) <nl> < < " \ n " ; <nl> - if ( ShouldSort ) <nl> + if ( PrintCtx . sortSIL ( ) ) <nl> std : : sort ( MappedRegions , MappedRegions + NumMappedRegions , <nl> [ ] ( const MappedRegion & LHS , const MappedRegion & RHS ) { <nl> return std : : tie ( LHS . StartLine , LHS . StartCol , LHS . EndLine , LHS . EndCol ) < <nl> void SILDebugScope : : dump ( SourceManager & SM , llvm : : raw_ostream & OS , <nl> } <nl> <nl> void SILSpecializeAttr : : print ( llvm : : raw_ostream & OS ) const { <nl> - SILPrinter ( OS ) . printSubstitutions ( getSubstitutions ( ) ) ; <nl> + SILPrintContext Ctx ( OS ) ; <nl> + SILPrinter ( Ctx ) . printSubstitutions ( getSubstitutions ( ) ) ; <nl> + } <nl> + <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + / / SILPrintContext members <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + <nl> + SILPrintContext : : ~ SILPrintContext ( ) { <nl> + } <nl> + <nl> + void SILPrintContext : : printInstructionCallBack ( const SILInstruction * I ) { <nl> } <nl> mmm a / lib / SILOptimizer / PassManager / Passes . cpp <nl> ppp b / lib / SILOptimizer / PassManager / Passes . cpp <nl> void swift : : runSILOptimizationPasses ( SILModule & Module ) { <nl> PM . addSimplifyCFG ( ) ; <nl> PM . runOneIteration ( ) ; <nl> <nl> + PM . resetAndRemoveTransformations ( ) ; <nl> + <nl> + / / Has only an effect if the - gsil option is specified . <nl> + PM . addSILDebugInfoGenerator ( ) ; <nl> + <nl> / / Call the CFG viewer . <nl> if ( SILViewCFG ) { <nl> - PM . resetAndRemoveTransformations ( ) ; <nl> PM . addCFGPrinter ( ) ; <nl> - PM . runOneIteration ( ) ; <nl> } <nl> + PM . runOneIteration ( ) ; <nl> <nl> / / Verify the module , if required . <nl> if ( Module . getOptions ( ) . VerifyAll ) <nl> void swift : : runSILPassesForOnone ( SILModule & Module ) { <nl> / / eventually remove unused declarations . <nl> PM . addExternalDefsToDecls ( ) ; <nl> <nl> + / / Has only an effect if the - gsil option is specified . <nl> + PM . addSILDebugInfoGenerator ( ) ; <nl> + <nl> PM . runOneIteration ( ) ; <nl> <nl> / / Verify the module , if required . <nl> mmm a / lib / SILOptimizer / UtilityPasses / CMakeLists . txt <nl> ppp b / lib / SILOptimizer / UtilityPasses / CMakeLists . txt <nl> set ( UTILITYPASSES_SOURCES <nl> UtilityPasses / MemBehaviorDumper . cpp <nl> UtilityPasses / RCIdentityDumper . cpp <nl> UtilityPasses / SideEffectsDumper . cpp <nl> + UtilityPasses / SILDebugInfoGenerator . cpp <nl> UtilityPasses / StripDebugInfo . cpp <nl> PARENT_SCOPE ) <nl> new file mode 100644 <nl> index 000000000000 . . d05a650b99c0 <nl> mmm / dev / null <nl> ppp b / lib / SILOptimizer / UtilityPasses / SILDebugInfoGenerator . cpp <nl> <nl> + / / = = = mmm SILDebugInfoGenerator . cc - Writes a SIL file for debugging mmmmmm - = = = / / <nl> + / / <nl> + / / This source file is part of the Swift . org open source project <nl> + / / <nl> + / / Copyright ( c ) 2014 - 2016 Apple Inc . and the Swift project authors <nl> + / / Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + / / <nl> + / / See http : / / swift . org / LICENSE . txt for license information <nl> + / / See http : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + <nl> + # define DEBUG_TYPE " gsil - gen " <nl> + # include " swift / AST / SILOptions . h " <nl> + # include " swift / SIL / SILPrintContext . h " <nl> + # include " swift / SIL / SILModule . h " <nl> + # include " swift / SILOptimizer / PassManager / Transforms . h " <nl> + # include " llvm / Support / FileSystem . h " <nl> + # include " llvm / Support / MemoryBuffer . h " <nl> + <nl> + using namespace swift ; <nl> + <nl> + namespace { <nl> + <nl> + / / / A pass for generating debug info on SIL level . <nl> + / / / <nl> + / / / This pass is only enabled if SILOptions : : SILOutputFileNameForDebugging is <nl> + / / / set ( i . e . if the - gsil command line option is specified ) . <nl> + / / / The pass writes all SIL functions into one or multiple output files , <nl> + / / / depending on the size of the SIL . The names of the output files are derived <nl> + / / / from the main output file . <nl> + / / / <nl> + / / / output file name = < main - output - filename > . gsil_ < n > . sil <nl> + / / / <nl> + / / / Where < n > is a consecutive number . The files are stored in the same <nl> + / / / same directory as the main output file . <nl> + / / / The debug locations and scopes of all functions and instructions are changed <nl> + / / / to point to the generated SIL output files . <nl> + / / / This enables debugging and profiling on SIL level . <nl> + class SILDebugInfoGenerator : public SILModuleTransform { <nl> + <nl> + enum { <nl> + / / / To prevent extra large output files , e . g . when compiling the stdlib . <nl> + LineLimitPerFile = 10000 <nl> + } ; <nl> + <nl> + / / / A stream for counting line numbers . <nl> + struct LineCountStream : public llvm : : raw_ostream { <nl> + llvm : : raw_ostream & Underlying ; <nl> + int LineNum = 1 ; <nl> + uint64_t Pos = 0 ; <nl> + <nl> + void write_impl ( const char * Ptr , size_t Size ) override { <nl> + for ( size_t Idx = 0 ; Idx < Size ; Idx + + ) { <nl> + char c = Ptr [ Idx ] ; <nl> + if ( c = = ' \ n ' ) <nl> + + + LineNum ; <nl> + } <nl> + Underlying . write ( Ptr , Size ) ; <nl> + Pos + = Size ; <nl> + } <nl> + <nl> + uint64_t current_pos ( ) const override { return Pos ; } <nl> + <nl> + LineCountStream ( llvm : : raw_ostream & Underlying ) : <nl> + llvm : : raw_ostream ( / * unbuffered = * / true ) , <nl> + Underlying ( Underlying ) { } <nl> + <nl> + ~ LineCountStream ( ) { <nl> + flush ( ) ; <nl> + } <nl> + } ; <nl> + <nl> + / / / A print context which records the line numbers where instructions are <nl> + / / / printed . <nl> + struct PrintContext : public SILPrintContext { <nl> + <nl> + LineCountStream LCS ; <nl> + <nl> + llvm : : DenseMap < const SILInstruction * , int > LineNums ; <nl> + <nl> + void printInstructionCallBack ( const SILInstruction * I ) override { <nl> + / / Record the current line number of the instruction . <nl> + LineNums [ I ] = LCS . LineNum ; <nl> + } <nl> + <nl> + PrintContext ( llvm : : raw_ostream & OS ) : SILPrintContext ( LCS ) , LCS ( OS ) { } <nl> + <nl> + virtual ~ PrintContext ( ) { } <nl> + } ; <nl> + <nl> + void run ( ) override { <nl> + SILModule * M = getModule ( ) ; <nl> + StringRef FileBaseName = M - > getOptions ( ) . SILOutputFileNameForDebugging ; <nl> + if ( FileBaseName . empty ( ) ) <nl> + return ; <nl> + <nl> + DEBUG ( llvm : : dbgs ( ) < < " * * SILDebugInfoGenerator * * \ n " ) ; <nl> + <nl> + std : : vector < SILFunction * > PrintedFuncs ; <nl> + int FileIdx = 0 ; <nl> + auto FIter = M - > begin ( ) ; <nl> + while ( FIter ! = M - > end ( ) ) { <nl> + <nl> + std : : string FileName ; <nl> + llvm : : raw_string_ostream NameOS ( FileName ) ; <nl> + NameOS < < FileBaseName < < " . gsil_ " < < FileIdx + + < < " . sil " ; <nl> + NameOS . flush ( ) ; <nl> + <nl> + char * FileNameBuf = ( char * ) M - > allocate ( FileName . size ( ) + 1 , 1 ) ; <nl> + strcpy ( FileNameBuf , FileName . c_str ( ) ) ; <nl> + <nl> + DEBUG ( llvm : : dbgs ( ) < < " Write debug SIL file " < < FileName < < ' \ n ' ) ; <nl> + <nl> + std : : error_code EC ; <nl> + llvm : : raw_fd_ostream OutFile ( FileName , EC , <nl> + llvm : : sys : : fs : : OpenFlags : : F_None ) ; <nl> + assert ( ! OutFile . has_error ( ) & & ! EC & & " Can ' t write SIL debug file " ) ; <nl> + <nl> + PrintContext Ctx ( OutFile ) ; <nl> + <nl> + / / Write functions until we reach the LineLimitPerFile . <nl> + do { <nl> + SILFunction * F = & * FIter + + ; <nl> + PrintedFuncs . push_back ( F ) ; <nl> + <nl> + / / Set the debug scope for the function . <nl> + SILLocation : : DebugLoc DL ( Ctx . LCS . LineNum , 1 , FileNameBuf ) ; <nl> + RegularLocation Loc ( DL ) ; <nl> + SILDebugScope * Scope = new ( * M ) SILDebugScope ( Loc , F ) ; <nl> + F - > setDebugScope ( Scope ) ; <nl> + <nl> + / / Ensure that the function is visible for debugging . <nl> + F - > setBare ( IsNotBare ) ; <nl> + <nl> + / / Print it to the output file . <nl> + F - > print ( Ctx ) ; <nl> + } while ( FIter ! = M - > end ( ) & & Ctx . LCS . LineNum < LineLimitPerFile ) ; <nl> + <nl> + / / Set the debug locations of all instructions . <nl> + for ( SILFunction * F : PrintedFuncs ) { <nl> + const SILDebugScope * Scope = F - > getDebugScope ( ) ; <nl> + for ( SILBasicBlock & BB : * F ) { <nl> + for ( SILInstruction & I : BB ) { <nl> + SILLocation Loc = I . getLoc ( ) ; <nl> + SILLocation : : DebugLoc DL ( Ctx . LineNums [ & I ] , 1 , FileNameBuf ) ; <nl> + assert ( DL . Line & & " no line set for instruction " ) ; <nl> + if ( Loc . is < ReturnLocation > ( ) | | Loc . is < ImplicitReturnLocation > ( ) ) { <nl> + Loc . setDebugInfoLoc ( DL ) ; <nl> + I . setDebugLocation ( SILDebugLocation ( Loc , Scope ) ) ; <nl> + } else { <nl> + RegularLocation RLoc ( DL ) ; <nl> + I . setDebugLocation ( SILDebugLocation ( RLoc , Scope ) ) ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + PrintedFuncs . clear ( ) ; <nl> + } <nl> + } <nl> + <nl> + StringRef getName ( ) override { return " SILDebugInfoGenerator " ; } <nl> + } ; <nl> + <nl> + } / / end anonymous namespace <nl> + <nl> + SILTransform * swift : : createSILDebugInfoGenerator ( ) { <nl> + return new SILDebugInfoGenerator ( ) ; <nl> + } <nl> new file mode 100644 <nl> index 000000000000 . . 9866e0f54ce5 <nl> mmm / dev / null <nl> ppp b / test / DebugInfo / gsil . swift <nl> <nl> + / / RUN : rm - rf % t & & mkdir % t <nl> + / / RUN : % target - swift - frontend % s - O - gsil - emit - ir - o % t / out . ir <nl> + / / RUN : FileCheck % s < % t / out . ir <nl> + / / RUN : FileCheck % s - - check - prefix = CHECK_OUT_SIL < % t / out . ir . gsil_0 . sil <nl> + <nl> + / / CHECK : [ [ F : ! [ 0 - 9 ] + ] ] = ! DIFile ( filename : " out . ir . gsil_0 . sil " , directory : " { { . + } } " ) <nl> + / / CHECK : ! DISubprogram ( linkageName : " _TF3out6testitFT_T_ " , scope : ! { { [ 0 - 9 ] + } } , file : [ [ F ] ] , line : { { [ 1 - 9 ] [ 0 - 9 ] + } } , <nl> + <nl> + / / CHECK_OUT_SIL : sil @ _TF3out6testitFT_T_ : $ @ convention ( thin ) ( ) - > ( ) { <nl> + public func testit ( ) { <nl> + print ( " Hello " ) <nl> + } <nl> + <nl>
Merge pull request from eeckstein / gsil_debugging2
apple/swift
5318c525b9af1ddf048822c2d9c467593b7d2043
2016-03-18T22:03:35Z
mmm a / modules / mono / csharp_script . cpp <nl> ppp b / modules / mono / csharp_script . cpp <nl> bool CSharpInstance : : set ( const StringName & p_name , const Variant & p_value ) { <nl> GDMonoClass * top = script - > script_class ; <nl> <nl> while ( top & & top ! = script - > native ) { <nl> - GDMonoField * field = script - > script_class - > get_field ( p_name ) ; <nl> + GDMonoField * field = top - > get_field ( p_name ) ; <nl> <nl> if ( field ) { <nl> field - > set_value_from_variant ( mono_object , p_value ) ; <nl> return true ; <nl> } <nl> <nl> - GDMonoProperty * property = script - > script_class - > get_property ( p_name ) ; <nl> + GDMonoProperty * property = top - > get_property ( p_name ) ; <nl> <nl> if ( property ) { <nl> property - > set_value ( mono_object , GDMonoMarshal : : variant_to_mono_object ( p_value , property - > get_type ( ) ) ) ; <nl>
Merge pull request from neikeq / issue - 26616
godotengine/godot
488884178e773a6e80070663d92cc53cb820bff9
2019-03-08T00:16:27Z
mmm a / xbmc / filesystem / AndroidAppFile . cpp <nl> ppp b / xbmc / filesystem / AndroidAppFile . cpp <nl> <nl> <nl> # include < android / bitmap . h > <nl> # include < androidjni / Bitmap . h > <nl> + # include < androidjni / Drawable . h > <nl> # include < androidjni / BitmapDrawable . h > <nl> # include < androidjni / Build . h > <nl> # include < androidjni / Context . h > <nl> unsigned int CFileAndroidApp : : ReadIcon ( unsigned char * * lpBuf , unsigned int * widt <nl> int densities [ ] = { CJNIDisplayMetrics : : DENSITY_XXXHIGH , CJNIDisplayMetrics : : DENSITY_XXHIGH , CJNIDisplayMetrics : : DENSITY_XHIGH , - 1 } ; <nl> <nl> CJNIBitmap bmp ; <nl> + jclass cBmpDrw = env - > FindClass ( " android / graphics / drawable / BitmapDrawable " ) ; <nl> + <nl> if ( CJNIBuild : : SDK_INT > = 15 & & m_icon ) <nl> { <nl> CJNIResources res = CJNIContext : : GetPackageManager ( ) . getResourcesForApplication ( m_packageName ) ; <nl> unsigned int CFileAndroidApp : : ReadIcon ( unsigned char * * lpBuf , unsigned int * widt <nl> for ( int i = 0 ; densities [ i ] ! = - 1 & & ! bmp ; + + i ) <nl> { <nl> int density = densities [ i ] ; <nl> - CJNIBitmapDrawable resbmp = res . getDrawableForDensity ( m_icon , density ) ; <nl> + CJNIDrawable drw = res . getDrawableForDensity ( m_icon , density ) ; <nl> if ( xbmc_jnienv ( ) - > ExceptionCheck ( ) ) <nl> xbmc_jnienv ( ) - > ExceptionClear ( ) ; <nl> + else if ( ! drw ) ; <nl> else <nl> - if ( resbmp . getBitmap ( ) ) <nl> - bmp = resbmp . getBitmap ( ) ; <nl> + { <nl> + if ( env - > IsInstanceOf ( drw . get_raw ( ) , cBmpDrw ) ) <nl> + { <nl> + CJNIBitmapDrawable resbmp = drw ; <nl> + if ( resbmp ) <nl> + bmp = resbmp . getBitmap ( ) ; <nl> + } <nl> + } <nl> } <nl> } <nl> } <nl> <nl> if ( ! bmp ) <nl> - bmp = ( ( CJNIBitmapDrawable ) ( CJNIContext : : GetPackageManager ( ) . getApplicationIcon ( m_packageName ) ) ) . getBitmap ( ) ; <nl> + { <nl> + CJNIDrawable drw = CJNIContext : : GetPackageManager ( ) . getApplicationIcon ( m_packageName ) ; <nl> + if ( xbmc_jnienv ( ) - > ExceptionCheck ( ) ) <nl> + xbmc_jnienv ( ) - > ExceptionClear ( ) ; <nl> + else if ( ! drw ) ; <nl> + else <nl> + { <nl> + if ( env - > IsInstanceOf ( drw . get_raw ( ) , cBmpDrw ) ) <nl> + { <nl> + CJNIBitmapDrawable resbmp = drw ; <nl> + if ( resbmp ) <nl> + bmp = resbmp . getBitmap ( ) ; <nl> + } <nl> + } <nl> + } <nl> if ( ! bmp ) <nl> return 0 ; <nl> <nl>
FIX : [ droid ] trap App icons not being bitmaps
xbmc/xbmc
6e2f9dd8d513c8bc6fed8b2ce57dadea68e18b62
2017-05-28T08:38:07Z
mmm a / cocos / 3d / CCBundle3D . cpp <nl> ppp b / cocos / 3d / CCBundle3D . cpp <nl> <nl> <nl> # include " base / ccMacros . h " <nl> # include " platform / CCFileUtils . h " <nl> - <nl> + # include " renderer / CCGLProgram . h " <nl> <nl> <nl> NS_CC_BEGIN <nl>
missing include
cocos2d/cocos2d-x
e1fb8c82f0b03bbfea62aadd366216ef96bed574
2014-06-17T07:31:45Z
mmm a / lib / ClangImporter / ImportDecl . cpp <nl> ppp b / lib / ClangImporter / ImportDecl . cpp <nl> namespace { <nl> / / " raw " name will be imported as unavailable with a more helpful and <nl> / / specific message . <nl> + + NumFactoryMethodsAsInitializers ; <nl> - bool redundant = false ; <nl> + ConstructorDecl * existing = nullptr ; <nl> auto result = <nl> importConstructor ( decl , dc , false , importedName . getInitKind ( ) , <nl> / * required = * / false , selector , importedName , <nl> { decl - > param_begin ( ) , decl - > param_size ( ) } , <nl> - decl - > isVariadic ( ) , redundant ) ; <nl> + decl - > isVariadic ( ) , existing ) ; <nl> <nl> if ( ! isActiveSwiftVersion ( ) & & result ) <nl> markAsVariant ( result , * correctSwiftName ) ; <nl> namespace { <nl> ImportedName importedName , <nl> ArrayRef < const clang : : ParmVarDecl * > args , <nl> bool variadic , <nl> - bool & redundant ) ; <nl> + ConstructorDecl * & existing ) ; <nl> <nl> void recordObjCOverride ( SubscriptDecl * subscript ) ; <nl> <nl> ConstructorDecl * SwiftDeclConverter : : importConstructor ( <nl> variadic = false ; <nl> } <nl> <nl> - bool redundant ; <nl> + ConstructorDecl * existing ; <nl> auto result = importConstructor ( objcMethod , dc , implicit , <nl> kind . getValueOr ( importedName . getInitKind ( ) ) , <nl> required , selector , importedName , params , <nl> - variadic , redundant ) ; <nl> + variadic , existing ) ; <nl> <nl> / / If this is a compatibility stub , mark it as such . <nl> if ( result & & correctSwiftName ) <nl> ConstructorDecl * SwiftDeclConverter : : importConstructor ( <nl> const clang : : ObjCMethodDecl * objcMethod , const DeclContext * dc , bool implicit , <nl> CtorInitializerKind kind , bool required , ObjCSelector selector , <nl> ImportedName importedName , ArrayRef < const clang : : ParmVarDecl * > args , <nl> - bool variadic , bool & redundant ) { <nl> - redundant = false ; <nl> + bool variadic , ConstructorDecl * & existing ) { <nl> + existing = nullptr ; <nl> <nl> / / Figure out the type of the container . <nl> auto ownerNominal = dc - > getSelfNominalTypeDecl ( ) ; <nl> ConstructorDecl * SwiftDeclConverter : : importConstructor ( <nl> <nl> / / Otherwise , we shouldn ' t create a new constructor , because <nl> / / it will be no better than the existing one . <nl> - redundant = true ; <nl> + existing = ctor ; <nl> return nullptr ; <nl> } <nl> <nl> void SwiftDeclConverter : : importInheritedConstructors ( <nl> ! correctSwiftName & & <nl> " Import inherited initializers never references correctSwiftName " ) ; <nl> importedName . setHasCustomName ( ) ; <nl> - bool redundant ; <nl> + ConstructorDecl * existing ; <nl> if ( auto newCtor = <nl> importConstructor ( objcMethod , classDecl , <nl> / * implicit = * / true , ctor - > getInitKind ( ) , <nl> / * required = * / false , ctor - > getObjCSelector ( ) , <nl> importedName , objcMethod - > parameters ( ) , <nl> - objcMethod - > isVariadic ( ) , redundant ) ) { <nl> + objcMethod - > isVariadic ( ) , existing ) ) { <nl> / / If this is a compatibility stub , mark it as such . <nl> if ( correctSwiftName ) <nl> markAsVariant ( newCtor , * correctSwiftName ) ; <nl> <nl> Impl . importAttributes ( objcMethod , newCtor , curObjCClass ) ; <nl> newMembers . push_back ( newCtor ) ; <nl> + } else if ( existing & & existing - > getClangDecl ( ) ) { <nl> + / / Check that the existing constructor the prevented new creation is <nl> + / / really an inherited factory initializer and not a class member . <nl> + auto existingMD = cast < clang : : ObjCMethodDecl > ( existing - > getClangDecl ( ) ) ; <nl> + if ( existingMD - > getClassInterface ( ) ! = curObjCClass ) { <nl> + newMembers . push_back ( existing ) ; <nl> + } <nl> } <nl> continue ; <nl> } <nl> mmm a / test / api - digester / Inputs / Foo - new - version / foo . h <nl> ppp b / test / api - digester / Inputs / Foo - new - version / foo . h <nl> <nl> @ interface ClangInterface : NSObject < ObjcProt > <nl> - ( void ) someFunction ; <nl> @ end <nl> + <nl> + @ interface PhotoSettings : NSObject <nl> + + ( instancetype ) photoSettingsWithFormat : ( int ) format ; <nl> + + ( instancetype ) photoSettingsWithNumber : ( int ) number ; <nl> + @ end <nl> + <nl> + @ interface PhotoBracketSettings : PhotoSettings <nl> + + ( instancetype ) photoBracketSettingsWithRawPixelFormatType : ( int ) rawPixelFormatType processedFormat : ( int ) processedFormat ; <nl> + + ( instancetype ) photoBracketSettingsWithNumber : ( int ) number ; <nl> + @ end <nl> mmm a / test / api - digester / Inputs / Foo / foo . h <nl> ppp b / test / api - digester / Inputs / Foo / foo . h <nl> <nl> @ interface ClangInterface : NSObject < ObjcProt > <nl> - ( void ) someFunction ; <nl> @ end <nl> + <nl> + @ interface PhotoSettings : NSObject <nl> + + ( instancetype ) photoSettingsWithFormat : ( int ) format ; <nl> + + ( instancetype ) photoSettingsWithNumber : ( int ) number ; <nl> + @ end <nl> + <nl> + @ interface PhotoBracketSettings : PhotoSettings <nl> + + ( instancetype ) photoBracketSettingsWithRawPixelFormatType : ( int ) rawPixelFormatType processedFormat : ( int ) processedFormat ; <nl> + + ( instancetype ) photoBracketSettingsWithNumber : ( int ) number ; <nl> + @ end <nl> mmm a / test / api - digester / Outputs / clang - module - dump . txt <nl> ppp b / test / api - digester / Outputs / clang - module - dump . txt <nl> <nl> " ObjC " , <nl> " Dynamic " <nl> ] <nl> + } , <nl> + { <nl> + " kind " : " TypeDecl " , <nl> + " name " : " PhotoBracketSettings " , <nl> + " printedName " : " PhotoBracketSettings " , <nl> + " children " : [ <nl> + { <nl> + " kind " : " Constructor " , <nl> + " name " : " init " , <nl> + " printedName " : " init ( rawPixelFormatType : processedFormat : ) " , <nl> + " children " : [ <nl> + { <nl> + " kind " : " TypeNominal " , <nl> + " name " : " Optional " , <nl> + " printedName " : " Foo . PhotoBracketSettings ? " , <nl> + " children " : [ <nl> + { <nl> + " kind " : " TypeNominal " , <nl> + " name " : " PhotoBracketSettings " , <nl> + " printedName " : " Foo . PhotoBracketSettings " , <nl> + " usr " : " c : objc ( cs ) PhotoBracketSettings " <nl> + } <nl> + ] , <nl> + " usr " : " s : Sq " <nl> + } , <nl> + { <nl> + " kind " : " TypeNominal " , <nl> + " name " : " Int32 " , <nl> + " printedName " : " Swift . Int32 " , <nl> + " usr " : " s : s5Int32V " <nl> + } , <nl> + { <nl> + " kind " : " TypeNominal " , <nl> + " name " : " Int32 " , <nl> + " printedName " : " Swift . Int32 " , <nl> + " usr " : " s : s5Int32V " <nl> + } <nl> + ] , <nl> + " declKind " : " Constructor " , <nl> + " usr " : " c : objc ( cs ) PhotoBracketSettings ( cm ) photoBracketSettingsWithRawPixelFormatType : processedFormat : " , <nl> + " moduleName " : " Foo " , <nl> + " objc_name " : " photoBracketSettingsWithRawPixelFormatType : processedFormat : " , <nl> + " declAttributes " : [ <nl> + " ObjC " , <nl> + " Dynamic " <nl> + ] , <nl> + " init_kind " : " ConvenienceFactory " <nl> + } , <nl> + { <nl> + " kind " : " Constructor " , <nl> + " name " : " init " , <nl> + " printedName " : " init ( number : ) " , <nl> + " children " : [ <nl> + { <nl> + " kind " : " TypeNominal " , <nl> + " name " : " Optional " , <nl> + " printedName " : " Foo . PhotoBracketSettings ? " , <nl> + " children " : [ <nl> + { <nl> + " kind " : " TypeNominal " , <nl> + " name " : " PhotoBracketSettings " , <nl> + " printedName " : " Foo . PhotoBracketSettings " , <nl> + " usr " : " c : objc ( cs ) PhotoBracketSettings " <nl> + } <nl> + ] , <nl> + " usr " : " s : Sq " <nl> + } , <nl> + { <nl> + " kind " : " TypeNominal " , <nl> + " name " : " Int32 " , <nl> + " printedName " : " Swift . Int32 " , <nl> + " usr " : " s : s5Int32V " <nl> + } <nl> + ] , <nl> + " declKind " : " Constructor " , <nl> + " usr " : " c : objc ( cs ) PhotoBracketSettings ( cm ) photoBracketSettingsWithNumber : " , <nl> + " moduleName " : " Foo " , <nl> + " objc_name " : " photoBracketSettingsWithNumber : " , <nl> + " declAttributes " : [ <nl> + " ObjC " , <nl> + " Dynamic " <nl> + ] , <nl> + " init_kind " : " ConvenienceFactory " <nl> + } , <nl> + { <nl> + " kind " : " Constructor " , <nl> + " name " : " init " , <nl> + " printedName " : " init ( format : ) " , <nl> + " children " : [ <nl> + { <nl> + " kind " : " TypeNominal " , <nl> + " name " : " Optional " , <nl> + " printedName " : " Foo . PhotoBracketSettings ? " , <nl> + " children " : [ <nl> + { <nl> + " kind " : " TypeNominal " , <nl> + " name " : " PhotoBracketSettings " , <nl> + " printedName " : " Foo . PhotoBracketSettings " , <nl> + " usr " : " c : objc ( cs ) PhotoBracketSettings " <nl> + } <nl> + ] , <nl> + " usr " : " s : Sq " <nl> + } , <nl> + { <nl> + " kind " : " TypeNominal " , <nl> + " name " : " Int32 " , <nl> + " printedName " : " Swift . Int32 " , <nl> + " usr " : " s : s5Int32V " <nl> + } <nl> + ] , <nl> + " declKind " : " Constructor " , <nl> + " usr " : " c : objc ( cs ) PhotoSettings ( cm ) photoSettingsWithFormat : " , <nl> + " moduleName " : " Foo " , <nl> + " overriding " : true , <nl> + " implicit " : true , <nl> + " objc_name " : " photoSettingsWithFormat : " , <nl> + " declAttributes " : [ <nl> + " Override " , <nl> + " ObjC " , <nl> + " Dynamic " <nl> + ] , <nl> + " init_kind " : " ConvenienceFactory " <nl> + } , <nl> + { <nl> + " kind " : " Constructor " , <nl> + " name " : " init " , <nl> + " printedName " : " init ( ) " , <nl> + " children " : [ <nl> + { <nl> + " kind " : " TypeNominal " , <nl> + " name " : " PhotoBracketSettings " , <nl> + " printedName " : " Foo . PhotoBracketSettings " , <nl> + " usr " : " c : objc ( cs ) PhotoBracketSettings " <nl> + } <nl> + ] , <nl> + " declKind " : " Constructor " , <nl> + " usr " : " c : objc ( cs ) NSObject ( im ) init " , <nl> + " moduleName " : " Foo " , <nl> + " overriding " : true , <nl> + " implicit " : true , <nl> + " objc_name " : " init " , <nl> + " declAttributes " : [ <nl> + " Override " , <nl> + " ObjC " , <nl> + " Dynamic " <nl> + ] , <nl> + " init_kind " : " Designated " <nl> + } <nl> + ] , <nl> + " declKind " : " Class " , <nl> + " usr " : " c : objc ( cs ) PhotoBracketSettings " , <nl> + " moduleName " : " Foo " , <nl> + " isOpen " : true , <nl> + " objc_name " : " PhotoBracketSettings " , <nl> + " declAttributes " : [ <nl> + " ObjC " , <nl> + " Dynamic " <nl> + ] , <nl> + " superclassUsr " : " c : objc ( cs ) PhotoSettings " , <nl> + " inheritsConvenienceInitializers " : true , <nl> + " superclassNames " : [ <nl> + " Foo . PhotoSettings " , <nl> + " ObjectiveC . NSObject " <nl> + ] , <nl> + " conformances " : [ <nl> + { <nl> + " kind " : " Conformance " , <nl> + " name " : " NSObjectProtocol " , <nl> + " printedName " : " NSObjectProtocol " , <nl> + " usr " : " c : objc ( pl ) NSObject " <nl> + } , <nl> + { <nl> + " kind " : " Conformance " , <nl> + " name " : " Equatable " , <nl> + " printedName " : " Equatable " , <nl> + " usr " : " s : SQ " <nl> + } , <nl> + { <nl> + " kind " : " Conformance " , <nl> + " name " : " Hashable " , <nl> + " printedName " : " Hashable " , <nl> + " usr " : " s : SH " <nl> + } , <nl> + { <nl> + " kind " : " Conformance " , <nl> + " name " : " CVarArg " , <nl> + " printedName " : " CVarArg " , <nl> + " usr " : " s : s7CVarArgP " <nl> + } <nl> + ] <nl> + } , <nl> + { <nl> + " kind " : " TypeDecl " , <nl> + " name " : " PhotoSettings " , <nl> + " printedName " : " PhotoSettings " , <nl> + " children " : [ <nl> + { <nl> + " kind " : " Constructor " , <nl> + " name " : " init " , <nl> + " printedName " : " init ( format : ) " , <nl> + " children " : [ <nl> + { <nl> + " kind " : " TypeNominal " , <nl> + " name " : " Optional " , <nl> + " printedName " : " Foo . PhotoSettings ? " , <nl> + " children " : [ <nl> + { <nl> + " kind " : " TypeNominal " , <nl> + " name " : " PhotoSettings " , <nl> + " printedName " : " Foo . PhotoSettings " , <nl> + " usr " : " c : objc ( cs ) PhotoSettings " <nl> + } <nl> + ] , <nl> + " usr " : " s : Sq " <nl> + } , <nl> + { <nl> + " kind " : " TypeNominal " , <nl> + " name " : " Int32 " , <nl> + " printedName " : " Swift . Int32 " , <nl> + " usr " : " s : s5Int32V " <nl> + } <nl> + ] , <nl> + " declKind " : " Constructor " , <nl> + " usr " : " c : objc ( cs ) PhotoSettings ( cm ) photoSettingsWithFormat : " , <nl> + " moduleName " : " Foo " , <nl> + " objc_name " : " photoSettingsWithFormat : " , <nl> + " declAttributes " : [ <nl> + " ObjC " , <nl> + " Dynamic " <nl> + ] , <nl> + " init_kind " : " ConvenienceFactory " <nl> + } , <nl> + { <nl> + " kind " : " Constructor " , <nl> + " name " : " init " , <nl> + " printedName " : " init ( number : ) " , <nl> + " children " : [ <nl> + { <nl> + " kind " : " TypeNominal " , <nl> + " name " : " Optional " , <nl> + " printedName " : " Foo . PhotoSettings ? " , <nl> + " children " : [ <nl> + { <nl> + " kind " : " TypeNominal " , <nl> + " name " : " PhotoSettings " , <nl> + " printedName " : " Foo . PhotoSettings " , <nl> + " usr " : " c : objc ( cs ) PhotoSettings " <nl> + } <nl> + ] , <nl> + " usr " : " s : Sq " <nl> + } , <nl> + { <nl> + " kind " : " TypeNominal " , <nl> + " name " : " Int32 " , <nl> + " printedName " : " Swift . Int32 " , <nl> + " usr " : " s : s5Int32V " <nl> + } <nl> + ] , <nl> + " declKind " : " Constructor " , <nl> + " usr " : " c : objc ( cs ) PhotoSettings ( cm ) photoSettingsWithNumber : " , <nl> + " moduleName " : " Foo " , <nl> + " objc_name " : " photoSettingsWithNumber : " , <nl> + " declAttributes " : [ <nl> + " ObjC " , <nl> + " Dynamic " <nl> + ] , <nl> + " init_kind " : " ConvenienceFactory " <nl> + } , <nl> + { <nl> + " kind " : " Constructor " , <nl> + " name " : " init " , <nl> + " printedName " : " init ( ) " , <nl> + " children " : [ <nl> + { <nl> + " kind " : " TypeNominal " , <nl> + " name " : " PhotoSettings " , <nl> + " printedName " : " Foo . PhotoSettings " , <nl> + " usr " : " c : objc ( cs ) PhotoSettings " <nl> + } <nl> + ] , <nl> + " declKind " : " Constructor " , <nl> + " usr " : " c : objc ( cs ) NSObject ( im ) init " , <nl> + " moduleName " : " Foo " , <nl> + " overriding " : true , <nl> + " implicit " : true , <nl> + " objc_name " : " init " , <nl> + " declAttributes " : [ <nl> + " Override " , <nl> + " ObjC " , <nl> + " Dynamic " <nl> + ] , <nl> + " init_kind " : " Designated " <nl> + } <nl> + ] , <nl> + " declKind " : " Class " , <nl> + " usr " : " c : objc ( cs ) PhotoSettings " , <nl> + " moduleName " : " Foo " , <nl> + " isOpen " : true , <nl> + " objc_name " : " PhotoSettings " , <nl> + " declAttributes " : [ <nl> + " ObjC " , <nl> + " Dynamic " <nl> + ] , <nl> + " superclassUsr " : " c : objc ( cs ) NSObject " , <nl> + " inheritsConvenienceInitializers " : true , <nl> + " superclassNames " : [ <nl> + " ObjectiveC . NSObject " <nl> + ] , <nl> + " conformances " : [ <nl> + { <nl> + " kind " : " Conformance " , <nl> + " name " : " NSObjectProtocol " , <nl> + " printedName " : " NSObjectProtocol " , <nl> + " usr " : " c : objc ( pl ) NSObject " <nl> + } , <nl> + { <nl> + " kind " : " Conformance " , <nl> + " name " : " Equatable " , <nl> + " printedName " : " Equatable " , <nl> + " usr " : " s : SQ " <nl> + } , <nl> + { <nl> + " kind " : " Conformance " , <nl> + " name " : " Hashable " , <nl> + " printedName " : " Hashable " , <nl> + " usr " : " s : SH " <nl> + } , <nl> + { <nl> + " kind " : " Conformance " , <nl> + " name " : " CVarArg " , <nl> + " printedName " : " CVarArg " , <nl> + " usr " : " s : s7CVarArgP " <nl> + } <nl> + ] <nl> } <nl> ] , <nl> " json_format_version " : 6 <nl>
Merge pull request from akyrtzi / clang - include - inherited - convenience - inits - for - members
apple/swift
a3ce4621a2226c512b22bea37400f471f45b98bc
2020-06-10T23:29:41Z
mmm a / src / common / common_funcs . h <nl> ppp b / src / common / common_funcs . h <nl> <nl> <nl> # pragma once <nl> <nl> - # if ! defined ( ARCHITECTURE_x86_64 ) & & ! defined ( _M_ARM ) <nl> + # if ! defined ( ARCHITECTURE_x86_64 ) & & ! defined ( ARCHITECTURE_ARM ) <nl> # include < cstdlib > / / for exit <nl> # endif <nl> # include " common / common_types . h " <nl> <nl> <nl> # ifdef ARCHITECTURE_x86_64 <nl> # define Crash ( ) __asm__ __volatile__ ( " int $ 3 " ) <nl> - # elif defined ( _M_ARM ) <nl> + # elif defined ( ARCHITECTURE_ARM ) <nl> # define Crash ( ) __asm__ __volatile__ ( " trap " ) <nl> # else <nl> # define Crash ( ) exit ( 1 ) <nl> mmm a / src / common / memory_util . cpp <nl> ppp b / src / common / memory_util . cpp <nl> <nl> # include < sys / mman . h > <nl> # endif <nl> <nl> - # if ! defined ( _WIN32 ) & & defined ( ARCHITECTURE_X64 ) & & ! defined ( MAP_32BIT ) <nl> + # if ! defined ( _WIN32 ) & & defined ( ARCHITECTURE_x86_64 ) & & ! defined ( MAP_32BIT ) <nl> # include < unistd . h > <nl> # define PAGE_MASK ( getpagesize ( ) - 1 ) <nl> # define round_page ( x ) ( ( ( ( unsigned long ) ( x ) ) + PAGE_MASK ) & ~ ( PAGE_MASK ) ) <nl> void * AllocateExecutableMemory ( size_t size , bool low ) { <nl> void * ptr = VirtualAlloc ( nullptr , size , MEM_COMMIT , PAGE_EXECUTE_READWRITE ) ; <nl> # else <nl> static char * map_hint = nullptr ; <nl> - # if defined ( ARCHITECTURE_X64 ) & & ! defined ( MAP_32BIT ) <nl> + # if defined ( ARCHITECTURE_x86_64 ) & & ! defined ( MAP_32BIT ) <nl> / / This OS has no flag to enforce allocation below the 4 GB boundary , <nl> / / but if we hint that we want a low address it is very likely we will <nl> / / get one . <nl> void * AllocateExecutableMemory ( size_t size , bool low ) { <nl> # endif <nl> void * ptr = mmap ( map_hint , size , PROT_READ | PROT_WRITE | PROT_EXEC , <nl> MAP_ANON | MAP_PRIVATE <nl> - # if defined ( ARCHITECTURE_X64 ) & & defined ( MAP_32BIT ) <nl> + # if defined ( ARCHITECTURE_x86_64 ) & & defined ( MAP_32BIT ) <nl> | ( low ? MAP_32BIT : 0 ) <nl> # endif <nl> , <nl> void * AllocateExecutableMemory ( size_t size , bool low ) { <nl> # endif <nl> LOG_ERROR ( Common_Memory , " Failed to allocate executable memory " ) ; <nl> } <nl> - # if ! defined ( _WIN32 ) & & defined ( ARCHITECTURE_X64 ) & & ! defined ( MAP_32BIT ) <nl> + # if ! defined ( _WIN32 ) & & defined ( ARCHITECTURE_x86_64 ) & & ! defined ( MAP_32BIT ) <nl> else { <nl> if ( low ) { <nl> map_hint + = size ; <nl> mmm a / src / common / swap . h <nl> ppp b / src / common / swap . h <nl> inline u32 swap32 ( u32 _data ) { <nl> inline u64 swap64 ( u64 _data ) { <nl> return _byteswap_uint64 ( _data ) ; <nl> } <nl> - # elif _M_ARM <nl> + # elif ARCHITECTURE_ARM <nl> inline u16 swap16 ( u16 _data ) { <nl> u32 data = _data ; <nl> __asm__ ( " rev16 % 0 , % 1 \ n " : " = l " ( data ) : " l " ( data ) ) ; <nl>
Merge pull request from FearlessTobi / port - defines
yuzu-emu/yuzu
04524e76c2694def4a2f1f4279ad2a2db787c775
2018-07-10T16:12:52Z
mmm a / editor / project_export . cpp <nl> ppp b / editor / project_export . cpp <nl> void ProjectExportDialog : : _edit_preset ( int p_index ) { <nl> if ( p_index < 0 | | p_index > = presets - > get_item_count ( ) ) { <nl> name - > set_text ( " " ) ; <nl> name - > set_editable ( false ) ; <nl> + export_path - > set_editable ( false ) ; <nl> runnable - > set_disabled ( true ) ; <nl> parameters - > edit ( NULL ) ; <nl> presets - > unselect_all ( ) ; <nl> void ProjectExportDialog : : _edit_preset ( int p_index ) { <nl> sections - > show ( ) ; <nl> <nl> name - > set_editable ( true ) ; <nl> + export_path - > set_editable ( true ) ; <nl> duplicate_preset - > set_disabled ( false ) ; <nl> delete_preset - > set_disabled ( false ) ; <nl> name - > set_text ( current - > get_name ( ) ) ; <nl> + export_path - > set_text ( current - > get_export_path ( ) ) ; <nl> runnable - > set_disabled ( false ) ; <nl> runnable - > set_pressed ( current - > is_runnable ( ) ) ; <nl> parameters - > edit ( current . ptr ( ) ) ; <nl> void ProjectExportDialog : : _name_changed ( const String & p_string ) { <nl> _update_presets ( ) ; <nl> } <nl> <nl> + void ProjectExportDialog : : _export_path_changed ( const String & p_string ) { <nl> + <nl> + if ( updating ) <nl> + return ; <nl> + <nl> + Ref < EditorExportPreset > current = EditorExport : : get_singleton ( ) - > get_export_preset ( presets - > get_current ( ) ) ; <nl> + ERR_FAIL_COND ( current . is_null ( ) ) ; <nl> + <nl> + current - > set_export_path ( p_string ) ; <nl> + _update_presets ( ) ; <nl> + } <nl> + <nl> void ProjectExportDialog : : _duplicate_preset ( ) { <nl> <nl> Ref < EditorExportPreset > current = EditorExport : : get_singleton ( ) - > get_export_preset ( presets - > get_current ( ) ) ; <nl> ProjectExportDialog : : ProjectExportDialog ( ) { <nl> runnable - > connect ( " pressed " , this , " _runnable_pressed " ) ; <nl> settings_vb - > add_child ( runnable ) ; <nl> <nl> + export_path = memnew ( LineEdit ) ; <nl> + settings_vb - > add_margin_child ( TTR ( " Export Path : " ) , export_path ) ; <nl> + export_path - > connect ( " text_changed " , this , " _export_path_changed " ) ; <nl> + <nl> sections = memnew ( TabContainer ) ; <nl> sections - > set_tab_align ( TabContainer : : ALIGN_LEFT ) ; <nl> settings_vb - > add_child ( sections ) ; <nl> ProjectExportDialog : : ProjectExportDialog ( ) { <nl> <nl> / / disable by default <nl> name - > set_editable ( false ) ; <nl> + export_path - > set_editable ( false ) ; <nl> runnable - > set_disabled ( true ) ; <nl> duplicate_preset - > set_disabled ( true ) ; <nl> delete_preset - > set_disabled ( true ) ; <nl> mmm a / editor / project_export . h <nl> ppp b / editor / project_export . h <nl> class ProjectExportDialog : public ConfirmationDialog { <nl> ItemList * presets ; <nl> <nl> LineEdit * name ; <nl> + LineEdit * export_path ; <nl> EditorInspector * parameters ; <nl> CheckButton * runnable ; <nl> <nl> class ProjectExportDialog : public ConfirmationDialog { <nl> void _runnable_pressed ( ) ; <nl> void _update_parameters ( const String & p_edited_property ) ; <nl> void _name_changed ( const String & p_string ) ; <nl> + void _export_path_changed ( const String & p_string ) ; <nl> void _add_preset ( int p_platform ) ; <nl> void _edit_preset ( int p_index ) ; <nl> void _duplicate_preset ( ) ; <nl>
Merge pull request from marcelofg55 / export_path2
godotengine/godot
8739f4b6e23b4655df444a019ccfab9f271b591a
2018-11-06T21:09:33Z
mmm a / atom / browser / api / atom_api_app . cc <nl> ppp b / atom / browser / api / atom_api_app . cc <nl> bool App : : MakeSingleInstance ( <nl> } <nl> } <nl> <nl> + void App : : ReleaseSingleInstance ( ) { <nl> + if ( process_singleton_ . get ( ) ) { <nl> + process_singleton_ - > Cleanup ( ) ; <nl> + process_singleton_ . reset ( ) ; <nl> + } <nl> + } <nl> + <nl> # if defined ( USE_NSS_CERTS ) <nl> void App : : ImportCertificate ( <nl> const base : : DictionaryValue & options , <nl> void App : : BuildPrototype ( <nl> # if defined ( USE_NSS_CERTS ) <nl> . SetMethod ( " importCertificate " , & App : : ImportCertificate ) <nl> # endif <nl> - . SetMethod ( " makeSingleInstance " , & App : : MakeSingleInstance ) ; <nl> + . SetMethod ( " makeSingleInstance " , & App : : MakeSingleInstance ) <nl> + . SetMethod ( " releaseSingleInstance " , & App : : ReleaseSingleInstance ) ; <nl> } <nl> <nl> } / / namespace api <nl> mmm a / atom / browser / api / atom_api_app . h <nl> ppp b / atom / browser / api / atom_api_app . h <nl> class App : public AtomBrowserClient : : Delegate , <nl> void SetDesktopName ( const std : : string & desktop_name ) ; <nl> bool MakeSingleInstance ( <nl> const ProcessSingleton : : NotificationCallback & callback ) ; <nl> + void ReleaseSingleInstance ( ) ; <nl> std : : string GetLocale ( ) ; <nl> <nl> # if defined ( USE_NSS_CERTS ) <nl> mmm a / docs / api / app . md <nl> ppp b / docs / api / app . md <nl> app . on ( ' ready ' , ( ) = > { <nl> } ) ; <nl> ` ` ` <nl> <nl> + # # # ` app . releaseSingleInstance ( ) ` <nl> + <nl> + Releases all locks that were created by ` makeSingleInstance ` . This will allow <nl> + multiple instances of the application to once again run side by side . <nl> + <nl> # # # ` app . setUserActivity ( type , userInfo [ , webpageURL ] ) ` _OS X_ <nl> <nl> * ` type ` String - Uniquely identifies the activity . Maps to <nl>
Merge pull request from danhp / release - single - instance
electron/electron
26fa963a70200f89e2d6d21bc074f3c7c3dd97a6
2016-05-30T00:51:13Z