diff options
90 files changed, 975 insertions, 982 deletions
diff --git a/core/extension/gdextension_interface.cpp b/core/extension/gdextension_interface.cpp index d1b4e6a30f..e02e7aa701 100644 --- a/core/extension/gdextension_interface.cpp +++ b/core/extension/gdextension_interface.cpp @@ -159,9 +159,7 @@ public: userdata = p_info->callable_userdata; token = p_info->token; - if (p_info->object != nullptr) { - object = ((Object *)p_info->object)->get_instance_id(); - } + object = p_info->object_id; call_func = p_info->call_func; is_valid_func = p_info->is_valid_func; diff --git a/core/extension/gdextension_interface.h b/core/extension/gdextension_interface.h index 240da6e073..d58f0226d8 100644 --- a/core/extension/gdextension_interface.h +++ b/core/extension/gdextension_interface.h @@ -392,7 +392,7 @@ typedef GDExtensionBool (*GDExtensionCallableCustomLessThan)(void *callable_user typedef void (*GDExtensionCallableCustomToString)(void *callable_userdata, GDExtensionBool *r_is_valid, GDExtensionStringPtr r_out); typedef struct { - /* Only `call_func` and `token` are strictly required, however, `object` should be passed if its not a static method. + /* Only `call_func` and `token` are strictly required, however, `object_id` should be passed if its not a static method. * * `token` should point to an address that uniquely identifies the GDExtension (for example, the * `GDExtensionClassLibraryPtr` passed to the entry symbol function. @@ -409,7 +409,7 @@ typedef struct { void *callable_userdata; void *token; - GDExtensionObjectPtr object; + GDObjectInstanceID object_id; GDExtensionCallableCustomCall call_func; GDExtensionCallableCustomIsValid is_valid_func; diff --git a/core/input/gamecontrollerdb.txt b/core/input/gamecontrollerdb.txt index 9a43c4e35d..77655e9b6a 100644 --- a/core/input/gamecontrollerdb.txt +++ b/core/input/gamecontrollerdb.txt @@ -414,6 +414,8 @@ 03000000ad1b000023f0000000000000,MLG,a:b0,b:b1,back:b7,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a6,rightx:a3,righty:a4,start:b6,x:b2,y:b3,platform:Windows, 03000000ad1b00003ef0000000000000,MLG Fightstick TE,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b8,rightshoulder:b5,righttrigger:b9,start:b7,x:b2,y:b3,platform:Windows, 03000000380700006382000000000000,MLG PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000004523000015e0000000000000,Mobapad Chitu HD,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,misc1:b13,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, +03000000491900000904000000000000,Mobapad Chitu HD,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,misc1:b15,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows, 03000000ffff00000000000000000000,Mocute M053,a:b3,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b11,leftstick:b7,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b6,righttrigger:b4,rightx:a3,righty:a4,start:b8,x:b1,y:b0,platform:Windows, 03000000d6200000e589000000000000,Moga 2,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,rightx:a2,righty:a5,start:b7,x:b2,y:b3,platform:Windows, 03000000d62000007162000000000000,Moga Pro,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,rightx:a2,righty:a5,start:b7,x:b2,y:b3,platform:Windows, @@ -582,6 +584,7 @@ 03000000921200004547000000000000,Retro Bit Sega Genesis Controller Adapter,a:b0,b:b1,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,lefttrigger:b7,rightshoulder:b5,righttrigger:b2,start:b6,x:b3,y:b4,platform:Windows, 03000000790000001100000000000000,Retro Controller,a:b1,b:b2,back:b8,dpdown:+a4,dpleft:-a3,dpright:+a3,dpup:-a4,leftshoulder:b6,lefttrigger:b7,rightshoulder:b4,righttrigger:b5,start:b9,x:b0,y:b3,platform:Windows, 03000000830500006020000000000000,Retro Controller,a:b0,b:b1,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,lefttrigger:b5,rightshoulder:b8,righttrigger:b9,start:b7,x:b2,y:b3,platform:Windows, +0300000003040000c197000000000000,Retrode Adapter,a:b0,b:b4,back:b2,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b3,x:b1,y:b5,platform:Windows, 03000000bd12000013d0000000000000,Retrolink Sega Saturn Classic Controller,a:b0,b:b1,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b5,lefttrigger:b6,rightshoulder:b2,righttrigger:b7,start:b8,x:b3,y:b4,platform:Windows, 03000000bd12000015d0000000000000,Retrolink SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Windows, 03000000341200000400000000000000,RetroUSB N64 RetroPort,+rightx:b8,+righty:b10,-rightx:b9,-righty:b11,a:b7,b:b6,dpdown:b2,dpleft:b1,dpright:b0,dpup:b3,leftshoulder:b13,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b12,start:b4,platform:Windows, @@ -643,7 +646,6 @@ 030000003b07000004a1000000000000,SFX,a:b0,b:b2,back:b7,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b9,righttrigger:b5,start:b8,x:b1,y:b3,platform:Windows, 03000000f82100001900000000000000,Shogun Bros Chameleon X1,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows, 03000000120c00001c1e000000000000,SnakeByte 4S PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, -0300000003040000c197000000000000,SNES Controller,a:b0,b:b4,back:b2,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b3,x:b1,y:b5,platform:Windows, 0300000081170000960a000000000000,SNES Controller,a:b4,b:b0,back:b2,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b3,x:b5,y:b1,platform:Windows, 03000000811700009d0a000000000000,SNES Controller,a:b0,b:b4,back:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b1,y:b5,platform:Windows, 030000008b2800000300000000000000,SNES Controller,a:b0,b:b4,back:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b1,y:b5,platform:Windows, @@ -772,6 +774,7 @@ 03000000341a00000608000000000000,Xeox,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, 03000000450c00002043000000000000,Xeox SL6556BK,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, 030000006f0e00000300000000000000,XGear,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a5,righty:a2,start:b9,x:b3,y:b0,platform:Windows, +03000000e0ff00000201000000000000,Xiaomi Black Shark (L),back:b0,dpdown:b11,dpleft:b9,dpright:b10,dpup:b8,leftshoulder:b5,lefttrigger:b7,leftx:a0,lefty:a1,platform:Windows, 03000000172700004431000000000000,Xiaomi Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b20,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a7,rightx:a2,righty:a5,start:b11,x:b3,y:b4,platform:Windows, 03000000172700003350000000000000,Xiaomi XMGP01YM,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows, 03000000bc2000005060000000000000,Xiaomi XMGP01YM,+lefty:+a2,+righty:+a5,-lefty:-a1,-righty:-a4,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,start:b11,x:b3,y:b4,platform:Windows, @@ -928,6 +931,7 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 030000005e0400000300000006010000,Microsoft SideWinder,a:b0,b:b1,back:b9,leftshoulder:b6,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b2,start:b8,x:b3,y:b4,platform:Mac OS X, 030000005e0400000700000006010000,Microsoft SideWinder,a:b0,b:b1,back:b8,leftshoulder:b6,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b2,start:b9,x:b3,y:b4,platform:Mac OS X, 030000005e0400002700000001010000,Microsoft SideWinder Plug and Play,a:b0,b:b1,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,lefttrigger:b4,righttrigger:b5,x:b2,y:b3,platform:Mac OS X, +030000004523000015e0000072050000,Mobapad Chitu HD,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,misc1:b13,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X, 03000000d62000007162000001000000,Moga Pro 2,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Mac OS X, 03000000c62400002a89000000010000,MOGA XP5A Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b21,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X, 03000000c62400002b89000000010000,MOGA XP5A Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X, @@ -979,6 +983,7 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 03000000790000001100000000000000,Retro Controller,a:b1,b:b2,back:b8,dpdown:+a4,dpleft:-a3,dpright:+a3,dpup:-a4,leftshoulder:b6,lefttrigger:b7,rightshoulder:b4,righttrigger:b5,start:b9,x:b0,y:b3,platform:Mac OS X, 03000000790000001100000005010000,Retro Controller,a:b1,b:b2,back:b8,dpdown:+a4,dpleft:-a3,dpright:+a3,dpup:-a4,leftshoulder:b6,lefttrigger:b7,rightshoulder:b5,righttrigger:b4,start:b9,x:b0,y:b3,platform:Mac OS X, 03000000830500006020000000010000,Retro Controller,a:b0,b:b1,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,lefttrigger:b5,rightshoulder:b8,righttrigger:b9,start:b7,x:b2,y:b3,platform:Mac OS X, +0300000003040000c197000000000000,Retrode Adapter,a:b0,b:b4,back:b2,dpdown:+a4,dpleft:-a0,dpright:+a0,dpup:-a4,leftshoulder:b6,rightshoulder:b7,start:b3,x:b1,y:b5,platform:Mac OS X, 03000000790000001100000006010000,Retrolink SNES Controller,a:b2,b:b1,back:b8,dpdown:+a4,dpleft:-a3,dpright:+a3,dpup:-a4,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X, 03000000341200000400000000000000,RetroUSB N64 RetroPort,+rightx:b8,+righty:b10,-rightx:b9,-righty:b11,a:b7,b:b6,dpdown:b2,dpleft:b1,dpright:b0,dpup:b3,leftshoulder:b13,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b12,start:b4,platform:Mac OS X, 030000006b140000010d000000010000,Revolution Pro Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X, @@ -1335,8 +1340,10 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 030000005e040000000b000007040000,Microsoft Xbox One Elite 2,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b12,paddle2:b14,paddle3:b13,paddle4:b15,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 030000005e040000000b000008040000,Microsoft Xbox One Elite 2,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b12,paddle2:b14,paddle3:b13,paddle4:b15,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 050000005e040000050b000003090000,Microsoft Xbox One Elite 2,a:b0,b:b1,back:b17,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a6,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux, +050000005e0400008e02000030110000,Microsoft Xbox One Elite 2,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b13,paddle3:b12,paddle4:b14,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 030000005e040000120b00000b050000,Microsoft Xbox Series Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 03000000030000000300000002000000,Miroof,a:b1,b:b0,back:b6,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Linux, +03000000790000001c18000010010000,Mobapad Chitu HD,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux, 050000004d4f435554452d3035335800,Mocute 053X,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux, 05000000e80400006e0400001b010000,Mocute 053X M59,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux, 050000004d4f435554452d3035305800,Mocute 054X,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux, @@ -1490,6 +1497,7 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 0300000032150000030a000001010000,Razer Wildcat,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 03000000321500000b10000011010000,Razer Wolverine PS5 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,touchpad:b13,x:b0,y:b3,platform:Linux, 03000000790000001100000010010000,Retro Controller,a:b1,b:b2,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,lefttrigger:b7,rightshoulder:b4,righttrigger:b5,start:b9,x:b0,y:b3,platform:Linux, +0300000003040000c197000011010000,Retrode Adapter,a:b0,b:b4,back:b2,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b3,x:b1,y:b5,platform:Linux, 190000004b4800000111000000010000,RetroGame Joypad,a:b1,b:b0,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux, 0300000081170000990a000001010000,Retronic Adapter,a:b0,leftx:a0,lefty:a1,platform:Linux, 0300000000f000000300000000010000,RetroPad,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,platform:Linux, @@ -1639,6 +1647,7 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 060000005e040000120b000007050000,Xbox Series Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 060000005e040000120b00000b050000,Xbox Series Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 060000005e040000120b00000f050000,Xbox Series Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,misc1:b11,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +060000005e040000120b00000d050000,Xbox Series X Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,misc1:b11,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 050000005e040000200b000013050000,Xbox Wireless Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux, 03000000450c00002043000010010000,XEOX SL6556 BK,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux, 05000000172700004431000029010000,XiaoMi Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b20,leftshoulder:b6,leftstick:b13,lefttrigger:a7,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a6,rightx:a2,righty:a5,start:b11,x:b3,y:b4,platform:Linux, @@ -1792,6 +1801,7 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 33323763323132376537376266393366,Microsoft Dual Strike,a:b24,b:b23,back:b25,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b27,lefttrigger:b29,rightshoulder:b78,rightx:a0,righty:a1~,start:b26,x:b22,y:b21,platform:Android, 30306461613834333439303734316539,Microsoft SideWinder Pro,a:b0,b:b1,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b20,lefttrigger:b9,rightshoulder:b19,righttrigger:b10,start:b17,x:b2,y:b3,platform:Android, 32386235353630393033393135613831,Microsoft Xbox Series Controller,a:b0,b:b1,back:b4,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, +4d4f42415041442050726f2d48440000,Mobapad Chitu HD,a:b0,b:b1,back:b15,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, 4d4f435554452d303533582d4d35312d,Mocute 053X,a:b0,b:b1,back:b15,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, 33343361376163623438613466616531,Mocute M053,a:b0,b:b1,back:b15,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:b17,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:b18,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, 39306635663061636563316166303966,Mocute M053,a:b0,b:b1,back:b15,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:b17,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:b18,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index f7915261af..6721ec0953 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -1053,8 +1053,9 @@ void ResourceLoader::clear_thread_load_tasks() { thread_load_mutex.lock(); } - for (KeyValue<String, LoadToken *> &E : user_load_tokens) { - memdelete(E.value); + while (user_load_tokens.begin()) { + // User load tokens remove themselves from the map on destruction. + memdelete(user_load_tokens.begin()->value); } user_load_tokens.clear(); diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp index c594f4a9b4..8c54db3c2c 100644 --- a/core/object/class_db.cpp +++ b/core/object/class_db.cpp @@ -165,8 +165,8 @@ ClassDB::APIType ClassDB::get_api_type(const StringName &p_class) { } uint32_t ClassDB::get_api_hash(APIType p_api) { - OBJTYPE_RLOCK; #ifdef DEBUG_METHODS_ENABLED + OBJTYPE_WLOCK; if (api_hashes_cache.has(p_api)) { return api_hashes_cache[p_api]; @@ -175,7 +175,9 @@ uint32_t ClassDB::get_api_hash(APIType p_api) { uint64_t hash = hash_murmur3_one_64(HashMapHasherDefault::hash(VERSION_FULL_CONFIG)); List<StringName> class_list; - ClassDB::get_class_list(&class_list); + for (const KeyValue<StringName, ClassInfo> &E : classes) { + class_list.push_back(E.key); + } // Must be alphabetically sorted for hash to compute. class_list.sort_custom<StringName::AlphCompare>(); @@ -859,8 +861,8 @@ void ClassDB::get_enum_constants(const StringName &p_class, const StringName &p_ } void ClassDB::set_method_error_return_values(const StringName &p_class, const StringName &p_method, const Vector<Error> &p_values) { - OBJTYPE_RLOCK; #ifdef DEBUG_METHODS_ENABLED + OBJTYPE_WLOCK; ClassInfo *type = classes.getptr(p_class); ERR_FAIL_NULL(type); @@ -871,6 +873,7 @@ void ClassDB::set_method_error_return_values(const StringName &p_class, const St Vector<Error> ClassDB::get_method_error_return_values(const StringName &p_class, const StringName &p_method) { #ifdef DEBUG_METHODS_ENABLED + OBJTYPE_RLOCK; ClassInfo *type = classes.getptr(p_class); ERR_FAIL_NULL_V(type, Vector<Error>()); @@ -1415,6 +1418,8 @@ void ClassDB::_bind_compatibility(ClassInfo *type, MethodBind *p_method) { } void ClassDB::_bind_method_custom(const StringName &p_class, MethodBind *p_method, bool p_compatibility) { + OBJTYPE_WLOCK; + ClassInfo *type = classes.getptr(p_class); if (!type) { ERR_FAIL_MSG("Couldn't bind custom method '" + p_method->get_name() + "' for instance '" + p_class + "'."); diff --git a/core/object/script_language_extension.h b/core/object/script_language_extension.h index 5f3a70cad8..00ab1cd6c0 100644 --- a/core/object/script_language_extension.h +++ b/core/object/script_language_extension.h @@ -313,6 +313,9 @@ public: ERR_CONTINUE(!err.has("message")); ScriptError serr; + if (err.has("path")) { + serr.path = err["path"]; + } serr.line = err["line"]; serr.column = err["column"]; serr.message = err["message"]; diff --git a/doc/classes/Animation.xml b/doc/classes/Animation.xml index d2b2c1fe47..15f6b16439 100644 --- a/doc/classes/Animation.xml +++ b/doc/classes/Animation.xml @@ -257,7 +257,7 @@ <param index="0" name="track_idx" type="int" /> <param index="1" name="to_animation" type="Animation" /> <description> - Adds a new track that is a copy of the given track from [param to_animation]. + Adds a new track to [param to_animation] that is a copy of the given track from this animation. </description> </method> <method name="find_track" qualifiers="const"> diff --git a/doc/classes/ImmediateMesh.xml b/doc/classes/ImmediateMesh.xml index bde11a850e..7e40d0b4c5 100644 --- a/doc/classes/ImmediateMesh.xml +++ b/doc/classes/ImmediateMesh.xml @@ -15,6 +15,14 @@ mesh.surface_add_vertex(Vector3.ZERO) mesh.surface_end() [/gdscript] + [csharp] + var mesh = new ImmediateMesh(); + mesh.SurfaceBegin(Mesh.PrimitiveType.Triangles); + mesh.SurfaceAddVertex(Vector3.Left); + mesh.SurfaceAddVertex(Vector3.Forward); + mesh.SurfaceAddVertex(Vector3.Zero); + mesh.SurfaceEnd(); + [/csharp] [/codeblocks] [b]Note:[/b] Generating complex geometries with [ImmediateMesh] is highly inefficient. Instead, it is designed to generate simple geometry that changes often. </description> diff --git a/doc/classes/Light3D.xml b/doc/classes/Light3D.xml index ebb36ba92b..d0bc7926ca 100644 --- a/doc/classes/Light3D.xml +++ b/doc/classes/Light3D.xml @@ -52,7 +52,7 @@ [b]Note:[/b] Only effective for [OmniLight3D] and [SpotLight3D], and only when [member shadow_enabled] is [code]true[/code]. </member> <member name="editor_only" type="bool" setter="set_editor_only" getter="is_editor_only" default="false"> - If [code]true[/code], the light only appears in the editor and will not be visible at runtime. + If [code]true[/code], the light only appears in the editor and will not be visible at runtime. If [code]true[/code], the light will never be baked in [LightmapGI] regardless of its [member light_bake_mode]. </member> <member name="light_angular_distance" type="float" setter="set_param" getter="get_param" default="0.0"> The light's angular size in degrees. Increasing this will make shadows softer at greater distances (also called percentage-closer soft shadows, or PCSS). Only available for [DirectionalLight3D]s. For reference, the Sun from the Earth is approximately [code]0.5[/code]. Increasing this value above [code]0.0[/code] for lights with shadows enabled will have a noticeable performance cost due to PCSS. @@ -203,6 +203,7 @@ </constant> <constant name="BAKE_STATIC" value="1" enum="BakeMode"> Light is taken into account in static baking ([VoxelGI], [LightmapGI], SDFGI ([member Environment.sdfgi_enabled])). The light can be moved around or modified, but its global illumination will not update in real-time. This is suitable for subtle changes (such as flickering torches), but generally not large changes such as toggling a light on and off. + [b]Note:[/b] The light is not baked in [LightmapGI] if [member editor_only] is [code]true[/code]. </constant> <constant name="BAKE_DYNAMIC" value="2" enum="BakeMode"> Light is taken into account in dynamic baking ([VoxelGI] and SDFGI ([member Environment.sdfgi_enabled]) only). The light can be moved around or modified with global illumination updating in real-time. The light's global illumination appearance will be slightly different compared to [constant BAKE_STATIC]. This has a greater performance cost compared to [constant BAKE_STATIC]. When using SDFGI, the update speed of dynamic lights is affected by [member ProjectSettings.rendering/global_illumination/sdfgi/frames_to_update_lights]. diff --git a/doc/classes/LightOccluder2D.xml b/doc/classes/LightOccluder2D.xml index 533e87bce9..e42ecd1c49 100644 --- a/doc/classes/LightOccluder2D.xml +++ b/doc/classes/LightOccluder2D.xml @@ -17,6 +17,7 @@ The LightOccluder2D's occluder light mask. The LightOccluder2D will cast shadows only from Light2D(s) that have the same light mask(s). </member> <member name="sdf_collision" type="bool" setter="set_as_sdf_collision" getter="is_set_as_sdf_collision" default="true"> + If enabled, the occluder will be part of a real-time generated signed distance field that can be used in custom shaders. </member> </members> </class> diff --git a/doc/classes/LightmapGI.xml b/doc/classes/LightmapGI.xml index e111251336..ec75d85898 100644 --- a/doc/classes/LightmapGI.xml +++ b/doc/classes/LightmapGI.xml @@ -32,7 +32,7 @@ The strength of denoising step applied to the generated lightmaps. Only effective if [member use_denoiser] is [code]true[/code] and [member ProjectSettings.rendering/lightmapping/denoising/denoiser] is set to JNLM. </member> <member name="directional" type="bool" setter="set_directional" getter="is_directional" default="false"> - If [code]true[/code], bakes lightmaps to contain directional information as spherical harmonics. This results in more realistic lighting appearance, especially with normal mapped materials and for lights that have their direct light baked ([member Light3D.light_bake_mode] set to [constant Light3D.BAKE_STATIC]). The directional information is also used to provide rough reflections for static and dynamic objects. This has a small run-time performance cost as the shader has to perform more work to interpret the direction information from the lightmap. Directional lightmaps also take longer to bake and result in larger file sizes. + If [code]true[/code], bakes lightmaps to contain directional information as spherical harmonics. This results in more realistic lighting appearance, especially with normal mapped materials and for lights that have their direct light baked ([member Light3D.light_bake_mode] set to [constant Light3D.BAKE_STATIC] and with [member Light3D.editor_only] set to [code]false[/code]). The directional information is also used to provide rough reflections for static and dynamic objects. This has a small run-time performance cost as the shader has to perform more work to interpret the direction information from the lightmap. Directional lightmaps also take longer to bake and result in larger file sizes. [b]Note:[/b] The property's name has no relationship with [DirectionalLight3D]. [member directional] works with all light types. </member> <member name="environment_custom_color" type="Color" setter="set_environment_custom_color" getter="get_environment_custom_color"> diff --git a/doc/classes/RenderingDevice.xml b/doc/classes/RenderingDevice.xml index b35eb89d19..20faa70226 100644 --- a/doc/classes/RenderingDevice.xml +++ b/doc/classes/RenderingDevice.xml @@ -706,7 +706,7 @@ <param index="5" name="layer_count" type="int" /> <param index="6" name="post_barrier" type="int" enum="RenderingDevice.BarrierMask" is_bitfield="true" default="32767" /> <description> - Clears the specified [param texture] by replacing all of its pixels with the specified [param color]. [param base_mipmap] and [param mipmap_count] determine which mipmaps of the texture are affected by this clear operation, while [param base_layer] and [param layer_count] determine which layers of a 3D texture (or texture array) are affected by this clear operation. For 2D textures (which only have one layer by design), [param base_layer] and [param layer_count] must both be [code]0[/code]. + Clears the specified [param texture] by replacing all of its pixels with the specified [param color]. [param base_mipmap] and [param mipmap_count] determine which mipmaps of the texture are affected by this clear operation, while [param base_layer] and [param layer_count] determine which layers of a 3D texture (or texture array) are affected by this clear operation. For 2D textures (which only have one layer by design), [param base_layer] must be [code]0[/code] and [param layer_count] must be [code]1[/code]. [b]Note:[/b] [param texture] can't be cleared while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to [constant FINAL_ACTION_CONTINUE]) to clear this texture. </description> </method> diff --git a/drivers/gles3/environment/gi.cpp b/drivers/gles3/environment/gi.cpp index 8beee25c64..6b33e0aa22 100644 --- a/drivers/gles3/environment/gi.cpp +++ b/drivers/gles3/environment/gi.cpp @@ -137,4 +137,7 @@ uint32_t GI::voxel_gi_get_version(RID p_voxel_gi) const { return 0; } +void GI::sdfgi_reset() { +} + #endif // GLES3_ENABLED diff --git a/drivers/gles3/environment/gi.h b/drivers/gles3/environment/gi.h index 41958e43e6..3eaa687f4f 100644 --- a/drivers/gles3/environment/gi.h +++ b/drivers/gles3/environment/gi.h @@ -85,6 +85,8 @@ public: virtual bool voxel_gi_is_using_two_bounces(RID p_voxel_gi) const override; virtual uint32_t voxel_gi_get_version(RID p_voxel_gi) const override; + + virtual void sdfgi_reset() override; }; }; // namespace GLES3 diff --git a/drivers/gles3/storage/mesh_storage.cpp b/drivers/gles3/storage/mesh_storage.cpp index eca0423a35..3213fa3775 100644 --- a/drivers/gles3/storage/mesh_storage.cpp +++ b/drivers/gles3/storage/mesh_storage.cpp @@ -202,12 +202,10 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) if (surface_version != uint64_t(RS::ARRAY_FLAG_FORMAT_CURRENT_VERSION)) { RS::get_singleton()->fix_surface_compatibility(new_surface); surface_version = new_surface.format & (uint64_t(RS::ARRAY_FLAG_FORMAT_VERSION_MASK) << RS::ARRAY_FLAG_FORMAT_VERSION_SHIFT); - ERR_FAIL_COND_MSG(surface_version != uint64_t(RS::ARRAY_FLAG_FORMAT_CURRENT_VERSION), - "Surface version provided (" + - itos((surface_version >> RS::ARRAY_FLAG_FORMAT_VERSION_SHIFT) & RS::ARRAY_FLAG_FORMAT_VERSION_MASK) + - ") does not match current version (" + - itos((uint64_t(RS::ARRAY_FLAG_FORMAT_CURRENT_VERSION) >> RS::ARRAY_FLAG_FORMAT_VERSION_SHIFT) & RS::ARRAY_FLAG_FORMAT_VERSION_MASK) + - ")"); + ERR_FAIL_COND_MSG(surface_version != RS::ARRAY_FLAG_FORMAT_CURRENT_VERSION, + vformat("Surface version provided (%d) does not match current version (%d).", + (surface_version >> RS::ARRAY_FLAG_FORMAT_VERSION_SHIFT) & RS::ARRAY_FLAG_FORMAT_VERSION_MASK, + (RS::ARRAY_FLAG_FORMAT_CURRENT_VERSION >> RS::ARRAY_FLAG_FORMAT_VERSION_SHIFT) & RS::ARRAY_FLAG_FORMAT_VERSION_MASK)); } #endif diff --git a/drivers/gles3/storage/texture_storage.cpp b/drivers/gles3/storage/texture_storage.cpp index 4d7e08c849..b7b62d78a0 100644 --- a/drivers/gles3/storage/texture_storage.cpp +++ b/drivers/gles3/storage/texture_storage.cpp @@ -2314,7 +2314,9 @@ Rect2i TextureStorage::_render_target_get_sdf_rect(const RenderTarget *rt) const scale = 200; } break; default: { - } + ERR_PRINT("Invalid viewport SDF oversize, defaulting to 100%."); + scale = 100; + } break; } margin = (rt->size * scale / 100) - rt->size; @@ -2391,6 +2393,7 @@ void TextureStorage::_render_target_allocate_sdf(RenderTarget *rt) { scale = 25; } break; default: { + ERR_PRINT("Invalid viewport SDF scale, defaulting to 100%."); scale = 100; } break; } diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 0e025b4430..e37035f5eb 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -309,8 +309,10 @@ void CreateDialog::_configure_search_option_item(TreeItem *r_item, const String r_item->set_custom_color(0, search_options->get_theme_color(SNAME("disabled_font_color"), EditorStringName(Editor))); } - bool is_deprecated = EditorHelp::get_doc_data()->class_list[p_type].is_deprecated; - bool is_experimental = EditorHelp::get_doc_data()->class_list[p_type].is_experimental; + HashMap<String, DocData::ClassDoc>::Iterator class_doc = EditorHelp::get_doc_data()->class_list.find(p_type); + + bool is_deprecated = (class_doc && class_doc->value.is_deprecated); + bool is_experimental = (class_doc && class_doc->value.is_experimental); if (is_deprecated) { r_item->add_button(0, get_editor_theme_icon("StatusError"), 0, false, TTR("This class is marked as deprecated.")); @@ -330,7 +332,7 @@ void CreateDialog::_configure_search_option_item(TreeItem *r_item, const String r_item->set_collapsed(should_collapse); } - const String &description = DTR(EditorHelp::get_doc_data()->class_list[p_type].brief_description); + const String &description = DTR(class_doc ? class_doc->value.brief_description : ""); r_item->set_tooltip_text(0, description); if (p_type_category == TypeCategory::OTHER_TYPE && !script_type) { diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index d6eadf3ab4..0ab6e20b01 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -2360,36 +2360,38 @@ void EditorHelp::_add_text(const String &p_bbcode) { _add_text_to_rt(p_bbcode, class_desc, this, edited_class); } -Thread EditorHelp::thread; +String EditorHelp::doc_version_hash; +bool EditorHelp::doc_gen_first_attempt = true; +bool EditorHelp::doc_gen_use_threads = true; +Thread EditorHelp::gen_thread; void EditorHelp::_wait_for_thread() { - if (thread.is_started()) { - thread.wait_to_finish(); + if (gen_thread.is_started()) { + gen_thread.wait_to_finish(); } } -String EditorHelp::get_cache_full_path() { - return EditorPaths::get_singleton()->get_cache_dir().path_join("editor_doc_cache.res"); +void EditorHelp::_compute_doc_version_hash() { + uint32_t version_hash = Engine::get_singleton()->get_version_info().hash(); + doc_version_hash = vformat("%d/%d/%d/%s", version_hash, ClassDB::get_api_hash(ClassDB::API_CORE), ClassDB::get_api_hash(ClassDB::API_EDITOR), _doc_data_hash); } -static bool first_attempt = true; - -static String _compute_doc_version_hash() { - uint32_t version_hash = Engine::get_singleton()->get_version_info().hash(); - return vformat("%d/%d/%d/%s", version_hash, ClassDB::get_api_hash(ClassDB::API_CORE), ClassDB::get_api_hash(ClassDB::API_EDITOR), _doc_data_hash); +String EditorHelp::get_cache_full_path() { + return EditorPaths::get_singleton()->get_cache_dir().path_join("editor_doc_cache.res"); } void EditorHelp::_load_doc_thread(void *p_udata) { - DEV_ASSERT(first_attempt); + DEV_ASSERT(doc_gen_first_attempt); + Ref<Resource> cache_res = ResourceLoader::load(get_cache_full_path()); - if (cache_res.is_valid() && cache_res->get_meta("version_hash", "") == _compute_doc_version_hash()) { + if (cache_res.is_valid() && cache_res->get_meta("version_hash", "") == doc_version_hash) { Array classes = cache_res->get_meta("classes", Array()); for (int i = 0; i < classes.size(); i++) { doc->add_doc(DocData::ClassDoc::from_dict(classes[i])); } } else { // We have to go back to the main thread to start from scratch. - first_attempt = false; + doc_gen_first_attempt = false; callable_mp_static(&EditorHelp::generate_doc).bind(true).call_deferred(); } } @@ -2401,7 +2403,7 @@ void EditorHelp::_gen_doc_thread(void *p_udata) { Ref<Resource> cache_res; cache_res.instantiate(); - cache_res->set_meta("version_hash", _compute_doc_version_hash()); + cache_res->set_meta("version_hash", doc_version_hash); Array classes; for (const KeyValue<String, DocData::ClassDoc> &E : doc->class_list) { classes.push_back(DocData::ClassDoc::to_dict(E.value)); @@ -2413,8 +2415,6 @@ void EditorHelp::_gen_doc_thread(void *p_udata) { } } -static bool doc_gen_use_threads = true; - void EditorHelp::generate_doc(bool p_use_cache) { OS::get_singleton()->benchmark_begin_measure("EditorHelp::generate_doc"); if (doc_gen_use_threads) { @@ -2422,15 +2422,19 @@ void EditorHelp::generate_doc(bool p_use_cache) { _wait_for_thread(); } - DEV_ASSERT(first_attempt == (doc == nullptr)); + DEV_ASSERT(doc_gen_first_attempt == (doc == nullptr)); if (!doc) { doc = memnew(DocTools); } - if (p_use_cache && first_attempt && FileAccess::exists(get_cache_full_path())) { + if (doc_version_hash.is_empty()) { + _compute_doc_version_hash(); + } + + if (p_use_cache && doc_gen_first_attempt && FileAccess::exists(get_cache_full_path())) { if (doc_gen_use_threads) { - thread.start(_load_doc_thread, nullptr); + gen_thread.start(_load_doc_thread, nullptr); } else { _load_doc_thread(nullptr); } @@ -2441,7 +2445,7 @@ void EditorHelp::generate_doc(bool p_use_cache) { doc->generate(true); if (doc_gen_use_threads) { - thread.start(_gen_doc_thread, nullptr); + gen_thread.start(_gen_doc_thread, nullptr); } else { _gen_doc_thread(nullptr); } diff --git a/editor/editor_help.h b/editor/editor_help.h index 0ca3942e0b..1f813f930c 100644 --- a/editor/editor_help.h +++ b/editor/editor_help.h @@ -187,12 +187,15 @@ class EditorHelp : public VBoxContainer { String _fix_constant(const String &p_constant) const; void _toggle_scripts_pressed(); - static Thread thread; + static String doc_version_hash; + static bool doc_gen_first_attempt; + static bool doc_gen_use_threads; + static Thread gen_thread; static void _wait_for_thread(); static void _load_doc_thread(void *p_udata); static void _gen_doc_thread(void *p_udata); - static void _generate_doc_first_step(); + static void _compute_doc_version_hash(); protected: virtual void _update_theme_item_cache() override; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index ffad8d7a43..8c3637663d 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -68,6 +68,7 @@ #include "servers/display_server.h" #include "servers/navigation_server_3d.h" #include "servers/physics_server_2d.h" +#include "servers/rendering_server.h" #include "editor/audio_stream_preview.h" #include "editor/debugger/editor_debugger_node.h" @@ -576,6 +577,10 @@ void EditorNode::update_preview_themes(int p_mode) { void EditorNode::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_POSTINITIALIZE: { + EditorHelp::generate_doc(); + } break; + case NOTIFICATION_PROCESS: { if (opening_prev && !confirmation->is_visible()) { opening_prev = false; @@ -3573,6 +3578,9 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) { ScriptEditor::get_singleton()->set_scene_root_script(editor_data.get_scene_root_script(editor_data.get_edited_scene())); editor_data.notify_edited_scene_changed(); emit_signal(SNAME("scene_changed")); + + // Reset SDFGI after everything else so that any last-second scene modifications will be processed. + RenderingServer::get_singleton()->sdfgi_reset(); } bool EditorNode::is_changing_scene() const { @@ -6761,7 +6769,6 @@ EditorNode::EditorNode() { DisplayServer::get_singleton()->cursor_set_custom_image(Ref<Resource>()); } - EditorHelp::generate_doc(); SceneState::set_disable_placeholders(true); ResourceLoader::clear_translation_remaps(); // Using no remaps if in editor. ResourceLoader::clear_path_remaps(); diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index eec3d30bc9..646831ca24 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -226,11 +226,6 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_ bool generate_tangents = p_generate_tangents; Vector3 scale_mesh = p_scale_mesh; Vector3 offset_mesh = p_offset_mesh; - uint64_t mesh_flags = RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES; - - if (p_disable_compression) { - mesh_flags = 0; - } Vector<Vector3> vertices; Vector<Vector3> normals; @@ -374,6 +369,11 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_ } } } else if (/*l.begins_with("g ") ||*/ l.begins_with("usemtl ") || (l.begins_with("o ") || f->eof_reached())) { //commit group to mesh + uint64_t mesh_flags = RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES; + + if (p_disable_compression) { + mesh_flags = 0; + } //groups are too annoying if (surf_tool->get_vertex_array().size()) { //another group going on, commit it @@ -385,7 +385,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_ surf_tool->generate_tangents(); } else { // We need tangents in order to compress vertex data. So disable if tangents aren't generated. - mesh_flags &= ~RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES; + mesh_flags = 0; } surf_tool->index(); diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 33c2b0e238..f9c989dc20 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -2371,7 +2371,7 @@ Node *ResourceImporterScene::pre_import(const String &p_source_file, const HashM Error err = OK; HashMap<StringName, Variant> options_dupe = p_options; - Node *scene = importer->import_scene(p_source_file, EditorSceneFormatImporter::IMPORT_ANIMATION | EditorSceneFormatImporter::IMPORT_GENERATE_TANGENT_ARRAYS, options_dupe, nullptr, &err); + Node *scene = importer->import_scene(p_source_file, EditorSceneFormatImporter::IMPORT_ANIMATION | EditorSceneFormatImporter::IMPORT_GENERATE_TANGENT_ARRAYS | EditorSceneFormatImporter::IMPORT_FORCE_DISABLE_MESH_COMPRESSION, options_dupe, nullptr, &err); if (!scene || err != OK) { return nullptr; } diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index 8c0a5b999a..87dbbd599d 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -569,5 +569,7 @@ PropertySelector::PropertySelector() { help_bit = memnew(EditorHelpBit); vbc->add_margin_child(TTR("Description:"), help_bit); + help_bit->get_rich_text()->set_fit_content(false); + help_bit->get_rich_text()->set_custom_minimum_size(Size2(help_bit->get_rich_text()->get_minimum_size().x, 135 * EDSCALE)); help_bit->connect("request_hide", callable_mp(this, &PropertySelector::_hide_requested)); } diff --git a/editor/scene_create_dialog.cpp b/editor/scene_create_dialog.cpp index d6cb36013f..60ad7e5968 100644 --- a/editor/scene_create_dialog.cpp +++ b/editor/scene_create_dialog.cpp @@ -47,7 +47,6 @@ void SceneCreateDialog::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { select_node_button->set_icon(get_editor_theme_icon(SNAME("ClassList"))); node_type_2d->set_icon(get_editor_theme_icon(SNAME("Node2D"))); @@ -55,6 +54,10 @@ void SceneCreateDialog::_notification(int p_what) { node_type_gui->set_icon(get_editor_theme_icon(SNAME("Control"))); node_type_other->add_theme_icon_override(SNAME("icon"), get_editor_theme_icon(SNAME("Node"))); } break; + + case NOTIFICATION_READY: { + select_node_dialog->select_base(); + } break; } } @@ -180,7 +183,6 @@ SceneCreateDialog::SceneCreateDialog() { select_node_dialog = memnew(CreateDialog); add_child(select_node_dialog); select_node_dialog->set_base_type("Node"); - select_node_dialog->select_base(); select_node_dialog->connect("create", callable_mp(this, &SceneCreateDialog::on_type_picked)); VBoxContainer *main_vb = memnew(VBoxContainer); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 7a96aaf59b..7968fdef55 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -29,6 +29,7 @@ /**************************************************************************/ #include "scene_tree_dock.h" +#include "node_dock.h" #include "core/config/project_settings.h" #include "core/input/input.h" @@ -680,10 +681,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { break; } - if (!_validate_no_foreign()) { - break; - } - List<Node *> selection = editor_selection->get_selected_node_list(); if (selection.size() == 0) { break; @@ -703,7 +700,15 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { Node *parent = node->get_parent(); List<Node *> owned; - node->get_owned_by(node->get_owner(), &owned); + Node *owner = node; + while (owner) { + List<Node *> cur_owned; + node->get_owned_by(owner, &cur_owned); + owner = owner->get_owner(); + for (Node *F : cur_owned) { + owned.push_back(F); + } + } HashMap<const Node *, Node *> duplimap; Node *dup = node->duplicate_from_editor(duplimap); @@ -723,9 +728,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { continue; } Node *d = duplimap[F]; - undo_redo->add_do_method(d, "set_owner", node->get_owner()); + undo_redo->add_do_method(d, "set_owner", edited_scene); } undo_redo->add_do_method(editor_selection, "add_node", dup); + undo_redo->add_do_method(dup, "set_owner", edited_scene); undo_redo->add_undo_method(parent, "remove_child", dup); undo_redo->add_do_reference(dup); @@ -1081,6 +1087,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { undo_redo->add_do_method(node, "set_scene_file_path", ""); undo_redo->add_undo_method(node, "set_scene_file_path", node->get_scene_file_path()); _node_replace_owner(node, node, root); + _node_strip_signal_inheritance(node); + NodeDock::get_singleton()->set_node(node); // Refresh. undo_redo->add_do_method(scene_tree, "update_tree"); undo_redo->add_undo_method(scene_tree, "update_tree"); undo_redo->commit_action(); @@ -1479,6 +1487,19 @@ void SceneTreeDock::_node_replace_owner(Node *p_base, Node *p_node, Node *p_root } } +void SceneTreeDock::_node_strip_signal_inheritance(Node *p_node) { + List<Object::Connection> conns; + p_node->get_all_signal_connections(&conns); + + for (Object::Connection conn : conns) { + conn.signal.disconnect(conn.callable); + conn.signal.connect(conn.callable, conn.flags & ~CONNECT_INHERITED); + } + for (int i = 0; i < p_node->get_child_count(); i++) { + _node_strip_signal_inheritance(p_node->get_child(i)); + } +} + void SceneTreeDock::_load_request(const String &p_path) { EditorNode::get_singleton()->open_request(p_path); _local_tree_selected(); diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index 3f02d2881d..be0e6e1158 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -201,6 +201,7 @@ class SceneTreeDock : public VBoxContainer { }; void _node_replace_owner(Node *p_base, Node *p_node, Node *p_root, ReplaceOwnerMode p_mode = MODE_BIDI); + void _node_strip_signal_inheritance(Node *p_node); void _load_request(const String &p_path); void _script_open_request(const Ref<Script> &p_script); void _push_item(Object *p_object); diff --git a/modules/gdscript/editor/gdscript_translation_parser_plugin.cpp b/modules/gdscript/editor/gdscript_translation_parser_plugin.cpp index becc2876f9..9128f104b8 100644 --- a/modules/gdscript/editor/gdscript_translation_parser_plugin.cpp +++ b/modules/gdscript/editor/gdscript_translation_parser_plugin.cpp @@ -40,7 +40,7 @@ void GDScriptEditorTranslationParserPlugin::get_recognized_extensions(List<Strin } Error GDScriptEditorTranslationParserPlugin::parse_file(const String &p_path, Vector<String> *r_ids, Vector<Vector<String>> *r_ids_ctx_plural) { - // Extract all translatable strings using the parsed tree from GDSriptParser. + // Extract all translatable strings using the parsed tree from GDScriptParser. // The strategy is to find all ExpressionNode and AssignmentNode from the tree and extract strings if relevant, i.e // Search strings in ExpressionNode -> CallNode -> tr(), set_text(), set_placeholder() etc. // Search strings in AssignmentNode -> text = "__", tooltip_text = "__" etc. diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h index 9067864dfe..4b46b98baa 100644 --- a/modules/gdscript/gdscript_parser.h +++ b/modules/gdscript/gdscript_parser.h @@ -178,11 +178,11 @@ public: bool operator==(const DataType &p_other) const { if (type_source == UNDETECTED || p_other.type_source == UNDETECTED) { - return true; // Can be consireded equal for parsing purposes. + return true; // Can be considered equal for parsing purposes. } if (type_source == INFERRED || p_other.type_source == INFERRED) { - return true; // Can be consireded equal for parsing purposes. + return true; // Can be considered equal for parsing purposes. } if (kind != p_other.kind) { diff --git a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs index 7b1d5c228a..1d17f3d4f5 100644 --- a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs +++ b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs @@ -1,5 +1,7 @@ using System; +using System.Linq; using Microsoft.Build.Construction; +using Microsoft.Build.Locator; namespace GodotTools.ProjectEditor { @@ -19,15 +21,18 @@ namespace GodotTools.ProjectEditor public static class ProjectUtils { - public static void MSBuildLocatorRegisterDefaults(out Version version, out string path) + public static void MSBuildLocatorRegisterLatest(out Version version, out string path) { - var instance = Microsoft.Build.Locator.MSBuildLocator.RegisterDefaults(); + var instance = MSBuildLocator.QueryVisualStudioInstances() + .OrderByDescending(x => x.Version) + .First(); + MSBuildLocator.RegisterInstance(instance); version = instance.Version; path = instance.MSBuildPath; } public static void MSBuildLocatorRegisterMSBuildPath(string msbuildPath) - => Microsoft.Build.Locator.MSBuildLocator.RegisterMSBuildPath(msbuildPath); + => MSBuildLocator.RegisterMSBuildPath(msbuildPath); public static MSBuildProject Open(string path) { diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs index a00c812c79..413f6f0029 100644 --- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs +++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs @@ -456,7 +456,7 @@ namespace GodotTools var dotNetSdkSearchVersion = Environment.Version; // First we try to find the .NET Sdk ourselves to make sure we get the - // correct version first (`RegisterDefaults` always picks the latest). + // correct version first, otherwise pick the latest. if (DotNetFinder.TryFindDotNetSdk(dotNetSdkSearchVersion, out var sdkVersion, out string sdkPath)) { if (Godot.OS.IsStdOutVerbose()) @@ -468,7 +468,7 @@ namespace GodotTools { try { - ProjectUtils.MSBuildLocatorRegisterDefaults(out sdkVersion, out sdkPath); + ProjectUtils.MSBuildLocatorRegisterLatest(out sdkVersion, out sdkPath); if (Godot.OS.IsStdOutVerbose()) Console.WriteLine($"Found .NET Sdk version '{sdkVersion}': {sdkPath}"); } diff --git a/modules/openxr/SCsub b/modules/openxr/SCsub index 2ccfe46062..73a3723ea4 100644 --- a/modules/openxr/SCsub +++ b/modules/openxr/SCsub @@ -71,7 +71,6 @@ if env["builtin_openxr"]: # Build the engine using object files khrloader_obj = [] env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/xr_generated_dispatch_table.c") - env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/xr_generated_dispatch_table_core.c") env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/common/filesystem_utils.cpp") env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/common/object_info.cpp") diff --git a/platform/android/display_server_android.cpp b/platform/android/display_server_android.cpp index 445a6ea6ea..dd5ab46bd7 100644 --- a/platform/android/display_server_android.cpp +++ b/platform/android/display_server_android.cpp @@ -310,9 +310,9 @@ void DisplayServerAndroid::window_set_drop_files_callback(const Callable &p_call void DisplayServerAndroid::_window_callback(const Callable &p_callable, const Variant &p_arg, bool p_deferred) const { if (!p_callable.is_null()) { if (p_deferred) { - p_callable.call(p_arg); - } else { p_callable.call_deferred(p_arg); + } else { + p_callable.call(p_arg); } } } diff --git a/platform/web/detect.py b/platform/web/detect.py index 887a9e14b9..b0044a80ff 100644 --- a/platform/web/detect.py +++ b/platform/web/detect.py @@ -44,7 +44,7 @@ def get_opts(): BoolVariable( "proxy_to_pthread", "Use Emscripten PROXY_TO_PTHREAD option to run the main application code to a separate thread", - True, + False, ), ] diff --git a/scene/3d/lightmap_gi.cpp b/scene/3d/lightmap_gi.cpp index fe1b10a31f..5175363538 100644 --- a/scene/3d/lightmap_gi.cpp +++ b/scene/3d/lightmap_gi.cpp @@ -995,6 +995,12 @@ LightmapGI::BakeError LightmapGI::bake(Node *p_from_node, String p_image_data_pa } for (int i = 0; i < lights_found.size(); i++) { Light3D *light = lights_found[i].light; + if (light->is_editor_only()) { + // Don't include editor-only lights in the lightmap bake, + // as this results in inconsistent visuals when running the project. + continue; + } + Transform3D xf = lights_found[i].xform; // For the lightmapper, the indirect energy represents the multiplier for the indirect bounces caused by the light, so the value is not converted when using physical units. @@ -1008,7 +1014,9 @@ LightmapGI::BakeError LightmapGI::bake(Node *p_from_node, String p_image_data_pa if (Object::cast_to<DirectionalLight3D>(light)) { DirectionalLight3D *l = Object::cast_to<DirectionalLight3D>(light); - lightmapper->add_directional_light(light->get_bake_mode() == Light3D::BAKE_STATIC, -xf.basis.get_column(Vector3::AXIS_Z).normalized(), linear_color, energy, indirect_energy, l->get_param(Light3D::PARAM_SIZE), l->get_param(Light3D::PARAM_SHADOW_BLUR)); + if (l->get_sky_mode() != DirectionalLight3D::SKY_MODE_SKY_ONLY) { + lightmapper->add_directional_light(light->get_bake_mode() == Light3D::BAKE_STATIC, -xf.basis.get_column(Vector3::AXIS_Z).normalized(), linear_color, energy, indirect_energy, l->get_param(Light3D::PARAM_SIZE), l->get_param(Light3D::PARAM_SHADOW_BLUR)); + } } else if (Object::cast_to<OmniLight3D>(light)) { OmniLight3D *l = Object::cast_to<OmniLight3D>(light); if (use_physical_light_units) { diff --git a/scene/gui/color_mode.h b/scene/gui/color_mode.h index bbbf3fbaac..84e9d4542d 100644 --- a/scene/gui/color_mode.h +++ b/scene/gui/color_mode.h @@ -43,6 +43,7 @@ public: virtual int get_slider_count() const { return 3; }; virtual float get_slider_step() const = 0; + virtual float get_spinbox_arrow_step() const { return get_slider_step(); }; virtual String get_slider_label(int idx) const = 0; virtual float get_slider_max(int idx) const = 0; virtual float get_slider_value(int idx) const = 0; @@ -109,7 +110,8 @@ public: virtual String get_name() const override { return "RAW"; } - virtual float get_slider_step() const override { return 0.01; } + virtual float get_slider_step() const override { return 0.001; } + virtual float get_spinbox_arrow_step() const override { return 0.01; } virtual String get_slider_label(int idx) const override; virtual float get_slider_max(int idx) const override; virtual float get_slider_value(int idx) const override; diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 761298c51c..669ce11e5d 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -575,9 +575,11 @@ void ColorPicker::_update_color(bool p_update_sliders) { if (p_update_sliders) { float step = modes[current_mode]->get_slider_step(); + float spinbox_arrow_step = modes[current_mode]->get_spinbox_arrow_step(); for (int i = 0; i < current_slider_count; i++) { sliders[i]->set_max(modes[current_mode]->get_slider_max(i)); sliders[i]->set_step(step); + values[i]->set_custom_arrow_step(spinbox_arrow_step); sliders[i]->set_value(modes[current_mode]->get_slider_value(i)); } alpha_slider->set_max(modes[current_mode]->get_slider_max(current_slider_count)); diff --git a/scene/resources/image_texture.cpp b/scene/resources/image_texture.cpp index ecf70d96ac..337d10f75c 100644 --- a/scene/resources/image_texture.cpp +++ b/scene/resources/image_texture.cpp @@ -462,9 +462,58 @@ void ImageTexture3D::set_path(const String &p_path, bool p_take_over) { Resource::set_path(p_path, p_take_over); } +TypedArray<Image> ImageTexture3D::_get_images() const { + TypedArray<Image> images; + if (texture.is_valid()) { + Vector<Ref<Image>> raw_images = get_data(); + ERR_FAIL_COND_V(raw_images.is_empty(), TypedArray<Image>()); + + for (int i = 0; i < raw_images.size(); i++) { + images.push_back(raw_images[i]); + } + } + return images; +} + +void ImageTexture3D::_set_images(const TypedArray<Image> &p_images) { + int new_layers = p_images.size(); + ERR_FAIL_COND(new_layers == 0); + Ref<Image> img_base = p_images[0]; + ERR_FAIL_COND(img_base.is_null()); + + Image::Format new_format = img_base->get_format(); + int new_width = img_base->get_width(); + int new_height = img_base->get_height(); + int new_depth = 0; + bool new_mipmaps = false; + + for (int i = 1; i < p_images.size(); i++) { + Ref<Image> img = p_images[i]; + ERR_FAIL_COND(img.is_null()); + ERR_FAIL_COND_MSG(img->get_format() != new_format, "All images must share the same format."); + + if (img->get_width() != new_width || img->get_height() != new_height) { + new_mipmaps = true; + if (new_depth == 0) { + new_depth = i; + } + } + } + + if (new_depth == 0) { + new_depth = p_images.size(); + } + + Error err = _create(new_format, new_width, new_height, new_depth, new_mipmaps, p_images); + ERR_FAIL_COND(err != OK); +} + void ImageTexture3D::_bind_methods() { ClassDB::bind_method(D_METHOD("create", "format", "width", "height", "depth", "use_mipmaps", "data"), &ImageTexture3D::_create); ClassDB::bind_method(D_METHOD("update", "data"), &ImageTexture3D::_update); + ClassDB::bind_method(D_METHOD("_get_images"), &ImageTexture3D::_get_images); + ClassDB::bind_method(D_METHOD("_set_images", "images"), &ImageTexture3D::_set_images); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "_images", PROPERTY_HINT_ARRAY_TYPE, "Image", PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT), "_set_images", "_get_images"); } ImageTexture3D::ImageTexture3D() { diff --git a/scene/resources/image_texture.h b/scene/resources/image_texture.h index 9d9c296a45..3b756fb593 100644 --- a/scene/resources/image_texture.h +++ b/scene/resources/image_texture.h @@ -137,6 +137,9 @@ class ImageTexture3D : public Texture3D { int depth = 1; bool mipmaps = false; + TypedArray<Image> _get_images() const; + void _set_images(const TypedArray<Image> &p_images); + protected: static void _bind_methods(); diff --git a/scene/resources/importer_mesh.cpp b/scene/resources/importer_mesh.cpp index c7ee277a1b..1f4171c072 100644 --- a/scene/resources/importer_mesh.cpp +++ b/scene/resources/importer_mesh.cpp @@ -868,7 +868,7 @@ void ImporterMesh::_set_data(const Dictionary &p_data) { if (s.has("material")) { material = s["material"]; } - uint32_t flags = 0; + uint64_t flags = 0; if (s.has("flags")) { flags = s["flags"]; } @@ -909,9 +909,7 @@ Dictionary ImporterMesh::_get_data() const { d["name"] = surfaces[i].name; } - if (surfaces[i].flags != 0) { - d["flags"] = surfaces[i].flags; - } + d["flags"] = surfaces[i].flags; surface_arr.push_back(d); } diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 461dbbec2f..6997777623 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -1059,20 +1059,33 @@ void BaseMaterial3D::_update_shader() { } if (flags[FLAG_UV1_USE_TRIPLANAR] || flags[FLAG_UV2_USE_TRIPLANAR]) { //generate tangent and binormal in world space - code += " TANGENT = vec3(0.0,0.0,-1.0) * abs(NORMAL.x);\n"; - code += " TANGENT+= vec3(1.0,0.0,0.0) * abs(NORMAL.y);\n"; - code += " TANGENT+= vec3(1.0,0.0,0.0) * abs(NORMAL.z);\n"; - code += " TANGENT = normalize(TANGENT);\n"; + if (flags[FLAG_UV1_USE_WORLD_TRIPLANAR]) { + code += " vec3 normal = MODEL_NORMAL_MATRIX * NORMAL;\n"; + } else { + code += " vec3 normal = NORMAL;\n"; + } + code += " TANGENT = vec3(0.0,0.0,-1.0) * abs(normal.x);\n"; + code += " TANGENT+= vec3(1.0,0.0,0.0) * abs(normal.y);\n"; + code += " TANGENT+= vec3(1.0,0.0,0.0) * abs(normal.z);\n"; + if (flags[FLAG_UV1_USE_WORLD_TRIPLANAR]) { + code += " TANGENT = inverse(MODEL_NORMAL_MATRIX) * normalize(TANGENT);\n"; + } else { + code += " TANGENT = normalize(TANGENT);\n"; + } - code += " BINORMAL = vec3(0.0,1.0,0.0) * abs(NORMAL.x);\n"; - code += " BINORMAL+= vec3(0.0,0.0,-1.0) * abs(NORMAL.y);\n"; - code += " BINORMAL+= vec3(0.0,1.0,0.0) * abs(NORMAL.z);\n"; - code += " BINORMAL = normalize(BINORMAL);\n"; + code += " BINORMAL = vec3(0.0,1.0,0.0) * abs(normal.x);\n"; + code += " BINORMAL+= vec3(0.0,0.0,-1.0) * abs(normal.y);\n"; + code += " BINORMAL+= vec3(0.0,1.0,0.0) * abs(normal.z);\n"; + if (flags[FLAG_UV1_USE_WORLD_TRIPLANAR]) { + code += " BINORMAL = inverse(MODEL_NORMAL_MATRIX) * normalize(BINORMAL);\n"; + } else { + code += " BINORMAL = normalize(BINORMAL);\n"; + } } if (flags[FLAG_UV1_USE_TRIPLANAR]) { if (flags[FLAG_UV1_USE_WORLD_TRIPLANAR]) { - code += " uv1_power_normal=pow(abs(mat3(MODEL_MATRIX) * NORMAL),vec3(uv1_blend_sharpness));\n"; + code += " uv1_power_normal=pow(abs(normal),vec3(uv1_blend_sharpness));\n"; code += " uv1_triplanar_pos = (MODEL_MATRIX * vec4(VERTEX, 1.0f)).xyz * uv1_scale + uv1_offset;\n"; } else { code += " uv1_power_normal=pow(abs(NORMAL),vec3(uv1_blend_sharpness));\n"; diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index 2aabf14203..25a65b5cc4 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -1639,6 +1639,11 @@ void ArrayMesh::_set_surfaces(const Array &p_surfaces) { uint64_t surface_version = surface.format & (ARRAY_FLAG_FORMAT_VERSION_MASK << ARRAY_FLAG_FORMAT_VERSION_SHIFT); if (surface_version != ARRAY_FLAG_FORMAT_CURRENT_VERSION) { RS::get_singleton()->fix_surface_compatibility(surface, get_path()); + surface_version = surface.format & (RS::ARRAY_FLAG_FORMAT_VERSION_MASK << RS::ARRAY_FLAG_FORMAT_VERSION_SHIFT); + ERR_FAIL_COND_MSG(surface_version != RS::ARRAY_FLAG_FORMAT_CURRENT_VERSION, + vformat("Surface version provided (%d) does not match current version (%d).", + (surface_version >> RS::ARRAY_FLAG_FORMAT_VERSION_SHIFT) & RS::ARRAY_FLAG_FORMAT_VERSION_MASK, + (RS::ARRAY_FLAG_FORMAT_CURRENT_VERSION >> RS::ARRAY_FLAG_FORMAT_VERSION_SHIFT) & RS::ARRAY_FLAG_FORMAT_VERSION_MASK)); } #endif @@ -2008,17 +2013,19 @@ void ArrayMesh::regen_normal_maps() { return; } Vector<Ref<SurfaceTool>> surfs; + Vector<uint64_t> formats; for (int i = 0; i < get_surface_count(); i++) { Ref<SurfaceTool> st = memnew(SurfaceTool); st->create_from(Ref<ArrayMesh>(this), i); surfs.push_back(st); + formats.push_back(surface_get_format(i)); } clear_surfaces(); for (int i = 0; i < surfs.size(); i++) { surfs.write[i]->generate_tangents(); - surfs.write[i]->commit(Ref<ArrayMesh>(this)); + surfs.write[i]->commit(Ref<ArrayMesh>(this), formats[i]); } } diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index b80e258af9..2456212327 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -1028,7 +1028,7 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, HashMap<String cd.to = target_id; cd.method = _nm_get_string(base_callable.get_method(), name_map); cd.signal = _nm_get_string(c.signal.get_name(), name_map); - cd.flags = c.flags; + cd.flags = c.flags & ~CONNECT_INHERITED; // Do not store inherited. cd.unbinds = unbinds; for (int i = 0; i < binds.size(); i++) { diff --git a/scene/resources/particle_process_material.cpp b/scene/resources/particle_process_material.cpp index 0a114d6b35..9ceddbc7b1 100644 --- a/scene/resources/particle_process_material.cpp +++ b/scene/resources/particle_process_material.cpp @@ -850,6 +850,27 @@ void ParticleProcessMaterial::_update_shader() { code += " }\n"; code += " if (RESTART_VELOCITY) {\n"; code += " VELOCITY = get_random_direction_from_spread(alt_seed, spread) * dynamic_params.initial_velocity_multiplier;\n"; + if (emission_shape == EMISSION_SHAPE_DIRECTED_POINTS) { + code += " int point = min(emission_texture_point_count - 1, int(rand_from_seed(alt_seed) * float(emission_texture_point_count)));\n"; + code += " ivec2 emission_tex_size = textureSize(emission_texture_points, 0);\n"; + code += " ivec2 emission_tex_ofs = ivec2(point % emission_tex_size.x, point / emission_tex_size.x);\n"; + if (particle_flags[PARTICLE_FLAG_DISABLE_Z]) { + code += " {\n"; + code += " mat2 rotm;"; + code += " rotm[0] = texelFetch(emission_texture_normal, emission_tex_ofs, 0).xy;\n"; + code += " rotm[1] = rotm[0].yx * vec2(1.0, -1.0);\n"; + code += " VELOCITY.xy = rotm * VELOCITY.xy;\n"; + code += " }\n"; + } else { + code += " {\n"; + code += " vec3 normal = texelFetch(emission_texture_normal, emission_tex_ofs, 0).xyz;\n"; + code += " vec3 v0 = abs(normal.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(0.0, 1.0, 0.0);\n"; + code += " vec3 tangent = normalize(cross(v0, normal));\n"; + code += " vec3 bitangent = normalize(cross(tangent, normal));\n"; + code += " VELOCITY = mat3(tangent, bitangent, normal) * VELOCITY;\n"; + code += " }\n"; + } + } code += " }\n"; code += " process_display_param(params, 0.);\n"; code += "// process_dynamic_parameters(dynamic_params, 0., alt_seed, TRANSFORM, EMISSION_TRANSFORM, DELTA);\n"; @@ -939,7 +960,9 @@ void ParticleProcessMaterial::_update_shader() { code += " if (physics_params.damping > 0.0) {\n"; if (!particle_flags[PARTICLE_FLAG_DAMPING_AS_FRICTION]) { code += " float v = length(VELOCITY);\n"; - code += " v -= physics_params.damping * DELTA;\n"; + code += " // Realistic friction formula. We assume the mass of a particle to be 0.05kg.\n"; + code += " float damp = v * v * physics_params.damping * 0.05 * DELTA;\n"; + code += " v -= damp;\n"; code += " if (v < 0.0) {\n"; code += " VELOCITY = vec3(0.0);\n"; code += " } else {\n"; @@ -984,12 +1007,16 @@ void ParticleProcessMaterial::_update_shader() { } code += " \n"; code += " vec3 noise_direction = get_noise_direction(TRANSFORM[3].xyz);\n"; - code += " if (!COLLIDED) {\n"; - code += " \n"; - code += " float vel_mag = length(final_velocity);\n"; - code += " float vel_infl = clamp(dynamic_params.turb_influence * turbulence_influence, 0.0,1.0);\n"; - code += " final_velocity = mix(final_velocity, normalize(noise_direction) * vel_mag * (1.0 + (1.0 - vel_infl) * 0.2), vel_infl);\n"; - code += " }\n"; + // The following snippet causes massive performance hit. We don't need it as long as collision is disabled. + // Refer to GH-83744 for more info. + if (collision_mode != COLLISION_DISABLED) { + code += " if (!COLLIDED) {\n"; + code += " \n"; + code += " float vel_mag = length(final_velocity);\n"; + code += " float vel_infl = clamp(dynamic_params.turb_influence * turbulence_influence, 0.0,1.0);\n"; + code += " final_velocity = mix(final_velocity, normalize(noise_direction) * vel_mag * (1.0 + (1.0 - vel_infl) * 0.2), vel_infl);\n"; + code += " }\n"; + } } code += " \n"; code += " // limit velocity\n"; diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp index 121d29b728..7b4080517f 100644 --- a/scene/resources/tile_set.cpp +++ b/scene/resources/tile_set.cpp @@ -4787,15 +4787,17 @@ Ref<ImageTexture> TileSetAtlasSource::_create_padded_image_texture(const Ref<Tex image->blit_rect(*src_image, src_rect, base_pos); + // Sides image->blit_rect(*src_image, top_src_rect, base_pos + Vector2i(0, -1)); image->blit_rect(*src_image, bottom_src_rect, base_pos + Vector2i(0, src_rect.size.y)); image->blit_rect(*src_image, left_src_rect, base_pos + Vector2i(-1, 0)); image->blit_rect(*src_image, right_src_rect, base_pos + Vector2i(src_rect.size.x, 0)); - image->set_pixelv(base_pos + Vector2i(-1, -1), src_image->get_pixelv(src_rect.position)); - image->set_pixelv(base_pos + Vector2i(src_rect.size.x, -1), src_image->get_pixelv(src_rect.position + Vector2i(src_rect.size.x - 1, 0))); - image->set_pixelv(base_pos + Vector2i(-1, src_rect.size.y), src_image->get_pixelv(src_rect.position + Vector2i(0, src_rect.size.y - 1))); - image->set_pixelv(base_pos + Vector2i(src_rect.size.x, src_rect.size.y), src_image->get_pixelv(src_rect.position + Vector2i(src_rect.size.x - 1, src_rect.size.y - 1))); + // Corners + image->blit_rect(*src_image, Rect2i(src_rect.position, Vector2i(1, 1)), base_pos + Vector2i(-1, -1)); + image->blit_rect(*src_image, Rect2i(src_rect.position + Vector2i(src_rect.size.x - 1, 0), Vector2i(1, 1)), base_pos + Vector2i(src_rect.size.x, -1)); + image->blit_rect(*src_image, Rect2i(src_rect.position + Vector2i(0, src_rect.size.y - 1), Vector2i(1, 1)), base_pos + Vector2i(-1, src_rect.size.y)); + image->blit_rect(*src_image, Rect2i(src_rect.position + Vector2i(src_rect.size.x - 1, src_rect.size.y - 1), Vector2i(1, 1)), base_pos + Vector2i(src_rect.size.x, src_rect.size.y)); } } @@ -4831,31 +4833,20 @@ void TileSetAtlasSource::_update_padded_texture() { Ref<Texture2D> src = src_canvas_texture->get_diffuse_texture(); Ref<ImageTexture> image_texture; if (src.is_valid()) { - image_texture = _create_padded_image_texture(src); - } else { - image_texture.instantiate(); + padded_texture->set_diffuse_texture(_create_padded_image_texture(src)); } - padded_texture->set_diffuse_texture(image_texture); // Normal src = src_canvas_texture->get_normal_texture(); - image_texture.instantiate(); if (src.is_valid()) { - image_texture = _create_padded_image_texture(src); - } else { - image_texture.instantiate(); + padded_texture->set_normal_texture(_create_padded_image_texture(src)); } - padded_texture->set_normal_texture(image_texture); // Specular src = src_canvas_texture->get_specular_texture(); - image_texture.instantiate(); if (src.is_valid()) { - image_texture = _create_padded_image_texture(src); - } else { - image_texture.instantiate(); + padded_texture->set_specular_texture(_create_padded_image_texture(src)); } - padded_texture->set_specular_texture(image_texture); // Other properties. padded_texture->set_specular_color(src_canvas_texture->get_specular_color()); diff --git a/servers/rendering/dummy/environment/gi.h b/servers/rendering/dummy/environment/gi.h index a26938c740..5d0e84ae43 100644 --- a/servers/rendering/dummy/environment/gi.h +++ b/servers/rendering/dummy/environment/gi.h @@ -78,6 +78,8 @@ public: virtual bool voxel_gi_is_using_two_bounces(RID p_voxel_gi) const override { return false; } virtual uint32_t voxel_gi_get_version(RID p_voxel_gi) const override { return 0; } + + virtual void sdfgi_reset() override {} }; } // namespace RendererDummy diff --git a/servers/rendering/environment/renderer_gi.h b/servers/rendering/environment/renderer_gi.h index 6eff319882..94e2c1afda 100644 --- a/servers/rendering/environment/renderer_gi.h +++ b/servers/rendering/environment/renderer_gi.h @@ -79,6 +79,8 @@ public: virtual bool voxel_gi_is_using_two_bounces(RID p_voxel_gi) const = 0; virtual uint32_t voxel_gi_get_version(RID p_probe) const = 0; + + virtual void sdfgi_reset() = 0; }; #endif // RENDERER_GI_H diff --git a/servers/rendering/renderer_rd/environment/gi.cpp b/servers/rendering/renderer_rd/environment/gi.cpp index 0667ae87e5..dce8fadb63 100644 --- a/servers/rendering/renderer_rd/environment/gi.cpp +++ b/servers/rendering/renderer_rd/environment/gi.cpp @@ -392,6 +392,10 @@ Dependency *GI::voxel_gi_get_dependency(RID p_voxel_gi) const { return &voxel_gi->dependency; } +void GI::sdfgi_reset() { + sdfgi_current_version++; +} + //////////////////////////////////////////////////////////////////////////////// // SDFGI @@ -416,6 +420,7 @@ void GI::SDFGI::create(RID p_env, const Vector3 &p_world_position, uint32_t p_re y_scale_mode = RendererSceneRenderRD::get_singleton()->environment_get_sdfgi_y_scale(p_env); static const float y_scale[3] = { 2.0, 1.5, 1.0 }; y_mult = y_scale[y_scale_mode]; + version = gi->sdfgi_current_version; cascades.resize(num_cascades); probe_axis_count = SDFGI::PROBE_DIVISOR + 1; solid_cell_ratio = gi->sdfgi_solid_cell_ratio; diff --git a/servers/rendering/renderer_rd/environment/gi.h b/servers/rendering/renderer_rd/environment/gi.h index 9a45919a2f..c46d4cbd25 100644 --- a/servers/rendering/renderer_rd/environment/gi.h +++ b/servers/rendering/renderer_rd/environment/gi.h @@ -667,6 +667,7 @@ public: float y_mult = 1.0; + uint32_t version = 0; uint32_t render_pass = 0; int32_t cascade_dynamic_light_count[SDFGI::MAX_CASCADES]; //used dynamically @@ -701,11 +702,14 @@ public: Vector3 sdfgi_debug_probe_dir; bool sdfgi_debug_probe_enabled = false; Vector3i sdfgi_debug_probe_index; + uint32_t sdfgi_current_version = 0; /* SDFGI UPDATE */ int sdfgi_get_lightprobe_octahedron_size() const { return SDFGI::LIGHTPROBE_OCT_SIZE; } + virtual void sdfgi_reset() override; + struct SDFGIData { float grid_size[3]; uint32_t max_cascades; diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp index dce97808b1..768701329b 100644 --- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp +++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp @@ -3486,14 +3486,18 @@ void RenderForwardClustered::sdfgi_update(const Ref<RenderSceneBuffers> &p_rende } bool needs_sdfgi = p_environment.is_valid() && environment_get_sdfgi_enabled(p_environment); + bool needs_reset = sdfgi.is_valid() ? sdfgi->version != gi.sdfgi_current_version : false; - if (!needs_sdfgi) { + if (!needs_sdfgi || needs_reset) { if (sdfgi.is_valid()) { // delete it sdfgi.unref(); rb->set_custom_data(RB_SCOPE_SDFGI, sdfgi); } - return; + + if (!needs_sdfgi) { + return; + } } // Ensure advanced shaders are available if SDFGI is used. diff --git a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp index 9e8d654b4e..a6a32d9e86 100644 --- a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp +++ b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp @@ -264,7 +264,7 @@ RID RenderForwardMobile::RenderBufferDataForwardMobile::get_color_fbs(Framebuffe RID render_target = render_buffers->get_render_target(); ERR_FAIL_COND_V(render_target.is_null(), RID()); RID target_buffer; - if (texture_storage->render_target_get_msaa(render_target) == RS::VIEWPORT_MSAA_DISABLED) { + if (view_count > 1 || texture_storage->render_target_get_msaa(render_target) == RS::VIEWPORT_MSAA_DISABLED) { target_buffer = texture_storage->render_target_get_rd_texture(render_target); } else { target_buffer = texture_storage->render_target_get_rd_texture_msaa(render_target); diff --git a/servers/rendering/renderer_rd/pipeline_cache_rd.h b/servers/rendering/renderer_rd/pipeline_cache_rd.h index 2f1e79b397..0ebebd0540 100644 --- a/servers/rendering/renderer_rd/pipeline_cache_rd.h +++ b/servers/rendering/renderer_rd/pipeline_cache_rd.h @@ -38,7 +38,7 @@ class PipelineCacheRD { SpinLock spin_lock; RID shader; - uint32_t input_mask; + uint64_t input_mask; RD::RenderPrimitive render_primitive; RD::PipelineRasterizationState rasterization_state; diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp index d10443d6ad..1a33f1d6e0 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp @@ -365,6 +365,8 @@ void RendererSceneRenderRD::_render_buffers_post_process_and_tonemap(const Rende RID color_texture = use_upscaled_texture ? rb->get_upscaled_texture() : rb->get_internal_texture(); Size2i color_size = use_upscaled_texture ? target_size : rb->get_internal_size(); + bool dest_is_msaa_2d = rb->get_view_count() == 1 && texture_storage->render_target_get_msaa(render_target) != RS::VIEWPORT_MSAA_DISABLED; + if (can_use_effects && RSG::camera_attributes->camera_attributes_uses_dof(p_render_data->camera_attributes)) { RENDER_TIMESTAMP("Depth of Field"); RD::get_singleton()->draw_command_begin_label("DOF"); @@ -581,7 +583,12 @@ void RendererSceneRenderRD::_render_buffers_post_process_and_tonemap(const Rende // If we do a bilinear upscale we just render into our render target and our shader will upscale automatically. // Target size in this case is lying as we never get our real target size communicated. // Bit nasty but... - dest_fb = texture_storage->render_target_get_rd_framebuffer(render_target); + + if (dest_is_msaa_2d) { + dest_fb = FramebufferCacheRD::get_singleton()->get_cache(texture_storage->render_target_get_rd_texture_msaa(render_target)); + } else { + dest_fb = texture_storage->render_target_get_rd_framebuffer(render_target); + } } tone_mapper->tonemapper(color_texture, dest_fb, tonemap); @@ -599,6 +606,13 @@ void RendererSceneRenderRD::_render_buffers_post_process_and_tonemap(const Rende fsr->fsr_upscale(rb, source_texture, dest_texture); } + if (dest_is_msaa_2d) { + // We can't upscale directly into our MSAA buffer so we need to do a copy + RID source_texture = texture_storage->render_target_get_rd_texture(render_target); + RID dest_fb = FramebufferCacheRD::get_singleton()->get_cache(texture_storage->render_target_get_rd_texture_msaa(render_target)); + copy_effects->copy_to_fb_rect(source_texture, dest_fb, Rect2i(Point2i(), rb->get_target_size())); + } + RD::get_singleton()->draw_command_end_label(); } diff --git a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp index 36ce1e38c6..3710ac0eed 100644 --- a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp @@ -359,11 +359,9 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) RS::get_singleton()->fix_surface_compatibility(new_surface); surface_version = new_surface.format & (RS::ARRAY_FLAG_FORMAT_VERSION_MASK << RS::ARRAY_FLAG_FORMAT_VERSION_SHIFT); ERR_FAIL_COND_MSG(surface_version != RS::ARRAY_FLAG_FORMAT_CURRENT_VERSION, - "Surface version provided (" + - itos((surface_version >> RS::ARRAY_FLAG_FORMAT_VERSION_SHIFT) & RS::ARRAY_FLAG_FORMAT_VERSION_MASK) + - ") does not match current version (" + - itos((RS::ARRAY_FLAG_FORMAT_CURRENT_VERSION >> RS::ARRAY_FLAG_FORMAT_VERSION_SHIFT) & RS::ARRAY_FLAG_FORMAT_VERSION_MASK) + - ")"); + vformat("Surface version provided (%d) does not match current version (%d).", + (surface_version >> RS::ARRAY_FLAG_FORMAT_VERSION_SHIFT) & RS::ARRAY_FLAG_FORMAT_VERSION_MASK, + (RS::ARRAY_FLAG_FORMAT_CURRENT_VERSION >> RS::ARRAY_FLAG_FORMAT_VERSION_SHIFT) & RS::ARRAY_FLAG_FORMAT_VERSION_MASK)); } #endif diff --git a/servers/rendering/renderer_rd/storage_rd/mesh_storage.h b/servers/rendering/renderer_rd/storage_rd/mesh_storage.h index f03334baac..db54816e09 100644 --- a/servers/rendering/renderer_rd/storage_rd/mesh_storage.h +++ b/servers/rendering/renderer_rd/storage_rd/mesh_storage.h @@ -469,7 +469,7 @@ public: } } - _FORCE_INLINE_ void mesh_surface_get_vertex_arrays_and_format(void *p_surface, uint32_t p_input_mask, bool p_input_motion_vectors, RID &r_vertex_array_rd, RD::VertexFormatID &r_vertex_format) { + _FORCE_INLINE_ void mesh_surface_get_vertex_arrays_and_format(void *p_surface, uint64_t p_input_mask, bool p_input_motion_vectors, RID &r_vertex_array_rd, RD::VertexFormatID &r_vertex_format) { Mesh::Surface *s = reinterpret_cast<Mesh::Surface *>(p_surface); s->version_lock.lock(); @@ -501,7 +501,7 @@ public: s->version_lock.unlock(); } - _FORCE_INLINE_ void mesh_instance_surface_get_vertex_arrays_and_format(RID p_mesh_instance, uint64_t p_surface_index, uint32_t p_input_mask, bool p_input_motion_vectors, RID &r_vertex_array_rd, RD::VertexFormatID &r_vertex_format) { + _FORCE_INLINE_ void mesh_instance_surface_get_vertex_arrays_and_format(RID p_mesh_instance, uint64_t p_surface_index, uint64_t p_input_mask, bool p_input_motion_vectors, RID &r_vertex_array_rd, RD::VertexFormatID &r_vertex_format) { MeshInstance *mi = mesh_instance_owner.get_or_null(p_mesh_instance); ERR_FAIL_NULL(mi); Mesh *mesh = mi->mesh; diff --git a/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp b/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp index 474ec897ef..678564a0e4 100644 --- a/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp @@ -3511,7 +3511,9 @@ Rect2i TextureStorage::_render_target_get_sdf_rect(const RenderTarget *rt) const scale = 200; } break; default: { - } + ERR_PRINT("Invalid viewport SDF oversize, defaulting to 100%."); + scale = 100; + } break; } margin = (rt->size * scale / 100) - rt->size; @@ -3603,6 +3605,7 @@ void TextureStorage::_render_target_allocate_sdf(RenderTarget *rt) { scale = 25; } break; default: { + ERR_PRINT("Invalid viewport SDF scale, defaulting to 100%."); scale = 100; } break; } diff --git a/servers/rendering/renderer_scene_cull.cpp b/servers/rendering/renderer_scene_cull.cpp index 1c5cbe9612..73aacf311f 100644 --- a/servers/rendering/renderer_scene_cull.cpp +++ b/servers/rendering/renderer_scene_cull.cpp @@ -2239,7 +2239,7 @@ void RendererSceneCull::_light_instance_setup_directional_shadow(int p_shadow_in // This trick here is what stabilizes the shadow (make potential jaggies to not move) // at the cost of some wasted resolution. Still, the quality increase is very well worth it. - const real_t unit = (radius + soft_shadow_expand) * 2.0 / texture_size; + const real_t unit = (radius + soft_shadow_expand) * 4.0 / texture_size; x_max_cam = Math::snapped(x_vec.dot(center) + radius + soft_shadow_expand, unit); x_min_cam = Math::snapped(x_vec.dot(center) - radius - soft_shadow_expand, unit); y_max_cam = Math::snapped(y_vec.dot(center) + radius + soft_shadow_expand, unit); diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp index 34d6a93e36..6b47c29382 100644 --- a/servers/rendering/renderer_viewport.cpp +++ b/servers/rendering/renderer_viewport.cpp @@ -116,19 +116,30 @@ void RendererViewport::_configure_3d_render_buffers(Viewport *p_viewport) { if (p_viewport->size.width == 0 || p_viewport->size.height == 0) { p_viewport->render_buffers.unref(); } else { + const float EPSILON = 0.0001; float scaling_3d_scale = p_viewport->scaling_3d_scale; RS::ViewportScaling3DMode scaling_3d_mode = p_viewport->scaling_3d_mode; + bool upscaler_available = p_viewport->fsr_enabled; + + if ((!upscaler_available || scaling_3d_mode == RS::VIEWPORT_SCALING_3D_MODE_BILINEAR || scaling_3d_mode == RS::VIEWPORT_SCALING_3D_MODE_FSR) && scaling_3d_scale >= (1.0 - EPSILON) && scaling_3d_scale <= (1.0 + EPSILON)) { + // No 3D scaling on bilinear or FSR? Ignore scaling mode, this just introduces overhead. + // - Mobile can't perform optimal path + // - FSR does an extra pass (or 2 extra passes if 2D-MSAA is enabled) + // Scaling = 1.0 on FSR2 has benefits + scaling_3d_scale = 1.0; + scaling_3d_mode = RS::VIEWPORT_SCALING_3D_MODE_OFF; + } + bool scaling_3d_is_fsr = (scaling_3d_mode == RS::VIEWPORT_SCALING_3D_MODE_FSR) || (scaling_3d_mode == RS::VIEWPORT_SCALING_3D_MODE_FSR2); bool use_taa = p_viewport->use_taa; - if (scaling_3d_is_fsr && (scaling_3d_scale > 1.0)) { + if (scaling_3d_is_fsr && (scaling_3d_scale >= (1.0 + EPSILON))) { // FSR is not designed for downsampling. // Fall back to bilinear scaling. WARN_PRINT_ONCE("FSR 3D resolution scaling is not designed for downsampling. Falling back to bilinear 3D resolution scaling."); scaling_3d_mode = RS::VIEWPORT_SCALING_3D_MODE_BILINEAR; } - bool upscaler_available = p_viewport->fsr_enabled; if (scaling_3d_is_fsr && !upscaler_available) { // FSR is not actually available. // Fall back to bilinear scaling. @@ -143,8 +154,8 @@ void RendererViewport::_configure_3d_render_buffers(Viewport *p_viewport) { use_taa = false; } - int width; - int height; + int target_width; + int target_height; int render_width; int render_height; @@ -152,40 +163,40 @@ void RendererViewport::_configure_3d_render_buffers(Viewport *p_viewport) { case RS::VIEWPORT_SCALING_3D_MODE_BILINEAR: // Clamp 3D rendering resolution to reasonable values supported on most hardware. // This prevents freezing the engine or outright crashing on lower-end GPUs. - width = CLAMP(p_viewport->size.width * scaling_3d_scale, 1, 16384); - height = CLAMP(p_viewport->size.height * scaling_3d_scale, 1, 16384); - render_width = width; - render_height = height; + target_width = p_viewport->size.width; + target_height = p_viewport->size.height; + render_width = CLAMP(target_width * scaling_3d_scale, 1, 16384); + render_height = CLAMP(target_height * scaling_3d_scale, 1, 16384); break; case RS::VIEWPORT_SCALING_3D_MODE_FSR: case RS::VIEWPORT_SCALING_3D_MODE_FSR2: - width = p_viewport->size.width; - height = p_viewport->size.height; - render_width = MAX(width * scaling_3d_scale, 1.0); // width / (width * scaling) - render_height = MAX(height * scaling_3d_scale, 1.0); + target_width = p_viewport->size.width; + target_height = p_viewport->size.height; + render_width = MAX(target_width * scaling_3d_scale, 1.0); // target_width / (target_width * scaling) + render_height = MAX(target_height * scaling_3d_scale, 1.0); break; case RS::VIEWPORT_SCALING_3D_MODE_OFF: - width = p_viewport->size.width; - height = p_viewport->size.height; - render_width = width; - render_height = height; + target_width = p_viewport->size.width; + target_height = p_viewport->size.height; + render_width = target_width; + render_height = target_height; break; default: // This is an unknown mode. WARN_PRINT_ONCE(vformat("Unknown scaling mode: %d. Disabling 3D resolution scaling.", scaling_3d_mode)); scaling_3d_mode = RS::VIEWPORT_SCALING_3D_MODE_OFF; scaling_3d_scale = 1.0; - width = p_viewport->size.width; - height = p_viewport->size.height; - render_width = width; - render_height = height; + target_width = p_viewport->size.width; + target_height = p_viewport->size.height; + render_width = target_width; + render_height = target_height; break; } uint32_t jitter_phase_count = 0; if (scaling_3d_mode == RS::VIEWPORT_SCALING_3D_MODE_FSR2) { // Implementation has been copied from ffxFsr2GetJitterPhaseCount. - jitter_phase_count = uint32_t(8.0f * pow(float(width) / render_width, 2.0f)); + jitter_phase_count = uint32_t(8.0f * pow(float(target_width) / render_width, 2.0f)); } else if (use_taa) { // Default jitter count for TAA. jitter_phase_count = 16; @@ -201,7 +212,7 @@ void RendererViewport::_configure_3d_render_buffers(Viewport *p_viewport) { RenderSceneBuffersConfiguration rb_config; rb_config.set_render_target(p_viewport->render_target); rb_config.set_internal_size(Size2i(render_width, render_height)); - rb_config.set_target_size(Size2(width, height)); + rb_config.set_target_size(Size2(target_width, target_height)); rb_config.set_view_count(p_viewport->view_count); rb_config.set_scaling_3d_mode(scaling_3d_mode); rb_config.set_msaa_3d(p_viewport->msaa_3d); @@ -259,6 +270,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { /* Camera should always be BEFORE any other 3D */ + bool can_draw_2d = !p_viewport->disable_2d && p_viewport->view_count == 1; // Stereo rendering does not support 2D, no depth data bool scenario_draw_canvas_bg = false; //draw canvas, or some layer of it, as BG for 3D instead of in front int scenario_canvas_max_layer = 0; bool force_clear_render_target = false; @@ -272,7 +284,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { if (RSG::scene->is_scenario(p_viewport->scenario)) { RID environment = RSG::scene->scenario_get_environment(p_viewport->scenario); if (RSG::scene->is_environment(environment)) { - if (!p_viewport->disable_2d && !viewport_is_environment_disabled(p_viewport)) { + if (can_draw_2d && !viewport_is_environment_disabled(p_viewport)) { scenario_draw_canvas_bg = RSG::scene->environment_get_background(environment) == RS::ENV_BG_CANVAS; scenario_canvas_max_layer = RSG::scene->environment_get_canvas_max_layer(environment); } else if (RSG::scene->environment_get_background(environment) == RS::ENV_BG_CANVAS) { @@ -307,7 +319,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { _draw_3d(p_viewport); } - if (!p_viewport->disable_2d) { + if (can_draw_2d) { RBMap<Viewport::CanvasKey, Viewport::CanvasData *> canvas_map; Rect2 clip_rect(0, 0, p_viewport->size.x, p_viewport->size.y); diff --git a/servers/rendering/rendering_server_default.h b/servers/rendering/rendering_server_default.h index 3d75ced3e3..cd5904f175 100644 --- a/servers/rendering/rendering_server_default.h +++ b/servers/rendering/rendering_server_default.h @@ -476,6 +476,8 @@ public: FUNC2(voxel_gi_set_interior, RID, bool) FUNC2(voxel_gi_set_use_two_bounces, RID, bool) + FUNC0(sdfgi_reset) + /* PARTICLES */ #undef ServerName diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index 41f2fbb03f..a2da26eb65 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -4639,6 +4639,10 @@ bool ShaderLanguage::_validate_assign(Node *p_node, const FunctionInfo &p_functi return false; } + if (shader->varyings.has(var->name)) { + return _validate_varying_assign(shader->varyings[var->name], r_message); + } + if (!(p_function_info.built_ins.has(var->name) && p_function_info.built_ins[var->name].constant)) { return true; } diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index 952d479651..cc42c5a3fb 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -323,16 +323,18 @@ RID RenderingServer::get_white_texture() { } void _get_axis_angle(const Vector3 &p_normal, const Vector4 &p_tangent, float &r_angle, Vector3 &r_axis) { - Vector3 tangent = Vector3(p_tangent.x, p_tangent.y, p_tangent.z); + Vector3 normal = p_normal.normalized(); + Vector3 tangent = Vector3(p_tangent.x, p_tangent.y, p_tangent.z).normalized(); float d = p_tangent.w; - Vector3 binormal = p_normal.cross(tangent); + Vector3 binormal = normal.cross(tangent).normalized(); + real_t angle; - r_angle = Math::acos((tangent.x + binormal.y + p_normal.z - 1.0) / 2.0); - float denom = 2.0 * Math::sin(r_angle); - r_axis.x = (p_normal.y - binormal.z) / denom; - r_axis.y = (tangent.z - p_normal.x) / denom; - r_axis.z = (binormal.x - tangent.y) / denom; - r_axis.normalize(); + Basis tbn = Basis(); + tbn.rows[0] = tangent; + tbn.rows[1] = binormal; + tbn.rows[2] = normal; + tbn.get_axis_angle(r_axis, angle); + r_angle = float(angle); if (d < 0.0) { r_angle = CLAMP((1.0 - r_angle / Math_PI) * 0.5, 0.0, 0.49999); @@ -346,13 +348,11 @@ void _get_axis_angle(const Vector3 &p_normal, const Vector4 &p_tangent, float &r void _get_tbn_from_axis_angle(const Vector3 &p_axis, float p_angle, Vector3 &r_normal, Vector4 &r_tangent) { float binormal_sign = p_angle > 0.5 ? 1.0 : -1.0; float angle = Math::abs(p_angle * 2.0 - 1.0) * Math_PI; - float c = cos(angle); - float s = sin(angle); - Vector3 omc_axis = (1.0 - c) * p_axis; - Vector3 s_axis = s * p_axis; - Vector3 tan = omc_axis.x * p_axis + Vector3(c, -s_axis.z, s_axis.y); + + Basis tbn = Basis(p_axis, angle); + Vector3 tan = tbn.rows[0]; r_tangent = Vector4(tan.x, tan.y, tan.z, binormal_sign); - r_normal = omc_axis.z * p_axis + Vector3(-s_axis.y, s_axis.x, c); + r_normal = tbn.rows[2]; } Error RenderingServer::_surface_set_data(Array p_arrays, uint64_t p_format, uint32_t *p_offsets, uint32_t p_vertex_stride, uint32_t p_normal_stride, uint32_t p_attrib_stride, uint32_t p_skin_stride, Vector<uint8_t> &r_vertex_array, Vector<uint8_t> &r_attrib_array, Vector<uint8_t> &r_skin_array, int p_vertex_array_len, Vector<uint8_t> &r_index_array, int p_index_array_len, AABB &r_aabb, Vector<AABB> &r_bone_aabb, Vector4 &r_uv_scale) { @@ -1194,7 +1194,7 @@ Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surfa format |= RS::ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY; } - if (format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES && ((format & RS::ARRAY_FORMAT_NORMAL) || (format & RS::ARRAY_FORMAT_TANGENT))) { + if ((format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES) && ((format & RS::ARRAY_FORMAT_NORMAL) || (format & RS::ARRAY_FORMAT_TANGENT))) { // If using normals or tangents, then we need all three. ERR_FAIL_COND_V_MSG(!(format & RS::ARRAY_FORMAT_VERTEX), ERR_INVALID_PARAMETER, "Can't use compression flag 'ARRAY_FLAG_COMPRESS_ATTRIBUTES' while using normals or tangents without vertex array."); ERR_FAIL_COND_V_MSG(!(format & RS::ARRAY_FORMAT_NORMAL), ERR_INVALID_PARAMETER, "Can't use compression flag 'ARRAY_FLAG_COMPRESS_ATTRIBUTES' while using tangents without normal array."); @@ -1399,7 +1399,7 @@ Array RenderingServer::_get_array_from_surface(uint64_t p_format, Vector<uint8_t tangentsw[j * 4 + 3] = tan.w; } ret[RS::ARRAY_NORMAL] = normals; - ret[RS::ARRAY_FORMAT_TANGENT] = tangents; + ret[RS::ARRAY_TANGENT] = tangents; } else { for (int j = 0; j < p_vertex_len; j++) { diff --git a/servers/rendering_server.h b/servers/rendering_server.h index 5b8c16e7fe..d23e0fb48d 100644 --- a/servers/rendering_server.h +++ b/servers/rendering_server.h @@ -298,6 +298,8 @@ public: ARRAY_FLAG_FORMAT_VERSION_MASK = 0xFF, // 8 bits version }; + static_assert(sizeof(ArrayFormat) == 8, "ArrayFormat should be 64 bits long."); + enum PrimitiveType { PRIMITIVE_POINTS, PRIMITIVE_LINES, @@ -631,6 +633,8 @@ public: virtual void voxel_gi_set_quality(VoxelGIQuality) = 0; + virtual void sdfgi_reset() = 0; + /* LIGHTMAP */ virtual RID lightmap_create() = 0; diff --git a/thirdparty/README.md b/thirdparty/README.md index 980c35abb0..a81b5ea0ff 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -74,7 +74,7 @@ fix build with our own copy of zstd (patch in `patches`). ## brotli - Upstream: https://github.com/google/brotli -- Version: git (ed1995b6bda19244070ab5d331111f16f67c8054, 2023) +- Version: 1.1.0 (ed738e842d2fbdf2d6459e39267a633c4a9b2f5d, 2023) - License: MIT Files extracted from upstream source: @@ -672,7 +672,7 @@ with the provided patch. ## openxr - Upstream: https://github.com/KhronosGroup/OpenXR-SDK -- Version: 1.0.30 (55224479ab13db8ebc8ab1e3d49197bce6201b0b, 2023) +- Version: 1.0.28 (f5beb0131f1bea8701ace744d1b50df9049bf331, 2023) - License: Apache 2.0 Files extracted from upstream source: diff --git a/thirdparty/brotli/common/platform.h b/thirdparty/brotli/common/platform.h index 4186a8e96d..7406f3fe69 100644 --- a/thirdparty/brotli/common/platform.h +++ b/thirdparty/brotli/common/platform.h @@ -14,10 +14,11 @@ * BROTLI_BUILD_LITTLE_ENDIAN forces to use little-endian optimizations * BROTLI_BUILD_NO_RBIT disables "rbit" optimization for ARM CPUs * BROTLI_BUILD_NO_UNALIGNED_READ_FAST forces off the fast-unaligned-read - optimizations (mainly for testing purposes). + optimizations (mainly for testing purposes) * BROTLI_DEBUG dumps file name and line number when decoder detects stream or memory error * BROTLI_ENABLE_LOG enables asserts and dumps various state information + * BROTLI_ENABLE_DUMP overrides default "dump" behaviour */ #ifndef BROTLI_COMMON_PLATFORM_H_ @@ -208,8 +209,13 @@ OR: #define BROTLI_TARGET_RISCV64 #endif +#if defined(__loongarch_lp64) +#define BROTLI_TARGET_LOONGARCH64 +#endif + #if defined(BROTLI_TARGET_X64) || defined(BROTLI_TARGET_ARMV8_64) || \ - defined(BROTLI_TARGET_POWERPC64) || defined(BROTLI_TARGET_RISCV64) + defined(BROTLI_TARGET_POWERPC64) || defined(BROTLI_TARGET_RISCV64) || \ + defined(BROTLI_TARGET_LOONGARCH64) #define BROTLI_TARGET_64_BITS 1 #else #define BROTLI_TARGET_64_BITS 0 @@ -268,7 +274,7 @@ OR: #define BROTLI_UNALIGNED_READ_FAST (!!0) #elif defined(BROTLI_TARGET_X86) || defined(BROTLI_TARGET_X64) || \ defined(BROTLI_TARGET_ARMV7) || defined(BROTLI_TARGET_ARMV8_ANY) || \ - defined(BROTLI_TARGET_RISCV64) + defined(BROTLI_TARGET_RISCV64) || defined(BROTLI_TARGET_LOONGARCH64) /* These targets are known to generate efficient code for unaligned reads * (e.g. a single instruction, not multiple 1-byte loads, shifted and or'd * together). */ @@ -402,14 +408,24 @@ static BROTLI_INLINE void BROTLI_UNALIGNED_STORE_PTR(void* p, const void* v) { #endif #if defined(BROTLI_DEBUG) || defined(BROTLI_ENABLE_LOG) +#define BROTLI_ENABLE_DUMP_DEFAULT 1 #define BROTLI_DCHECK(x) assert(x) +#else +#define BROTLI_ENABLE_DUMP_DEFAULT 0 +#define BROTLI_DCHECK(x) +#endif + +#if !defined(BROTLI_ENABLE_DUMP) +#define BROTLI_ENABLE_DUMP BROTLI_ENABLE_DUMP_DEFAULT +#endif + +#if BROTLI_ENABLE_DUMP static BROTLI_INLINE void BrotliDump(const char* f, int l, const char* fn) { fprintf(stderr, "%s:%d (%s)\n", f, l, fn); fflush(stderr); } #define BROTLI_DUMP() BrotliDump(__FILE__, __LINE__, __FUNCTION__) #else -#define BROTLI_DCHECK(x) #define BROTLI_DUMP() (void)(0) #endif @@ -517,7 +533,7 @@ BROTLI_UNUSED_FUNCTION void BrotliSuppressUnusedFunctions(void) { BROTLI_UNUSED(&brotli_max_uint8_t); BROTLI_UNUSED(&BrotliDefaultAllocFunc); BROTLI_UNUSED(&BrotliDefaultFreeFunc); -#if defined(BROTLI_DEBUG) || defined(BROTLI_ENABLE_LOG) +#if BROTLI_ENABLE_DUMP BROTLI_UNUSED(&BrotliDump); #endif } diff --git a/thirdparty/brotli/common/shared_dictionary.c b/thirdparty/brotli/common/shared_dictionary.c index 3ca40c0698..49f1c9b075 100644 --- a/thirdparty/brotli/common/shared_dictionary.c +++ b/thirdparty/brotli/common/shared_dictionary.c @@ -20,6 +20,8 @@ extern "C" { #endif +#if defined(BROTLI_EXPERIMENTAL) + #define BROTLI_NUM_ENCODED_LENGTHS (SHARED_BROTLI_MAX_DICTIONARY_WORD_LENGTH \ - SHARED_BROTLI_MIN_DICTIONARY_WORD_LENGTH + 1) @@ -442,6 +444,8 @@ static BROTLI_BOOL DecodeSharedDictionary( return ParseDictionary(encoded, size, dict); } +#endif /* BROTLI_EXPERIMENTAL */ + void BrotliSharedDictionaryDestroyInstance( BrotliSharedDictionary* dict) { if (!dict) { @@ -464,9 +468,12 @@ BROTLI_BOOL BrotliSharedDictionaryAttach( if (!dict) { return BROTLI_FALSE; } +#if defined(BROTLI_EXPERIMENTAL) if (type == BROTLI_SHARED_DICTIONARY_SERIALIZED) { return DecodeSharedDictionary(data, data_size, dict); - } else if (type == BROTLI_SHARED_DICTIONARY_RAW) { + } +#endif /* BROTLI_EXPERIMENTAL */ + if (type == BROTLI_SHARED_DICTIONARY_RAW) { if (dict->num_prefix >= SHARED_BROTLI_MAX_COMPOUND_DICTS) { return BROTLI_FALSE; } @@ -474,9 +481,8 @@ BROTLI_BOOL BrotliSharedDictionaryAttach( dict->prefix[dict->num_prefix] = data; dict->num_prefix++; return BROTLI_TRUE; - } else { - return BROTLI_FALSE; } + return BROTLI_FALSE; } BrotliSharedDictionary* BrotliSharedDictionaryCreateInstance( diff --git a/thirdparty/brotli/common/version.h b/thirdparty/brotli/common/version.h index 01b2998e25..8098040f64 100644 --- a/thirdparty/brotli/common/version.h +++ b/thirdparty/brotli/common/version.h @@ -9,18 +9,43 @@ #ifndef BROTLI_COMMON_VERSION_H_ #define BROTLI_COMMON_VERSION_H_ -/* This macro should only be used when library is compiled together with client. - If library is dynamically linked, use BrotliDecoderVersion and +/* Compose 3 components into a single number. In a hexadecimal representation + B and C components occupy exactly 3 digits. */ +#define BROTLI_MAKE_HEX_VERSION(A, B, C) ((A << 24) | (B << 12) | C) + +/* Those macros should only be used when library is compiled together with + the client. If library is dynamically linked, use BrotliDecoderVersion and BrotliEncoderVersion methods. */ -/* Semantic version, calculated as (MAJOR << 24) | (MINOR << 12) | PATCH */ -#define BROTLI_VERSION 0x1000009 +#define BROTLI_VERSION_MAJOR 1 +#define BROTLI_VERSION_MINOR 1 +#define BROTLI_VERSION_PATCH 0 + +#define BROTLI_VERSION BROTLI_MAKE_HEX_VERSION( \ + BROTLI_VERSION_MAJOR, BROTLI_VERSION_MINOR, BROTLI_VERSION_PATCH) /* This macro is used by build system to produce Libtool-friendly soname. See https://www.gnu.org/software/libtool/manual/html_node/Libtool-versioning.html + Version evolution rules: + - interfaces added (or change is compatible) -> current+1:0:age+1 + - interfaces removed (or changed is incompatible) -> current+1:0:0 + - interfaces not changed -> current:revision+1:age */ -/* ABI version, calculated as (CURRENT << 24) | (REVISION << 12) | AGE */ -#define BROTLI_ABI_VERSION 0x1009000 +#define BROTLI_ABI_CURRENT 2 +#define BROTLI_ABI_REVISION 0 +#define BROTLI_ABI_AGE 1 + +#if BROTLI_VERSION_MAJOR != (BROTLI_ABI_CURRENT - BROTLI_ABI_AGE) +#error ABI/API version inconsistency +#endif + +#if BROTLI_VERSION_MINOR != BROTLI_ABI_AGE +#error ABI/API version inconsistency +#endif + +#if BROTLI_VERSION_PATCH != BROTLI_ABI_REVISION +#error ABI/API version inconsistency +#endif #endif /* BROTLI_COMMON_VERSION_H_ */ diff --git a/thirdparty/brotli/dec/bit_reader.c b/thirdparty/brotli/dec/bit_reader.c index 97e21f56f6..35101ddc1a 100644 --- a/thirdparty/brotli/dec/bit_reader.c +++ b/thirdparty/brotli/dec/bit_reader.c @@ -16,7 +16,7 @@ extern "C" { #endif -const uint32_t kBrotliBitMask[33] = { 0x00000000, +const brotli_reg_t kBrotliBitMask[33] = { 0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000F, 0x0000001F, 0x0000003F, 0x0000007F, 0x000000FF, 0x000001FF, 0x000003FF, 0x000007FF, 0x00000FFF, @@ -29,7 +29,7 @@ const uint32_t kBrotliBitMask[33] = { 0x00000000, void BrotliInitBitReader(BrotliBitReader* const br) { br->val_ = 0; - br->bit_pos_ = sizeof(br->val_) << 3; + br->bit_pos_ = 0; } BROTLI_BOOL BrotliWarmupBitReader(BrotliBitReader* const br) { @@ -41,6 +41,7 @@ BROTLI_BOOL BrotliWarmupBitReader(BrotliBitReader* const br) { aligned_read_mask = 0; } if (BrotliGetAvailableBits(br) == 0) { + br->val_ = 0; if (!BrotliPullByte(br)) { return BROTLI_FALSE; } @@ -56,9 +57,9 @@ BROTLI_BOOL BrotliWarmupBitReader(BrotliBitReader* const br) { } BROTLI_BOOL BrotliSafeReadBits32Slow(BrotliBitReader* const br, - uint32_t n_bits, uint32_t* val) { - uint32_t low_val; - uint32_t high_val; + brotli_reg_t n_bits, brotli_reg_t* val) { + brotli_reg_t low_val; + brotli_reg_t high_val; BrotliBitReaderState memento; BROTLI_DCHECK(n_bits <= 32); BROTLI_DCHECK(n_bits > 24); diff --git a/thirdparty/brotli/dec/bit_reader.h b/thirdparty/brotli/dec/bit_reader.h index 64701ecacc..930dc60f1d 100644 --- a/thirdparty/brotli/dec/bit_reader.h +++ b/thirdparty/brotli/dec/bit_reader.h @@ -22,13 +22,16 @@ extern "C" { #define BROTLI_SHORT_FILL_BIT_WINDOW_READ (sizeof(brotli_reg_t) >> 1) -BROTLI_INTERNAL extern const uint32_t kBrotliBitMask[33]; +/* 162 bits + 7 bytes */ +#define BROTLI_FAST_INPUT_SLACK 28 -static BROTLI_INLINE uint32_t BitMask(uint32_t n) { +BROTLI_INTERNAL extern const brotli_reg_t kBrotliBitMask[33]; + +static BROTLI_INLINE brotli_reg_t BitMask(brotli_reg_t n) { if (BROTLI_IS_CONSTANT(n) || BROTLI_HAS_UBFX) { /* Masking with this expression turns to a single "Unsigned Bit Field Extract" UBFX instruction on ARM. */ - return ~((0xFFFFFFFFu) << n); + return ~(~((brotli_reg_t)0) << n); } else { return kBrotliBitMask[n]; } @@ -36,40 +39,57 @@ static BROTLI_INLINE uint32_t BitMask(uint32_t n) { typedef struct { brotli_reg_t val_; /* pre-fetched bits */ - uint32_t bit_pos_; /* current bit-reading position in val_ */ + brotli_reg_t bit_pos_; /* current bit-reading position in val_ */ const uint8_t* next_in; /* the byte we're reading from */ - size_t avail_in; + const uint8_t* guard_in; /* position from which "fast-path" is prohibited */ + const uint8_t* last_in; /* == next_in + avail_in */ } BrotliBitReader; typedef struct { brotli_reg_t val_; - uint32_t bit_pos_; + brotli_reg_t bit_pos_; const uint8_t* next_in; size_t avail_in; } BrotliBitReaderState; /* Initializes the BrotliBitReader fields. */ -BROTLI_INTERNAL void BrotliInitBitReader(BrotliBitReader* const br); +BROTLI_INTERNAL void BrotliInitBitReader(BrotliBitReader* br); /* Ensures that accumulator is not empty. May consume up to sizeof(brotli_reg_t) - 1 bytes of input. Returns BROTLI_FALSE if data is required but there is no input available. For !BROTLI_UNALIGNED_READ_FAST this function also prepares bit reader for aligned reading. */ -BROTLI_INTERNAL BROTLI_BOOL BrotliWarmupBitReader(BrotliBitReader* const br); +BROTLI_INTERNAL BROTLI_BOOL BrotliWarmupBitReader(BrotliBitReader* br); /* Fallback for BrotliSafeReadBits32. Extracted as noninlined method to unburden the main code-path. Never called for RFC brotli streams, required only for "large-window" mode and other extensions. */ BROTLI_INTERNAL BROTLI_NOINLINE BROTLI_BOOL BrotliSafeReadBits32Slow( - BrotliBitReader* const br, uint32_t n_bits, uint32_t* val); + BrotliBitReader* br, brotli_reg_t n_bits, brotli_reg_t* val); + +static BROTLI_INLINE size_t +BrotliBitReaderGetAvailIn(BrotliBitReader* const br) { + return (size_t)(br->last_in - br->next_in); +} static BROTLI_INLINE void BrotliBitReaderSaveState( BrotliBitReader* const from, BrotliBitReaderState* to) { to->val_ = from->val_; to->bit_pos_ = from->bit_pos_; to->next_in = from->next_in; - to->avail_in = from->avail_in; + to->avail_in = BrotliBitReaderGetAvailIn(from); +} + +static BROTLI_INLINE void BrotliBitReaderSetInput( + BrotliBitReader* const br, const uint8_t* next_in, size_t avail_in) { + br->next_in = next_in; + br->last_in = (avail_in == 0) ? next_in : (next_in + avail_in); + if (avail_in + 1 > BROTLI_FAST_INPUT_SLACK) { + br->guard_in = next_in + (avail_in + 1 - BROTLI_FAST_INPUT_SLACK); + } else { + br->guard_in = next_in; + } } static BROTLI_INLINE void BrotliBitReaderRestoreState( @@ -77,12 +97,12 @@ static BROTLI_INLINE void BrotliBitReaderRestoreState( to->val_ = from->val_; to->bit_pos_ = from->bit_pos_; to->next_in = from->next_in; - to->avail_in = from->avail_in; + BrotliBitReaderSetInput(to, from->next_in, from->avail_in); } -static BROTLI_INLINE uint32_t BrotliGetAvailableBits( +static BROTLI_INLINE brotli_reg_t BrotliGetAvailableBits( const BrotliBitReader* br) { - return (BROTLI_64_BITS ? 64 : 32) - br->bit_pos_; + return br->bit_pos_; } /* Returns amount of unread bytes the bit reader still has buffered from the @@ -90,15 +110,27 @@ static BROTLI_INLINE uint32_t BrotliGetAvailableBits( maximal ring-buffer size (larger number won't be utilized anyway). */ static BROTLI_INLINE size_t BrotliGetRemainingBytes(BrotliBitReader* br) { static const size_t kCap = (size_t)1 << BROTLI_LARGE_MAX_WBITS; - if (br->avail_in > kCap) return kCap; - return br->avail_in + (BrotliGetAvailableBits(br) >> 3); + size_t avail_in = BrotliBitReaderGetAvailIn(br); + if (avail_in > kCap) return kCap; + return avail_in + (BrotliGetAvailableBits(br) >> 3); } /* Checks if there is at least |num| bytes left in the input ring-buffer (excluding the bits remaining in br->val_). */ static BROTLI_INLINE BROTLI_BOOL BrotliCheckInputAmount( - BrotliBitReader* const br, size_t num) { - return TO_BROTLI_BOOL(br->avail_in >= num); + BrotliBitReader* const br) { + return TO_BROTLI_BOOL(br->next_in < br->guard_in); +} + +/* Load more bits into accumulator. */ +static BROTLI_INLINE brotli_reg_t BrotliBitReaderLoadBits(brotli_reg_t val, + brotli_reg_t new_bits, + brotli_reg_t count, + brotli_reg_t offset) { + BROTLI_DCHECK( + !((val >> offset) & ~new_bits & ~(~((brotli_reg_t)0) << count))); + (void)count; + return val | (new_bits << offset); } /* Guarantees that there are at least |n_bits| + 1 bits in accumulator. @@ -106,61 +138,51 @@ static BROTLI_INLINE BROTLI_BOOL BrotliCheckInputAmount( |n_bits| should be in the range [1..24] for regular build. For portable non-64-bit little-endian build only 16 bits are safe to request. */ static BROTLI_INLINE void BrotliFillBitWindow( - BrotliBitReader* const br, uint32_t n_bits) { + BrotliBitReader* const br, brotli_reg_t n_bits) { #if (BROTLI_64_BITS) if (BROTLI_UNALIGNED_READ_FAST && BROTLI_IS_CONSTANT(n_bits) && (n_bits <= 8)) { - uint32_t bit_pos = br->bit_pos_; - if (bit_pos >= 56) { - br->val_ = - (br->val_ >> 56) | (BROTLI_UNALIGNED_LOAD64LE(br->next_in) << 8); - br->bit_pos_ = - bit_pos ^ 56; /* here same as -= 56 because of the if condition */ - br->avail_in -= 7; + brotli_reg_t bit_pos = br->bit_pos_; + if (bit_pos <= 8) { + br->val_ = BrotliBitReaderLoadBits(br->val_, + BROTLI_UNALIGNED_LOAD64LE(br->next_in), 56, bit_pos); + br->bit_pos_ = bit_pos + 56; br->next_in += 7; } } else if (BROTLI_UNALIGNED_READ_FAST && BROTLI_IS_CONSTANT(n_bits) && (n_bits <= 16)) { - uint32_t bit_pos = br->bit_pos_; - if (bit_pos >= 48) { - br->val_ = - (br->val_ >> 48) | (BROTLI_UNALIGNED_LOAD64LE(br->next_in) << 16); - br->bit_pos_ = - bit_pos ^ 48; /* here same as -= 48 because of the if condition */ - br->avail_in -= 6; + brotli_reg_t bit_pos = br->bit_pos_; + if (bit_pos <= 16) { + br->val_ = BrotliBitReaderLoadBits(br->val_, + BROTLI_UNALIGNED_LOAD64LE(br->next_in), 48, bit_pos); + br->bit_pos_ = bit_pos + 48; br->next_in += 6; } } else { - uint32_t bit_pos = br->bit_pos_; - if (bit_pos >= 32) { - br->val_ = (br->val_ >> 32) | - (((uint64_t)BROTLI_UNALIGNED_LOAD32LE(br->next_in)) << 32); - br->bit_pos_ = - bit_pos ^ 32; /* here same as -= 32 because of the if condition */ - br->avail_in -= BROTLI_SHORT_FILL_BIT_WINDOW_READ; + brotli_reg_t bit_pos = br->bit_pos_; + if (bit_pos <= 32) { + br->val_ = BrotliBitReaderLoadBits(br->val_, + (uint64_t)BROTLI_UNALIGNED_LOAD32LE(br->next_in), 32, bit_pos); + br->bit_pos_ = bit_pos + 32; br->next_in += BROTLI_SHORT_FILL_BIT_WINDOW_READ; } } #else if (BROTLI_UNALIGNED_READ_FAST && BROTLI_IS_CONSTANT(n_bits) && (n_bits <= 8)) { - uint32_t bit_pos = br->bit_pos_; - if (bit_pos >= 24) { - br->val_ = - (br->val_ >> 24) | (BROTLI_UNALIGNED_LOAD32LE(br->next_in) << 8); - br->bit_pos_ = - bit_pos ^ 24; /* here same as -= 24 because of the if condition */ - br->avail_in -= 3; + brotli_reg_t bit_pos = br->bit_pos_; + if (bit_pos <= 8) { + br->val_ = BrotliBitReaderLoadBits(br->val_, + BROTLI_UNALIGNED_LOAD32LE(br->next_in), 24, bit_pos); + br->bit_pos_ = bit_pos + 24; br->next_in += 3; } } else { - uint32_t bit_pos = br->bit_pos_; - if (bit_pos >= 16) { - br->val_ = (br->val_ >> 16) | - (((uint32_t)BROTLI_UNALIGNED_LOAD16LE(br->next_in)) << 16); - br->bit_pos_ = - bit_pos ^ 16; /* here same as -= 16 because of the if condition */ - br->avail_in -= BROTLI_SHORT_FILL_BIT_WINDOW_READ; + brotli_reg_t bit_pos = br->bit_pos_; + if (bit_pos <= 16) { + br->val_ = BrotliBitReaderLoadBits(br->val_, + (uint32_t)BROTLI_UNALIGNED_LOAD16LE(br->next_in), 16, bit_pos); + br->bit_pos_ = bit_pos + 16; br->next_in += BROTLI_SHORT_FILL_BIT_WINDOW_READ; } } @@ -176,17 +198,12 @@ static BROTLI_INLINE void BrotliFillBitWindow16(BrotliBitReader* const br) { /* Tries to pull one byte of input to accumulator. Returns BROTLI_FALSE if there is no input available. */ static BROTLI_INLINE BROTLI_BOOL BrotliPullByte(BrotliBitReader* const br) { - if (br->avail_in == 0) { + if (br->next_in == br->last_in) { return BROTLI_FALSE; } - br->val_ >>= 8; -#if (BROTLI_64_BITS) - br->val_ |= ((uint64_t)*br->next_in) << 56; -#else - br->val_ |= ((uint32_t)*br->next_in) << 24; -#endif - br->bit_pos_ -= 8; - --br->avail_in; + br->val_ = BrotliBitReaderLoadBits(br->val_, + (brotli_reg_t)*br->next_in, 8, br->bit_pos_); + br->bit_pos_ += 8; ++br->next_in; return BROTLI_TRUE; } @@ -195,81 +212,90 @@ static BROTLI_INLINE BROTLI_BOOL BrotliPullByte(BrotliBitReader* const br) { The number of valid bits could be calculated by BrotliGetAvailableBits. */ static BROTLI_INLINE brotli_reg_t BrotliGetBitsUnmasked( BrotliBitReader* const br) { - return br->val_ >> br->bit_pos_; + return br->val_; } /* Like BrotliGetBits, but does not mask the result. The result contains at least 16 valid bits. */ -static BROTLI_INLINE uint32_t BrotliGet16BitsUnmasked( +static BROTLI_INLINE brotli_reg_t BrotliGet16BitsUnmasked( BrotliBitReader* const br) { BrotliFillBitWindow(br, 16); - return (uint32_t)BrotliGetBitsUnmasked(br); + return (brotli_reg_t)BrotliGetBitsUnmasked(br); } /* Returns the specified number of bits from |br| without advancing bit position. */ -static BROTLI_INLINE uint32_t BrotliGetBits( - BrotliBitReader* const br, uint32_t n_bits) { +static BROTLI_INLINE brotli_reg_t BrotliGetBits( + BrotliBitReader* const br, brotli_reg_t n_bits) { BrotliFillBitWindow(br, n_bits); - return (uint32_t)BrotliGetBitsUnmasked(br) & BitMask(n_bits); + return BrotliGetBitsUnmasked(br) & BitMask(n_bits); } /* Tries to peek the specified amount of bits. Returns BROTLI_FALSE, if there is not enough input. */ static BROTLI_INLINE BROTLI_BOOL BrotliSafeGetBits( - BrotliBitReader* const br, uint32_t n_bits, uint32_t* val) { + BrotliBitReader* const br, brotli_reg_t n_bits, brotli_reg_t* val) { while (BrotliGetAvailableBits(br) < n_bits) { if (!BrotliPullByte(br)) { return BROTLI_FALSE; } } - *val = (uint32_t)BrotliGetBitsUnmasked(br) & BitMask(n_bits); + *val = BrotliGetBitsUnmasked(br) & BitMask(n_bits); return BROTLI_TRUE; } /* Advances the bit pos by |n_bits|. */ static BROTLI_INLINE void BrotliDropBits( - BrotliBitReader* const br, uint32_t n_bits) { - br->bit_pos_ += n_bits; + BrotliBitReader* const br, brotli_reg_t n_bits) { + br->bit_pos_ -= n_bits; + br->val_ >>= n_bits; } -static BROTLI_INLINE void BrotliBitReaderUnload(BrotliBitReader* br) { - uint32_t unused_bytes = BrotliGetAvailableBits(br) >> 3; - uint32_t unused_bits = unused_bytes << 3; - br->avail_in += unused_bytes; - br->next_in -= unused_bytes; - if (unused_bits == sizeof(br->val_) << 3) { - br->val_ = 0; - } else { - br->val_ <<= unused_bits; +/* Make sure that there are no spectre bits in accumulator. + This is important for the cases when some bytes are skipped + (i.e. never placed into accumulator). */ +static BROTLI_INLINE void BrotliBitReaderNormalize(BrotliBitReader* br) { + /* Actually, it is enough to normalize when br->bit_pos_ == 0 */ + if (br->bit_pos_ < (sizeof(brotli_reg_t) << 3u)) { + br->val_ &= (((brotli_reg_t)1) << br->bit_pos_) - 1; } - br->bit_pos_ += unused_bits; +} + +static BROTLI_INLINE void BrotliBitReaderUnload(BrotliBitReader* br) { + brotli_reg_t unused_bytes = BrotliGetAvailableBits(br) >> 3; + brotli_reg_t unused_bits = unused_bytes << 3; + br->next_in = + (unused_bytes == 0) ? br->next_in : (br->next_in - unused_bytes); + br->bit_pos_ -= unused_bits; + BrotliBitReaderNormalize(br); } /* Reads the specified number of bits from |br| and advances the bit pos. Precondition: accumulator MUST contain at least |n_bits|. */ -static BROTLI_INLINE void BrotliTakeBits( - BrotliBitReader* const br, uint32_t n_bits, uint32_t* val) { - *val = (uint32_t)BrotliGetBitsUnmasked(br) & BitMask(n_bits); +static BROTLI_INLINE void BrotliTakeBits(BrotliBitReader* const br, + brotli_reg_t n_bits, + brotli_reg_t* val) { + *val = BrotliGetBitsUnmasked(br) & BitMask(n_bits); BROTLI_LOG(("[BrotliTakeBits] %d %d %d val: %6x\n", - (int)br->avail_in, (int)br->bit_pos_, (int)n_bits, (int)*val)); + (int)BrotliBitReaderGetAvailIn(br), (int)br->bit_pos_, + (int)n_bits, (int)*val)); BrotliDropBits(br, n_bits); } /* Reads the specified number of bits from |br| and advances the bit pos. Assumes that there is enough input to perform BrotliFillBitWindow. Up to 24 bits are allowed to be requested from this method. */ -static BROTLI_INLINE uint32_t BrotliReadBits24( - BrotliBitReader* const br, uint32_t n_bits) { +static BROTLI_INLINE brotli_reg_t BrotliReadBits24( + BrotliBitReader* const br, brotli_reg_t n_bits) { BROTLI_DCHECK(n_bits <= 24); if (BROTLI_64_BITS || (n_bits <= 16)) { - uint32_t val; + brotli_reg_t val; BrotliFillBitWindow(br, n_bits); BrotliTakeBits(br, n_bits, &val); return val; } else { - uint32_t low_val; - uint32_t high_val; + brotli_reg_t low_val; + brotli_reg_t high_val; BrotliFillBitWindow(br, 16); BrotliTakeBits(br, 16, &low_val); BrotliFillBitWindow(br, 8); @@ -279,17 +305,17 @@ static BROTLI_INLINE uint32_t BrotliReadBits24( } /* Same as BrotliReadBits24, but allows reading up to 32 bits. */ -static BROTLI_INLINE uint32_t BrotliReadBits32( - BrotliBitReader* const br, uint32_t n_bits) { +static BROTLI_INLINE brotli_reg_t BrotliReadBits32( + BrotliBitReader* const br, brotli_reg_t n_bits) { BROTLI_DCHECK(n_bits <= 32); if (BROTLI_64_BITS || (n_bits <= 16)) { - uint32_t val; + brotli_reg_t val; BrotliFillBitWindow(br, n_bits); BrotliTakeBits(br, n_bits, &val); return val; } else { - uint32_t low_val; - uint32_t high_val; + brotli_reg_t low_val; + brotli_reg_t high_val; BrotliFillBitWindow(br, 16); BrotliTakeBits(br, 16, &low_val); BrotliFillBitWindow(br, 16); @@ -302,7 +328,7 @@ static BROTLI_INLINE uint32_t BrotliReadBits32( is not enough input. |n_bits| MUST be positive. Up to 24 bits are allowed to be requested from this method. */ static BROTLI_INLINE BROTLI_BOOL BrotliSafeReadBits( - BrotliBitReader* const br, uint32_t n_bits, uint32_t* val) { + BrotliBitReader* const br, brotli_reg_t n_bits, brotli_reg_t* val) { BROTLI_DCHECK(n_bits <= 24); while (BrotliGetAvailableBits(br) < n_bits) { if (!BrotliPullByte(br)) { @@ -315,7 +341,7 @@ static BROTLI_INLINE BROTLI_BOOL BrotliSafeReadBits( /* Same as BrotliSafeReadBits, but allows reading up to 32 bits. */ static BROTLI_INLINE BROTLI_BOOL BrotliSafeReadBits32( - BrotliBitReader* const br, uint32_t n_bits, uint32_t* val) { + BrotliBitReader* const br, brotli_reg_t n_bits, brotli_reg_t* val) { BROTLI_DCHECK(n_bits <= 32); if (BROTLI_64_BITS || (n_bits <= 24)) { while (BrotliGetAvailableBits(br) < n_bits) { @@ -333,16 +359,19 @@ static BROTLI_INLINE BROTLI_BOOL BrotliSafeReadBits32( /* Advances the bit reader position to the next byte boundary and verifies that any skipped bits are set to zero. */ static BROTLI_INLINE BROTLI_BOOL BrotliJumpToByteBoundary(BrotliBitReader* br) { - uint32_t pad_bits_count = BrotliGetAvailableBits(br) & 0x7; - uint32_t pad_bits = 0; + brotli_reg_t pad_bits_count = BrotliGetAvailableBits(br) & 0x7; + brotli_reg_t pad_bits = 0; if (pad_bits_count != 0) { BrotliTakeBits(br, pad_bits_count, &pad_bits); } + BrotliBitReaderNormalize(br); return TO_BROTLI_BOOL(pad_bits == 0); } static BROTLI_INLINE void BrotliDropBytes(BrotliBitReader* br, size_t num) { - br->avail_in -= num; + /* Check detour is legal: accumulator must to be empty. */ + BROTLI_DCHECK(br->bit_pos_ == 0); + BROTLI_DCHECK(br->val_ == 0); br->next_in += num; } @@ -357,12 +386,36 @@ static BROTLI_INLINE void BrotliCopyBytes(uint8_t* dest, ++dest; --num; } + BrotliBitReaderNormalize(br); if (num > 0) { memcpy(dest, br->next_in, num); BrotliDropBytes(br, num); } } +BROTLI_UNUSED_FUNCTION void BrotliBitReaderSuppressUnusedFunctions(void) { + BROTLI_UNUSED(&BrotliBitReaderSuppressUnusedFunctions); + + BROTLI_UNUSED(&BrotliBitReaderGetAvailIn); + BROTLI_UNUSED(&BrotliBitReaderLoadBits); + BROTLI_UNUSED(&BrotliBitReaderRestoreState); + BROTLI_UNUSED(&BrotliBitReaderSaveState); + BROTLI_UNUSED(&BrotliBitReaderSetInput); + BROTLI_UNUSED(&BrotliBitReaderUnload); + BROTLI_UNUSED(&BrotliCheckInputAmount); + BROTLI_UNUSED(&BrotliCopyBytes); + BROTLI_UNUSED(&BrotliFillBitWindow16); + BROTLI_UNUSED(&BrotliGet16BitsUnmasked); + BROTLI_UNUSED(&BrotliGetBits); + BROTLI_UNUSED(&BrotliGetRemainingBytes); + BROTLI_UNUSED(&BrotliJumpToByteBoundary); + BROTLI_UNUSED(&BrotliReadBits24); + BROTLI_UNUSED(&BrotliReadBits32); + BROTLI_UNUSED(&BrotliSafeGetBits); + BROTLI_UNUSED(&BrotliSafeReadBits); + BROTLI_UNUSED(&BrotliSafeReadBits32); +} + #if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ #endif diff --git a/thirdparty/brotli/dec/decode.c b/thirdparty/brotli/dec/decode.c index 3ee1963a85..220c7e85c6 100644 --- a/thirdparty/brotli/dec/decode.c +++ b/thirdparty/brotli/dec/decode.c @@ -44,7 +44,7 @@ extern "C" { - doing up to two 16-byte copies for fast backward copying - inserting transformed dictionary word: 255 prefix + 32 base + 255 suffix */ -static const uint32_t kRingBufferWriteAheadSlack = 542; +static const brotli_reg_t kRingBufferWriteAheadSlack = 542; static const uint8_t kCodeLengthCodeOrder[BROTLI_CODE_LENGTH_CODES] = { 1, 2, 3, 4, 0, 5, 17, 6, 16, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -116,6 +116,10 @@ static BROTLI_NOINLINE BrotliDecoderResult SaveErrorCode( BrotliDecoderState* s, BrotliDecoderErrorCode e, size_t consumed_input) { s->error_code = (int)e; s->used_input += consumed_input; + if ((s->buffer_length != 0) && (s->br.next_in == s->br.last_in)) { + /* If internal buffer is depleted at last, reset it. */ + s->buffer_length = 0; + } switch (e) { case BROTLI_DECODER_SUCCESS: return BROTLI_DECODER_RESULT_SUCCESS; @@ -135,7 +139,7 @@ static BROTLI_NOINLINE BrotliDecoderResult SaveErrorCode( Precondition: bit-reader accumulator has at least 8 bits. */ static BrotliDecoderErrorCode DecodeWindowBits(BrotliDecoderState* s, BrotliBitReader* br) { - uint32_t n; + brotli_reg_t n; BROTLI_BOOL large_window = s->large_window; s->large_window = BROTLI_FALSE; BrotliTakeBits(br, 1, &n); @@ -145,7 +149,7 @@ static BrotliDecoderErrorCode DecodeWindowBits(BrotliDecoderState* s, } BrotliTakeBits(br, 3, &n); if (n != 0) { - s->window_bits = 17 + n; + s->window_bits = (17u + n) & 63u; return BROTLI_DECODER_SUCCESS; } BrotliTakeBits(br, 3, &n); @@ -162,7 +166,7 @@ static BrotliDecoderErrorCode DecodeWindowBits(BrotliDecoderState* s, } } if (n != 0) { - s->window_bits = 8 + n; + s->window_bits = (8u + n) & 63u; return BROTLI_DECODER_SUCCESS; } s->window_bits = 17; @@ -181,8 +185,8 @@ static BROTLI_INLINE void memmove16(uint8_t* dst, uint8_t* src) { /* Decodes a number in the range [0..255], by reading 1 - 11 bits. */ static BROTLI_NOINLINE BrotliDecoderErrorCode DecodeVarLenUint8( - BrotliDecoderState* s, BrotliBitReader* br, uint32_t* value) { - uint32_t bits; + BrotliDecoderState* s, BrotliBitReader* br, brotli_reg_t* value) { + brotli_reg_t bits; switch (s->substate_decode_uint8) { case BROTLI_STATE_DECODE_UINT8_NONE: if (BROTLI_PREDICT_FALSE(!BrotliSafeReadBits(br, 1, &bits))) { @@ -226,7 +230,7 @@ static BROTLI_NOINLINE BrotliDecoderErrorCode DecodeVarLenUint8( /* Decodes a metablock length and flags by reading 2 - 31 bits. */ static BrotliDecoderErrorCode BROTLI_NOINLINE DecodeMetaBlockLength( BrotliDecoderState* s, BrotliBitReader* br) { - uint32_t bits; + brotli_reg_t bits; int i; for (;;) { switch (s->substate_metablock_header) { @@ -349,13 +353,13 @@ static BrotliDecoderErrorCode BROTLI_NOINLINE DecodeMetaBlockLength( This method doesn't read data from the bit reader, BUT drops the amount of bits that correspond to the decoded symbol. bits MUST contain at least 15 (BROTLI_HUFFMAN_MAX_CODE_LENGTH) valid bits. */ -static BROTLI_INLINE uint32_t DecodeSymbol(uint32_t bits, - const HuffmanCode* table, - BrotliBitReader* br) { +static BROTLI_INLINE brotli_reg_t DecodeSymbol(brotli_reg_t bits, + const HuffmanCode* table, + BrotliBitReader* br) { BROTLI_HC_MARK_TABLE_FOR_FAST_LOAD(table); BROTLI_HC_ADJUST_TABLE_INDEX(table, bits & HUFFMAN_TABLE_MASK); if (BROTLI_HC_FAST_LOAD_BITS(table) > HUFFMAN_TABLE_BITS) { - uint32_t nbits = BROTLI_HC_FAST_LOAD_BITS(table) - HUFFMAN_TABLE_BITS; + brotli_reg_t nbits = BROTLI_HC_FAST_LOAD_BITS(table) - HUFFMAN_TABLE_BITS; BrotliDropBits(br, HUFFMAN_TABLE_BITS); BROTLI_HC_ADJUST_TABLE_INDEX(table, BROTLI_HC_FAST_LOAD_VALUE(table) + @@ -367,17 +371,17 @@ static BROTLI_INLINE uint32_t DecodeSymbol(uint32_t bits, /* Reads and decodes the next Huffman code from bit-stream. This method peeks 16 bits of input and drops 0 - 15 of them. */ -static BROTLI_INLINE uint32_t ReadSymbol(const HuffmanCode* table, - BrotliBitReader* br) { +static BROTLI_INLINE brotli_reg_t ReadSymbol(const HuffmanCode* table, + BrotliBitReader* br) { return DecodeSymbol(BrotliGet16BitsUnmasked(br), table, br); } /* Same as DecodeSymbol, but it is known that there is less than 15 bits of input are currently available. */ static BROTLI_NOINLINE BROTLI_BOOL SafeDecodeSymbol( - const HuffmanCode* table, BrotliBitReader* br, uint32_t* result) { - uint32_t val; - uint32_t available_bits = BrotliGetAvailableBits(br); + const HuffmanCode* table, BrotliBitReader* br, brotli_reg_t* result) { + brotli_reg_t val; + brotli_reg_t available_bits = BrotliGetAvailableBits(br); BROTLI_HC_MARK_TABLE_FOR_FAST_LOAD(table); if (available_bits == 0) { if (BROTLI_HC_FAST_LOAD_BITS(table) == 0) { @@ -386,7 +390,7 @@ static BROTLI_NOINLINE BROTLI_BOOL SafeDecodeSymbol( } return BROTLI_FALSE; /* No valid bits at all. */ } - val = (uint32_t)BrotliGetBitsUnmasked(br); + val = BrotliGetBitsUnmasked(br); BROTLI_HC_ADJUST_TABLE_INDEX(table, val & HUFFMAN_TABLE_MASK); if (BROTLI_HC_FAST_LOAD_BITS(table) <= HUFFMAN_TABLE_BITS) { if (BROTLI_HC_FAST_LOAD_BITS(table) <= available_bits) { @@ -415,8 +419,8 @@ static BROTLI_NOINLINE BROTLI_BOOL SafeDecodeSymbol( } static BROTLI_INLINE BROTLI_BOOL SafeReadSymbol( - const HuffmanCode* table, BrotliBitReader* br, uint32_t* result) { - uint32_t val; + const HuffmanCode* table, BrotliBitReader* br, brotli_reg_t* result) { + brotli_reg_t val; if (BROTLI_PREDICT_TRUE(BrotliSafeGetBits(br, 15, &val))) { *result = DecodeSymbol(val, table, br); return BROTLI_TRUE; @@ -428,8 +432,8 @@ static BROTLI_INLINE BROTLI_BOOL SafeReadSymbol( static BROTLI_INLINE void PreloadSymbol(int safe, const HuffmanCode* table, BrotliBitReader* br, - uint32_t* bits, - uint32_t* value) { + brotli_reg_t* bits, + brotli_reg_t* value) { if (safe) { return; } @@ -441,15 +445,15 @@ static BROTLI_INLINE void PreloadSymbol(int safe, /* Decodes the next Huffman code using data prepared by PreloadSymbol. Reads 0 - 15 bits. Also peeks 8 following bits. */ -static BROTLI_INLINE uint32_t ReadPreloadedSymbol(const HuffmanCode* table, +static BROTLI_INLINE brotli_reg_t ReadPreloadedSymbol(const HuffmanCode* table, BrotliBitReader* br, - uint32_t* bits, - uint32_t* value) { - uint32_t result = *value; + brotli_reg_t* bits, + brotli_reg_t* value) { + brotli_reg_t result = *value; if (BROTLI_PREDICT_FALSE(*bits > HUFFMAN_TABLE_BITS)) { - uint32_t val = BrotliGet16BitsUnmasked(br); + brotli_reg_t val = BrotliGet16BitsUnmasked(br); const HuffmanCode* ext = table + (val & HUFFMAN_TABLE_MASK) + *value; - uint32_t mask = BitMask((*bits - HUFFMAN_TABLE_BITS)); + brotli_reg_t mask = BitMask((*bits - HUFFMAN_TABLE_BITS)); BROTLI_HC_MARK_TABLE_FOR_FAST_LOAD(ext); BrotliDropBits(br, HUFFMAN_TABLE_BITS); BROTLI_HC_ADJUST_TABLE_INDEX(ext, (val >> HUFFMAN_TABLE_BITS) & mask); @@ -462,8 +466,8 @@ static BROTLI_INLINE uint32_t ReadPreloadedSymbol(const HuffmanCode* table, return result; } -static BROTLI_INLINE uint32_t Log2Floor(uint32_t x) { - uint32_t result = 0; +static BROTLI_INLINE brotli_reg_t Log2Floor(brotli_reg_t x) { + brotli_reg_t result = 0; while (x) { x >>= 1; ++result; @@ -475,16 +479,16 @@ static BROTLI_INLINE uint32_t Log2Floor(uint32_t x) { Totally 1..4 symbols are read, 1..11 bits each. The list of symbols MUST NOT contain duplicates. */ static BrotliDecoderErrorCode ReadSimpleHuffmanSymbols( - uint32_t alphabet_size_max, uint32_t alphabet_size_limit, + brotli_reg_t alphabet_size_max, brotli_reg_t alphabet_size_limit, BrotliDecoderState* s) { /* max_bits == 1..11; symbol == 0..3; 1..44 bits will be read. */ BrotliBitReader* br = &s->br; BrotliMetablockHeaderArena* h = &s->arena.header; - uint32_t max_bits = Log2Floor(alphabet_size_max - 1); - uint32_t i = h->sub_loop_counter; - uint32_t num_symbols = h->symbol; + brotli_reg_t max_bits = Log2Floor(alphabet_size_max - 1); + brotli_reg_t i = h->sub_loop_counter; + brotli_reg_t num_symbols = h->symbol; while (i <= num_symbols) { - uint32_t v; + brotli_reg_t v; if (BROTLI_PREDICT_FALSE(!BrotliSafeReadBits(br, max_bits, &v))) { h->sub_loop_counter = i; h->substate_huffman = BROTLI_STATE_HUFFMAN_SIMPLE_READ; @@ -500,7 +504,7 @@ static BrotliDecoderErrorCode ReadSimpleHuffmanSymbols( } for (i = 0; i < num_symbols; ++i) { - uint32_t k = i + 1; + brotli_reg_t k = i + 1; for (; k <= num_symbols; ++k) { if (h->symbols_lists_array[i] == h->symbols_lists_array[k]) { return BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME); @@ -517,9 +521,9 @@ static BrotliDecoderErrorCode ReadSimpleHuffmanSymbols( C) extend corresponding index-chain D) reduce the Huffman space E) update the histogram */ -static BROTLI_INLINE void ProcessSingleCodeLength(uint32_t code_len, - uint32_t* symbol, uint32_t* repeat, uint32_t* space, - uint32_t* prev_code_len, uint16_t* symbol_lists, +static BROTLI_INLINE void ProcessSingleCodeLength(brotli_reg_t code_len, + brotli_reg_t* symbol, brotli_reg_t* repeat, brotli_reg_t* space, + brotli_reg_t* prev_code_len, uint16_t* symbol_lists, uint16_t* code_length_histo, int* next_symbol) { *repeat = 0; if (code_len != 0) { /* code_len == 1..15 */ @@ -544,14 +548,14 @@ static BROTLI_INLINE void ProcessSingleCodeLength(uint32_t code_len, PRECONDITION: code_len == BROTLI_REPEAT_PREVIOUS_CODE_LENGTH or code_len == BROTLI_REPEAT_ZERO_CODE_LENGTH */ -static BROTLI_INLINE void ProcessRepeatedCodeLength(uint32_t code_len, - uint32_t repeat_delta, uint32_t alphabet_size, uint32_t* symbol, - uint32_t* repeat, uint32_t* space, uint32_t* prev_code_len, - uint32_t* repeat_code_len, uint16_t* symbol_lists, +static BROTLI_INLINE void ProcessRepeatedCodeLength(brotli_reg_t code_len, + brotli_reg_t repeat_delta, brotli_reg_t alphabet_size, brotli_reg_t* symbol, + brotli_reg_t* repeat, brotli_reg_t* space, brotli_reg_t* prev_code_len, + brotli_reg_t* repeat_code_len, uint16_t* symbol_lists, uint16_t* code_length_histo, int* next_symbol) { - uint32_t old_repeat; - uint32_t extra_bits = 3; /* for BROTLI_REPEAT_ZERO_CODE_LENGTH */ - uint32_t new_len = 0; /* for BROTLI_REPEAT_ZERO_CODE_LENGTH */ + brotli_reg_t old_repeat; + brotli_reg_t extra_bits = 3; /* for BROTLI_REPEAT_ZERO_CODE_LENGTH */ + brotli_reg_t new_len = 0; /* for BROTLI_REPEAT_ZERO_CODE_LENGTH */ if (code_len == BROTLI_REPEAT_PREVIOUS_CODE_LENGTH) { new_len = *prev_code_len; extra_bits = 2; @@ -576,7 +580,7 @@ static BROTLI_INLINE void ProcessRepeatedCodeLength(uint32_t code_len, BROTLI_LOG(("[ReadHuffmanCode] code_length[%d..%d] = %d\n", (int)*symbol, (int)(*symbol + repeat_delta - 1), (int)*repeat_code_len)); if (*repeat_code_len != 0) { - unsigned last = *symbol + repeat_delta; + brotli_reg_t last = *symbol + repeat_delta; int next = next_symbol[*repeat_code_len]; do { symbol_lists[next] = (uint16_t)*symbol; @@ -593,14 +597,14 @@ static BROTLI_INLINE void ProcessRepeatedCodeLength(uint32_t code_len, /* Reads and decodes symbol codelengths. */ static BrotliDecoderErrorCode ReadSymbolCodeLengths( - uint32_t alphabet_size, BrotliDecoderState* s) { + brotli_reg_t alphabet_size, BrotliDecoderState* s) { BrotliBitReader* br = &s->br; BrotliMetablockHeaderArena* h = &s->arena.header; - uint32_t symbol = h->symbol; - uint32_t repeat = h->repeat; - uint32_t space = h->space; - uint32_t prev_code_len = h->prev_code_len; - uint32_t repeat_code_len = h->repeat_code_len; + brotli_reg_t symbol = h->symbol; + brotli_reg_t repeat = h->repeat; + brotli_reg_t space = h->space; + brotli_reg_t prev_code_len = h->prev_code_len; + brotli_reg_t repeat_code_len = h->repeat_code_len; uint16_t* symbol_lists = h->symbol_lists; uint16_t* code_length_histo = h->code_length_histo; int* next_symbol = h->next_symbol; @@ -609,9 +613,9 @@ static BrotliDecoderErrorCode ReadSymbolCodeLengths( } while (symbol < alphabet_size && space > 0) { const HuffmanCode* p = h->table; - uint32_t code_len; + brotli_reg_t code_len; BROTLI_HC_MARK_TABLE_FOR_FAST_LOAD(p); - if (!BrotliCheckInputAmount(br, BROTLI_SHORT_FILL_BIT_WINDOW_READ)) { + if (!BrotliCheckInputAmount(br)) { h->symbol = symbol; h->repeat = repeat; h->prev_code_len = prev_code_len; @@ -628,10 +632,10 @@ static BrotliDecoderErrorCode ReadSymbolCodeLengths( ProcessSingleCodeLength(code_len, &symbol, &repeat, &space, &prev_code_len, symbol_lists, code_length_histo, next_symbol); } else { /* code_len == 16..17, extra_bits == 2..3 */ - uint32_t extra_bits = + brotli_reg_t extra_bits = (code_len == BROTLI_REPEAT_PREVIOUS_CODE_LENGTH) ? 2 : 3; - uint32_t repeat_delta = - (uint32_t)BrotliGetBitsUnmasked(br) & BitMask(extra_bits); + brotli_reg_t repeat_delta = + BrotliGetBitsUnmasked(br) & BitMask(extra_bits); BrotliDropBits(br, extra_bits); ProcessRepeatedCodeLength(code_len, repeat_delta, alphabet_size, &symbol, &repeat, &space, &prev_code_len, &repeat_code_len, @@ -643,15 +647,15 @@ static BrotliDecoderErrorCode ReadSymbolCodeLengths( } static BrotliDecoderErrorCode SafeReadSymbolCodeLengths( - uint32_t alphabet_size, BrotliDecoderState* s) { + brotli_reg_t alphabet_size, BrotliDecoderState* s) { BrotliBitReader* br = &s->br; BrotliMetablockHeaderArena* h = &s->arena.header; BROTLI_BOOL get_byte = BROTLI_FALSE; while (h->symbol < alphabet_size && h->space > 0) { const HuffmanCode* p = h->table; - uint32_t code_len; - uint32_t available_bits; - uint32_t bits = 0; + brotli_reg_t code_len; + brotli_reg_t available_bits; + brotli_reg_t bits = 0; BROTLI_HC_MARK_TABLE_FOR_FAST_LOAD(p); if (get_byte && !BrotliPullByte(br)) return BROTLI_DECODER_NEEDS_MORE_INPUT; get_byte = BROTLI_FALSE; @@ -672,8 +676,8 @@ static BrotliDecoderErrorCode SafeReadSymbolCodeLengths( &h->prev_code_len, h->symbol_lists, h->code_length_histo, h->next_symbol); } else { /* code_len == 16..17, extra_bits == 2..3 */ - uint32_t extra_bits = code_len - 14U; - uint32_t repeat_delta = (bits >> BROTLI_HC_FAST_LOAD_BITS(p)) & + brotli_reg_t extra_bits = code_len - 14U; + brotli_reg_t repeat_delta = (bits >> BROTLI_HC_FAST_LOAD_BITS(p)) & BitMask(extra_bits); if (available_bits < BROTLI_HC_FAST_LOAD_BITS(p) + extra_bits) { get_byte = BROTLI_TRUE; @@ -694,15 +698,15 @@ static BrotliDecoderErrorCode SafeReadSymbolCodeLengths( static BrotliDecoderErrorCode ReadCodeLengthCodeLengths(BrotliDecoderState* s) { BrotliBitReader* br = &s->br; BrotliMetablockHeaderArena* h = &s->arena.header; - uint32_t num_codes = h->repeat; - unsigned space = h->space; - uint32_t i = h->sub_loop_counter; + brotli_reg_t num_codes = h->repeat; + brotli_reg_t space = h->space; + brotli_reg_t i = h->sub_loop_counter; for (; i < BROTLI_CODE_LENGTH_CODES; ++i) { const uint8_t code_len_idx = kCodeLengthCodeOrder[i]; - uint32_t ix; - uint32_t v; + brotli_reg_t ix; + brotli_reg_t v; if (BROTLI_PREDICT_FALSE(!BrotliSafeGetBits(br, 4, &ix))) { - uint32_t available_bits = BrotliGetAvailableBits(br); + brotli_reg_t available_bits = BrotliGetAvailableBits(br); if (available_bits != 0) { ix = BrotliGetBitsUnmasked(br) & 0xF; } else { @@ -747,10 +751,10 @@ static BrotliDecoderErrorCode ReadCodeLengthCodeLengths(BrotliDecoderState* s) { encoded with predefined entropy code. 32 - 74 bits are used. B.2) Decoded table is used to decode code lengths of symbols in resulting Huffman table. In worst case 3520 bits are read. */ -static BrotliDecoderErrorCode ReadHuffmanCode(uint32_t alphabet_size_max, - uint32_t alphabet_size_limit, +static BrotliDecoderErrorCode ReadHuffmanCode(brotli_reg_t alphabet_size_max, + brotli_reg_t alphabet_size_limit, HuffmanCode* table, - uint32_t* opt_table_size, + brotli_reg_t* opt_table_size, BrotliDecoderState* s) { BrotliBitReader* br = &s->br; BrotliMetablockHeaderArena* h = &s->arena.header; @@ -796,9 +800,9 @@ static BrotliDecoderErrorCode ReadHuffmanCode(uint32_t alphabet_size_max, /* Fall through. */ case BROTLI_STATE_HUFFMAN_SIMPLE_BUILD: { - uint32_t table_size; + brotli_reg_t table_size; if (h->symbol == 3) { - uint32_t bits; + brotli_reg_t bits; if (!BrotliSafeReadBits(br, 1, &bits)) { h->substate_huffman = BROTLI_STATE_HUFFMAN_SIMPLE_BUILD; return BROTLI_DECODER_NEEDS_MORE_INPUT; @@ -806,8 +810,9 @@ static BrotliDecoderErrorCode ReadHuffmanCode(uint32_t alphabet_size_max, h->symbol += bits; } BROTLI_LOG_UINT(h->symbol); - table_size = BrotliBuildSimpleHuffmanTable( - table, HUFFMAN_TABLE_BITS, h->symbols_lists_array, h->symbol); + table_size = BrotliBuildSimpleHuffmanTable(table, HUFFMAN_TABLE_BITS, + h->symbols_lists_array, + (uint32_t)h->symbol); if (opt_table_size) { *opt_table_size = table_size; } @@ -817,7 +822,7 @@ static BrotliDecoderErrorCode ReadHuffmanCode(uint32_t alphabet_size_max, /* Decode Huffman-coded code lengths. */ case BROTLI_STATE_HUFFMAN_COMPLEX: { - uint32_t i; + brotli_reg_t i; BrotliDecoderErrorCode result = ReadCodeLengthCodeLengths(s); if (result != BROTLI_DECODER_SUCCESS) { return result; @@ -841,7 +846,7 @@ static BrotliDecoderErrorCode ReadHuffmanCode(uint32_t alphabet_size_max, /* Fall through. */ case BROTLI_STATE_HUFFMAN_LENGTH_SYMBOLS: { - uint32_t table_size; + brotli_reg_t table_size; BrotliDecoderErrorCode result = ReadSymbolCodeLengths( alphabet_size_limit, s); if (result == BROTLI_DECODER_NEEDS_MORE_INPUT) { @@ -872,10 +877,10 @@ static BrotliDecoderErrorCode ReadHuffmanCode(uint32_t alphabet_size_max, } /* Decodes a block length by reading 3..39 bits. */ -static BROTLI_INLINE uint32_t ReadBlockLength(const HuffmanCode* table, - BrotliBitReader* br) { - uint32_t code; - uint32_t nbits; +static BROTLI_INLINE brotli_reg_t ReadBlockLength(const HuffmanCode* table, + BrotliBitReader* br) { + brotli_reg_t code; + brotli_reg_t nbits; code = ReadSymbol(table, br); nbits = _kBrotliPrefixCodeRanges[code].nbits; /* nbits == 2..24 */ return _kBrotliPrefixCodeRanges[code].offset + BrotliReadBits24(br, nbits); @@ -884,9 +889,9 @@ static BROTLI_INLINE uint32_t ReadBlockLength(const HuffmanCode* table, /* WARNING: if state is not BROTLI_STATE_READ_BLOCK_LENGTH_NONE, then reading can't be continued with ReadBlockLength. */ static BROTLI_INLINE BROTLI_BOOL SafeReadBlockLength( - BrotliDecoderState* s, uint32_t* result, const HuffmanCode* table, + BrotliDecoderState* s, brotli_reg_t* result, const HuffmanCode* table, BrotliBitReader* br) { - uint32_t index; + brotli_reg_t index; if (s->substate_read_block_length == BROTLI_STATE_READ_BLOCK_LENGTH_NONE) { if (!SafeReadSymbol(table, br, &index)) { return BROTLI_FALSE; @@ -895,9 +900,9 @@ static BROTLI_INLINE BROTLI_BOOL SafeReadBlockLength( index = s->block_length_index; } { - uint32_t bits; - uint32_t nbits = _kBrotliPrefixCodeRanges[index].nbits; - uint32_t offset = _kBrotliPrefixCodeRanges[index].offset; + brotli_reg_t bits; + brotli_reg_t nbits = _kBrotliPrefixCodeRanges[index].nbits; + brotli_reg_t offset = _kBrotliPrefixCodeRanges[index].offset; if (!BrotliSafeReadBits(br, nbits, &bits)) { s->block_length_index = index; s->substate_read_block_length = BROTLI_STATE_READ_BLOCK_LENGTH_SUFFIX; @@ -924,10 +929,10 @@ static BROTLI_INLINE BROTLI_BOOL SafeReadBlockLength( Most of input values are 0 and 1. To reduce number of branches, we replace inner for loop with do-while. */ static BROTLI_NOINLINE void InverseMoveToFrontTransform( - uint8_t* v, uint32_t v_len, BrotliDecoderState* state) { + uint8_t* v, brotli_reg_t v_len, BrotliDecoderState* state) { /* Reinitialize elements that could have been changed. */ - uint32_t i = 1; - uint32_t upper_bound = state->mtf_upper_bound; + brotli_reg_t i = 1; + brotli_reg_t upper_bound = state->mtf_upper_bound; uint32_t* mtf = &state->mtf[1]; /* Make mtf[-1] addressable. */ uint8_t* mtf_u8 = (uint8_t*)mtf; /* Load endian-aware constant. */ @@ -970,7 +975,7 @@ static BrotliDecoderErrorCode HuffmanTreeGroupDecode( h->substate_tree_group = BROTLI_STATE_TREE_GROUP_LOOP; } while (h->htree_index < group->num_htrees) { - uint32_t table_size; + brotli_reg_t table_size; BrotliDecoderErrorCode result = ReadHuffmanCode(group->alphabet_size_max, group->alphabet_size_limit, h->next, &table_size, s); if (result != BROTLI_DECODER_SUCCESS) return result; @@ -990,8 +995,8 @@ static BrotliDecoderErrorCode HuffmanTreeGroupDecode( This table will be used for reading context map items. 3) Read context map items; "0" values could be run-length encoded. 4) Optionally, apply InverseMoveToFront transform to the resulting map. */ -static BrotliDecoderErrorCode DecodeContextMap(uint32_t context_map_size, - uint32_t* num_htrees, +static BrotliDecoderErrorCode DecodeContextMap(brotli_reg_t context_map_size, + brotli_reg_t* num_htrees, uint8_t** context_map_arg, BrotliDecoderState* s) { BrotliBitReader* br = &s->br; @@ -1021,7 +1026,7 @@ static BrotliDecoderErrorCode DecodeContextMap(uint32_t context_map_size, /* Fall through. */ case BROTLI_STATE_CONTEXT_MAP_READ_PREFIX: { - uint32_t bits; + brotli_reg_t bits; /* In next stage ReadHuffmanCode uses at least 4 bits, so it is safe to peek 4 bits ahead. */ if (!BrotliSafeGetBits(br, 5, &bits)) { @@ -1040,7 +1045,7 @@ static BrotliDecoderErrorCode DecodeContextMap(uint32_t context_map_size, /* Fall through. */ case BROTLI_STATE_CONTEXT_MAP_HUFFMAN: { - uint32_t alphabet_size = *num_htrees + h->max_run_length_prefix; + brotli_reg_t alphabet_size = *num_htrees + h->max_run_length_prefix; result = ReadHuffmanCode(alphabet_size, alphabet_size, h->context_map_table, NULL, s); if (result != BROTLI_DECODER_SUCCESS) return result; @@ -1050,10 +1055,10 @@ static BrotliDecoderErrorCode DecodeContextMap(uint32_t context_map_size, /* Fall through. */ case BROTLI_STATE_CONTEXT_MAP_DECODE: { - uint32_t context_index = h->context_index; - uint32_t max_run_length_prefix = h->max_run_length_prefix; + brotli_reg_t context_index = h->context_index; + brotli_reg_t max_run_length_prefix = h->max_run_length_prefix; uint8_t* context_map = *context_map_arg; - uint32_t code = h->code; + brotli_reg_t code = h->code; BROTLI_BOOL skip_preamble = (code != 0xFFFF); while (context_index < context_map_size || skip_preamble) { if (!skip_preamble) { @@ -1078,7 +1083,7 @@ static BrotliDecoderErrorCode DecodeContextMap(uint32_t context_map_size, } /* RLE sub-stage. */ { - uint32_t reps; + brotli_reg_t reps; if (!BrotliSafeReadBits(br, code, &reps)) { h->code = code; h->context_index = context_index; @@ -1099,7 +1104,7 @@ static BrotliDecoderErrorCode DecodeContextMap(uint32_t context_map_size, /* Fall through. */ case BROTLI_STATE_CONTEXT_MAP_TRANSFORM: { - uint32_t bits; + brotli_reg_t bits; if (!BrotliSafeReadBits(br, 1, &bits)) { h->substate_context_map = BROTLI_STATE_CONTEXT_MAP_TRANSFORM; return BROTLI_DECODER_NEEDS_MORE_INPUT; @@ -1121,14 +1126,14 @@ static BrotliDecoderErrorCode DecodeContextMap(uint32_t context_map_size, Reads 3..54 bits. */ static BROTLI_INLINE BROTLI_BOOL DecodeBlockTypeAndLength( int safe, BrotliDecoderState* s, int tree_type) { - uint32_t max_block_type = s->num_block_types[tree_type]; + brotli_reg_t max_block_type = s->num_block_types[tree_type]; const HuffmanCode* type_tree = &s->block_type_trees[ tree_type * BROTLI_HUFFMAN_MAX_SIZE_258]; const HuffmanCode* len_tree = &s->block_len_trees[ tree_type * BROTLI_HUFFMAN_MAX_SIZE_26]; BrotliBitReader* br = &s->br; - uint32_t* ringbuffer = &s->block_type_rb[tree_type * 2]; - uint32_t block_type; + brotli_reg_t* ringbuffer = &s->block_type_rb[tree_type * 2]; + brotli_reg_t block_type; if (max_block_type <= 1) { return BROTLI_FALSE; } @@ -1173,6 +1178,7 @@ static BROTLI_INLINE void DetectTrivialLiteralBlockTypes( size_t sample = s->context_map[offset]; size_t j; for (j = 0; j < (1u << BROTLI_LITERAL_CONTEXT_BITS);) { + /* NOLINTNEXTLINE(bugprone-macro-repeated-side-effects) */ BROTLI_REPEAT_4({ error |= s->context_map[offset + j++] ^ sample; }) } if (error == 0) { @@ -1184,8 +1190,8 @@ static BROTLI_INLINE void DetectTrivialLiteralBlockTypes( static BROTLI_INLINE void PrepareLiteralDecoding(BrotliDecoderState* s) { uint8_t context_mode; size_t trivial; - uint32_t block_type = s->block_type_rb[1]; - uint32_t context_offset = block_type << BROTLI_LITERAL_CONTEXT_BITS; + brotli_reg_t block_type = s->block_type_rb[1]; + brotli_reg_t context_offset = block_type << BROTLI_LITERAL_CONTEXT_BITS; s->context_map_slice = s->context_map + context_offset; trivial = s->trivial_literal_contexts[block_type >> 5]; s->trivial_literal_context = (trivial >> (block_type & 31)) & 1; @@ -1549,8 +1555,8 @@ static int CopyFromCompoundDictionary(BrotliDecoderState* s, int pos) { BROTLI_BOOL BrotliDecoderAttachDictionary( BrotliDecoderState* state, BrotliSharedDictionaryType type, size_t data_size, const uint8_t data[BROTLI_ARRAY_PARAM(data_size)]) { - uint32_t i; - uint32_t num_prefix_before = state->dictionary->num_prefix; + brotli_reg_t i; + brotli_reg_t num_prefix_before = state->dictionary->num_prefix; if (state->state != BROTLI_STATE_UNINITED) return BROTLI_FALSE; if (!BrotliSharedDictionaryAttach(state->dictionary, type, data_size, data)) { return BROTLI_FALSE; @@ -1616,7 +1622,7 @@ static BrotliDecoderErrorCode ReadContextModes(BrotliDecoderState* s) { int i = s->loop_counter; while (i < (int)s->num_block_types[0]) { - uint32_t bits; + brotli_reg_t bits; if (!BrotliSafeReadBits(br, 2, &bits)) { s->loop_counter = i; return BROTLI_DECODER_NEEDS_MORE_INPUT; @@ -1656,7 +1662,7 @@ static BROTLI_INLINE void TakeDistanceFromRingBuffer(BrotliDecoderState* s) { } static BROTLI_INLINE BROTLI_BOOL SafeReadBits( - BrotliBitReader* const br, uint32_t n_bits, uint32_t* val) { + BrotliBitReader* const br, brotli_reg_t n_bits, brotli_reg_t* val) { if (n_bits != 0) { return BrotliSafeReadBits(br, n_bits, val); } else { @@ -1666,7 +1672,7 @@ static BROTLI_INLINE BROTLI_BOOL SafeReadBits( } static BROTLI_INLINE BROTLI_BOOL SafeReadBits32( - BrotliBitReader* const br, uint32_t n_bits, uint32_t* val) { + BrotliBitReader* const br, brotli_reg_t n_bits, brotli_reg_t* val) { if (n_bits != 0) { return BrotliSafeReadBits32(br, n_bits, val); } else { @@ -1744,16 +1750,16 @@ static BROTLI_INLINE BROTLI_BOOL SafeReadBits32( NB: it is possible to have all 64 tables precalculated. */ static void CalculateDistanceLut(BrotliDecoderState* s) { BrotliMetablockBodyArena* b = &s->arena.body; - uint32_t npostfix = s->distance_postfix_bits; - uint32_t ndirect = s->num_direct_distance_codes; - uint32_t alphabet_size_limit = s->distance_hgroup.alphabet_size_limit; - uint32_t postfix = 1u << npostfix; - uint32_t j; - uint32_t bits = 1; - uint32_t half = 0; + brotli_reg_t npostfix = s->distance_postfix_bits; + brotli_reg_t ndirect = s->num_direct_distance_codes; + brotli_reg_t alphabet_size_limit = s->distance_hgroup.alphabet_size_limit; + brotli_reg_t postfix = 1u << npostfix; + brotli_reg_t j; + brotli_reg_t bits = 1; + brotli_reg_t half = 0; /* Skip short codes. */ - uint32_t i = BROTLI_NUM_DISTANCE_SHORT_CODES; + brotli_reg_t i = BROTLI_NUM_DISTANCE_SHORT_CODES; /* Fill direct codes. */ for (j = 0; j < ndirect; ++j) { @@ -1764,7 +1770,7 @@ static void CalculateDistanceLut(BrotliDecoderState* s) { /* Fill regular distance codes. */ while (i < alphabet_size_limit) { - uint32_t base = ndirect + ((((2 + half) << bits) - 4) << npostfix) + 1; + brotli_reg_t base = ndirect + ((((2 + half) << bits) - 4) << npostfix) + 1; /* Always fill the complete group. */ for (j = 0; j < postfix; ++j) { b->dist_extra_bits[i] = (uint8_t)bits; @@ -1780,8 +1786,8 @@ static void CalculateDistanceLut(BrotliDecoderState* s) { static BROTLI_INLINE BROTLI_BOOL ReadDistanceInternal( int safe, BrotliDecoderState* s, BrotliBitReader* br) { BrotliMetablockBodyArena* b = &s->arena.body; - uint32_t code; - uint32_t bits; + brotli_reg_t code; + brotli_reg_t bits; BrotliBitReaderState memento; HuffmanCode* distance_tree = s->distance_hgroup.htrees[s->dist_htree_index]; if (!safe) { @@ -1827,9 +1833,9 @@ static BROTLI_INLINE BROTLI_BOOL SafeReadDistance( static BROTLI_INLINE BROTLI_BOOL ReadCommandInternal( int safe, BrotliDecoderState* s, BrotliBitReader* br, int* insert_length) { - uint32_t cmd_code; - uint32_t insert_len_extra = 0; - uint32_t copy_length; + brotli_reg_t cmd_code; + brotli_reg_t insert_len_extra = 0; + brotli_reg_t copy_length; CmdLutElement v; BrotliBitReaderState memento; if (!safe) { @@ -1874,11 +1880,11 @@ static BROTLI_INLINE BROTLI_BOOL SafeReadCommand( } static BROTLI_INLINE BROTLI_BOOL CheckInputAmount( - int safe, BrotliBitReader* const br, size_t num) { + int safe, BrotliBitReader* const br) { if (safe) { return BROTLI_TRUE; } - return BrotliCheckInputAmount(br, num); + return BrotliCheckInputAmount(br); } #define BROTLI_SAFE(METHOD) \ @@ -1901,7 +1907,7 @@ static BROTLI_INLINE BrotliDecoderErrorCode ProcessCommandsInternal( BrotliBitReader* br = &s->br; int compound_dictionary_size = GetCompoundDictionarySize(s); - if (!CheckInputAmount(safe, br, 28)) { + if (!CheckInputAmount(safe, br)) { result = BROTLI_DECODER_NEEDS_MORE_INPUT; goto saveStateAndReturn; } @@ -1926,7 +1932,7 @@ CommandBegin: if (safe) { s->state = BROTLI_STATE_COMMAND_BEGIN; } - if (!CheckInputAmount(safe, br, 28)) { /* 156 bits + 7 bytes */ + if (!CheckInputAmount(safe, br)) { s->state = BROTLI_STATE_COMMAND_BEGIN; result = BROTLI_DECODER_NEEDS_MORE_INPUT; goto saveStateAndReturn; @@ -1950,25 +1956,23 @@ CommandInner: } /* Read the literals in the command. */ if (s->trivial_literal_context) { - uint32_t bits; - uint32_t value; + brotli_reg_t bits; + brotli_reg_t value; PreloadSymbol(safe, s->literal_htree, br, &bits, &value); do { - if (!CheckInputAmount(safe, br, 28)) { /* 162 bits + 7 bytes */ + if (!CheckInputAmount(safe, br)) { s->state = BROTLI_STATE_COMMAND_INNER; result = BROTLI_DECODER_NEEDS_MORE_INPUT; goto saveStateAndReturn; } if (BROTLI_PREDICT_FALSE(s->block_length[0] == 0)) { - BROTLI_SAFE(DecodeLiteralBlockSwitch(s)); - PreloadSymbol(safe, s->literal_htree, br, &bits, &value); - if (!s->trivial_literal_context) goto CommandInner; + goto NextLiteralBlock; } if (!safe) { s->ringbuffer[pos] = (uint8_t)ReadPreloadedSymbol(s->literal_htree, br, &bits, &value); } else { - uint32_t literal; + brotli_reg_t literal; if (!SafeReadSymbol(s->literal_htree, br, &literal)) { result = BROTLI_DECODER_NEEDS_MORE_INPUT; goto saveStateAndReturn; @@ -1990,14 +1994,13 @@ CommandInner: do { const HuffmanCode* hc; uint8_t context; - if (!CheckInputAmount(safe, br, 28)) { /* 162 bits + 7 bytes */ + if (!CheckInputAmount(safe, br)) { s->state = BROTLI_STATE_COMMAND_INNER; result = BROTLI_DECODER_NEEDS_MORE_INPUT; goto saveStateAndReturn; } if (BROTLI_PREDICT_FALSE(s->block_length[0] == 0)) { - BROTLI_SAFE(DecodeLiteralBlockSwitch(s)); - if (s->trivial_literal_context) goto CommandInner; + goto NextLiteralBlock; } context = BROTLI_CONTEXT(p1, p2, s->context_lookup); BROTLI_LOG_UINT(context); @@ -2006,7 +2009,7 @@ CommandInner: if (!safe) { p1 = (uint8_t)ReadSymbol(hc, br); } else { - uint32_t literal; + brotli_reg_t literal; if (!SafeReadSymbol(hc, br, &literal)) { result = BROTLI_DECODER_NEEDS_MORE_INPUT; goto saveStateAndReturn; @@ -2087,7 +2090,7 @@ CommandPostDecodeLiterals: const BrotliDictionary* words = s->dictionary->words[dict_id]; const BrotliTransforms* transforms = s->dictionary->transforms[dict_id]; int offset = (int)words->offsets_by_length[i]; - uint32_t shift = words->size_bits_by_length[i]; + brotli_reg_t shift = words->size_bits_by_length[i]; int address = s->distance_code - s->max_distance - 1 - compound_dictionary_size; int mask = (int)BitMask(shift); @@ -2110,7 +2113,7 @@ CommandPostDecodeLiterals: if (dict_id2 != dict_id && words2->size_bits_by_length[i] != 0) { const BrotliTransforms* transforms2 = s->dictionary->transforms[dict_id2]; - uint32_t shift2 = words2->size_bits_by_length[i]; + brotli_reg_t shift2 = words2->size_bits_by_length[i]; int num = (int)((1u << shift2) & ~1u) * (int)transforms2->num_transforms; if (dist_remaining < num) { @@ -2236,6 +2239,10 @@ CommandPostWrapCopy: goto CommandBegin; } +NextLiteralBlock: + BROTLI_SAFE(DecodeLiteralBlockSwitch(s)); + goto CommandInner; + saveStateAndReturn: s->pos = pos; s->loop_counter = i; @@ -2312,14 +2319,13 @@ BrotliDecoderResult BrotliDecoderDecompressStream( } if (!*available_out) next_out = 0; if (s->buffer_length == 0) { /* Just connect bit reader to input stream. */ - br->avail_in = *available_in; - br->next_in = *next_in; + BrotliBitReaderSetInput(br, *next_in, *available_in); } else { /* At least one byte of input is required. More than one byte of input may be required to complete the transaction -> reading more data must be done in a loop -> do it in a main loop. */ result = BROTLI_DECODER_NEEDS_MORE_INPUT; - br->next_in = &s->buffer.u8[0]; + BrotliBitReaderSetInput(br, &s->buffer.u8[0], s->buffer_length); } /* State machine */ for (;;) { @@ -2336,23 +2342,23 @@ BrotliDecoderResult BrotliDecoderDecompressStream( } } if (s->buffer_length != 0) { /* Used with internal buffer. */ - if (br->avail_in == 0) { + if (br->next_in == br->last_in) { /* Successfully finished read transaction. Accumulator contains less than 8 bits, because internal buffer is expanded byte-by-byte until it is enough to complete read. */ s->buffer_length = 0; /* Switch to input stream and restart. */ result = BROTLI_DECODER_SUCCESS; - br->avail_in = *available_in; - br->next_in = *next_in; + BrotliBitReaderSetInput(br, *next_in, *available_in); continue; } else if (*available_in != 0) { /* Not enough data in buffer, but can take one more byte from input stream. */ result = BROTLI_DECODER_SUCCESS; + BROTLI_DCHECK(s->buffer_length < 8); s->buffer.u8[s->buffer_length] = **next_in; s->buffer_length++; - br->avail_in = s->buffer_length; + BrotliBitReaderSetInput(br, &s->buffer.u8[0], s->buffer_length); (*next_in)++; (*available_in)--; /* Retry with more data in buffer. */ @@ -2363,7 +2369,7 @@ BrotliDecoderResult BrotliDecoderDecompressStream( } else { /* Input stream doesn't contain enough input. */ /* Copy tail to internal buffer and return. */ *next_in = br->next_in; - *available_in = br->avail_in; + *available_in = BrotliBitReaderGetAvailIn(br); while (*available_in) { s->buffer.u8[s->buffer_length] = **next_in; s->buffer_length++; @@ -2386,7 +2392,7 @@ BrotliDecoderResult BrotliDecoderDecompressStream( stream it has less than 8 bits in accumulator, so it is safe to return unused accumulator bits there. */ BrotliBitReaderUnload(br); - *available_in = br->avail_in; + *available_in = BrotliBitReaderGetAvailIn(br); *next_in = br->next_in; } break; @@ -2410,17 +2416,20 @@ BrotliDecoderResult BrotliDecoderDecompressStream( s->state = BROTLI_STATE_INITIALIZE; break; - case BROTLI_STATE_LARGE_WINDOW_BITS: - if (!BrotliSafeReadBits(br, 6, &s->window_bits)) { + case BROTLI_STATE_LARGE_WINDOW_BITS: { + brotli_reg_t bits; + if (!BrotliSafeReadBits(br, 6, &bits)) { result = BROTLI_DECODER_NEEDS_MORE_INPUT; break; } + s->window_bits = bits & 63u; if (s->window_bits < BROTLI_LARGE_MIN_WBITS || s->window_bits > BROTLI_LARGE_MAX_WBITS) { result = BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS); break; } s->state = BROTLI_STATE_INITIALIZE; + } /* Fall through. */ case BROTLI_STATE_INITIALIZE: @@ -2518,7 +2527,7 @@ BrotliDecoderResult BrotliDecoderDecompressStream( /* Fall through. */ case BROTLI_STATE_HUFFMAN_CODE_1: { - uint32_t alphabet_size = s->num_block_types[s->loop_counter] + 2; + brotli_reg_t alphabet_size = s->num_block_types[s->loop_counter] + 2; int tree_offset = s->loop_counter * BROTLI_HUFFMAN_MAX_SIZE_258; result = ReadHuffmanCode(alphabet_size, alphabet_size, &s->block_type_trees[tree_offset], NULL, s); @@ -2528,7 +2537,7 @@ BrotliDecoderResult BrotliDecoderDecompressStream( /* Fall through. */ case BROTLI_STATE_HUFFMAN_CODE_2: { - uint32_t alphabet_size = BROTLI_NUM_BLOCK_LEN_SYMBOLS; + brotli_reg_t alphabet_size = BROTLI_NUM_BLOCK_LEN_SYMBOLS; int tree_offset = s->loop_counter * BROTLI_HUFFMAN_MAX_SIZE_26; result = ReadHuffmanCode(alphabet_size, alphabet_size, &s->block_len_trees[tree_offset], NULL, s); @@ -2569,7 +2578,7 @@ BrotliDecoderResult BrotliDecoderDecompressStream( break; case BROTLI_STATE_METABLOCK_HEADER_2: { - uint32_t bits; + brotli_reg_t bits; if (!BrotliSafeReadBits(br, 6, &bits)) { result = BROTLI_DECODER_NEEDS_MORE_INPUT; break; @@ -2610,15 +2619,16 @@ BrotliDecoderResult BrotliDecoderDecompressStream( /* Fall through. */ case BROTLI_STATE_CONTEXT_MAP_2: { - uint32_t npostfix = s->distance_postfix_bits; - uint32_t ndirect = s->num_direct_distance_codes; - uint32_t distance_alphabet_size_max = BROTLI_DISTANCE_ALPHABET_SIZE( + brotli_reg_t npostfix = s->distance_postfix_bits; + brotli_reg_t ndirect = s->num_direct_distance_codes; + brotli_reg_t distance_alphabet_size_max = BROTLI_DISTANCE_ALPHABET_SIZE( npostfix, ndirect, BROTLI_MAX_DISTANCE_BITS); - uint32_t distance_alphabet_size_limit = distance_alphabet_size_max; + brotli_reg_t distance_alphabet_size_limit = distance_alphabet_size_max; BROTLI_BOOL allocation_success = BROTLI_TRUE; if (s->large_window) { BrotliDistanceCodeLimit limit = BrotliCalculateDistanceCodeLimit( - BROTLI_MAX_ALLOWED_DISTANCE, npostfix, ndirect); + BROTLI_MAX_ALLOWED_DISTANCE, (uint32_t)npostfix, + (uint32_t)ndirect); distance_alphabet_size_max = BROTLI_DISTANCE_ALPHABET_SIZE( npostfix, ndirect, BROTLI_LARGE_MAX_DISTANCE_BITS); distance_alphabet_size_limit = limit.max_alphabet_size; @@ -2749,7 +2759,7 @@ BrotliDecoderResult BrotliDecoderDecompressStream( } if (s->buffer_length == 0) { BrotliBitReaderUnload(br); - *available_in = br->avail_in; + *available_in = BrotliBitReaderGetAvailIn(br); *next_in = br->next_in; } s->state = BROTLI_STATE_DONE; @@ -2821,7 +2831,7 @@ BrotliDecoderErrorCode BrotliDecoderGetErrorCode(const BrotliDecoderState* s) { const char* BrotliDecoderErrorString(BrotliDecoderErrorCode c) { switch (c) { #define BROTLI_ERROR_CODE_CASE_(PREFIX, NAME, CODE) \ - case BROTLI_DECODER ## PREFIX ## NAME: return #NAME; + case BROTLI_DECODER ## PREFIX ## NAME: return #PREFIX #NAME; #define BROTLI_NOTHING_ BROTLI_DECODER_ERROR_CODES_LIST(BROTLI_ERROR_CODE_CASE_, BROTLI_NOTHING_) #undef BROTLI_ERROR_CODE_CASE_ @@ -2846,16 +2856,16 @@ void BrotliDecoderSetMetadataCallbacks( /* Escalate internal functions visibility; for testing purposes only. */ #if defined(BROTLI_TEST) BROTLI_BOOL SafeReadSymbolForTest( - const HuffmanCode*, BrotliBitReader*, uint32_t*); + const HuffmanCode*, BrotliBitReader*, brotli_reg_t*); BROTLI_BOOL SafeReadSymbolForTest( - const HuffmanCode* table, BrotliBitReader* br, uint32_t* result) { + const HuffmanCode* table, BrotliBitReader* br, brotli_reg_t* result) { return SafeReadSymbol(table, br, result); } void InverseMoveToFrontTransformForTest( - uint8_t*, uint32_t, BrotliDecoderState*); + uint8_t*, brotli_reg_t, BrotliDecoderState*); void InverseMoveToFrontTransformForTest( - uint8_t* v, uint32_t l, BrotliDecoderState* s) { + uint8_t* v, brotli_reg_t l, BrotliDecoderState* s) { InverseMoveToFrontTransform(v, l, s); } #endif diff --git a/thirdparty/brotli/dec/state.c b/thirdparty/brotli/dec/state.c index a3baf37b6d..be6a26680b 100644 --- a/thirdparty/brotli/dec/state.c +++ b/thirdparty/brotli/dec/state.c @@ -98,9 +98,9 @@ BROTLI_BOOL BrotliDecoderStateInit(BrotliDecoderState* s, void BrotliDecoderStateMetablockBegin(BrotliDecoderState* s) { s->meta_block_remaining_len = 0; - s->block_length[0] = 1U << 24; - s->block_length[1] = 1U << 24; - s->block_length[2] = 1U << 24; + s->block_length[0] = BROTLI_BLOCK_SIZE_CAP; + s->block_length[1] = BROTLI_BLOCK_SIZE_CAP; + s->block_length[2] = BROTLI_BLOCK_SIZE_CAP; s->num_block_types[0] = 1; s->num_block_types[1] = 1; s->num_block_types[2] = 1; @@ -158,8 +158,8 @@ void BrotliDecoderStateCleanup(BrotliDecoderState* s) { } BROTLI_BOOL BrotliDecoderHuffmanTreeGroupInit(BrotliDecoderState* s, - HuffmanTreeGroup* group, uint32_t alphabet_size_max, - uint32_t alphabet_size_limit, uint32_t ntrees) { + HuffmanTreeGroup* group, brotli_reg_t alphabet_size_max, + brotli_reg_t alphabet_size_limit, brotli_reg_t ntrees) { /* 376 = 256 (1-st level table) + 4 + 7 + 15 + 31 + 63 (2-nd level mix-tables) This number is discovered "unlimited" "enough" calculator; it is actually a wee bigger than required in several cases (especially for alphabets with diff --git a/thirdparty/brotli/dec/state.h b/thirdparty/brotli/dec/state.h index 84fddc8a72..fd250b6842 100644 --- a/thirdparty/brotli/dec/state.h +++ b/thirdparty/brotli/dec/state.h @@ -211,15 +211,15 @@ typedef struct BrotliMetablockHeaderArena { BrotliRunningContextMapState substate_context_map; BrotliRunningHuffmanState substate_huffman; - uint32_t sub_loop_counter; + brotli_reg_t sub_loop_counter; - uint32_t repeat_code_len; - uint32_t prev_code_len; + brotli_reg_t repeat_code_len; + brotli_reg_t prev_code_len; /* For ReadHuffmanCode. */ - uint32_t symbol; - uint32_t repeat; - uint32_t space; + brotli_reg_t symbol; + brotli_reg_t repeat; + brotli_reg_t space; /* Huffman table for "histograms". */ HuffmanCode table[32]; @@ -233,21 +233,22 @@ typedef struct BrotliMetablockHeaderArena { uint8_t code_length_code_lengths[BROTLI_CODE_LENGTH_CODES]; /* Population counts for the code lengths. */ uint16_t code_length_histo[16]; + /* TODO(eustas): +2 bytes padding */ /* For HuffmanTreeGroupDecode. */ int htree_index; HuffmanCode* next; /* For DecodeContextMap. */ - uint32_t context_index; - uint32_t max_run_length_prefix; - uint32_t code; + brotli_reg_t context_index; + brotli_reg_t max_run_length_prefix; + brotli_reg_t code; HuffmanCode context_map_table[BROTLI_HUFFMAN_MAX_SIZE_272]; } BrotliMetablockHeaderArena; typedef struct BrotliMetablockBodyArena { uint8_t dist_extra_bits[544]; - uint32_t dist_offset[544]; + brotli_reg_t dist_offset[544]; } BrotliMetablockBodyArena; struct BrotliDecoderStateStruct { @@ -268,7 +269,7 @@ struct BrotliDecoderStateStruct { uint64_t u64; uint8_t u8[8]; } buffer; - uint32_t buffer_length; + brotli_reg_t buffer_length; int pos; int max_backward_distance; @@ -278,6 +279,8 @@ struct BrotliDecoderStateStruct { int dist_rb_idx; int dist_rb[4]; int error_code; + int meta_block_remaining_len; + uint8_t* ringbuffer; uint8_t* ringbuffer_end; HuffmanCode* htree_command; @@ -298,29 +301,30 @@ struct BrotliDecoderStateStruct { /* Distance context is actual after command is decoded and before distance is computed. After distance computation it is used as a temporary variable. */ int distance_context; - int meta_block_remaining_len; - uint32_t block_length_index; - uint32_t block_length[3]; - uint32_t num_block_types[3]; - uint32_t block_type_rb[6]; - uint32_t distance_postfix_bits; - uint32_t num_direct_distance_codes; - uint32_t num_dist_htrees; + brotli_reg_t block_length[3]; + brotli_reg_t block_length_index; + brotli_reg_t num_block_types[3]; + brotli_reg_t block_type_rb[6]; + brotli_reg_t distance_postfix_bits; + brotli_reg_t num_direct_distance_codes; + brotli_reg_t num_dist_htrees; uint8_t* dist_context_map; HuffmanCode* literal_htree; - uint8_t dist_htree_index; - - int copy_length; - int distance_code; /* For partial write operations. */ size_t rb_roundtrips; /* how many times we went around the ring-buffer */ size_t partial_pos_out; /* how much output to the user in total */ /* For InverseMoveToFrontTransform. */ - uint32_t mtf_upper_bound; + brotli_reg_t mtf_upper_bound; uint32_t mtf[64 + 1]; + int copy_length; + int distance_code; + + uint8_t dist_htree_index; + /* TODO(eustas): +3 bytes padding */ + /* Less used attributes are at the end of this struct. */ brotli_decoder_metadata_start_func metadata_start_func; @@ -336,18 +340,20 @@ struct BrotliDecoderStateStruct { BrotliRunningDecodeUint8State substate_decode_uint8; BrotliRunningReadBlockLengthState substate_read_block_length; + int new_ringbuffer_size; + /* TODO(eustas): +4 bytes padding */ + unsigned int is_last_metablock : 1; unsigned int is_uncompressed : 1; unsigned int is_metadata : 1; unsigned int should_wrap_ringbuffer : 1; unsigned int canny_ringbuffer_allocation : 1; unsigned int large_window : 1; + unsigned int window_bits : 6; unsigned int size_nibbles : 8; - uint32_t window_bits; - - int new_ringbuffer_size; + /* TODO(eustas): +12 bits padding */ - uint32_t num_literal_htrees; + brotli_reg_t num_literal_htrees; uint8_t* context_map; uint8_t* context_modes; @@ -372,8 +378,9 @@ BROTLI_INTERNAL void BrotliDecoderStateMetablockBegin(BrotliDecoderState* s); BROTLI_INTERNAL void BrotliDecoderStateCleanupAfterMetablock( BrotliDecoderState* s); BROTLI_INTERNAL BROTLI_BOOL BrotliDecoderHuffmanTreeGroupInit( - BrotliDecoderState* s, HuffmanTreeGroup* group, uint32_t alphabet_size_max, - uint32_t alphabet_size_limit, uint32_t ntrees); + BrotliDecoderState* s, HuffmanTreeGroup* group, + brotli_reg_t alphabet_size_max, brotli_reg_t alphabet_size_limit, + brotli_reg_t ntrees); #define BROTLI_DECODER_ALLOC(S, L) S->alloc_func(S->memory_manager_opaque, L) @@ -382,6 +389,10 @@ BROTLI_INTERNAL BROTLI_BOOL BrotliDecoderHuffmanTreeGroupInit( X = NULL; \ } +/* Literal/Command/Distance block size maximum; same as maximum metablock size; + used as block size when there is no block switching. */ +#define BROTLI_BLOCK_SIZE_CAP (1U << 24) + #if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ #endif diff --git a/thirdparty/brotli/include/brotli/decode.h b/thirdparty/brotli/include/brotli/decode.h index 3c473d611e..af1aa23f60 100644 --- a/thirdparty/brotli/include/brotli/decode.h +++ b/thirdparty/brotli/include/brotli/decode.h @@ -357,7 +357,7 @@ BROTLI_DEC_API const char* BrotliDecoderErrorString(BrotliDecoderErrorCode c); /** * Gets a decoder library version. * - * Look at BROTLI_VERSION for more information. + * Look at BROTLI_MAKE_HEX_VERSION for more information. */ BROTLI_DEC_API uint32_t BrotliDecoderVersion(void); diff --git a/thirdparty/brotli/include/brotli/encode.h b/thirdparty/brotli/include/brotli/encode.h index 7247d3d698..dea9931ebb 100644 --- a/thirdparty/brotli/include/brotli/encode.h +++ b/thirdparty/brotli/include/brotli/encode.h @@ -490,7 +490,7 @@ BROTLI_ENC_EXTRA_API size_t BrotliEncoderGetPreparedDictionarySize( /** * Gets an encoder library version. * - * Look at BROTLI_VERSION for more information. + * Look at BROTLI_MAKE_HEX_VERSION for more information. */ BROTLI_ENC_API uint32_t BrotliEncoderVersion(void); diff --git a/thirdparty/brotli/include/brotli/shared_dictionary.h b/thirdparty/brotli/include/brotli/shared_dictionary.h index ceb6cf1cd2..2970c2dcc9 100644 --- a/thirdparty/brotli/include/brotli/shared_dictionary.h +++ b/thirdparty/brotli/include/brotli/shared_dictionary.h @@ -35,7 +35,10 @@ typedef struct BrotliSharedDictionaryStruct BrotliSharedDictionary; typedef enum BrotliSharedDictionaryType { /** Raw LZ77 prefix dictionary. */ BROTLI_SHARED_DICTIONARY_RAW = 0, - /** Serialized shared dictionary. */ + /** Serialized shared dictionary. + * + * DO NOT USE: methods accepting this value will fail. + */ BROTLI_SHARED_DICTIONARY_SERIALIZED = 1 } BrotliSharedDictionaryType; diff --git a/thirdparty/openxr/include/openxr/openxr.h b/thirdparty/openxr/include/openxr/openxr.h index 1faee71082..5d953fb9ba 100644 --- a/thirdparty/openxr/include/openxr/openxr.h +++ b/thirdparty/openxr/include/openxr/openxr.h @@ -25,7 +25,7 @@ extern "C" { ((((major) & 0xffffULL) << 48) | (((minor) & 0xffffULL) << 32) | ((patch) & 0xffffffffULL)) // OpenXR current version number. -#define XR_CURRENT_API_VERSION XR_MAKE_VERSION(1, 0, 30) +#define XR_CURRENT_API_VERSION XR_MAKE_VERSION(1, 0, 28) #define XR_VERSION_MAJOR(version) (uint16_t)(((uint64_t)(version) >> 48)& 0xffffULL) #define XR_VERSION_MINOR(version) (uint16_t)(((uint64_t)(version) >> 32) & 0xffffULL) @@ -491,7 +491,6 @@ typedef enum XrStructureType { XR_TYPE_DEVICE_PCM_SAMPLE_RATE_STATE_FB = 1000209002, XR_TYPE_COMPOSITION_LAYER_DEPTH_TEST_FB = 1000212000, XR_TYPE_LOCAL_DIMMING_FRAME_END_INFO_META = 1000216000, - XR_TYPE_PASSTHROUGH_PREFERENCES_META = 1000217000, XR_TYPE_SYSTEM_VIRTUAL_KEYBOARD_PROPERTIES_META = 1000219001, XR_TYPE_VIRTUAL_KEYBOARD_CREATE_INFO_META = 1000219002, XR_TYPE_VIRTUAL_KEYBOARD_SPACE_CREATE_INFO_META = 1000219003, @@ -1800,7 +1799,7 @@ XRAPI_ATTR XrResult XRAPI_CALL xrThermalGetTemperatureTrendEXT( #define XR_EXT_debug_utils 1 XR_DEFINE_HANDLE(XrDebugUtilsMessengerEXT) -#define XR_EXT_debug_utils_SPEC_VERSION 5 +#define XR_EXT_debug_utils_SPEC_VERSION 4 #define XR_EXT_DEBUG_UTILS_EXTENSION_NAME "XR_EXT_debug_utils" typedef XrFlags64 XrDebugUtilsMessageSeverityFlagsEXT; @@ -2116,9 +2115,9 @@ XRAPI_ATTR XrResult XRAPI_CALL xrSetInputDeviceLocationEXT( #define XR_MSFT_spatial_graph_bridge 1 XR_DEFINE_HANDLE(XrSpatialGraphNodeBindingMSFT) -#define XR_GUID_SIZE_MSFT 16 #define XR_MSFT_spatial_graph_bridge_SPEC_VERSION 2 #define XR_MSFT_SPATIAL_GRAPH_BRIDGE_EXTENSION_NAME "XR_MSFT_spatial_graph_bridge" +#define XR_GUID_SIZE_MSFT 16 typedef enum XrSpatialGraphNodeTypeMSFT { XR_SPATIAL_GRAPH_NODE_TYPE_STATIC_MSFT = 1, @@ -2454,9 +2453,9 @@ typedef struct XrSecondaryViewConfigurationSwapchainCreateInfoMSFT { #define XR_NULL_CONTROLLER_MODEL_KEY_MSFT 0 XR_DEFINE_ATOM(XrControllerModelKeyMSFT) -#define XR_MAX_CONTROLLER_MODEL_NODE_NAME_SIZE_MSFT 64 #define XR_MSFT_controller_model_SPEC_VERSION 2 #define XR_MSFT_CONTROLLER_MODEL_EXTENSION_NAME "XR_MSFT_controller_model" +#define XR_MAX_CONTROLLER_MODEL_NODE_NAME_SIZE_MSFT 64 typedef struct XrControllerModelKeyStateMSFT { XrStructureType type; void* XR_MAY_ALIAS next; @@ -3267,7 +3266,7 @@ XRAPI_ATTR XrResult XRAPI_CALL xrRequestDisplayRefreshRateFB( #define XR_HTCX_vive_tracker_interaction 1 -#define XR_HTCX_vive_tracker_interaction_SPEC_VERSION 3 +#define XR_HTCX_vive_tracker_interaction_SPEC_VERSION 2 #define XR_HTCX_VIVE_TRACKER_INTERACTION_EXTENSION_NAME "XR_HTCX_vive_tracker_interaction" typedef struct XrViveTrackerPathsHTCX { XrStructureType type; @@ -3452,7 +3451,7 @@ typedef struct XrSystemColorSpacePropertiesFB { } XrSystemColorSpacePropertiesFB; typedef XrResult (XRAPI_PTR *PFN_xrEnumerateColorSpacesFB)(XrSession session, uint32_t colorSpaceCapacityInput, uint32_t* colorSpaceCountOutput, XrColorSpaceFB* colorSpaces); -typedef XrResult (XRAPI_PTR *PFN_xrSetColorSpaceFB)(XrSession session, const XrColorSpaceFB colorSpace); +typedef XrResult (XRAPI_PTR *PFN_xrSetColorSpaceFB)(XrSession session, const XrColorSpaceFB colorspace); #ifndef XR_NO_PROTOTYPES #ifdef XR_EXTENSION_PROTOTYPES @@ -3464,7 +3463,7 @@ XRAPI_ATTR XrResult XRAPI_CALL xrEnumerateColorSpacesFB( XRAPI_ATTR XrResult XRAPI_CALL xrSetColorSpaceFB( XrSession session, - const XrColorSpaceFB colorSpace); + const XrColorSpaceFB colorspace); #endif /* XR_EXTENSION_PROTOTYPES */ #endif /* !XR_NO_PROTOTYPES */ @@ -3757,9 +3756,9 @@ typedef struct XrFoveationLevelProfileCreateInfoFB { #define XR_FB_keyboard_tracking 1 -#define XR_MAX_KEYBOARD_TRACKING_NAME_SIZE_FB 128 #define XR_FB_keyboard_tracking_SPEC_VERSION 1 #define XR_FB_KEYBOARD_TRACKING_EXTENSION_NAME "XR_FB_keyboard_tracking" +#define XR_MAX_KEYBOARD_TRACKING_NAME_SIZE_FB 128 typedef XrFlags64 XrKeyboardTrackingFlagsFB; // Flag bits for XrKeyboardTrackingFlagsFB @@ -3894,9 +3893,9 @@ XRAPI_ATTR XrResult XRAPI_CALL xrTriangleMeshEndVertexBufferUpdateFB( XR_DEFINE_HANDLE(XrPassthroughFB) XR_DEFINE_HANDLE(XrPassthroughLayerFB) XR_DEFINE_HANDLE(XrGeometryInstanceFB) -#define XR_PASSTHROUGH_COLOR_MAP_MONO_SIZE_FB 256 #define XR_FB_passthrough_SPEC_VERSION 3 #define XR_FB_PASSTHROUGH_EXTENSION_NAME "XR_FB_passthrough" +#define XR_PASSTHROUGH_COLOR_MAP_MONO_SIZE_FB 256 typedef enum XrPassthroughLayerPurposeFB { XR_PASSTHROUGH_LAYER_PURPOSE_RECONSTRUCTION_FB = 0, @@ -4085,9 +4084,9 @@ XRAPI_ATTR XrResult XRAPI_CALL xrGeometryInstanceSetTransformFB( #define XR_NULL_RENDER_MODEL_KEY_FB 0 XR_DEFINE_ATOM(XrRenderModelKeyFB) -#define XR_MAX_RENDER_MODEL_NAME_SIZE_FB 64 #define XR_FB_render_model_SPEC_VERSION 4 #define XR_FB_RENDER_MODEL_EXTENSION_NAME "XR_FB_render_model" +#define XR_MAX_RENDER_MODEL_NAME_SIZE_FB 64 typedef XrFlags64 XrRenderModelFlagsFB; // Flag bits for XrRenderModelFlagsFB @@ -4244,7 +4243,7 @@ typedef struct XrMarkerSpaceCreateInfoVARJO { typedef XrResult (XRAPI_PTR *PFN_xrSetMarkerTrackingVARJO)(XrSession session, XrBool32 enabled); typedef XrResult (XRAPI_PTR *PFN_xrSetMarkerTrackingTimeoutVARJO)(XrSession session, uint64_t markerId, XrDuration timeout); -typedef XrResult (XRAPI_PTR *PFN_xrSetMarkerTrackingPredictionVARJO)(XrSession session, uint64_t markerId, XrBool32 enable); +typedef XrResult (XRAPI_PTR *PFN_xrSetMarkerTrackingPredictionVARJO)(XrSession session, uint64_t markerId, XrBool32 enabled); typedef XrResult (XRAPI_PTR *PFN_xrGetMarkerSizeVARJO)(XrSession session, uint64_t markerId, XrExtent2Df* size); typedef XrResult (XRAPI_PTR *PFN_xrCreateMarkerSpaceVARJO)(XrSession session, const XrMarkerSpaceCreateInfoVARJO* createInfo, XrSpace* space); @@ -4262,7 +4261,7 @@ XRAPI_ATTR XrResult XRAPI_CALL xrSetMarkerTrackingTimeoutVARJO( XRAPI_ATTR XrResult XRAPI_CALL xrSetMarkerTrackingPredictionVARJO( XrSession session, uint64_t markerId, - XrBool32 enable); + XrBool32 enabled); XRAPI_ATTR XrResult XRAPI_CALL xrGetMarkerSizeVARJO( XrSession session, @@ -5239,31 +5238,6 @@ typedef struct XrLocalDimmingFrameEndInfoMETA { -#define XR_META_passthrough_preferences 1 -#define XR_META_passthrough_preferences_SPEC_VERSION 1 -#define XR_META_PASSTHROUGH_PREFERENCES_EXTENSION_NAME "XR_META_passthrough_preferences" -typedef XrFlags64 XrPassthroughPreferenceFlagsMETA; - -// Flag bits for XrPassthroughPreferenceFlagsMETA -static const XrPassthroughPreferenceFlagsMETA XR_PASSTHROUGH_PREFERENCE_DEFAULT_TO_ACTIVE_BIT_META = 0x00000001; - -typedef struct XrPassthroughPreferencesMETA { - XrStructureType type; - const void* XR_MAY_ALIAS next; - XrPassthroughPreferenceFlagsMETA flags; -} XrPassthroughPreferencesMETA; - -typedef XrResult (XRAPI_PTR *PFN_xrGetPassthroughPreferencesMETA)(XrSession session, XrPassthroughPreferencesMETA* preferences); - -#ifndef XR_NO_PROTOTYPES -#ifdef XR_EXTENSION_PROTOTYPES -XRAPI_ATTR XrResult XRAPI_CALL xrGetPassthroughPreferencesMETA( - XrSession session, - XrPassthroughPreferencesMETA* preferences); -#endif /* XR_EXTENSION_PROTOTYPES */ -#endif /* !XR_NO_PROTOTYPES */ - - #define XR_META_virtual_keyboard 1 XR_DEFINE_HANDLE(XrVirtualKeyboardMETA) #define XR_MAX_VIRTUAL_KEYBOARD_COMMIT_TEXT_SIZE_META 3992 @@ -5960,7 +5934,7 @@ XRAPI_ATTR XrResult XRAPI_CALL xrApplyForceFeedbackCurlMNDX( #define XR_BD_controller_interaction 1 -#define XR_BD_controller_interaction_SPEC_VERSION 2 +#define XR_BD_controller_interaction_SPEC_VERSION 1 #define XR_BD_CONTROLLER_INTERACTION_EXTENSION_NAME "XR_BD_controller_interaction" @@ -6154,11 +6128,6 @@ XRAPI_ATTR XrResult XRAPI_CALL xrGetPlanePolygonBufferEXT( #define XR_OPPO_controller_interaction_SPEC_VERSION 1 #define XR_OPPO_CONTROLLER_INTERACTION_EXTENSION_NAME "XR_OPPO_controller_interaction" - -#define XR_YVR_controller_interaction 1 -#define XR_YVR_controller_interaction_SPEC_VERSION 1 -#define XR_YVR_CONTROLLER_INTERACTION_EXTENSION_NAME "XR_YVR_controller_interaction" - #ifdef __cplusplus } #endif diff --git a/thirdparty/openxr/include/openxr/openxr_platform.h b/thirdparty/openxr/include/openxr/openxr_platform.h index e4ddfcbb7d..b0a5328f3e 100644 --- a/thirdparty/openxr/include/openxr/openxr_platform.h +++ b/thirdparty/openxr/include/openxr/openxr_platform.h @@ -491,15 +491,14 @@ XRAPI_ATTR XrResult XRAPI_CALL xrGetVulkanGraphicsRequirements2KHR( #define XR_MNDX_egl_enable 1 #define XR_MNDX_egl_enable_SPEC_VERSION 1 #define XR_MNDX_EGL_ENABLE_EXTENSION_NAME "XR_MNDX_egl_enable" -typedef PFN_xrVoidFunction (*PFN_xrEglGetProcAddressMNDX)(const char *name); // XrGraphicsBindingEGLMNDX extends XrSessionCreateInfo typedef struct XrGraphicsBindingEGLMNDX { - XrStructureType type; - const void* XR_MAY_ALIAS next; - PFN_xrEglGetProcAddressMNDX getProcAddress; - EGLDisplay display; - EGLConfig config; - EGLContext context; + XrStructureType type; + const void* XR_MAY_ALIAS next; + PFNEGLGETPROCADDRESSPROC getProcAddress; + EGLDisplay display; + EGLConfig config; + EGLContext context; } XrGraphicsBindingEGLMNDX; #endif /* XR_USE_PLATFORM_EGL */ diff --git a/thirdparty/openxr/include/openxr/openxr_reflection.h b/thirdparty/openxr/include/openxr/openxr_reflection.h index 8c9aabfab1..c53d412365 100644 --- a/thirdparty/openxr/include/openxr/openxr_reflection.h +++ b/thirdparty/openxr/include/openxr/openxr_reflection.h @@ -386,7 +386,6 @@ XR_ENUM_STR(XrResult); _(XR_TYPE_DEVICE_PCM_SAMPLE_RATE_STATE_FB, 1000209002) \ _(XR_TYPE_COMPOSITION_LAYER_DEPTH_TEST_FB, 1000212000) \ _(XR_TYPE_LOCAL_DIMMING_FRAME_END_INFO_META, 1000216000) \ - _(XR_TYPE_PASSTHROUGH_PREFERENCES_META, 1000217000) \ _(XR_TYPE_SYSTEM_VIRTUAL_KEYBOARD_PROPERTIES_META, 1000219001) \ _(XR_TYPE_VIRTUAL_KEYBOARD_CREATE_INFO_META, 1000219002) \ _(XR_TYPE_VIRTUAL_KEYBOARD_SPACE_CREATE_INFO_META, 1000219003) \ @@ -1270,9 +1269,6 @@ XR_ENUM_STR(XrResult); _(XR_COMPOSITION_LAYER_SETTINGS_NORMAL_SHARPENING_BIT_FB, 0x00000004) \ _(XR_COMPOSITION_LAYER_SETTINGS_QUALITY_SHARPENING_BIT_FB, 0x00000008) \ -#define XR_LIST_BITS_XrPassthroughPreferenceFlagsMETA(_) \ - _(XR_PASSTHROUGH_PREFERENCE_DEFAULT_TO_ACTIVE_BIT_META, 0x00000001) \ - #define XR_LIST_BITS_XrVirtualKeyboardInputStateFlagsMETA(_) \ _(XR_VIRTUAL_KEYBOARD_INPUT_STATE_PRESSED_BIT_META, 0x00000001) \ @@ -3592,12 +3588,6 @@ XR_ENUM_STR(XrResult); _(next) \ _(localDimmingMode) \ -/// Calls your macro with the name of each member of XrPassthroughPreferencesMETA, in order. -#define XR_LIST_STRUCT_XrPassthroughPreferencesMETA(_) \ - _(type) \ - _(next) \ - _(flags) \ - /// Calls your macro with the name of each member of XrSystemVirtualKeyboardPropertiesMETA, in order. #define XR_LIST_STRUCT_XrSystemVirtualKeyboardPropertiesMETA(_) \ _(type) \ @@ -4237,7 +4227,6 @@ XR_ENUM_STR(XrResult); _(XrDevicePcmSampleRateStateFB, XR_TYPE_DEVICE_PCM_SAMPLE_RATE_STATE_FB) \ _(XrCompositionLayerDepthTestFB, XR_TYPE_COMPOSITION_LAYER_DEPTH_TEST_FB) \ _(XrLocalDimmingFrameEndInfoMETA, XR_TYPE_LOCAL_DIMMING_FRAME_END_INFO_META) \ - _(XrPassthroughPreferencesMETA, XR_TYPE_PASSTHROUGH_PREFERENCES_META) \ _(XrSystemVirtualKeyboardPropertiesMETA, XR_TYPE_SYSTEM_VIRTUAL_KEYBOARD_PROPERTIES_META) \ _(XrVirtualKeyboardCreateInfoMETA, XR_TYPE_VIRTUAL_KEYBOARD_CREATE_INFO_META) \ _(XrVirtualKeyboardSpaceCreateInfoMETA, XR_TYPE_VIRTUAL_KEYBOARD_SPACE_CREATE_INFO_META) \ @@ -4567,7 +4556,6 @@ XR_ENUM_STR(XrResult); _(XR_FB_haptic_pcm, 210) \ _(XR_FB_composition_layer_depth_test, 213) \ _(XR_META_local_dimming, 217) \ - _(XR_META_passthrough_preferences, 218) \ _(XR_META_virtual_keyboard, 220) \ _(XR_OCULUS_external_camera, 227) \ _(XR_META_vulkan_swapchain_create_info, 228) \ @@ -4588,7 +4576,6 @@ XR_ENUM_STR(XrResult); _(XR_EXT_hand_tracking_data_source, 429) \ _(XR_EXT_plane_detection, 430) \ _(XR_OPPO_controller_interaction, 454) \ - _(XR_YVR_controller_interaction, 498) \ #endif diff --git a/thirdparty/openxr/include/openxr/openxr_reflection_structs.h b/thirdparty/openxr/include/openxr/openxr_reflection_structs.h index 7028a6edeb..ec186390a3 100644 --- a/thirdparty/openxr/include/openxr/openxr_reflection_structs.h +++ b/thirdparty/openxr/include/openxr/openxr_reflection_structs.h @@ -268,7 +268,6 @@ This file contains expansion macros (X Macros) for OpenXR structures. _avail(XrDevicePcmSampleRateStateFB, XR_TYPE_DEVICE_PCM_SAMPLE_RATE_STATE_FB) \ _avail(XrCompositionLayerDepthTestFB, XR_TYPE_COMPOSITION_LAYER_DEPTH_TEST_FB) \ _avail(XrLocalDimmingFrameEndInfoMETA, XR_TYPE_LOCAL_DIMMING_FRAME_END_INFO_META) \ - _avail(XrPassthroughPreferencesMETA, XR_TYPE_PASSTHROUGH_PREFERENCES_META) \ _avail(XrSystemVirtualKeyboardPropertiesMETA, XR_TYPE_SYSTEM_VIRTUAL_KEYBOARD_PROPERTIES_META) \ _avail(XrVirtualKeyboardCreateInfoMETA, XR_TYPE_VIRTUAL_KEYBOARD_CREATE_INFO_META) \ _avail(XrVirtualKeyboardSpaceCreateInfoMETA, XR_TYPE_VIRTUAL_KEYBOARD_SPACE_CREATE_INFO_META) \ diff --git a/thirdparty/openxr/src/common/platform_utils.hpp b/thirdparty/openxr/src/common/platform_utils.hpp index 883baef82d..219d19789d 100644 --- a/thirdparty/openxr/src/common/platform_utils.hpp +++ b/thirdparty/openxr/src/common/platform_utils.hpp @@ -37,44 +37,6 @@ #include "common_config.h" #endif // OPENXR_HAVE_COMMON_CONFIG -#if defined(__x86_64__) && defined(__ILP32__) -#define XR_ARCH_ABI "x32" -#elif defined(_M_X64) || defined(__x86_64__) -#define XR_ARCH_ABI "x86_64" -#elif defined(_M_IX86) || defined(__i386__) || defined(_X86_) -#define XR_ARCH_ABI "i686" -#elif (defined(__aarch64__) && defined(__LP64__)) || defined(_M_ARM64) -#define XR_ARCH_ABI "aarch64" -#elif (defined(__ARM_ARCH) && __ARM_ARCH >= 7 && (defined(__ARM_PCS_VFP) || defined(__ANDROID__))) || defined(_M_ARM) -#define XR_ARCH_ABI "armv7a-vfp" -#elif defined(__ARM_ARCH_5TE__) -#define XR_ARCH_ABI "armv5te" -#elif defined(__mips64) -#define XR_ARCH_ABI "mips64" -#elif defined(__mips) -#define XR_ARCH_ABI "mips" -#elif defined(__powerpc64__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ -#define XR_ARCH_ABI "ppc64" -#elif defined(__powerpc__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ -#define XR_ARCH_ABI "ppc64el" -#elif defined(__s390x__) || defined(__zarch__) -#define XR_ARCH_ABI "s390x" -#elif defined(__hppa__) -#define XR_ARCH_ABI "hppa" -#elif defined(__alpha__) -#define XR_ARCH_ABI "alpha" -#elif defined(__ia64__) || defined(_M_IA64) -#define XR_ARCH_ABI "ia64" -#elif defined(__m68k__) -#define XR_ARCH_ABI "m68k" -#elif defined(__riscv_xlen) && (__riscv_xlen == 64) -#define XR_ARCH_ABI "riscv64" -#elif defined(__sparc__) && defined(__arch64__) -#define XR_ARCH_ABI "sparc64" -#else -#error "No architecture string known!" -#endif - // Consumers of this file must ensure this function is implemented. For example, the loader will implement this function so that it // can route messages through the loader's logging system. void LogPlatformUtilsError(const std::string& message); @@ -85,7 +47,6 @@ void LogPlatformUtilsError(const std::string& message); #include <unistd.h> #include <fcntl.h> #include <iostream> -#include <sys/stat.h> namespace detail { @@ -111,31 +72,6 @@ static inline char* ImplGetSecureEnv(const char* name) { } // namespace detail #endif // defined(XR_OS_LINUX) || defined(XR_OS_APPLE) - -#if defined(XR_OS_ANDROID) || defined(XR_OS_APPLE) - -#include <sys/stat.h> - -namespace detail { - -static inline bool ImplTryRuntimeFilename(const char* rt_dir_prefix, uint16_t major_version, std::string& file_name) { - auto decorated_path = rt_dir_prefix + std::to_string(major_version) + "/active_runtime." XR_ARCH_ABI ".json"; - auto undecorated_path = rt_dir_prefix + std::to_string(major_version) + "/active_runtime.json"; - - struct stat buf {}; - if (0 == stat(decorated_path.c_str(), &buf)) { - file_name = decorated_path; - return true; - } - if (0 == stat(undecorated_path.c_str(), &buf)) { - file_name = undecorated_path; - return true; - } - return false; -} - -} // namespace detail -#endif // defined(XR_OS_ANDROID) || defined(XR_OS_APPLE) #if defined(XR_OS_LINUX) static inline std::string PlatformUtilsGetEnv(const char* name) { @@ -194,8 +130,15 @@ static inline bool PlatformUtilsSetEnv(const char* name, const char* value) { return (result == 0); } +// Prefix for the Apple global runtime JSON file name +static const std::string rt_dir_prefix = "/usr/local/share/openxr/"; +static const std::string rt_filename = "/active_runtime.json"; + static inline bool PlatformGetGlobalRuntimeFileName(uint16_t major_version, std::string& file_name) { - return detail::ImplTryRuntimeFilename("/usr/local/share/openxr/", major_version, file_name); + file_name = rt_dir_prefix; + file_name += std::to_string(major_version); + file_name += rt_filename; + return true; } #elif defined(XR_OS_WINDOWS) @@ -368,19 +311,22 @@ static inline bool PlatformUtilsSetEnv(const char* /* name */, const char* /* va return false; } +#include <sys/stat.h> + // Intended to be only used as a fallback on Android, with a more open, "native" technique used in most cases static inline bool PlatformGetGlobalRuntimeFileName(uint16_t major_version, std::string& file_name) { // Prefix for the runtime JSON file name static const char* rt_dir_prefixes[] = {"/product", "/odm", "/oem", "/vendor", "/system"}; - + static const std::string rt_filename = "/active_runtime.json"; static const std::string subdir = "/etc/openxr/"; for (const auto prefix : rt_dir_prefixes) { - const std::string rt_dir_prefix = prefix + subdir; - if (detail::ImplTryRuntimeFilename(rt_dir_prefix.c_str(), major_version, file_name)) { + auto path = prefix + subdir + std::to_string(major_version) + rt_filename; + struct stat buf; + if (0 == stat(path.c_str(), &buf)) { + file_name = path; return true; } } - return false; } #else // Not Linux, Apple, nor Windows diff --git a/thirdparty/openxr/src/common/xr_dependencies.h b/thirdparty/openxr/src/common/xr_dependencies.h index 6c9cf2d05f..5c7bd04774 100644 --- a/thirdparty/openxr/src/common/xr_dependencies.h +++ b/thirdparty/openxr/src/common/xr_dependencies.h @@ -76,10 +76,7 @@ #include "wayland-client.h" #endif // XR_USE_PLATFORM_WAYLAND -#ifdef XR_USE_PLATFORM_EGL -#include <EGL/egl.h> -#endif // XR_USE_PLATFORM_EGL - +#ifdef XR_USE_GRAPHICS_API_OPENGL #if defined(XR_USE_PLATFORM_XLIB) || defined(XR_USE_PLATFORM_XCB) #ifdef Success #undef Success @@ -93,3 +90,4 @@ #undef None #endif // None #endif // defined(XR_USE_PLATFORM_XLIB) || defined(XR_USE_PLATFORM_XCB) +#endif // XR_USE_GRAPHICS_API_OPENGL diff --git a/thirdparty/openxr/src/common/xr_linear.h b/thirdparty/openxr/src/common/xr_linear.h index ce65f8ddfb..5b0da645ac 100644 --- a/thirdparty/openxr/src/common/xr_linear.h +++ b/thirdparty/openxr/src/common/xr_linear.h @@ -1,5 +1,5 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. -// Copyright (c) 2016, Oculus VR, LLC. +// Copyright (c) 2017 The Khronos Group Inc. +// Copyright (c) 2016 Oculus VR, LLC. // // SPDX-License-Identifier: Apache-2.0 // @@ -23,17 +23,15 @@ #include <openxr/openxr.h> -/* REUSE-IgnoreStart */ -/* The following has copyright notices that duplicate the header above */ - /* ================================================================================================ -Description : Vector, matrix and quaternion math. -Orig. Author : J.M.P. van Waveren -Orig. Date : 12/10/2016 -Language : C99 -Copyright : Copyright (c) 2016 Oculus VR, LLC. All Rights reserved. +Description : Vector, matrix and quaternion math. +Author : J.M.P. van Waveren +Date : 12/10/2016 +Language : C99 +Format : Indent 4 spaces - no tabs. +Copyright : Copyright (c) 2016 Oculus VR, LLC. All Rights reserved. DESCRIPTION @@ -147,8 +145,6 @@ inline static float XrRcpSqrt(const float x) { return rcp; } -inline static float XrVector2f_Length(const XrVector2f* v) { return sqrtf(v->x * v->x + v->y * v->y); } - inline static void XrVector3f_Set(XrVector3f* v, const float value) { v->x = value; v->y = value; diff --git a/thirdparty/openxr/src/loader/api_layer_interface.cpp b/thirdparty/openxr/src/loader/api_layer_interface.cpp index c9e24ec40b..5560c31a52 100644 --- a/thirdparty/openxr/src/loader/api_layer_interface.cpp +++ b/thirdparty/openxr/src/loader/api_layer_interface.cpp @@ -237,23 +237,21 @@ XrResult ApiLayerInterface::LoadApiLayers(const std::string& openxr_command, uin for (const auto& layer_name : enabled_explicit_api_layer_names) { bool found_this_layer = false; - if (layers_already_found.count(layer_name) > 0) { - found_this_layer = true; - } else { - for (auto it = explicit_layer_manifest_files.begin(); it != explicit_layer_manifest_files.end();) { - bool erased_layer_manifest_file = false; - - if (layer_name == (*it)->LayerName()) { - found_this_layer = true; - layers_already_found.insert(layer_name); - enabled_layer_manifest_files_in_init_order.push_back(std::move(*it)); - it = explicit_layer_manifest_files.erase(it); - erased_layer_manifest_file = true; - } + for (auto it = explicit_layer_manifest_files.begin(); it != explicit_layer_manifest_files.end();) { + bool erased_layer_manifest_file = false; + + if (layers_already_found.count(layer_name) > 0) { + found_this_layer = true; + } else if (layer_name == (*it)->LayerName()) { + found_this_layer = true; + layers_already_found.insert(layer_name); + enabled_layer_manifest_files_in_init_order.push_back(std::move(*it)); + it = explicit_layer_manifest_files.erase(it); + erased_layer_manifest_file = true; + } - if (!erased_layer_manifest_file) { - it++; - } + if (!erased_layer_manifest_file) { + it++; } } diff --git a/thirdparty/openxr/src/loader/loader_core.cpp b/thirdparty/openxr/src/loader/loader_core.cpp index 06e6870053..98d3fa971a 100644 --- a/thirdparty/openxr/src/loader/loader_core.cpp +++ b/thirdparty/openxr/src/loader/loader_core.cpp @@ -19,7 +19,7 @@ #include "loader_logger.hpp" #include "loader_platform.hpp" #include "runtime_interface.hpp" -#include "xr_generated_dispatch_table_core.h" +#include "xr_generated_dispatch_table.h" #include "xr_generated_loader.hpp" #include <openxr/openxr.h> diff --git a/thirdparty/openxr/src/loader/loader_instance.cpp b/thirdparty/openxr/src/loader/loader_instance.cpp index ce5c205505..badd39193c 100644 --- a/thirdparty/openxr/src/loader/loader_instance.cpp +++ b/thirdparty/openxr/src/loader/loader_instance.cpp @@ -18,7 +18,7 @@ #include "loader_interfaces.h" #include "loader_logger.hpp" #include "runtime_interface.hpp" -#include "xr_generated_dispatch_table_core.h" +#include "xr_generated_dispatch_table.h" #include "xr_generated_loader.hpp" #include <openxr/openxr.h> diff --git a/thirdparty/openxr/src/loader/manifest_file.cpp b/thirdparty/openxr/src/loader/manifest_file.cpp index 0683bc166a..99f4e84104 100644 --- a/thirdparty/openxr/src/loader/manifest_file.cpp +++ b/thirdparty/openxr/src/loader/manifest_file.cpp @@ -274,45 +274,16 @@ static std::string GetXDGEnvAbsolute(const char *name, const char *fallback_path return fallback_paths; } -/// @param rt_dir_prefix Directory prefix with a trailing slash -static bool FindEitherActiveRuntimeFilename(const char *prefix_desc, const std::string &rt_dir_prefix, uint16_t major_version, - std::string &out) { - { - std::ostringstream oss; - oss << "Looking for active_runtime." XR_ARCH_ABI ".json or active_runtime.json in "; - oss << prefix_desc; - oss << ": "; - oss << rt_dir_prefix; - - LoaderLogger::LogInfoMessage("", oss.str()); - } - { - auto decorated_path = rt_dir_prefix + std::to_string(major_version) + "/active_runtime." XR_ARCH_ABI ".json"; - - if (FileSysUtilsPathExists(decorated_path)) { - out = decorated_path; - return true; - } - } - { - auto undecorated_path = rt_dir_prefix + std::to_string(major_version) + "/active_runtime.json"; - - if (FileSysUtilsPathExists(undecorated_path)) { - out = undecorated_path; - return true; - } - } - return false; -} // Return the first instance of relative_path occurring in an XDG config dir according to standard // precedence order. -static bool FindXDGConfigFile(const char *relative_dir, uint16_t major_version, std::string &out) { - const std::string message{"Looking for active_runtime." XR_ARCH_ABI ".json or active_runtime.json"}; - std::string dir_prefix = GetXDGEnvHome("XDG_CONFIG_HOME", ".config"); - if (!dir_prefix.empty()) { - dir_prefix += "/"; - dir_prefix += relative_dir; - if (FindEitherActiveRuntimeFilename("XDG_CONFIG_HOME", dir_prefix, major_version, out)) { +static bool FindXDGConfigFile(const std::string &relative_path, std::string &out) { + out = GetXDGEnvHome("XDG_CONFIG_HOME", ".config"); + if (!out.empty()) { + out += "/"; + out += relative_path; + + LoaderLogger::LogInfoMessage("", "Looking for " + relative_path + " in XDG_CONFIG_HOME: " + out); + if (FileSysUtilsPathExists(out)) { return true; } } @@ -323,26 +294,29 @@ static bool FindXDGConfigFile(const char *relative_dir, uint16_t major_version, if (path.empty()) { continue; } - dir_prefix = std::move(path); - dir_prefix += "/"; - dir_prefix += relative_dir; - if (FindEitherActiveRuntimeFilename("an entry of XDG_CONFIG_DIRS", dir_prefix, major_version, out)) { + out = path; + out += "/"; + out += relative_path; + LoaderLogger::LogInfoMessage("", "Looking for " + relative_path + " in an entry of XDG_CONFIG_DIRS: " + out); + if (FileSysUtilsPathExists(out)) { return true; } } - dir_prefix = SYSCONFDIR; - dir_prefix += "/"; - dir_prefix += relative_dir; - if (FindEitherActiveRuntimeFilename("compiled-in SYSCONFDIR", dir_prefix, major_version, out)) { + out = SYSCONFDIR; + out += "/"; + out += relative_path; + LoaderLogger::LogInfoMessage("", "Looking for " + relative_path + " in compiled-in SYSCONFDIR: " + out); + if (FileSysUtilsPathExists(out)) { return true; } #if defined(EXTRASYSCONFDIR) - dir_prefix = EXTRASYSCONFDIR; - dir_prefix += "/"; - dir_prefix += relative_dir; - if (FindEitherActiveRuntimeFilename("compiled-in EXTRASYSCONFDIR", dir_prefix, major_version, out)) { + out = EXTRASYSCONFDIR; + out += "/"; + out += relative_path; + LoaderLogger::LogInfoMessage("", "Looking for " + relative_path + " in compiled-in EXTRASYSCONFDIR: " + out); + if (FileSysUtilsPathExists(out)) { return true; } #endif @@ -658,8 +632,9 @@ XrResult RuntimeManifestFile::FindManifestFiles(std::vector<std::unique_ptr<Runt LoaderLogger::LogInfoMessage("", "RuntimeManifestFile::FindManifestFiles - using registry-specified runtime file " + filename); #elif defined(XR_OS_LINUX) - - if (!FindXDGConfigFile("openxr/", XR_VERSION_MAJOR(XR_CURRENT_API_VERSION), filename)) { + const std::string relative_path = + "openxr/" + std::to_string(XR_VERSION_MAJOR(XR_CURRENT_API_VERSION)) + "/active_runtime.json"; + if (!FindXDGConfigFile(relative_path, filename)) { LoaderLogger::LogErrorMessage( "", "RuntimeManifestFile::FindManifestFiles - failed to determine active runtime file path for this environment"); return XR_ERROR_RUNTIME_UNAVAILABLE; diff --git a/thirdparty/openxr/src/loader/runtime_interface.cpp b/thirdparty/openxr/src/loader/runtime_interface.cpp index 8312b15ba4..d9ab86bb58 100644 --- a/thirdparty/openxr/src/loader/runtime_interface.cpp +++ b/thirdparty/openxr/src/loader/runtime_interface.cpp @@ -13,7 +13,7 @@ #include "loader_interfaces.h" #include "loader_logger.hpp" #include "loader_platform.hpp" -#include "xr_generated_dispatch_table_core.h" +#include "xr_generated_dispatch_table.h" #include <openxr/openxr.h> @@ -29,10 +29,6 @@ #include "android_utilities.h" #include <android/asset_manager_jni.h> #include <json/value.h> - -// Needed for the loader init struct -#include <xr_dependencies.h> -#include <openxr/openxr_platform.h> #endif // XR_USE_PLATFORM_ANDROID #ifdef XR_KHR_LOADER_INIT_SUPPORT @@ -109,22 +105,33 @@ XrResult LoaderInitData::initialize(const XrLoaderInitInfoBaseHeaderKHR* info) { if (cast_info->applicationContext == nullptr) { return XR_ERROR_VALIDATION_FAILURE; } - - // Copy and store the JVM pointer and Android Context, ensuring the JVM is initialised. _data = *cast_info; + jni::init((jni::JavaVM*)_data.applicationVM); _data.next = nullptr; - jni::init(static_cast<jni::JavaVM*>(_data.applicationVM)); - const jni::Object context = jni::Object{static_cast<jni::jobject>(_data.applicationContext)}; - - // Retrieve a reference to the Android AssetManager. - const auto assetManager = context.call<jni::Object>("getAssets()Landroid/content/res/AssetManager;"); - _android_asset_manager = AAssetManager_fromJava(jni::env(), assetManager.getHandle()); - - // Retrieve the path to the native libraries. - const auto applicationContext = context.call<jni::Object>("getApplicationContext()Landroid/content/Context;"); - const auto applicationInfo = context.call<jni::Object>("getApplicationInfo()Landroid/content/pm/ApplicationInfo;"); - _native_library_path = applicationInfo.get<std::string>("nativeLibraryDir"); - + JNIEnv* Env; + ((jni::JavaVM*)(cast_info->applicationVM))->AttachCurrentThread(&Env, nullptr); + const jclass contextClass = Env->GetObjectClass((jobject)_data.applicationContext); + + const jmethodID getAssetsMethod = Env->GetMethodID(contextClass, "getAssets", "()Landroid/content/res/AssetManager;"); + const jobject AssetManagerObject = Env->CallObjectMethod((jobject)_data.applicationContext, getAssetsMethod); + _android_asset_manager = AAssetManager_fromJava(Env, AssetManagerObject); + + const jmethodID getApplicationContextMethod = + Env->GetMethodID(contextClass, "getApplicationContext", "()Landroid/content/Context;"); + const jobject contextObject = Env->CallObjectMethod((jobject)_data.applicationContext, getApplicationContextMethod); + const jmethodID getApplicationInfoMethod = + Env->GetMethodID(contextClass, "getApplicationInfo", "()Landroid/content/pm/ApplicationInfo;"); + const jobject applicationInfoObject = Env->CallObjectMethod(contextObject, getApplicationInfoMethod); + const jfieldID nativeLibraryDirField = + Env->GetFieldID(Env->GetObjectClass(applicationInfoObject), "nativeLibraryDir", "Ljava/lang/String;"); + const jobject nativeLibraryDirObject = Env->GetObjectField(applicationInfoObject, nativeLibraryDirField); + const jmethodID getBytesMethod = + Env->GetMethodID(Env->GetObjectClass(nativeLibraryDirObject), "getBytes", "(Ljava/lang/String;)[B"); + const auto bytesObject = + static_cast<jbyteArray>(Env->CallObjectMethod(nativeLibraryDirObject, getBytesMethod, Env->NewStringUTF("UTF-8"))); + const size_t length = Env->GetArrayLength(bytesObject); + const jbyte* const bytes = Env->GetByteArrayElements(bytesObject, nullptr); + _native_library_path = std::string(reinterpret_cast<const char*>(bytes), length); _initialized = true; return XR_SUCCESS; } diff --git a/thirdparty/openxr/src/loader/xr_generated_loader.cpp b/thirdparty/openxr/src/loader/xr_generated_loader.cpp index 8c79afddc5..e7767fd30a 100644 --- a/thirdparty/openxr/src/loader/xr_generated_loader.cpp +++ b/thirdparty/openxr/src/loader/xr_generated_loader.cpp @@ -36,7 +36,7 @@ #include "loader_logger.hpp" #include "loader_platform.hpp" #include "runtime_interface.hpp" -#include "xr_generated_dispatch_table_core.h" +#include "xr_generated_dispatch_table.h" #include "xr_dependencies.h" #include <openxr/openxr.h> diff --git a/thirdparty/openxr/src/xr_generated_dispatch_table.c b/thirdparty/openxr/src/xr_generated_dispatch_table.c index 6e43a29724..302bed31f5 100644 --- a/thirdparty/openxr/src/xr_generated_dispatch_table.c +++ b/thirdparty/openxr/src/xr_generated_dispatch_table.c @@ -1,9 +1,7 @@ // Copyright (c) 2017-2023, The Khronos Group Inc. -// Copyright (c) 2017-2019, Valve Corporation -// Copyright (c) 2017-2019, LunarG, Inc. - +// Copyright (c) 2017-2019 Valve Corporation +// Copyright (c) 2017-2019 LunarG, Inc. // SPDX-License-Identifier: Apache-2.0 OR MIT - // *********** THIS FILE IS GENERATED - DO NOT EDIT *********** // See utility_source_generator.py for modifications // ************************************************************ @@ -31,6 +29,9 @@ #include <time.h> #include "xr_generated_dispatch_table.h" +#include "xr_dependencies.h" +#include <openxr/openxr.h> +#include <openxr/openxr_platform.h> #ifdef __cplusplus @@ -403,9 +404,6 @@ void GeneratedXrPopulateDispatchTable(struct XrGeneratedDispatchTable *table, // ---- XR_FB_haptic_pcm extension commands (get_inst_proc_addr(instance, "xrGetDeviceSampleRateFB", (PFN_xrVoidFunction*)&table->GetDeviceSampleRateFB)); - // ---- XR_META_passthrough_preferences extension commands - (get_inst_proc_addr(instance, "xrGetPassthroughPreferencesMETA", (PFN_xrVoidFunction*)&table->GetPassthroughPreferencesMETA)); - // ---- XR_META_virtual_keyboard extension commands (get_inst_proc_addr(instance, "xrCreateVirtualKeyboardMETA", (PFN_xrVoidFunction*)&table->CreateVirtualKeyboardMETA)); (get_inst_proc_addr(instance, "xrDestroyVirtualKeyboardMETA", (PFN_xrVoidFunction*)&table->DestroyVirtualKeyboardMETA)); diff --git a/thirdparty/openxr/src/xr_generated_dispatch_table.h b/thirdparty/openxr/src/xr_generated_dispatch_table.h index a385f81906..b6e17f98d4 100644 --- a/thirdparty/openxr/src/xr_generated_dispatch_table.h +++ b/thirdparty/openxr/src/xr_generated_dispatch_table.h @@ -1,9 +1,7 @@ // Copyright (c) 2017-2023, The Khronos Group Inc. -// Copyright (c) 2017-2019, Valve Corporation -// Copyright (c) 2017-2019, LunarG, Inc. - +// Copyright (c) 2017-2019 Valve Corporation +// Copyright (c) 2017-2019 LunarG, Inc. // SPDX-License-Identifier: Apache-2.0 OR MIT - // *********** THIS FILE IS GENERATED - DO NOT EDIT *********** // See utility_source_generator.py for modifications // ************************************************************ @@ -30,7 +28,6 @@ // #pragma once - #include "xr_dependencies.h" #include <openxr/openxr.h> #include <openxr/openxr_platform.h> @@ -409,9 +406,6 @@ struct XrGeneratedDispatchTable { // ---- XR_FB_haptic_pcm extension commands PFN_xrGetDeviceSampleRateFB GetDeviceSampleRateFB; - // ---- XR_META_passthrough_preferences extension commands - PFN_xrGetPassthroughPreferencesMETA GetPassthroughPreferencesMETA; - // ---- XR_META_virtual_keyboard extension commands PFN_xrCreateVirtualKeyboardMETA CreateVirtualKeyboardMETA; PFN_xrDestroyVirtualKeyboardMETA DestroyVirtualKeyboardMETA; diff --git a/thirdparty/openxr/src/xr_generated_dispatch_table_core.c b/thirdparty/openxr/src/xr_generated_dispatch_table_core.c deleted file mode 100644 index b3f34e68a9..0000000000 --- a/thirdparty/openxr/src/xr_generated_dispatch_table_core.c +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. -// Copyright (c) 2017-2019, Valve Corporation -// Copyright (c) 2017-2019, LunarG, Inc. - -// SPDX-License-Identifier: Apache-2.0 OR MIT - -// *********** THIS FILE IS GENERATED - DO NOT EDIT *********** -// See utility_source_generator.py for modifications -// ************************************************************ - -// Copyright (c) 2017-2023, The Khronos Group Inc. -// Copyright (c) 2017-2019 Valve Corporation -// Copyright (c) 2017-2019 LunarG, Inc. -// -// SPDX-License-Identifier: Apache-2.0 -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Author: Mark Young <marky@lunarg.com> -// - -#include "xr_generated_dispatch_table_core.h" - - -#ifdef __cplusplus -extern "C" { -#endif -// Helper function to populate an instance dispatch table -void GeneratedXrPopulateDispatchTable(struct XrGeneratedDispatchTable *table, - XrInstance instance, - PFN_xrGetInstanceProcAddr get_inst_proc_addr) { - - // ---- Core 1.0 commands - table->GetInstanceProcAddr = get_inst_proc_addr; - (get_inst_proc_addr(instance, "xrCreateInstance", (PFN_xrVoidFunction*)&table->CreateInstance)); - (get_inst_proc_addr(instance, "xrDestroyInstance", (PFN_xrVoidFunction*)&table->DestroyInstance)); - (get_inst_proc_addr(instance, "xrGetInstanceProperties", (PFN_xrVoidFunction*)&table->GetInstanceProperties)); - (get_inst_proc_addr(instance, "xrPollEvent", (PFN_xrVoidFunction*)&table->PollEvent)); - (get_inst_proc_addr(instance, "xrResultToString", (PFN_xrVoidFunction*)&table->ResultToString)); - (get_inst_proc_addr(instance, "xrStructureTypeToString", (PFN_xrVoidFunction*)&table->StructureTypeToString)); - (get_inst_proc_addr(instance, "xrGetSystem", (PFN_xrVoidFunction*)&table->GetSystem)); - (get_inst_proc_addr(instance, "xrGetSystemProperties", (PFN_xrVoidFunction*)&table->GetSystemProperties)); - (get_inst_proc_addr(instance, "xrEnumerateEnvironmentBlendModes", (PFN_xrVoidFunction*)&table->EnumerateEnvironmentBlendModes)); - (get_inst_proc_addr(instance, "xrCreateSession", (PFN_xrVoidFunction*)&table->CreateSession)); - (get_inst_proc_addr(instance, "xrDestroySession", (PFN_xrVoidFunction*)&table->DestroySession)); - (get_inst_proc_addr(instance, "xrEnumerateReferenceSpaces", (PFN_xrVoidFunction*)&table->EnumerateReferenceSpaces)); - (get_inst_proc_addr(instance, "xrCreateReferenceSpace", (PFN_xrVoidFunction*)&table->CreateReferenceSpace)); - (get_inst_proc_addr(instance, "xrGetReferenceSpaceBoundsRect", (PFN_xrVoidFunction*)&table->GetReferenceSpaceBoundsRect)); - (get_inst_proc_addr(instance, "xrCreateActionSpace", (PFN_xrVoidFunction*)&table->CreateActionSpace)); - (get_inst_proc_addr(instance, "xrLocateSpace", (PFN_xrVoidFunction*)&table->LocateSpace)); - (get_inst_proc_addr(instance, "xrDestroySpace", (PFN_xrVoidFunction*)&table->DestroySpace)); - (get_inst_proc_addr(instance, "xrEnumerateViewConfigurations", (PFN_xrVoidFunction*)&table->EnumerateViewConfigurations)); - (get_inst_proc_addr(instance, "xrGetViewConfigurationProperties", (PFN_xrVoidFunction*)&table->GetViewConfigurationProperties)); - (get_inst_proc_addr(instance, "xrEnumerateViewConfigurationViews", (PFN_xrVoidFunction*)&table->EnumerateViewConfigurationViews)); - (get_inst_proc_addr(instance, "xrEnumerateSwapchainFormats", (PFN_xrVoidFunction*)&table->EnumerateSwapchainFormats)); - (get_inst_proc_addr(instance, "xrCreateSwapchain", (PFN_xrVoidFunction*)&table->CreateSwapchain)); - (get_inst_proc_addr(instance, "xrDestroySwapchain", (PFN_xrVoidFunction*)&table->DestroySwapchain)); - (get_inst_proc_addr(instance, "xrEnumerateSwapchainImages", (PFN_xrVoidFunction*)&table->EnumerateSwapchainImages)); - (get_inst_proc_addr(instance, "xrAcquireSwapchainImage", (PFN_xrVoidFunction*)&table->AcquireSwapchainImage)); - (get_inst_proc_addr(instance, "xrWaitSwapchainImage", (PFN_xrVoidFunction*)&table->WaitSwapchainImage)); - (get_inst_proc_addr(instance, "xrReleaseSwapchainImage", (PFN_xrVoidFunction*)&table->ReleaseSwapchainImage)); - (get_inst_proc_addr(instance, "xrBeginSession", (PFN_xrVoidFunction*)&table->BeginSession)); - (get_inst_proc_addr(instance, "xrEndSession", (PFN_xrVoidFunction*)&table->EndSession)); - (get_inst_proc_addr(instance, "xrRequestExitSession", (PFN_xrVoidFunction*)&table->RequestExitSession)); - (get_inst_proc_addr(instance, "xrWaitFrame", (PFN_xrVoidFunction*)&table->WaitFrame)); - (get_inst_proc_addr(instance, "xrBeginFrame", (PFN_xrVoidFunction*)&table->BeginFrame)); - (get_inst_proc_addr(instance, "xrEndFrame", (PFN_xrVoidFunction*)&table->EndFrame)); - (get_inst_proc_addr(instance, "xrLocateViews", (PFN_xrVoidFunction*)&table->LocateViews)); - (get_inst_proc_addr(instance, "xrStringToPath", (PFN_xrVoidFunction*)&table->StringToPath)); - (get_inst_proc_addr(instance, "xrPathToString", (PFN_xrVoidFunction*)&table->PathToString)); - (get_inst_proc_addr(instance, "xrCreateActionSet", (PFN_xrVoidFunction*)&table->CreateActionSet)); - (get_inst_proc_addr(instance, "xrDestroyActionSet", (PFN_xrVoidFunction*)&table->DestroyActionSet)); - (get_inst_proc_addr(instance, "xrCreateAction", (PFN_xrVoidFunction*)&table->CreateAction)); - (get_inst_proc_addr(instance, "xrDestroyAction", (PFN_xrVoidFunction*)&table->DestroyAction)); - (get_inst_proc_addr(instance, "xrSuggestInteractionProfileBindings", (PFN_xrVoidFunction*)&table->SuggestInteractionProfileBindings)); - (get_inst_proc_addr(instance, "xrAttachSessionActionSets", (PFN_xrVoidFunction*)&table->AttachSessionActionSets)); - (get_inst_proc_addr(instance, "xrGetCurrentInteractionProfile", (PFN_xrVoidFunction*)&table->GetCurrentInteractionProfile)); - (get_inst_proc_addr(instance, "xrGetActionStateBoolean", (PFN_xrVoidFunction*)&table->GetActionStateBoolean)); - (get_inst_proc_addr(instance, "xrGetActionStateFloat", (PFN_xrVoidFunction*)&table->GetActionStateFloat)); - (get_inst_proc_addr(instance, "xrGetActionStateVector2f", (PFN_xrVoidFunction*)&table->GetActionStateVector2f)); - (get_inst_proc_addr(instance, "xrGetActionStatePose", (PFN_xrVoidFunction*)&table->GetActionStatePose)); - (get_inst_proc_addr(instance, "xrSyncActions", (PFN_xrVoidFunction*)&table->SyncActions)); - (get_inst_proc_addr(instance, "xrEnumerateBoundSourcesForAction", (PFN_xrVoidFunction*)&table->EnumerateBoundSourcesForAction)); - (get_inst_proc_addr(instance, "xrGetInputSourceLocalizedName", (PFN_xrVoidFunction*)&table->GetInputSourceLocalizedName)); - (get_inst_proc_addr(instance, "xrApplyHapticFeedback", (PFN_xrVoidFunction*)&table->ApplyHapticFeedback)); - (get_inst_proc_addr(instance, "xrStopHapticFeedback", (PFN_xrVoidFunction*)&table->StopHapticFeedback)); - - // ---- XR_EXT_debug_utils extension commands - (get_inst_proc_addr(instance, "xrSetDebugUtilsObjectNameEXT", (PFN_xrVoidFunction*)&table->SetDebugUtilsObjectNameEXT)); - (get_inst_proc_addr(instance, "xrCreateDebugUtilsMessengerEXT", (PFN_xrVoidFunction*)&table->CreateDebugUtilsMessengerEXT)); - (get_inst_proc_addr(instance, "xrDestroyDebugUtilsMessengerEXT", (PFN_xrVoidFunction*)&table->DestroyDebugUtilsMessengerEXT)); - (get_inst_proc_addr(instance, "xrSubmitDebugUtilsMessageEXT", (PFN_xrVoidFunction*)&table->SubmitDebugUtilsMessageEXT)); - (get_inst_proc_addr(instance, "xrSessionBeginDebugUtilsLabelRegionEXT", (PFN_xrVoidFunction*)&table->SessionBeginDebugUtilsLabelRegionEXT)); - (get_inst_proc_addr(instance, "xrSessionEndDebugUtilsLabelRegionEXT", (PFN_xrVoidFunction*)&table->SessionEndDebugUtilsLabelRegionEXT)); - (get_inst_proc_addr(instance, "xrSessionInsertDebugUtilsLabelEXT", (PFN_xrVoidFunction*)&table->SessionInsertDebugUtilsLabelEXT)); -} - - -#ifdef __cplusplus -} // extern "C" -#endif - diff --git a/thirdparty/openxr/src/xr_generated_dispatch_table_core.h b/thirdparty/openxr/src/xr_generated_dispatch_table_core.h deleted file mode 100644 index 0f3e7e0502..0000000000 --- a/thirdparty/openxr/src/xr_generated_dispatch_table_core.h +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. -// Copyright (c) 2017-2019, Valve Corporation -// Copyright (c) 2017-2019, LunarG, Inc. - -// SPDX-License-Identifier: Apache-2.0 OR MIT - -// *********** THIS FILE IS GENERATED - DO NOT EDIT *********** -// See utility_source_generator.py for modifications -// ************************************************************ - -// Copyright (c) 2017-2023, The Khronos Group Inc. -// Copyright (c) 2017-2019 Valve Corporation -// Copyright (c) 2017-2019 LunarG, Inc. -// -// SPDX-License-Identifier: Apache-2.0 -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Author: Mark Young <marky@lunarg.com> -// - -#pragma once - -#include <openxr/openxr.h> - - -#ifdef __cplusplus -extern "C" { -#endif -// Generated dispatch table -struct XrGeneratedDispatchTable { - - // ---- Core 1.0 commands - PFN_xrGetInstanceProcAddr GetInstanceProcAddr; - PFN_xrEnumerateApiLayerProperties EnumerateApiLayerProperties; - PFN_xrEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties; - PFN_xrCreateInstance CreateInstance; - PFN_xrDestroyInstance DestroyInstance; - PFN_xrGetInstanceProperties GetInstanceProperties; - PFN_xrPollEvent PollEvent; - PFN_xrResultToString ResultToString; - PFN_xrStructureTypeToString StructureTypeToString; - PFN_xrGetSystem GetSystem; - PFN_xrGetSystemProperties GetSystemProperties; - PFN_xrEnumerateEnvironmentBlendModes EnumerateEnvironmentBlendModes; - PFN_xrCreateSession CreateSession; - PFN_xrDestroySession DestroySession; - PFN_xrEnumerateReferenceSpaces EnumerateReferenceSpaces; - PFN_xrCreateReferenceSpace CreateReferenceSpace; - PFN_xrGetReferenceSpaceBoundsRect GetReferenceSpaceBoundsRect; - PFN_xrCreateActionSpace CreateActionSpace; - PFN_xrLocateSpace LocateSpace; - PFN_xrDestroySpace DestroySpace; - PFN_xrEnumerateViewConfigurations EnumerateViewConfigurations; - PFN_xrGetViewConfigurationProperties GetViewConfigurationProperties; - PFN_xrEnumerateViewConfigurationViews EnumerateViewConfigurationViews; - PFN_xrEnumerateSwapchainFormats EnumerateSwapchainFormats; - PFN_xrCreateSwapchain CreateSwapchain; - PFN_xrDestroySwapchain DestroySwapchain; - PFN_xrEnumerateSwapchainImages EnumerateSwapchainImages; - PFN_xrAcquireSwapchainImage AcquireSwapchainImage; - PFN_xrWaitSwapchainImage WaitSwapchainImage; - PFN_xrReleaseSwapchainImage ReleaseSwapchainImage; - PFN_xrBeginSession BeginSession; - PFN_xrEndSession EndSession; - PFN_xrRequestExitSession RequestExitSession; - PFN_xrWaitFrame WaitFrame; - PFN_xrBeginFrame BeginFrame; - PFN_xrEndFrame EndFrame; - PFN_xrLocateViews LocateViews; - PFN_xrStringToPath StringToPath; - PFN_xrPathToString PathToString; - PFN_xrCreateActionSet CreateActionSet; - PFN_xrDestroyActionSet DestroyActionSet; - PFN_xrCreateAction CreateAction; - PFN_xrDestroyAction DestroyAction; - PFN_xrSuggestInteractionProfileBindings SuggestInteractionProfileBindings; - PFN_xrAttachSessionActionSets AttachSessionActionSets; - PFN_xrGetCurrentInteractionProfile GetCurrentInteractionProfile; - PFN_xrGetActionStateBoolean GetActionStateBoolean; - PFN_xrGetActionStateFloat GetActionStateFloat; - PFN_xrGetActionStateVector2f GetActionStateVector2f; - PFN_xrGetActionStatePose GetActionStatePose; - PFN_xrSyncActions SyncActions; - PFN_xrEnumerateBoundSourcesForAction EnumerateBoundSourcesForAction; - PFN_xrGetInputSourceLocalizedName GetInputSourceLocalizedName; - PFN_xrApplyHapticFeedback ApplyHapticFeedback; - PFN_xrStopHapticFeedback StopHapticFeedback; - - // ---- XR_EXT_debug_utils extension commands - PFN_xrSetDebugUtilsObjectNameEXT SetDebugUtilsObjectNameEXT; - PFN_xrCreateDebugUtilsMessengerEXT CreateDebugUtilsMessengerEXT; - PFN_xrDestroyDebugUtilsMessengerEXT DestroyDebugUtilsMessengerEXT; - PFN_xrSubmitDebugUtilsMessageEXT SubmitDebugUtilsMessageEXT; - PFN_xrSessionBeginDebugUtilsLabelRegionEXT SessionBeginDebugUtilsLabelRegionEXT; - PFN_xrSessionEndDebugUtilsLabelRegionEXT SessionEndDebugUtilsLabelRegionEXT; - PFN_xrSessionInsertDebugUtilsLabelEXT SessionInsertDebugUtilsLabelEXT; -}; - - -// Prototype for dispatch table helper function -void GeneratedXrPopulateDispatchTable(struct XrGeneratedDispatchTable *table, - XrInstance instance, - PFN_xrGetInstanceProcAddr get_inst_proc_addr); - -#ifdef __cplusplus -} // extern "C" -#endif - |
